dedicated mapper for menu, new logo gfx, TODO: fix avr mem access again

also minor cleanups.
This commit is contained in:
ikari 2009-12-28 04:50:17 +01:00
parent a312640506
commit a120be76bd
27 changed files with 2259 additions and 1907 deletions

BIN
gfx/logo_v2.chi Normal file

Binary file not shown.

BIN
gfx/logo_v2_sprites.chi Normal file

Binary file not shown.

Binary file not shown.

BIN
gfx/sd2snes_v2.psd Normal file

Binary file not shown.

View File

@ -3,33 +3,33 @@ zero .word 0
bg2tile .byt $20 bg2tile .byt $20
hdma_pal_src .byt 44 hdma_pal_src .byt 44
.byt $60, $2d .byt $60, $2d
.byt 24 .byt 14
.byt $00, $00 .byt $00, $00
.byt 2 .byt 2
.byt $60, $2d .byt $60, $2d
.byt 10 .byt 11
.byt $00, $00 .byt $00, $00
.byt 10 .byt 11
.byt $20, $04 .byt $20, $04
.byt 10 .byt 11
.byt $40, $08 .byt $40, $08
.byt 10 .byt 11
.byt $60, $0c .byt $60, $0c
.byt 10 .byt 11
.byt $80, $10 .byt $80, $10
.byt 10 .byt 11
.byt $a0, $14 .byt $a0, $14
.byt 10 .byt 11
.byt $c0, $18 .byt $c0, $18
.byt 10 .byt 11
.byt $e0, $1c .byt $e0, $1c
.byt 10 .byt 11
.byt $00, $21 .byt $00, $21
.byt 10 .byt 11
.byt $20, $25 .byt $20, $25
.byt 10 .byt 11
.byt $40, $29 .byt $40, $29
.byt 32 .byt 31
.byt $60, $2d .byt $60, $2d
.byt 2 .byt 2
.byt $20, $04 .byt $20, $04
@ -69,8 +69,8 @@ hdma_cg_addr_src
.byt $00, $00, $00, $00, $00, $00, $00, $00 .byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00, $00, $00, $00, $00, $00, $00, $00 .byt $00, $00, $00, $00, $00, $00, $00, $00
.byt $00 .byt $00
hdma_mode_src .byt 74, $03, $01, $05, $00 hdma_mode_src .byt 64, $03, $01, $05, $00
hdma_scroll_src .byt 74 hdma_scroll_src .byt 64
.byt $00, $00, $ff, $0f .byt $00, $00, $ff, $0f
.byt $01 .byt $01
.byt $fc, $00, $05, $00 .byt $fc, $00, $05, $00
@ -80,11 +80,38 @@ hdma_math_src .byt 1
.byt 1 .byt 1
.byt $00, $e0 .byt $00, $e0
.byt 10 .byt 10
.byt $20, $ea .byt $70, $ff
.byt 1 .byt 1
.byt $00, $e0 .byt $00, $e0
.byt 0 .byt 0
oam_data_l .byt 75, 56, 31, $0e
.byt 83, 56, 1, $0e
.byt 91, 56, 2, $0e
.byt 99, 56, 3, $0e
.byt 107, 56, 4, $0e
.byt 115, 56, 5, $0e
.byt 123, 56, 6, $0e
.byt 131, 56, 7, $0e
;x shift left due to mode switch glitch
.byt 75, 64, 8, $0e
.byt 83, 64, 9, $0e
.byt 91, 64, 10, $0e
.byt 99, 64, 11, $0e
.byt 107, 64, 12, $0e
.byt 115, 64, 13, $0e
.byt 123, 64, 14, $0e
.byt 131, 64, 15, $0e
.byt 75, 72, 16, $0e
.byt 83, 72, 17, $0e
.byt 91, 72, 18, $0e
.byt 99, 72, 19, $0e
.byt 75, 80, 24, $0e
.byt 83, 80, 25, $0e
.byt 91, 80, 26, $0e
oam_data_h .byt 0, 0, 0, 0, 0, 0, 0, 0
space64 .byt $20, $20, $20, $20, $20, $20, $20, $20 space64 .byt $20, $20, $20, $20, $20, $20, $20, $20
.byt $20, $20, $20, $20, $20, $20, $20, $20 .byt $20, $20, $20, $20, $20, $20, $20, $20
.byt $20, $20, $20, $20, $20, $20, $20, $20 .byt $20, $20, $20, $20, $20, $20, $20, $20

File diff suppressed because it is too large Load Diff

View File

