From 39524cdb766660a7bf6d60379040349652cecc04 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jul 2015 15:48:44 -0400 Subject: More enumeration of constants, more annotations of scripts. --- home/battle.asm | 2 +- home/joypad.asm | 4 +- home/map.asm | 32 +++---- home/map_objects.asm | 240 ++++++++++++++++++++++++--------------------------- home/menu.asm | 26 +++--- home/movement.asm | 4 +- home/text.asm | 18 ++-- home/window.asm | 2 +- 8 files changed, 157 insertions(+), 171 deletions(-) (limited to 'home') diff --git a/home/battle.asm b/home/battle.asm index 758c15ae1..fa72d75a0 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -310,7 +310,7 @@ BattleTextBox:: ; 3ac3 push hl call SpeechTextBox call MobileTextBorder - call Function1ad2 + call DrawOnMap call Function321c pop hl call PrintTextBoxText diff --git a/home/joypad.asm b/home/joypad.asm index 5a161fb14..42a61cd5d 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -312,7 +312,7 @@ Functiona36:: ; a36 jr Functiona36 ; a46 -Functiona46:: ; a46 +CloseText:: ; a46 ld a, [hOAMUpdate] push af ld a, 1 @@ -387,7 +387,7 @@ Functionaa5:: ; aa5 ret ; aaf -Functionaaf:: ; aaf +KeepTextOpen:: ; aaf ld a, [InLinkBattle] and a jr nz, .asm_ac1 diff --git a/home/map.asm b/home/map.asm index 259ed9503..e800a8d12 100644 --- a/home/map.asm +++ b/home/map.asm @@ -8,7 +8,7 @@ Function210f:: ; 210f ret ; 211b -Function211b:: ; 211b +CheckTriggers:: ; 211b push hl ld hl, BikeFlags + 2 ld a, [hli] @@ -17,7 +17,7 @@ Function211b:: ; 211b or h ld a, [hl] jr nz, .asm_2128 - ld a, $ff + ld a, -1 .asm_2128 pop hl @@ -702,7 +702,7 @@ Function24cd:: ; 24cd ld bc, OverworldMapEnd - OverworldMap ld a, 0 call ByteFill - call Function24e4 + call ChangeMap call FillMapConnections ld a, $1 call Function263b @@ -711,7 +711,7 @@ Function24cd:: ; 24cd -Function24e4:: ; 24e4 +ChangeMap:: ; 24e4 ld a, [hROMBank] push af @@ -938,7 +938,7 @@ FillEastConnectionStrip:: ; 25f6 ret ; 261b -Function261b:: ; 261b +LoadMapStatus:: ; 261b ld [MapStatus], a ret ; 261f @@ -1027,7 +1027,7 @@ Function2674:: ; 2674 ld a, [hl] push af set 1, [hl] - callba Function96c56 + callba EnableScriptMode callba ScriptEvents pop af ld [ScriptFlags], a @@ -1036,7 +1036,7 @@ Function2674:: ; 2674 ret ; 269a -Function269a:: ; 269a +MapTextbox:: ; 269a ld a, [hROMBank] push af @@ -1059,7 +1059,7 @@ Function269a:: ; 269a ret ; 26b7 -Function26b7:: ; 26b7 +Call_a_de:: ; 26b7 ; Call a:de. ld [hBuffer], a @@ -1079,7 +1079,7 @@ Function26b7:: ; 26b7 ret ; 26c7 -Function26c7:: ; 26c7 +GetMovementData:: ; 26c7 ld a, [hROMBank] push af ld a, b @@ -1412,7 +1412,7 @@ Function2821:: ; 2821 ret ; 2879 -Function2879:: ; 2879 +BufferScreen:: ; 2879 ld hl, wd194 ld a, [hli] ld h, [hl] @@ -1733,7 +1733,7 @@ GetFacingTileCoord:: ; 2a07 Function2a3c:: ; 2a3c - call Function2a66 + call GetBlockLocation ld a, [hl] and a jr z, .asm_2a63 @@ -1766,7 +1766,7 @@ Function2a3c:: ; 2a3c ret ; 2a66 -Function2a66:: ; 2a66 +GetBlockLocation:: ; 2a66 ld a, [MapWidth] add $6 ld c, a @@ -1878,7 +1878,7 @@ Function2ae7:: ; 2ae7 ld a, [hli] ld h, [hl] ld l, a - call Function211b + call CheckTriggers ld b, a ld a, [MapX] sub $4 @@ -1941,7 +1941,7 @@ FadeToMenu:: ; 2b29 Function2b3c:: ; 2b3c call WhiteBGMap call Function2bae - call Function1ad2 + call DrawOnMap call Function1d7d call Functiond90 jr Function2b5c @@ -1951,7 +1951,7 @@ Function2b4d:: ; 2b4d call WhiteBGMap call Function1d7d call Function2bae - call Function1ad2 + call DrawOnMap call Functiond90 ; 2b5c @@ -1978,7 +1978,7 @@ Function2b74:: ; 0x2b74 call TextBox ld hl, VramState set 0, [hl] - call Function1ad2 + call DrawOnMap call Function3200 ld b, $9 call GetSGBLayout diff --git a/home/map_objects.asm b/home/map_objects.asm index 4a2b58712..509492033 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -19,33 +19,33 @@ Function180e:: ; 180e push hl push bc ld hl, UsedSprites + 2 - ld c, $1f + ld c, SPRITE_GFX_LIST_CAPACITY - 1 ld b, a ld a, [hConnectionStripLength] cp $0 - jr z, .asm_182b + jr z, .nope ld a, b -.asm_181d +.loop cp [hl] - jr z, .asm_1830 + jr z, .found inc hl inc hl dec c - jr nz, .asm_181d + jr nz, .loop ld a, [UsedSprites + 1] scf - jr .asm_1833 + jr .done -.asm_182b +.nope ld a, [UsedSprites + 1] - jr .asm_1833 + jr .done -.asm_1830 +.found inc hl xor a ld a, [hl] -.asm_1833 +.done pop bc pop hl ret @@ -125,20 +125,20 @@ Function1875:: ; 1875 ld d, a and $f0 cp $10 - jr z, .asm_1882 + jr z, .ok_10 cp $20 - jr z, .asm_1888 + jr z, .ok_20 scf ret -.asm_1882 +.ok_10 ld a, d and 7 ret z scf ret -.asm_1888 +.ok_20 ld a, d and 7 ret z @@ -223,7 +223,7 @@ CheckStandingOnEntrance:: ; 18c3 GetMapObject:: ; 18d2 ; Return the location of map object a in bc. ld hl, MapObjects - ld bc, $10 + ld bc, OBJECT_LENGTH call AddNTimes ld b, h ld c, l @@ -232,93 +232,94 @@ GetMapObject:: ; 18d2 Function18de:: ; 18de +; Sets carry if the object is not visible on the screen. ld [hConnectionStripLength], a call GetMapObject - ld hl, $0000 + ld hl, MAPOBJECT_VRAM_ID add hl, bc ld a, [hl] - cp $ff - jr z, .asm_18f3 + cp MAPOBJECT_NOT_VISIBLE + jr z, .not_visible ld [hConnectedMapWidth], a - call Function1ae5 + call GetObjectStruct and a ret -.asm_18f3 +.not_visible scf ret ; 18f5 Function18f5:: ; 18f5 - ld hl, $0006 + ld hl, MAPOBJECT_HOUR add hl, bc ld a, [hl] - cp $ff - jr nz, .asm_1921 - ld hl, $0007 + cp -1 + jr nz, .check_hour + ld hl, MAPOBJECT_TIMEOFDAY add hl, bc ld a, [hl] - cp $ff - jr z, .asm_191c - ld hl, .data_191e + cp -1 + jr z, .timeofday_always + ld hl, .TimeOfDayValues_191e ld a, [TimeOfDay] add l ld l, a - jr nc, .asm_1912 + jr nc, .ok inc h -.asm_1912 +.ok ld a, [hl] - ld hl, $0007 + ld hl, MAPOBJECT_TIMEOFDAY add hl, bc and [hl] - jr nz, .asm_191c + jr nz, .timeofday_always scf ret -.asm_191c +.timeofday_always and a ret -.data_191e - db $1 - db $2 - db $4 +.TimeOfDayValues_191e + db 1 << MORN ; 1 + db 1 << DAY ; 2 + db 1 << NITE ; 4 -.asm_1921 - ld hl, $0006 +.check_hour + ld hl, MAPOBJECT_HOUR add hl, bc ld d, [hl] - ld hl, $0007 + ld hl, MAPOBJECT_TIMEOFDAY add hl, bc ld e, [hl] ld hl, hHours ld a, d cp e - jr z, .asm_1949 - jr c, .asm_193f + jr z, .yes + jr c, .check_timeofday ld a, [hl] cp d - jr nc, .asm_1949 + jr nc, .yes cp e - jr c, .asm_1949 - jr z, .asm_1949 - jr .asm_194b + jr c, .yes + jr z, .yes + jr .no -.asm_193f +.check_timeofday ld a, e cp [hl] - jr c, .asm_194b + jr c, .no ld a, [hl] cp d - jr nc, .asm_1949 - jr .asm_194b + jr nc, .yes + jr .no -.asm_1949 +.yes and a ret -.asm_194b +.no scf ret ; 194d @@ -344,16 +345,16 @@ Function1956:: ; 1956 Function1967:: ; 1967 ld [hConnectionStripLength], a call GetMapObject - ld hl, $0000 + ld hl, MAPOBJECT_VRAM_ID add hl, bc ld a, [hl] - cp $ff + cp MAPOBJECT_NOT_VISIBLE ret z - ld [hl], $ff + ld [hl], MAPOBJECT_NOT_VISIBLE push af call Function1985 pop af - call Function1ae5 + call GetObjectStruct callba Function4357 ret ; 1985 @@ -361,14 +362,14 @@ Function1967:: ; 1967 Function1985:: ; 1985 ld hl, wd4cd cp [hl] - jr z, .asm_1990 + jr z, .ok ld hl, wd4ce cp [hl] ret nz -.asm_1990 +.ok callba Function581f - ld a, $ff + ld a, -1 ld [wd4cd], a ld [wd4ce], a ret @@ -385,41 +386,41 @@ Function19a6:: ; 19a6 call GetMapObject ld d, b ld e, c - ld a, $ff + ld a, MAPOBJECT_NOT_VISIBLE ld [de], a inc de pop hl - ld bc, $000f + ld bc, OBJECT_LENGTH - 1 call CopyBytes ret ; 19b8 Function19b8:: ; 19b8 call GetMapObject - ld hl, $0000 + ld hl, MAPOBJECT_VRAM_ID add hl, bc ld a, [hl] push af - ld [hl], $ff + ld [hl], MAPOBJECT_NOT_VISIBLE inc hl - ld bc, $000f + ld bc, OBJECT_LENGTH - 1 xor a call ByteFill pop af - cp $ff + cp MAPOBJECT_NOT_VISIBLE ret z cp $d ret nc ld b, a ld a, [wd4cd] cp b - jr nz, .asm_19de - ld a, $ff + jr nz, .ok + ld a, -1 ld [wd4cd], a -.asm_19de +.ok ld a, b - call Function1ae5 + call GetObjectStruct callba Function4357 ret ; 19e9 @@ -437,12 +438,12 @@ Function19e9:: ; 19e9 ld a, [wc2e2] call Function18de ret c - ld hl, $0003 + ld hl, OBJECT_03 add hl, bc ld [hl], $14 - ld hl, $0009 + ld hl, OBJECT_09 add hl, bc - ld [hl], $0 + ld [hl], 0 ld hl, VramState set 7, [hl] and a @@ -455,24 +456,24 @@ Function1a13:: ; 1a13 push bc push de ld hl, ObjectStructs - ld de, $0028 - ld c, $d -.asm_1a1d + ld de, OBJECT_STRUCT_LENGTH + ld c, NUM_OBJECT_STRUCTS +.loop ld a, [hl] and a - jr z, .asm_1a28 + jr z, .empty add hl, de dec c - jr nz, .asm_1a1d + jr nz, .loop xor a - jr .asm_1a2c + jr .done -.asm_1a28 +.empty ld a, $d sub c scf -.asm_1a2c +.done pop de pop bc ret @@ -481,23 +482,18 @@ Function1a13:: ; 1a13 Function1a2f:: ; 1a2f - ld hl, $0003 + ld hl, OBJECT_03 add hl, bc ld a, [hl] - cp $25 - jr c, .asm_1a39 + cp OBJECT_STRUCT_3_DATA_HEIGHT + jr c, .ok xor a -.asm_1a39 - ld hl, Data4273 +.ok + ld hl, ObjectStruct3_Data ld e, a ld d, 0 - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de + add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH ld a, [hl] ret ; 1a47 @@ -507,14 +503,9 @@ Function1a47:: ; 1a47 push de ld e, a ld d, 0 - ld hl, Data4273 + 1 - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de - ld a, BANK(Data4273) + ld hl, ObjectStruct3_Data + 1 + add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH + ld a, BANK(ObjectStruct3_Data) call GetFarByte add a add a @@ -529,7 +520,7 @@ Function1a61:: ; 1a61 ld l, a ld a, [hROMBank] push af - ld a, BANK(Data4273) + ld a, BANK(ObjectStruct3_Data) rst Bankswitch ld a, l push bc @@ -544,19 +535,14 @@ Function1a61:: ; 1a61 ; 1a71 Function1a71:: ; 1a71 - ld hl, $0003 + ld hl, OBJECT_03 add hl, de ld [hl], a push de ld e, a ld d, 0 - ld hl, Data4273 + 1 - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de + ld hl, ObjectStruct3_Data + 1 + add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH ld b, h ld c, l pop de @@ -565,27 +551,27 @@ Function1a71:: ; 1a71 rlca rlca and $c - ld hl, $0008 + ld hl, OBJECT_FACING add hl, de ld [hl], a ld a, [bc] inc bc - ld hl, $000b + ld hl, OBJECT_11 add hl, de ld [hl], a ld a, [bc] inc bc - ld hl, $0004 + ld hl, OBJECT_04 add hl, de ld [hl], a ld a, [bc] inc bc - ld hl, $0005 + ld hl, OBJECT_FLAGS add hl, de ld [hl], a ld a, [bc] inc bc - ld hl, $0006 + ld hl, OBJECT_PALETTE add hl, de ld [hl], a ret @@ -599,12 +585,12 @@ Function1aae:: ; 1aae ld a, [hli] ld d, [hl] - ld hl, $001b + ld hl, OBJECT_27 add hl, bc add [hl] ld e, a ld a, d - adc $0 + adc 0 ld d, a inc [hl] ld a, [de] @@ -616,20 +602,20 @@ Function1aae:: ; 1aae ret ; 1ac6 -Function1ac6:: ; 1ac6 +SetVramState_Bit0:: ; 1ac6 ld hl, VramState set 0, [hl] ret ; 1acc -Function1acc:: ; 1acc +ResetVramState_Bit0:: ; 1acc ld hl, VramState res 0, [hl] ret ; 1ad2 -Function1ad2:: ; 1ad2 +DrawOnMap:: ; 1ad2 ld a, [VramState] bit 0, a ret z @@ -639,8 +625,8 @@ Function1ad2:: ; 1ad2 ; 1ae5 -Function1ae5:: ; 1ae5 - ld bc, $0028 +GetObjectStruct:: ; 1ae5 + ld bc, OBJECT_STRUCT_LENGTH ld hl, ObjectStructs call AddNTimes ld b, h @@ -648,23 +634,23 @@ Function1ae5:: ; 1ae5 ret ; 1af1 -Function1af1:: ; 1af1 - ld hl, $0000 +GetObjectSprite:: ; 1af1 + ld hl, OBJECT_SPRITE add hl, bc ld a, [hl] and a ret ; 1af8 -Function1af8:: ; 1af8 +SetSpriteDirection:: ; 1af8 push af - ld hl, $0008 + ld hl, OBJECT_FACING add hl, bc ld a, [hl] - and $f3 + and %11110011 ld e, a pop af - and $c + and %00001100 or e ld [hl], a ret @@ -672,9 +658,9 @@ Function1af8:: ; 1af8 GetSpriteDirection:: ; 1b07 - ld hl, $0008 + ld hl, OBJECT_FACING add hl, bc ld a, [hl] - and $c + and %00001100 ret ; 1b0f diff --git a/home/menu.asm b/home/menu.asm index 21ce9c515..3c28b95e5 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -2,11 +2,11 @@ LoadMenuDataHeader:: ; 0x1d35 - call Function1d3c + call CopyMenuDataHeader call Function1c00 ret -Function1d3c:: ; 0x1d3c +CopyMenuDataHeader:: ; 0x1d3c ld de, wcf81 ld bc, $0010 call CopyBytes @@ -48,7 +48,7 @@ MenuDataHeader_0x1d5f:: ; 1d5f Function1d67:: ; 1d67 call Function1d4f - call Function1c17 + call WriteBackup ret ; 1d6e @@ -71,11 +71,11 @@ Function1d7d:: ; 1d7d ret ; 1d81 -Function1d81:: ; 0x1d81 +InterpretMenu2:: ; 0x1d81 xor a ld [hBGMapMode], a call Function1cbb - call Function1ad2 + call DrawOnMap call Function1c89 call Function321c call Function1c66 @@ -97,8 +97,8 @@ Function1d81:: ; 0x1d81 Function1dab:: ; 1dab call LoadMenuDataHeader - call Function1d81 - call Function1c17 + call InterpretMenu2 + call WriteBackup ld a, [wcfa9] ret ; 1db8 @@ -138,7 +138,7 @@ _YesNoBox:: ; 1dd9 ; Return nc (yes) or c (no). push bc ld hl, YesNoMenuDataHeader - call Function1d3c + call CopyMenuDataHeader pop bc ld a, b cp $e @@ -158,11 +158,11 @@ _YesNoBox:: ; 1dd9 call Function1c00 Function1dfe:: ; 1dfe - call Function1d81 + call InterpretMenu2 push af ld c, $f call DelayFrames - call Function1c17 + call WriteBackup pop af jr c, .asm_1e16 ld a, [wcfa9] @@ -201,7 +201,7 @@ Function1e2e:: ; 1e2e Function1e35:: ; 1e35 push de - call Function1d3c + call CopyMenuDataHeader pop de ld a, [wcf83] ld h, a @@ -540,7 +540,7 @@ PlayClickSFX:: ; 2009 Function2012:: ; 2012 call Function1d4f - call Functiona46 + call CloseText call Function1c07 ret ; 201c @@ -559,7 +559,7 @@ Function201c:: ; 201c ret ; 202a -Function202a:: ; 202a +InterpretMenu:: ; 202a ld a, [hROMBank] ld [wcf94], a callba Function2400e diff --git a/home/movement.asm b/home/movement.asm index f0869aa99..0cbb14f5d 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -203,11 +203,11 @@ Function1c10:: ; 0x1c10 callab Function2446d ret -Function1c17:: ; 0x1c17 +WriteBackup:: ; 0x1c17 push af call Function1c07 call Function321c - call Function1ad2 + call DrawOnMap pop af ret diff --git a/home/text.asm b/home/text.asm index feb3eb734..4cb581bcb 100644 --- a/home/text.asm +++ b/home/text.asm @@ -169,7 +169,7 @@ Function1052:: ; 1052 PrintText:: ; 1057 - call Function106c + call SetUpTextBox Function105a:: ; 105a push hl hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY @@ -183,10 +183,10 @@ PrintTextBoxText:: ; 1065 ret ; 106c -Function106c:: ; 106c +SetUpTextBox:: ; 106c push hl call SpeechTextBox - call Function1ad2 + call DrawOnMap call Function321c pop hl ret @@ -385,7 +385,7 @@ Char3F:: ; 121b ld de, String12a2 call PlaceString push bc - callab Function39939 + callab Battle_GetTrainerName pop hl ld de, StringBuffer1 jr Function126a @@ -517,7 +517,7 @@ Paragraph:: ; 12f2 .asm_1301 call Function13b6 - call Functionaaf + call KeepTextOpen hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW call ClearBox @@ -540,7 +540,7 @@ Char4B:: ; 131f call Function13b6 push de - call Functionaaf + call KeepTextOpen pop de ld a, [InLinkBattle] @@ -590,7 +590,7 @@ PromptText:: ; 135a .ok call Function13b6 - call Functionaaf + call KeepTextOpen ld a, [InLinkBattle] cp $3 jr z, DoneText @@ -904,7 +904,7 @@ Text_06:: ; 149f push hl call Function13c7 push bc - call Functionaaf + call KeepTextOpen pop bc call Function13cd pop hl @@ -1066,7 +1066,7 @@ Text_0D:: ; 1562 ; display arrow push hl push bc - call Functionaaf + call KeepTextOpen pop bc pop hl ret diff --git a/home/window.asm b/home/window.asm index 8c1e95134..31e299827 100644 --- a/home/window.asm +++ b/home/window.asm @@ -83,7 +83,7 @@ Function2e31:: ; 2e31 ld [hBGMapMode], a ld a, $1 ld [hOAMUpdate], a - call Function1ad2 + call DrawOnMap xor a ld [hOAMUpdate], a call DelayFrame -- cgit v1.2.3 From 894955f9d922de5fc33e6c0aa7af9795dbcbc158 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 16 Jul 2015 18:10:10 -0400 Subject: Special script annotation, trainer constant enumeration, person-event structure update --- home/map.asm | 210 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 113 insertions(+), 97 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index e800a8d12..78ec839c5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -9,40 +9,48 @@ Function210f:: ; 210f ; 211b CheckTriggers:: ; 211b +; Checks wCurrentMapTriggerPointer. If it's empty, returns -1 in a. Otherwise, returns the active trigger ID in a. push hl - ld hl, BikeFlags + 2 + ld hl, wCurrentMapTriggerPointer ld a, [hli] ld h, [hl] ld l, a or h ld a, [hl] - jr nz, .asm_2128 + jr nz, .triggerexists ld a, -1 -.asm_2128 +.triggerexists pop hl ret ; 212a GetCurrentMapTrigger:: ; 212a +; Grabs the wram map trigger pointer for the current map and loads it into wCurrentMapTriggerPointer. +; If there are no triggers, both bytes of wCurrentMapTriggerPointer are wiped clean. +; Copy the current map group and number into bc. This is needed for GetMapTrigger. ld a, [MapGroup] ld b, a ld a, [MapNumber] ld c, a +; Blank out wCurrentMapTriggerPointer; this is the default scenario. xor a - ld [BikeFlags + 2], a - ld [BikeFlags + 3], a + ld [wCurrentMapTriggerPointer], a + ld [wCurrentMapTriggerPointer + 1], a call GetMapTrigger - ret c + ret c ; The map is not in the trigger table +; Load the trigger table pointer from de into wCurrentMapTriggerPointer ld a, e - ld [BikeFlags + 2], a + ld [wCurrentMapTriggerPointer], a ld a, d - ld [BikeFlags + 3], a + ld [wCurrentMapTriggerPointer + 1], a xor a ret ; 2147 GetMapTrigger:: ; 2147 +; Searches the trigger table for the map group and number loaded in bc, and returns the wram pointer in de. +; If the map is not in the trigger table, returns carry. push bc ld a, [hROMBank] push af @@ -50,34 +58,34 @@ GetMapTrigger:: ; 2147 rst Bankswitch ld hl, MapTriggers -.asm_2151 +.loop push hl - ld a, [hli] - cp $ff - jr z, .asm_2167 + ld a, [hli] ; map group, or terminator + cp -1 + jr z, .end ; the current map is not in the trigger table cp b - jr nz, .asm_2160 - ld a, [hli] + jr nz, .next ; map group did not match + ld a, [hli] ; map number cp c - jr nz, .asm_2160 - jr .asm_216a + jr nz, .next ; map number did not match + jr .found ; we found our map -.asm_2160 +.next pop hl - ld de, $0004 + ld de, 4 ; size of an entry in the trigger table add hl, de - jr .asm_2151 + jr .loop -.asm_2167 +.end scf - jr .asm_216d + jr .done -.asm_216a +.found ld e, [hl] inc hl ld d, [hl] -.asm_216d +.done pop hl pop bc ld a, b @@ -234,7 +242,7 @@ Function2252:: ; 2252 ld a, [hROMBank] push af - call Function2c52 + call SwitchToMapScriptHeaderBank call Function2266 pop de @@ -305,7 +313,7 @@ Function22a7:: ; 22a7 ld a, [hROMBank] push af - call Function2c52 + call SwitchToMapScriptHeaderBank call Function22b4 pop af @@ -381,7 +389,7 @@ Function2300:: ; 2300 Function2309:: ; 2309 call Function2326 - call Function2c52 + call SwitchToMapScriptHeaderBank call Function234f xor a call Function2336 @@ -390,7 +398,7 @@ Function2309:: ; 2309 Function2317:: ; 2317 call Function2326 - call Function2c52 + call SwitchToMapScriptHeaderBank call Function234f ld a, $1 call Function2336 @@ -548,7 +556,7 @@ Function23da:: ; 23da Function23f1:: ; 23f1 ld a, [hli] ld c, a - ld [wdbfe], a + ld [wCurrentMapXYTriggerCount], a ld a, l ld [wdbff], a ld a, h @@ -564,7 +572,7 @@ Function23f1:: ; 23f1 Function2408:: ; 2408 ld a, [hli] ld c, a - ld [wdc01], a + ld [wCurrentMapSignpostCount], a ld a, l ld [wdc02], a ld a, h @@ -972,7 +980,7 @@ Function263b:: ; 263b ld b, a ld a, [hROMBank] push af - call Function2c52 + call SwitchToMapScriptHeaderBank call Function2653 jr nc, .done @@ -1607,13 +1615,13 @@ Function298b:: ; 298b ld a, [TileDown] and $7 cp $2 - jr z, .asm_299f + jr z, .ok cp $6 - jr z, .asm_299f + jr z, .ok cp $7 ret nz -.asm_299f +.ok ld a, [TilePermissions] or $8 ld [TilePermissions], a @@ -1626,13 +1634,13 @@ Function29a8:: ; 29a8 ld a, [TileUp] and $7 cp $3 - jr z, .asm_29bc + jr z, .ok cp $4 - jr z, .asm_29bc + jr z, .ok cp $5 ret nz -.asm_29bc +.ok ld a, [TilePermissions] or $4 ld [TilePermissions], a @@ -1645,13 +1653,13 @@ Function29c5:: ; 29c5 ld a, [TileRight] and $7 cp $1 - jr z, .asm_29d9 + jr z, .ok cp $5 - jr z, .asm_29d9 + jr z, .ok cp $7 ret nz -.asm_29d9 +.ok ld a, [TilePermissions] or $1 ld [TilePermissions], a @@ -1664,13 +1672,13 @@ Function29e2:: ; 29e2 ld a, [TileLeft] and $7 cp $0 - jr z, .asm_29f6 + jr z, .ok cp $4 - jr z, .asm_29f6 + jr z, .ok cp $6 ret nz -.asm_29f6 +.ok ld a, [TilePermissions] or $2 ld [TilePermissions], a @@ -1696,8 +1704,7 @@ GetFacingTileCoord:: ; 2a07 srl a ld l, a ld h, 0 - add hl, hl - add hl, hl + add_n_times hl, hl, 2 ld de, .Directions add hl, de @@ -1736,33 +1743,32 @@ Function2a3c:: ; 2a3c call GetBlockLocation ld a, [hl] and a - jr z, .asm_2a63 + jr z, .nope ld l, a ld h, $0 - add hl, hl - add hl, hl + add_n_times hl, hl, 2 ld a, [TilesetCollisionAddress] ld c, a ld a, [TilesetCollisionAddress + 1] ld b, a add hl, bc rr d - jr nc, .asm_2a56 + jr nc, .nocarry inc hl -.asm_2a56 +.nocarry rr e - jr nc, .asm_2a5c + jr nc, .nocarry2 inc hl inc hl -.asm_2a5c +.nocarry2 ld a, [TilesetCollisionBank] call GetFarByte ret -.asm_2a63 - ld a, $ff +.nope + ld a, -1 ret ; 2a66 @@ -1775,20 +1781,20 @@ GetBlockLocation:: ; 2a66 add hl, bc ld a, e srl a - jr z, .asm_2a84 + jr z, .nope and a -.asm_2a78 +.loop srl a - jr nc, .asm_2a7d + jr nc, .ok add hl, bc -.asm_2a7d +.ok sla c rl b and a - jr nz, .asm_2a78 + jr nz, .loop -.asm_2a84 +.nope ld c, d srl c ld b, $0 @@ -1799,128 +1805,138 @@ GetBlockLocation:: ; 2a66 CheckFacingSign:: ; 2a8b call GetFacingTileCoord +; Load facing into b. ld b, a +; Convert the coordinates at de to within-boundaries coordinates. ld a, d sub 4 ld d, a ld a, e sub 4 ld e, a - ld a, [wdc01] +; If there are no signposts, we don't need to be here. + ld a, [wCurrentMapSignpostCount] and a ret z ld c, a ld a, [hROMBank] push af - call Function2c52 - call Function2aaa + call SwitchToMapScriptHeaderBank + call CheckIfFacingTileCoordIsSign pop hl ld a, h rst Bankswitch ret ; 2aaa -Function2aaa:: ; 2aaa +CheckIfFacingTileCoordIsSign:: ; 2aaa +; Checks to see if you are facing a signpost. If so, copies it into EngineBuffer1 and sets carry. ld hl, wdc02 ld a, [hli] ld h, [hl] ld l, a -.asm_2ab0 +.loop push hl ld a, [hli] cp e - jr nz, .asm_2abb + jr nz, .next ld a, [hli] cp d - jr nz, .asm_2abb - jr .asm_2ac8 + jr nz, .next + jr .copysign -.asm_2abb +.next pop hl - ld a, 5 + ld a, 5 ; signpost event length add l ld l, a - jr nc, .asm_2ac3 + jr nc, .nocarry inc h -.asm_2ac3 +.nocarry dec c - jr nz, .asm_2ab0 + jr nz, .loop xor a ret -.asm_2ac8 +.copysign pop hl ld de, EngineBuffer1 - ld bc, 5 + ld bc, 5 ; signpost event length call CopyBytes scf ret ; 2ad4 -Function2ad4:: ; 2ad4 - ld a, [wdbfe] +CheckCurrentMapXYTriggers:: ; 2ad4 +; If there are no xy triggers, we don't need to be here. + ld a, [wCurrentMapXYTriggerCount] and a ret z +; Copy the trigger count into c. ld c, a ld a, [hROMBank] push af - call Function2c52 - call Function2ae7 + call SwitchToMapScriptHeaderBank + call CheckStandingOnXYTrigger pop hl ld a, h rst Bankswitch ret ; 2ae7 -Function2ae7:: ; 2ae7 +CheckStandingOnXYTrigger:: ; 2ae7 +; Checks to see if you are standing on an xy-trigger. If yes, copies the trigger to EngineBuffer1 and sets carry. ld hl, wdbff ld a, [hli] ld h, [hl] ld l, a +; Load the active trigger ID into b call CheckTriggers ld b, a +; Load your current coordinates into de. This will be used to check if your position is in the xy-trigger table for the current map. ld a, [MapX] - sub $4 + sub 4 ld d, a ld a, [MapY] - sub $4 + sub 4 ld e, a -.asm_2afd + +.loop push hl ld a, [hli] cp b - jr z, .asm_2b06 - cp $ff - jr nz, .asm_2b10 + jr z, .got_id + cp -1 + jr nz, .next -.asm_2b06 +.got_id ld a, [hli] cp e - jr nz, .asm_2b10 + jr nz, .next ld a, [hli] cp d - jr nz, .asm_2b10 - jr .asm_2b1d + jr nz, .next + jr .copytrigger -.asm_2b10 +.next pop hl - ld a, $8 + ld a, $8 ; xy-trigger size add l ld l, a - jr nc, .asm_2b18 + jr nc, .nocarry inc h -.asm_2b18 +.nocarry dec c - jr nz, .asm_2afd + jr nz, .loop xor a ret -.asm_2b1d +.copytrigger pop hl ld de, EngineBuffer1 - ld bc, $0008 + ld bc, $0008 ; xy-trigger size call CopyBytes scf ret @@ -2139,7 +2155,7 @@ Function2c3d:: ; 2c3d ret ; 2c52 -Function2c52:: ; 2c52 +SwitchToMapScriptHeaderBank:: ; 2c52 ld a, [MapScriptHeaderBank] rst Bankswitch ret -- cgit v1.2.3 From e674869018ffe8f9be2351b2b569eb7300910e6a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 18 Jul 2015 15:46:38 -0400 Subject: Updated signpost items and person_event flags --- home/map_objects.asm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'home') diff --git a/home/map_objects.asm b/home/map_objects.asm index 509492033..2874cbdf3 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -22,7 +22,7 @@ Function180e:: ; 180e ld c, SPRITE_GFX_LIST_CAPACITY - 1 ld b, a ld a, [hConnectionStripLength] - cp $0 + cp 0 jr z, .nope ld a, b .loop @@ -235,7 +235,7 @@ Function18de:: ; 18de ; Sets carry if the object is not visible on the screen. ld [hConnectionStripLength], a call GetMapObject - ld hl, MAPOBJECT_VRAM_ID + ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] cp MAPOBJECT_NOT_VISIBLE @@ -327,25 +327,25 @@ Function18f5:: ; 18f5 Function194d:: ; 194d ld [hConnectionStripLength], a call GetMapObject - call Function80e7 + call CopyObjectStruct ret ; 1956 -Function1956:: ; 1956 +_CopyObjectStruct:: ; 1956 ld [hConnectionStripLength], a call Function271e ld a, [hConnectionStripLength] call GetMapObject - callba Function80e7 + callba CopyObjectStruct ret ; 1967 Function1967:: ; 1967 ld [hConnectionStripLength], a call GetMapObject - ld hl, MAPOBJECT_VRAM_ID + ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] cp MAPOBJECT_NOT_VISIBLE @@ -375,7 +375,7 @@ Function1985:: ; 1985 ret ; 199f -Function199f:: ; 199f +DeleteObjectStruct:: ; 199f call Function1967 call Function2712 ret @@ -397,7 +397,7 @@ Function19a6:: ; 19a6 Function19b8:: ; 19b8 call GetMapObject - ld hl, MAPOBJECT_VRAM_ID + ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] push af @@ -620,7 +620,7 @@ DrawOnMap:: ; 1ad2 bit 0, a ret z callba Function55e0 - callba Function5920 + callba RefreshMapAppearDisappear ret ; 1ae5 -- cgit v1.2.3 From 60cd04b02300c288a01a2f78a44cb39cbe6861d1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 18 Jul 2015 23:45:39 -0400 Subject: Trainer data structure and field move functions Trainer data in map scripts is now a macro-defined structure. Field move functions in main.asm are now nearly completely annotated, with local references. Trailing white space deleted. --- home/map.asm | 6 +++--- home/menu.asm | 16 ++++++++-------- home/vblank.asm | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index 78ec839c5..8cd185b61 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1774,9 +1774,9 @@ Function2a3c:: ; 2a3c GetBlockLocation:: ; 2a66 ld a, [MapWidth] - add $6 + add 6 ld c, a - ld b, $0 + ld b, 0 ld hl, wc801 add hl, bc ld a, e @@ -1797,7 +1797,7 @@ GetBlockLocation:: ; 2a66 .nope ld c, d srl c - ld b, $0 + ld b, 0 add hl, bc ret ; 2a8b diff --git a/home/menu.asm b/home/menu.asm index 3c28b95e5..995d7c454 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -21,9 +21,9 @@ Function1d4b:: ; 1d4b ; 1d4f -Function1d4f:: ; 1d4f +MenuTextBox:: ; 1d4f push hl - call Function1d58 + call LoadMenuTextBox pop hl jp PrintText ; 1d57 @@ -32,7 +32,7 @@ Function1d57:: ; 1d57 ret ; 1d58 -Function1d58:: ; 1d58 +LoadMenuTextBox:: ; 1d58 ld hl, MenuDataHeader_0x1d5f call LoadMenuDataHeader ret @@ -46,8 +46,8 @@ MenuDataHeader_0x1d5f:: ; 1d5f db 0 ; default option ; 1d67 -Function1d67:: ; 1d67 - call Function1d4f +MenuTextBoxBackup:: ; 1d67 + call MenuTextBox call WriteBackup ret ; 1d6e @@ -252,7 +252,7 @@ MenuFunc_1e7f:: ; 0x1e7f MenuWriteText:: ; 0x1e8c xor a ld [hBGMapMode], a - call Function1ebd ; sort out the text + call Function1ebd ; sort out the text call Function1eda ; actually write it call Function2e31 ld a, [hOAMUpdate] @@ -530,7 +530,7 @@ Function1ff8:: ; 1ff8 ; 2009 -PlayClickSFX:: ; 2009 +PlayClickSFX:: ; 2009 push de ld de, SFX_READ_TEXT_2 call PlaySFX @@ -539,7 +539,7 @@ PlayClickSFX:: ; 2009 ; 0x2012 Function2012:: ; 2012 - call Function1d4f + call MenuTextBox call CloseText call Function1c07 ret diff --git a/home/vblank.asm b/home/vblank.asm index 563e705fe..501da9382 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -363,7 +363,7 @@ VBlank5:: ; 400 ; bg map ; tiles ; joypad -; +; ld a, [hROMBank] ld [hROMBankBackup], a -- cgit v1.2.3 From 94129b6b451fc7770ea75ffbdcbaab4967f513bd Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 19 Jul 2015 04:58:31 -0400 Subject: Finished the decoration attributes table Interpretation of the Decoration Attributes table is complete. Other changes include some more event flag and function naming, as well as a minor tweak to the person_events of every map. --- home/map_objects.asm | 12 ++++++------ home/menu.asm | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'home') diff --git a/home/map_objects.asm b/home/map_objects.asm index 2874cbdf3..ee13390ad 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -238,7 +238,7 @@ Function18de:: ; 18de ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] - cp MAPOBJECT_NOT_VISIBLE + cp -1 jr z, .not_visible ld [hConnectedMapWidth], a call GetObjectStruct @@ -348,9 +348,9 @@ Function1967:: ; 1967 ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld a, [hl] - cp MAPOBJECT_NOT_VISIBLE + cp -1 ret z - ld [hl], MAPOBJECT_NOT_VISIBLE + ld [hl], -1 push af call Function1985 pop af @@ -386,7 +386,7 @@ Function19a6:: ; 19a6 call GetMapObject ld d, b ld e, c - ld a, MAPOBJECT_NOT_VISIBLE + ld a, -1 ld [de], a inc de pop hl @@ -401,13 +401,13 @@ Function19b8:: ; 19b8 add hl, bc ld a, [hl] push af - ld [hl], MAPOBJECT_NOT_VISIBLE + ld [hl], -1 inc hl ld bc, OBJECT_LENGTH - 1 xor a call ByteFill pop af - cp MAPOBJECT_NOT_VISIBLE + cp -1 ret z cp $d ret nc diff --git a/home/menu.asm b/home/menu.asm index 995d7c454..e9b8abeac 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -95,7 +95,7 @@ InterpretMenu2:: ; 0x1d81 ret ; 0x1dab -Function1dab:: ; 1dab +GetMenu2:: ; 1dab call LoadMenuDataHeader call InterpretMenu2 call WriteBackup -- cgit v1.2.3 From bef792f2d21ccac0127aeffd9e0838aba81f44b6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 20 Jul 2015 03:51:52 -0400 Subject: More label updates, moved predefs to new file Also named most of the engine and event flag constants. --- home/audio.asm | 2 +- home/fade.asm | 2 +- home/map.asm | 55 +++++++++++++++++++++++++++---------------------------- home/menu.asm | 4 ++-- home/movement.asm | 4 ++-- home/window.asm | 2 +- 6 files changed, 34 insertions(+), 35 deletions(-) (limited to 'home') diff --git a/home/audio.asm b/home/audio.asm index 331999e78..859ace116 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -321,7 +321,7 @@ Function3ca8:: ; 3ca8 ret ; 3cae -Function3cae:: ; 3cae +CrankUpTheVolume:: ; 3cae ld a, 4 | 1 << 7 ld [MusicFade], a ret diff --git a/home/fade.asm b/home/fade.asm index 2c8bc3baa..2559a0eb7 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -36,7 +36,7 @@ Function4a3:: ; 4a3 jr FadeOut ; 4b6 -Function4b6:: ; 4b6 +FadeToWhite:: ; 4b6 ld a, [hCGB] and a jr z, .asm_4c2 diff --git a/home/map.asm b/home/map.asm index 8cd185b61..beefb2c3f 100644 --- a/home/map.asm +++ b/home/map.asm @@ -150,9 +150,7 @@ Function2198:: ; 2198 add a ld l, a ld h, 0 - add hl, hl - add hl, hl - add hl, hl + add_n_times hl, hl, 3 ld a, [TilesetBlocksAddress] add l ld l, a @@ -387,7 +385,7 @@ Function2300:: ; 2300 ; 2309 -Function2309:: ; 2309 +LoadMapAttributes:: ; 2309 call Function2326 call SwitchToMapScriptHeaderBank call Function234f @@ -396,7 +394,7 @@ Function2309:: ; 2309 ret ; 2317 -Function2317:: ; 2317 +LoadMapAttributes_IgnoreHidden:: ; 2317 call Function2326 call SwitchToMapScriptHeaderBank call Function234f @@ -664,7 +662,7 @@ Function2471:: ; 2471 ret ; 248a -Function248a:: ; 248a +RestoreFacingAfterWarp:: ; 248a call GetMapScriptHeaderBank rst Bankswitch @@ -691,7 +689,7 @@ Function248a:: ; 248a call Function24ba .asm_24b3 - callba Function10486d + callba GetCoordOfUpperLeftCorner ret ; 24ba @@ -705,7 +703,7 @@ Function24ba:: ; 24ba ret ; 24cd -Function24cd:: ; 24cd +LoadBlockData:: ; 24cd ld hl, OverworldMap ld bc, OverworldMapEnd - OverworldMap ld a, 0 @@ -713,7 +711,7 @@ Function24cd:: ; 24cd call ChangeMap call FillMapConnections ld a, $1 - call Function263b + call RunMapCallback ret ; 24e4 @@ -976,7 +974,8 @@ Function2631:: ; 2631 jr CallScript ; 263b -Function263b:: ; 263b +RunMapCallback:: ; 263b +; Will run the first callback found in the map header with execution index equal to a. ld b, a ld a, [hROMBank] push af @@ -988,7 +987,7 @@ Function263b:: ; 263b ld b, a ld d, h ld e, l - call Function2674 + call ExecuteCallbackScript .done pop af @@ -1007,18 +1006,18 @@ Function2653:: ; 2653 ld l, a or h ret z - ld de, $0003 -.asm_2664 + ld de, 3 +.loop ld a, [hl] cp b - jr z, .asm_266e + jr z, .done add hl, de dec c - jr nz, .asm_2664 + jr nz, .loop xor a ret -.asm_266e +.done inc hl ld a, [hli] ld h, [hl] @@ -1027,7 +1026,7 @@ Function2653:: ; 2653 ret ; 2674 -Function2674:: ; 2674 +ExecuteCallbackScript:: ; 2674 callba Function974f3 ld a, [ScriptMode] push af @@ -1449,7 +1448,7 @@ BufferScreen:: ; 2879 ret ; 289d -Function289d:: ; 289d +SaveScreen:: ; 289d ld hl, wd194 ld a, [hli] ld h, [hl] @@ -1499,7 +1498,7 @@ Function289d:: ; 289d jr Function28f7 -Function28e3:: ; 28e3 +LoadNeighboringBlockData:: ; 28e3 ld hl, wd194 ld a, [hli] ld h, [hl] @@ -1947,7 +1946,7 @@ FadeToMenu:: ; 2b29 xor a ld [hBGMapMode], a call Function1d6e - callba Function8c084 + callba FadeBlackBGMap call ClearSprites call Function2ed3 ret @@ -1976,7 +1975,7 @@ Function2b5c:: ; 2b5c call GetSGBLayout callba Function49409 call Function3200 - callba Function8c079 + callba FadeInBGMap call Function2ee4 ret ; 2b74 @@ -2308,23 +2307,23 @@ RADIO_TOWER_MUSIC EQU 7 jr .done ; 2cff -Function2cff:: ; 2cff - call Function2d0d +GetMapHeaderTimeOfDayNybble:: ; 2cff + call GetPhoneServiceTimeOfDayByte and $f ret ; 2d05 -Function2d05:: ; 2d05 - call Function2d0d +GetMapHeaderPhoneServiceNybble:: ; 2d05 + call GetPhoneServiceTimeOfDayByte and $f0 swap a ret ; 2d0d -Function2d0d:: ; 2d0d +GetPhoneServiceTimeOfDayByte:: ; 2d0d push hl push bc - ld de, $0007 + ld de, 7 ; phone service and time of day call GetMapHeaderMember ld a, c pop bc @@ -2336,7 +2335,7 @@ Function2d19:: ; 2d19 push de push hl push bc - ld de, $0008 + ld de, 8 ; fishing group call GetMapHeaderMember ld a, c pop bc diff --git a/home/menu.asm b/home/menu.asm index e9b8abeac..26d47490b 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -67,7 +67,7 @@ MenuDataHeader_0x1d75:: ; 1d75 ; 1d7d Function1d7d:: ; 1d7d - call Function1c07 + call ExitMenu ret ; 1d81 @@ -541,7 +541,7 @@ PlayClickSFX:: ; 2009 Function2012:: ; 2012 call MenuTextBox call CloseText - call Function1c07 + call ExitMenu ret ; 201c diff --git a/home/movement.asm b/home/movement.asm index 0cbb14f5d..eb59c0525 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -193,7 +193,7 @@ Function1c00:: ; 1c00 ret ; 1c07 -Function1c07:: ; 0x1c07 +ExitMenu:: ; 0x1c07 push af callab Function243e8 pop af @@ -205,7 +205,7 @@ Function1c10:: ; 0x1c10 WriteBackup:: ; 0x1c17 push af - call Function1c07 + call ExitMenu call Function321c call DrawOnMap pop af diff --git a/home/window.asm b/home/window.asm index 31e299827..e0be7f83d 100644 --- a/home/window.asm +++ b/home/window.asm @@ -41,7 +41,7 @@ Function2de2:: ; 2de2 ld a, $90 ld [hWY], a call Functione4a - callba Functionb8000 + callba ReturnFromMapSetupScript callba Function106594 ret ; 2e08 -- cgit v1.2.3 From d9300a9becc9aa699b7191f87d8b493a93139ba2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 20 Jul 2015 11:28:05 -0400 Subject: Fix unnecessary white space and retire add_n_times --- home/map.asm | 12 +++++++++--- home/map_objects.asm | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index beefb2c3f..01c3b5824 100644 --- a/home/map.asm +++ b/home/map.asm @@ -150,7 +150,9 @@ Function2198:: ; 2198 add a ld l, a ld h, 0 - add_n_times hl, hl, 3 +rept 3 + add hl,hl +endr ld a, [TilesetBlocksAddress] add l ld l, a @@ -1703,7 +1705,9 @@ GetFacingTileCoord:: ; 2a07 srl a ld l, a ld h, 0 - add_n_times hl, hl, 2 +rept 2 + add hl,hl +endr ld de, .Directions add hl, de @@ -1745,7 +1749,9 @@ Function2a3c:: ; 2a3c jr z, .nope ld l, a ld h, $0 - add_n_times hl, hl, 2 +rept 2 + add hl,hl +endr ld a, [TilesetCollisionAddress] ld c, a ld a, [TilesetCollisionAddress + 1] diff --git a/home/map_objects.asm b/home/map_objects.asm index ee13390ad..7c686e122 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -493,7 +493,9 @@ Function1a2f:: ; 1a2f ld hl, ObjectStruct3_Data ld e, a ld d, 0 - add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH +rept OBJECT_STRUCT_3_DATA_WIDTH + add hl,de +endr ld a, [hl] ret ; 1a47 @@ -504,7 +506,9 @@ Function1a47:: ; 1a47 ld e, a ld d, 0 ld hl, ObjectStruct3_Data + 1 - add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH +rept OBJECT_STRUCT_3_DATA_WIDTH + add hl,de +endr ld a, BANK(ObjectStruct3_Data) call GetFarByte add a @@ -542,7 +546,9 @@ Function1a71:: ; 1a71 ld e, a ld d, 0 ld hl, ObjectStruct3_Data + 1 - add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH +rept OBJECT_STRUCT_3_DATA_WIDTH + add hl,de +endr ld b, h ld c, l pop de -- cgit v1.2.3 From 06673cbee76630f4049da1ce763d27d4eb967432 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 20 Jul 2015 18:59:26 -0400 Subject: Named more specials, fixed a missing EOL --- home/copy.asm | 2 +- home/flag.asm | 8 ++++---- home/map.asm | 2 +- home/palettes.asm | 2 +- home/window.asm | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'home') diff --git a/home/copy.asm b/home/copy.asm index e49094554..d0bc1983f 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -105,7 +105,7 @@ Functiondfd:: ; dfd -Functione4a:: ; e4a +Special_ReplaceKrisSprite:: ; e4a callba Function14135 ret ; e51 diff --git a/home/flag.asm b/home/flag.asm index 479a51c33..389dd4910 100644 --- a/home/flag.asm +++ b/home/flag.asm @@ -1,11 +1,11 @@ -Function2e50:: ; 2e50 +ResetMapBufferEventFlags:: ; 2e50 xor a ld hl, EventFlags ld [hli], a ret ; 2e56 -Function2e56:: ; 2e56 +ResetBikeFlags:: ; 2e56 xor a ld hl, BikeFlags ld [hli], a @@ -13,8 +13,8 @@ Function2e56:: ; 2e56 ret ; 2e5d -Function2e5d:: ; 2e5d - ld a, [wd19a] +ResetFlashIfOutOfCave:: ; 2e5d + ld a, [wRoofPalette] cp $2 jr z, .asm_2e69 cp $1 diff --git a/home/map.asm b/home/map.asm index 01c3b5824..b93435517 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1,6 +1,6 @@ ; Functions dealing with rendering and interacting with maps. -Function210f:: ; 210f +Clearwc7e8:: ; 210f ld hl, wc7e8 ld bc, $0018 ld a, $0 diff --git a/home/palettes.asm b/home/palettes.asm index 38f1d554d..1a24fbe89 100644 --- a/home/palettes.asm +++ b/home/palettes.asm @@ -302,7 +302,7 @@ Functiond90:: ; d90 ; d91 -Functiond91:: ; d91 +Special_ReloadSpritesNoPalettes:: ; d91 ld a, [hCGB] and a ret z diff --git a/home/window.asm b/home/window.asm index e0be7f83d..850b7466e 100644 --- a/home/window.asm +++ b/home/window.asm @@ -40,7 +40,7 @@ Function2de2:: ; 2de2 call Function2e31 ld a, $90 ld [hWY], a - call Functione4a + call Special_ReplaceKrisSprite callba ReturnFromMapSetupScript callba Function106594 ret -- cgit v1.2.3 From 471492b775fc2a0f5162f3d1c13c5472359beb14 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 20 Jul 2015 22:18:18 -0400 Subject: Reverted ld_hl_pointer macro --- home/audio.asm | 7 ++----- home/battle.asm | 6 ++++-- home/copy.asm | 7 ++++--- home/cry.asm | 7 ++----- home/joypad.asm | 13 ++++++------- home/map.asm | 23 ++++++++++++++--------- home/map_objects.asm | 6 ++++-- home/menu.asm | 17 ++++++++++------- home/movement.asm | 10 ++++++---- home/text.asm | 24 ++++++++++++++++-------- home/tilemap.asm | 12 ++++++++---- home/vblank.asm | 3 ++- home/video.asm | 3 ++- 13 files changed, 80 insertions(+), 58 deletions(-) (limited to 'home') diff --git a/home/audio.asm b/home/audio.asm index 859ace116..610117715 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -158,12 +158,9 @@ PlayCryHeader:: ; 3be3 ld [MBC3RomBank], a ld hl, CryHeaders +rept 6 add hl, de - add hl, de - add hl, de - add hl, de - add hl, de - add hl, de +endr ld e, [hl] inc hl diff --git a/home/battle.asm b/home/battle.asm index fa72d75a0..832792d88 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -153,8 +153,9 @@ GetBattleVarAddr:: ; 39e7 ld hl, .battlevarpairs ld c, a ld b, 0 +rept 2 add hl, bc - add hl, bc +endr ld a, [hli] ld h, [hl] @@ -174,8 +175,9 @@ GetBattleVarAddr:: ; 39e7 ld b, 0 ld hl, .vars +rept 2 add hl, bc - add hl, bc +endr ld a, [hli] ld h, [hl] diff --git a/home/copy.asm b/home/copy.asm index d0bc1983f..f18b12802 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -195,8 +195,9 @@ FarCopyBytesDouble:: ; e9b .loop ld a, [de] inc de +rept 2 ld [hli], a - ld [hli], a +endr .dec dec c jr nz, .loop @@ -406,9 +407,9 @@ Copy1bpp:: ; fa4 push af ld h, 0 ld l, c +rept 3 add hl, hl - add hl, hl - add hl, hl +endr ld b, h ld c, l pop af diff --git a/home/cry.asm b/home/cry.asm index 456037db4..ac9ac8029 100644 --- a/home/cry.asm +++ b/home/cry.asm @@ -66,12 +66,9 @@ LoadCryHeader:: ; 37f3 rst Bankswitch ld hl, CryHeaders +rept 6 add hl, bc - add hl, bc - add hl, bc - add hl, bc - add hl, bc - add hl, bc +endr ld e, [hl] inc hl diff --git a/home/joypad.asm b/home/joypad.asm index 42a61cd5d..78a1ac143 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -42,8 +42,9 @@ Joypad:: ; 935 ld a, D_PAD ld [rJOYP], a ; Read twice to give the request time to take. +rept 2 ld a, [rJOYP] - ld a, [rJOYP] +endr ; The Joypad register output is in the lo nybble (inversed). ; We make the hi nybble of our new container d-pad input. @@ -59,12 +60,9 @@ Joypad:: ; 935 ld a, BUTTONS ld [rJOYP], a ; Wait for input to stabilize. +rept 6 ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] - ld a, [rJOYP] +endr ; Buttons take the lo nybble. cpl and $f @@ -211,8 +209,9 @@ GetJoypad:: ; 984 jr nz, .next ; The current input is overwritten. +rept 2 dec hl - dec hl +endr ld b, NO_INPUT jr .finishauto diff --git a/home/map.asm b/home/map.asm index b93435517..2954c7d41 100644 --- a/home/map.asm +++ b/home/map.asm @@ -303,8 +303,9 @@ Function2266:: ; 2266 ; 22a3 Function22a3:: ; 22a3 +rept 2 inc hl - inc hl +endr scf ret ; 22a7 @@ -420,8 +421,9 @@ Function2336:: ; 2336 ld a, [hli] ld h, [hl] ld l, a +rept 2 inc hl - inc hl +endr call Function23da call Function23f1 call Function2408 @@ -672,9 +674,9 @@ RestoreFacingAfterWarp:: ; 248a ld a, [hli] ld h, [hl] ld l, a +rept 3 inc hl - inc hl - inc hl +endr ld a, [WarpNumber] dec a ld c, a @@ -730,9 +732,9 @@ ChangeMap:: ; 24e4 ld [hConnectionStripLength], a ld c, a ld b, 0 +rept 3 add hl, bc - add hl, bc - add hl, bc +endr ld c, 3 add hl, bc ld a, [MapBlockDataBank] @@ -1324,8 +1326,9 @@ Function27d3:: ; 27d3 ld a, d ld [hli], a ld a, e +rept 2 inc a - inc a +endr and $1f ld b, a ld a, e @@ -1764,8 +1767,9 @@ endr .nocarry rr e jr nc, .nocarry2 +rept 2 inc hl - inc hl +endr .nocarry2 ld a, [TilesetCollisionBank] @@ -2062,8 +2066,9 @@ GetAnyMapHeaderPointer:: ; 0x2bed ld c, b ld b, 0 ld hl, MapGroupPointers +rept 2 add hl, bc - add hl, bc +endr ld a, [hli] ld h, [hl] diff --git a/home/map_objects.asm b/home/map_objects.asm index 7c686e122..2b7bd9a92 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -28,8 +28,9 @@ Function180e:: ; 180e .loop cp [hl] jr z, .found +rept 2 inc hl - inc hl +endr dec c jr nz, .loop ld a, [UsedSprites + 1] @@ -511,8 +512,9 @@ rept OBJECT_STRUCT_3_DATA_WIDTH endr ld a, BANK(ObjectStruct3_Data) call GetFarByte +rept 2 add a - add a +endr and $c pop de pop bc diff --git a/home/menu.asm b/home/menu.asm index 26d47490b..2b9885834 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -111,8 +111,9 @@ Function1db8:: ; 0x1db8 ld a, [hli] ld h, [hl] ld l, a +rept 2 inc hl - inc hl +endr pop af call GetNthString ld d, h @@ -439,8 +440,9 @@ Function1f8d:: ; 1f8d push de ld a, [MenuSelection] call Function1fb1 +rept 2 inc hl - inc hl +endr ld a, [hli] ld d, [hl] ld e, a @@ -451,8 +453,9 @@ Function1f8d:: ; 1f8d Function1f9e:: ; 1f9e call Function1fb1 +rept 2 inc hl - inc hl +endr ld a, [hli] ld d, [hl] ld e, a @@ -475,10 +478,9 @@ Function1fb1:: ; 1fb1 ld a, [hli] ld h, [hl] ld l, a +rept 4 add hl, de - add hl, de - add hl, de - add hl, de +endr ret ; 1fbf @@ -497,8 +499,9 @@ Function1fbf:: ; 1fbf ld [rSVBK], a xor a ld hl, $dfff +rept 2 ld [hld], a - ld [hld], a +endr ld a, l ld [wcf71], a ld a, h diff --git a/home/movement.asm b/home/movement.asm index eb59c0525..e6e2e1025 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -102,8 +102,9 @@ Function1b92:: ; 1b92 push hl ld l, b ld h, 0 +rept 2 add hl, hl - add hl, hl +endr ld e, a ld d, 0 add hl, de @@ -131,12 +132,13 @@ Function1bb1:: ; 1bb1 dec b jr nz, .asm_1bb8 ld a, $1 +rept 2 ld [hli], a - ld [hli], a +endr xor a +rept 3 ld [hli], a - ld [hli], a - ld [hli], a +endr pop bc pop hl ret diff --git a/home/text.asm b/home/text.asm index 4cb581bcb..98ca87051 100644 --- a/home/text.asm +++ b/home/text.asm @@ -126,10 +126,12 @@ TextBoxPalette:: ; 1024 ; Fill text box width c height b at hl with pal 7 ld de, AttrMap - TileMap add hl, de +rept 2 inc b - inc b - inc c +endr +rept 2 inc c +endr ld a, TEXTBOX_PAL .col push bc @@ -626,10 +628,12 @@ Function138c:: ; 138c inc de dec c jr nz, .row +rept 2 inc de - inc de - inc hl +endr +rept 2 inc hl +endr pop af dec a jr nz, .col @@ -719,8 +723,9 @@ Function13f6:: ; 13f6 ld c, a ld b, 0 ld hl, TextCommands +rept 2 add hl, bc - add hl, bc +endr ld e, [hl] inc hl ld d, [hl] @@ -992,8 +997,9 @@ Text_PlaySound:: ; 1500 jr z, .done cp b jr z, .play +rept 2 inc hl - inc hl +endr jr .loop .play @@ -1088,8 +1094,9 @@ Text_14:: ; 156a ld e, a ld d, 0 ld hl, Unknown_24000 +rept 2 add hl, de - add hl, de +endr ld a, BANK(Unknown_24000) call GetFarHalfword ld d, h @@ -1110,8 +1117,9 @@ Text_15:: ; 1582 ld c, a ld b, 0 ld hl, .Days +rept 2 add hl, bc - add hl, bc +endr ld a, [hli] ld h, [hl] ld l, a diff --git a/home/tilemap.asm b/home/tilemap.asm index ceda55dd2..c9eaaba67 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -175,11 +175,13 @@ GetTileCoord:: ; 1d05 ld a, c ld b, h ld c, l +rept 2 add hl, hl - add hl, hl +endr add hl, bc +rept 2 add hl, hl - add hl, hl +endr ld c, a xor a ld b, a @@ -203,11 +205,13 @@ GetAttrCoord:: ; 1d21 ld a, c ld b, h ld c, l +rept 2 add hl, hl - add hl, hl +endr add hl, bc +rept 2 add hl, hl - add hl, hl +endr ld c, a xor a ld b, a diff --git a/home/vblank.asm b/home/vblank.asm index 501da9382..b8b8b0efb 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -19,8 +19,9 @@ VBlank:: ; 283 ld e, a ld d, 0 ld hl, .VBlanks +rept 2 add hl, de - add hl, de +endr ld a, [hli] ld h, [hl] ld l, a diff --git a/home/video.asm b/home/video.asm index 7392d6e0f..440c90307 100644 --- a/home/video.asm +++ b/home/video.asm @@ -77,8 +77,9 @@ endr ; We've done 2 16x8 blocks ld a, [$ffdc] +rept 2 dec a - dec a +endr ld [$ffdc], a jr nz, .next -- cgit v1.2.3 From 5631bdc0d7f90d5036b71489883d787715983d41 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 21 Jul 2015 00:02:21 -0400 Subject: Added labels to different parts of the map script and event headers --- home/flag.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/flag.asm b/home/flag.asm index 389dd4910..b4dff4531 100644 --- a/home/flag.asm +++ b/home/flag.asm @@ -14,7 +14,7 @@ ResetBikeFlags:: ; 2e56 ; 2e5d ResetFlashIfOutOfCave:: ; 2e5d - ld a, [wRoofPalette] + ld a, [wPermission] cp $2 jr z, .asm_2e69 cp $1 -- cgit v1.2.3 From d5ddd9e54ec2422d6f1cd7c561c1750512d0a81d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 21 Jul 2015 01:52:46 -0400 Subject: Move radio code to its own file --- home/audio.asm | 2 +- home/battle.asm | 4 ++-- home/copy.asm | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'home') diff --git a/home/audio.asm b/home/audio.asm index 610117715..3e22a1540 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -420,7 +420,7 @@ EnterMapMusic:: ; 3d03 ret ; 3d2f -Function3d2f:: ; 3d2f +TryRestartMapMusic:: ; 3d2f ld a, [wc2c1] and a jr z, RestartMapMusic diff --git a/home/battle.asm b/home/battle.asm index 832792d88..9b89e673c 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -91,7 +91,7 @@ UpdateBattleMonInParty:: ; 399c ld a, [CurBattleMon] -Function399f:: ; 399f +UpdateBattleMon:: ; 399f ld hl, PartyMon1Level call GetPartyLocation @@ -262,7 +262,7 @@ endr ; 3a90 -Function3a90:: ; 3a90 +FarJumpText:: ; 3a90 inc hl ld a, [hROMBank] push af diff --git a/home/copy.asm b/home/copy.asm index f18b12802..3cc64f091 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -56,7 +56,7 @@ Functiondfd:: ; dfd ld a, b rst Bankswitch -.asm_e09 +.loop ld a, d ld [rHDMA1], a ld a, e @@ -70,27 +70,27 @@ Functiondfd:: ; dfd ld [rHDMA4], a ld a, c cp $8 - jr c, .asm_e3c + jr c, .done sub $8 ld c, a ld a, $f ld [hDMATransfer], a call DelayFrame ld a, l - add $0 + add 0 ld l, a ld a, h - adc $1 + adc 1 ld h, a ld a, e - add $0 + add 0 ld e, a ld a, d - adc $1 + adc 1 ld d, a - jr .asm_e09 + jr .loop -.asm_e3c +.done ld a, c and $7f ld [hDMATransfer], a -- cgit v1.2.3