Merge branch 'master' into audio-macros

This commit is contained in:
dannye
2020-01-06 22:07:33 -06:00
451 changed files with 10496 additions and 10448 deletions

View File

@@ -1,6 +1,6 @@
; Audio interfaces.
MapSetup_Sound_Off::
InitSound::
push hl
push de
push bc
@@ -8,11 +8,11 @@ MapSetup_Sound_Off::
ldh a, [hROMBank]
push af
ld a, BANK(_MapSetup_Sound_Off)
ld a, BANK(_InitSound)
ldh [hROMBank], a
ld [MBC3RomBank], a
call _MapSetup_Sound_Off
call _InitSound
pop af
ldh [hROMBank], a
@@ -71,7 +71,7 @@ PlayMusic::
ldh a, [hROMBank]
push af
ld a, BANK(_PlayMusic) ; aka BANK(_MapSetup_Sound_Off)
ld a, BANK(_PlayMusic) ; aka BANK(_InitSound)
ldh [hROMBank], a
ld [MBC3RomBank], a
@@ -83,7 +83,7 @@ PlayMusic::
jr .end
.nomusic
call _MapSetup_Sound_Off
call _InitSound
.end
pop af
@@ -359,7 +359,8 @@ PlayMapMusic::
pop hl
ret
EnterMapMusic::
PlayMapMusicBike::
; If the player's on a bike, play the bike music instead of the map music
push hl
push de
push bc

View File

@@ -272,9 +272,9 @@ Request1bpp::
ldh a, [hTilesPerCycle]
push af
ld a, $8
ldh [hTilesPerCycle], a
ld a, [wLinkMode]
cp LINK_MOBILE
jr nz, .NotMobile

View File

@@ -23,7 +23,7 @@ FarCall_hl::
push af
ldh a, [hBuffer]
rst Bankswitch
call FarJump_hl
call FarCall_JumpToHL
ReturnFarCall::
; We want to retain the contents of f.
@@ -45,5 +45,5 @@ ReturnFarCall::
ld c, a
ret
FarJump_hl::
FarCall_JumpToHL::
jp hl

View File

@@ -1,6 +1,6 @@
Reset::
di
call MapSetup_Sound_Off
call InitSound
xor a
ldh [hMapAnims], a
call ClearPalettes
@@ -162,7 +162,7 @@ Init::
predef InitSGBBorder ; SGB init
call MapSetup_Sound_Off
call InitSound
xor a
ld [wMapMusic], a
jp GameInit

View File

@@ -338,6 +338,12 @@ JoyTextDelay::
ret
WaitPressAorB_BlinkCursor::
; Show a blinking cursor in the lower right-hand
; corner of a textbox and wait until A or B is
; pressed.
;
; NOTE: The cursor has to be shown before calling
; this function or no cursor will be shown at all.
ldh a, [hMapObjectIndexBuffer]
push af
ldh a, [hObjectStructIndexBuffer]
@@ -372,7 +378,10 @@ SimpleWaitPressAorB::
jr z, .loop
ret
ButtonSound::
PromptButton::
; Show a blinking cursor in the lower right-hand
; corner of a textbox and wait until A or B is
; pressed, afterwards, play a sound.
ld a, [wLinkMode]
and a
jr nz, .link

View File

