Added mining and currency spend for weapons

This commit is contained in:
blondie7575 2021-09-23 12:36:48 -06:00
parent 7d3ae38f8f
commit ee42046090
9 changed files with 125 additions and 36 deletions

10
font.s
View File

@ -196,12 +196,12 @@ s_Number:
qbyte $00F00F00 qbyte $00F00F00
s_Dollar: s_Dollar:
qbyte $000F0F00
qbyte $00FFFFF0
qbyte $0F0F0F00
qbyte $00FFFF00 qbyte $00FFFF00
qbyte $000F0FF0 qbyte $0F000FF0
qbyte $0FFFFF00 qbyte $0F000FF0
qbyte $0FFFFFF0
qbyte $00FFFF00
qbyte $00000000
s_Percent: s_Percent:
qbyte $0FF000F0 qbyte $0FF000F0

View File

@ -372,6 +372,7 @@ fire:
stz fireRequested stz fireRequested
ldy currentPlayer ldy currentPlayer
jsr playerFire jsr playerFire
jsr renderPlayerHeader
rts rts

Binary file not shown.

View File

@ -29,7 +29,7 @@ renderInventory:
tya tya
clc clc
adc #playerData adc #playerData
adc #PD_INVENTORY adc #PD_PRICES
sta PARAML1 sta PARAML1
; Compute initial VRAM position ($E1-relative) ; Compute initial VRAM position ($E1-relative)
@ -114,13 +114,22 @@ renderInventoryItem_unselected:
lda (PARAML1),y lda (PARAML1),y
sta PARAML0 sta PARAML0
jsr intToString jsr intToString
; Prepend currency prefix to counter string
BITS8A
lda intToStringResult
inc
sta intToStringPrefix
lda #':' ; Colon maps to dollar sign in tiny number font
sta intToStringResult
BITS16
sec sec
pla pla
sbc #($2000 - 160*2)-1 ; Font engine wants VRAM-relative sbc #($2000 - 160*2)-1 ; Font engine wants VRAM-relative
tax tax
lda #intToStringResult lda #intToStringPrefix
jsr DrawNumber jsr DrawTinyNumber
renderInventoryItem_done: renderInventoryItem_done:
RESTORE_AXY RESTORE_AXY
@ -133,3 +142,25 @@ renderInventoryItem_abort:
renderInventoryItemIndex: renderInventoryItemIndex:
.word 0 .word 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; awardTreats
;
; PARAML0 = Amount to award
;
awardTreats:
SAVE_AY
ldy currentPlayer
PLAYERPTR_Y
clc
lda playerData+PD_TREATS,y
adc PARAML0
sta playerData+PD_TREATS,y
ldy currentPlayer
jsr renderPlayerHeader
RESTORE_AY
rts

View File

