mirror of https://github.com/pret/pokecrystal.git
Bit 6 of PrintNum left-aligns numbers
This commit is contained in:
parent
0c7b309f7f
commit
4d32035d4f
|
@ -33,12 +33,12 @@ TEXTBOX_INNERY EQU TEXTBOX_Y + 2
|
||||||
; PrintNum bit flags
|
; PrintNum bit flags
|
||||||
const_def 5
|
const_def 5
|
||||||
const PRINTNUM_MONEY_F ; 5
|
const PRINTNUM_MONEY_F ; 5
|
||||||
const PRINTNUM_RIGHTALIGN_F ; 6
|
const PRINTNUM_LEFTALIGN_F ; 6
|
||||||
const PRINTNUM_LEADINGZEROS_F ; 7
|
const PRINTNUM_LEADINGZEROS_F ; 7
|
||||||
|
|
||||||
; PrintNum arguments (see engine/math/print_num.asm)
|
; PrintNum arguments (see engine/math/print_num.asm)
|
||||||
PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F
|
PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F
|
||||||
PRINTNUM_RIGHTALIGN EQU 1 << PRINTNUM_RIGHTALIGN_F
|
PRINTNUM_LEFTALIGN EQU 1 << PRINTNUM_LEFTALIGN_F
|
||||||
PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F
|
PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F
|
||||||
|
|
||||||
; character sets (see charmap.asm)
|
; character sets (see charmap.asm)
|
||||||
|
|
|
@ -89,12 +89,12 @@ PrintMagikarpLength:
|
||||||
call Magikarp_LoadFeetInchesChars
|
call Magikarp_LoadFeetInchesChars
|
||||||
ld hl, wStringBuffer1
|
ld hl, wStringBuffer1
|
||||||
ld de, wMagikarpLength
|
ld de, wMagikarpLength
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld [hl], "′"
|
ld [hl], "′"
|
||||||
inc hl
|
inc hl
|
||||||
ld de, wMagikarpLength + 1
|
ld de, wMagikarpLength + 1
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld [hl], "″"
|
ld [hl], "″"
|
||||||
inc hl
|
inc hl
|
||||||
|
|
|
@ -164,7 +164,7 @@ GetCaughtLevel:
|
||||||
ld [wSeerCaughtLevel], a
|
ld [wSeerCaughtLevel], a
|
||||||
ld hl, wSeerCaughtLevelString
|
ld hl, wSeerCaughtLevelString
|
||||||
ld de, wSeerCaughtLevel
|
ld de, wSeerCaughtLevel
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
|
lb bc, PRINTNUM_LEFTALIGN | 1, 3
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ Rate:
|
||||||
ld bc, ITEM_NAME_LENGTH
|
ld bc, ITEM_NAME_LENGTH
|
||||||
call ByteFill
|
call ByteFill
|
||||||
pop hl
|
pop hl
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
|
lb bc, PRINTNUM_LEFTALIGN | 1, 3
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ TMHM_DisplayPocketItems:
|
||||||
ld [hl], "H"
|
ld [hl], "H"
|
||||||
inc hl
|
inc hl
|
||||||
ld de, wTempTMHM
|
ld de, wTempTMHM
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
call PrintNum
|
call PrintNum
|
||||||
pop af
|
pop af
|
||||||
ld [wTempTMHM], a
|
ld [wTempTMHM], a
|
||||||
|
|
|
@ -161,7 +161,7 @@ StartMenu_PrintBugContestStatus:
|
||||||
call PlaceString
|
call PlaceString
|
||||||
hlcoord 8, 5
|
hlcoord 8, 5
|
||||||
ld de, wParkBallsRemaining
|
ld de, wParkBallsRemaining
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
call PrintNum
|
call PrintNum
|
||||||
hlcoord 1, 1
|
hlcoord 1, 1
|
||||||
ld de, .CAUGHT
|
ld de, .CAUGHT
|
||||||
|
@ -187,7 +187,7 @@ StartMenu_PrintBugContestStatus:
|
||||||
ld l, c
|
ld l, c
|
||||||
inc hl
|
inc hl
|
||||||
ld c, 3
|
ld c, 3
|
||||||
call Print8BitNumRightAlign
|
call Print8BitNumLeftAlign
|
||||||
|
|
||||||
.skip_level
|
.skip_level
|
||||||
pop af
|
pop af
|
||||||
|
|
|
@ -1952,7 +1952,7 @@ Script_getmoney:
|
||||||
call ResetStringBuffer1
|
call ResetStringBuffer1
|
||||||
call GetMoneyAccount
|
call GetMoneyAccount
|
||||||
ld hl, wStringBuffer1
|
ld hl, wStringBuffer1
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 3, 6
|
lb bc, PRINTNUM_LEFTALIGN | 3, 6
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld de, wStringBuffer1
|
ld de, wStringBuffer1
|
||||||
jp GetStringBuffer
|
jp GetStringBuffer
|
||||||
|
@ -1964,7 +1964,7 @@ Script_getcoins:
|
||||||
call ResetStringBuffer1
|
call ResetStringBuffer1
|
||||||
ld hl, wStringBuffer1
|
ld hl, wStringBuffer1
|
||||||
ld de, wCoins
|
ld de, wCoins
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 2, 6
|
lb bc, PRINTNUM_LEFTALIGN | 2, 6
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld de, wStringBuffer1
|
ld de, wStringBuffer1
|
||||||
jp GetStringBuffer
|
jp GetStringBuffer
|
||||||
|
@ -1976,7 +1976,7 @@ Script_getnum:
|
||||||
call ResetStringBuffer1
|
call ResetStringBuffer1
|
||||||
ld de, wScriptVar
|
ld de, wScriptVar
|
||||||
ld hl, wStringBuffer1
|
ld hl, wStringBuffer1
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
|
lb bc, PRINTNUM_LEFTALIGN | 1, 3
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld de, wStringBuffer1
|
ld de, wStringBuffer1
|
||||||
jp GetStringBuffer
|
jp GetStringBuffer
|
||||||
|
|
|
@ -246,10 +246,10 @@ PlacePartyMonLevel:
|
||||||
jr nc, .ThreeDigits
|
jr nc, .ThreeDigits
|
||||||
ld a, "<LV>"
|
ld a, "<LV>"
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
; jr .okay
|
; jr .okay
|
||||||
.ThreeDigits:
|
.ThreeDigits:
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
|
lb bc, PRINTNUM_LEFTALIGN | 1, 3
|
||||||
; .okay
|
; .okay
|
||||||
call PrintNum
|
call PrintNum
|
||||||
|
|
||||||
|
|
|
@ -273,19 +273,19 @@ SetMinutes:
|
||||||
|
|
||||||
DisplayMinutesWithMinString:
|
DisplayMinutesWithMinString:
|
||||||
ld de, wInitMinuteBuffer
|
ld de, wInitMinuteBuffer
|
||||||
call PrintTwoDigitNumberRightAlign
|
call PrintTwoDigitNumberLeftAlign
|
||||||
inc hl
|
inc hl
|
||||||
ld de, String_min
|
ld de, String_min
|
||||||
call PlaceString
|
call PlaceString
|
||||||
ret
|
ret
|
||||||
|
|
||||||
PrintTwoDigitNumberRightAlign:
|
PrintTwoDigitNumberLeftAlign:
|
||||||
push hl
|
push hl
|
||||||
ld a, " "
|
ld a, " "
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
pop hl
|
pop hl
|
||||||
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
|
lb bc, PRINTNUM_LEFTALIGN | 1, 2
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ PrintHour:
|
||||||
call AdjustHourForAMorPM
|
call AdjustHourForAMorPM
|
||||||
ld [wDeciramBuffer], a
|
ld [wDeciramBuffer], a
|
||||||
ld de, wDeciramBuffer
|
ld de, wDeciramBuffer
|
||||||
call PrintTwoDigitNumberRightAlign
|
call PrintTwoDigitNumberLeftAlign
|
||||||
ret
|
ret
|
||||||
|
|
||||||
GetTimeOfDayString:
|
GetTimeOfDayString:
|
||||||
|
|
|
@ -13,12 +13,12 @@ PrintBCDNumber::
|
||||||
; Note that bits 5 and 7 are modified during execution. The above reflects
|
; Note that bits 5 and 7 are modified during execution. The above reflects
|
||||||
; their meaning at the beginning of the functions's execution.
|
; their meaning at the beginning of the functions's execution.
|
||||||
ld b, c ; save flags in b
|
ld b, c ; save flags in b
|
||||||
res 7, c
|
res PRINTNUM_LEADINGZEROS_F, c
|
||||||
res 6, c
|
res PRINTNUM_LEFTALIGN_F, c
|
||||||
res 5, c ; c now holds the length
|
res PRINTNUM_MONEY_F, c ; c now holds the length
|
||||||
bit 5, b
|
bit PRINTNUM_MONEY_F, b
|
||||||
jr z, .loop
|
jr z, .loop
|
||||||
bit 7, b
|
bit PRINTNUM_LEADINGZEROS_F, b
|
||||||
jr nz, .loop ; skip currency symbol
|
jr nz, .loop ; skip currency symbol
|
||||||
ld [hl], "¥"
|
ld [hl], "¥"
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -31,14 +31,14 @@ PrintBCDNumber::
|
||||||
inc de
|
inc de
|
||||||
dec c
|
dec c
|
||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
bit 7, b ; were any non-zero digits printed?
|
bit PRINTNUM_LEADINGZEROS_F, b
|
||||||
jr z, .done ; if so, we are done
|
jr z, .done ; if so, we are done
|
||||||
.numberEqualsZero ; if every digit of the BCD number is zero
|
.numberEqualsZero ; if every digit of the BCD number is zero
|
||||||
bit 6, b ; left or right alignment?
|
bit PRINTNUM_LEFTALIGN_F, b
|
||||||
jr nz, .skipRightAlignmentAdjustment
|
jr nz, .skipLeftAlignmentAdjustment
|
||||||
dec hl ; if the string is right-aligned, it needs to be moved back one space
|
dec hl ; if the string is left-aligned, it needs to be moved back one space
|
||||||
.skipRightAlignmentAdjustment
|
.skipLeftAlignmentAdjustment
|
||||||
bit 5, b
|
bit PRINTNUM_MONEY_F, b
|
||||||
jr z, .skipCurrencySymbol
|
jr z, .skipCurrencySymbol
|
||||||
ld [hl], "¥" ; currency symbol
|
ld [hl], "¥" ; currency symbol
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -54,25 +54,25 @@ PrintBCDDigit::
|
||||||
and a
|
and a
|
||||||
jr z, .zeroDigit
|
jr z, .zeroDigit
|
||||||
.nonzeroDigit
|
.nonzeroDigit
|
||||||
bit 7, b ; have any non-space characters been printed?
|
bit PRINTNUM_LEADINGZEROS_F, b ; have any non-space characters been printed?
|
||||||
jr z, .outputDigit
|
jr z, .outputDigit
|
||||||
; if bit 7 is set, then no numbers have been printed yet
|
; if bit 7 is set, then no numbers have been printed yet
|
||||||
bit 5, b ; print the currency symbol?
|
bit PRINTNUM_MONEY_F, b
|
||||||
jr z, .skipCurrencySymbol
|
jr z, .skipCurrencySymbol
|
||||||
ld [hl], "¥"
|
ld [hl], "¥"
|
||||||
inc hl
|
inc hl
|
||||||
res 5, b
|
res PRINTNUM_MONEY_F, b
|
||||||
.skipCurrencySymbol
|
.skipCurrencySymbol
|
||||||
res 7, b ; unset 7 to indicate that a nonzero digit has been reached
|
res PRINTNUM_LEADINGZEROS_F, b ; unset 7 to indicate that a nonzero digit has been reached
|
||||||
.outputDigit
|
.outputDigit
|
||||||
add "0"
|
add "0"
|
||||||
ld [hli], a
|
ld [hli], a
|
||||||
jp PrintLetterDelay
|
jp PrintLetterDelay
|
||||||
|
|
||||||
.zeroDigit
|
.zeroDigit
|
||||||
bit 7, b ; either printing leading zeroes or already reached a nonzero digit?
|
bit PRINTNUM_LEADINGZEROS_F, b ; either printing leading zeroes or already reached a nonzero digit?
|
||||||
jr z, .outputDigit ; if so, print a zero digit
|
jr z, .outputDigit ; if so, print a zero digit
|
||||||
bit 6, b ; left or right alignment?
|
bit PRINTNUM_LEFTALIGN_F, b
|
||||||
ret nz
|
ret nz
|
||||||
ld a, " "
|
ld a, " "
|
||||||
ld [hli], a ; if right-aligned, "print" a space by advancing the pointer
|
ld [hli], a ; if right-aligned, "print" a space by advancing the pointer
|
||||||
|
|
|
@ -8,12 +8,12 @@ PrintLevel::
|
||||||
; How many digits?
|
; How many digits?
|
||||||
ld c, 2
|
ld c, 2
|
||||||
cp 100 ; This is distinct from MAX_LEVEL.
|
cp 100 ; This is distinct from MAX_LEVEL.
|
||||||
jr c, Print8BitNumRightAlign
|
jr c, Print8BitNumLeftAlign
|
||||||
|
|
||||||
; 3-digit numbers overwrite the :L.
|
; 3-digit numbers overwrite the :L.
|
||||||
dec hl
|
dec hl
|
||||||
inc c
|
inc c
|
||||||
jr Print8BitNumRightAlign
|
jr Print8BitNumLeftAlign
|
||||||
|
|
||||||
PrintLevel_Force3Digits::
|
PrintLevel_Force3Digits::
|
||||||
; Print :L and all 3 digits
|
; Print :L and all 3 digits
|
||||||
|
@ -21,8 +21,8 @@ PrintLevel_Force3Digits::
|
||||||
inc hl
|
inc hl
|
||||||
ld c, 3
|
ld c, 3
|
||||||
|
|
||||||
Print8BitNumRightAlign::
|
Print8BitNumLeftAlign::
|
||||||
ld [wDeciramBuffer], a
|
ld [wDeciramBuffer], a
|
||||||
ld de, wDeciramBuffer
|
ld de, wDeciramBuffer
|
||||||
ld b, PRINTNUM_RIGHTALIGN | 1
|
ld b, PRINTNUM_LEFTALIGN | 1
|
||||||
jp PrintNum
|
jp PrintNum
|
||||||
|
|
|
@ -896,7 +896,7 @@ TextCommand_NUM::
|
||||||
ld a, b
|
ld a, b
|
||||||
and $f0
|
and $f0
|
||||||
swap a
|
swap a
|
||||||
set PRINTNUM_RIGHTALIGN_F, a
|
set PRINTNUM_LEFTALIGN_F, a
|
||||||
ld b, a
|
ld b, a
|
||||||
call PrintNum
|
call PrintNum
|
||||||
ld b, h
|
ld b, h
|
||||||
|
|
Loading…
Reference in New Issue