@@ -330,7 +330,7 @@ CopyWarpData::
ld bc, 2 ; warp number
add hl, bc
ld a, [hli]
cp $ff
cp -1
jr nz, .skip
ld hl, wBackupWarpNumber
ld a, [hli]
@@ -369,6 +369,7 @@ CheckIndoorMap::
ret
; unused
UnreferencedCheckEnvironment::
cp INDOOR
ret z
cp GATE
@@ -380,11 +381,11 @@ LoadMapAttributes::
call CopyMapPartialAndAttributes
call SwitchToMapScriptsBank
call ReadMapScripts
xor a ; do not skip object_events
xor a ; do not skip object events
call ReadMapEvents
ret
LoadMapAttributes_SkipPeople::
LoadMapAttributes_SkipObjects::
call CopyMapPartialAndAttributes
call SwitchToMapScriptsBank
call ReadMapScripts
@@ -597,7 +598,7 @@ ReadObjectEvents::
; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
; Bleeds into wObjectMasks due to a bug. Uncomment the above subtraction
; to fix.
ld bc, OBJECT_LENGTH
ld bc, MAPOBJECT_LENGTH
.loop
ld [hl], 0
inc hl
@@ -631,7 +632,7 @@ CopyMapObjectEvents::
jr nz, .loop2
pop hl
ld bc, OBJECT_LENGTH
ld bc, MAPOBJECT_LENGTH
add hl, bc
pop bc
dec c
@@ -640,13 +641,13 @@ CopyMapObjectEvents::
ClearObjectStructs::
ld hl, wObject1Struct
ld bc, OBJECT_STRUCT_LENGTH * (NUM_OBJECT_STRUCTS - 1)
ld bc, OBJECT_LENGTH * (NUM_OBJECT_STRUCTS - 1)
xor a
call ByteFill
; Just to make sure (this is rather pointless)
ld hl, wObject1Struct
ld de, OBJECT_STRUCT_LENGTH
ld de, OBJECT_LENGTH
ld c, NUM_OBJECT_STRUCTS - 1
xor a
.loop
@@ -656,7 +657,7 @@ ClearObjectStructs::
jr nz, .loop
ret
RestoreFacingAfterWarp::
GetWarpDestCoords::
call GetMapScriptsBank
rst Bankswitch
@@ -679,12 +680,12 @@ endr
ld [wXCoord], a
; destination warp number
ld a, [hli]
cp $ff
cp -1
jr nz, .skip
call .backup
.skip
farcall GetCoordOfUpperLeftCorner
farcall GetMapScreenCoords
ret
.backup
@@ -1114,14 +1115,14 @@ BGEvent::
jumptext BGEventText
BGEventText::
text_far UnknownText_0x1c46fc
text_far _BGEventText
text_end
CoordinatesEvent::
jumptext CoordinatesEventText
CoordinatesEventText::
text_far UnknownText_0x1c4706
text_far _CoordinatesEventText
text_end
CheckObjectMask::
@@ -1437,7 +1438,7 @@ SaveScreen::
.vertical
ld b, SCREEN_META_WIDTH
ld c, SCREEN_META_HEIGHT - 1
jr SaveScreen_LoadNeighbor
jr SaveScreen_LoadConnection
.left
ld de, wScreenSave + 1
@@ -1449,9 +1450,9 @@ SaveScreen::
.horizontal
ld b, SCREEN_META_WIDTH - 1
ld c, SCREEN_META_HEIGHT
jr SaveScreen_LoadNeighbor
jr SaveScreen_LoadConnection
LoadNeighboringBlockData::
LoadConnectionBlockData::
ld hl, wOverworldMapAnchor
ld a, [hli]
ld h, [hl]
@@ -1463,7 +1464,7 @@ LoadNeighboringBlockData::
ld b, SCREEN_META_WIDTH
ld c, SCREEN_META_HEIGHT
SaveScreen_LoadNeighbor::
SaveScreen_LoadConnection::
.row
push bc
push hl
@@ -1480,7 +1481,6 @@ SaveScreen_LoadNeighbor::
ld e, a
jr nc, .okay
inc d
.okay
pop hl
ldh a, [hConnectionStripLength]
@@ -2259,7 +2259,7 @@ GetFishingGroup::
pop de
ret
LoadTileset::
LoadMapTileset::
push hl
push bc

View File

@@ -202,7 +202,7 @@ CheckStandingOnEntrance::
GetMapObject::
; Return the location of map object a in bc.
ld hl, wMapObjects
ld bc, OBJECT_LENGTH
ld bc, MAPOBJECT_LENGTH
call AddNTimes
ld b, h
ld c, l
@@ -358,7 +358,7 @@ CopyPlayerObjectTemplate::
ld [de], a
inc de
pop hl
ld bc, OBJECT_LENGTH - 1
ld bc, MAPOBJECT_LENGTH - 1
call CopyBytes
ret
@@ -370,7 +370,7 @@ Unreferenced_Function19b8:
push af
ld [hl], -1
inc hl
ld bc, OBJECT_LENGTH - 1
ld bc, MAPOBJECT_LENGTH - 1
xor a
call ByteFill
pop af
@@ -424,7 +424,7 @@ FindFirstEmptyObjectStruct::
push bc
push de
ld hl, wObjectStructs
ld de, OBJECT_STRUCT_LENGTH
ld de, OBJECT_LENGTH
ld c, NUM_OBJECT_STRUCTS
.loop
ld a, [hl]
@@ -594,7 +594,7 @@ UpdateSprites::
ret
GetObjectStruct::
ld bc, OBJECT_STRUCT_LENGTH
ld bc, OBJECT_LENGTH
ld hl, wObjectStructs
call AddNTimes
ld b, h

View File

