Fixed several rendering and input bugs

This commit is contained in:
blondie7575 2017-09-05 12:48:30 -07:00
parent 4525010273
commit c7efb24fe7
5 changed files with 41 additions and 6 deletions

View File

@ -52,6 +52,9 @@ gameplayLoop:
jsr renderPlayers
gameplayLoopKbd:
lda projectileActive
bpl gameplayLoopProjectiles ; Skip input during shots
; Check for keys down
jsr kbdScan
@ -72,6 +75,7 @@ gameplayLoopFire:
jsr fire
gameplayLoopProjectiles:
sta KBDSTROBE
jsr unrenderProjectiles
jsr updateProjectiles
jsr renderProjectiles
@ -137,7 +141,7 @@ scrollMap:
asl
sta leftScreenEdge
clc
adc #160-GAMEOBJECTWIDTH/4
adc #160-GAMEOBJECTWIDTH/4-1
sta rightScreenEdge
jsr clipTerrain
@ -199,6 +203,8 @@ currentPlayer:
.word 0
gameOver:
.word -1 ; Player index of winner
projectileActive:
.word -1
; Position of map viewing window. Can be visualized in two ways:
@ -210,4 +216,4 @@ mapScrollPos:
leftScreenEdge:
.word 0
rightScreenEdge:
.word 160-GAMEOBJECTWIDTH/4
.word 160-GAMEOBJECTWIDTH/4-1

View File

@ -203,6 +203,11 @@ renderGameobjectDone:
; X
lda ptr+GO_POSX,y
lsr
cmp leftScreenEdge
bmi unrenderGameobjectSkip ; Gameobject is off left edge of screen
cmp rightScreenEdge
bpl unrenderGameobjectSkip ; Gameobject is off right edge of screen
sec
sbc leftScreenEdge
sta SCRATCHL
@ -211,6 +216,10 @@ renderGameobjectDone:
sec
lda #200
sbc ptr+GO_POSY,y
bmi unrenderGameobjectSkip ; Gameobject is off top edge of screen
cmp #200 - GAMEOBJECTHEIGHT
bpl unrenderGameobjectSkip ; Gameobject is off bottom edge of screen
asl
tax
lda vramYOffset,x
@ -218,6 +227,12 @@ renderGameobjectDone:
adc SCRATCHL
tax ; X now contains the VRAM offset of the upper left corner
bra unrenderGameobjectBackground
unrenderGameobjectSkip:
jmp unrenderGameobjectDone
unrenderGameobjectBackground:
lda ptr+GO_BACKGROUND,y
sta VRAM,x
iny

Binary file not shown.

View File

@ -13,7 +13,7 @@ playerData:
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
.word 45 ; Angle in degrees from +X
.word 2 ; Power
.word 1 ; Power
.word 100 ; Anger
.byte 8,"SPROCKET " ; Name
.word 0,0,0,0,0,0 ;Padding
@ -23,8 +23,8 @@ playerData:
.word 0 ; Y pos in pixels (from bottom terrain edge)
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Saved background
.word 135 ; Angle in degrees from +X
.word 3 ; Power
.word 45 ; Angle in degrees from +X
.word 1 ; Power
.word 100 ; Anger
.byte 8,"TINKER " ; Name
.word 0,0,0,0,0,0 ;Padding

View File

@ -17,12 +17,14 @@ projectileData:
.word 0 ; Velocity X (8.8 fixed point)
.word 0 ; Velocity Y (8.8 fixed point)
.word 0 ; Type
.word 1 ; New?
JD_PRECISEX = 36 ; Byte offsets into projectile data structure
JD_PRECISEY = 38
JD_VX = 40
JD_VY = 42
JD_TYPE = 44
JD_NEW = 46
GRAVITY = $ffff ; 8.8 fixed point
@ -122,6 +124,10 @@ fireProjectile:
jsr mult88
sta projectileData+JD_VY,y
lda #1
sta projectileData+JD_NEW,y
stz projectileActive
RESTORE_AXY
rts
@ -246,6 +252,8 @@ updateProjectilesDelete:
jsr deleteProjectile
lda #1
sta turnRequested
lda #-1
sta projectileActive
bra updateProjectilesDone
updateProjectilesPlayerHit:
@ -294,7 +302,13 @@ renderProjectilesDone:
unrenderProjectiles:
pha
lda projectileData
bpl unrenderProjectilesDoIt
bpl unrenderProjectilesActive
jmp unrenderProjectilesDone
unrenderProjectilesActive:
lda projectileData+JD_NEW
beq unrenderProjectilesDoIt
stz projectileData+JD_NEW
jmp unrenderProjectilesDone
unrenderProjectilesDoIt: