Okay, so I've been successful in nearly everything related to making this, except one thing: I can't seem to get it to where I'm uploading from the correct address. So, it is able to find what slots are empty, make the linked list correctly, and upload the tiles in the correct location, but it just isn't able to upload them from the correct location.
I even tried to make it static to where it is loading "LOWORD(Test1Tiles)" and stuff like that, but it still doesn't work, inexplicably. I had noticed that I have direct page somewhere other than 0, (it's at the start of the object it is currently looking at) and so I've put an "a:" in front of anything else. Is this not always the same as loading something normally when direct page is #$0000? I mean, that's all I can think of.
The code is a mess because I kept running out of hardware registers and things are named poorly (which is easy enough to fix though). I already know I'll have to go back and optimize it, but that's for another day.
This almost looks like gibberish to me so I don't expect anyone else to be able to understand it, but I figure I might as well post it here. The object's identity is #$0004. #$0000 counts as nothing for objects, and it also counts as nothing for vram slots, that's why a majority of the tables are being offset by -2.
Code:
.proc vram_engine
rep #$30 ;A=16, X/Y=16
lda #ObjectTable
tcd
ldy #$0002
vram_engine_loop:
ldx ObjectSlot::RequestedFrame
beq next_object
lda a:AnimationFrameSlotUsageTable-2,x
beq find_vram
inc a:AnimationFrameSlotUsageTable-2,x
lda a:AnimationFrameLinkedListTable-2,x
sta ObjectSlot::VramOffset
stz ObjectSlot::RequestedFrame
next_object:
stz ObjectSlot::RequestedFrame
inx
inx
tdc
clc
adc #ObjectSlotSize
cmp #ObjectTable+ObjectTableSize
bcs vram_engine_done
tcd
bra vram_engine_loop
vram_engine_done:
rts
find_vram:
lda a:TilesInFrameTable-2,x
sta a:TilesInFrame
lda a:VramAddressFrameTable-2,x
sta a:VramAddressOfFrame
lda a:VramBankByteFrameTable-2,x
sta a:BankByteOfFrame
find_vram_loop_1:
lda a:VramLinkedListTable-2,y
beq open_slot_found_1
iny
iny
cpy #$0102
bcc find_vram_loop_1
bra next_object
open_slot_found_1:
tya
sta a:AnimationFrameLinkedListTable-2,x
sta ObjectSlot::VramOffset
phy
ldy a:TileRequestCounter16x16
lda a:VramAddressToTransferAddressTable-2,x
sta a:TileRequestTable+VramAddress,y
lda a:VramAddressOfFrame
sta a:TileRequestTable+TileAddress,y
lda a:BankByteOfFrame
sta a:TileRequestTable+BankNumber,y
lda a:VramAddressOfFrame
clc
adc #$0020
sta a:VramAddressOfFrame
lda a:TileRequestCounter16x16
clc
adc #$0006
sta a:TileRequestCounter16x16
ply
dec a:TilesInFrame
beq next_object
tyx
iny
iny
cpy #$0102
bcc find_vram_loop_2
bra next_object
find_vram_loop_2:
lda a:VramLinkedListTable-2,y
beq open_slot_found_2
iny
iny
cpy #$0102
bcc find_vram_loop_2
bra next_object
open_slot_found_2:
tya
sta a:VramLinkedListTable-2,x
phy
ldy a:TileRequestCounter16x16
lda a:VramAddressToTransferAddressTable-2,x
sta a:TileRequestTable+VramAddress,y
lda a:VramAddressOfFrame
sta a:TileRequestTable+TileAddress,y
lda a:BankByteOfFrame
sta a:TileRequestTable+BankNumber,y
lda a:VramAddressOfFrame
clc
adc #$0020
sta a:VramAddressOfFrame
lda a:TileRequestCounter16x16
clc
adc #$0006
sta a:TileRequestCounter16x16
ply
dec a:TilesInFrame
beq jump_to_next_object
iny
iny
cpy #$0102
bcc find_vram_loop_2
jump_to_next_object:
brl next_object
.endproc
Code:
;=========================================================================================
.segment "RODATA"
;=========================================================================================
VramAdressToTileNumberTable:
.word $0000,$0002,$0004,$0006,$0008,$000A,$000C,$000E
.word $0020,$0022,$0024,$0026,$0028,$002A,$002C,$002E
.word $0040,$0042,$0044,$0046,$0048,$004A,$004C,$004E
.word $0060,$0062,$0064,$0066,$0068,$006A,$006C,$006E
.word $0080,$0082,$0084,$0086,$0088,$008A,$008C,$008E
.word $00A0,$00A2,$00A4,$00A6,$00A8,$00AA,$00AC,$00AE
.word $00C0,$00C2,$00C4,$00C6,$00C8,$00CA,$00CC,$00CE
.word $00E0,$00E2,$00E4,$00E6,$00E8,$00EA,$00EC,$00EE
.word $0100,$0102,$0104,$0106,$0108,$010A,$010C,$010E
.word $0120,$0122,$0124,$0126,$0128,$012A,$012C,$012E
.word $0140,$0142,$0144,$0146,$0148,$014A,$014C,$014E
.word $0160,$0162,$0164,$0166,$0168,$016A,$016C,$016E
.word $0180,$0182,$0184,$0186,$0188,$018A,$018C,$018E
.word $01A0,$01A2,$01A4,$01A6,$01A8,$01AA,$01AC,$01AE
.word $01C0,$01C2,$01C4,$01C6,$01C8,$01CA,$01CC,$01CE
.word $01E0,$01E2,$01E4,$01E6,$01E8,$01EA,$01EC,$01EE
VramAddressToTransferAddressTable:
.word $0000,$0020,$0040,$0060,$0080,$00A0,$00C0,$00E0
.word $0200,$0220,$0240,$0260,$0280,$02A0,$02C0,$02E0
.word $0400,$0420,$0440,$0460,$0480,$04A0,$04C0,$04E0
.word $0600,$0620,$0640,$0660,$0680,$06A0,$06C0,$06E0
.word $0800,$0820,$0840,$0860,$0880,$08A0,$08C0,$08E0
.word $0A00,$0A20,$0A40,$0A60,$0A80,$0AA0,$0AC0,$0AE0
.word $0C00,$0C20,$0C40,$0C60,$0C80,$0CA0,$0CC0,$0CE0
.word $0E00,$0E20,$0E40,$0E60,$0E80,$0EA0,$0EC0,$0EE0
.word $1000,$1002,$1004,$1006,$1008,$100A,$100C,$100E
.word $1200,$1220,$1240,$1260,$1280,$12A0,$12C0,$12E0
.word $1400,$1420,$1440,$1460,$1480,$14A0,$14C0,$14E0
.word $1600,$1620,$1640,$1660,$1680,$16A0,$16C0,$16E0
.word $1800,$1820,$1840,$1860,$1880,$18A0,$18C0,$18E0
.word $1A00,$1A20,$1A40,$1A60,$1A80,$1AA0,$1AC0,$1AE0
.word $1C00,$1C20,$1C40,$1C60,$1C80,$1CA0,$1CC0,$1CE0
.word $1E00,$1E20,$1E40,$1E60,$1E80,$1EA0,$1EC0,$1EE0
;=========================================================================================
TilesInFrameTable:
.word $0002,$0002
VramAddressFrameTable:
.word .LOWORD(Test1Tiles)
VramBankByteFrameTable:
.word .BANKBYTE(Test1Tiles),$00
;=========================================================================================
Test1Tiles:
.incbin "Test1.pic"
Test2Tiles:
.incbin "Test2.pic"
;=========================================================================================
Kind of random, but about things that are only used during one routine, I think I'll just have everything use its own space in vram and then just replace the names of everything so that they're all the same, like "Temporary1" or something like that. I have bigger concerns right now though.
Actually, hell, why not, here's the rom:
Attachment:
Vram Engine Test.zip [236.93 KiB]
Downloaded 122 times
Dang it, I keep realizing I have things to say... The vram engine doesn't have any sort of double buffering thing because I realized that I really don't need it right now. I'll incorporate one if I ever get to 16x16 and 32x32 sized sprites.