From 0deba65a953ddde55a71d73653704993cfc853db Mon Sep 17 00:00:00 2001 From: TheWindowsPro98 Date: Wed, 23 Aug 2023 20:34:59 -0500 Subject: [PATCH] Add preferences screen Do not be alarmed at how bare it is, it's not like there's anything to change anyway. --- inc/main.h | 6 +- res/aseprite/stephanie.aseprite | Bin 1320 -> 1316 bytes res/tiles/font_menu.png | Bin 1058 -> 1806 bytes src/boot/rom_head.c | 6 +- src/main.c | 11 ++- src/prefs.c | 164 +++++++++++++++++++++++++++----- 6 files changed, 155 insertions(+), 32 deletions(-) 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 e8bc4708d199cf589e9d35ea0648bfa0af822b7f..35c750d76cd4dad0e3f838014d3c7c90e5a86eb2 100755 GIT binary patch delta 197 zcmZ3%wSQ-~apMMqs3${>BLf2i zs{$hf7lSaveZW7%Ju@CnO}KrMU@2%m@(j+PGl@gQuLFoWjXd$GB8(-nbzl z!62N^uyC_DvooWgA5a^s0tW*p10#|#d<=Y0V;-orN z4s7OUc4qYQVqjokRp4OYWME|Y&jjRv0UrY|)WipD%xoMC8z0mduugXCaJ+KB^ZBi&bYbeE8)!vHJ@D(|}V(8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/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);