Milestone 11 hit very early, 2nd sprite on screen, on my way to a multisprite list that just gets iterated.

This commit is contained in:
2012-11-04 14:41:36 -05:00
parent 637764ff28
commit 38e8607572
3 changed files with 44 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
all: nesgame.nes all: nesgame.nes
nesgame.nes : nesgame.S nesgame.nes : nesgame.S
NESASM3 $< ophis -o $@ $<
.PHONY: test .PHONY: test
test: test:

3
README
View File

@@ -15,7 +15,8 @@ Milestone list:
8- Apply gravity to a sprite and have him stand on the "ground" 8- Apply gravity to a sprite and have him stand on the "ground"
9- Jumping sprite in response to the gamepad 9- Jumping sprite in response to the gamepad
10- Scrolling tile map (moving camera) 10- Scrolling tile map (moving camera)
11- Add a second actor/sprite to the screen and make it stand 11- (DONE) Add a second actor/sprite to the screen
11.5 Make all visible actors stand
12- Collide two actors with each other 12- Collide two actors with each other
13- Create actors on screen from map data (e.g. some data in RAM) 13- Create actors on screen from map data (e.g. some data in RAM)
14- Change an actor's sprite based on its state 14- Change an actor's sprite based on its state

View File

@@ -25,6 +25,8 @@
.space prevReturnAddrHi 1 .space prevReturnAddrHi 1
.org $0010 .org $0010
;; $0010 - 001F is reserved for global pointers ;; $0010 - 001F is reserved for global pointers
.space curSpriteOAMIndexLo 1
.space curSpriteOAMIndexHi 1
.space curSpriteDataLo 1 .space curSpriteDataLo 1
.space curSpriteDataHi 1 .space curSpriteDataHi 1
.org $0020 .org $0020
@@ -208,7 +210,29 @@ _MAIN_LoadPaletteLoop:
LDA sprMario LDA sprMario
PHA PHA
;; DO IT ;; DO IT
LDA #$00
STA curSpriteOAMIndexLo
LDA #$02
STA curSpriteOAMIndexHi
JSR oamInsertMultiSprite JSR oamInsertMultiSprite
;; ----------------------------------
LDA #$20
STA playerx
LDA #$20
STA playery
LDA #<sprMario2Data
PHA
LDA #>sprMario2Data
PHA
LDA sprMario2
PHA
LDA #$40
STA curSpriteOAMIndexLo
LDA #$02
STA curSpriteOAMIndexHi
JSR oamInsertMultiSprite
;; ---------------------------
_MAIN_loop: _MAIN_loop:
JMP _MAIN_loop ;; Loop forever JMP _MAIN_loop ;; Loop forever
@@ -242,18 +266,18 @@ _looptop:
LDA playery ; set Y position LDA playery ; set Y position
CLC CLC
ADC (curSpriteDataLo), y ADC (curSpriteDataLo), y
STA $0200, y STA (curSpriteOAMIndexLo), y
INY INY
LDA (curSpriteDataLo), y ; set tile number LDA (curSpriteDataLo), y ; set tile number
STA $0200, y STA (curSpriteOAMIndexLo), y
INY INY
LDA (curSpriteDataLo), y LDA (curSpriteDataLo), y
STA $0200, y STA (curSpriteOAMIndexLo), y
INY INY
LDA playerx ; set X position LDA playerx ; set X position
CLC CLC
ADC (curSpriteDataLo), y ADC (curSpriteDataLo), y
STA $0200, y STA (curSpriteOAMIndexLo), y
INY INY
INX ; increment the sprite counter INX ; increment the sprite counter
CPX curSpriteLen ; any more sprites in the current multisprite? CPX curSpriteLen ; any more sprites in the current multisprite?
@@ -292,6 +316,19 @@ sprMarioData:
.byte $18,$06,$00,$00 .byte $18,$06,$00,$00
.byte $18,$07,$00,$08 .byte $18,$07,$00,$08
sprMario2:
.byte $08 ; Total number of subsprites in this metasprite
sprMario2Data:
;; Y, Tile, Atr, X
.byte $00,$08,$00,$00
.byte $00,$09,$00,$08
.byte $08,$0A,$00,$00
.byte $08,$0B,$00,$08
.byte $10,$0C,$00,$00
.byte $10,$0D,$00,$08
.byte $18,$0E,$00,$00
.byte $18,$0F,$00,$08
.advance $FFFA .advance $FFFA
.word NMI ;; For Non-Maskable Interrupts, please jump to the location .word NMI ;; For Non-Maskable Interrupts, please jump to the location
;; of the NMI label ;; of the NMI label