2017-08-16 02:04:22 +00:00
|
|
|
;
|
|
|
|
; gamemanager
|
|
|
|
; The manager for overall game logic
|
|
|
|
;
|
|
|
|
; Created by Quinn Dunki on 8/15/17
|
|
|
|
;
|
|
|
|
|
2017-09-03 00:31:12 +00:00
|
|
|
NUMPLAYERS = 2
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
|
|
|
|
beginGameplay:
|
|
|
|
|
|
|
|
; Set up palette for terrain and players
|
|
|
|
lda #basePalette
|
|
|
|
sta PARAML0
|
|
|
|
lda #0
|
|
|
|
jsr setPalette
|
|
|
|
|
|
|
|
; Erase the screen
|
2017-09-30 20:01:36 +00:00
|
|
|
ldx #$0000
|
2017-08-16 02:04:22 +00:00
|
|
|
jsr colorFill
|
|
|
|
|
|
|
|
; Generate, compile, and clip terrain
|
|
|
|
jsr generateTerrain
|
|
|
|
jsr compileTerrain
|
|
|
|
jsr clipTerrain
|
|
|
|
|
2017-09-02 19:32:40 +00:00
|
|
|
; Create players
|
2017-09-30 00:53:05 +00:00
|
|
|
lda #40
|
2017-09-03 00:31:12 +00:00
|
|
|
ldy #0
|
|
|
|
jsr playerCreate
|
|
|
|
|
2017-09-30 00:53:05 +00:00
|
|
|
lda #196
|
2017-09-03 00:31:12 +00:00
|
|
|
ldy #1
|
2017-09-02 19:32:40 +00:00
|
|
|
jsr playerCreate
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
ldy #0
|
|
|
|
jsr renderPlayerHeader
|
|
|
|
|
|
|
|
gameplayLoop:
|
|
|
|
|
|
|
|
jsr syncVBL
|
|
|
|
|
|
|
|
; Render the terrain if needed
|
|
|
|
lda terrainDirty
|
|
|
|
beq gameplayLoopKbd
|
|
|
|
jsr renderTerrain
|
|
|
|
stz terrainDirty
|
|
|
|
|
|
|
|
; Render players
|
|
|
|
jsr renderPlayers
|
|
|
|
|
|
|
|
gameplayLoopKbd:
|
2017-09-30 20:01:36 +00:00
|
|
|
; lda projectileActive
|
|
|
|
; bpl gameplayLoopProjectiles ; Skip input during shots
|
2017-09-05 19:48:30 +00:00
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
; Check for keys down
|
|
|
|
jsr kbdScan
|
|
|
|
|
2017-09-30 20:01:36 +00:00
|
|
|
; Check for pause
|
|
|
|
lda paused
|
|
|
|
bne gameplayLoopEndFrame
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
; Scroll map if needed
|
|
|
|
lda mapScrollRequested
|
2017-08-21 00:51:12 +00:00
|
|
|
bmi gameplayLoopAngle
|
2017-08-16 02:04:22 +00:00
|
|
|
jsr scrollMap
|
|
|
|
|
2017-08-21 00:51:12 +00:00
|
|
|
gameplayLoopAngle:
|
|
|
|
; Update aim angle if needed
|
2017-08-16 02:04:22 +00:00
|
|
|
lda angleDeltaRequested
|
2017-09-05 19:55:27 +00:00
|
|
|
beq gameplayLoopPower
|
2017-08-16 02:04:22 +00:00
|
|
|
jsr changeAngle
|
|
|
|
|
2017-09-05 19:55:27 +00:00
|
|
|
gameplayLoopPower:
|
|
|
|
; Update power if needed
|
|
|
|
lda powerDeltaRequested
|
|
|
|
beq gameplayLoopFire
|
|
|
|
jsr changePower
|
|
|
|
|
2017-08-21 00:51:12 +00:00
|
|
|
gameplayLoopFire:
|
|
|
|
lda fireRequested
|
2017-08-23 03:33:07 +00:00
|
|
|
beq gameplayLoopProjectiles
|
2017-08-21 00:51:12 +00:00
|
|
|
jsr fire
|
|
|
|
|
2017-08-23 03:33:07 +00:00
|
|
|
gameplayLoopProjectiles:
|
2017-09-05 19:48:30 +00:00
|
|
|
sta KBDSTROBE
|
2017-08-25 04:45:05 +00:00
|
|
|
jsr unrenderProjectiles
|
2017-09-13 13:53:40 +00:00
|
|
|
jsr updateProjectilePhysics
|
2017-08-25 04:45:05 +00:00
|
|
|
jsr renderProjectiles
|
2017-09-13 13:53:40 +00:00
|
|
|
jsr updateProjectileCollisions
|
2017-08-23 03:33:07 +00:00
|
|
|
|
2017-09-03 00:31:12 +00:00
|
|
|
lda turnRequested
|
2017-09-04 00:20:24 +00:00
|
|
|
beq gameplayLoopVictoryCondition
|
2017-09-03 00:31:12 +00:00
|
|
|
jsr endTurn
|
2017-08-16 02:04:22 +00:00
|
|
|
|
2017-09-04 00:20:24 +00:00
|
|
|
gameplayLoopVictoryCondition:
|
|
|
|
lda gameOver
|
|
|
|
bmi gameplayLoopEndFrame
|
|
|
|
jsr endGame
|
|
|
|
|
2017-09-03 00:31:12 +00:00
|
|
|
gameplayLoopEndFrame:
|
2017-08-16 02:04:22 +00:00
|
|
|
lda quitRequested
|
|
|
|
beq gameplayLoop
|
|
|
|
jmp quitGame
|
|
|
|
|
|
|
|
|
2017-09-03 00:31:12 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; endTurn
|
|
|
|
;
|
|
|
|
; Handles changing the active player
|
|
|
|
;
|
|
|
|
endTurn:
|
|
|
|
lda currentPlayer
|
|
|
|
inc
|
|
|
|
cmp #NUMPLAYERS
|
|
|
|
beq endTurnWrap
|
|
|
|
sta currentPlayer
|
|
|
|
|
|
|
|
endTurnRefresh:
|
|
|
|
ldy currentPlayer
|
|
|
|
jsr renderPlayerHeader
|
|
|
|
stz turnRequested
|
|
|
|
rts
|
|
|
|
|
|
|
|
endTurnWrap:
|
|
|
|
stz currentPlayer
|
|
|
|
bra endTurnRefresh
|
|
|
|
|
|
|
|
|
2017-09-04 00:20:24 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; endGame
|
|
|
|
;
|
|
|
|
; Handles someone winning
|
|
|
|
;
|
|
|
|
endGame:
|
|
|
|
lda #1
|
|
|
|
sta quitRequested
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; scrollMap
|
|
|
|
;
|
|
|
|
; Handles updating the state of the terrain in response to scrolling
|
|
|
|
;
|
|
|
|
scrollMap:
|
|
|
|
jsr unclipTerrain
|
|
|
|
|
|
|
|
sta mapScrollPos
|
|
|
|
asl
|
|
|
|
sta leftScreenEdge
|
2017-09-02 19:32:40 +00:00
|
|
|
clc
|
2017-09-05 19:48:30 +00:00
|
|
|
adc #160-GAMEOBJECTWIDTH/4-1
|
2017-09-02 19:32:40 +00:00
|
|
|
sta rightScreenEdge
|
2017-08-16 02:04:22 +00:00
|
|
|
|
|
|
|
jsr clipTerrain
|
|
|
|
lda #$ffff
|
|
|
|
sta mapScrollRequested
|
|
|
|
|
|
|
|
lda #1
|
|
|
|
sta terrainDirty
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; changeAngle
|
|
|
|
;
|
|
|
|
; Handles changing a player's aim
|
|
|
|
;
|
|
|
|
changeAngle:
|
2017-09-03 00:31:12 +00:00
|
|
|
ldy currentPlayer
|
2017-08-16 02:04:22 +00:00
|
|
|
tax
|
|
|
|
jsr playerDeltaAngle
|
|
|
|
|
2017-09-03 00:31:12 +00:00
|
|
|
ldy currentPlayer
|
2017-08-16 02:04:22 +00:00
|
|
|
jsr renderPlayerHeader
|
|
|
|
|
|
|
|
stz angleDeltaRequested
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-09-05 19:55:27 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; changePower
|
|
|
|
;
|
|
|
|
; Handles changing a player's power
|
|
|
|
;
|
|
|
|
changePower:
|
|
|
|
ldy currentPlayer
|
|
|
|
tax
|
|
|
|
jsr playerDeltaPower
|
|
|
|
|
|
|
|
ldy currentPlayer
|
|
|
|
jsr renderPlayerHeader
|
|
|
|
|
|
|
|
stz powerDeltaRequested
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-08-21 00:51:12 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; fire
|
|
|
|
;
|
|
|
|
; Handles firing a player's weapon
|
|
|
|
;
|
|
|
|
fire:
|
|
|
|
stz fireRequested
|
2017-09-03 00:31:12 +00:00
|
|
|
ldy currentPlayer
|
2017-08-21 00:51:12 +00:00
|
|
|
jsr playerFire
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
basePalette:
|
2017-09-30 20:01:36 +00:00
|
|
|
.word $0000,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
quitRequested:
|
|
|
|
.word $0000
|
|
|
|
mapScrollRequested:
|
|
|
|
.word $FFFF
|
|
|
|
angleDeltaRequested:
|
|
|
|
.word $0000
|
2017-09-05 19:55:27 +00:00
|
|
|
powerDeltaRequested:
|
|
|
|
.word $0000
|
2017-08-21 00:51:12 +00:00
|
|
|
fireRequested:
|
|
|
|
.word $0000
|
2017-09-03 00:31:12 +00:00
|
|
|
turnRequested:
|
|
|
|
.word $0000
|
2017-08-16 02:04:22 +00:00
|
|
|
terrainDirty:
|
|
|
|
.word 1
|
2017-08-16 02:20:47 +00:00
|
|
|
activePlayer:
|
|
|
|
.word 0
|
2017-09-03 00:31:12 +00:00
|
|
|
currentPlayer:
|
|
|
|
.word 0
|
2017-09-04 00:20:24 +00:00
|
|
|
gameOver:
|
|
|
|
.word -1 ; Player index of winner
|
2017-09-05 19:48:30 +00:00
|
|
|
projectileActive:
|
|
|
|
.word -1
|
2017-09-30 20:01:36 +00:00
|
|
|
paused:
|
|
|
|
.word 0
|
2017-09-03 00:31:12 +00:00
|
|
|
|
2017-08-16 02:04:22 +00:00
|
|
|
|
|
|
|
; Position of map viewing window. Can be visualized in two ways:
|
|
|
|
; a) Word-distance from right edge of terrain data (which is in memory right-to-left) to left edge of visible screen
|
2017-09-02 19:32:40 +00:00
|
|
|
; b) Byte-distance from left edge of logical terrain to left edge of visible screen
|
|
|
|
; c) Byte-distance from left edge of logical terrain to right edge of visible screen minus game object width in words
|
2017-08-16 02:04:22 +00:00
|
|
|
mapScrollPos:
|
|
|
|
.word 0
|
|
|
|
leftScreenEdge:
|
2017-09-02 19:32:40 +00:00
|
|
|
.word 0
|
|
|
|
rightScreenEdge:
|
2017-09-05 19:48:30 +00:00
|
|
|
.word 160-GAMEOBJECTWIDTH/4-1
|