mirror of
https://github.com/robmcmullen/asmgen.git
synced 2024-06-09 13:29:33 +00:00
Finally working demo of color & bw sprite
This commit is contained in:
parent
304d1269b3
commit
a4ba45872d
BIN
moldy_burger.png
BIN
moldy_burger.png
Binary file not shown.
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
182
multitest.s
182
multitest.s
|
@ -22,8 +22,9 @@ SCRATCH1 = $1a
|
||||||
SPRITEPTR_L = $1b
|
SPRITEPTR_L = $1b
|
||||||
SPRITEPTR_H = $1c
|
SPRITEPTR_H = $1c
|
||||||
|
|
||||||
*= $80
|
; constants
|
||||||
drawptr .ds 2
|
MAXPOSX = 127 ; This demo doesn't wanna do 16 bit math
|
||||||
|
MAXPOSY = 127
|
||||||
|
|
||||||
|
|
||||||
*= $6000
|
*= $6000
|
||||||
|
@ -34,128 +35,109 @@ start
|
||||||
bit TXTPAGE1
|
bit TXTPAGE1
|
||||||
bit SETHIRES
|
bit SETHIRES
|
||||||
|
|
||||||
|
;jsr clrscr
|
||||||
|
jsr initsprites
|
||||||
|
|
||||||
gameloop
|
gameloop
|
||||||
jmp draw
|
jsr renderstart
|
||||||
|
jsr movestart
|
||||||
|
jsr wait
|
||||||
|
jsr erasestart
|
||||||
|
jmp gameloop
|
||||||
|
|
||||||
jsr clrscr
|
|
||||||
|
|
||||||
ldx #0
|
initsprites
|
||||||
?1
|
nop
|
||||||
txa
|
rts
|
||||||
sta $2000,x
|
|
||||||
inx
|
|
||||||
bne ?1
|
|
||||||
|
|
||||||
; Draw sprites by looping through the list of sprites
|
; Draw sprites by looping through the list of sprites
|
||||||
renderinit
|
renderstart
|
||||||
lda #<drawlist
|
|
||||||
sta drawptr
|
|
||||||
lda #>drawlist
|
|
||||||
sta drawptr+1
|
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|
||||||
renderloop
|
renderloop
|
||||||
lda (drawptr),y
|
lda sprite_active,y
|
||||||
|
bmi renderend ; end of list if negative
|
||||||
|
beq renderskip ; skip if zero
|
||||||
|
lda sprite_l,y
|
||||||
sta jsrsprite+1
|
sta jsrsprite+1
|
||||||
iny
|
lda sprite_h,y
|
||||||
lda (drawptr),y
|
|
||||||
beq renderend ; check high byte is 0 ==> end of list
|
|
||||||
sta jsrsprite+2
|
sta jsrsprite+2
|
||||||
iny
|
lda sprite_x,y
|
||||||
lda (drawptr),y ; x coord
|
|
||||||
sta PARAM0
|
sta PARAM0
|
||||||
iny
|
lda sprite_y,y
|
||||||
lda (drawptr),y ; y coord
|
|
||||||
sta PARAM1
|
sta PARAM1
|
||||||
|
|
||||||
jsrsprite
|
jsrsprite
|
||||||
jsr $ffff
|
jsr $ffff ; wish you could JSR ($nnnn)
|
||||||
|
renderskip
|
||||||
; skip y coords
|
|
||||||
iny
|
iny
|
||||||
iny
|
bne renderloop ; branch always because always positive; otherwise limited to 255 sprites (haha)
|
||||||
bne renderLoop
|
|
||||||
|
|
||||||
jsr wait
|
renderend
|
||||||
inc PARAM0
|
rts
|
||||||
lda PARAM0
|
|
||||||
cmp #100
|
|
||||||
bcc checky
|
|
||||||
lda #0
|
|
||||||
sta PARAM0
|
|
||||||
|
|
||||||
movementLoop:
|
|
||||||
; Find our sprite pointer
|
|
||||||
lda spriteNum
|
|
||||||
asl
|
|
||||||
tax
|
|
||||||
lda META_BUFFERS+1,x
|
|
||||||
sta SPRITEPTR_H
|
|
||||||
lda META_BUFFERS,x
|
|
||||||
sta SPRITEPTR_L
|
|
||||||
|
|
||||||
|
movestart
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
moveloop
|
||||||
|
lda sprite_active,y
|
||||||
|
bmi moveend
|
||||||
|
beq movenext
|
||||||
|
|
||||||
|
movex
|
||||||
; Apply X velocity to X coordinate
|
; Apply X velocity to X coordinate
|
||||||
clc
|
clc
|
||||||
ldy #0
|
lda sprite_x,y
|
||||||
lda (SPRITEPTR_L),y
|
adc sprite_dx,y
|
||||||
ldy #2
|
|
||||||
adc (SPRITEPTR_L),y
|
|
||||||
bmi flipX
|
bmi flipX
|
||||||
cmp #MAXPOSX
|
cmp #MAXPOSX
|
||||||
bpl flipX
|
bpl flipX
|
||||||
|
|
||||||
; Store the new X
|
; Store the new X
|
||||||
ldy #0
|
sta sprite_x,y
|
||||||
sta (SPRITEPTR_L),y
|
|
||||||
|
|
||||||
adjustY:
|
movey
|
||||||
; Apply Y velocity to Y coordinate
|
; Apply Y velocity to Y coordinate
|
||||||
clc
|
clc
|
||||||
ldy #1
|
lda sprite_y,y
|
||||||
lda (SPRITEPTR_L),y
|
adc sprite_dy,y
|
||||||
ldy #3
|
|
||||||
adc (SPRITEPTR_L),y
|
|
||||||
bmi flipY
|
bmi flipY
|
||||||
cmp #MAXPOSY
|
cmp #MAXPOSY
|
||||||
bpl flipY
|
bpl flipY
|
||||||
|
|
||||||
; Store the new Y
|
; Store the new Y
|
||||||
ldy #1
|
sta sprite_y,y
|
||||||
sta (SPRITEPTR_L),y
|
|
||||||
|
|
||||||
continueMovementList:
|
movenext
|
||||||
dec spriteNum
|
iny
|
||||||
bmi movementRestartList
|
bne moveloop
|
||||||
jmp movementLoop
|
|
||||||
|
|
||||||
flipX:
|
moveend
|
||||||
lda (SPRITEPTR_L),y
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
flipX
|
||||||
|
lda sprite_dx,y
|
||||||
eor #$ff
|
eor #$ff
|
||||||
inc
|
clc
|
||||||
sta (SPRITEPTR_L),y
|
adc #1
|
||||||
bra adjustY
|
sta sprite_dx,y
|
||||||
|
jmp movey
|
||||||
|
|
||||||
flipY:
|
flipY
|
||||||
lda (SPRITEPTR_L),y
|
lda sprite_dy,y
|
||||||
eor #$ff
|
eor #$ff
|
||||||
inc
|
clc
|
||||||
sta (SPRITEPTR_L),y
|
adc #1
|
||||||
bra continueMovementList
|
sta sprite_dy,y
|
||||||
|
jmp moveloop
|
||||||
movementRestartList:
|
|
||||||
lda #MAXSPRITEINDEX
|
|
||||||
sta spriteNum
|
|
||||||
jmp renderLoop
|
|
||||||
|
|
||||||
|
|
||||||
checky
|
erasestart
|
||||||
inc PARAM1
|
rts
|
||||||
lda PARAM1
|
|
||||||
cmp #100
|
|
||||||
bcc loop
|
|
||||||
lda #0
|
|
||||||
sta PARAM1
|
|
||||||
beq loop
|
|
||||||
|
|
||||||
wait
|
wait
|
||||||
ldy #$06 ; Loop a bit
|
ldy #$06 ; Loop a bit
|
||||||
|
@ -194,26 +176,26 @@ clr1
|
||||||
bcc clr1
|
bcc clr1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
sprite_active
|
||||||
|
.byte 1, 1, 0, $ff ; 1 = active, 0 = skip, $ff = end of list
|
||||||
|
|
||||||
drawlist
|
sprite_l
|
||||||
.word SPRITE1
|
.byte <COLORSPRITE, <BWSPRITE, 0, 0
|
||||||
.word SPRITE2
|
|
||||||
.word 0
|
|
||||||
|
|
||||||
|
sprite_h
|
||||||
|
.byte >COLORSPRITE, >BWSPRITE, 0, 0
|
||||||
|
|
||||||
SPRITE1
|
sprite_x
|
||||||
.word COLORSPRITE
|
.byte 80, 64, 0, 0
|
||||||
.byte 80 ; X pos
|
|
||||||
.byte 116 ; Y pos
|
|
||||||
.byte -1 ; X vec
|
|
||||||
.byte -3 ; Y vec
|
|
||||||
|
|
||||||
SPRITE2
|
sprite_y
|
||||||
.word BWSPRITE
|
.byte 116, 126, 0, 0
|
||||||
.byte 64 ; X pos
|
|
||||||
.byte 126 ; Y pos
|
sprite_dx
|
||||||
.byte 4 ; X vec
|
.byte -1, 4, 0, 0
|
||||||
.byte 3 ; Y vec
|
|
||||||
|
sprite_dy
|
||||||
|
.byte -3, 1, 0, 0
|
||||||
|
|
||||||
|
|
||||||
.include colorsprite.s
|
.include colorsprite.s
|
||||||
|
|
Loading…
Reference in New Issue
Block a user