@@ -1,539 +1,62 @@
; Functions used in displaying and handling menus.
LoadMenuHeader::
call CopyMenuHeader
call PushWindow
ret
CopyMenuHeader::
ld de, wMenuHeader
ld bc, wMenuHeaderEnd - wMenuHeader
call CopyBytes
ldh a, [hROMBank]
ld [wMenuDataBank], a
ret
StoreTo_wMenuCursorBuffer::
ld [wMenuCursorBuffer], a
ret
MenuTextbox::
push hl
call LoadMenuTextbox
pop hl
jp PrintText
; unused
ret
LoadMenuTextbox::
ld hl, .MenuHeader
call LoadMenuHeader
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw vTiles0
db 0 ; default option
MenuTextboxBackup::
call MenuTextbox
call CloseWindow
ret
LoadStandardMenuHeader::
ld hl, .MenuHeader
call LoadMenuHeader
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw 0
db 1 ; default option
Call_ExitMenu::
call ExitMenu
ret
VerticalMenu::
xor a
ldh [hBGMapMode], a
call MenuBox
call UpdateSprites
call PlaceVerticalMenuItems
call ApplyTilemap
call CopyMenuData
ld a, [wMenuDataFlags]
bit 7, a
jr z, .cancel
call InitVerticalMenuCursor
call StaticMenuJoypad
call MenuClickSound
bit 1, a
jr z, .okay
.cancel
scf
ret
.okay
and a
ret
GetMenu2::
call LoadMenuHeader
call VerticalMenu
call CloseWindow
ld a, [wMenuCursorY]
ret
CopyNameFromMenu::
SetMenuAttributes::
push hl
push bc
push af
ld hl, wMenuDataPointer
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
inc hl
pop af
call GetNthString
ld d, h
ld e, l
call CopyName1
pop bc
pop hl
ret
YesNoBox::
lb bc, SCREEN_WIDTH - 6, 7
PlaceYesNoBox::
jr _YesNoBox
PlaceGenericTwoOptionBox::
call LoadMenuHeader
jr InterpretTwoOptionMenu
_YesNoBox::
; Return nc (yes) or c (no).
push bc
ld hl, YesNoMenuHeader
call CopyMenuHeader
pop bc
; This seems to be an overflow prevention, but
; it was coded wrong.
ld a, b
cp SCREEN_WIDTH - 6
jr nz, .okay ; should this be "jr nc"?
ld a, SCREEN_WIDTH - 6
ld b, a
.okay
ld a, b
ld [wMenuBorderLeftCoord], a
add 5
ld [wMenuBorderRightCoord], a
ld a, c
ld [wMenuBorderTopCoord], a
add 4
ld [wMenuBorderBottomCoord], a
call PushWindow
InterpretTwoOptionMenu::
call VerticalMenu
push af
ld c, $f
call DelayFrames
call CloseWindow
pop af
jr c, .no
ld a, [wMenuCursorY]
cp 2 ; no
jr z, .no
and a
ret
.no
ld a, 2
ld [wMenuCursorY], a
scf
ret
YesNoMenuHeader::
db MENU_BACKUP_TILES ; flags
menu_coords 10, 5, 15, 9
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2
db "YES@"
db "NO@"
OffsetMenuHeader::
call _OffsetMenuHeader
call PushWindow
ret
_OffsetMenuHeader::
push de
call CopyMenuHeader
pop de
ld a, [wMenuBorderLeftCoord]
ld h, a
ld a, [wMenuBorderRightCoord]
sub h
ld h, a
ld a, d
ld [wMenuBorderLeftCoord], a
add h
ld [wMenuBorderRightCoord], a
ld a, [wMenuBorderTopCoord]
ld l, a
ld a, [wMenuBorderBottomCoord]
sub l
ld l, a
ld a, e
ld [wMenuBorderTopCoord], a
add l
ld [wMenuBorderBottomCoord], a
ret
DoNthMenu::
call DrawVariableLengthMenuBox
call MenuWriteText
call InitMenuCursorAndButtonPermissions
call GetStaticMenuJoypad
call GetMenuJoypad
call MenuClickSound
ret
SetUpMenu::
call DrawVariableLengthMenuBox ; ???
call MenuWriteText
call InitMenuCursorAndButtonPermissions ; set up selection pointer
ld hl, w2DMenuFlags1
set 7, [hl]
ret
DrawVariableLengthMenuBox::
call CopyMenuData
call GetMenuIndexSet
call AutomaticGetMenuBottomCoord
call MenuBox
ret
MenuWriteText::
xor a
ldh [hBGMapMode], a
call GetMenuIndexSet ; sort out the text
call RunMenuItemPrintingFunction ; actually write it
call SafeUpdateSprites
ldh a, [hOAMUpdate]
push af
ld a, $1
ldh [hOAMUpdate], a
call ApplyTilemap
pop af
ldh [hOAMUpdate], a
ret
AutomaticGetMenuBottomCoord::
ld a, [wMenuBorderLeftCoord]
ld c, a
ld a, [wMenuBorderRightCoord]
sub c
ld c, a
ld a, [wMenuDataItems]
add a
inc a
ld b, a
ld a, [wMenuBorderTopCoord]
add b
ld [wMenuBorderBottomCoord], a
ret
GetMenuIndexSet::
ld hl, wMenuDataIndicesPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wWhichIndexSet]
and a
jr z, .skip
ld b, a
ld c, -1
ld hl, w2DMenuCursorInitY
ld b, $8
.loop
ld a, [hli]
cp c
jr nz, .loop
ld a, [de]
inc de
ld [hli], a
dec b
jr nz, .loop
.skip
ld d, h
ld e, l
ld a, [hl]
ld [wMenuDataItems], a
ret
RunMenuItemPrintingFunction::
call MenuBoxCoord2Tile
ld bc, 2 * SCREEN_WIDTH + 2
add hl, bc
.loop
inc de
ld a, [de]
cp -1
ret z
ld [wMenuSelection], a
push de
push hl
ld d, h
ld e, l
ld hl, wMenuDataDisplayFunctionPointer
call ._hl_
ld a, $1
ld [hli], a
ld [hli], a
xor a
ld [hli], a
ld [hli], a
ld [hli], a
pop bc
pop hl
ld de, 2 * SCREEN_WIDTH
add hl, de
pop de
jr .loop
._hl_
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
InitMenuCursorAndButtonPermissions::
call InitVerticalMenuCursor
ld hl, wMenuJoypadFilter
ld a, [wMenuDataFlags]
bit 3, a
jr z, .disallow_select
set START_F, [hl]
.disallow_select
ld a, [wMenuDataFlags]
bit 2, a
jr z, .disallow_left_right
set D_LEFT_F, [hl]
set D_RIGHT_F, [hl]
.disallow_left_right
ret
GetScrollingMenuJoypad::
call ScrollingMenuJoypad
ld hl, wMenuJoypadFilter
and [hl]
jr ContinueGettingMenuJoypad
GetStaticMenuJoypad::
xor a
ld [wMenuJoypad], a
call StaticMenuJoypad
ContinueGettingMenuJoypad:
bit A_BUTTON_F, a
jr nz, .a_button
bit B_BUTTON_F, a
jr nz, .b_start
bit START_F, a
jr nz, .b_start
bit D_RIGHT_F, a
jr nz, .d_right
bit D_LEFT_F, a
jr nz, .d_left
xor a
ld [wMenuJoypad], a
jr .done
.d_right
ld a, D_RIGHT
ld [wMenuJoypad], a
jr .done
.d_left
ld a, D_LEFT
ld [wMenuJoypad], a
jr .done
.a_button
ld a, A_BUTTON
ld [wMenuJoypad], a
.done
call GetMenuIndexSet
ld a, [wMenuCursorY]
ld l, a
ld h, $0
add hl, de
ld a, [hl]
ld [wMenuSelection], a
ld a, [wMenuCursorY]
ld [wMenuCursorBuffer], a
and a
StaticMenuJoypad::
callfar _StaticMenuJoypad
call GetMenuJoypad
ret
.b_start
ld a, B_BUTTON
ld [wMenuJoypad], a
ld a, -1
ld [wMenuSelection], a
scf
ScrollingMenuJoypad::
callfar _ScrollingMenuJoypad
call GetMenuJoypad
ret
PlaceMenuStrings::
push de
ld hl, wMenuDataPointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wMenuSelection]
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ret
PlaceNthMenuStrings::
push de
ld a, [wMenuSelection]
call GetMenuDataPointerTableEntry
inc hl
inc hl
ld a, [hli]
ld d, [hl]
ld e, a
pop hl
call PlaceString
ret
Unreferenced_Function1f9e::
call GetMenuDataPointerTableEntry
inc hl
inc hl
ld a, [hli]
ld d, [hl]
ld e, a
ret
MenuJumptable::
ld a, [wMenuSelection]
call GetMenuDataPointerTableEntry
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
GetMenuDataPointerTableEntry::
ld e, a
ld d, $0
ld hl, wMenuDataPointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a
add hl, de
add hl, de
add hl, de
add hl, de
ret
ClearWindowData::
ld hl, wWindowStackPointer
call .bytefill
ld hl, wMenuHeader
call .bytefill
ld hl, wMenuDataFlags
call .bytefill
ld hl, w2DMenuCursorInitY
call .bytefill
ldh a, [rSVBK]
GetMenuJoypad::
push bc
push af
ld a, BANK(wWindowStack)
ldh [rSVBK], a
xor a
ld hl, wWindowStackBottom
ld [hld], a
ld [hld], a
ld a, l
ld [wWindowStackPointer], a
ld a, h
ld [wWindowStackPointer + 1], a
ldh a, [hJoyLast]
and D_PAD
ld b, a
ldh a, [hJoyPressed]
and BUTTONS
or b
ld b, a
pop af
ldh [rSVBK], a
ld a, b
pop bc
ret
.bytefill
ld bc, $10
xor a
call ByteFill
PlaceHollowCursor::
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], "▷"
ret
MenuClickSound::
push af
and A_BUTTON | B_BUTTON
jr z, .nosound
ld hl, wMenuFlags
bit 3, [hl]
jr nz, .nosound
call PlayClickSFX
.nosound
pop af
ret
PlayClickSFX::
push de
ld de, SFX_READ_TEXT_2
call PlaySFX
pop de
ret
MenuTextboxWaitButton::
call MenuTextbox
call WaitButton
call ExitMenu
ret
Place2DMenuItemName::
ldh [hBuffer], a
ldh a, [hROMBank]
push af
ldh a, [hBuffer]
rst Bankswitch
call PlaceString
pop af
rst Bankswitch
ret
_2DMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _2DMenu_
ld a, [wMenuCursorBuffer]
ret
InterpretBattleMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _InterpretBattleMenu
ld a, [wMenuCursorBuffer]
ret
InterpretMobileMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _InterpretMobileMenu
ld a, [wMenuCursorBuffer]
HideCursor::
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], " "
ret

