Question on tile animation

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
infidelity
Posts: 486
Joined: Fri Mar 01, 2013 4:46 am

Re: Question on tile animation

Post by infidelity »

Thank You Khaz & AWJ!

The 2bpp gfx now appear correctly within the snes vram 2bpp viewer, due to changing to the GB codec within the snes rom! :-D

And thank you AWJ on that $2100 snes address! That did the trick! As soon as $420B was written to, I saw the vram fill up instantaneously, AND, I did not need to keep consistently jumping back to the start of dma/vram routine to keep it on!

I'd like to post what I have from my beginnings. I do NOT have anything written to any BG planes, nor any palettes, all I have is the initialization setup, turn on brightness to full, and my dma/vram test to upload 1000 bytes to vram.

Question, I'm not sure if I understood correctly on $2100. Does that act the same way as ppu rendering on/off for nes, like turning the screen to black? Just wondering if I need to come up with a new method, for writing to actual tiles from vram to the bg planes, once I get that far.

Anyway here is what I have for code, it's all within 00:0000.

Code: Select all

;initialization setup
008000 sei                    A:0000 X:0000 Y:0000 S:01ff D:0000 DB:00 nv1BdIzc V:  0 H: 186
008001 clc                    A:0000 X:0000 Y:0000 S:01ff D:0000 DB:00 nv1BdIzc V:  0 H: 208
008002 xce                    A:0000 X:0000 Y:0000 S:01ff D:0000 DB:00 nv1BdIzc V:  0 H: 230
008003 rep #$18               A:0000 X:0000 Y:0000 S:01ff D:0000 DB:00 nvMXdIzC V:  0 H: 252
008005 ldx #$1fff             A:0000 X:0000 Y:0000 S:01ff D:0000 DB:00 nvMxdIzC V:  0 H: 282
008008 txs                    A:0000 X:1fff Y:0000 S:01ff D:0000 DB:00 nvMxdIzC V:  0 H: 314
008009 jsr $800f     [00800f] A:0000 X:1fff Y:0000 S:1fff D:0000 DB:00 nvMxdIzC V:  0 H: 336
00800f sep #$30               A:0000 X:1fff Y:0000 S:1ffd D:0000 DB:00 nvMxdIzC V:  0 H: 390
008011 lda #$8f               A:0000 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  0 H: 420
008013 sta $2100     [002100] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 444
008016 stz $2100     [002100] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 482
008019 stz $2101     [002101] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 520
00801c stz $2102     [002102] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 598
00801f stz $2103     [002103] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 636
008022 stz $2105     [002105] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 674
008025 stz $2106     [002106] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 712
008028 stz $2107     [002107] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 750
00802b stz $2108     [002108] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 788
00802e stz $2109     [002109] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 826
008031 stz $210a     [00210a] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 864
008034 stz $210b     [00210b] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 902
008037 stz $210c     [00210c] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 940
00803a stz $210d     [00210d] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H: 978
00803d stz $210d     [00210d] A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1016
008040 lda #$ff               A:008f X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1054
008042 sta $210e     [00210e] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1078
008045 sta $2110     [002110] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1116
008048 sta $2112     [002112] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1154
00804b sta $2114     [002114] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1192
00804e lda #$07               A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  0 H:1230
008050 sta $210e     [00210e] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  0 H:1254
008053 sta $2110     [002110] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  0 H:1292
008056 sta $2112     [002112] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  0 H:1330
008059 sta $2114     [002114] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:   4
00805c stz $210f     [00210f] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:  42
00805f stz $210f     [00210f] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:  80
008062 stz $2111     [002111] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 118
008065 stz $2111     [002111] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 156
008068 stz $2113     [002113] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 194
00806b stz $2113     [002113] A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 232
00806e lda #$80               A:0007 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 270
008070 sta $2115     [002115] A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 294
008073 stz $2116     [002116] A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 332
008076 stz $2117     [002117] A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 370
008079 stz $211a     [00211a] A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 408
00807c stz $211b     [00211b] A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 446
00807f lda #$01               A:0080 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  1 H: 484
008081 sta $211b     [00211b] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 508
008084 stz $211c     [00211c] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 586
008087 stz $211c     [00211c] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 624
00808a stz $211d     [00211d] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 662
00808d stz $211d     [00211d] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 700
008090 stz $211e     [00211e] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 738
008093 sta $211e     [00211e] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 776
008096 stz $211f     [00211f] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 814
008099 stz $211f     [00211f] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 852
00809c stz $2120     [002120] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 890
00809f stz $2120     [002120] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 928
0080a2 stz $2121     [002121] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H: 966
0080a5 stz $2123     [002123] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1004
0080a8 stz $2124     [002124] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1042
0080ab stz $2125     [002125] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1080
0080ae stz $2126     [002126] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1118
0080b1 stz $2127     [002127] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1156
0080b4 stz $2128     [002128] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1194
0080b7 stz $2129     [002129] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1232
0080ba stz $212a     [00212a] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1270
0080bd stz $212b     [00212b] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1308
0080c0 stz $212c     [00212c] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  1 H:1346
0080c3 stz $212d     [00212d] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H:  20
0080c6 stz $212e     [00212e] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H:  58
0080c9 stz $212f     [00212f] A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H:  96
0080cc lda #$30               A:0001 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H: 134
0080ce sta $2130     [002130] A:0030 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H: 158
0080d1 stz $2131     [002131] A:0030 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H: 196
0080d4 lda #$e0               A:0030 X:00ff Y:0000 S:1ffd D:0000 DB:00 nvMXdIzC V:  2 H: 234
0080d6 sta $2132     [002132] A:00e0 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 258
0080d9 stz $2133     [002133] A:00e0 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 296
0080dc stz $4200     [004200] A:00e0 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 334
0080df lda #$ff               A:00e0 X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 372
0080e1 sta $4201     [004201] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 396
0080e4 stz $4202     [004202] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 434
0080e7 stz $4203     [004203] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 472
0080ea stz $4204     [004204] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 510
0080ed stz $4205     [004205] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 588
0080f0 stz $4206     [004206] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 626
0080f3 stz $4207     [004207] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 664
0080f6 stz $4208     [004208] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 702
0080f9 stz $4209     [004209] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 740
0080fc stz $420a     [00420a] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 778
0080ff stz $420b     [00420b] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 816
008102 stz $420c     [00420c] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 854
008105 stz $420d     [00420d] A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 892
008108 cli                    A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdIzC V:  2 H: 930
008109 rts                    A:00ff X:00ff Y:0000 S:1ffd D:0000 DB:00 NvMXdizC V:  2 H: 952

