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: Select all
BikerSprite
.INCBIN ".\\Pictures\\biker.pic"
.INCBIN ".\\Pictures\\biker.clr"
Code: Select all
;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
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: Select all
;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
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