diff --git a/src/gfx.c b/src/gfx.c index 2cf92ae5..b4c2a89d 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -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; diff --git a/src/menu.c b/src/menu.c index daedac9c..47de1be9 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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; @@ -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 diff --git a/src/stage.c b/src/stage.c index 3abb672b..8bc3959e 100644 --- a/src/stage.c +++ b/src/stage.c @@ -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" @@ -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 @@ -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; @@ -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, ¬e_src, ¬e_dst, stage.bump); } @@ -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, ¬e_src, ¬e_dst, stage.bump); } @@ -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); @@ -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; @@ -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++) diff --git a/src/stage.h b/src/stage.h index 5c33da65..ace82a13 100644 --- a/src/stage.h +++ b/src/stage.h @@ -134,6 +134,9 @@ typedef struct typedef struct { + //Stage settings + boolean downscroll; + //HUD textures Gfx_Tex tex_hud0, tex_hud1;