Re: Need guidance with nes to snes.
Posted: Wed Mar 17, 2021 3:42 pm
Ok, so I'm making progress, but can't figure out why my DMA doesn't finish its transfer, and then doesnt transfer anything else when the routine is called upon 3 more times. I'll get my code up, rather big.
Here's the code
primary graphics load routine
dma routine
So what happens for the copyright screen, is that the primary graphics routine gets initiated 4 times, to set up the chr in the nes to $0000-$07FF, $0800-$0FFF, $1000-$17FF, $1800-$1FFF. And since in snes its 2 bytes wide per chr tile, i made a conversion table regarding the amount of bytes to transfer.
And i have the bank id's converted as well.
And when these routines load, i almost got the first dma transfer completed, then the other 3 times, i get nothing. Here is a breakdown of the bytes that are loaded.
So the conversion of mine, only $0F40-$0FE0 are not transferred via DMA, even though I set 1000 bytes to be transferred, and the remaining gfx I want transferred, nothing happens.
Here's the code
primary graphics load routine
Code: Select all
lda $f5 ;current $8000-$9FFF
pha
lda $f6 ;current $A000-$BFFF
pha
lda $08
pha
lda $09
pha
lda #$28 ;bank 28
sta $f6 ;bank 28 to $A000-$BFFF
jsr $ff37 ;mmc3 bankswap
lda $ff ;NES PPUCTRL
and #$fe
jmp $ed38 ;set bits from NES $2000 to SNES equivilents
lda $03b800,x ;lo byte pointer to gfx
sta $02
lda $03b870,x ;hi byte pointer to gfx
sta $03
ldy #$00
lda [$02],y ;if A=FF, no palettes, if 00-7F, palettes
bmi $da42
sta $0618,y ;sprite palette 2 & 3 buffer
sta $0638,y ;sprite palette 2 & 3 buffer
iny
cpy #$08 ;8 bytes loaded yet?
bne $da2d
lda #$ff ;palette buffer write flag
sta $18 ;palette buffer
bne $da43
iny
lda #$28 ;bank 28
sta $f6
jsr $ff37 ;mmc3 bankswap
lda [$02],y ;load bank id for gfx location
bmi $da77 ;if 80-FF, goto pull's to end routine
pha
iny
lda [$02],y ;hi byte # of bytes to transfer to vram
sta $08
iny
lda [$02},y ;hi byte to chr gfx
sta $06
ldx #$00
stx $05
iny
lda $4212 ;originally lda $2002 (nes)
lda [$02],y ;vram hi byte
sta $09
pla ;restore bank id for gfx location
sta $f5 ;store as $8000-$9FFF
sta $f6 ;store as $8000-$9FFF
inc $f6 ;inc so bank id will store as $A000-$BFFF
jsr $ff37 ;mmc3 bankswap
jmp $ecf2 ;dma routine
nop
nop
bne $da43
pla
sta $09
pla
sta $08
pla
sta $f6
pla
sta $f5
jmp $ff37 ;mmc3 bankswap
Code: Select all
phy
lda $09
sta $7b
lda $06
sta $7d
lda $08
sta $7f
rep #$18
lda #$80
sta $2115
ldy $007A ;vram target location
sty $2116
lda $f5 ;bank id
sta $4304
ldy $007c ;chr hi byte location
sty $4302
ldy $007e ;# of bytes to transfer
sty $4305
lda #$01
sta $4300
lda #$18
sta $4301
lda #$01
sta $420b
stz $7b
stz $7d
stz $7f
sep #$30
ply
jmp $da72
Code: Select all
strings represent tiles 00-0F, 10-1F, 20-2F, etc etc
1 string, 100 bytes - 200 bytes
2 strings, 200 bytes - 400 bytes
3 strings, 300 bytes - 600 bytes
4 strings, 400 bytes - 800 bytes
5 strings, 500 bytes - A00 bytes
6 strings, 600 bytes - C00 bytes
7 strings, 700 bytes - E00 bytes
8 strings, 800 bytes - 1000 bytes
9 strings, 900 bytes - 1200 bytes
10 strings, A00 bytes - 1400 bytes
11 strings, B00 bytes - 1600 bytes
12 strings, C00 bytes - 1800 bytes
13 strings, D00 bytes - 1A00 bytes
14 strings, E00 bytes - 1C00 bytes
15 strings, F00 bytes - 1E00 bytes
16 strings, 1000 bytes - 2000 bytes
And when these routines load, i almost got the first dma transfer completed, then the other 3 times, i get nothing. Here is a breakdown of the bytes that are loaded.
Code: Select all
breakdown
[palette (08 bytes, if no palette then first byte is always FF)] [bank id] [# of bytes to transfer in 100's] [hi byte gfx pointer] [hi byte ppu address]
original nes version
FF2408B800 2A089808 08089010 08029B18 02019A1A FF
my snes conversion
FF2B10F000 2C10B010 2410A040 2404B648 2102B44A FF