@ -7,6 +7,7 @@
playerData: playerData:
;;;;;;;;;;;; PLAYER 1 ;;;;;;;;;;;;;;
; gameobject data ; gameobject data
.word 0 ; X pos in pixels (from left terrain edge) .word 0 ; X pos in pixels (from left terrain edge)
.word 0 ; Y pos in pixels (from bottom terrain edge) .word 0 ; Y pos in pixels (from bottom terrain edge)
@ -20,13 +21,15 @@ playerData:
.word 100 ; Anger .word 100 ; Anger
.byte 8,"SPROCKET " ; Name .byte 8,"SPROCKET " ; Name
.word 1 ; Base Sprite .word 1 ; Base Sprite
.word 0,5,5,0,0,0,0,0 ; Inventory .word 0,5,7,0,0,0,0,0 ; Prices
.word 0 ; Current weapon .word 0 ; Current weapon
.word 7 ; Treats
.repeat 88 .repeat 86
.byte 0 ; Padding to 256-byte boundary .byte 0 ; Padding to 256-byte boundary
.endrepeat .endrepeat
;;;;;;;;;;;; PLAYER 2 ;;;;;;;;;;;;;;
; gameobject data ; gameobject data
.word 0 ; X pos in pixels (from left terrain edge) .word 0 ; X pos in pixels (from left terrain edge)
.word 0 ; Y pos in pixels (from bottom terrain edge) .word 0 ; Y pos in pixels (from bottom terrain edge)
@ -35,15 +38,16 @@ playerData:
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 155 ; Angle in degrees from +X .word 155 ; Angle in degrees from +X
.word 2 ; Power .word 2 ; Power
.word 100 ; Anger .word 100 ; Anger
.byte 8,"TINKER " ; Name .byte 8,"TINKER " ; Name
.word 0 ; Base Sprite .word 0 ; Base Sprite
.word 0,5,5,0,0,0,0,0 ; Inventory .word 0,5,7,0,0,0,0,0 ; Prices
.word 0 ; Current weapon .word 0 ; Current weapon
.word 7 ; Treats
.repeat 88 .repeat 86
.byte 0 ; Padding to 256-byte boundary .byte 0 ; Padding to 256-byte boundary
.endrepeat .endrepeat
@ -52,8 +56,9 @@ PD_POWER = 134
PD_ANGER = 136 PD_ANGER = 136
PD_NAME = 138 PD_NAME = 138
PD_BASESPRITE = 148 PD_BASESPRITE = 148
PD_INVENTORY = 150 PD_PRICES = 150
PD_CURRWEAPON = 166 PD_CURRWEAPON = 166
PD_TREATS = 168
PD_SIZE = 256 PD_SIZE = 256
.macro PLAYERPTR_Y .macro PLAYERPTR_Y
@ -172,30 +177,32 @@ playerDeltaPowerClampHigh:
; playerFire ; playerFire
; ;
; Y = Player index ; Y = Player index
; Trashes SCRATCHL ; Trashes SCRATCHL,SCRATCHL2
; ;
playerFire: playerFire:
SAVE_AX SAVE_AXY
PLAYERPTR_Y PLAYERPTR_Y
; Check for inventory ; Check that we can afford it
lda playerData+PD_CURRWEAPON,y lda playerData+PD_CURRWEAPON,y
pha pha
asl asl
tax tax
beq playerFire_infiniteAmmo ; Weapon 0 is always infinite
stx SCRATCHL stx SCRATCHL
lda #playerData+PD_INVENTORY lda #playerData+PD_PRICES
clc clc
adc SCRATCHL adc SCRATCHL
sta SCRATCHL sta SCRATCHL
lda (SCRATCHL),y lda (SCRATCHL),y
beq playerFire_abort sta SCRATCHL
dec ; Consume ammo
sta (SCRATCHL),y
dec inventoryDirty
playerFire_infiniteAmmo: lda playerData+PD_TREATS,y
cmp SCRATCHL
bmi playerFire_abort
sec ; Spend money
sbc SCRATCHL
sta playerData+PD_TREATS,y
; Prepare projectile parameters ; Prepare projectile parameters
pla pla
@ -213,7 +220,7 @@ playerFire_infiniteAmmo:
jsr fireProjectile jsr fireProjectile
playerFire_done: playerFire_done:
RESTORE_AX RESTORE_AXY
rts rts
playerFire_abort: playerFire_abort:
@ -358,6 +365,14 @@ renderPlayerHeader:
ldx #96 + 321 ldx #96 + 321
jsr drawNumber jsr drawNumber
lda #treatsStr
ldx #126 + 321
jsr DrawString
lda playerData+PD_TREATS,y
ldx #130 + 321
jsr drawNumber
RESTORE_AXY RESTORE_AXY
rts rts
@ -367,5 +382,7 @@ powerStr:
pstring "+: " pstring "+: "
angerStr: angerStr:
pstring "): " pstring "): "
treatsStr:
pstring "$ "

View File

