Need some tips for a demo
Posted: Thu Feb 14, 2019 2:48 pm
Hello,
So I've been working on SNES demo for a while, and it's working somewhat well right now. I can move the sprite from one border to the other, it's animated, and the background is scrolling.
Now, I don't know if anything I've done is best practice (and I think it certainly isn't). Maybe someone more experienced can give me some tips/make a code review?
My main questions are related to addressing.
Currently, what I'm doing is defining RAM addresses for global variables like this:
It's rather painful and ugly. I saw you can do it like that instead:
But I can't get it to work. I think maybe it has to do with bank switching? And for the case of of two bytes label, how can I access the high byte?
Also, for the assets, I have for example: (I manually declare the asset size and its ROM location.)
Isn't there a way to find out the same information automatically? The start address, the bank and the size?
-----
You can find the complete source code here:
https://github.com/vivi168/SNES_utils
Thank you for your help
So I've been working on SNES demo for a while, and it's working somewhat well right now. I can move the sprite from one border to the other, it's animated, and the background is scrolling.
Now, I don't know if anything I've done is best practice (and I think it certainly isn't). Maybe someone more experienced can give me some tips/make a code review?
My main questions are related to addressing.
Currently, what I'm doing is defining RAM addresses for global variables like this:
Code: Select all
PLAYER_SX = $0001
BGH_SCRL = $0002
BGH_SCRH = $0003
But I can't get it to work. I think maybe it has to do with bank switching? And for the case of of two bytes label, how can I access the high byte?
Code: Select all
.segment "ZEROPAGE"
PLAYER_SX: .res 1
BGH_SCR: .res 2
Isn't there a way to find out the same information automatically? The start address, the bank and the size?
Code: Select all
.segment "DATA"
.incbin "assets/background.png.vra"
BG_START = $8000
BG_SIZE = $800
; loading example, I've defined a macro
.segment "CODE"
; VRAM start, bank, asset start, asset size
transfer_vram #$0000, #$02, #BG_START, #BG_SIZE
You can find the complete source code here:
https://github.com/vivi168/SNES_utils
Thank you for your help

