Optimization and fleshing out of demo app

This commit is contained in:
Quinn Dunki 2017-05-28 11:55:20 -07:00
parent f031405e33
commit d9cb4bd8af
4 changed files with 242 additions and 44 deletions

View File

@ -187,6 +187,79 @@ restoreBackground_smc5:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BlackRect
; PARAM0: X pos
; PARAM1: Y pos
;
; Assumes 4-byte-wide, 8px-high sprites
;
BlackRect:
SAVE_AX
lda #0
pha
blackRect_loop:
clc
pla
pha
adc PARAM1 ; Calculate Y line
tax
lda HGRROWS_H1,x ; Compute hires row
sta blackRect_smc0+2
sta blackRect_smc1+2
sta blackRect_smc2+2
sta blackRect_smc3+2
sta blackRect_smc4+2
sta blackRect_smc5+2
lda HGRROWS_L,x
sta blackRect_smc0+1
sta blackRect_smc1+1
sta blackRect_smc2+1
sta blackRect_smc3+1
sta blackRect_smc4+1
sta blackRect_smc5+1
ldx PARAM0 ; Compute hires column
lda DIV7_2,x
tax
blackRect_smc0:
stz $2000,x
inx
blackRect_smc1:
stz $2000,x
inx
blackRect_smc2:
stz $2000,x
inx
blackRect_smc3:
stz $2000,x
inx
blackRect_smc4:
stz $2000,x
inx
blackRect_smc5:
stz $2000,x
pla
inc
pha
cmp #8
bne blackRect_loop
pla
RESTORE_AX
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LinearFill
; A: Byte value to fill

Binary file not shown.

View File

@ -30,6 +30,10 @@ SCRATCH1 = $1a
SPRITEPTR_L = $1b
SPRITEPTR_H = $1c
MAXSPRITEINDEX = 19 ; Sprite count - 1
MAXPOSX = 127 ; This demo doesn't wanna do 16 bit math
MAXPOSY = 127
; Macros
.macro BLITBYTE xPos,yPos,addr
lda #xPos
@ -99,11 +103,11 @@ renderLoop:
sta PARAM0
; Calculate sprite background buffer location
lda BG_BUFFERS,x
sta PARAM2
lda BG_BUFFERS+1,x
sta PARAM3
jsr SaveBackground
; lda BG_BUFFERS,x
; sta PARAM2
; lda BG_BUFFERS+1,x
; sta PARAM3
; jsr SaveBackground
jsr BOXW_MAG
@ -113,11 +117,10 @@ renderLoop:
jmp renderLoop
restartList:
lda #9
lda #MAXSPRITEINDEX
sta spriteNum
jsr delayShort
jsr delayShort
; Background restore
backgroundLoop:
@ -142,11 +145,12 @@ backgroundLoop:
sta PARAM0
; Calculate sprite background buffer location
lda BG_BUFFERS,x
sta PARAM2
lda BG_BUFFERS+1,x
sta PARAM3
jsr RestoreBackground
;lda BG_BUFFERS,x
; sta PARAM2
; lda BG_BUFFERS+1,x
; sta PARAM3
; jsr RestoreBackground
jsr BlackRect
; Next sprite
dec spriteNum
@ -154,7 +158,7 @@ backgroundLoop:
jmp backgroundLoop
backgroundRestartList:
lda #9
lda #MAXSPRITEINDEX
sta spriteNum
movementLoop:
@ -167,26 +171,56 @@ movementLoop:
lda META_BUFFERS,x
sta SPRITEPTR_L
; Adjust X coordinate
; Apply X velocity to X coordinate
clc
ldy #0
lda (SPRITEPTR_L),y
inc
inc
cmp #132
beq resetX
ldy #2
adc (SPRITEPTR_L),y
bmi flipX
cmp #MAXPOSX
bpl flipX
storeAndContinue:
; Store the new X
ldy #0
sta (SPRITEPTR_L),y
adjustY:
; Apply Y velocity to Y coordinate
clc
ldy #1
lda (SPRITEPTR_L),y
ldy #3
adc (SPRITEPTR_L),y
bmi flipY
cmp #MAXPOSY
bpl flipY
; Store the new Y
ldy #1
sta (SPRITEPTR_L),y
continueMovementList:
dec spriteNum
bmi movementRestartList
jmp movementLoop
resetX:
lda #0
bra storeAndContinue
flipX:
lda (SPRITEPTR_L),y
eor #$ff
inc
sta (SPRITEPTR_L),y
bra adjustY
flipY:
lda (SPRITEPTR_L),y
eor #$ff
inc
sta (SPRITEPTR_L),y
bra continueMovementList
movementRestartList:
lda #9
lda #MAXSPRITEINDEX
sta spriteNum
jmp renderLoop
@ -223,7 +257,7 @@ delayShortInner:
spriteNum:
.byte 9
.byte MAXSPRITEINDEX
bgFilename:
.byte "KOL",0

