menu: new files

This commit is contained in:
ikari 2009-11-09 11:26:31 +01:00
parent 2b05f0b695
commit b99bd76434
3 changed files with 528 additions and 0 deletions

76
snes/dma.a65 Normal file
View File

@ -0,0 +1,76 @@
dma0:
rep #$10 : .xl
sep #$20 : .as
lda dma_mode
sta $4300
lda dma_b_reg
sta $4301
lda dma_a_bank
ldx dma_a_addr
stx $4302
sta $4304
ldx dma_len
stx $4305
lda #$01
sta $420b
rts
setup_hdma:
sep #$20 : .as
rep #$10 : .xl
stz $420b
stz $420c
lda #$02 ;A to B; direct; 2x single reg
sta $4320 ;we use ch. 2 for color data
lda #$22 ;2122 = CG RAM
sta $4321 ;dest: CG RAM
lda #^hdma_pal
ldy #!hdma_pal
sty $4322
sta $4324
lda #$00 ;A to B; direct; 1x single reg
sta $4310 ;ch. 1 for color address
lda #$21 ;2121 = CG addr
sta $4311 ;dest: CG Address
lda #^hdma_cg_addr
ldy #!hdma_cg_addr
sty $4312
sta $4314
lda #$00 ;A to B; direct; 1x single reg
sta $4330 ;ch. 3 for mode switch
lda #$05 ;2105 = BG mode
sta $4331
lda #^hdma_mode
ldy #!hdma_mode
sty $4332
sta $4334
lda #$03 ;A to B; direct; 2x 2x single reg
sta $4340 ;ch. 4 for scroll
lda #$0d ;210d = BG1HOFS
sta $4341
lda #^hdma_scroll
ldy #!hdma_scroll
sty $4342
sta $4344
lda #$01 ;A to B; direct; 1x two reg
sta $4350 ;ch. 5 for color math
lda #$31 ;2131 + 2132 = math, color constant
sta $4351
lda #^hdma_math
ldy #!hdma_math
sty $4352
sta $4354
; lda #$06
; sta $420c ;enable HDMA ch. 1+2
lda #$81 ;VBlank NMI + Auto Joypad Read
sta $4200 ;enable V-BLANK NMI
rts

420
snes/menu.a65 Normal file
View File