;jmp to dma/vram routine. the inc of $0f is for my own personal write breakpoint, so I don't have to step through the initialization setup
00800c jmp $810a     [00810a] A:00ff X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1002

;dma/vram test
00810a inc $0f       [00000f] A:00ff X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1034
00810c lda #$80               A:00ff X:00ff Y:0000 S:1fff D:0000 DB:00 nvMXdizC V:  2 H:1080
00810e sta $2115     [002115] A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1104
008111 lda #$80               A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1142
008113 sta $2100     [002100] A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1166
008116 rep #$10               A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H:1204
008118 ldx #$0000             A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H:1234
00811b stx $2116     [002116] A:0080 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V:  2 H:1266
00811e lda #$01               A:0080 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V:  2 H:1310
008120 sta $4300     [004300] A:0001 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H:1334
008123 lda #$18               A:0001 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H:   8
008125 sta $4301     [004301] A:0018 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H:  32
008128 ldx #$9000             A:0018 X:0000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H:  70
00812b stx $4302     [004302] A:0018 X:9000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  3 H: 102
00812e lda #$00               A:0018 X:9000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  3 H: 146
008130 sta $4304     [004304] A:0000 X:9000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V:  3 H: 170
008133 ldx #$2000             A:0000 X:9000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V:  3 H: 208
008136 stx $4305     [004305] A:0000 X:2000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H: 240
008139 lda #$01               A:0000 X:2000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H: 284
00813b sta $420b     [00420b] A:0001 X:2000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H: 308
00813e jmp $813e     [00813e] A:0001 X:2000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  3 H: 346
User avatar
Khaz
Posts: 314
Joined: Thu Dec 25, 2014 10:26 pm
Location: Canada

