Skip to content

Commit

Permalink
Merge branch 'develop' into furious-save3
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehkopf committed Sep 30, 2020
2 parents 5a3bbf3 + d7c932f commit 7263930
Show file tree
Hide file tree
Showing 13 changed files with 586 additions and 43 deletions.
12 changes: 11 additions & 1 deletion snes/const.a65
Expand Up @@ -188,6 +188,7 @@ last_win_w .byt 60
text_ellipse .byt 127, 128, 0
text_mm_file .byt "File Browser", 0
text_mm_last .byt "Recent games", 0
text_mm_favorites .byt "Favorite games", 0
mtext_mm_cfg .byt "Configuration", 0
mtext_mm_sysinfo .byt "System Information", 0
mtext_cfg_time .byt "Set Clock", 0
Expand Down Expand Up @@ -232,6 +233,7 @@ mtext_chip_gsu_speed .byt "SuperFX speed", 0
mtext_chip_msu1_volume_boost .byt "MSU-1 volume boost", 0

mdesc_mm_last .byt "Show up to 10 most recently played games", 0
mdesc_mm_favorites .byt "Show up to 10 favorite games", 0
mdesc_mm_cfg .byt "Configure the sd2snes", 0
mdesc_mm_sysinfo .byt "Info about FW version, SD Card, SNES, CIC", 127, 128, 0
mdesc_cfg_time .byt "Set the date and time", 0
Expand Down Expand Up @@ -279,11 +281,19 @@ mdesc_cx4_speed_normal .byt "Run at approx. original speed", 0
mdesc_gsu_speed_fast .byt "Run as fast as possible", 0
mdesc_gsu_speed_normal .byt "Run at approx. original speed", 0

text_filesel_selected_file .byt "Selected file", 0
text_filesel_context_add_to_favorites .byt "Add to favorites", 0
mdesc_filesel_context_add_to_favorites .byt "Add the selected file to favorites", 0

text_filesel_favorites_context_remove_from_favorites .byt "Remove from favorites", 0
mdesc_filesel_favorites_context_remove_from_favorites .byt "Remove the selected file from favorites", 0

text_statusbar_play .byt "A:Play B:Back X:Menu", 0
text_statusbar_keys .byt "A:Select B:Back X:Menu", 0
text_statusbar_keys .byt "A:Select B:Back X:Menu Y:Context", 0
text_statusbar_spc .byt "B:Back", 0
text_statusbar_menu .byt "A:Select B:Back", 0
text_last .byt "Recent games", 0
text_favorite .byt "Favorite games", 0
text_system .byt "CPU/PPU1/PPU2: a/b/c VMode: x0Hz",0

text_on_p1 .byt "On: P1", 0
Expand Down
2 changes: 2 additions & 0 deletions snes/data.a65
Expand Up @@ -87,6 +87,7 @@ mm_sel .byt 0
;--
num_recent_games .byt 0
recent_sel .byt 0
num_favorite_games .byt 0
;----------menu layout/system constants
listdisp .word 0 ; number of displayable list entries

Expand All @@ -96,6 +97,7 @@ testvar .word 0,0,0,0
listsel_sel .byt 0
listsel_step .byt 0
listsel_max .byt 0
listsel_pickbutton .byt 0
;----------hdma tables in WRAM (must be stable when cartridge is cut off)
hdma_pal
.byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Expand Down
200 changes: 200 additions & 0 deletions snes/filesel.a65
Expand Up @@ -134,6 +134,8 @@ filesel_updates:
bne key_a
lda pad_x
bne key_x
lda pad_y
bne key_y
lda pad_l
bne key_l
lda pad_r
Expand All @@ -160,6 +162,9 @@ key_a
key_x
jsr filesel_key_x
bra fileselupd_out
key_y
jsr filesel_key_y
bra fileselupd_out
key_select
jsr filesel_key_select
bra fileselupd_out
Expand Down Expand Up @@ -482,6 +487,7 @@ filesel_key_a:
rts

filesel_key_select:
jsl select_favorite_file
rts

filesel_key_start:
Expand Down Expand Up @@ -774,6 +780,90 @@ filesel_key_x:
jsr mainmenu
rts

filesel_key_y:
jsr open_context_menu
rts

open_context_menu:
rep #$20 : .al
lda filesel_sel
and #$00ff
asl
asl
tay
sep #$20 : .as
iny
iny
iny
lda [dirptr_addr], y
cmp #TYPE_ROM
beq ctx_is_file
cmp #TYPE_SPC
beq ctx_is_spc
cmp #TYPE_SUBDIR
beq ctx_is_dir
cmp #TYPE_PARENT
beq ctx_is_parent
open_context_menu_cont
rts
ctx_is_file
; "save" selected file path to MCU_PARAM in case we need to send it there later
dey
rep #$20 : .al
lda [dirptr_addr], y
and #$00ff
sta @MCU_PARAM+6
dey
dey
lda [dirptr_addr], y
sta @MCU_PARAM+4
lda #!FILESEL_CWD
sta @MCU_PARAM
sep #$20 : .as
lda #^FILESEL_CWD
sta @MCU_PARAM+2
lda #$00
sta @MCU_PARAM+3
jsr filesel_contextmenu_file
bra open_context_menu_cont
ctx_is_parent
bra open_context_menu_cont
ctx_is_dir
bra open_context_menu_cont
ctx_is_spc
bra open_context_menu_cont

