diff --git a/inc/main.h b/inc/main.h index 77d0e65..fac0f37 100755 --- a/inc/main.h +++ b/inc/main.h @@ -21,9 +21,9 @@ extern fix16* scrollSpeed; extern Sprite* menuCursor; #define MUSIC_FADE MDS_fade(127,7,TRUE) -#define PAL_FADE_OUT PAL_fadeOutAll(palFadeTime,TRUE); -#define CLEAR_BG1 VDP_clearPlane(BG_A,TRUE); -#define CLEAR_BG2 VDP_clearPlane(BG_B,TRUE); +#define PAL_FADE_OUT PAL_fadeOutAll(palFadeTime,TRUE) +#define CLEAR_BG1 VDP_clearPlane(BG_A,TRUE) +#define CLEAR_BG2 VDP_clearPlane(BG_B,TRUE) #define TILE_TO_PIXEL(tile) (tile << 3) #define SELECTION_SFX MDS_request(MDS_SE1,BGM_SFX_S1SELECT) #define SIZEOF_8BIT 1 diff --git a/res/aseprite/stephanie.aseprite b/res/aseprite/stephanie.aseprite index e8bc470..35c750d 100755 Binary files a/res/aseprite/stephanie.aseprite and b/res/aseprite/stephanie.aseprite differ diff --git a/res/tiles/font_menu.png b/res/tiles/font_menu.png index 7b9fa69..d8f878e 100755 Binary files a/res/tiles/font_menu.png and b/res/tiles/font_menu.png differ diff --git a/src/boot/rom_head.c b/src/boot/rom_head.c index 31f7cf5..f3e3714 100755 --- a/src/boot/rom_head.c +++ b/src/boot/rom_head.c @@ -10,8 +10,8 @@ const ROMHeader rom_header = { "SEGA MEGA DRIVE ", #endif "(C)RD23 2023.AUG", - "PROJECT DAISY MEGADRIVE BUILD 20230821", - "PROJECT DAISY GENESIS BUILD 20230821", + "PROJECT DAISY MEGADRIVE BUILD 20230823", + "PROJECT DAISY GENESIS BUILD 20230823", "GM 88688463-00", 0x000, "JD ", @@ -28,6 +28,6 @@ const ROMHeader rom_header = { 0x00200000, 0x0020FFFF, " ", - "192 days remaining; it's a new day ", + "190 days remaining; it's a new day ", "JUE " }; diff --git a/src/main.c b/src/main.c index c0642c6..d759633 100755 --- a/src/main.c +++ b/src/main.c @@ -23,8 +23,8 @@ fix16* scrollSpeed; void fadePalette(const u16* palette) { u16 finalPalette[64]; - memcpy(finalPalette,palette,48*sizeof(u16)); - memcpy(&finalPalette[48],playerPalettes[1],16*sizeof(u16)); + memcpy(finalPalette,palette,48*SIZEOF_16BIT); + memcpy(&finalPalette[48],playerPalettes[1],16*SIZEOF_16BIT); PAL_fadeInAll(finalPalette,palFadeTime,TRUE); } @@ -38,7 +38,7 @@ void drawMenu(const Option* option, u8 length, u8 paletteLine, u8 plane) VDP_drawText(o.label,o.x,o.y); } u16 basetile = TILE_ATTR(paletteLine,FALSE,FALSE,FALSE); - currentIndex = MEM_alloc(sizeof(u8)); + currentIndex = MEM_alloc(SIZEOF_8BIT); menuCursor = SPR_addSprite(&cursor,TILE_TO_PIXEL(option[*currentIndex].x) - 8,TILE_TO_PIXEL(option[*currentIndex].y),basetile); } @@ -73,6 +73,7 @@ void curMove(const Option* option, u8 length, bool direction) static void selectOption_Title() { SELECTION_SFX; + JOY_setEventHandler(NULL); u8 timer = palFadeTime; PAL_FADE_OUT; MUSIC_FADE; @@ -92,6 +93,8 @@ static void selectOption_Title() { case 3: { + MEM_free(currentIndex); + currentIndex = NULL; preferences(); break; } @@ -163,7 +166,7 @@ void title() VDP_drawImageEx(BG_B,&title_bg,basetileBG,0,0,FALSE,TRUE); VDP_setTextPalette(PAL3); VDP_drawText("}TheWindowsPro98 2023",9,y); - VDP_drawText("Version ppa1.2",0,6); + VDP_drawText("Version ppa1.3",0,6); VDP_drawText("Press START button",11,14); fadePalette(titlePalette); JOY_setEventHandler(joyEvent_Title); diff --git a/src/prefs.c b/src/prefs.c index 9cd96ca..cc6b737 100755 --- a/src/prefs.c +++ b/src/prefs.c @@ -4,61 +4,156 @@ const u8 optX = 10; const u8 optY = 8; const u8 optNum = 9; const u8 optXDelta = 13; +const u8 sfxStart = 4; bool player = TRUE; // 0 - Lucy, 1 - Stephanie -u8 difficulty = 1; // 0 - Easy, 1 - Normal, 2 - Hard, 3 - Cement (name subject to change) +u8 difficulty = 1; // 0 - Easy, 1 - Normal, 2 - Hard, 3 - Hardest Sprite* confCurDiff; Sprite* confCurChr; +u8 lives = 5; const Option menuPrefs[] = { - {optX+optXDelta, optY, "Easy"}, - {optX+optXDelta, optY+1, "Normal"}, - {optX+optXDelta, optY+2, "Hard"}, - {optX+optXDelta, optY+3, "Cement"}, + {optX+optXDelta, optY, "Sissy"}, + {optX+optXDelta, optY+1, "Average"}, + {optX+optXDelta, optY+2, "Honors"}, + {optX+optXDelta, optY+3, "Hell^"}, {optX+optXDelta, optY+5, "Lucy"}, {optX+optXDelta, optY+6, "Stephanie"}, - {optX+optXDelta, optY+8, "00"}, + {optX+optXDelta, optY+8, "05"}, {optX+optXDelta, optY+9, "00"}, {optX+(optXDelta >> 1) + 1, optY+12, "Exit"}, }; -void selectOption_Prefs() +static void selectorMove(bool type) +{ + u8 szStr = strlen(menuPrefs[*currentIndex].label); + if (!type) + { + SPR_setPosition(confCurDiff,TILE_TO_PIXEL(menuPrefs[*currentIndex].x + szStr),TILE_TO_PIXEL(menuPrefs[*currentIndex].y)); + difficulty = *currentIndex; + } + else + { + SPR_setPosition(confCurChr,TILE_TO_PIXEL(menuPrefs[*currentIndex].x + szStr),TILE_TO_PIXEL(menuPrefs[*currentIndex].y)); + player = *currentIndex - 4; + } +} + +static void selectOption_Prefs() { SELECTION_SFX; - u8 timer = palFadeTime; - PAL_FADE_OUT; - MUSIC_FADE; - while(1) + switch (*currentIndex) { - timer--; - SYS_doVBlankProcess(); - MDS_update(); - if (timer == 0) + case 6: + { + break; + } + case 7: + { + if (*musIndex < sfxStart) { - SPR_releaseSprite(menuCursor); - SPR_update(); - break; + MDS_request(MDS_BGM,*musIndex); } + else + { + MDS_request(MDS_SE1,*musIndex); + } + break; } - switch (*currentIndex) - { case 8: { + JOY_setEventHandler(NULL); + u8 timer = palFadeTime; + PAL_FADE_OUT; + MUSIC_FADE; + while(1) + { + timer--; + SYS_doVBlankProcess(); + MDS_update(); + if (timer == 0) + { + SPR_releaseSprite(menuCursor); + SPR_update(); + break; + } + } CLEAR_BG2; SPR_reset(); MEM_free(currentIndex); + currentIndex = NULL; MEM_free(musIndex); + musIndex = NULL; title(); break; } default: { + if (*currentIndex < 4) + { + selectorMove(FALSE); + break; + } + else if (*currentIndex < 6) + { + selectorMove(TRUE); + break; + } + JOY_setEventHandler(NULL); + u8 timer = palFadeTime; + PAL_FADE_OUT; + MUSIC_FADE; + while(1) + { + timer--; + SYS_doVBlankProcess(); + MDS_update(); + if (timer == 0) + { + SPR_releaseSprite(menuCursor); + SPR_update(); + break; + } + } killExec(menuIndexInvalid); break; } } } +static void drawMenuHex(bool direction, bool type) +{ + SELECTION_SFX; + char hexStr[3] = "00"; + if (!direction) + { + if (!type) + { + lives--; + intToHex(lives,hexStr,2); + } + else + { + *musIndex -= 1; + intToHex(*musIndex,hexStr,2); + } + } + else + { + if (!type) + { + lives++; + intToHex(lives,hexStr,2); + } + else + { + *musIndex += 1; + intToHex(*musIndex,hexStr,2); + } + } + VDP_drawText(hexStr,menuPrefs[*currentIndex].x,menuPrefs[*currentIndex].y); +} + static void joyEvent_Prefs(u16 joy, u16 changed, u16 state) { if (joy != JOY_1) @@ -73,6 +168,28 @@ static void joyEvent_Prefs(u16 joy, u16 changed, u16 state) { curMove(menuPrefs,optNum,TRUE); } + if (changed & state & BUTTON_LEFT) + { + if (*currentIndex == 6) + { + drawMenuHex(FALSE,FALSE); + } + else if (*currentIndex == 7) + { + drawMenuHex(FALSE,TRUE); + } + } + else if (changed & state & BUTTON_RIGHT) + { + if (*currentIndex == 6) + { + drawMenuHex(TRUE,FALSE); + } + else if (*currentIndex == 7) + { + drawMenuHex(TRUE,TRUE); + } + } if (changed & state & BUTTON_B) { *currentIndex = 8; @@ -87,6 +204,8 @@ static void joyEvent_Prefs(u16 joy, u16 changed, u16 state) void preferences() { u16 basetile = TILE_ATTR(PAL3,FALSE,FALSE,FALSE); + u8 diffStrLen = strlen(menuPrefs[difficulty].label); + u8 chrStrLen = strlen(menuPrefs[player + 4].label); CLEAR_BG1; VDP_drawText("Changes made will only take effect",2,0); VDP_drawText("upon starting a new game.",2,1); @@ -95,8 +214,9 @@ void preferences() VDP_drawText("Lives:",optX,optY+8); VDP_drawText("Sound Test:",optX,optY+9); drawMenu(menuPrefs,optNum,PAL3,BG_A); - confCurDiff = SPR_addSprite(&heart,TILE_TO_PIXEL((menuPrefs[difficulty].x + 6)),TILE_TO_PIXEL(menuPrefs[difficulty].y),basetile); - confCurDiff = SPR_addSprite(&heart,TILE_TO_PIXEL((menuPrefs[player].x + 9)),TILE_TO_PIXEL(menuPrefs[player + 4].y),basetile); + confCurDiff = SPR_addSprite(&heart,TILE_TO_PIXEL((menuPrefs[difficulty].x + diffStrLen)),TILE_TO_PIXEL(menuPrefs[difficulty].y),basetile); + confCurChr = SPR_addSprite(&heart,TILE_TO_PIXEL((menuPrefs[player].x + chrStrLen)),TILE_TO_PIXEL(menuPrefs[player + 4].y),basetile); + musIndex = MEM_alloc(SIZEOF_8BIT); JOY_setEventHandler(joyEvent_Prefs); fadePalette(titlePalette); MDS_request(MDS_BGM,BGM_MUS_S2BLVS);