controls help screen
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 31 Oct 2022 23:09:45 +0000 (01:09 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 31 Oct 2022 23:09:45 +0000 (01:09 +0200)
Makefile
src/ctrlscr.c [new file with mode: 0644]
src/data.h
src/data.s
src/game.c
src/gamescr.c
src/menuscr.c

index f6b89a3..d690745 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,8 @@ data = data/color.raw data/color.pal data/color.gpal data/height.raw \
           data/spr_game.raw data/spr_game.pal data/spr_game.gpal \
           data/spr_logo.raw data/spr_logo.pal \
           data/menuscr.raw data/menuscr.pal data/menuscr.gpal \
-          data/spr_menu.raw data/spr_menu.pal
+          data/spr_menu.raw data/spr_menu.pal \
+          data/controls.raw data/controls.pal data/controls.gpal
 
 libs = libs/maxmod/libmm.a
 
diff --git a/src/ctrlscr.c b/src/ctrlscr.c
new file mode 100644 (file)
index 0000000..72aeeec
--- /dev/null
@@ -0,0 +1,68 @@
+#include "game.h"
+#include "data.h"
+#include "gba.h"
+#include "util.h"
+#include "dma.h"
+#include "input.h"
+#include "debug.h"
+
+static int ctrlscr_start(void);
+static void ctrlscr_stop(void);
+static void ctrlscr_frame(void);
+static void ctrlscr_vblank(void);
+
+static struct screen ctrlscr = {
+       "controls",
+       ctrlscr_start,
+       ctrlscr_stop,
+       ctrlscr_frame,
+       ctrlscr_vblank
+};
+
+struct screen *init_controls_screen(void)
+{
+       return &ctrlscr;
+}
+
+static void setup_palette(void)
+{
+       int i;
+       unsigned char *cmap = gba_colors ? controls_gba_cmap : controls_cmap;
+
+       for(i=0; i<256; i++) {
+               int r = cmap[i * 3];
+               int g = cmap[i * 3 + 1];
+               int b = cmap[i * 3 + 2];
+               gba_bgpal[i] = RGB555(r, g, b);
+       }
+}
+
+static int ctrlscr_start(void)
+{
+       gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ);
+       dma_copy16(3, gba_vram_lfb0, controls_pixels, 240 * 160 / 2, 0);
+
+       setup_palette();
+       return 0;
+}
+
+static void ctrlscr_stop(void)
+{
+       wait_vblank();
+}
+
+static void ctrlscr_frame(void)
+{
+       update_keyb();
+
+       if(KEYPRESS(BN_START) || KEYPRESS(BN_A) || KEYPRESS(BN_B)) {
+               change_screen(find_screen("menu"));
+               return;
+       }
+
+       wait_vblank();
+}
+
+static void ctrlscr_vblank(void)
+{
+}
index 461c1e6..e11fcb2 100644 (file)
@@ -59,4 +59,8 @@ extern unsigned char spr_menu_cmap[];
 extern unsigned char spr_logo_pixels[];
 extern unsigned char spr_logo_cmap[];
 
+extern unsigned char controls_pixels[];
+extern unsigned char controls_cmap[];
+extern unsigned char controls_gba_cmap[];
+
 #endif /* DATA_H_ */
index 990b0c9..3c565f7 100644 (file)
@@ -14,6 +14,9 @@
        .globl spr_menu_cmap
        .globl spr_logo_pixels
        .globl spr_logo_cmap
+       .globl controls_pixels
+       .globl controls_cmap
+       .globl controls_gba_cmap
 
        .align 1
 color_pixels:
@@ -70,3 +73,16 @@ spr_logo_pixels:
        .align 1
 spr_logo_cmap:
        .incbin "data/spr_logo.pal"
+
+       .align 1
+controls_pixels:
+       .incbin "data/controls.raw"
+
+       .align 1
+controls_cmap:
+       .incbin "data/controls.pal"
+
+       .align 1
+controls_gba_cmap:
+       .incbin "data/controls.gpal"
+
index 3c00d3b..45dcc9c 100644 (file)
@@ -5,6 +5,7 @@
 struct screen *init_logo_screen(void);
 struct screen *init_menu_screen(void);
 struct screen *init_game_screen(void);
+struct screen *init_controls_screen(void);
 
 struct screen *curscr;
 
@@ -20,6 +21,9 @@ int init_screens(void)
        if(!(scrlist[num_scr++] = init_menu_screen())) {
                return -1;
        }
+       if(!(scrlist[num_scr++] = init_controls_screen())) {
+               return -1;
+       }
        if(!(scrlist[num_scr++] = init_game_screen())) {
                return -1;
        }
index 5fdfa6b..11390c7 100644 (file)
@@ -553,7 +553,7 @@ static void draw(void)
 
 static void victory(void)
 {
-       int sec, time_bonus;
+       int sec, time_bonus = 0;
 
        total_time = timer_msec - start_time;
        sec = total_time / 1000;
index 9185fa9..e613b10 100644 (file)
@@ -86,11 +86,24 @@ static void menuscr_frame(void)
 {
        update_keyb();
 
-       if(KEYPRESS(BN_START) || (sel == 0 && KEYPRESS(BN_A))) {
+       if(KEYPRESS(BN_START)) {
                change_screen(find_screen("game"));
                return;
        }
 
+       if(KEYPRESS(BN_A)) {
+               switch(sel) {
+               case MENU_START:
+                       change_screen(find_screen("game"));
+                       return;
+               case MENU_CTRL:
+                       change_screen(find_screen("controls"));
+                       return;
+               default:
+                       break;
+               }
+       }
+
        if(KEYPRESS(BN_DOWN) && sel <= NUM_MENU_ITEMS) {
                cur_x = pos[++sel][0] - CUR_XOFFS;
                cur_y = pos[sel][1];