2018-06-24 07:09:41 -07:00
|
|
|
_ResetClock:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BlankScreen
|
2016-06-06 15:23:00 -07:00
|
|
|
ld b, SCGB_DIPLOMA
|
2016-05-04 08:46:23 -07:00
|
|
|
call GetSGBLayout
|
|
|
|
call LoadStandardFont
|
|
|
|
call LoadFontsExtra
|
|
|
|
ld de, MUSIC_MAIN_MENU
|
|
|
|
call PlayMusic
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .PasswordAskResetClockText
|
2016-05-04 08:46:23 -07:00
|
|
|
call PrintText
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, .NoYes_MenuHeader
|
|
|
|
call CopyMenuHeader
|
2016-05-04 08:46:23 -07:00
|
|
|
call VerticalMenu
|
|
|
|
ret c
|
|
|
|
ld a, [wMenuCursorY]
|
|
|
|
cp $1
|
|
|
|
ret z
|
|
|
|
call ClockResetPassword
|
|
|
|
jr c, .wrongpassword
|
|
|
|
ld a, BANK(sRTCStatusFlags)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, $80
|
|
|
|
ld [sRTCStatusFlags], a
|
|
|
|
call CloseSRAM
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .PasswordAskResetText
|
2016-05-04 08:46:23 -07:00
|
|
|
call PrintText
|
|
|
|
ret
|
|
|
|
|
|
|
|
.wrongpassword
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .PasswordWrongText
|
2016-05-04 08:46:23 -07:00
|
|
|
call PrintText
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.PasswordAskResetText:
|
|
|
|
text_far _PasswordAskResetText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2016-05-04 08:46:23 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.PasswordWrongText:
|
|
|
|
text_far _PasswordWrongText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2016-05-04 08:46:23 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.PasswordAskResetClockText:
|
|
|
|
text_far _PasswordAskResetClockText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2016-05-04 08:46:23 -07:00
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.NoYes_MenuHeader:
|
2018-01-14 02:59:56 -08:00
|
|
|
db 0 ; flags
|
2018-01-13 13:38:14 -08:00
|
|
|
menu_coords 14, 7, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
|
2018-01-23 13:08:43 -08:00
|
|
|
dw .NoYes_MenuData
|
2016-05-04 08:46:23 -07:00
|
|
|
db 1 ; default option
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
.NoYes_MenuData:
|
2018-01-14 02:59:56 -08:00
|
|
|
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
|
2016-05-04 08:46:23 -07:00
|
|
|
db 2 ; items
|
|
|
|
db "NO@"
|
|
|
|
db "YES@"
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClockResetPassword:
|
2016-05-04 08:46:23 -07:00
|
|
|
call .CalculatePassword
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer2
|
2016-05-04 08:46:23 -07:00
|
|
|
ld bc, 5
|
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ld a, $4
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 5], a
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, .PasswordAskEnterText
|
2016-05-04 08:46:23 -07:00
|
|
|
call PrintText
|
|
|
|
.loop
|
|
|
|
call .updateIDdisplay
|
|
|
|
.loop2
|
|
|
|
call JoyTextDelay
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyLast]
|
2016-05-04 08:46:23 -07:00
|
|
|
ld b, a
|
|
|
|
and A_BUTTON
|
|
|
|
jr nz, .confirm
|
|
|
|
ld a, b
|
|
|
|
and D_PAD
|
|
|
|
jr z, .loop2
|
|
|
|
call .dpadinput
|
|
|
|
ld c, 3
|
|
|
|
call DelayFrames
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.confirm
|
|
|
|
call .ConvertDecIDToBytes
|
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
cp l
|
|
|
|
jr nz, .nope
|
|
|
|
ld a, d
|
|
|
|
cp h
|
|
|
|
jr nz, .nope
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nope
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
.PasswordAskEnterText:
|
|
|
|
text_far _PasswordAskEnterText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2016-05-04 08:46:23 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.updateIDdisplay
|
2016-05-04 08:46:23 -07:00
|
|
|
hlcoord 14, 15
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer2
|
2016-05-04 08:46:23 -07:00
|
|
|
ld c, 5
|
|
|
|
.loop3
|
|
|
|
ld a, [de]
|
|
|
|
add "0"
|
|
|
|
ld [hli], a
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop3
|
|
|
|
hlcoord 14, 16
|
|
|
|
ld bc, 5
|
|
|
|
ld a, " "
|
|
|
|
call ByteFill
|
|
|
|
hlcoord 14, 16
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wStringBuffer2 + 5]
|
2016-05-04 08:46:23 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
|
|
|
add hl, de
|
2017-12-11 10:47:58 -08:00
|
|
|
ld [hl], "▲"
|
2016-05-04 08:46:23 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.dpadinput
|
2016-05-04 08:46:23 -07:00
|
|
|
ld a, b
|
|
|
|
and D_LEFT
|
|
|
|
jr nz, .left
|
|
|
|
ld a, b
|
|
|
|
and D_RIGHT
|
|
|
|
jr nz, .right
|
|
|
|
ld a, b
|
|
|
|
and D_UP
|
|
|
|
jr nz, .up
|
|
|
|
ld a, b
|
|
|
|
and D_DOWN
|
|
|
|
jr nz, .down
|
|
|
|
ret
|
|
|
|
|
|
|
|
.left
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wStringBuffer2 + 5]
|
2016-05-04 08:46:23 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 5], a
|
2016-05-04 08:46:23 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.right
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wStringBuffer2 + 5]
|
2016-05-04 08:46:23 -07:00
|
|
|
cp $4
|
|
|
|
ret z
|
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wStringBuffer2 + 5], a
|
2016-05-04 08:46:23 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.up
|
|
|
|
call .getcurrentdigit
|
|
|
|
ld a, [hl]
|
|
|
|
cp 9
|
|
|
|
jr z, .wraparound_up
|
|
|
|
inc a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.wraparound_up
|
|
|
|
ld [hl], $0
|
|
|
|
ret
|
|
|
|
|
|
|
|
.down
|
|
|
|
call .getcurrentdigit
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .wraparound_down
|
|
|
|
dec a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.wraparound_down
|
|
|
|
ld [hl], 9
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.getcurrentdigit
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wStringBuffer2 + 5]
|
2016-05-04 08:46:23 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer2
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.ConvertDecIDToBytes:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld hl, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer2 + 4
|
2016-05-04 08:46:23 -07:00
|
|
|
ld bc, 1
|
|
|
|
call .ConvertToBytes
|
|
|
|
ld bc, 10
|
|
|
|
call .ConvertToBytes
|
|
|
|
ld bc, 100
|
|
|
|
call .ConvertToBytes
|
|
|
|
ld bc, 1000
|
|
|
|
call .ConvertToBytes
|
|
|
|
ld bc, 10000
|
2018-06-24 07:09:41 -07:00
|
|
|
.ConvertToBytes:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
push hl
|
|
|
|
ld hl, 0
|
|
|
|
call AddNTimes
|
|
|
|
ld c, l
|
|
|
|
ld b, h
|
|
|
|
pop hl
|
|
|
|
add hl, bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CalculatePassword:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld a, BANK(sPlayerData)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld de, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + (wPlayerID - wPlayerData)
|
2016-05-04 08:46:23 -07:00
|
|
|
ld c, $2
|
|
|
|
call .ComponentFromNumber
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + (wPlayerName - wPlayerData)
|
2017-12-11 10:47:58 -08:00
|
|
|
ld c, NAME_LENGTH_JAPANESE - 1
|
2016-05-04 08:46:23 -07:00
|
|
|
call .ComponentFromString
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + (wMoney - wPlayerData)
|
2016-05-04 08:46:23 -07:00
|
|
|
ld c, $3
|
|
|
|
call .ComponentFromNumber
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.ComponentFromNumber:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld a, [hli]
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
ld a, $0
|
|
|
|
adc d
|
|
|
|
ld d, a
|
|
|
|
dec c
|
|
|
|
jr nz, .ComponentFromNumber
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.ComponentFromString:
|
2016-05-04 08:46:23 -07:00
|
|
|
ld a, [hli]
|
|
|
|
cp "@"
|
|
|
|
ret z
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
ld a, $0
|
|
|
|
adc d
|
|
|
|
ld d, a
|
|
|
|
dec c
|
|
|
|
jr nz, .ComponentFromString
|
|
|
|
ret
|