Re: Question on tile animation

Post by Khaz »

Glad to hear you've got that fixed! I'd say the good news is it's very little work to get from where you are now to displaying a background on screen. You just have to set up a few registers to tell the PPU what video mode you're in and where to find the tiles and tilemap in VRAM, and then build a tilemap. Specifically you'll definitely need to set up $2105 (mode/tile sizes) and $2107-$210D (VRAM locations for each BG Tileset/map).

You'll also need to write a palette to CGRAM to make the tiles appear correctly. You can input your colours manually using $2121 and $2122, or you can DMA a palette to $2122 just like you DMA'd the tiles.

(And if you're looking for a quick reference for the SNES's registers, my copy of Yoshi's (err, Koitsu's) "Snes1.txt" document has been absolutely indispensible to me since day one... Long since forgotten where I found it.)

EDIT: Forgot:
Question, I'm not sure if I understood correctly on $2100. Does that act the same way as ppu rendering on/off for nes, like turning the screen to black? Just wondering if I need to come up with a new method, for writing to actual tiles from vram to the bg planes, once I get that far.
If you turn the screen off with $2100 the PPU stops drawing, meaning the screen instantly turns black and you're able to access VRAM again. For most normal purposes, you'll turn the screen on once and leave it, and do all your VRAM-accessing during vBlank. If you need more time, you can use $2100 to keep the screen off until you're done and turn it on after, at the expense of vertical drawing room.
infidelity
Posts: 486
Joined: Fri Mar 01, 2013 4:46 am

Re: Question on tile animation

Post by infidelity »

would it be because I'm loading 1000/2000 bytes of data into the dma/vram, that I'm required to shut off $2100? Cause I'm thinking maybe that's why when I did a bare bones write to the vram with one tile without dma, there was no issue. I'll start begin working on upload an entire palette set using dma too, I already have just one color inserted into the transparent palette slot. :-)
User avatar
Khaz
Posts: 314
Joined: Thu Dec 25, 2014 10:26 pm
Location: Canada

Re: Question on tile animation

Post by Khaz »

infidelity wrote:would it be because I'm loading 1000/2000 bytes of data into the dma/vram, that I'm required to shut off $2100? Cause I'm thinking maybe that's why when I did a bare bones write to the vram with one tile without dma, there was no issue
Quite possibly, I forget offhand how much you can DMA in one vBlank. It's also very likely to do with your program (I assume) going straight from initialization to the DMA without timing it to a vBlank, so you were probably trying to start the DMA right in the middle of the screen to begin with.

And speaking of timing when you want to go beyond just making things appear on screen to actually animating backgrounds and such, you'll need to have an actual game-loop-structure in your code too, whereby you have a main loop that waits for a vBlank interrupt every time through (probably with a WAI instruction) and a vBlank interrupt routine that does all your interactions with VRAM. Which I should mention; to do that you need to enable the vBlank interrupt by writing $80 to $4200.
93143
Posts: 1371
Joined: Fri Jul 04, 2014 9:31 pm

Re: Question on tile animation

Post by 93143 »