@ -104,8 +104,9 @@ projectileTypes:
.addr 0 ; Render .addr 0 ; Render
.addr 0 ; Cleanup .addr 0 ; Cleanup
.word 1 ; Directional .word 1 ; Directional
.word 1 ; Mining
.repeat 12 .repeat 10
.byte 0 ; Padding to 32-byte boundary .byte 0 ; Padding to 32-byte boundary
.endrepeat .endrepeat
@ -120,8 +121,9 @@ projectileTypes:
.addr 0 ; Render .addr 0 ; Render
.addr 0 ; Cleanup .addr 0 ; Cleanup
.word 0 ; Directional .word 0 ; Directional
.word 0 ; Mining
.repeat 12 .repeat 10
.byte 0 ; Padding to 32-byte boundary .byte 0 ; Padding to 32-byte boundary
.endrepeat .endrepeat
@ -136,8 +138,10 @@ projectileTypes:
.addr renderFan ; Render .addr renderFan ; Render
.addr deleteFan ; Cleanup .addr deleteFan ; Cleanup
.word 1 ; Directional .word 1 ; Directional
.word 0 ; Mining
.repeat 12 .repeat 10
.byte 0 ; Padding to 32-byte boundary .byte 0 ; Padding to 32-byte boundary
.endrepeat .endrepeat
@ -152,6 +156,7 @@ PT_UPDATE = 12
PT_RENDER = 14 PT_RENDER = 14
PT_CLEANUP = 16 PT_CLEANUP = 16
PT_DIRECTIONAL = 18 PT_DIRECTIONAL = 18
PT_MINING = 20
.macro PROJECTILEPTR_Y .macro PROJECTILEPTR_Y
tya ; Pointer to projectile structure from index tya ; Pointer to projectile structure from index
@ -890,14 +895,14 @@ processTerrainImpact:
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
clc clc
adc #GAMEOBJECTWIDTH/2+1 ; A fudge that makes crater location look better in this direction, and tunneling work better adc #GAMEOBJECTWIDTH/2+1 ; A fudge that makes crater location look better in this direction, and tunneling work better
bra processTerrainStoreContinue bra processTerrainImpactStoreContinue
processTerrainImpactNegative: processTerrainImpactNegative:
lda projectileData+GO_POSX,y lda projectileData+GO_POSX,y
clc clc
adc #GAMEOBJECTWIDTH/4-1 ; A fudge that makes crater location look better in this direction, and tunneling work better adc #GAMEOBJECTWIDTH/4-1 ; A fudge that makes crater location look better in this direction, and tunneling work better
processTerrainStoreContinue: processTerrainImpactStoreContinue:
sta PARAML0 sta PARAML0
pha ; Dirt explosion will need this pha ; Dirt explosion will need this
lda projectileData+GO_POSY,y lda projectileData+GO_POSY,y
@ -916,7 +921,7 @@ processTerrainStoreContinue:
jsr craterTerrain jsr craterTerrain
jsr unclipTerrain jsr unclipTerrain
; Recompile the rows affected by the crater ; Recompile the rows affected by the crater
clc clc
@ -943,4 +948,22 @@ processTerrainStoreContinue:
sta PARAML0 sta PARAML0
jsr createDirtExplosion jsr createDirtExplosion
; Cash in the dirt if needed
ldy projectileActive
lda projectileData+JD_TYPE,y
tay
PROJECTILETYPEPTR_Y
lda projectileTypes+PT_MINING,y
beq processTerrainImpactDone
lda craterTerrainAccumulator
lsr ; Dirt to treats conversion rate
lsr
lsr
inc ; Ensure minimum one treat
sta PARAML0
jsr awardTreats
processTerrainImpactDone:
rts rts

View File

@ -12,7 +12,7 @@ F_CURRPOS: .word 0 ;current top left char position
F_NUMPTR = $06 ;pointer to string (including length byte) / DP F_NUMPTR = $06 ;pointer to string (including length byte) / DP
DrawNumber: DrawTinyNumber:
SAVE_AXY SAVE_AXY
sta F_NUMPTR sta F_NUMPTR
@ -85,6 +85,7 @@ DigitTable:
.addr s_7 .addr s_7
.addr s_8 .addr s_8
.addr s_9 .addr s_9
.addr s_SmallDollar ; Use ASCII code for colon
DigitData: DigitData:
@ -158,3 +159,10 @@ s_9:
fontword $00F0 fontword $00F0
fontword $00F0 fontword $00F0
s_SmallDollar: ; Use ASCII code for colon
.dbyt $a66a
.dbyt $6F66
.dbyt $6666
.dbyt $a66a
.dbyt $aaaa

View File

@ -69,6 +69,7 @@ renderTerrainDone:
craterTerrain: craterTerrain:
SAVE_AX SAVE_AX
stz craterTerrainAccumulator
lda #TERRAINWIDTH ; Convert X pos to terrain-right byte count lda #TERRAINWIDTH ; Convert X pos to terrain-right byte count
sec sec
sbc PARAML0 sbc PARAML0
@ -108,11 +109,17 @@ craterTerrainLoop:
adc PARAML1 ; Convert to terrain-space adc PARAML1 ; Convert to terrain-space
bmi craterTerrainZero bmi craterTerrainZero
sta SCRATCHL2 sta SCRATCHL2
sec
lda (PARAML0),y lda (PARAML0),y
cmp SCRATCHL2 sbc SCRATCHL2
bmi craterTerrainLoop bmi craterTerrainLoop
lda SCRATCHL2 ; Circle value is lower, so use that ; Circle value is lower, so use that
clc
adc craterTerrainAccumulator ; Track total crater material
sta craterTerrainAccumulator
lda SCRATCHL2 ; Replace terrain height with cratered value
sta (PARAML0),y sta (PARAML0),y
bra craterTerrainLoop bra craterTerrainLoop
@ -128,6 +135,8 @@ craterTerrainDone:
RESTORE_AX RESTORE_AX
rts rts
craterTerrainAccumulator:
.word 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; clipTerrain ; clipTerrain

View File

@ -96,9 +96,9 @@ intToStringDone:
rts rts
intToStringBCD: .byte 0,0,0 intToStringBCD: .byte 0,0,0
intToStringPrefix: .byte 0
intToStringResult: .byte 0,0,0,0,0,0 intToStringResult: .byte 0,0,0,0,0,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mult16 ; mult16
; ;