539
home/menu2.asm Normal file
View File

@@ -0,0 +1,539 @@
; Functions used in displaying and handling menus.
LoadMenuHeader::
call CopyMenuHeader
call PushWindow
ret
CopyMenuHeader::
ld de, wMenuHeader
ld bc, wMenuHeaderEnd - wMenuHeader
call CopyBytes
ldh a, [hROMBank]
ld [wMenuDataBank], a
ret
StoreTo_wMenuCursorBuffer::
ld [wMenuCursorBuffer], a
ret
MenuTextbox::
push hl
call LoadMenuTextbox
pop hl
jp PrintText
; unused
ret
LoadMenuTextbox::
ld hl, .MenuHeader
call LoadMenuHeader
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw vTiles0
db 0 ; default option
MenuTextboxBackup::
call MenuTextbox
call CloseWindow
ret
LoadStandardMenuHeader::
ld hl, .MenuHeader
call LoadMenuHeader
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw 0
db 1 ; default option
Call_ExitMenu::
call ExitMenu
ret
VerticalMenu::
xor a
ldh [hBGMapMode], a
call MenuBox
call UpdateSprites
call PlaceVerticalMenuItems
call ApplyTilemap
call CopyMenuData
ld a, [wMenuDataFlags]
bit 7, a
jr z, .cancel
call InitVerticalMenuCursor
call StaticMenuJoypad
call MenuClickSound
bit 1, a
jr z, .okay
.cancel
scf
ret
.okay
and a
ret
GetMenu2::
call LoadMenuHeader
call VerticalMenu
call CloseWindow
ld a, [wMenuCursorY]
ret
CopyNameFromMenu::
push hl
push bc
push af
ld hl, wMenuDataPointer
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
inc hl
pop af
call GetNthString
ld d, h
ld e, l
call CopyName1
pop bc
pop hl
ret
YesNoBox::
lb bc, SCREEN_WIDTH - 6, 7
PlaceYesNoBox::
jr _YesNoBox
PlaceGenericTwoOptionBox::
call LoadMenuHeader
jr InterpretTwoOptionMenu
_YesNoBox::
; Return nc (yes) or c (no).
push bc
ld hl, YesNoMenuHeader
call CopyMenuHeader
pop bc
; This seems to be an overflow prevention, but
; it was coded wrong.
ld a, b
cp SCREEN_WIDTH - 6
jr nz, .okay ; should this be "jr nc"?
ld a, SCREEN_WIDTH - 6
ld b, a
.okay
ld a, b
ld [wMenuBorderLeftCoord], a
add 5
ld [wMenuBorderRightCoord], a
ld a, c
ld [wMenuBorderTopCoord], a
add 4
ld [wMenuBorderBottomCoord], a
call PushWindow
InterpretTwoOptionMenu::
call VerticalMenu
push af
ld c, $f
call DelayFrames
call CloseWindow
pop af
jr c, .no
ld a, [wMenuCursorY]
cp 2 ; no
jr z, .no
and a
ret
.no
ld a, 2
ld [wMenuCursorY], a
scf
ret
YesNoMenuHeader::
db MENU_BACKUP_TILES ; flags
menu_coords 10, 5, 15, 9
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2
db "YES@"
db "NO@"
OffsetMenuHeader::
call _OffsetMenuHeader
call PushWindow
ret
_OffsetMenuHeader::
push de
call CopyMenuHeader
pop de
ld a, [wMenuBorderLeftCoord]
ld h, a
ld a, [wMenuBorderRightCoord]
sub h
ld h, a
ld a, d
ld [wMenuBorderLeftCoord], a
add h
ld [wMenuBorderRightCoord], a
ld a, [wMenuBorderTopCoord]
ld l, a
ld a, [wMenuBorderBottomCoord]
sub l
ld l, a
ld a, e
ld [wMenuBorderTopCoord], a
add l
ld [wMenuBorderBottomCoord], a
ret
DoNthMenu::
call DrawVariableLengthMenuBox
call MenuWriteText
call InitMenuCursorAndButtonPermissions
call GetStaticMenuJoypad
call GetMenuJoypad
call MenuClickSound
ret
SetUpMenu::
call DrawVariableLengthMenuBox ; ???
call MenuWriteText
call InitMenuCursorAndButtonPermissions ; set up selection pointer
ld hl, w2DMenuFlags1
set 7, [hl]
ret
DrawVariableLengthMenuBox::
call CopyMenuData
call GetMenuIndexSet
call AutomaticGetMenuBottomCoord
call MenuBox
ret
MenuWriteText::
xor a
ldh [hBGMapMode], a
call GetMenuIndexSet ; sort out the text
call RunMenuItemPrintingFunction ; actually write it
call SafeUpdateSprites
ldh a, [hOAMUpdate]
push af
ld a, $1
ldh [hOAMUpdate], a
call ApplyTilemap
pop af
ldh [hOAMUpdate], a
ret
AutomaticGetMenuBottomCoord::
ld a, [wMenuBorderLeftCoord]
ld c, a
ld a, [wMenuBorderRightCoord]
sub c
ld c, a
ld a, [wMenuDataItems]
add a
inc a
ld b, a
ld a, [wMenuBorderTopCoord]
add b
ld [wMenuBorderBottomCoord], a
ret
GetMenuIndexSet::
ld hl, wMenuDataIndicesPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wWhichIndexSet]
and a
jr z, .skip
ld b, a
ld c, -1
.loop
ld a, [hli]
cp c
jr nz, .loop
dec b
jr nz, .loop
.skip
ld d, h
ld e, l
ld a, [hl]
ld [wMenuDataItems], a
ret
RunMenuItemPrintingFunction::
call MenuBoxCoord2Tile
ld bc, 2 * SCREEN_WIDTH + 2
add hl, bc
.loop
inc de
ld a, [de]
cp -1
ret z
ld [wMenuSelection], a
push de
push hl
ld d, h
ld e, l
ld hl, wMenuDataDisplayFunctionPointer
call ._hl_
pop hl
ld de, 2 * SCREEN_WIDTH
add hl, de
pop de
jr .loop
._hl_
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
InitMenuCursorAndButtonPermissions::
call InitVerticalMenuCursor
ld hl, wMenuJoypadFilter
ld a, [wMenuDataFlags]
bit 3, a
jr z, .disallow_select
set START_F, [hl]
.disallow_select
ld a, [wMenuDataFlags]
bit 2, a
jr z, .disallow_left_right
set D_LEFT_F, [hl]
set D_RIGHT_F, [hl]
.disallow_left_right
ret
GetScrollingMenuJoypad::
call ScrollingMenuJoypad
ld hl, wMenuJoypadFilter
and [hl]
jr ContinueGettingMenuJoypad
GetStaticMenuJoypad::
xor a
ld [wMenuJoypad], a
call StaticMenuJoypad
ContinueGettingMenuJoypad:
bit A_BUTTON_F, a
jr nz, .a_button
bit B_BUTTON_F, a
jr nz, .b_start
bit START_F, a
jr nz, .b_start
bit D_RIGHT_F, a
jr nz, .d_right
bit D_LEFT_F, a
jr nz, .d_left
xor a
ld [wMenuJoypad], a
jr .done
.d_right
ld a, D_RIGHT
ld [wMenuJoypad], a
jr .done
.d_left
ld a, D_LEFT
ld [wMenuJoypad], a
jr .done
.a_button
ld a, A_BUTTON
ld [wMenuJoypad], a
.done
call GetMenuIndexSet
ld a, [wMenuCursorY]
ld l, a
ld h, $0
add hl, de
ld a, [hl]
ld [wMenuSelection], a
ld a, [wMenuCursorY]
ld [wMenuCursorBuffer], a
and a
ret
.b_start
ld a, B_BUTTON
ld [wMenuJoypad], a
ld a, -1
ld [wMenuSelection], a
scf
ret
PlaceMenuStrings::
push de
ld hl, wMenuDataPointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wMenuSelection]
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ret
PlaceNthMenuStrings::
push de
ld a, [wMenuSelection]
call GetMenuDataPointerTableEntry
inc hl
inc hl
ld a, [hli]
ld d, [hl]
ld e, a
pop hl
call PlaceString
ret
Unreferenced_Function1f9e::
call GetMenuDataPointerTableEntry
inc hl
inc hl
ld a, [hli]
ld d, [hl]
ld e, a
ret
MenuJumptable::
ld a, [wMenuSelection]
call GetMenuDataPointerTableEntry
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
GetMenuDataPointerTableEntry::
ld e, a
ld d, $0
ld hl, wMenuDataPointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a
add hl, de
add hl, de
add hl, de
add hl, de
ret
ClearWindowData::
ld hl, wWindowStackPointer
call .bytefill
ld hl, wMenuHeader
call .bytefill
ld hl, wMenuDataFlags
call .bytefill
ld hl, w2DMenuCursorInitY
call .bytefill
ldh a, [rSVBK]
push af
ld a, BANK(wWindowStack)
ldh [rSVBK], a
xor a
ld hl, wWindowStackBottom
ld [hld], a
ld [hld], a
ld a, l
ld [wWindowStackPointer], a
ld a, h
ld [wWindowStackPointer + 1], a
pop af
ldh [rSVBK], a
ret
.bytefill
ld bc, $10
xor a
call ByteFill
ret
MenuClickSound::
push af
and A_BUTTON | B_BUTTON
jr z, .nosound
ld hl, wMenuFlags
bit 3, [hl]
jr nz, .nosound
call PlayClickSFX
.nosound
pop af
ret
PlayClickSFX::
push de
ld de, SFX_READ_TEXT_2
call PlaySFX
pop de
ret
MenuTextboxWaitButton::
call MenuTextbox
call WaitButton
call ExitMenu
ret
Place2DMenuItemName::
ldh [hBuffer], a
ldh a, [hROMBank]
push af
ldh a, [hBuffer]
rst Bankswitch
call PlaceString
pop af
rst Bankswitch
ret
_2DMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _2DMenu_
ld a, [wMenuCursorBuffer]
ret
InterpretBattleMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _InterpretBattleMenu
ld a, [wMenuCursorBuffer]
ret
InterpretMobileMenu::
ldh a, [hROMBank]
ld [wMenuData_2DMenuItemStringsBank], a
farcall _InterpretMobileMenu
ld a, [wMenuCursorBuffer]
ret

