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

Commit

Permalink
Add preferences page
Browse files Browse the repository at this point in the history
It doesn't really do much yet.
  • Loading branch information
TheWindowsPro98 committed Aug 22, 2023
1 parent 992c556 commit a767062
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 17 deletions.
1 change: 1 addition & 0 deletions inc/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#include "spr.h"
#include "mdsdat.h"
#include "mdsdrv.h"
#include "prefs.h"
#include "main.h"
#include "bsod.h"
14 changes: 13 additions & 1 deletion inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ extern u8 palFadeTime;
extern u8 vblankRate;
extern const u8* region;
extern u8* currentIndex;
extern u8* musIndex;
extern fix16* scroll;
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 TILE_TO_PIXEL(tile) (tile << 3)
#define SELECTION_SFX MDS_request(MDS_SE1,BGM_SFX_S1SELECT)
#define SELECTION_SFX MDS_request(MDS_SE1,BGM_SFX_S1SELECT)
#define SIZEOF_8BIT 1
#define SIZEOF_16BIT 2
#define SIZEOF_32BIT 4

void fadePalette(const u16* palette);
void drawMenu(const Option* option, u8 length, u8 paletteLine, u8 plane);
void curMove(const Option* option, u8 length, bool direction);
void title();
3 changes: 3 additions & 0 deletions inc/prefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void preferences();
Binary file modified res/mdsbin.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions res/mdsdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _RES_MDSDAT_H_

extern const u8 mdsdrvdat[8202];
extern const u8 mdsseqdat[2176];
extern const u8 mdspcmdat[61516];
extern const u8 mdsseqdat[2206];
extern const u8 mdspcmdat[64538];

#endif // _RES_MDSDAT_H_
Binary file modified res/mdsseq.bin
Binary file not shown.
Binary file modified res/mus/mus_s2blvs.mds
Binary file not shown.
Binary file modified res/mus/mus_s3clear.mds
Binary file not shown.
1 change: 1 addition & 0 deletions res/spr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define _RES_SPR_H_

extern const SpriteDefinition cursor;
extern const SpriteDefinition heart;

#endif // _RES_SPR_H_
3 changes: 2 additions & 1 deletion res/spr.res
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SPRITE cursor "spr/cursor.png" 1 1 BEST 0
SPRITE cursor "spr/cursor.png" 1 1 BEST 0
SPRITE heart "spr/heart.png" 1 1 BEST 0
Binary file modified res/spr/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/spr/heart.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 20230820",
"PROJECT DAISY GENESIS BUILD 20230820",
"PROJECT DAISY MEGADRIVE BUILD 20230821",
"PROJECT DAISY GENESIS BUILD 20230821",
"GM 88688463-00",
0x000,
"JD ",
Expand All @@ -28,6 +28,6 @@ const ROMHeader rom_header = {
0x00200000,
0x0020FFFF,
" ",
"193 days remaining; it's a new day ",
"192 days remaining; it's a new day ",
"JUE "
};
27 changes: 17 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ const Option menuTitle[] =
Sprite* menuCursor;
u8* currentIndex;
u8* musIndex;
fix16* scroll;
fix16* scrollSpeed;

static void fadePalette(const u16* palette)
void fadePalette(const u16* palette)
{
u16 finalPalette[64];
memcpy(finalPalette,palette,48*sizeof(u16));
memcpy(&finalPalette[48],playerPalettes[1],16*sizeof(u16));
PAL_fadeInAll(finalPalette,palFadeTime,TRUE);
}

static void drawMenu(const Option* option, u8 length, u8 paletteLine, u8 plane)
void drawMenu(const Option* option, u8 length, u8 paletteLine, u8 plane)
{
VDP_setTextPalette(paletteLine);
VDP_setTextPlane(plane);
Expand All @@ -40,7 +42,7 @@ static void drawMenu(const Option* option, u8 length, u8 paletteLine, u8 plane)
menuCursor = SPR_addSprite(&cursor,TILE_TO_PIXEL(option[*currentIndex].x) - 8,TILE_TO_PIXEL(option[*currentIndex].y),basetile);
}

static void curMove(const Option* option, u8 length, bool direction)
void curMove(const Option* option, u8 length, bool direction)
{
SELECTION_SFX;
if (!direction)
Expand Down Expand Up @@ -88,6 +90,11 @@ static void selectOption_Title()
}
switch (*currentIndex)
{
case 3:
{
preferences();
break;
}
default:
{
killExec(menuIndexInvalid);
Expand Down Expand Up @@ -131,24 +138,24 @@ static void joyEvent_Title(u16 joy, u16 changed, u16 state)
}
}

