mirror of
https://github.com/pret/pokeyellow.git
synced 2026-10-01 13:47:36 -05:00
DisplayTextIDInit and DrawStartMenu
Also re-add event_macros.asm
This commit is contained in:
@@ -29,4 +29,6 @@ INCLUDE "constants/music_constants.asm"
|
||||
INCLUDE "constants/tilesets.asm"
|
||||
INCLUDE "constants/starter_mons.asm"
|
||||
INCLUDE "constants/predef_constants.asm"
|
||||
INCLUDE "constants/tx_pre_constants.asm"
|
||||
INCLUDE "constants/tx_pre_constants.asm"
|
||||
INCLUDE "constants/event_constants.asm"
|
||||
INCLUDE "constants/event_macros.asm"
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
;\1 = event index
|
||||
;\2 = return result in carry instead of zero flag
|
||||
CheckEvent: MACRO
|
||||
@@ -164,14 +163,13 @@ event_byte = ((\1) / 8)
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index
|
||||
;\3 = event index (optional)
|
||||
;\3, \4, ... = additional (optional) event indices
|
||||
SetEvents: MACRO
|
||||
SetEvent \1
|
||||
rept (_NARG + -1)
|
||||
SetEventReuseHL \2
|
||||
|
||||
IF _NARG > 2
|
||||
SetEventReuseHL \3
|
||||
ENDC
|
||||
shift
|
||||
endr
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
@@ -215,11 +213,10 @@ event_byte = ((\1) / 8)
|
||||
;\3 = event index (optional)
|
||||
ResetEvents: MACRO
|
||||
ResetEvent \1
|
||||
rept (_NARG + -1)
|
||||
ResetEventReuseHL \2
|
||||
|
||||
IF _NARG > 2
|
||||
ResetEventReuseHL \3
|
||||
ENDC
|
||||
shift
|
||||
endr
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
@@ -441,449 +438,4 @@ AdjustEventBit: MACRO
|
||||
IF ((\1) % 8) != (\2)
|
||||
add ((\1) % 8) - (\2)
|
||||
ENDC
|
||||
ENDM
|
||||
=======
|
||||
;\1 = event index
|
||||
;\2 = return result in carry instead of zero flag
|
||||
CheckEvent: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld a, [wEventFlags + event_byte]
|
||||
|
||||
IF _NARG > 1
|
||||
IF ((\1) % 8) == 7
|
||||
add a
|
||||
ELSE
|
||||
REPT ((\1) % 8) + 1
|
||||
rrca
|
||||
ENDR
|
||||
ENDC
|
||||
ELSE
|
||||
bit (\1) % 8, a
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckEventReuseA: MACRO
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld a, [wEventFlags + event_byte]
|
||||
ENDC
|
||||
|
||||
bit (\1) % 8, a
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index of the last event used before the branch
|
||||
CheckEventAfterBranchReuseA: MACRO
|
||||
event_byte = ((\2) / 8)
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld a, [wEventFlags + event_byte]
|
||||
ENDC
|
||||
|
||||
bit (\1) % 8, a
|
||||
ENDM
|
||||
|
||||
;\1 = reg
|
||||
;\2 = event index
|
||||
;\3 = event index this event is relative to (optional, this is needed when there is a fixed flag address)
|
||||
EventFlagBit: MACRO
|
||||
IF _NARG > 2
|
||||
ld \1, ((\3) % 8) + ((\2) - (\3))
|
||||
ELSE
|
||||
ld \1, (\2) % 8
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = reg
|
||||
;\2 = event index
|
||||
EventFlagAddress: MACRO
|
||||
event_byte = ((\2) / 8)
|
||||
ld \1, wEventFlags + event_byte
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckEventHL: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
bit (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckEventReuseHL: MACRO
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
bit (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
; dangerous, only use when HL is guaranteed to be the desired value
|
||||
;\1 = event index
|
||||
CheckEventForceReuseHL: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
bit (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index of the last event used before the branch
|
||||
CheckEventAfterBranchReuseHL: MACRO
|
||||
event_byte = ((\2) / 8)
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
bit (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckAndSetEvent: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
bit (\1) % 8, [hl]
|
||||
set (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckAndResetEvent: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
bit (\1) % 8, [hl]
|
||||
res (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckAndSetEventA: MACRO
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
bit (\1) % 8, a
|
||||
set (\1) % 8, a
|
||||
ld [wEventFlags + ((\1) / 8)], a
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
CheckAndResetEventA: MACRO
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
bit (\1) % 8, a
|
||||
res (\1) % 8, a
|
||||
ld [wEventFlags + ((\1) / 8)], a
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
SetEvent: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
set (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
SetEventReuseHL: MACRO
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
set (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index of the last event used before the branch
|
||||
SetEventAfterBranchReuseHL: MACRO
|
||||
event_byte = ((\2) / 8)
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
set (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
; dangerous, only use when HL is guaranteed to be the desired value
|
||||
;\1 = event index
|
||||
SetEventForceReuseHL: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
set (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index
|
||||
;\3 = event index (optional)
|
||||
SetEvents: MACRO
|
||||
SetEvent \1
|
||||
SetEventReuseHL \2
|
||||
|
||||
IF _NARG > 2
|
||||
SetEventReuseHL \3
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
ResetEvent: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
res (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
ResetEventReuseHL: MACRO
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
res (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index of the last event used before the branch
|
||||
ResetEventAfterBranchReuseHL: MACRO
|
||||
event_byte = ((\2) / 8)
|
||||
IF event_byte != ((\1) / 8)
|
||||
event_byte = ((\1) / 8)
|
||||
ld hl, wEventFlags + event_byte
|
||||
ENDC
|
||||
|
||||
res (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
; dangerous, only use when HL is guaranteed to be the desired value
|
||||
;\1 = event index
|
||||
ResetEventForceReuseHL: MACRO
|
||||
event_byte = ((\1) / 8)
|
||||
res (\1) % 8, [hl]
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = event index
|
||||
;\3 = event index (optional)
|
||||
ResetEvents: MACRO
|
||||
ResetEvent \1
|
||||
ResetEventReuseHL \2
|
||||
|
||||
IF _NARG > 2
|
||||
ResetEventReuseHL \3
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = number of bytes away from the base address (optional, for matching the ROM)
|
||||
dbEventFlagBit: MACRO
|
||||
IF _NARG > 1
|
||||
db ((\1) % 8) + ((\2) * 8)
|
||||
ELSE
|
||||
db ((\1) % 8)
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = event index
|
||||
;\2 = number of bytes away from the base address (optional, for matching the ROM)
|
||||
dwEventFlagAddress: MACRO
|
||||
IF _NARG > 1
|
||||
dw wEventFlags + ((\1) / 8) - (\2)
|
||||
ELSE
|
||||
dw wEventFlags + ((\1) / 8)
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = start
|
||||
;\2 = end
|
||||
SetEventRange: MACRO
|
||||
event_start_byte = ((\1) / 8)
|
||||
event_end_byte = ((\2) / 8)
|
||||
|
||||
IF event_end_byte < event_start_byte
|
||||
FAIL "Incorrect argument order in SetEventRange."
|
||||
ENDC
|
||||
|
||||
IF event_start_byte == event_end_byte
|
||||
ld a, [wEventFlags + event_start_byte]
|
||||
or (1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))
|
||||
ld [wEventFlags + event_start_byte], a
|
||||
ELSE
|
||||
event_fill_start = event_start_byte + 1
|
||||
event_fill_count = event_end_byte - event_start_byte - 1
|
||||
|
||||
IF ((\1) % 8) == 0
|
||||
event_fill_start = event_fill_start + -1
|
||||
event_fill_count = event_fill_count + 1
|
||||
ELSE
|
||||
ld a, [wEventFlags + event_start_byte]
|
||||
or $ff - ((1 << ((\1) % 8)) - 1)
|
||||
ld [wEventFlags + event_start_byte], a
|
||||
ENDC
|
||||
|
||||
IF ((\2) % 8) == 7
|
||||
event_fill_count = event_fill_count + 1
|
||||
ENDC
|
||||
|
||||
IF event_fill_count == 1
|
||||
ld hl, wEventFlags + event_fill_start
|
||||
ld [hl], $ff
|
||||
ENDC
|
||||
|
||||
IF event_fill_count > 1
|
||||
ld a, $ff
|
||||
ld hl, wEventFlags + event_fill_start
|
||||
|
||||
REPT event_fill_count + -1
|
||||
ld [hli], a
|
||||
ENDR
|
||||
|
||||
ld [hl], a
|
||||
ENDC
|
||||
|
||||
IF ((\2) % 8) == 0
|
||||
ld hl, wEventFlags + event_end_byte
|
||||
set 0, [hl]
|
||||
ELSE
|
||||
IF ((\2) % 8) != 7
|
||||
ld a, [wEventFlags + event_end_byte]
|
||||
or (1 << (((\2) % 8) + 1)) - 1
|
||||
ld [wEventFlags + event_end_byte], a
|
||||
ENDC
|
||||
ENDC
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
;\1 = start
|
||||
;\2 = end
|
||||
;\3 = assume a is 0 if present
|
||||
ResetEventRange: MACRO
|
||||
event_start_byte = ((\1) / 8)
|
||||
event_end_byte = ((\2) / 8)
|
||||
|
||||
IF event_end_byte < event_start_byte
|
||||
FAIL "Incorrect argument order in ResetEventRange."
|
||||
ENDC
|
||||
|
||||
IF event_start_byte == event_end_byte
|
||||
ld a, [wEventFlags + event_start_byte]
|
||||
and ~((1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))) & $ff
|
||||
ld [wEventFlags + event_start_byte], a
|
||||
ELSE
|
||||
event_fill_start = event_start_byte + 1
|
||||
event_fill_count = event_end_byte - event_start_byte - 1
|
||||
|
||||
IF ((\1) % 8) == 0
|
||||
event_fill_start = event_fill_start + -1
|
||||
event_fill_count = event_fill_count + 1
|
||||
ELSE
|
||||
ld a, [wEventFlags + event_start_byte]
|
||||
and ~($ff - ((1 << ((\1) % 8)) - 1)) & $ff
|
||||
ld [wEventFlags + event_start_byte], a
|
||||
ENDC
|
||||
|
||||
IF ((\2) % 8) == 7
|
||||
event_fill_count = event_fill_count + 1
|
||||
ENDC
|
||||
|
||||
IF event_fill_count == 1
|
||||
ld hl, wEventFlags + event_fill_start
|
||||
ld [hl], 0
|
||||
ENDC
|
||||
|
||||
IF event_fill_count > 1
|
||||
ld hl, wEventFlags + event_fill_start
|
||||
|
||||
; force xor a if we just to wrote to it above
|
||||
IF (_NARG < 3) || (((\1) % 8) != 0)
|
||||
xor a
|
||||
ENDC
|
||||
|
||||
REPT event_fill_count + -1
|
||||
ld [hli], a
|
||||
ENDR
|
||||
|
||||
ld [hl], a
|
||||
ENDC
|
||||
|
||||
IF ((\2) % 8) == 0
|
||||
ld hl, wEventFlags + event_end_byte
|
||||
res 0, [hl]
|
||||
ELSE
|
||||
IF ((\2) % 8) != 7
|
||||
ld a, [wEventFlags + event_end_byte]
|
||||
and ~((1 << (((\2) % 8) + 1)) - 1) & $ff
|
||||
ld [wEventFlags + event_end_byte], a
|
||||
ENDC
|
||||
ENDC
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
; returns whether both events are set in Z flag
|
||||
; This is counter-intuitive because the other event checks set the Z flag when
|
||||
; the event is not set, but this sets the Z flag when the event is set.
|
||||
;\1 = event index 1
|
||||
;\2 = event index 2
|
||||
;\3 = try to reuse a (optional)
|
||||
CheckBothEventsSet: MACRO
|
||||
IF ((\1) / 8) == ((\2) / 8)
|
||||
IF (_NARG < 3) || (((\1) / 8) != event_byte)
|
||||
event_byte = ((\1) / 8)
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
ENDC
|
||||
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
|
||||
cp (1 << ((\1) % 8)) | (1 << ((\2) % 8))
|
||||
ELSE
|
||||
; This case doesn't happen in the original ROM.
|
||||
IF ((\1) % 8) == ((\2) % 8)
|
||||
push hl
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
ld hl, wEventFlags + ((\2) / 8)
|
||||
and [hl]
|
||||
cpl
|
||||
bit ((\1) % 8), a
|
||||
pop hl
|
||||
ELSE
|
||||
push bc
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
and (1 << ((\1) % 8))
|
||||
ld b, a
|
||||
ld a, [wEventFlags + ((\2) / 8)]
|
||||
and (1 << ((\2) % 8))
|
||||
or b
|
||||
cp (1 << ((\1) % 8)) | (1 << ((\2) % 8))
|
||||
pop bc
|
||||
ENDC
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
; returns the complement of whether either event is set in Z flag
|
||||
;\1 = event index 1
|
||||
;\2 = event index 2
|
||||
CheckEitherEventSet: MACRO
|
||||
IF ((\1) / 8) == ((\2) / 8)
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
|
||||
ELSE
|
||||
; This case doesn't happen in the original ROM.
|
||||
IF ((\1) % 8) == ((\2) % 8)
|
||||
push hl
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
ld hl, wEventFlags + ((\2) / 8)
|
||||
or [hl]
|
||||
bit ((\1) % 8), a
|
||||
pop hl
|
||||
ELSE
|
||||
push bc
|
||||
ld a, [wEventFlags + ((\1) / 8)]
|
||||
and (1 << ((\1) % 8))
|
||||
ld b, a
|
||||
ld a, [wEventFlags + ((\2) / 8)]
|
||||
and (1 << ((\2) % 8))
|
||||
or b
|
||||
pop bc
|
||||
ENDC
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
; for handling fixed event bits when events are inserted/removed
|
||||
;\1 = event index
|
||||
;\2 = fixed flag bit
|
||||
AdjustEventBit: MACRO
|
||||
IF ((\1) % 8) != (\2)
|
||||
add ((\1) % 8) - (\2)
|
||||
ENDC
|
||||
ENDM
|
||||
>>>>>>> 1a987d1e1ab96ca9553d4253c72858057332a03a
|
||||
ENDM
|
||||
@@ -5,8 +5,7 @@ DisplayPCMainMenu:: ; 213c8 (8:5378)
|
||||
ld a, [wNumHoFTeams]
|
||||
and a
|
||||
jr nz, .leaguePCAvailable
|
||||
ld a, [wd74b]
|
||||
bit 5, a
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
jr z, .noOaksPC
|
||||
ld a, [wNumHoFTeams]
|
||||
and a
|
||||
@@ -26,8 +25,7 @@ DisplayPCMainMenu:: ; 213c8 (8:5378)
|
||||
call UpdateSprites
|
||||
ld a, 3
|
||||
ld [wMaxMenuItem], a
|
||||
ld a, [wd7f1]
|
||||
bit 0, a
|
||||
CheckEvent EVENT_MET_BILL
|
||||
jr nz, .metBill
|
||||
coord hl, 2, 2
|
||||
ld de, SomeonesPCText
|
||||
@@ -44,8 +42,7 @@ DisplayPCMainMenu:: ; 213c8 (8:5378)
|
||||
ld h, b
|
||||
ld de, PlayersPCText
|
||||
call PlaceString
|
||||
ld a, [wd74b]
|
||||
bit 5, a
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
jr z, .noOaksPC2
|
||||
coord hl, 2, 6
|
||||
ld de, OaksPCText
|
||||
|
||||
17
main.asm
17
main.asm
@@ -942,7 +942,7 @@ SafariZoneRestHouses:
|
||||
db -1
|
||||
|
||||
; function that performs initialization for DisplayTextID
|
||||
DisplayTextIDInit: ; 7096 (1:7096)
|
||||
DisplayTextIDInit: ; 6f0e (1:6f0e)
|
||||
xor a
|
||||
ld [wListMenuID],a
|
||||
ld a,[wAutoTextBoxDrawingControl]
|
||||
@@ -954,22 +954,19 @@ DisplayTextIDInit: ; 7096 (1:7096)
|
||||
; if text ID is 0 (i.e. the start menu)
|
||||
; Note that the start menu text border is also drawn in the function directly
|
||||
; below this, so this seems unnecessary.
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
CheckEvent EVENT_GOT_POKEDEX ; ld a, [wd74b]
|
||||
; start menu with pokedex
|
||||
coord hl, 10, 0
|
||||
ld b,$0e
|
||||
ld c,$08
|
||||
lb bc, 8, 14
|
||||
jr nz,.drawTextBoxBorder
|
||||
; start menu without pokedex
|
||||
coord hl, 10, 0
|
||||
ld b,$0c
|
||||
ld c,$08
|
||||
lb bc, 12, 8
|
||||
jr .drawTextBoxBorder
|
||||
; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
|
||||
.notStartMenu
|
||||
coord hl, 0, 12
|
||||
ld b,$04
|
||||
ld c,$12
|
||||
lb bc, 4, 18
|
||||
.drawTextBoxBorder
|
||||
call TextBoxBorder
|
||||
.skipDrawingTextBoxBorder
|
||||
@@ -1011,7 +1008,7 @@ DisplayTextIDInit: ; 7096 (1:7096)
|
||||
add hl,de
|
||||
dec c
|
||||
jr nz,.spriteStandStillLoop
|
||||
ld b,$9c ; window background address
|
||||
ld b,vBGMap1 / $100 ; window background address
|
||||
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
|
||||
xor a
|
||||
ld [hWY],a ; put the window on the screen
|
||||
@@ -1021,7 +1018,7 @@ DisplayTextIDInit: ; 7096 (1:7096)
|
||||
ret
|
||||
|
||||
; function that displays the start menu
|
||||
DrawStartMenu: ; 710b (1:710b)
|
||||
DrawStartMenu: ; 6f80 (1:6f80)
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
; menu with pokedex
|
||||
coord hl, 10, 0
|
||||
|
||||
1
wram.asm
1
wram.asm
@@ -3060,6 +3060,7 @@ wSecondLockTrashCanIndex:: ; d744
|
||||
|
||||
ds 2
|
||||
|
||||
wEventFlags::
|
||||
wd747:: ds 3 ; below here are mostly in game flags
|
||||
wd74a:: ds 1
|
||||
|
||||
|
||||
164
yellow/main.asm
164
yellow/main.asm
@@ -923,10 +923,170 @@ SafariZoneRestHouses: ; 6f0a (1:6f0a)
|
||||
db SAFARI_ZONE_REST_HOUSE_4
|
||||
db -1
|
||||
|
||||
; function that performs initialization for DisplayTextID
|
||||
DisplayTextIDInit: ; 6f0e (1:6f0e)
|
||||
dr $6f0e,$6f80
|
||||
xor a
|
||||
ld [wListMenuID],a
|
||||
ld a,[wAutoTextBoxDrawingControl]
|
||||
bit 0,a
|
||||
jr nz,.skipDrawingTextBoxBorder
|
||||
ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID)
|
||||
and a
|
||||
jr nz,.notStartMenu
|
||||
; if text ID is 0 (i.e. the start menu)
|
||||
; Note that the start menu text border is also drawn in the function directly
|
||||
; below this, so this seems unnecessary.
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
; start menu with pokedex
|
||||
coord hl, 10, 0
|
||||
lb bc, 14, 8
|
||||
jr nz,.drawTextBoxBorder
|
||||
; start menu without pokedex
|
||||
coord hl, 10, 0
|
||||
lb bc, 12, 8
|
||||
jr .drawTextBoxBorder
|
||||
; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
|
||||
.notStartMenu
|
||||
coord hl, 0, 12
|
||||
lb bc, 4, 18
|
||||
.drawTextBoxBorder
|
||||
call TextBoxBorder
|
||||
.skipDrawingTextBoxBorder
|
||||
ld hl,wFontLoaded
|
||||
set 0,[hl]
|
||||
ld hl,wFlags_0xcd60
|
||||
bit 4,[hl]
|
||||
res 4,[hl]
|
||||
jr nz,.skipMovingSprites
|
||||
call UpdateSprites
|
||||
.skipMovingSprites
|
||||
; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
|
||||
; this is done because when you talk to an NPC, they turn to look your way
|
||||
; the original direction they were facing must be restored after the dialogue is over
|
||||
ld hl,wSpriteStateData1 + $19
|
||||
ld c,$0f
|
||||
ld de,$0010
|
||||
.spriteFacingDirectionCopyLoop
|
||||
ld a,[hl]
|
||||
inc h
|
||||
ld [hl],a
|
||||
dec h
|
||||
add hl,de
|
||||
dec c
|
||||
jr nz,.spriteFacingDirectionCopyLoop
|
||||
; loop to force all the sprites in the middle of animation to stand still
|
||||
; (so that they don't like they're frozen mid-step during the dialogue)
|
||||
ld hl,wSpriteStateData1 + 2
|
||||
ld de,$0010
|
||||
ld c,e
|
||||
.spriteStandStillLoop
|
||||
ld a,[hl]
|
||||
cp a,$ff ; is the sprite visible?
|
||||
jr z,.nextSprite
|
||||
; if it is visible
|
||||
and a,$fc
|
||||
ld [hl],a
|
||||
.nextSprite
|
||||
add hl,de
|
||||
dec c
|
||||
jr nz,.spriteStandStillLoop
|
||||
ld b,vBGMap1 / $100 ; window background address
|
||||
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
|
||||
xor a
|
||||
ld [hWY],a ; put the window on the screen
|
||||
call LoadFontTilePatterns
|
||||
ld a,$01
|
||||
ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank
|
||||
ret
|
||||
|
||||
; function that displays the start menu
|
||||
DrawStartMenu: ; 6f80 (1:6f80)
|
||||
dr $6f80,$7035
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
; menu with pokedex
|
||||
coord hl, 10, 0
|
||||
lb bc, 14, 8
|
||||
jr nz,.drawTextBoxBorder
|
||||
; shorter menu if the player doesn't have the pokedex
|
||||
coord hl, 10, 0
|
||||
lb bc, 12, 8
|
||||
.drawTextBoxBorder
|
||||
call TextBoxBorder
|
||||
ld a,D_DOWN | D_UP | START | B_BUTTON | A_BUTTON
|
||||
ld [wMenuWatchedKeys],a
|
||||
ld a,$02
|
||||
ld [wTopMenuItemY],a ; Y position of first menu choice
|
||||
ld a,$0b
|
||||
ld [wTopMenuItemX],a ; X position of first menu choice
|
||||
ld a,[wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
|
||||
ld [wCurrentMenuItem],a
|
||||
ld [wLastMenuItem],a
|
||||
xor a
|
||||
ld [wMenuWatchMovingOutOfBounds],a
|
||||
ld hl,wd730
|
||||
set 6,[hl] ; no pauses between printing each letter
|
||||
coord hl, 12, 2
|
||||
CheckEvent EVENT_GOT_POKEDEX
|
||||
; case for not having pokdex
|
||||
ld a,$06
|
||||
jr z,.storeMenuItemCount
|
||||
; case for having pokedex
|
||||
ld de,StartMenuPokedexText
|
||||
call PrintStartMenuItem
|
||||
ld a,$07
|
||||
.storeMenuItemCount
|
||||
ld [wMaxMenuItem],a ; number of menu items
|
||||
ld de,StartMenuPokemonText
|
||||
call PrintStartMenuItem
|
||||
ld de,StartMenuItemText
|
||||
call PrintStartMenuItem
|
||||
ld de,wPlayerName ; player's name
|
||||
call PrintStartMenuItem
|
||||
ld a,[wd72e]
|
||||
bit 6,a ; is the player using the link feature?
|
||||
; case for not using link feature
|
||||
ld de,StartMenuSaveText
|
||||
jr z,.printSaveOrResetText
|
||||
; case for using link feature
|
||||
ld de,StartMenuResetText
|
||||
.printSaveOrResetText
|
||||
call PrintStartMenuItem
|
||||
ld de,StartMenuOptionText
|
||||
call PrintStartMenuItem
|
||||
ld de,StartMenuExitText
|
||||
call PlaceString
|
||||
ld hl,wd730
|
||||
res 6,[hl] ; turn pauses between printing letters back on
|
||||
ret
|
||||
|
||||
StartMenuPokedexText: ; 7002 (1:7002)
|
||||
db "POKéDEX@"
|
||||
|
||||
StartMenuPokemonText: ; 700a (1:700a)
|
||||
db "#MON@"
|
||||
|
||||
StartMenuItemText: ; 700f (1:700f)
|
||||
db "ITEM@"
|
||||
|
||||
StartMenuSaveText: ; 7014 (1:7014)
|
||||
db "SAVE@"
|
||||
|
||||
StartMenuResetText: ; 7019 (1:7019)
|
||||
db "RESET@"
|
||||
|
||||
StartMenuExitText: ; 701f (1:701f)
|
||||
db "EXIT@"
|
||||
|
||||
StartMenuOptionText: ; 7024 (1:7024)
|
||||
db "OPTION@"
|
||||
|
||||
PrintStartMenuItem: ; 702b (1:702b)
|
||||
push hl
|
||||
call PlaceString
|
||||
pop hl
|
||||
ld de,SCREEN_WIDTH * 2
|
||||
add hl,de
|
||||
ret
|
||||
|
||||
CableClubNPC: ; 7035 (1:7035)
|
||||
dr $7035,$71ac
|
||||
CloseLinkConnection: ; 71ac (1:71ac)
|
||||
|
||||
Reference in New Issue
Block a user