View File

@@ -127,66 +127,3 @@ ComputePathToWalkToPlayer::
big_step UP
big_step LEFT
big_step RIGHT
SetMenuAttributes::
push hl
push bc
ld hl, w2DMenuCursorInitY
ld b, $8
.loop
ld a, [de]
inc de
ld [hli], a
dec b
jr nz, .loop
ld a, $1
ld [hli], a
ld [hli], a
xor a
ld [hli], a
ld [hli], a
ld [hli], a
pop bc
pop hl
ret
StaticMenuJoypad::
callfar _StaticMenuJoypad
call GetMenuJoypad
ret
ScrollingMenuJoypad::
callfar _ScrollingMenuJoypad
call GetMenuJoypad
ret
GetMenuJoypad::
push bc
push af
ldh a, [hJoyLast]
and D_PAD
ld b, a
ldh a, [hJoyPressed]
and BUTTONS
or b
ld b, a
pop af
ld a, b
pop bc
ret
PlaceHollowCursor::
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], "▷"
ret
HideCursor::
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], " "
ret

View File

@@ -13,12 +13,12 @@ PrintBCDNumber::
; Note that bits 5 and 7 are modified during execution. The above reflects
; their meaning at the beginning of the functions's execution.
ld b, c ; save flags in b
res 7, c
res 6, c
res 5, c ; c now holds the length
bit 5, b
res PRINTNUM_LEADINGZEROS_F, c
res PRINTNUM_LEFTALIGN_F, c
res PRINTNUM_MONEY_F, c ; c now holds the length
bit PRINTNUM_MONEY_F, b
jr z, .loop
bit 7, b
bit PRINTNUM_LEADINGZEROS_F, b
jr nz, .loop ; skip currency symbol
ld [hl], "¥"
inc hl
@@ -31,14 +31,14 @@ PrintBCDNumber::
inc de
dec c
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
.numberEqualsZero ; if every digit of the BCD number is zero
bit 6, b ; left or right alignment?
jr nz, .skipRightAlignmentAdjustment
dec hl ; if the string is right-aligned, it needs to be moved back one space
.skipRightAlignmentAdjustment
bit 5, b
bit PRINTNUM_LEFTALIGN_F, b
jr nz, .skipLeftAlignmentAdjustment
dec hl ; if the string is left-aligned, it needs to be moved back one space
.skipLeftAlignmentAdjustment
bit PRINTNUM_MONEY_F, b
jr z, .skipCurrencySymbol
ld [hl], "¥" ; currency symbol
inc hl
@@ -54,25 +54,25 @@ PrintBCDDigit::
and a
jr z, .zeroDigit
.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
; 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
ld [hl], "¥"
inc hl
res 5, b
res PRINTNUM_MONEY_F, b
.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
add "0"
ld [hli], a
jp PrintLetterDelay
.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
bit 6, b ; left or right alignment?
bit PRINTNUM_LEFTALIGN_F, b
ret nz
ld a, " "
ld [hli], a ; if right-aligned, "print" a space by advancing the pointer

