mirror of
https://github.com/blondie7575/GSCats.git
synced 2025-02-19 14:30:58 +00:00
Game manager singleton added
This commit is contained in:
parent
c3c88a79ea
commit
d6ab080ac8
@ -15,6 +15,7 @@
|
||||
7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateRenderSpans.py; sourceTree = "<group>"; };
|
||||
7099E3841F41022100182A82 /* gameobject.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameobject.s; sourceTree = "<group>"; };
|
||||
7099E3851F4107B100182A82 /* GenerateVRAMYOffset.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateVRAMYOffset.py; sourceTree = "<group>"; };
|
||||
70A80FB01F43D7F200BD34C9 /* gamemanager.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gamemanager.s; sourceTree = "<group>"; };
|
||||
70E9D85F1F2BD95400555C19 /* equates.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = equates.s; sourceTree = "<group>"; };
|
||||
70E9D8601F2BD95400555C19 /* graphics.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = graphics.s; sourceTree = "<group>"; };
|
||||
70E9D8611F2BD95400555C19 /* gscats.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gscats.s; sourceTree = "<group>"; };
|
||||
@ -38,6 +39,7 @@
|
||||
70F086A01F4230CB002446C3 /* utility.s */,
|
||||
700C39C51F2E5CA800C24F9C /* tables.s */,
|
||||
70F0869F1F413A89002446C3 /* player.s */,
|
||||
70A80FB01F43D7F200BD34C9 /* gamemanager.s */,
|
||||
70E9D8611F2BD95400555C19 /* gscats.s */,
|
||||
70E9D8631F2BD95400555C19 /* Makefile */,
|
||||
7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */,
|
||||
|
192
gamemanager.s
Normal file
192
gamemanager.s
Normal file
@ -0,0 +1,192 @@
|
||||
;
|
||||
; gamemanager
|
||||
; The manager for overall game logic
|
||||
;
|
||||
; Created by Quinn Dunki on 8/15/17
|
||||
;
|
||||
|
||||
|
||||
beginGameplay:
|
||||
|
||||
; Set up palette for terrain and players
|
||||
lda #basePalette
|
||||
sta PARAML0
|
||||
lda #0
|
||||
jsr setPalette
|
||||
|
||||
; Erase the screen
|
||||
ldx #$2222
|
||||
jsr colorFill
|
||||
|
||||
; Generate, compile, and clip terrain
|
||||
jsr generateTerrain
|
||||
jsr compileTerrain
|
||||
jsr clipTerrain
|
||||
|
||||
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:
|
||||
|
||||
; Check for keys down
|
||||
jsr kbdScan
|
||||
|
||||
; Scroll map if needed
|
||||
lda mapScrollRequested
|
||||
bmi gameplayLoopPlayers
|
||||
jsr scrollMap
|
||||
|
||||
gameplayLoopPlayers:
|
||||
|
||||
; Update active player state if needed
|
||||
lda angleDeltaRequested
|
||||
beq gameplayLoopEndFrame
|
||||
jsr changeAngle
|
||||
|
||||
gameplayLoopEndFrame:
|
||||
|
||||
lda quitRequested
|
||||
beq gameplayLoop
|
||||
jmp quitGame
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; scrollMap
|
||||
;
|
||||
; Handles updating the state of the terrain in response to scrolling
|
||||
;
|
||||
scrollMap:
|
||||
jsr unclipTerrain
|
||||
|
||||
sta mapScrollPos
|
||||
asl
|
||||
sta leftScreenEdge
|
||||
|
||||
jsr clipTerrain
|
||||
lda #$ffff
|
||||
sta mapScrollRequested
|
||||
|
||||
lda #1
|
||||
sta terrainDirty
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; changeAngle
|
||||
;
|
||||
; Handles changing a player's aim
|
||||
;
|
||||
changeAngle:
|
||||
ldy #0
|
||||
tax
|
||||
jsr playerDeltaAngle
|
||||
|
||||
ldy #0
|
||||
jsr renderPlayerHeader
|
||||
|
||||
stz angleDeltaRequested
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; kbdScan
|
||||
; Processes keyboard input
|
||||
;
|
||||
; Trashes A
|
||||
;
|
||||
|
||||
kbdScan:
|
||||
EMULATION
|
||||
|
||||
kbdScanLoop:
|
||||
lda KBD
|
||||
bpl kbdScanDone
|
||||
sta KBDSTROBE
|
||||
|
||||
cmp #(8 + $80)
|
||||
beq kbdScanLeftArrow
|
||||
cmp #(21 + $80)
|
||||
beq kbdScanRightArrow
|
||||
cmp #(' ' + $80)
|
||||
beq kbdScanSpace
|
||||
cmp #('a' + $80)
|
||||
beq kbdScanA
|
||||
cmp #('z' + $80)
|
||||
beq kbdScanZ
|
||||
|
||||
kbdScanDone:
|
||||
NATIVE
|
||||
rts
|
||||
|
||||
kbdScanRightArrow:
|
||||
NATIVE
|
||||
lda mapScrollPos
|
||||
cmp #VISIBLETERRAINWIDTH-VISIBLETERRAINWINDOW
|
||||
beq kbdScanDone
|
||||
inc
|
||||
inc
|
||||
sta mapScrollRequested
|
||||
rts
|
||||
|
||||
kbdScanLeftArrow:
|
||||
NATIVE
|
||||
lda mapScrollPos
|
||||
beq kbdScanDone
|
||||
dec
|
||||
dec
|
||||
sta mapScrollRequested
|
||||
rts
|
||||
|
||||
kbdScanSpace:
|
||||
NATIVE
|
||||
lda #1
|
||||
sta quitRequested
|
||||
rts
|
||||
|
||||
kbdScanA:
|
||||
NATIVE
|
||||
lda #1
|
||||
sta angleDeltaRequested
|
||||
rts
|
||||
|
||||
kbdScanZ:
|
||||
NATIVE
|
||||
lda #-1
|
||||
sta angleDeltaRequested
|
||||
rts
|
||||
|
||||
|
||||
|
||||
basePalette:
|
||||
.word $0000,$0080,$0000,$000F,$0FFF,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF
|
||||
quitRequested:
|
||||
.word $0000
|
||||
mapScrollRequested:
|
||||
.word $FFFF
|
||||
angleDeltaRequested:
|
||||
.word $0000
|
||||
terrainDirty:
|
||||
.word 1
|
||||
|
||||
; 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
|
||||
; b) Word-distance from left edge of logical terrain to left edge of visible screen
|
||||
mapScrollPos:
|
||||
.word 0
|
||||
leftScreenEdge:
|
||||
.word 0 ; In pixels
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
157
gscats.s
157
gscats.s
@ -21,164 +21,12 @@ mainBank2:
|
||||
jsr initSCBs
|
||||
SHRVIDEO
|
||||
|
||||
lda #basePalette
|
||||
sta PARAML0
|
||||
lda #0
|
||||
jsr setPalette
|
||||
|
||||
ldx #$2222
|
||||
jsr colorFill
|
||||
jmp beginGameplay
|
||||
|
||||
jsr generateTerrain
|
||||
jsr compileTerrain
|
||||
jsr clipTerrain
|
||||
|
||||
ldy #0
|
||||
jsr renderPlayerHeader
|
||||
|
||||
mainGameLoop:
|
||||
|
||||
jsr syncVBL
|
||||
|
||||
jsr renderTerrain
|
||||
jsr kbdScan
|
||||
|
||||
lda mapScrollRequested
|
||||
bpl scrollMap
|
||||
|
||||
lda angleDeltaRequested
|
||||
bne changeAngle
|
||||
|
||||
lda #gameobjectData
|
||||
sta PARAML0
|
||||
jsr renderGameobject
|
||||
|
||||
lda quitRequested
|
||||
beq mainGameLoop
|
||||
|
||||
quit:
|
||||
quitGame:
|
||||
CLASSICVIDEO
|
||||
jml (proDOSLongJump)
|
||||
|
||||
scrollMap:
|
||||
jsr unclipTerrain
|
||||
|
||||
sta mapScrollPos
|
||||
asl
|
||||
sta leftScreenEdge
|
||||
|
||||
jsr clipTerrain
|
||||
lda #$ffff
|
||||
sta mapScrollRequested
|
||||
jmp mainGameLoop
|
||||
|
||||
changeAngle:
|
||||
ldy #0
|
||||
tax
|
||||
jsr playerDeltaAngle
|
||||
|
||||
ldy #0
|
||||
jsr renderPlayerHeader
|
||||
|
||||
stz angleDeltaRequested
|
||||
jmp mainGameLoop
|
||||
|
||||
reverseScroll:
|
||||
lda scrollV
|
||||
eor #$ffff
|
||||
inc
|
||||
sta scrollV
|
||||
jmp mainGameLoop
|
||||
|
||||
scrollV:
|
||||
.word 1
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; kbdScan
|
||||
; Processes keyboard input
|
||||
;
|
||||
; Trashes A
|
||||
;
|
||||
|
||||
kbdScan:
|
||||
EMULATION
|
||||
|
||||
kbdScanLoop:
|
||||
lda KBD
|
||||
bpl kbdScanDone
|
||||
sta KBDSTROBE
|
||||
|
||||
cmp #(8 + $80)
|
||||
beq kbdScanLeftArrow
|
||||
cmp #(21 + $80)
|
||||
beq kbdScanRightArrow
|
||||
cmp #(' ' + $80)
|
||||
beq kbdScanSpace
|
||||
cmp #('a' + $80)
|
||||
beq kbdScanA
|
||||
cmp #('z' + $80)
|
||||
beq kbdScanZ
|
||||
|
||||
kbdScanDone:
|
||||
NATIVE
|
||||
rts
|
||||
|
||||
kbdScanRightArrow:
|
||||
NATIVE
|
||||
lda mapScrollPos
|
||||
cmp #VISIBLETERRAINWIDTH-VISIBLETERRAINWINDOW
|
||||
beq kbdScanDone
|
||||
inc
|
||||
inc
|
||||
sta mapScrollRequested
|
||||
rts
|
||||
|
||||
kbdScanLeftArrow:
|
||||
NATIVE
|
||||
lda mapScrollPos
|
||||
beq kbdScanDone
|
||||
dec
|
||||
dec
|
||||
sta mapScrollRequested
|
||||
rts
|
||||
|
||||
kbdScanSpace:
|
||||
NATIVE
|
||||
lda #1
|
||||
sta quitRequested
|
||||
rts
|
||||
|
||||
kbdScanA:
|
||||
NATIVE
|
||||
lda #1
|
||||
sta angleDeltaRequested
|
||||
rts
|
||||
|
||||
kbdScanZ:
|
||||
NATIVE
|
||||
lda #-1
|
||||
sta angleDeltaRequested
|
||||
rts
|
||||
|
||||
|
||||
|
||||
basePalette:
|
||||
.word $0000,$0080,$0000,$000F,$0FFF,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF
|
||||
quitRequested:
|
||||
.word $0000
|
||||
mapScrollRequested:
|
||||
.word $FFFF
|
||||
angleDeltaRequested:
|
||||
.word $0000
|
||||
|
||||
|
||||
; 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
|
||||
; b) Word-distance from left edge of logical terrain to left edge of visible screen
|
||||
mapScrollPos:
|
||||
.word 0
|
||||
leftScreenEdge:
|
||||
.word 0 ; In pixels
|
||||
|
||||
.include "graphics.s"
|
||||
.include "font.s"
|
||||
@ -187,6 +35,7 @@ leftScreenEdge:
|
||||
.include "player.s"
|
||||
.include "utility.s"
|
||||
.include "tables.s"
|
||||
.include "gamemanager.s"
|
||||
endMainBank2:
|
||||
|
||||
|
||||
|
11
player.s
11
player.s
@ -57,6 +57,17 @@ playerDeltaAngleClampHigh:
|
||||
bra playerDeltaAngleStore
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; renderPlayers
|
||||
;
|
||||
;
|
||||
renderPlayers:
|
||||
lda #playerData
|
||||
sta PARAML0
|
||||
jsr renderGameobject
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; renderPlayerHeader
|
||||
;
|
||||
|
Loading…
x
Reference in New Issue
Block a user