Khaz wrote:(And if you're looking for a quick reference for the SNES's registers, my copy of Yoshi's (err, Koitsu's) "Snes1.txt" document has been absolutely indispensible to me since day one... Long since forgotten where I found it.)
I use the collected information on superfamicom.org, a lot of which is transcribed from anomie's docs. Several of the pages have gotten a lot of use, but the Registers page is one of two that I keep going back to no matter what I'm doing, the other being the 65816 reference page (I was new to ASM when I started a year ago). For second opinions and to confirm the latest known data on a topic, I check the newer (but IMO harder to navigate) fullsnes by nocash.
infidelity wrote:would it be because I'm loading 1000/2000 bytes of data into the dma/vram, that I'm required to shut off $2100? Cause I'm thinking maybe that's why when I did a bare bones write to the vram with one tile without dma, there was no issue.
Did the earlier attempt have the same code context, so that it would happen at the same time? It could be that you randomly hit VBlank. As far as I know it doesn't matter whether it's the CPU proper or the DMA unit that's putting the values on the bus; you can't change VRAM during active display. I'd suspect an emulator bug, but with bsnes that's pretty unlikely unless you're deliberately trying to exploit an edge case...
Khaz wrote:I forget offhand how much you can DMA in one vBlank.
A regular VBlank is 38 lines at 165.5 bytes per line, minus handling time at the beginning. About 6 kB. I suspect the problem here is timing - trying to run VRAM loading code without a timed trigger is a recipe for general failure peppered with random successes...
infidelity
Posts: 486
Joined: Fri Mar 01, 2013 4:46 am

Re: Question on tile animation

Post by infidelity »

yeah everything im doing is based off of seeing if I can get things to work for the first time. I honestly don't have any kind of demo or project in mind lol, im just excited to be able to get stuff (somewhat) working and appearing on the snes.

I tried reusing the exact same method I did for my dmd/vram, and try a dma/palette setup, only chaning the low byte of $2118 to 22, so that it's storing the palette data to $2122. I tried loading 200 bytes, but only 100 of the 200 logged bytes are being stored within the CGRAM. This is what I have.

Code: Select all

008155 lda #$22               A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 724
008157 sta $4301     [004301] A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 748
00815a ldx #$a000             A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 786
00815d stx $4302     [004302] A:0022 X:a000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 818
008160 lda #$00               A:0022 X:a000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 862
008162 sta $4304     [004304] A:0000 X:a000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 886
008165 ldx #$0200             A:0000 X:a000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 924
008168 stx $4305     [004305] A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 956
00816b lda #$01               A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1000
00816d sta $420b     [00420b] A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1024
008170 lda #$80               A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1062
008172 sta $2100     [002100] A:0080 X:0200 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 30 H:1234
I'm still trying to figure it out, can thank you guys enough for all of your info and help!
AWJ
Posts: 433
Joined: Mon Nov 10, 2008 3:09 pm

Re: Question on tile animation

Post by AWJ »

infidelity wrote:yeah everything im doing is based off of seeing if I can get things to work for the first time. I honestly don't have any kind of demo or project in mind lol, im just excited to be able to get stuff (somewhat) working and appearing on the snes.

I tried reusing the exact same method I did for my dmd/vram, and try a dma/palette setup, only chaning the low byte of $2118 to 22, so that it's storing the palette data to $2122. I tried loading 200 bytes, but only 100 of the 200 logged bytes are being stored within the CGRAM. This is what I have.

Code: Select all

008155 lda #$22               A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 724
008157 sta $4301     [004301] A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 748
00815a ldx #$a000             A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 786
00815d stx $4302     [004302] A:0022 X:a000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 818
008160 lda #$00               A:0022 X:a000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 862
008162 sta $4304     [004304] A:0000 X:a000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 886
008165 ldx #$0200             A:0000 X:a000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 924
008168 stx $4305     [004305] A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 956
00816b lda #$01               A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1000
00816d sta $420b     [00420b] A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1024
008170 lda #$80               A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1062
008172 sta $2100     [002100] A:0080 X:0200 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 30 H:1234
I'm still trying to figure it out, can thank you guys enough for all of your info and help!
If you're transferring to CGRAM you have to use DMA transfer mode 0 or 2, rather than transfer mode 1 as with VRAM (in other words, write #$00 or #$02 to $43x0 rather than #$01). You want to write all the bytes to $2122, not alternate between $2122 and $2123.
infidelity
Posts: 486
Joined: Fri Mar 01, 2013 4:46 am

Re: Question on tile animation