@ -0,0 +1,420 @@
#include "memmap.i65"
#include "dma.i65"
menu_init:
sep #$20 : .as
rep #$10 : .xl
lda #^ROOT_DIR
ldx #!ROOT_DIR
sta dirptr_bank
stx dirptr_addr
sta dirstart_bank
stx dirstart_addr
stz menu_state
stz dirend_onscreen
lda #$04
sta cursor_x
lda #$0A
sta cursor_y
ldx #$0000
stx dirptr_idx
stx menu_sel
lda #$01
sta menu_dirty
rts
menuloop:
sep #$20 : .as
rep #$10 : .xl
menuloop_s1
lda isr_done
lsr
bcc menuloop_s1
stz isr_done
jsr menu_cleanup ;update phase 2
jsr menu_updates ;update stuff, check keys etc
lda menu_dirty ;is there ANY reason to redraw the menu?
cmp #$01
beq menuloop_redraw ;then do
bra menuloop_s1
menuloop_redraw
stz menu_dirty
jsr menu_redraw
bra menuloop_s1
rts
menu_cleanup:
sep #$20 : .as
rep #$10 : .xl
lda dirend_onscreen
beq menu_cleanup_out
lda dirend_idx
lsr
lsr
pha
menu_cleanup_loop
cmp #17
beq +
pha
clc
adc #$0a
sta print_y
lda #^space64
ldx #!space64
sta print_bank
stx print_src
stz print_pal
lda #64
sta print_count
jsr hiprint
pla
inc
bra menu_cleanup_loop
+
pla
cmp menu_sel
beq menu_cleanup_out
bpl menu_cleanup_out
sta menu_sel
menu_cleanup_out
rts
menu_updates:
;update selection, scroll etc
lda menu_sel
asl
asl
sta dirptr_idx
lda menu_sel
clc
adc #$09
sta bar_yl
;get input
jsr read_pad
lda #$04
and pad1trig+1
bne key_down
lda #$08
and pad1trig+1
bne key_up
lda #$01
and pad1trig+1
bne key_right
lda #$02
and pad1trig+1
bne key_left
lda #$80
and pad1trig+1
bne key_b
bra menuupd_out
key_down
jsr menu_key_down
bra menuupd_out
key_up
jsr menu_key_up
bra menuupd_out
key_right
jsr menu_key_right
bra menuupd_out
key_left
jsr menu_key_left
bra menuupd_out
key_b
jsr menu_key_b
bra menuupd_out
menuupd_out
lda #$0A
sta cursor_y
rts
menu_redraw:
lda menu_state
beq redraw_filelist
; cmp 1
; beq redraw_main
menu_redraw_out
rts
redraw_filelist
ldy #$0000
sty dirptr_idx
stz dirend_idx
stz dirend_onscreen
redraw_filelist_loop
ldy dirptr_idx
tya
cmp #17*4
beq redraw_filelist_last
lda dirptr_bank
phb
pha
plb
rep #$20 : .al
lda (dirptr_addr), y
sta @dirent_addr
iny
iny
sep #$20 : .as
lda (dirptr_addr), y
clc
adc #$c0
sta @dirent_bank
cmp #$c0
beq redraw_filelist_dirend
iny
lda (dirptr_addr), y
iny
sta @dirent_type
plb
sty dirptr_idx
jsr print_direntry
bra redraw_filelist_loop
redraw_filelist_dirend
plb
dey
dey
dey
dey
dey
dey
sty dirend_idx
lda #$01
sta dirend_onscreen
bra redraw_filelist_out
redraw_filelist_last ;check if next offscreen item is end of dir
lda dirptr_bank
phb
pha
plb
iny
iny
lda (dirptr_addr), y
beq redraw_filelist_dirend
plb
redraw_filelist_out
ldx #$0000
stx dirptr_idx
brl menu_redraw_out
print_direntry:
lda dirent_bank
ldx dirent_addr
phb
pha
plb
lda @dirent_type
cmp #$80
rep #$20 : .al
bne dirent_is_file
dirent_is_dir
lda #$04 ;skip dir tgt
sta @fd_fnoff
lda #$01 ;different color for dirs
sta @print_pal
bra dirent_type_cont
dirent_is_file
lda #$40 ;skip game header
sta @fd_fnoff
lda #$00
sta @print_pal ;palette 0 (white)
dirent_type_cont
txa
clc
adc @fd_fnoff
tax
sep #$20 : .as
lda !0, x ;load offset of leaf (file) name
clc
adc #1
rep #$20 : .al
and #$00ff ;kill hi byte
sta @fd_fnoff
txa
adc @fd_fnoff
sta @fd_fnoff
plb
lda cursor_y
sta print_y
inc
sta cursor_y
lda cursor_x
sta print_x
sep #$20 : .as
ldx fd_fnoff
lda #58
sta print_count
stx print_src
lda dirent_bank
sta print_bank
jsr hiprint
lda cursor_x
clc
adc print_done
sta print_x
lda #58
sec
sbc print_done
sta print_count
lda #^space64
ldx #!space64
sta print_bank
stx print_src
jsr hiprint
rts
menu_key_down:
lda menu_sel
cmp #$10
bne +
lda #$01
sta menu_dirty
lda dirend_onscreen
bne down_out
rep #$20 : .al
lda dirptr_addr
clc
adc #$04
sta dirptr_addr
sep #$20 : .as
rts
+ inc
sta menu_sel
down_out
rts
menu_key_up:
lda menu_sel
bne +
lda #$01
sta menu_dirty
rep #$20 : .al
lda dirptr_addr
cmp dirstart_addr
beq up_out
sec
sbc #$04
sta dirptr_addr
bra up_out
+ dec
sta menu_sel
up_out
sep #$20 : .as
rts
menu_key_left:
lda #$01
sta menu_dirty
rep #$20 : .al
lda dirptr_addr
beq +
sec
sbc #17*4
cmp dirstart_addr
bcc +
- sta dirptr_addr
sep #$20 : .as
rts
+ lda dirstart_addr
sep #$20 : .as
stz menu_sel
rep #$20 : .al
bra -
menu_key_right:
sep #$20 : .as
lda dirend_onscreen
bne menuupd_lastcursor
lda #$01
sta menu_dirty
rep #$20 : .al
lda dirptr_addr
clc
adc #17*4
sta dirptr_addr
sep #$20 : .as
rts
menuupd_lastcursor
lda dirend_idx
lsr
lsr
sta menu_sel
rts
menu_key_b:
jsr select_item
rts
select_item:
rep #$20 : .al
lda menu_sel
and #$00ff
asl
asl
tay
sep #$20 : .as
lda dirptr_bank
phb
pha
plb
iny
iny
iny
lda (dirptr_addr), y
beq sel_is_file
cmp #$80
beq sel_is_dir
select_item_cont
plb
rts
sel_is_file
jsr select_file
bra select_item_cont
sel_is_dir
jsr select_dir
bra select_item_cont
select_file:
; have avr load the rom
rts
select_dir: ; y = direntry ptr
sta @$ffffff ;for great breakpoint
dey
lda (dirptr_addr), y
clc
adc #$c0
sta @dirent_bank
dey
dey
rep #$20 : .al
lda (dirptr_addr), y
sta @dirent_addr
tax
sep #$20 : .as
lda @dirent_bank
phb
pha
plb
lda !2, x ; load linked dir start bank
clc
adc #$c0
sta @dirptr_bank
sta @dirstart_bank
rep #$20 : .al
lda !0, x ; load linked dir start address
sta @dirptr_addr
sta @dirstart_addr
sep #$20 : .as
lda #$01
sta @menu_dirty
plb
rts

32
snes/pad.a65 Normal file
View File

@ -0,0 +1,32 @@
read_pad:
php
rep #$30 : .xl : .al
read_pad1
ldx pad1mem ;byetUDLRaxlriiii
lda $4218
sta pad1mem
and #$0f00
bne read_pad1_count
stz pad1delay
read_pad1_cont1
txa
eor pad1mem
and pad1mem
sta pad1trig
lda #$0010
cmp pad1delay
bne read_pad1_cont2
stz pad1mem
lda #$000d
sta pad1delay
read_pad1_cont2
;lda $4218
;sta pad1trig
plp
rts
read_pad1_count
lda pad1delay
inc
sta pad1delay
bra read_pad1_cont1