View File

@@ -8,12 +8,12 @@ PrintLevel::
; How many digits?
ld c, 2
cp 100 ; This is distinct from MAX_LEVEL.
jr c, Print8BitNumRightAlign
jr c, Print8BitNumLeftAlign
; 3-digit numbers overwrite the :L.
dec hl
inc c
jr Print8BitNumRightAlign
jr Print8BitNumLeftAlign
PrintLevel_Force3Digits::
; Print :L and all 3 digits
@@ -21,8 +21,8 @@ PrintLevel_Force3Digits::
inc hl
ld c, 3
Print8BitNumRightAlign::
Print8BitNumLeftAlign::
ld [wDeciramBuffer], a
ld de, wDeciramBuffer
ld b, PRINTNUM_RIGHTALIGN | 1
ld b, PRINTNUM_LEFTALIGN | 1
jp PrintNum

View File

@@ -26,12 +26,10 @@ SECTION "rst28", ROM0 ; rst JumpTable
add hl, de
ld a, [hli]
ld h, [hl]
; SECTION "rst30", ROM0
ld l, a
pop de
jp hl
; SECTION "rst30", ROM0
; rst30 is midst rst28
SECTION "rst38", ROM0
rst $38

View File

@@ -478,7 +478,7 @@ Paragraph::
.linkbattle
call Text_WaitBGMap
call ButtonSound
call PromptButton
hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY
lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW
call ClearBox
@@ -499,7 +499,7 @@ _ContText::
call Text_WaitBGMap
push de
call ButtonSound
call PromptButton
pop de
ld a, [wLinkMode]
@@ -545,7 +545,7 @@ PromptText::
.ok
call Text_WaitBGMap
call ButtonSound
call PromptButton
ld a, [wLinkMode]
cp LINK_COLOSSEUM
jr z, DoneText
@@ -686,29 +686,29 @@ DoTextUntilTerminator::
TextCommands::
; entries correspond to TX_* constants (see macros/scripts/text.asm)
dw TextCommand_START ; TX_START
dw TextCommand_RAM ; TX_RAM
dw TextCommand_BCD ; TX_BCD
dw TextCommand_MOVE ; TX_MOVE
dw TextCommand_BOX ; TX_BOX
dw TextCommand_LOW ; TX_LOW
dw TextCommand_WAIT_BUTTON ; TX_WAIT_BUTTON
dw TextCommand_SCROLL ; TX_SCROLL
dw TextCommand_START_ASM ; TX_START_ASM
dw TextCommand_NUM ; TX_NUM
dw TextCommand_PAUSE ; TX_PAUSE
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_50_79
dw TextCommand_DOTS ; TX_DOTS
dw TextCommand_LINK_WAIT_BUTTON ; TX_LINK_WAIT_BUTTON
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_20_49
dw TextCommand_SOUND ; TX_SOUND_ITEM
dw TextCommand_SOUND ; TX_SOUND_CAUGHT_MON
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_80_109
dw TextCommand_SOUND ; TX_SOUND_FANFARE
dw TextCommand_SOUND ; TX_SOUND_SLOT_MACHINE_START
dw TextCommand_STRINGBUFFER ; TX_STRINGBUFFER
dw TextCommand_DAY ; TX_DAY
dw TextCommand_FAR ; TX_FAR
dw TextCommand_START ; TX_START
dw TextCommand_RAM ; TX_RAM
dw TextCommand_BCD ; TX_BCD
dw TextCommand_MOVE ; TX_MOVE
dw TextCommand_BOX ; TX_BOX
dw TextCommand_LOW ; TX_LOW
dw TextCommand_PROMPT_BUTTON ; TX_PROMPT_BUTTON
dw TextCommand_SCROLL ; TX_SCROLL
dw TextCommand_START_ASM ; TX_START_ASM
dw TextCommand_NUM ; TX_NUM
dw TextCommand_PAUSE ; TX_PAUSE
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_50_79
dw TextCommand_DOTS ; TX_DOTS
dw TextCommand_LINK_PROMPT_BUTTON ; TX_LINK_PROMPT_BUTTON
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_20_49
dw TextCommand_SOUND ; TX_SOUND_ITEM
dw TextCommand_SOUND ; TX_SOUND_CAUGHT_MON
dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_80_109
dw TextCommand_SOUND ; TX_SOUND_FANFARE
dw TextCommand_SOUND ; TX_SOUND_SLOT_MACHINE_START
dw TextCommand_STRINGBUFFER ; TX_STRINGBUFFER
dw TextCommand_DAY ; TX_DAY
dw TextCommand_FAR ; TX_FAR
TextCommand_START::
; text_start
@@ -834,22 +834,22 @@ TextCommand_LOW::
bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2
ret
TextCommand_WAIT_BUTTON::
; text_waitbutton
TextCommand_PROMPT_BUTTON::
; text_promptbutton
; wait for button press
; show arrow
; [06]
ld a, [wLinkMode]
cp LINK_COLOSSEUM
jp z, TextCommand_LINK_WAIT_BUTTON
jp z, TextCommand_LINK_PROMPT_BUTTON
cp LINK_MOBILE
jp z, TextCommand_LINK_WAIT_BUTTON
jp z, TextCommand_LINK_PROMPT_BUTTON
push hl
call LoadBlinkingCursor
push bc
call ButtonSound
call PromptButton
pop bc
call UnloadBlinkingCursor
pop hl
@@ -896,7 +896,7 @@ TextCommand_NUM::
ld a, b
and $f0
swap a
set PRINTNUM_RIGHTALIGN_F, a
set PRINTNUM_LEFTALIGN_F, a
ld b, a
call PrintNum
ld b, h
@@ -1005,13 +1005,13 @@ TextCommand_DOTS::
pop hl
ret
TextCommand_LINK_WAIT_BUTTON::
; text_linkwaitbutton
TextCommand_LINK_PROMPT_BUTTON::
; text_linkpromptbutton
; wait for key down
; display arrow
push hl
push bc
call ButtonSound
call PromptButton
pop bc
pop hl
ret

View File

@@ -15,7 +15,7 @@ _CheckTrainerBattle::
; Skip the player object.
ld a, 1
ld de, wMapObjects + OBJECT_LENGTH
ld de, wMapObjects + MAPOBJECT_LENGTH
.loop
@@ -78,7 +78,7 @@ _CheckTrainerBattle::
.next
pop de
ld hl, OBJECT_LENGTH
ld hl, MAPOBJECT_LENGTH
add hl, de
ld d, h
ld e, l

View File

@@ -39,7 +39,7 @@ CloseText::
ld a, $90
ldh [hWY], a
call ReplaceKrisSprite
farcall ReturnFromMapSetupScript
farcall InitMapNameSign
farcall LoadOverworldFont
ret