add_selected_file_to_favorites:
; have MCU save the file to the favorites list
; the file path should already have been saved to MCU_PARAM before calling
; this routine
php
phb
sep #$20 : .as
lda #$01
jsr hide_cursor
jsr draw_loading_window
jsr waitblank
lda #$00
sta @SNES_CMD
lda #CMD_ADD_FAVORITE_ROM
sta @MCU_CMD
; wait for ACK/NACK
- lda @SNES_CMD
cmp #$55
; success
beq +
cmp #$aa
; failure
beq +
bra -
+ lda #$55
sta @MCU_CMD
jsr pop_window
plb
plp
rtl

setup_224:
php
rep #$30 : .xl : .al
Expand Down Expand Up @@ -894,6 +984,7 @@ select_last_file:
bne -
lda #$01
sta listsel_step
stz listsel_pickbutton
jsr menu_select
sta @MCU_PARAM
cmp #$ff
Expand All @@ -905,6 +996,115 @@ select_last_file:
plp
rtl

select_favorite_file:
; shows a window with a list of favorite games
php
sep #$20 : .as
rep #$10 : .xl
lda @ST_NUM_FAVORITE_GAMES
sta num_favorite_games
bne +
plp
rtl
+ lda #^text_favorite
sta window_tbank
ldx #!text_favorite
stx window_taddr
lda @last_win_x
sta window_x
inc
inc
pha
lda @last_win_y
sta window_y
inc
pha
lda @last_win_w
sta window_w
lda @ST_NUM_FAVORITE_GAMES
inc
inc
sta window_h
jsr push_window
lda num_favorite_games
sta listsel_max
jsr draw_window
stz print_pal
lda #^FAVORITE_GAMES
ldx #!FAVORITE_GAMES
sta print_bank
stx print_src
stz print_pal
pla
sta print_y
pla
sta print_x
- lda #56
sta print_count
jsr hiprint
inc print_src+1
inc print_y
dec num_favorite_games
bne -
lda #$01
sta listsel_step
sta listsel_pickbutton
jsr menu_select
sta @MCU_PARAM ; store selected item index in mcu param
cmp #$ff ; if no selected item, do nothing
beq select_favorite_file_done
lda listsel_pickbutton
cmp #$00 ; if button A was pressed
beq select_favorite_file_play
cmp #$01 ; if button Y was pressed
beq select_favorite_file_context_menu
bra select_favorite_file_done ; unknown button was pressed
select_favorite_file_play
sep #$20 : .as
lda #CMD_LOADFAVORITE
jsr game_handshake
bra select_favorite_file_done
select_favorite_file_context_menu
jsr filesel_favorites_contextmenu
jsr pop_window
plp
jmp select_favorite_file ; return to favorite list after closing the ctx menu
select_favorite_file_done
jsr pop_window
plp
rtl

remove_selected_favorite_file:
; have MCU remove the file from the favorites list
; the list index of the file should already have been saved to MCU_PARAM before
; calling this routine
php
phb
sep #$20 : .as
lda #$01
jsr hide_cursor
jsr draw_loading_window
jsr waitblank
lda #$00
sta @SNES_CMD
lda #CMD_REMOVE_FAVORITE_ROM
sta @MCU_CMD
; wait for ACK/NACK
- lda @SNES_CMD
cmp #$55
; success
beq +
cmp #$aa
; failure
beq +
bra -
+ lda #$55
sta @MCU_CMD
jsr pop_window
plb
plp
rtl

scroll_direntry_clean:
lda #$01
sta direntry_xscroll_state
Expand Down
6 changes: 6 additions & 0 deletions snes/memmap.i65
Expand Up @@ -59,12 +59,14 @@
#define SYSINFO_BLK $FF1200
#define LAST_GAME $FF1420
#define WRAM_BAK $FF2000
#define FAVORITE_GAMES $FF4000

#define CMD_LOADROM $01 /* shortcut - load ROM with default settings */
#define CMD_SETRTC $02
#define CMD_SYSINFO $03
#define CMD_LOADLAST $04
#define CMD_LOADSPC $05
#define CMD_LOADFAVORITE $06
#define CMD_SET_ALLOW_PAIR $07
#define CMD_SET_VIDMODE_GAME $08
#define CMD_SET_VIDMODE_MENU $09
Expand All @@ -77,6 +79,8 @@
#define CMD_SELECTROM $10 /* TODO WIP */
#define CMD_RUNROM $11 /* TODO WIP - ROM must first be selected by SELECTROM */
#define CMD_LED_BRIGHTNESS $12
#define CMD_ADD_FAVORITE_ROM $13
#define CMD_REMOVE_FAVORITE_ROM $14
#define CMD_SAVESTATE $40
#define CMD_LOADSTATE $41
#define CMD_MCU_RDY $55
Expand Down Expand Up @@ -133,6 +137,7 @@
#define ST_RTC_VALID ST_MCU_ADDR+$0000
#define ST_NUM_RECENT_GAMES ST_MCU_ADDR+$0001
#define ST_PAIRMODE ST_MCU_ADDR+$0002
#define ST_NUM_FAVORITE_GAMES ST_MCU_ADDR+$0003

#define ST_IS_U16 ST_SNES_ADDR+$0000
#define ST_U16_CFG ST_SNES_ADDR+$0001
Expand All @@ -141,6 +146,7 @@
#define MTYPE_FUNC $01
#define MTYPE_SUBMENU $02
#define MTYPE_VALUE $03
#define MTYPE_FUNC_CLOSE $04

#define OPTTYPE_NONE $00
#define OPTTYPE_BYTE $01
Expand Down

0 comments on commit 7263930

Please sign in to comment.