static void title()
void title()
{
s16 indLogo = TILE_USER_INDEX;
s16 indBG = indLogo + title_logo.tileset->numTile;
u16 basetileLogo = TILE_ATTR_FULL(PAL0,FALSE,FALSE,FALSE,indLogo);
u16 basetileBG = TILE_ATTR_FULL(PAL1,FALSE,FALSE,FALSE,indBG);
fix16 scroll = FIX16(0);
fix16 scrollSpeed;
u8 y;
scroll = MEM_alloc(SIZEOF_16BIT);
scrollSpeed = MEM_alloc(SIZEOF_16BIT);
if (isNTSC)
{
y = 27;
scrollSpeed = FIX16(1.0/3.0);
*scrollSpeed = FIX16(1.0/3.0);
}
else
{
y = 29;
scrollSpeed = FIX16(0.4);
*scrollSpeed = FIX16(0.4);
}
CLEAR_BG1;
CLEAR_BG2;
Expand All @@ -163,11 +170,11 @@ static void title()
MDS_request(MDS_BGM,BGM_MUS_CLI2);
while (1)
{
scroll -= scrollSpeed;
*scroll -= *scrollSpeed;
SYS_doVBlankProcess();
SPR_update();
MDS_update();
VDP_setHorizontalScroll(BG_B,fix16ToInt(scroll));
VDP_setHorizontalScroll(BG_B,fix16ToInt(*scroll));
}
}

Expand Down
111 changes: 111 additions & 0 deletions src/prefs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "includes.h"

const u8 optX = 10;
const u8 optY = 8;
const u8 optNum = 9;
const u8 optXDelta = 13;
bool player = TRUE; // 0 - Lucy, 1 - Stephanie
u8 difficulty = 1; // 0 - Easy, 1 - Normal, 2 - Hard, 3 - Cement (name subject to change)
Sprite* confCurDiff;
Sprite* confCurChr;

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+5, "Lucy"},
{optX+optXDelta, optY+6, "Stephanie"},
{optX+optXDelta, optY+8, "00"},
{optX+optXDelta, optY+9, "00"},
{optX+(optXDelta >> 1) + 1, optY+12, "Exit"},
};

void selectOption_Prefs()
{
SELECTION_SFX;
u8 timer = palFadeTime;
PAL_FADE_OUT;
MUSIC_FADE;
while(1)
{
timer--;
SYS_doVBlankProcess();
MDS_update();
if (timer == 0)
{
SPR_releaseSprite(menuCursor);
SPR_update();
break;
}
}
switch (*currentIndex)
{
case 8:
{
CLEAR_BG2;
SPR_reset();
MEM_free(currentIndex);
MEM_free(musIndex);
title();
break;
}
default:
{
killExec(menuIndexInvalid);
break;
}
}
}

static void joyEvent_Prefs(u16 joy, u16 changed, u16 state)
{
if (joy != JOY_1)
{
return;
}
if (changed & state & BUTTON_UP)
{
curMove(menuPrefs,optNum,FALSE);
}
else if (changed & state & BUTTON_DOWN)
{
curMove(menuPrefs,optNum,TRUE);
}
if (changed & state & BUTTON_B)
{
*currentIndex = 8;
selectOption_Prefs();
}
if (changed & state & BUTTON_START)
{
selectOption_Prefs();
}
}

void preferences()
{
u16 basetile = TILE_ATTR(PAL3,FALSE,FALSE,FALSE);
CLEAR_BG1;
VDP_drawText("Changes made will only take effect",2,0);
VDP_drawText("upon starting a new game.",2,1);
VDP_drawText("Difficulty:",optX,optY);
VDP_drawText("Character:",optX,optY+5);
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);
JOY_setEventHandler(joyEvent_Prefs);
fadePalette(titlePalette);
MDS_request(MDS_BGM,BGM_MUS_S2BLVS);
while (1)
{
*scroll -= *scrollSpeed;
SYS_doVBlankProcess();
SPR_update();
MDS_update();
VDP_setHorizontalScroll(BG_B,fix16ToInt(*scroll));
}
}

0 comments on commit a767062

Please sign in to comment.