Post by infidelity »

Thank you AWJ! That was the issue, plus, it seemed I needed to only use LDA #$00 STA $2121, to properly set the starting point for my CG-RAM. I was doing LDA #$0000 $8E2121, and it wasn't storing the palette hex values correctly. But when I did the LDA #$00, it stored them correctly. I know this because I copied/pasted the 200 bytes used in the bootup for Super Mario World. So this is the code I have for loading 200 bytes. :-)

Code: Select all

;already have x/y set to 16-bit's

008141 lda #$00               A:0001 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 692
008143 sta $4300     [004300] A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 716
008146 lda #$00               A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 754
008148 sta $2121     [002121] A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 778
00814b lda #$22               A:0000 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 816
00814d sta $4301     [004301] A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 840
008150 ldx #$b000             A:0022 X:1000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H: 878
008153 stx $4302     [004302] A:0022 X:b000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 910
008156 lda #$00               A:0022 X:b000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V: 27 H: 954
008158 sta $4304     [004304] A:0000 X:b000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H: 978
00815b ldx #$0200             A:0000 X:b000 Y:0000 S:1fff D:0000 DB:00 nvMxdiZC V: 27 H:1016
00815e stx $4305     [004305] A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1048
008161 lda #$01               A:0000 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1092
008163 sta $420b     [00420b] A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1116
008166 lda #$0f               A:0001 X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 27 H:1154
008168 sta $2100     [002100] A:000f X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 30 H:1326
00816b jmp $816b     [00816b] A:000f X:0200 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V: 31 H:   0
So I hope at some point today to begin seeing if I can draw a tile to a BG plane.

EDIT

I'm doing a test to see if I can fill the entire vram with tiles. So far, I'm able to load 8000 bytes into the vram, but if I go any higher, the bytes from 8000-FFFF are not correct, I'm assuming this is because I cant reach the other bank.

I have my tiles stored at address (viewing in a hex editor) $10000-$1FFFF, so that's 16 full chr pages of tiles, and it should fill the entire vram when viewing in 2bpp mode.

My question is, is there a way for me to read the DMA address that deals with how many bytes are stored into it, and if im able to perform some sort of CMP, where I can adjust the DMA register that looks for the bank id to load the rest of the tiles from? I'm asking this, incase you are only allowed 8000 bytes, and then have to re-write the routine again, due to needing to change the bank id.

This is what I have for loading the entire vram from $0000-$FFFF.

Code: Select all

;load 8000 bytes into vram, from $0000-$7FFF, in bank 02, while asm is running in bank 00
00810c lda #$80               A:00ff X:00ff Y:0000 S:1fff D:0000 DB:00 nvMXdizC V:  2 H: 264
00810e sta $2115     [002115] A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H: 288
008111 lda #$80               A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H: 326
008113 sta $2100     [002100] A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H: 350
008116 rep #$10               A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMXdizC V:  2 H: 388
008118 stz $2116     [002116] A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 418
00811b lda #$01               A:0080 X:00ff Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 456
00811d sta $4300     [004300] A:0001 X:00ff Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 480
008120 lda #$18               A:0001 X:00ff Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 518
008122 sta $4301     [004301] A:0018 X:00ff Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 582
008125 ldx #$8000             A:0018 X:00ff Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 620
008128 stx $4302     [004302] A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 652
00812b lda #$02               A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 696
00812d sta $4304     [004304] A:0002 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 720
008130 ldx #$8000             A:0002 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 758
008133 stx $4305     [004305] A:0002 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 790
008136 lda #$01               A:0002 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:  2 H: 834
008138 sta $420b     [00420b] A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 858

