-
+#define MAIN_MENU_FILE_1_OFFSET 128+2
+
+#define MENU_CURSOR_TILE 0xF5
+
+
+ ; location table for cursor
+ ; y positon
+main_menu_cursor_locations_y:
+.db 40, 48, 56, 72
+
+#define MAIN_MENU_CURSOR_MAX 3
+
+ ; fixed x position
+#define main_menu_cursor_x 16
+
; update main menu state
; handles cursor sprite drawing
; handles file/new game selection
main_menu_update:
- ld b, BTNSTART ; b = button mask
+ ; clear oam
+ call shadow_oam_clear
+
+ ; ensure the cursor is capped to MAX
+ ld a, [menu_cursor_index]
+ and a, MAIN_MENU_CURSOR_MAX
+ ld [menu_cursor_index], a
+
+ ; draw cursor as sprite
+ ld d, 0
+ ld a, [menu_cursor_index]
+ ld e, a ; de = cursor location offset
+ ld hl, main_menu_cursor_locations_y
+ add hl, de
+ ld a, [hl] ; a = y position
+
+ ld hl, shadow_oam
+ ld [hl+], a ; write y
+
+ ld a, main_menu_cursor_x
+ ld [hl+], a ; write x
+
+ ; write tile
+ ld a, MENU_CURSOR_TILE
+ ld [hl+], a
+
+ xor a, a
+ ld [hl], a ; write flags
+
+
+ ld b, BTNSTART | BTNA ; b = button mask
input_just
jr z, @no_new_game REL
ld bc, st_init_new_game
ret
@no_new_game:
+
+ ld b, BTNDOWN
+ input_held
+ jr z, @not_down REL
+
+ ; cursor++
+ ld a, [menu_cursor_index]
+ inc a
+ ld [menu_cursor_index], a
+ ld bc, st_main_menu_delay
+ ret
+@not_down:
+
+
+ ld b, BTNUP
+ input_held
+ jr z, @not_up REL
+
+ ; cursor--
+ ld a, [menu_cursor_index]
+ dec a
+ ld [menu_cursor_index], a
+ ld bc, st_main_menu_delay
+ ret
+@not_up:
+
ldnull bc
ret
; disables lcd and interrupts while it is
; loading
main_menu_init:
- call video_fade_out
-
+ call next_vblank_wait
+ call lcd_off
+
+ ; set up palettes
+ ; for main menu
+ ld a, 0b11000000
+ ld [RBGP], a
+
+ ld a, 0b11000000
+ ld [ROBP0], a
+
+ ld a, 0b11000000
+ ld [ROBP1], a
+
call unit_load_default_player
- ; load default map
- ; to get the engine to load a tileset
- call map_init
+
+ ; load tile banks of default map
+ ld hl, default_map_header
+ call map_tile_banks_load
- call lcd_off
- ld hl, STR_PRESS_START
- ld de, SCRN0+128+2
+ ld hl, STR_FILE1
+ ld de, SCRN0+MAIN_MENU_FILE_1_OFFSET
+ call puts
+
+ ld hl, STR_FILE2
+ ld de, SCRN0+MAIN_MENU_FILE_1_OFFSET+32
+ call puts
+
+ ld hl, STR_FILE3
+ ld de, SCRN0+MAIN_MENU_FILE_1_OFFSET+64
+ call puts
+
+ ld hl, STR_DELETE
+ ld de, SCRN0+MAIN_MENU_FILE_1_OFFSET+128
call puts
; hide window
ld [RWY], a
ld [RWX], a
+ ; set cursor index to 0
+ xor a, a
+ ld [menu_cursor_index], a
+
call lcd_on
- call video_fade_in
ldnull bc
ret
st_main_menu_update:
st_def 0x00, main_menu_update, st_main_menu_update
+st_main_menu_delay:
+ st_def 16, st_null_fn, st_main_menu_update
+
st_main_menu_init:
st_def 0x00, main_menu_init, st_main_menu_update