So I'm new to snes homebrew but I know how to program somewhat well.
So anyway, I've been sort of crapping around with SNES code in order to build my understanding of how this works and possibly eventually make my own game for lulz (Flappy Bird, anyone?)
There's a lot of helpful stuff on the superfamicom.org wiki to read about which has made it a lot easier for me.
Anyway, one thing I'm finding it especially difficult to grasp an understanding of is how you can display sprites on the screen. For example, how would I add just a stationary sprite to, say, the "walker" demo found in Neviksti’s Snes Starterkit?
So I make a borderless 32x32 pcx image and then run it through PCX2SNES and then get the .clr and .pic files.
I then know I'm supposed to add it to the bottom of my .asm file like so:
I understand that I'm then probably supposed to use LoadBlockToVRAM. In the walker example, adding "LoadBlockToVRAM newsprite, $9000, $0800" will look like this:
After spending a day or so studying the code, looking at other relevant code in other examples and reading stuff on superfamicom wiki, I can't really understand what exactly to do to just display my sprite stationary on the screen somewhere.
I know there are sprite numbers, but how do I assign a number? In the walker example, the main sprite appears to be put onto the screen using the following code:
It looks like the sprite number is #$54. If I change it to #$53 or 55, the walking guy sprite just disappears while I expected it to show a different sprite instead. Obviously there's more to it that I haven't been able to figure out by studying or trial and error. Can anyone help me with this?
My goal is to just get any sprite to appear in the walker example just so I can understand what exactly has to be done to do this again in a game of my own.
Thanks in advance
So anyway, I've been sort of crapping around with SNES code in order to build my understanding of how this works and possibly eventually make my own game for lulz (Flappy Bird, anyone?)
There's a lot of helpful stuff on the superfamicom.org wiki to read about which has made it a lot easier for me.
Anyway, one thing I'm finding it especially difficult to grasp an understanding of is how you can display sprites on the screen. For example, how would I add just a stationary sprite to, say, the "walker" demo found in Neviksti’s Snes Starterkit?
So I make a borderless 32x32 pcx image and then run it through PCX2SNES and then get the .clr and .pic files.
I then know I'm supposed to add it to the bottom of my .asm file like so:
Code:
BikerSprite
.INCBIN ".\\Pictures\\biker.pic"
.INCBIN ".\\Pictures\\biker.clr"
.INCBIN ".\\Pictures\\biker.pic"
.INCBIN ".\\Pictures\\biker.clr"
I understand that I'm then probably supposed to use LoadBlockToVRAM. In the walker example, adding "LoadBlockToVRAM newsprite, $9000, $0800" will look like this:
Code:
;Load Tile and Character data to VRAM
LoadBlockToVRAM BackgroundMap, $0000, $2000 ; 64x64 tiles = 4096 words = 8192 bytes
LoadBlockToVRAM BackgroundPics, $2000, $6000 ; 384 tiles * (8bit color)= 0x6000 bytes
LoadBlockToVRAM ASCIITiles, $5000, $0800 ;128 tiles * (2bit color = 2 planes) --> 2048 bytes
LoadBlockToVRAM SpriteTiles, $6000, $2800 ;20 32x32 tiles * (4bit color = 4 planes) --> 10240 bytes
LoadBlockToVRAM BikerSprite, $9000, $0800; new test sprite
LoadBlockToVRAM BackgroundMap, $0000, $2000 ; 64x64 tiles = 4096 words = 8192 bytes
LoadBlockToVRAM BackgroundPics, $2000, $6000 ; 384 tiles * (8bit color)= 0x6000 bytes
LoadBlockToVRAM ASCIITiles, $5000, $0800 ;128 tiles * (2bit color = 2 planes) --> 2048 bytes
LoadBlockToVRAM SpriteTiles, $6000, $2800 ;20 32x32 tiles * (4bit color = 4 planes) --> 10240 bytes
LoadBlockToVRAM BikerSprite, $9000, $0800; new test sprite
After spending a day or so studying the code, looking at other relevant code in other examples and reading stuff on superfamicom wiki, I can't really understand what exactly to do to just display my sprite stationary on the screen somewhere.
I know there are sprite numbers, but how do I assign a number? In the walker example, the main sprite appears to be put onto the screen using the following code:
Code:
;Set the priority bit of all the BG2 tiles
LDA #$80
STA $2115 ;set up the VRAM so we can write just to the high byte
LDX #$5800
STX $2116
LDX #$0400 ;32x32 tiles = 1024
LDA #$20
Next_tile:
STA $2119
DEX
BNE Next_tile
LDA #01
STA $1E
LDA #00
STA $20
JSR SpriteInit ;setup the sprite buffer
JSR JoyInit ;setup joypads and enable NMI
; ---12345678901234567890123456789012---
;setup our walking sprite
;put him in the center of the screen
lda #($80-16)
sta SpriteBuf1+sx
lda #(224/2-16)
sta SpriteBuf1+sy
;put sprite #0 on screen
lda #$54
sta SpriteBuf2
;set the sprite to the highest priority
lda #$30
sta SpriteBuf1+spriority
;setup the video modes and such, then turn on the screen
JSR SetupVideo
LDA #$80
STA $2115 ;set up the VRAM so we can write just to the high byte
LDX #$5800
STX $2116
LDX #$0400 ;32x32 tiles = 1024
LDA #$20
Next_tile:
STA $2119
DEX
BNE Next_tile
LDA #01
STA $1E
LDA #00
STA $20
JSR SpriteInit ;setup the sprite buffer
JSR JoyInit ;setup joypads and enable NMI
; ---12345678901234567890123456789012---
;setup our walking sprite
;put him in the center of the screen
lda #($80-16)
sta SpriteBuf1+sx
lda #(224/2-16)
sta SpriteBuf1+sy
;put sprite #0 on screen
lda #$54
sta SpriteBuf2
;set the sprite to the highest priority
lda #$30
sta SpriteBuf1+spriority
;setup the video modes and such, then turn on the screen
JSR SetupVideo
It looks like the sprite number is #$54. If I change it to #$53 or 55, the walking guy sprite just disappears while I expected it to show a different sprite instead. Obviously there's more to it that I haven't been able to figure out by studying or trial and error. Can anyone help me with this?
My goal is to just get any sprite to appear in the walker example just so I can understand what exactly has to be done to do this again in a game of my own.
Thanks in advance