Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Add preferences screen
Browse files Browse the repository at this point in the history
Do not be alarmed at how bare it is, it's not like there's anything to change anyway.
  • Loading branch information
TheWindowsPro98 committed Aug 24, 2023
1 parent a767062 commit 0deba65
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 32 deletions.
6 changes: 3 additions & 3 deletions inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified res/aseprite/stephanie.aseprite
Binary file not shown.
Binary file modified res/tiles/font_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/boot/rom_head.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand All @@ -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 "
};
11 changes: 7 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand All @@ -92,6 +93,8 @@ static void selectOption_Title()
{
case 3:
{
MEM_free(currentIndex);
currentIndex = NULL;
preferences();
break;
}
Expand Down Expand Up @@ -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);
Expand Down
164 changes: 142 additions & 22 deletions src/prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 0deba65

Please # to comment.