@ -60,16 +60,34 @@ setup_gfx:
stx $2116 stx $2116
DMA0(#$09, #$1000, #^zero, #!zero, #$18) DMA0(#$09, #$1000, #^zero, #!zero, #$18)
;clear OAM tables
ldx #$0000
stx $2102
DMA0(#$08, #$544, #^zero, #!zero, #$04)
;copy logo tiles ;copy logo tiles
ldx #$2000 ldx #$2000
stx $2116 stx $2116
DMA0(#$01, #$3480, #^logo, #!logo, #$18) DMA0(#$01, #$3740, #^logo, #!logo, #$18)
;copy logo tilemap ;copy logo tilemap
ldx #BG1_TILE_BASE ldx #BG1_TILE_BASE
stx $2116 stx $2116
DMA0(#$01, #$280, #^logomap, #!logomap, #$18) DMA0(#$01, #$280, #^logomap, #!logomap, #$18)
;copy sprites tiles
ldx #OAM_TILE_BASE
stx $2116
DMA0(#$01, #$400, #^logospr, #!logospr, #$18)
;set OAM tables
ldx #$0000
stx $2102
DMA0(#$00, #$5C, #^oam_data_l, #!oam_data_l, #$04)
ldx #$0100
stx $2102
DMA0(#$00, #$08, #^oam_data_h, #!oam_data_h, #$04)
;set palette ;set palette
stz $2121 stz $2121
DMA0(#$00, #$200, #^palette, #!palette, #$22) DMA0(#$00, #$200, #^palette, #!palette, #$22)
@ -131,8 +149,9 @@ tests:
sta $2108 ;for BG2 sta $2108 ;for BG2
lda #$40 ;chr base addr: lda #$40 ;chr base addr:
sta $210b ;BG1=0x0000, BG2=0x8000 sta $210b ;BG1=0x0000, BG2=0x8000
lda #$03 ;enable BG1+BG2 lda #$13 ;enable BG1+BG2+OBJ
sta $212c ;BG Main sta $212c ;BG Main
lda #$13 ;enable BG1+BG2+OBJ
sta $212d ;BG Sub sta $212d ;BG Sub
jsr setup_224 jsr setup_224
lda #$00 lda #$00
@ -151,7 +170,8 @@ snes_init:
sta $420d ; FAAAAAST sta $420d ; FAAAAAST
lda #$8f lda #$8f
sta $2100 ;INIDISP: force blank sta $2100 ;INIDISP: force blank
stz $2101 ; lda #$03 ; 8x8+16x16; name=0; base=3
sta $2101 ;
stz $2102 ; stz $2102 ;
stz $2103 ; stz $2103 ;
; stz $2104 ; (OAM Data?!) ; stz $2104 ; (OAM Data?!)

View File

@ -14,7 +14,7 @@ menu_init:
stz dirend_onscreen stz dirend_onscreen
lda #$04 lda #$04
sta cursor_x sta cursor_x
lda #$0A lda #$09
sta cursor_y sta cursor_y
ldx #$0000 ldx #$0000
stx dirptr_idx stx dirptr_idx
@ -57,7 +57,7 @@ menu_cleanup_loop
beq + beq +
pha pha
clc clc
adc #$0a adc #$09
sta print_y sta print_y
lda #^space64 lda #^space64
ldx #!space64 ldx #!space64
@ -88,7 +88,7 @@ menu_updates:
sta dirptr_idx sta dirptr_idx
lda menu_sel lda menu_sel
clc clc
adc #$09 adc #$08
sta bar_yl sta bar_yl
;get input ;get input
@ -138,7 +138,7 @@ key_select
bra menuupd_out bra menuupd_out
menuupd_out menuupd_out
lda #$0A lda #$09
sta cursor_y sta cursor_y
rts rts
@ -487,7 +487,7 @@ select_dir: ; y = direntry ptr
setup_224: setup_224:
php php
rep #$30 : .xl : .al rep #$30 : .xl : .al
lda #17 lda #18
sta listdisp sta listdisp
dec dec
cmp menu_sel cmp menu_sel
@ -496,17 +496,18 @@ setup_224:
setup_228_adjsel setup_228_adjsel
sta menu_sel sta menu_sel
+ +
lda #18*64 lda #19*64
sta textdmasize sta textdmasize
lda #$0005 lda #$0007
sta hdma_scroll+8 sta hdma_scroll+8
sep #$20 : .as sep #$20 : .as
lda #$05 lda #$07
sta $2110 sta $2110
lda #$00 lda #$00
sta $2110 sta $2110
lda #$00 lda #$00
sta barstep sta barstep
ora #$08
sta $2133 sta $2133
lda #$0a lda #$0a
sta hdma_math+6 sta hdma_math+6
@ -534,19 +535,20 @@ setup_228_adjsel
setup_448: setup_448:
php php
rep #$30 : .xl : .al rep #$30 : .xl : .al
lda #34 lda #36
sta listdisp sta listdisp
lda #36*64 lda #38*64
sta textdmasize sta textdmasize
lda #$ffba lda #$ffc6
sta hdma_scroll+8 sta hdma_scroll+8
sep #$20 : .as sep #$20 : .as
lda #$ba lda #$c6
sta $2110 sta $2110
lda #$ff lda #$ff
sta $2110 sta $2110
lda #$01 lda #$01
sta barstep sta barstep
ora #$08
sta $2133 sta $2133
lda #$06 lda #$06
sta hdma_math+6 sta hdma_math+6

View File

@ -1,4 +1,6 @@
palette .byt $42, $08, $ff, $7f, $00, $00, $18, $63 palette
;fonts
.byt $42, $08, $ff, $7f, $00, $00, $18, $63
.byt $42, $08, $ff, $43, $00, $00, $18, $63 .byt $42, $08, $ff, $43, $00, $00, $18, $63
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
@ -6,59 +8,64 @@ palette .byt $42, $08, $ff, $7f, $00, $00, $18, $63
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
;logo
.byt $10, $42, $82, $35, $23, $46, $85, $4e
.byt $a0, $39, $c8, $56, $09, $5f, $e9, $5a
.byt $6b, $6f, $2a, $63, $66, $4e, $8d, $73
.byt $6e, $6f, $a0, $35, $04, $42, $4a, $6b
.byt $42, $46, $07, $63, $e7, $5a, $20, $46
.byt $4d, $6b, $29, $67, $a4, $52, $64, $4a
.byt $c0, $3d, $e1, $41, $c3, $3d, $c6, $56
.byt $a7, $52, $45, $4a, $21, $25, $40, $29
.byt $e1, $1c, $00, $21, $84, $31, $88, $52
.byt $a9, $56, $a1, $14, $c6, $18, $5a, $67
.byt $a5, $14, $39, $63, $ff, $7f, $c1, $18
.byt $83, $10, $17, $5f, $f7, $5a, $84, $10
.byt $72, $4a, $7b, $6b, $4a, $29, $21, $04
.byt $b5, $52, $de, $7b, $ad, $35, $42, $08
.byt $63, $0c, $30, $42, $41, $04, $93, $4e
.byt $d5, $56, $61, $0c, $41, $08, $6b, $2d
.byt $08, $21, $bd, $77, $29, $25, $0f, $3e
.byt $e7, $1c, $ee, $39, $21, $08, $82, $14
.byt $63, $10, $62, $10, $9c, $73, $81, $10
.byt $ac, $31, $62, $0c, $51, $46, $83, $0c
.byt $62, $08, $42, $0c, $43, $29, $82, $4e
.byt $53, $4a, $a5, $10, $00, $7f, $06, $7f
.byt $a6, $6e, $67, $5e, $a7, $6e, $e4, $7a
.byt $02, $7f, $e6, $76, $e5, $7e, $64, $2d
.byt $45, $56, $a6, $62, $e6, $72, $44, $56
.byt $23, $4e, $a7, $6a, $c3, $41, $52, $29
.byt $6a, $2d, $7e, $14, $37, $29, $be, $14
.byt $be, $18, $4f, $29, $11, $21, $12, $25
.byt $2f, $25, $bc, $18, $66, $31, $db, $1c
.byt $6d, $2d, $ca, $5a, $82, $10, $82, $08
.byt $a4, $2d, $ac, $2a, $89, $11, $a3, $08
.byt $83, $2d, $ed, $2a, $4e, $23, $0e, $27
.byt $4f, $27, $69, $2e, $86, $5e, $83, $39
.byt $6b, $31, $34, $25, $7e, $10, $d8, $1c
.byt $6d, $31, $9f, $10, $19, $25, $6b, $1a
.byt $4a, $1a, $04, $0d, $cc, $1e, $6b, $22
;sprite palette 3
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $10, $42, $10, $42, $10, $42 .byt $10, $42, $10, $42, $10, $42, $10, $42
.byt $10, $42, $03, $21, $64, $2d, $62, $0c ;logo
.byt $e2, $20, $44, $29, $85, $31, $c5, $3d .byt $87, $19, $c8, $1d, $49, $19, $ad, $19
.byt $8c, $73, $47, $4a, $23, $25, $84, $31 .byt $31, $1e, $b5, $1e, $d5, $1a, $72, $1e
.byt $e7, $3d, $e5, $41, $65, $5a, $c6, $3d .byt $ac, $19, $46, $2d, $e6, $10, $49, $2d
.byt $a6, $62, $06, $7f, $04, $4a, $08, $7b .byt $a3, $0c, $a8, $35, $17, $21, $cc, $18
.byt $e3, $45, $83, $39, $c6, $6e, $24, $52 .byt $41, $0c, $ce, $18, $a8, $18, $c1, $14
.byt $e4, $7a, $e6, $76, $45, $52, $c7, $72 .byt $e9, $1d, $a9, $1d, $d6, $26, $f7, $22
.byt $e4, $49, $23, $4e, $86, $5e, $68, $4e .byt $30, $22, $ff, $13, $de, $17, $ff, $1b
.byt $a2, $31, $c5, $35, $85, $62, $c5, $2d .byt $39, $1f, $93, $1e, $7a, $1f, $df, $1b
.byt $87, $5e, $a4, $2d, $c4, $3d, $a5, $6a .byt $48, $19, $9a, $23, $ee, $21, $a9, $14
.byt $47, $5a, $07, $4a, $4d, $29, $16, $29 .byt $b8, $18, $49, $36, $d0, $2a, $36, $27
.byt $a7, $35, $36, $25, $be, $18, $1a, $21 .byt $bc, $1f, $78, $27, $13, $2f, $6f, $32
.byt $83, $2d, $18, $21, $50, $31, $fb, $20 .byt $07, $32, $62, $2d, $10, $42, $10, $42
.byt $4a, $2d, $2e, $29, $dc, $1c, $31, $29 ;sprite palette 7
.byt $6a, $2d, $de, $1c, $aa, $31, $87, $31 .byt $3f, $7c, $20, $08, $84, $0c, $a5, $14
.byt $53, $2d, $e6, $41, $40, $46, $aa, $32 .byt $08, $21, $5a, $6b, $bc, $73, $fe, $7b
.byt $28, $2e, $2f, $2b, $4f, $27, $0e, $27 .byt $f7, $5e, $73, $4e, $10, $42, $42, $08
.byt $cb, $2a, $68, $2a, $e4, $2d, $83, $29 .byt $00, $00, $ad, $35, $b5, $56, $6b, $2d
.byt $61, $29, $0d, $2f, $4f, $2b, $ec, $2a
.byt $ab, $2a, $cc, $2e, $68, $2e, $4e, $2b
.byt $8a, $2e, $ad, $26, $a4, $31, $0d, $2b
.byt $26, $19, $4e, $27, $ef, $2a, $47, $19
.byt $c4, $14, $c2, $39, $c3, $49, $c2, $45
.byt $46, $56, $65, $2d, $f8, $20, $4c, $29
.byt $2f, $29, $19, $29, $51, $29, $c9, $18
.byt $da, $18, $a8, $18, $9c, $18, $d1, $18
.byt $84, $10, $db, $18, $7e, $14, $f1, $1c
.byt $eb, $20, $a2, $18, $48, $2a, $20, $25
.byt $e3, $20, $ee, $26, $4a, $22, $e5, $18
.byt $ef, $21, $50, $1e, $48, $19, $e5, $14
.byt $58, $1f, $ff, $17, $bd, $1f, $ab, $1d
.byt $f7, $1e, $cc, $19, $ff, $1f, $d5, $1e
.byt $c4, $10, $7a, $1f, $6a, $19, $ef, $19
.byt $72, $1e, $94, $1a, $93, $1e, $ce, $1d
.byt $49, $15, $9c, $1f, $b3, $1e, $94, $1e
.byt $bd, $17, $18, $1f, $de, $1f, $8b, $19
.byt $71, $22, $49, $19, $d4, $18, $ce, $18
.byt $88, $10, $b6, $18, $b1, $18, $a6, $14
.byt $c4, $5a, $e2, $5e, $d4, $1e, $06, $15
.byt $ed, $1d, $38, $1f, $ce, $19, $27, $19
.byt $a0, $39, $a9, $56, $0b, $63, $45, $4a
.byt $2a, $63, $c8, $56, $88, $52, $6b, $6f
.byt $6e, $6f, $4d, $6b, $ae, $77, $24, $46
.byt $09, $5f, $23, $46, $4a, $6b, $e9, $5a
.byt $e1, $41, $c3, $3d, $e4, $41, $82, $35
.byt $64, $4a, $a7, $52, $86, $4e, $2c, $63
.byt $a4, $52, $ca, $5a, $65, $4e, $43, $29
.byt $62, $2d, $8d, $73, $8f, $6f, $66, $4e
.byt $c8, $5a, $42, $46, $21, $25, $29, $67
.byt $42, $4a, $c6, $56, $e2, $1c, $02, $21
.byt $07, $63, $a2, $14, $eb, $5e, $c1, $18
.byt $82, $10, $e7, $5a, $cf, $7b, $82, $4e

View File

@ -18,17 +18,17 @@ NMI_ROUTINE:
plb plb
lda $4210 lda $4210
ldx #BG1_TILE_BASE+32*10 ldx #BG1_TILE_BASE+32*9
stx $2116 stx $2116
DMA0(#$01, #34*64, #^BG1_TILE_BUF, #!BG1_TILE_BUF+64*10, #$18) DMA0(#$01, #36*64, #^BG1_TILE_BUF, #!BG1_TILE_BUF+64*9, #$18)
ldx #BG2_TILE_BASE+32*10 ldx #BG2_TILE_BASE+32*9
stx $2116 stx $2116
DMA0(#$01, #34*64, #^BG2_TILE_BUF, #!BG2_TILE_BUF+64*10, #$18) DMA0(#$01, #36*64, #^BG2_TILE_BUF, #!BG2_TILE_BUF+64*9, #$18)
ldx #BG2_TILE_BASE ldx #BG2_TILE_BASE
stx $2116 stx $2116
DMA0(#$01, #64*10, #^BG2_TILE_BUF, #!BG2_TILE_BUF, #$18) DMA0(#$01, #64*9, #^BG2_TILE_BUF, #!BG2_TILE_BUF, #$18)
lda bar_yl lda bar_yl
asl asl
@ -37,13 +37,14 @@ NMI_ROUTINE:
lda barstep lda barstep
php php
txa txa
dec
plp plp
bne small_bar bne small_bar
asl asl
bra normal_bar bra normal_bar
small_bar small_bar
clc clc
adc #36 adc #31
normal_bar normal_bar
sta bar_y sta bar_y

View File

@ -59,6 +59,7 @@ print_loop_inner
asl asl
asl asl
adc #$00 adc #$00
ora #$20
sta @$2180 sta @$2180
lda @print_done lda @print_done
inc inc
@ -105,6 +106,7 @@ print_loop2_inner
asl asl
asl asl
adc #$00 adc #$00
ora #$20
sta @$2180 sta @$2180
lda @print_done lda @print_done
inc inc

View File

@ -1662,7 +1662,7 @@ FRESULT f_write (
*bw = 0; *bw = 0;
res = validate(fs /*, fp->id*/); /* Check validity of the object */ res = validate(fs /*, fp->id*/); /* Check validity of the object */
if (res != FR_OK) return res; if (res != FR_OK) return res;
if (fp->flag & FA__ERROR) {dprintf("fp->flag & FA__ERROR \n"); return FR_RW_ERROR;} /* Check error flag */ if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */ if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */ if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
@ -1680,18 +1680,17 @@ FRESULT f_write (
clust = create_chain(fs, fp->curr_clust); /* Trace or streach cluster chain */ clust = create_chain(fs, fp->curr_clust); /* Trace or streach cluster chain */
} }
if (clust == 0) break; /* Disk full */ if (clust == 0) break; /* Disk full */
if (clust == 1 || clust >= fs->max_clust) { dprintf("cluster alloc error\n"); goto fw_error; } if (clust == 1 || clust >= fs->max_clust) goto fw_error;
fp->curr_clust = clust; /* Current cluster */ fp->curr_clust = clust; /* Current cluster */
sect = clust2sect(fs, clust); /* Get current sector */ sect = clust2sect(fs, clust); /* Get current sector */
fp->csect = fs->csize; /* Re-initialize the left sector counter */ fp->csect = fs->csize; /* Re-initialize the left sector counter */
} }
if(!move_fp_window(fp,0)) {dprintf("move_fp_window error\n"); goto fw_error;} if(!move_fp_window(fp,0)) goto fw_error;
fp->curr_sect = sect; /* Update current sector */ fp->curr_sect = sect; /* Update current sector */
cc = btw / SS(fs); /* When left bytes >= SS(fs), */ cc = btw / SS(fs); /* When left bytes >= SS(fs), */
if (cc) { /* Write maximum contiguous sectors directly */ if (cc) { /* Write maximum contiguous sectors directly */
if (cc > fp->csect) cc = fp->csect; if (cc > fp->csect) cc = fp->csect;
if (disk_write(fs->drive, wbuff, sect, (BYTE)cc) != RES_OK) if (disk_write(fs->drive, wbuff, sect, (BYTE)cc) != RES_OK) goto fw_error;
{ dprintf("disk_write error\n"); goto fw_error;}
fp->csect -= (BYTE)(cc - 1); fp->csect -= (BYTE)(cc - 1);
fp->curr_sect += cc - 1; fp->curr_sect += cc - 1;
wcnt = cc * SS(fs); wcnt = cc * SS(fs);
@ -1705,8 +1704,7 @@ FRESULT f_write (
#if _USE_1_BUF == 0 #if _USE_1_BUF == 0
fp->fptr < fp->fsize && /* Fill sector buffer with file data if needed */ fp->fptr < fp->fsize && /* Fill sector buffer with file data if needed */
#endif #endif
!move_fp_window(fp,fp->curr_sect)) !move_fp_window(fp,fp->curr_sect)) goto fw_error;
{ dprintf("fract write error\n "); goto fw_error; }
memcpy(&FPBUF.data[fp->fptr & (SS(fs) - 1)], wbuff, wcnt); memcpy(&FPBUF.data[fp->fptr & (SS(fs) - 1)], wbuff, wcnt);
FPBUF.dirty=TRUE; FPBUF.dirty=TRUE;
} }

View File

@ -44,9 +44,7 @@ UINT file_readblock(void* buf, uint32_t addr, uint16_t size) {
if(file_handle.fptr != addr) { if(file_handle.fptr != addr) {
return 0; return 0;
} }
if(file_res) { dprintf("no lseek %d\n", file_res); _delay_ms(30); return 0;}
file_res = f_read(&file_handle, buf, size, &bytes_read); file_res = f_read(&file_handle, buf, size, &bytes_read);
if(file_res) { dprintf("no read %d\n", file_res); _delay_ms(30); }
return bytes_read; return bytes_read;
} }

View File

@ -90,10 +90,10 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
db_tgt += 0x00010000; db_tgt += 0x00010000;
dprintf("new=%lx\n", db_tgt); dprintf("new=%lx\n", db_tgt);
} }
sram_writelong(parent_tgt, db_tgt); sram_writelong((parent_tgt-SRAM_MENU_ADDR), db_tgt);
sram_writebyte(0, db_tgt+sizeof(next_subdir_tgt)); sram_writebyte(0, db_tgt+sizeof(next_subdir_tgt));
sram_writeblock("../\0", db_tgt+sizeof(next_subdir_tgt)+sizeof(len), 4); sram_writeblock("../\0", db_tgt+sizeof(next_subdir_tgt)+sizeof(len), 4);
sram_writelong(db_tgt|((uint32_t)0x80<<24), dir_tgt); sram_writelong((db_tgt-SRAM_MENU_ADDR)|((uint32_t)0x80<<24), dir_tgt);
db_tgt += sizeof(next_subdir_tgt)+sizeof(len)+4; db_tgt += sizeof(next_subdir_tgt)+sizeof(len)+4;
dir_tgt += 4; dir_tgt += 4;
} }
@ -122,7 +122,7 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
// write element pointer to current dir structure // write element pointer to current dir structure
dprintf("d=%d Saving %lX to Address %lX [dir]\n", depth, db_tgt, dir_tgt); dprintf("d=%d Saving %lX to Address %lX [dir]\n", depth, db_tgt, dir_tgt);
// _delay_ms(50); // _delay_ms(50);
sram_writelong(db_tgt|((uint32_t)0x80<<24), dir_tgt); sram_writelong((db_tgt-SRAM_MENU_ADDR)|((uint32_t)0x80<<24), dir_tgt);
// sram_writeblock((uint8_t*)&db_tgt, dir_tgt_save, sizeof(dir_tgt_save)); // sram_writeblock((uint8_t*)&db_tgt, dir_tgt_save, sizeof(dir_tgt_save));
// save element: // save element:
@ -136,7 +136,7 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
} }
dprintf(" Saving dir descriptor to %lX, tgt=%lX, path=%s\n", db_tgt, next_subdir_tgt, path); dprintf(" Saving dir descriptor to %lX, tgt=%lX, path=%s\n", db_tgt, next_subdir_tgt, path);
// _delay_ms(100); // _delay_ms(100);
sram_writelong(next_subdir_tgt, db_tgt); sram_writelong((next_subdir_tgt-SRAM_MENU_ADDR), db_tgt);
sram_writebyte(len+1, db_tgt+sizeof(next_subdir_tgt)); sram_writebyte(len+1, db_tgt+sizeof(next_subdir_tgt));
sram_writeblock(path, db_tgt+sizeof(next_subdir_tgt)+sizeof(len), pathlen); sram_writeblock(path, db_tgt+sizeof(next_subdir_tgt)+sizeof(len), pathlen);
sram_writeblock("/\0", db_tgt + sizeof(next_subdir_tgt) + sizeof(len) + pathlen, 2); sram_writeblock("/\0", db_tgt + sizeof(next_subdir_tgt) + sizeof(len) + pathlen, 2);
@ -180,7 +180,7 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
db_tgt += 0x00010000; db_tgt += 0x00010000;
dprintf("new=%lx\n", db_tgt); dprintf("new=%lx\n", db_tgt);
} }
sram_writelong(db_tgt, dir_tgt); sram_writelong((db_tgt-SRAM_MENU_ADDR), dir_tgt);
// sram_writeblock((uint8_t*)&db_tgt, dir_tgt, sizeof(db_tgt)); // sram_writeblock((uint8_t*)&db_tgt, dir_tgt, sizeof(db_tgt));
dir_tgt += 4; dir_tgt += 4;
// save element: // save element:
@ -214,8 +214,8 @@ uint16_t scan_dir(char* path, char mkdb, uint32_t this_dir_tgt) {
} }
// dprintf("%x\n", crc); // dprintf("%x\n", crc);
// _delay_ms(50); // _delay_ms(50);
sram_writeblock(&db_tgt, SRAM_DB_ADDR+4, sizeof(db_tgt)); sram_writelong(db_tgt, SRAM_DB_ADDR+4);
sram_writeblock(&dir_end, SRAM_DB_ADDR+8, sizeof(dir_end)); sram_writelong(dir_end, SRAM_DB_ADDR+8);
return crc; return crc;
} }

