Add game timer.
This commit is contained in:
parent
ed8bf5d047
commit
6c3957f044
BIN
bin/DMGTRIS.GBC
BIN
bin/DMGTRIS.GBC
Binary file not shown.
2627
bin/DMGTRIS.map
2627
bin/DMGTRIS.map
File diff suppressed because it is too large
Load Diff
Binary file not shown.
2426
bin/DMGTRIS.sym
2426
bin/DMGTRIS.sym
File diff suppressed because it is too large
Load Diff
|
@ -184,6 +184,8 @@ DEF CLEVEL_BASE_Y EQU 133
|
||||||
DEF NLEVEL_BASE_Y EQU 145
|
DEF NLEVEL_BASE_Y EQU 145
|
||||||
DEF GRADE_BASE_X EQU 145
|
DEF GRADE_BASE_X EQU 145
|
||||||
DEF GRADE_BASE_Y EQU 20
|
DEF GRADE_BASE_Y EQU 20
|
||||||
|
DEF TIME_BASE_X EQU 100
|
||||||
|
DEF TIME_BASE_Y EQU 153
|
||||||
DEF TELLS_BASE_X EQU 154
|
DEF TELLS_BASE_X EQU 154
|
||||||
DEF TELLS_BASE_Y EQU 61
|
DEF TELLS_BASE_Y EQU 61
|
||||||
DEF TELLS_Y_DIST EQU 10
|
DEF TELLS_Y_DIST EQU 10
|
||||||
|
@ -226,6 +228,7 @@ DEF TILE_CLEARING EQU 106
|
||||||
DEF TILE_GHOST EQU 107
|
DEF TILE_GHOST EQU 107
|
||||||
DEF TILE_PIECE_SMALL_0 EQU 116
|
DEF TILE_PIECE_SMALL_0 EQU 116
|
||||||
DEF TILE_PIECE_BONE EQU 104
|
DEF TILE_PIECE_BONE EQU 104
|
||||||
|
DEF TILE_SMALL_0 EQU 213
|
||||||
DEF GAME_OVER_R10 EQU 147
|
DEF GAME_OVER_R10 EQU 147
|
||||||
DEF GAME_OVER_R12 EQU 167
|
DEF GAME_OVER_R12 EQU 167
|
||||||
DEF GAME_OVER_R14 EQU 187
|
DEF GAME_OVER_R14 EQU 187
|
||||||
|
|
|
@ -322,7 +322,7 @@ sBigGameplayTileMap::
|
||||||
DB $01,$01,$01,$01,$01,$01,$01,$6F,$00,$00
|
DB $01,$01,$01,$01,$01,$01,$01,$6F,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
|
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
|
||||||
DB $6D,$01,$01,$01,$01,$01,$01,$01,$01,$6F
|
DB $6D,$01,$01,$D4,$01,$01,$DF,$01,$01,$6F
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00
|
DB $00,$00
|
||||||
sBigGameplayTileMapEnd::
|
sBigGameplayTileMapEnd::
|
||||||
|
|
|
@ -334,7 +334,7 @@ sGameplayTileMap::
|
||||||
DB $01,$01,$01,$01,$01,$01,$01,$6F,$00,$00
|
DB $01,$01,$01,$01,$01,$01,$01,$6F,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
|
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
|
||||||
DB $6D,$01,$01,$01,$01,$01,$01,$01,$01,$6F
|
DB $6D,$01,$01,$D4,$01,$01,$DF,$01,$01,$6F
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00
|
DB $00,$00
|
||||||
sGameplayTileMapEnd::
|
sGameplayTileMapEnd::
|
||||||
|
|
|
@ -1472,8 +1472,8 @@ sGameplayTilesM::
|
||||||
DB $42,$42,$42,$42,$EC,$EC,$00,$00
|
DB $42,$42,$42,$42,$EC,$EC,$00,$00
|
||||||
DB $FE,$FE,$DB,$DB,$DB,$DB,$DB,$DB
|
DB $FE,$FE,$DB,$DB,$DB,$DB,$DB,$DB
|
||||||
DB $DB,$DB,$DB,$DB,$DB,$DB,$00,$00
|
DB $DB,$DB,$DB,$DB,$DB,$DB,$00,$00
|
||||||
DB $00,$00,$18,$18,$18,$18,$00,$00
|
DB $00,$00,$06,$06,$06,$06,$00,$00
|
||||||
DB $00,$00,$18,$18,$18,$18,$00,$00
|
DB $00,$00,$06,$06,$06,$06,$00,$00
|
||||||
DB $00,$00,$3C,$3C,$66,$66,$6E,$6E
|
DB $00,$00,$3C,$3C,$66,$66,$6E,$6E
|
||||||
DB $76,$76,$66,$66,$3C,$3C,$00,$00
|
DB $76,$76,$66,$66,$3C,$3C,$00,$00
|
||||||
DB $00,$00,$0C,$0C,$1C,$1C,$0C,$0C
|
DB $00,$00,$0C,$0C,$1C,$1C,$0C,$0C
|
||||||
|
@ -1494,8 +1494,8 @@ sGameplayTilesM::
|
||||||
DB $66,$66,$66,$66,$3C,$3C,$00,$00
|
DB $66,$66,$66,$66,$3C,$3C,$00,$00
|
||||||
DB $00,$00,$1C,$1C,$36,$36,$36,$36
|
DB $00,$00,$1C,$1C,$36,$36,$36,$36
|
||||||
DB $1E,$1E,$06,$06,$1C,$1C,$00,$00
|
DB $1E,$1E,$06,$06,$1C,$1C,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$60,$60,$60,$60,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$60,$60,$60,$60,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
@ -1891,8 +1891,8 @@ sGameplayTilesC::
|
||||||
DB $42,$42,$42,$42,$EC,$EC,$00,$00
|
DB $42,$42,$42,$42,$EC,$EC,$00,$00
|
||||||
DB $FE,$FE,$DB,$DB,$DB,$DB,$DB,$DB
|
DB $FE,$FE,$DB,$DB,$DB,$DB,$DB,$DB
|
||||||
DB $DB,$DB,$DB,$DB,$DB,$DB,$00,$00
|
DB $DB,$DB,$DB,$DB,$DB,$DB,$00,$00
|
||||||
DB $00,$00,$18,$18,$18,$18,$00,$00
|
DB $00,$00,$06,$06,$06,$06,$00,$00
|
||||||
DB $00,$00,$18,$18,$18,$18,$00,$00
|
DB $00,$00,$06,$06,$06,$06,$00,$00
|
||||||
DB $00,$00,$3C,$3C,$66,$66,$6E,$6E
|
DB $00,$00,$3C,$3C,$66,$66,$6E,$6E
|
||||||
DB $76,$76,$66,$66,$3C,$3C,$00,$00
|
DB $76,$76,$66,$66,$3C,$3C,$00,$00
|
||||||
DB $00,$00,$0C,$0C,$1C,$1C,$0C,$0C
|
DB $00,$00,$0C,$0C,$1C,$1C,$0C,$0C
|
||||||
|
@ -1913,8 +1913,8 @@ sGameplayTilesC::
|
||||||
DB $66,$66,$66,$66,$3C,$3C,$00,$00
|
DB $66,$66,$66,$66,$3C,$3C,$00,$00
|
||||||
DB $00,$00,$1C,$1C,$36,$36,$36,$36
|
DB $00,$00,$1C,$1C,$36,$36,$36,$36
|
||||||
DB $1E,$1E,$06,$06,$1C,$1C,$00,$00
|
DB $1E,$1E,$06,$06,$1C,$1C,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$60,$60,$60,$60,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$60,$60,$60,$60,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
DB $00,$00,$00,$00,$00,$00,$00,$00
|
DB $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
155
src/sprites.asm
155
src/sprites.asm
|
@ -60,13 +60,14 @@ wSPRModeDrop:: ds 4
|
||||||
wSPRModeHiG:: ds 4
|
wSPRModeHiG:: ds 4
|
||||||
wSPRGrade1:: ds 4
|
wSPRGrade1:: ds 4
|
||||||
wSPRGrade2:: ds 4
|
wSPRGrade2:: ds 4
|
||||||
wUnused0:: ds 4
|
wSPRTimeM1:: ds 4
|
||||||
wUnused1:: ds 4
|
wSPRTimeM2:: ds 4
|
||||||
wUnused2:: ds 4
|
wSPRTimeS1:: ds 4
|
||||||
wUnused3:: ds 4
|
wSPRTimeS2:: ds 4
|
||||||
wUnused4:: ds 4
|
wSPRTimeCS1:: ds 4
|
||||||
wUnused5:: ds 4
|
wSPRTimeCS2:: ds 4
|
||||||
ENDU
|
ENDU
|
||||||
|
wScratch: ds 2
|
||||||
|
|
||||||
|
|
||||||
SECTION "OAM DMA Code", ROM0
|
SECTION "OAM DMA Code", ROM0
|
||||||
|
@ -381,6 +382,146 @@ ApplyHold::
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
; Draw the time.
|
||||||
|
ApplyTime::
|
||||||
|
; Set the Y position of the time objects.
|
||||||
|
ld a, TIME_BASE_Y
|
||||||
|
ld [wSPRTimeM1], a
|
||||||
|
ld [wSPRTimeM2], a
|
||||||
|
ld [wSPRTimeS1], a
|
||||||
|
ld [wSPRTimeS2], a
|
||||||
|
ld [wSPRTimeCS1], a
|
||||||
|
ld [wSPRTimeCS2], a
|
||||||
|
|
||||||
|
; Set the X position of the time objects.
|
||||||
|
ldh a, [rSCX]
|
||||||
|
ld b, a
|
||||||
|
ld a, TIME_BASE_X
|
||||||
|
sub a, b
|
||||||
|
ld [wSPRTimeM1+1], a
|
||||||
|
add a, 8
|
||||||
|
ld [wSPRTimeM2+1], a
|
||||||
|
add a, 12
|
||||||
|
ld [wSPRTimeS1+1], a
|
||||||
|
add a, 8
|
||||||
|
ld [wSPRTimeS2+1], a
|
||||||
|
add a, 12
|
||||||
|
ld [wSPRTimeCS1+1], a
|
||||||
|
add a, 8
|
||||||
|
ld [wSPRTimeCS2+1], a
|
||||||
|
|
||||||
|
; Set the palette of the time objects.
|
||||||
|
ld a, OAMF_PAL0 | $07
|
||||||
|
ld [wSPRTimeM1+3], a
|
||||||
|
ld [wSPRTimeM2+3], a
|
||||||
|
ld [wSPRTimeS1+3], a
|
||||||
|
ld [wSPRTimeS2+3], a
|
||||||
|
ld [wSPRTimeCS1+3], a
|
||||||
|
ld [wSPRTimeCS2+3], a
|
||||||
|
|
||||||
|
; Minutes. Hex to BCD.
|
||||||
|
ld a, [wMinutes]
|
||||||
|
ld c, a
|
||||||
|
ld b, 8
|
||||||
|
xor a, a
|
||||||
|
.loop0
|
||||||
|
sla c
|
||||||
|
adc a, a
|
||||||
|
daa
|
||||||
|
dec b
|
||||||
|
jr nz, .loop0
|
||||||
|
|
||||||
|
; Save to scratch.
|
||||||
|
ld b, a
|
||||||
|
and a, $0F
|
||||||
|
ld [wScratch+1], a
|
||||||
|
ld a, b
|
||||||
|
and a, $F0
|
||||||
|
swap a
|
||||||
|
ld [wScratch], a
|
||||||
|
|
||||||
|
; Apply to sprites.
|
||||||
|
ld de, wScratch
|
||||||
|
ld hl, wSPRTimeM1+2
|
||||||
|
ld bc, 4
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
add hl, bc
|
||||||
|
inc de
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; Seconds. Hex to BCD.
|
||||||
|
ld a, [wSeconds]
|
||||||
|
ld c, a
|
||||||
|
ld b, 8
|
||||||
|
xor a, a
|
||||||
|
.loop1
|
||||||
|
sla c
|
||||||
|
adc a, a
|
||||||
|
daa
|
||||||
|
dec b
|
||||||
|
jr nz, .loop1
|
||||||
|
|
||||||
|
; Save to scratch.
|
||||||
|
ld b, a
|
||||||
|
and a, $0F
|
||||||
|
ld [wScratch+1], a
|
||||||
|
ld a, b
|
||||||
|
and a, $F0
|
||||||
|
swap a
|
||||||
|
ld [wScratch], a
|
||||||
|
|
||||||
|
; Apply to sprites.
|
||||||
|
ld de, wScratch
|
||||||
|
ld hl, wSPRTimeS1+2
|
||||||
|
ld bc, 4
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
add hl, bc
|
||||||
|
inc de
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; Centiseconds. Frames using LUT.
|
||||||
|
ld a, [wFrames]
|
||||||
|
ld c, a
|
||||||
|
ld b, 0
|
||||||
|
ld hl, sFramesToCS
|
||||||
|
add hl, bc
|
||||||
|
ld a, [hl]
|
||||||
|
|
||||||
|
; Save to scratch.
|
||||||
|
ld b, a
|
||||||
|
and a, $0F
|
||||||
|
ld [wScratch+1], a
|
||||||
|
ld a, b
|
||||||
|
and a, $F0
|
||||||
|
swap a
|
||||||
|
ld [wScratch], a
|
||||||
|
|
||||||
|
; Apply to sprites.
|
||||||
|
ld de, wScratch
|
||||||
|
ld hl, wSPRTimeCS1+2
|
||||||
|
ld bc, 4
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
add hl, bc
|
||||||
|
inc de
|
||||||
|
ld a, [de]
|
||||||
|
add a, TILE_SMALL_0
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
; Generic function to draw a BCD number (8 digits) as 8 sprites.
|
; Generic function to draw a BCD number (8 digits) as 8 sprites.
|
||||||
|
@ -482,6 +623,7 @@ ApplyNumbers6::
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
; Generic function to draw a BCD number (4 digits) as 4 sprites.
|
; Generic function to draw a BCD number (4 digits) as 4 sprites.
|
||||||
; Address of first sprite in hl.
|
; Address of first sprite in hl.
|
||||||
; Address of first digit in de.
|
; Address of first digit in de.
|
||||||
|
@ -712,6 +854,7 @@ SetNumberSpritePositions::
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
GradeRendering::
|
GradeRendering::
|
||||||
; Set the Y position of the grade objects.
|
; Set the Y position of the grade objects.
|
||||||
ld a, GRADE_BASE_Y
|
ld a, GRADE_BASE_Y
|
||||||
|
|
|
@ -172,6 +172,7 @@ GamePlayEventLoopHandlerB::
|
||||||
|
|
||||||
; Draw "READY" and wait a bit.
|
; Draw "READY" and wait a bit.
|
||||||
.leadyMode
|
.leadyMode
|
||||||
|
call ResetGameTime
|
||||||
ldh a, [hModeCounter]
|
ldh a, [hModeCounter]
|
||||||
cp a, LEADY_TIME
|
cp a, LEADY_TIME
|
||||||
jr nz, .firstleadyiterskip
|
jr nz, .firstleadyiterskip
|
||||||
|
@ -196,6 +197,7 @@ GamePlayEventLoopHandlerB::
|
||||||
|
|
||||||
; Draw "GO" and wait a bit.
|
; Draw "GO" and wait a bit.
|
||||||
.goMode
|
.goMode
|
||||||
|
call ResetGameTime
|
||||||
ldh a, [hModeCounter]
|
ldh a, [hModeCounter]
|
||||||
dec a
|
dec a
|
||||||
jr nz, .notdonego
|
jr nz, .notdonego
|
||||||
|
@ -626,6 +628,7 @@ GamePlayEventLoopHandlerB::
|
||||||
|
|
||||||
call SetNumberSpritePositions
|
call SetNumberSpritePositions
|
||||||
call ApplyTells
|
call ApplyTells
|
||||||
|
call ApplyTime
|
||||||
|
|
||||||
jp GBCGameplayProcess
|
jp GBCGameplayProcess
|
||||||
|
|
||||||
|
@ -806,6 +809,7 @@ GamePlayBigEventLoopHandlerB:
|
||||||
|
|
||||||
; Draw "READY" and wait a bit.
|
; Draw "READY" and wait a bit.
|
||||||
.leadyMode
|
.leadyMode
|
||||||
|
call ResetGameTime
|
||||||
ldh a, [hModeCounter]
|
ldh a, [hModeCounter]
|
||||||
cp a, LEADY_TIME
|
cp a, LEADY_TIME
|
||||||
jr nz, .firstleadyiterskip
|
jr nz, .firstleadyiterskip
|
||||||
|
@ -830,6 +834,7 @@ GamePlayBigEventLoopHandlerB:
|
||||||
|
|
||||||
; Draw "GO" and wait a bit.
|
; Draw "GO" and wait a bit.
|
||||||
.goMode
|
.goMode
|
||||||
|
call ResetGameTime
|
||||||
ldh a, [hModeCounter]
|
ldh a, [hModeCounter]
|
||||||
dec a
|
dec a
|
||||||
jr nz, .notdonego
|
jr nz, .notdonego
|
||||||
|
@ -1255,6 +1260,7 @@ GamePlayBigEventLoopHandlerB:
|
||||||
|
|
||||||
call SetNumberSpritePositions
|
call SetNumberSpritePositions
|
||||||
call ApplyTells
|
call ApplyTells
|
||||||
|
call ApplyTime
|
||||||
|
|
||||||
jp GBCBigGameplayProcess
|
jp GBCBigGameplayProcess
|
||||||
|
|
||||||
|
|
25
src/time.asm
25
src/time.asm
|
@ -33,6 +33,20 @@ wSeconds:: ds 1
|
||||||
wFrames:: ds 1
|
wFrames:: ds 1
|
||||||
|
|
||||||
|
|
||||||
|
SECTION "Time Data", ROM0
|
||||||
|
sFramesToCS::
|
||||||
|
db $00, $02, $03, $05, $07, $10
|
||||||
|
db $12, $13, $15, $17, $18, $20
|
||||||
|
db $22, $23, $25, $27, $28, $30
|
||||||
|
db $32, $33, $35, $37, $38, $40
|
||||||
|
db $42, $43, $45, $47, $48, $50
|
||||||
|
db $52, $53, $55, $57, $58, $60
|
||||||
|
db $62, $63, $65, $67, $68, $70
|
||||||
|
db $72, $73, $75, $77, $78, $80
|
||||||
|
db $82, $83, $85, $87, $88, $90
|
||||||
|
db $92, $93, $95, $97, $98, $00
|
||||||
|
|
||||||
|
|
||||||
SECTION "Time Functions", ROM0
|
SECTION "Time Functions", ROM0
|
||||||
; Zeroes all timers and gets the free-running timer ticking.
|
; Zeroes all timers and gets the free-running timer ticking.
|
||||||
TimeInit::
|
TimeInit::
|
||||||
|
@ -106,6 +120,17 @@ HandleTimers::
|
||||||
cp a, MODE_PRE_GAME_OVER
|
cp a, MODE_PRE_GAME_OVER
|
||||||
ret z
|
ret z
|
||||||
|
|
||||||
|
ld a, [wMinutes]
|
||||||
|
cp a, 99
|
||||||
|
jr nz, .go
|
||||||
|
ld a, [wSeconds]
|
||||||
|
cp a, 59
|
||||||
|
jr nz, .go
|
||||||
|
ld a, [wFrames]
|
||||||
|
cp a, 59
|
||||||
|
ret z
|
||||||
|
|
||||||
|
.go
|
||||||
ld a, [wFrames]
|
ld a, [wFrames]
|
||||||
inc a
|
inc a
|
||||||
ld [wFrames], a
|
ld [wFrames], a
|
||||||
|
|
Loading…
Reference in New Issue