View File

@ -28,46 +28,137 @@ META_BUFFERS:
.addr metaBuffer7
.addr metaBuffer8
.addr metaBuffer9
.addr metaBuffer10
.addr metaBuffer11
.addr metaBuffer12
.addr metaBuffer13
.addr metaBuffer14
.addr metaBuffer15
.addr metaBuffer16
.addr metaBuffer17
.addr metaBuffer18
.addr metaBuffer19
metaBuffer0:
.byte 0 ; X pos
.byte 0 ; Y pos
.byte 80 ; X pos
.byte 116 ; Y pos
.byte -1 ; X vec
.byte -3 ; Y vec
metaBuffer1:
.byte 0 ; X pos
.byte 10 ; Y pos
.byte 64 ; X pos
.byte 126 ; Y pos
.byte 4 ; X vec
.byte 3 ; Y vec
metaBuffer2:
.byte 0 ; X pos
.byte 20 ; Y pos
.byte 42 ; X pos
.byte 67 ; Y pos
.byte -3 ; X vec
.byte -3 ; Y vec
metaBuffer3:
.byte 0 ; X pos
.byte 30 ; Y pos
.byte 72 ; X pos
.byte 70 ; Y pos
.byte -3 ; X vec
.byte 5 ; Y vec
metaBuffer4:
.byte 0 ; X pos
.byte 40 ; Y pos
.byte 75 ; X pos
.byte 49 ; Y pos
.byte -5 ; X vec
.byte 3 ; Y vec
metaBuffer5:
.byte 0 ; X pos
.byte 50 ; Y pos
.byte 42 ; X pos
.byte 101 ; Y pos
.byte 4 ; X vec
.byte 2 ; Y vec
metaBuffer6:
.byte 0 ; X pos
.byte 60 ; Y pos
.byte 40 ; X pos
.byte 74 ; Y pos
.byte 4 ; X vec
.byte -5 ; Y vec
metaBuffer7:
.byte 0 ; X pos
.byte 70 ; Y pos
.byte 71 ; X pos
.byte 58 ; Y pos
.byte 5 ; X vec
.byte 5 ; Y vec
metaBuffer8:
.byte 0 ; X pos
.byte 80 ; Y pos
.byte 20 ; X pos
.byte 51 ; Y pos
.byte -5 ; X vec
.byte 3 ; Y vec
metaBuffer9:
.byte 0 ; X pos
.byte 90 ; Y pos
.byte 74 ; X pos
.byte 61 ; Y pos
.byte 1 ; X vec
.byte -2 ; Y vec
metaBuffer10:
.byte 115 ; X pos
.byte 86 ; Y pos
.byte 5 ; X vec
.byte -2 ; Y vec
metaBuffer11:
.byte 104 ; X pos
.byte 53 ; Y pos
.byte -5 ; X vec
.byte 1 ; Y vec
metaBuffer12:
.byte 21 ; X pos
.byte 2 ; Y pos
.byte 1 ; X vec
.byte 3 ; Y vec
metaBuffer13:
.byte 2 ; X pos
.byte 127 ; Y pos
.byte 1 ; X vec
.byte -5 ; Y vec
metaBuffer14:
.byte 97 ; X pos
.byte 123 ; Y pos
.byte 1 ; X vec
.byte -5 ; Y vec
metaBuffer15:
.byte 5 ; X pos
.byte 12 ; Y pos
.byte 1 ; X vec
.byte -1 ; Y vec
metaBuffer16:
.byte 4 ; X pos
.byte 40 ; Y pos
.byte -3 ; X vec
.byte 4 ; Y vec
metaBuffer17:
.byte 43 ; X pos
.byte 67 ; Y pos
.byte 4 ; X vec
.byte -1 ; Y vec
metaBuffer18:
.byte 105 ; X pos
.byte 43 ; Y pos
.byte -1 ; X vec
.byte -2 ; Y vec
metaBuffer19:
.byte 75 ; X pos
.byte 4 ; Y pos
.byte -3 ; X vec
.byte -5 ; Y vec
bgBuffer0:
.repeat 48