View File

@ -27,6 +27,7 @@
#include "fpga_spi.h" #include "fpga_spi.h"
#include "spi.h" #include "spi.h"
#include "avrcompat.h" #include "avrcompat.h"
#include "led.h"
/*DWORD get_fattime(void) { /*DWORD get_fattime(void) {
return 0L; return 0L;
@ -75,6 +76,7 @@ void fpga_postinit() {
void fpga_pgm(uint8_t* filename) { void fpga_pgm(uint8_t* filename) {
int MAXRETRIES = 10; int MAXRETRIES = 10;
int retries = MAXRETRIES; int retries = MAXRETRIES;
int j=0;
do { do {
set_prog_b(0); set_prog_b(0);
uart_putc('P'); uart_putc('P');
@ -93,6 +95,9 @@ void fpga_pgm(uint8_t* filename) {
} }
for (;;) { for (;;) {
if(!(j++ % 8)) {
toggle_pwr_led();
}
bytes_read = file_read(); bytes_read = file_read();
if (file_res || bytes_read == 0) break; // error or eof if (file_res || bytes_read == 0) break; // error or eof
for(int i=0; i<bytes_read; i++) { for(int i=0; i<bytes_read; i++) {
@ -105,6 +110,7 @@ void fpga_pgm(uint8_t* filename) {
if(!fpga_get_done()) { if(!fpga_get_done()) {
dprintf("FPGA failed to configure after %d tries.\n", MAXRETRIES); dprintf("FPGA failed to configure after %d tries.\n", MAXRETRIES);
_delay_ms(50); _delay_ms(50);
led_panic();
} }
fpga_postinit(); fpga_postinit();
} }
@ -113,13 +119,13 @@ void set_avr_ena(uint8_t val) {
if(val) { // shared mode if(val) { // shared mode
PORTD |= _BV(PD7); PORTD |= _BV(PD7);
// Disable SPI double speed mode -> clock = f/4 // Disable SPI double speed mode -> clock = f/4
SPSR = 0; // SPSR = 0;
dprintf("SPI slow\n"); // dprintf("SPI slow\n");
} else { // avr only } else { // avr only
PORTD &= ~_BV(PD7); PORTD &= ~_BV(PD7);
// Enable SPI double speed mode -> clock = f/2 // Enable SPI double speed mode -> clock = f/2
SPSR = _BV(SPI2X); // SPSR = _BV(SPI2X);
dprintf("SPI fast\n"); // dprintf("SPI fast\n");
} }
} }

View File

@ -25,6 +25,7 @@
*/ */
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h>
#include "config.h" #include "config.h"
#include "led.h" #include "led.h"
@ -34,11 +35,30 @@ static uint8_t led_bounce_dir = 1;
volatile uint8_t led_state; volatile uint8_t led_state;
void led_panic(void) {
led_std();
while(1) {
set_pwr_led(1);
set_busy_led(1);
_delay_ms(150);
set_pwr_led(0);
set_busy_led(0);
_delay_ms(150);
}
}
void toggle_busy_led(void) { void toggle_busy_led(void) {
PORTB &= ~_BV(PB3); PORTB &= ~_BV(PB3);
DDRB ^= _BV(PB3); DDRB ^= _BV(PB3);
} }
void toggle_pwr_led(void) {
PORTB &= ~_BV(PB0);
DDRB ^= _BV(PB0);
}
void set_busy_led(uint8_t state) { void set_busy_led(uint8_t state) {
PORTB &= ~_BV(PB3); PORTB &= ~_BV(PB3);
if(state) { if(state) {

View File

@ -39,10 +39,12 @@ extern volatile uint8_t led_state;
/* Update the LEDs to match the buffer state */ /* Update the LEDs to match the buffer state */
void toggle_busy_led(void); void toggle_busy_led(void);
void toggle_pwr_led(void);
void set_busy_led(uint8_t); void set_busy_led(uint8_t);
void set_pwr_led(uint8_t); void set_pwr_led(uint8_t);
void set_busy_pwm(uint8_t brightness); void set_busy_pwm(uint8_t brightness);
void bounce_busy_led(void); void bounce_busy_led(void);
void led_pwm(void); void led_pwm(void);
void led_std(void); void led_std(void);
void led_panic(void);
#endif #endif

View File

@ -261,8 +261,9 @@ restart:
// sram_hexdump(0, 0x200); // sram_hexdump(0, 0x200);
uart_putc('('); uart_putc('(');
load_rom((uint8_t*)"/sd2snes/menu.bin"); load_rom((uint8_t*)"/sd2snes/menu.bin", SRAM_MENU_ADDR);
set_rom_mask(0x3fffff); // force mirroring off set_rom_mask(0x3fffff); // force mirroring off
set_avr_mapper(0x7); // menu mapper
uart_putc(')'); uart_putc(')');
uart_putcrlf(); uart_putcrlf();
// sram_hexdump(0x7ffff0, 0x10); // sram_hexdump(0x7ffff0, 0x10);
@ -279,7 +280,6 @@ restart:
snes_reset(0); snes_reset(0);
uint8_t cmd = 0; uint8_t cmd = 0;
while(!sram_reliable()); while(!sram_reliable());
@ -292,7 +292,7 @@ restart:
// snes_reset(1); // snes_reset(1);
set_avr_ena(0); set_avr_ena(0);
dprintf("Selected name: %s\n", file_lfn); dprintf("Selected name: %s\n", file_lfn);
load_rom(file_lfn); load_rom(file_lfn, SRAM_ROM_ADDR);
// save_sram((uint8_t*)"/sd2snes/test.smc", romprops.romsize_bytes, 0); // save_sram((uint8_t*)"/sd2snes/test.smc", romprops.romsize_bytes, 0);
if(romprops.ramsize_bytes) { if(romprops.ramsize_bytes) {
strcpy(strrchr((char*)file_lfn, (int)'.'), ".srm"); strcpy(strrchr((char*)file_lfn, (int)'.'), ".srm");
@ -318,7 +318,6 @@ restart:
cmd=0; cmd=0;
uint8_t snes_reset_prev=0, snes_reset_now=0, snes_reset_state=0; uint8_t snes_reset_prev=0, snes_reset_now=0, snes_reset_state=0;
uint16_t reset_count=0; uint16_t reset_count=0;
// /* XXX */ writetest();
while(fpga_test() == FPGA_TEST_TOKEN) { while(fpga_test() == FPGA_TEST_TOKEN) {
snes_reset_now=get_snes_reset(); snes_reset_now=get_snes_reset();
if(snes_reset_now) { if(snes_reset_now) {
@ -359,17 +358,7 @@ restart:
snes_reset_prev = snes_reset_now; snes_reset_prev = snes_reset_now;
} }
// FPGA TEST FAIL. PANIC. // FPGA TEST FAIL. PANIC.
led_panic();
led_std();
while(1) {
set_pwr_led(1);
set_busy_led(1);
_delay_ms(150);
set_pwr_led(0);
set_busy_led(0);
_delay_ms(150);
}
/* HERE BE LIONS */ /* HERE BE LIONS */
while(1) { while(1) {

View File

@ -88,11 +88,15 @@ uint32_t sram_readlong(uint32_t addr) {
spi_fpga(); spi_fpga();
spiTransferByte(0x81); spiTransferByte(0x81);
spiTransferByte(0x00); spiTransferByte(0x00);
uint32_t count=0;
uint32_t val = spiTransferByte(0x00); uint32_t val = spiTransferByte(count & 0xff);
val |= ((uint32_t)spiTransferByte(0x00)<<8); count++;
val |= ((uint32_t)spiTransferByte(0x00)<<16); val |= ((uint32_t)spiTransferByte(count & val)<<8);
val |= ((uint32_t)spiTransferByte(0x00)<<24); count++;
val |= ((uint32_t)spiTransferByte(count & val)<<16);
count++;
val |= ((uint32_t)spiTransferByte(count & val)<<24);
count++;
spi_none(); spi_none();
return val; return val;
} }
@ -123,15 +127,15 @@ void sram_writeblock(void* buf, uint32_t addr, uint16_t size) {
spi_none(); spi_none();
} }
uint32_t load_rom(uint8_t* filename) { uint32_t load_rom(uint8_t* filename, uint32_t base_addr) {
// uint8_t dummy; // uint8_t dummy;
set_avr_bank(0);
UINT bytes_read; UINT bytes_read;
DWORD filesize; DWORD filesize;
UINT count=0; UINT count=0;
file_open(filename, FA_READ); file_open(filename, FA_READ);
filesize = file_handle.fsize; filesize = file_handle.fsize;
smc_id(&romprops); smc_id(&romprops);
set_avr_addr(base_addr);
dprintf("no nervous breakdown beyond this point! or else!\n"); dprintf("no nervous breakdown beyond this point! or else!\n");
if(file_res) { if(file_res) {
uart_putc('?'); uart_putc('?');
@ -293,8 +297,9 @@ uint8_t sram_reliable() {
val=sram_readlong(SRAM_SCRATCHPAD); val=sram_readlong(SRAM_SCRATCHPAD);
if(val==0x12345678) { if(val==0x12345678) {
score++; score++;
} else {
dprintf("i=%d val=%08lX\n", i, val);
} }
// dprintf("val=%08lX\n", val);
} }
if(score<SRAM_RELIABILITY_SCORE) { if(score<SRAM_RELIABILITY_SCORE) {
result = 0; result = 0;

View File

@ -4,16 +4,20 @@
#ifndef MEMORY_H #ifndef MEMORY_H
#define MEMORY_H #define MEMORY_H
#define SRAM_DB_ADDR (0x080000L) #define SRAM_ROM_ADDR (0x000000L)
#define SRAM_DIR_ADDR (0x300000L)
#define SRAM_CMD_ADDR (0x601004L)
#define SRAM_FD_ADDR (0x601000L)
#define SRAM_SAVE_ADDR (0x600000L) #define SRAM_SAVE_ADDR (0x600000L)
#define SRAM_MENU_ADDR (0x600000L)
#define SRAM_DB_ADDR (0x620000L)
#define SRAM_DIR_ADDR (0x610000L)
#define SRAM_CMD_ADDR (0x7F1004L)
#define SRAM_FD_ADDR (0x7F1000L)
#define SRAM_MENU_SAVE_ADDR (0x7F0000L)
#define SRAM_SCRATCHPAD (0x7FFF00L) #define SRAM_SCRATCHPAD (0x7FFF00L)
#define SRAM_DIRID (0x7FFFF0L) #define SRAM_DIRID (0x7FFFF0L)
#define SRAM_RELIABILITY_SCORE (0x100) #define SRAM_RELIABILITY_SCORE (0x100)
uint32_t load_rom(uint8_t* filename); uint32_t load_rom(uint8_t* filename, uint32_t base_addr);
uint32_t load_sram(uint8_t* filename, uint32_t base_addr); uint32_t load_sram(uint8_t* filename, uint32_t base_addr);
void sram_hexdump(uint32_t addr, uint32_t len); void sram_hexdump(uint32_t addr, uint32_t len);
uint8_t sram_readbyte(uint32_t addr); uint8_t sram_readbyte(uint32_t addr);

View File

@ -15,7 +15,6 @@
uint8_t initloop=1; uint8_t initloop=1;
uint32_t saveram_crc, saveram_crc_old; uint32_t saveram_crc, saveram_crc_old;
uint32_t saveram_base_addr = 0x600000; // chip 3
void snes_init() { void snes_init() {
DDRD |= _BV(PD5); // PD5 = RESET_DIR DDRD |= _BV(PD5); // PD5 = RESET_DIR
DDRD |= _BV(PD6); // PD6 = RESET DDRD |= _BV(PD6); // PD6 = RESET
@ -59,10 +58,10 @@ uint8_t sram_valid = 0;
void snes_main_loop() { void snes_main_loop() {
if(!romprops.ramsize_bytes)return; if(!romprops.ramsize_bytes)return;
if(initloop) { if(initloop) {
saveram_crc_old = calc_sram_crc(saveram_base_addr, romprops.ramsize_bytes); saveram_crc_old = calc_sram_crc(SRAM_SAVE_ADDR, romprops.ramsize_bytes);
initloop=0; initloop=0;
} }
saveram_crc = calc_sram_crc(saveram_base_addr, romprops.ramsize_bytes); saveram_crc = calc_sram_crc(SRAM_SAVE_ADDR, romprops.ramsize_bytes);
sram_valid = sram_reliable(); sram_valid = sram_reliable();
if(crc_valid && sram_valid) { if(crc_valid && sram_valid) {
if(saveram_crc != saveram_crc_old) { if(saveram_crc != saveram_crc_old) {
@ -82,7 +81,7 @@ void snes_main_loop() {
uart_puthexshort(saveram_crc); uart_puthexshort(saveram_crc);
uart_putcrlf(); uart_putcrlf();
set_busy_led(1); set_busy_led(1);
save_sram(file_lfn, romprops.ramsize_bytes, saveram_base_addr); save_sram(file_lfn, romprops.ramsize_bytes, SRAM_SAVE_ADDR);
set_busy_led(0); set_busy_led(0);
didnotsave=0; didnotsave=0;
} }
@ -90,7 +89,7 @@ void snes_main_loop() {
diffcount=0; diffcount=0;
uart_putc('V'); uart_putc('V');
set_busy_led(1); set_busy_led(1);
save_sram(file_lfn, romprops.ramsize_bytes, saveram_base_addr); save_sram(file_lfn, romprops.ramsize_bytes, SRAM_SAVE_ADDR);
didnotsave=0; didnotsave=0;
set_busy_led(0); set_busy_led(0);
} }
@ -121,5 +120,5 @@ uint8_t menu_main_loop() {
void get_selected_name(uint8_t* fn) { void get_selected_name(uint8_t* fn) {
uint32_t addr = sram_readlong(SRAM_FD_ADDR); uint32_t addr = sram_readlong(SRAM_FD_ADDR);
dprintf("fd addr=%lX\n", addr); dprintf("fd addr=%lX\n", addr);
sram_readblock(fn, addr+0x41, 256); sram_readblock(fn, addr+0x41+SRAM_MENU_ADDR, 256);
} }

View File

@ -32,16 +32,16 @@ int main(int argc, char** argv) {
// depth = 2; // depth = 2;
// 4->2 // 4->2
pixperbyte = 2; // pixperbyte = 2;
mask_shift = 4; // mask_shift = 4;
mask = 0x0f; // mask = 0x0f;
depth = 4; // depth = 4;
// 4->4? // 4->4?
// pixperbyte = 1; pixperbyte = 1;
// mask_shift = 0; mask_shift = 0;
// mask = 0xff; mask = 0xff;
// depth = 8; depth = 8;
// 8->8 // 8->8
dsize = fsize * depth / (8/pixperbyte); dsize = fsize * depth / (8/pixperbyte);

View File

@ -3,19 +3,19 @@
int main(void) { int main(void) {
uint16_t tile=256; uint16_t tile=256;
uint16_t pad=0xa+256; uint16_t pad=256;
int i,j; int i,j;
FILE *out; FILE *out;
if((out=fopen("tilemap", "wb"))==NULL) { if((out=fopen("tilemap", "wb"))==NULL) {
perror("Could not open output file 'tilemap'"); perror("Could not open output file 'tilemap'");
return 1; return 1;
} }
for(i=0; i<10; i++) { for(i=0; i<8; i++) {
for(j=0; j<21; j++) { for(j=0; j<26; j++) {
fwrite(&tile, 2, 1, out); fwrite(&tile, 2, 1, out);
tile++; tile++;
} }
for(j=21; j<32; j++) { for(j=26; j<32; j++) {
fwrite(&pad, 2, 1, out); fwrite(&pad, 2, 1, out);
} }
} }

View File

@ -18,8 +18,27 @@ int main(int argc, char **argv) {
while(1) { while(1) {
uint8_t c=fgetc(in); uint8_t c=fgetc(in);
if(feof(in))break; if(feof(in))break;
if(c>=1 && c<=48) { // if(c>=1 && c<=48) {
c+=207; // c+=207;
// }
// shift palette by 32
// keep color 0
// leave room for sprite pal 3 and 7 (176-192 and 240-255)
if(c) {
if(c>224) { // move upper colors to start
c-=224;
} else if(c==224) { // remap 224 to 32, not 0
c=32;
} else { // shift colors, leave gap 176-191
// relocate 0xd0-0xdf (which would be
// remapped to 0x00-0x0f) to 0xb0-0xbf
c+=32;
if(c>=176) {
c+=16;
if(c<16) c=0xb0+c;
}
}
} }
fputc(c, out); fputc(c, out);
} }

46
utils/palreorder.c Normal file
View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdint.h>
int main(int argc, char **argv) {
if(argc<3) {
fprintf(stderr, "Usage: %s <infile> <outfile>\n", argv[0]);
return 1;
}
FILE *in, *out;
if((in=fopen(argv[1], "rb"))==NULL) {
perror("Could not open input file");
return 1;
}
if((out=fopen(argv[2], "wb"))==NULL) {
perror("Could not open output file");
return 1;
}
uint16_t palette_src[256];
uint16_t palette_tgt[256];
uint16_t i=0;
fread(palette_src, 2, 256, in);
for(i=0; i<256; i++) {
uint8_t tgt_index=i;
if(tgt_index) {
if(tgt_index>224) { // move upper colors to start
tgt_index-=224;
} else if(tgt_index==224) { // remap 224 to 32, not 0
tgt_index=32;
} else { // shift colors, leave gap 176-191
// relocate 0xd0-0xdf (which would be
// remapped to 0x00-0x0f) to 0xb0-0xbf
tgt_index+=32;
if(tgt_index>=176) {
tgt_index+=16;
if(tgt_index<16) tgt_index=0xb0+tgt_index;
}
}
}
palette_tgt[tgt_index] = palette_src[i];
}
fwrite(palette_tgt, 2, 256, out);
fclose(out);
fclose(in);
return 0;
}

View File

@ -55,6 +55,8 @@ end
000 HiROM 000 HiROM
001 LoROM 001 LoROM
010 ExHiROM (48-64Mbit) 010 ExHiROM (48-64Mbit)
111 menu (ROM in upper SRAM)
*/ */
/* HiROM: SRAM @ Bank 0x30-0x3f, 0xb0-0xbf /* HiROM: SRAM @ Bank 0x30-0x3f, 0xb0-0xbf
@ -67,9 +69,11 @@ assign IS_ROM = ( (MAPPER == 3'b000) ? ( (!SNES_ADDR[22]
|(SNES_ADDR[22])) |(SNES_ADDR[22]))
: (MAPPER == 3'b010) ? ((!SNES_ADDR[22] & SNES_ADDR[15]) : (MAPPER == 3'b010) ? ((!SNES_ADDR[22] & SNES_ADDR[15])
|(SNES_ADDR[22])) |(SNES_ADDR[22]))
: (MAPPER == 3'b111) ? ((!SNES_ADDR[22] & SNES_ADDR[15])
|(SNES_ADDR[22]))
: 1'b0); : 1'b0);
assign IS_SAVERAM = ((MAPPER == 3'b000 || MAPPER == 3'b010) ? (!SNES_ADDR[22] assign IS_SAVERAM = ((MAPPER == 3'b000 || MAPPER == 3'b010 || MAPPER == 3'b111) ? (!SNES_ADDR[22]
& SNES_ADDR[21:20] & SNES_ADDR[21:20]
& &SNES_ADDR[14:13] & &SNES_ADDR[14:13]
& !SNES_ADDR[15] & !SNES_ADDR[15]
@ -94,6 +98,9 @@ assign SRAM_ADDR_FULL = (MODE) ? AVR_ADDR
:(MAPPER == 3'b010) ? :(MAPPER == 3'b010) ?
(IS_SAVERAM ? (SNES_ADDR[14:0] - 15'h6000) & SAVERAM_MASK (IS_SAVERAM ? (SNES_ADDR[14:0] - 15'h6000) & SAVERAM_MASK
: ({!SNES_ADDR[23], SNES_ADDR[21:0]} & ROM_MASK)) : ({!SNES_ADDR[23], SNES_ADDR[21:0]} & ROM_MASK))
:(MAPPER == 3'b111) ?
(IS_SAVERAM ? 23'h7F0000 + ((SNES_ADDR[14:0] - 15'h6000) & SAVERAM_MASK)
: ((SNES_ADDR[22:0] & ROM_MASK) + 23'h600000))
: 23'b0); : 23'b0);
assign SRAM_BANK = SRAM_ADDR_FULL[22:21]; assign SRAM_BANK = SRAM_ADDR_FULL[22:21];

View File

@ -147,7 +147,7 @@ always @(posedge clk) begin
// Read pulse is two spi cycles to ensure that the value // Read pulse is two spi cycles to ensure that the value
// is ready in the 2nd cycle in AVR master mode // is ready in the 2nd cycle in AVR master mode
if ((spi_bit_cnt == 3'h6 || spi_bit_cnt == 3'h7) & (cmd_data[7:4] == 4'h8) & (spi_byte_cnt > 32'h0)) if ((spi_bit_cnt == 3'h5 || spi_bit_cnt == 3'h6 || spi_bit_cnt == 3'h7) & (cmd_data[7:4] == 4'h8) & (spi_byte_cnt > 32'h0))
AVR_READ_BUF <= 1'b0; AVR_READ_BUF <= 1'b0;
else else
AVR_READ_BUF <= 1'b1; AVR_READ_BUF <= 1'b1;