Redo high score sorting.
This commit is contained in:
parent
8b1e0c2995
commit
1695175cb1
BIN
bin/DMGTRIS.GBC
BIN
bin/DMGTRIS.GBC
Binary file not shown.
1403
bin/DMGTRIS.map
1403
bin/DMGTRIS.map
File diff suppressed because it is too large
Load Diff
Binary file not shown.
1131
bin/DMGTRIS.sym
1131
bin/DMGTRIS.sym
File diff suppressed because it is too large
Load Diff
124
src/hiscore.asm
124
src/hiscore.asm
|
@ -25,25 +25,25 @@ INCLUDE "globals.asm"
|
|||
SECTION "Hi Score Data", ROM0
|
||||
sHiscoreDefaultData::
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "DMG", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "TRI", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "SDM", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "GTR", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "ISD", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "MGT", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "RIS", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "DMG", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "TRI", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, "SDM", GRADE_NONE, RNG_MODE_TGM3, ROT_MODE_ARSTI, DROP_MODE_FIRM, HIG_MODE_OFF
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
db 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
|
||||
|
||||
SECTION "Hi Score Variables", WRAM0
|
||||
|
@ -68,6 +68,86 @@ CheckAndAddHiscore::
|
|||
; Load the score at position a.
|
||||
call GetHiScoreEntry
|
||||
|
||||
; Backup HL to DE for later.
|
||||
ld d, h
|
||||
ld e, l
|
||||
|
||||
|
||||
; Compare grades, HL needs to forwarded 11 bytes.
|
||||
.checkgrade
|
||||
ld bc, 11
|
||||
add hl, bc
|
||||
|
||||
; HL is now pointing to the grade in this high score.
|
||||
; The handling depends on whether or not the old score had a grade.
|
||||
ld a, [hl]
|
||||
cp a, GRADE_NONE
|
||||
jr z, .oldungraded
|
||||
|
||||
; The old score had a grade, so compare ours to theirs.
|
||||
.oldgraded
|
||||
ld b, a
|
||||
ld a, [wDisplayedGrade]
|
||||
cp a, b
|
||||
jr c, .notbetter ; If we're less, we're not better.
|
||||
jr nz, .better ; If we're higher, we're better.
|
||||
jr .checklevel ; Equal, so check level.
|
||||
|
||||
; The old score did NOT have a grade. So check if we do.
|
||||
.oldungraded
|
||||
ld a, [wDisplayedGrade]
|
||||
cp a, GRADE_NONE
|
||||
jr nz, .better ; We do have a grade, so we win.
|
||||
; We don't have a grade either, so continue as equals.
|
||||
|
||||
|
||||
; Our grade is equal.
|
||||
; Compare levels. HL needs to be forwarded 5 bytes.
|
||||
.checklevel
|
||||
ld bc, 5
|
||||
add hl, bc
|
||||
|
||||
; HL is now pointing to the level in this high score.
|
||||
; Make BC point to our level.
|
||||
ld bc, hCLevel
|
||||
|
||||
; And compare the first digit...
|
||||
ld a, [bc]
|
||||
cp a, [hl]
|
||||
jr c, .notbetter ; Lower? Not better.
|
||||
jr nz, .better ; Higher? Better.
|
||||
inc bc ; Equal? Keep checking...
|
||||
inc hl
|
||||
|
||||
; Second...
|
||||
ld a, [bc]
|
||||
cp a, [hl]
|
||||
jr c, .notbetter
|
||||
jr nz, .better
|
||||
inc bc
|
||||
inc hl
|
||||
|
||||
; Third...
|
||||
ld a, [bc]
|
||||
cp a, [hl]
|
||||
jr c, .notbetter
|
||||
jr nz, .better
|
||||
inc bc
|
||||
inc hl
|
||||
|
||||
; Fourth...
|
||||
ld a, [bc]
|
||||
cp a, [hl]
|
||||
jr c, .notbetter
|
||||
jr nz, .better
|
||||
|
||||
|
||||
; Our level is equal.
|
||||
; So now also check the score. Restore the DE from earlier.
|
||||
.checkscore
|
||||
ld h, d
|
||||
ld l, e
|
||||
|
||||
; HL is pointing to that score, make BC point to our current score.
|
||||
ld bc, hScore
|
||||
|
||||
|
@ -133,6 +213,8 @@ CheckAndAddHiscore::
|
|||
jr c, .notbetter
|
||||
jr nz, .better
|
||||
|
||||
|
||||
; If we fell through all the way to here, we are completely equal. Oldest score has priority.
|
||||
; Loop or return if we didn't make the scores.
|
||||
.notbetter
|
||||
ld a, [wInsertTarget]
|
||||
|
@ -140,7 +222,7 @@ CheckAndAddHiscore::
|
|||
ld [wInsertTarget], a
|
||||
cp a, 10
|
||||
ret z
|
||||
jr .checkloop
|
||||
jp .checkloop
|
||||
|
||||
.better
|
||||
jr InsertHiScore
|
||||
|
@ -223,10 +305,26 @@ InsertHiScore::
|
|||
ld [hl+], a
|
||||
ld a, [wAlways20GState]
|
||||
ld [hl+], a
|
||||
ldh a, [hCLevel+0]
|
||||
ld [hl+], a
|
||||
ldh a, [hCLevel+1]
|
||||
ld [hl+], a
|
||||
ldh a, [hCLevel+2]
|
||||
ld [hl+], a
|
||||
ldh a, [hCLevel+3]
|
||||
ld [hl+], a
|
||||
ldh a, [hNLevel+0]
|
||||
ld [hl+], a
|
||||
ldh a, [hNLevel+1]
|
||||
ld [hl+], a
|
||||
ldh a, [hNLevel+2]
|
||||
ld [hl+], a
|
||||
ldh a, [hNLevel+3]
|
||||
ld [hl+], a
|
||||
|
||||
; 16 filler bytes.
|
||||
; 8 filler bytes.
|
||||
xor a, a
|
||||
REPT 16
|
||||
REPT 8
|
||||
ld [hl+], a
|
||||
ENDR
|
||||
|
||||
|
|
|
@ -1338,8 +1338,8 @@ sTitleTiles::
|
|||
DB $50,$50,$20,$20,$24,$24,$00,$00
|
||||
DB $40,$40,$C0,$C0,$40,$40,$40,$40
|
||||
DB $40,$40,$40,$40,$E4,$E4,$00,$00
|
||||
DB $44,$44,$AC,$AC,$A4,$A4,$A4,$A4
|
||||
DB $A4,$A4,$A4,$A4,$4E,$4E,$00,$00
|
||||
DB $4C,$4C,$A2,$A2,$A2,$A2,$A4,$A4
|
||||
DB $A8,$A8,$A8,$A8,$4E,$4E,$00,$00
|
||||
sTitleTilesEnd::
|
||||
|
||||
sGameplayTilesM::
|
||||
|
|
Binary file not shown.
25
src/sram.asm
25
src/sram.asm
|
@ -98,7 +98,7 @@ RestoreSRAM::
|
|||
cp a, 0
|
||||
jp nz, InitializeSRAM
|
||||
ld a, [rCheck+5]
|
||||
cp a, 3
|
||||
cp a, 4
|
||||
jp nz, InitializeSRAM
|
||||
|
||||
; SRAM is initialized and for this build, so we can load the data.
|
||||
|
@ -228,7 +228,7 @@ InitializeSRAM:
|
|||
ld [rCheck+3], a
|
||||
ld a, 0
|
||||
ld [rCheck+4], a
|
||||
ld a, 3
|
||||
ld a, 4
|
||||
ld [rCheck+5], a
|
||||
|
||||
xor a, a
|
||||
|
@ -340,6 +340,27 @@ InitializeSRAM:
|
|||
ld a, "9"
|
||||
ld [rProfileName9+2], a
|
||||
|
||||
ld a, 6
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
ld a, 5
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
ld a, 4
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
ld a, 3
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
ld a, 2
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
ld a, 1
|
||||
ld [wSelected], a
|
||||
call ResetScores
|
||||
xor a, a
|
||||
ld [wSelected], a
|
||||
|
||||
; Set the default scores.
|
||||
ResetScores::
|
||||
ld a, [wSelected]
|
||||
|
|
|
@ -27,6 +27,8 @@ SECTION "Title Variables", WRAM0
|
|||
wSelected:: ds 1
|
||||
wTitleMode:: ds 1
|
||||
wProfileName:: ds 3
|
||||
wDisplayingScoreMode:: ds 1
|
||||
wScoreFlipTimer:: ds 1
|
||||
|
||||
|
||||
SECTION "Title Function Trampolines", ROM0
|
||||
|
@ -351,6 +353,8 @@ SwitchTitleMode:
|
|||
call GBCTitleInit
|
||||
xor a, a
|
||||
ldh [hSelectState], a
|
||||
ld [wDisplayingScoreMode], a
|
||||
ld [wScoreFlipTimer], a
|
||||
jp RenderScores
|
||||
|
||||
.switchCredits
|
||||
|
@ -556,8 +560,19 @@ TitleEventLoopHandlerB:
|
|||
; Select
|
||||
ldh a, [hSelectState]
|
||||
cp a, 255 ; Max hold duraction
|
||||
jp z, RecordsHandleSelect
|
||||
|
||||
ld a, [wScoreFlipTimer]
|
||||
inc a
|
||||
ld [wScoreFlipTimer], a
|
||||
cp a, 180
|
||||
ret nz
|
||||
jp RecordsHandleSelect
|
||||
xor a, a
|
||||
ld [wScoreFlipTimer], a
|
||||
ld a, [wDisplayingScoreMode]
|
||||
cpl
|
||||
ld [wDisplayingScoreMode], a
|
||||
jp RenderScores
|
||||
|
||||
.eventLoopCredits
|
||||
ldh a, [hAState]
|
||||
|
@ -1522,6 +1537,8 @@ CheckLevelRange:
|
|||
RecordsHandleLeft:
|
||||
xor a, a
|
||||
ldh [hSelectState], a
|
||||
ld [wDisplayingScoreMode], a
|
||||
ld [wScoreFlipTimer], a
|
||||
ld a, [wSelected]
|
||||
cp a, 0
|
||||
jr z, :+
|
||||
|
@ -1535,6 +1552,8 @@ RecordsHandleLeft:
|
|||
RecordsHandleRight:
|
||||
xor a, a
|
||||
ldh [hSelectState], a
|
||||
ld [wDisplayingScoreMode], a
|
||||
ld [wScoreFlipTimer], a
|
||||
ld a, [wSelected]
|
||||
cp a, SCURVE_COUNT-1
|
||||
jr z, :+
|
||||
|
@ -1585,7 +1604,12 @@ RenderScores:
|
|||
ld hl, TITLE_RECORDS_SCORE_BASE+4
|
||||
|
||||
REPT 10
|
||||
ld a, [wDisplayingScoreMode]
|
||||
cp a, $FF
|
||||
jr z, .level\@
|
||||
|
||||
; Render score.
|
||||
.score\@
|
||||
ld a, [de]
|
||||
inc de
|
||||
add a, "0"
|
||||
|
@ -1619,11 +1643,63 @@ RenderScores:
|
|||
add a, "0"
|
||||
ld [hl+], a
|
||||
|
||||
; Go render the name.
|
||||
jr .name\@
|
||||
|
||||
; Jump forward to level in the score.
|
||||
.level\@
|
||||
push hl
|
||||
ld h, d
|
||||
ld l, e
|
||||
ld bc, 16
|
||||
add hl, bc
|
||||
ld d, h
|
||||
ld e, l
|
||||
pop hl
|
||||
|
||||
; Render it.
|
||||
ld a, "L"
|
||||
ld [hl+], a
|
||||
ld a, "V"
|
||||
ld [hl+], a
|
||||
ld a, "L"
|
||||
ld [hl+], a
|
||||
ld a, 115
|
||||
ld [hl+], a
|
||||
ld a, [de]
|
||||
inc de
|
||||
add a, "0"
|
||||
ld [hl+], a
|
||||
ld a, [de]
|
||||
inc de
|
||||
add a, "0"
|
||||
ld [hl+], a
|
||||
ld a, [de]
|
||||
inc de
|
||||
add a, "0"
|
||||
ld [hl+], a
|
||||
ld a, [de]
|
||||
inc de
|
||||
add a, "0"
|
||||
ld [hl+], a
|
||||
|
||||
; And jump back to the name.
|
||||
push hl
|
||||
ld h, d
|
||||
ld l, e
|
||||
ld bc, -12
|
||||
add hl, bc
|
||||
ld d, h
|
||||
ld e, l
|
||||
pop hl
|
||||
|
||||
|
||||
.name\@
|
||||
; Jump back to Name.
|
||||
ld bc, -12
|
||||
add hl, bc
|
||||
|
||||
; Render it.
|
||||
; Render name.
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hl+], a
|
||||
|
@ -1644,7 +1720,7 @@ RenderScores:
|
|||
cp a, GRADE_NONE
|
||||
jr nz, .grade\@
|
||||
.nograde\@
|
||||
ld a, TILE_BLANK
|
||||
ld a, 197
|
||||
ld [hl+], a
|
||||
jr .postgrade\@
|
||||
.grade\@
|
||||
|
|
Loading…
Reference in New Issue