Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Options
Browse files Browse the repository at this point in the history
  • Loading branch information
cuckydev committed Jun 29, 2021
1 parent fb9d6e9 commit 2fdffae
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ void Gfx_DrawTexCol(Gfx_Tex *tex, const RECT *src, const RECT *dst, u8 r, u8 g,
memcpy(&csrc, src, sizeof(RECT));
memcpy(&cdst, dst, sizeof(RECT));

if (dst->w < 0)
csrc.x--;
if (dst->h < 0)
csrc.y--;

if ((csrc.x + csrc.w) >= 0x100)
{
csrc.w = 0xFF - csrc.x;
Expand Down
102 changes: 101 additions & 1 deletion src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void Menu_Tick(void)
menu.next_page = MenuPage_Mods;
break;
case 3: //Options
menu.next_page = MenuPage_Main;//Options;
menu.next_page = MenuPage_Options;
break;
}
menu.next_select = 0;
Expand Down Expand Up @@ -830,6 +830,106 @@ void Menu_Tick(void)
);
break;
}
case MenuPage_Options:
{
static const struct
{
enum
{
OptType_Boolean,
} type;
const char *text;
void *value;
} menu_options[] = {
{OptType_Boolean, "DOWNSCROLL", &stage.downscroll},
};

//Initialize page
if (menu.page_swap)
menu.scroll = -(COUNT_OF(menu_options) * 24 + SCREEN_HEIGHT2);

//Draw page label
menu.font_bold.draw(&menu.font_bold,
"OPTIONS",
16,
SCREEN_HEIGHT - 32,
FontAlign_Left
);

//Handle option and selection
if (menu.next_page == menu.page && Trans_Idle())
{
//Change option
if (pad_state.press & PAD_UP)
{
if (menu.select > 0)
menu.select--;
else
menu.select = COUNT_OF(menu_options) - 1;
}
if (pad_state.press & PAD_DOWN)
{
if (menu.select < COUNT_OF(menu_options) - 1)
menu.select++;
else
menu.select = 0;
}

//Handle option changing
switch (menu_options[menu.select].type)
{
case OptType_Boolean:
if (pad_state.press & (PAD_CROSS | PAD_LEFT | PAD_RIGHT))
*((boolean*)menu_options[menu.select].value) ^= 1;
break;
}

//Return to main menu if circle is pressed
if (pad_state.press & PAD_CIRCLE)
{
menu.next_page = MenuPage_Main;
menu.next_select = 3; //Options
Trans_Start();
}
}

//Draw options
menu.scroll += (((s32)menu.select * -24) - menu.scroll) >> 4;

for (u8 i = 0; i < COUNT_OF(menu_options); i++)
{
//Get position on screen
s32 y = (i * 24) - 8 + menu.scroll;
if (y <= -SCREEN_HEIGHT2 - 8)
continue;
if (y >= SCREEN_HEIGHT2 + 8)
break;

//Draw text
char text[0x80];
switch (menu_options[i].type)
{
case OptType_Boolean:
sprintf(text, "%s %s", menu_options[i].text, *((boolean*)menu_options[i].value) ? "ON" : "OFF");
menu.font_bold.draw(&menu.font_bold,
Menu_LowerIf(text, menu.select != i),
48 + (y >> 2),
SCREEN_HEIGHT2 + y - 8,
FontAlign_Left
);
break;
}
}

//Draw background
Menu_DrawBack(
true,
-8,
253 >> 1, 113 >> 1, 155 >> 1,
0, 0, 0
);
break;
}
case MenuPage_Stage:
{
//Unload menu state
Expand Down
16 changes: 7 additions & 9 deletions src/stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
//Stage constants
//#define STAGE_PERFECT //Play all notes perfectly

boolean downscroll = false;

//Stage definitions
#include "character/bf.h"
#include "character/gf.h"
Expand Down Expand Up @@ -795,7 +793,7 @@ void Stage_DrawHealth(u8 i, s8 ox)
src.w << FIXED_SHIFT,
src.h << FIXED_SHIFT
};
if (downscroll)
if (stage.downscroll)
dst.y = -dst.y - dst.h;

//Draw health icon
Expand Down Expand Up @@ -899,7 +897,7 @@ void Stage_DrawNotes()
note_src.w << FIXED_SHIFT,
(note_src.h << FIXED_SHIFT)
};
if (downscroll)
if (stage.downscroll)
{
note_dst.y = -note_dst.y;
note_dst.h = -note_dst.h;
Expand All @@ -923,7 +921,7 @@ void Stage_DrawNotes()
note_src.w << FIXED_SHIFT,
scroll.size - clip
};
if (downscroll)
if (stage.downscroll)
note_dst.y = -note_dst.y - note_dst.h;
Stage_DrawTex(&stage.tex_hud0, &note_src, &note_dst, stage.bump);
}
Expand All @@ -942,7 +940,7 @@ void Stage_DrawNotes()
note_src.w << FIXED_SHIFT,
note_src.h << FIXED_SHIFT
};
if (downscroll)
if (stage.downscroll)
note_dst.y = -note_dst.y - note_dst.h;
Stage_DrawTex(&stage.tex_hud0, &note_src, &note_dst, stage.bump);
}
Expand Down Expand Up @@ -1333,7 +1331,7 @@ void Stage_Tick()
//Display score
RECT score_src = {80, 224, 40, 10};
RECT_FIXED score_dst = {FIXED_DEC(14,1), (SCREEN_HEIGHT2 - 42) << FIXED_SHIFT, FIXED_DEC(40,1), FIXED_DEC(10,1)};
if (downscroll)
if (stage.downscroll)
score_dst.y = -score_dst.y - score_dst.h;

Stage_DrawTex(&stage.tex_hud0, &score_src, &score_dst, stage.bump);
Expand Down Expand Up @@ -1390,7 +1388,7 @@ void Stage_Tick()
RECT health_fill = {0, 0, 256 - (256 * stage.health / 20000), 8};
RECT health_back = {0, 8, 256, 8};
RECT_FIXED health_dst = {FIXED_DEC(-128,1), (SCREEN_HEIGHT2 - 32) << FIXED_SHIFT, 0, FIXED_DEC(8,1)};
if (downscroll)
if (stage.downscroll)
health_dst.y = -health_dst.y - health_dst.h;

health_dst.w = health_fill.w << FIXED_SHIFT;
Expand All @@ -1404,7 +1402,7 @@ void Stage_Tick()
//Draw note HUD
RECT note_src = {0, 0, 32, 32};
RECT_FIXED note_dst = {0, note_y - FIXED_DEC(16,1), FIXED_DEC(32,1), FIXED_DEC(32,1)};
if (downscroll)
if (stage.downscroll)
note_dst.y = -note_dst.y - note_dst.h;

for (u8 i = 0; i < 4; i++)
Expand Down
3 changes: 3 additions & 0 deletions src/stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ typedef struct

typedef struct
{
//Stage settings
boolean downscroll;

//HUD textures
Gfx_Tex tex_hud0, tex_hud1;

Expand Down

0 comments on commit 2fdffae

Please sign in to comment.