From 38e8607572ff5650283874f8ffd9dacbbbabd4fc Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sun, 4 Nov 2012 14:41:36 -0500 Subject: [PATCH] Milestone 11 hit very early, 2nd sprite on screen, on my way to a multisprite list that just gets iterated. --- Makefile | 2 +- README | 3 ++- nesgame.S | 45 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d3c82ef..1ee7f98 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: nesgame.nes nesgame.nes : nesgame.S - NESASM3 $< + ophis -o $@ $< .PHONY: test test: diff --git a/README b/README index 61e36fa..f016f25 100644 --- a/README +++ b/README @@ -15,7 +15,8 @@ Milestone list: 8- Apply gravity to a sprite and have him stand on the "ground" 9- Jumping sprite in response to the gamepad 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 13- Create actors on screen from map data (e.g. some data in RAM) 14- Change an actor's sprite based on its state diff --git a/nesgame.S b/nesgame.S index 65c89a6..c853fd8 100644 --- a/nesgame.S +++ b/nesgame.S @@ -25,6 +25,8 @@ .space prevReturnAddrHi 1 .org $0010 ;; $0010 - 001F is reserved for global pointers + .space curSpriteOAMIndexLo 1 + .space curSpriteOAMIndexHi 1 .space curSpriteDataLo 1 .space curSpriteDataHi 1 .org $0020 @@ -208,7 +210,29 @@ _MAIN_LoadPaletteLoop: LDA sprMario PHA ;; DO IT + LDA #$00 + STA curSpriteOAMIndexLo + LDA #$02 + STA curSpriteOAMIndexHi JSR oamInsertMultiSprite + ;; ---------------------------------- + LDA #$20 + STA playerx + LDA #$20 + STA playery + LDA #sprMario2Data + PHA + LDA sprMario2 + PHA + LDA #$40 + STA curSpriteOAMIndexLo + LDA #$02 + STA curSpriteOAMIndexHi + JSR oamInsertMultiSprite + ;; --------------------------- + _MAIN_loop: JMP _MAIN_loop ;; Loop forever @@ -242,18 +266,18 @@ _looptop: LDA playery ; set Y position CLC ADC (curSpriteDataLo), y - STA $0200, y + STA (curSpriteOAMIndexLo), y INY LDA (curSpriteDataLo), y ; set tile number - STA $0200, y + STA (curSpriteOAMIndexLo), y INY LDA (curSpriteDataLo), y - STA $0200, y + STA (curSpriteOAMIndexLo), y INY LDA playerx ; set X position CLC ADC (curSpriteDataLo), y - STA $0200, y + STA (curSpriteOAMIndexLo), y INY INX ; increment the sprite counter CPX curSpriteLen ; any more sprites in the current multisprite? @@ -292,6 +316,19 @@ sprMarioData: .byte $18,$06,$00,$00 .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 .word NMI ;; For Non-Maskable Interrupts, please jump to the location ;; of the NMI label