;load 8000 bytes into vram, from $8000-$FFFF, in bank 03, while asm is running in bank 00
;for some reason at 00:813E, I need to set the vram high byte as C0, to start at vram address $8000?
00813b stz $2116     [002116] A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:  2 H: 896
00813e lda #$c0               A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H: 958
008140 sta $2117     [002117] A:00c0 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H: 982
008143 lda #$01               A:00c0 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H:1020
008145 sta $4300     [004300] A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1044
008148 lda #$18               A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1082
00814a sta $4301     [004301] A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1106
00814d ldx #$8000             A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1144
008150 stx $4302     [004302] A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H:1176
008153 lda #$03               A:0018 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H:1220
008155 sta $4304     [004304] A:0003 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1244
008158 ldx #$8000             A:0003 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:200 H:1282
00815b stx $4305     [004305] A:0003 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H:1314
00815e lda #$01               A:0003 X:8000 Y:0000 S:1fff D:0000 DB:00 NvMxdizC V:200 H:1358
008160 sta $420b     [00420b] A:0001 X:8000 Y:0000 S:1fff D:0000 DB:00 nvMxdizC V:201 H:  18
Image

Thanks everyone! :-)
93143
Posts: 1371
Joined: Fri Jul 04, 2014 9:31 pm

Re: Question on tile animation

Post by 93143 »

infidelity wrote:So far, I'm able to load 8000 bytes into the vram, but if I go any higher, the bytes from 8000-FFFF are not correct, I'm assuming this is because I cant reach the other bank.

I have my tiles stored at address (viewing in a hex editor) $10000-$1FFFF, so that's 16 full chr pages of tiles, and it should fill the entire vram when viewing in 2bpp mode.
Sounds like a memory mapping issue.

First off, please note that in order to determine how the location of data in a hex editor translates to its location in the system's memory map, it's necessary to know what memory model you're using. If you're hex-editing a ROM directly, I'm not sure I have the requisite understanding to instruct you - it's the cartridge, not the SNES, that determines the ROM mapping...

On a Super NES, banks $00-$3F and $80-$BF have registers and mirrored RAM in the bottom half of each bank; they're somewhat like the NES's memory map. This is very useful since you get fast access to all MMIO resources as well as the bottom 8 kB of internal WRAM, but it means you can only access 32 kB of ROM per bank. A type of ROM mapping called (by hackers) LoROM restricts ROM bank sizes to 32 kB so as to allow fast access to all data from within these bank ranges.

Banks $40-$7D and $C0-$FF are 100% ROM (the 128 kB of internal WRAM takes up banks $7E and $7F), so you can access a whole ROM bank there. A type of ROM mapping called HiROM allows 64 kB data banks, so you can read data in 64 kB chunks in these bank ranges, but this means you can only read the top half of a ROM bank in $00-$3F and $80-$BF.

For small to medium-sized games, normally the ROM is mirrored across bank ranges. If you're using HiROM, for instance, the 64 kB of ROM that you can't access all of in bank $01 (or $81) will be present in its entirety in banks $41 and $C1. Games over 2 MB (LoROM) or 4 MB (HiROM) have to use less mirroring; the 12 MB Star Ocean hack uses none (it's a mix of 32 kB and 64 kB ROM banks).

...

If I had to guess, I'd say you're probably using LoROM, which would explain why the data at $10000-$1FFFF is ending up in banks $02 and $03. You won't be able to DMA that in one chunk from there, because the data is no longer contiguous in the SNES memory map (shadow RAM and MMIO are in between the two halves). Even in the all-ROM regions it wouldn't work (assuming my LoROM conjecture is correct), because DMA wraps within a bank - not to mention that not all LoROM mappings bother to mirror $8000-$FFFF to $0000-$7FFF in those banks. To access 64 kB all at once you need to be using HiROM and access the data in $40-$7D or $C0-$FF.

...

Also note that addresses into VRAM are word, not byte.
User avatar
Khaz
Posts: 314
Joined: Thu Dec 25, 2014 10:26 pm
Location: Canada

Re: Question on tile animation

Post by Khaz »

At the risk of being a little off topic, I have a "tile animation" question that's rather specific, and it's short so I didn't feel like starting a thread over it. Was watching a TAS of Demon's Crest and admiring the final boss's death animation at 35:10. I've seen similar animations in other games - Dragon View has one really nice teleport animation that's the same kinda concept (here at 28:43), with the sprite spreading out vertically one line at a time.

Does anyone know, in general terms, how that's done? The Demon's Crest version I could see deleting pixels from VRAM in some repeating pattern to do the fading effect, but spreading it out vertically like that seems like a royal pain. Is there maybe some easy trick to it I'm missing out on? Demon's Crest's one is a bit big for it but I could see giving each horizontal strip its own sprites in Dragon View, so you can move them more freely.

Just curious...
Last edited by Khaz on Fri May 22, 2015 5:44 pm, edited 1 time in total.
KungFuFurby
Posts: 264
Joined: Wed Jul 09, 2008 8:46 pm

Re: Question on tile animation

Post by KungFuFurby »

For Demon's Crest, I think it's a combination of deleting pixels in VRAM and a per-scanline effect of modifying the BG scroll registers (for Dragon View, the sprite may have been transferred to a background layer, too... although it may also be rendering the effect, too on a per-line basis, although it's limited to the size of the sprite).
User avatar
Khaz
Posts: 314
Joined: Thu Dec 25, 2014 10:26 pm
Location: Canada

Re: Question on tile animation

Post by Khaz »

KungFuFurby wrote:For Demon's Crest, I think it's a combination of deleting pixels in VRAM and a per-scanline effect of modifying the BG scroll registers (for Dragon View, the sprite may have been transferred to a background layer, too... although it may also be rendering the effect, too on a per-line basis, although it's limited to the size of the sprite).
Ahaa, that makes perfect sense for Demon's Crest, especially considering the background is just a solid colour gradient. I should have realized there was a free layer there.

I'm not sure what Dragon View's doing though, I'm pretty sure there's no spare BG layer in that room. Seeing as how the effect stays within the original sprite area, I think it's probably actually editing the sprite tiles. I should have a closer look and actually see what's going on...

EDIT: Alright, I was wrong. The instant you touch the warp point, Dragon View copies that crouching position over to BG1. BG1 is apparently empty in that room. It SHOULD be used for the bit of foreground along the bottom with the doorway, but I guess they used sprites for that just in this room so they could abuse BG1.
Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: Question on tile animation

Post by Optiroc »

Khaz wrote:EDIT: Alright, I was wrong. The instant you touch the warp point, Dragon View copies that crouching position over to BG1. BG1 is apparently empty in that room. It SHOULD be used for the bit of foreground along the bottom with the doorway, but I guess they used sprites for that just in this room so they could abuse BG1.
Color me surprised, I was also betting on a sprite based effect (either allocating plenty of sprites or blitting into just one or two). I'm surprised they didn't go further with the HDMA tables then, the effect does look kinda lame...
infidelity
Posts: 486
Joined: Fri Mar 01, 2013 4:46 am

Re: Question on tile animation

Post by infidelity »

Thank you 93143, for explaining the LoROM HiRom. That explains why I need to do 8000 bytes (hex) at a time for dma/vram transfer.

Ok I have another question on vram. The vram has address $0000-$FFFF. I currently have it entirely filled with tile data, as seen in my previous post with a pic. Where do the bg planes store the tile data? Is it within the vram I already have filled? Is there another (ram) section that I don't know about that holds these values? Thanks! :-)
Last edited by infidelity on Sat May 23, 2015 6:15 am, edited 1 time in total.
KungFuFurby
Posts: 264
Joined: Wed Jul 09, 2008 8:46 pm

Re: Question on tile animation

Post by KungFuFurby »

infidelity wrote:Thank you 93143, for explaining the LoROM HiRom. That explains why I need to do 8000 bytes at a time for dma/vram transfer.
Better revise that to 32,768 bytes for the convenience for our readers (which is $8000 bytes in hexadecimal). Reduces confusion that way (I sometimes end up doing that myself). Also, that's only good if the data is at the start of the bank ($xx8000-$xxFFFF)... otherwise, you've got until the end of the bank, followed by any data on the next bank for the next transfer.
Post Reply