From a9149c6cc3be2a1cab6a374b2c10f359ce5f29f5 Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sat, 16 Jun 2018 18:27:10 -0600 Subject: work on talk_to_npc done, naming of some overworld logic and wram values. --- home/map.asm | 10 +- home/map_objects.asm | 14 +-- home/talk_to_npc.asm | 260 ++++++++++++++++++++++++++++++++++++++++++++------ home/unknown_388f.asm | 14 +-- home/util.asm | 5 +- home/window.asm | 2 +- 6 files changed, 254 insertions(+), 51 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index aac770c..1f7c27d 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1593,7 +1593,7 @@ Function2a8d:: ; 00:2a8d dbbw $05, $33, Function14777 Function2ae5:: -.asm_2ae5: ; 00:2ae5 +.loop: ; 00:2ae5 ld hl, wJoypadFlags set 4, [hl] set 6, [hl] @@ -1608,7 +1608,7 @@ Function2ae5:: bit 7, [hl] res 7, [hl] ret nz - call Function38e3 + call TestWildBattleStart ret nz call OverworldStartButtonCheck ret nz @@ -1619,16 +1619,16 @@ Function2ae5:: and a ret nz call Function2c4a - jr nc, .asm_2ae5 + jr nc, .loop callba Function824c ld a, [wc5ed] bit 6, a - jr nz, .asm_2ae5 + jr nz, .loop call CheckMovingOffEdgeOfMap ret c call WarpCheck ret c - jr .asm_2ae5 + jr .loop Function2b39:: ld hl, wJoypadFlags diff --git a/home/map_objects.asm b/home/map_objects.asm index 70cba50..ca7ca0b 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -315,6 +315,7 @@ UpdateSprites:: ; 00:17a8 ret GetObjectStruct:: ; 00:17bf +; Puts the start of the a'th object struct into bc ld bc, $28 ld hl, wObjectStructs call AddNTimes @@ -334,26 +335,27 @@ Function17cb:: call Bankswitch ret -Function17de:: +CheckNonTurningSprite:: ; 00:17de + ; sets carry flag if a is equal to any of the sprites below push hl push bc ld c, a ld b, $ff ld hl, .Data -.asm_17e6: ; 00:17e6 +.loop: ; 00:17e6 ld a, [hli] cp b - jr z, .asm_17ee + jr z, .escape ; if a == $FF, escape cp c - jr nz, .asm_17e6 + jr nz, .loop ; if a != c, loop scf -.asm_17ee: ; 00:17ee +.escape: ; 00:17ee pop bc pop hl ret .Data: ; 00:17f1 - db $51, $55, $56, $57, $58, $5a, $5b, $ff + db SPRITE_KABIGON, SPRITE_POKE_BALL, SPRITE_POKEDEX, SPRITE_PAPER, SPRITE_OLD_LINK_RECEPTIONIST, SPRITE_EGG, SPRITE_BOULDER, $ff Function17f9:: call GetMapObject diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 9ef5dd3..1820692 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -22,8 +22,8 @@ Function3036:: ; 3036 .Text: ; 00:303a db "@" -CallMapTextSubroutine:: - ld a, [wcdb0] +CallMapTextSubroutine:: ; 00:303b + ld a, [wTalkingTargetType] bit 0, a jr z, asm_3062 call Function3055 @@ -43,16 +43,16 @@ CallMapTextSubroutine:: Function3055:: ; 00:3055 ldh a, [hFFEA] ld b, a -.asm_3058: ; 00:3058 +.Loop: ; 00:3058 ld a, [hli] cp $ff ret z cp b - jp z, Function3240 - jr .asm_3058 + jp z, SetFFInAccumulator + jr .Loop asm_3062: ; 00:3062 - ld a, [wcdb0] + ld a, [wTalkingTargetType] bit 1, a ret z ld h, d @@ -71,28 +71,29 @@ asm_3062: ; 00:3062 jp hl Function307a:: ; 00:307a - ld hl, wcdb0 + ld hl, wTalkingTargetType res 0, [hl] res 1, [hl] - call Function3240 + call SetFFInAccumulator ret -Function3085:: ; 00:3085 +PrintTextboxDebugNumbers:: ; 00:3085 push hl push de push bc - ld de, $99 - ld a, [wcdb0] + ld de, $0099 ; default address to print from (not a sign or NPC) + ld a, [wTalkingTargetType] bit 0, a - jr z, .asm_3097 - ld de, hFFEA - jr .asm_309e + jr z, .CheckSign + ld de, hFFEA ; address if we're talking to an NPC + jr .PrintNum -.asm_3097: ; 00:3097 +.CheckSign: ; 00:3097 bit 1, a - jr z, .asm_309e - ld de, hFFEE -.asm_309e: ; 00:309e + jr z, .PrintNum + ld de, hFFEE ; address if we're talking to a sign + +.PrintNum: ; 00:309e hlcoord 4, 12 lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNumber @@ -105,17 +106,17 @@ Function3085:: ; 00:3085 pop hl ret -QueueMapTextSubroutine:: +QueueMapTextSubroutine:: ; 00:30b7 ldh a, [hJoyState] bit A_BUTTON_F, a - jp z, Function323e + jp z, ClearAccumulator ; if we didn't press a call GetFacingPersonText - jp nc, Function30e8 + jp nc, Function30e8 ; if not talking to a person ld d, $0 ld e, a ld a, [wce63] bit 1, a - call nz, Function3085 + call nz, PrintTextboxDebugNumbers ; if debug, print these ld hl, wMapTextPtr ld a, [hli] ld h, [hl] @@ -128,14 +129,14 @@ QueueMapTextSubroutine:: inc de ld a, [hl] ld [de], a - ld hl, wcdb0 - set 0, [hl] - call Function3240 + ld hl, wTalkingTargetType + set 0, [hl] ; we're talking to an NPC + call SetFFInAccumulator ret Function30e8:: ; 00:30e8 call GetFacingSignpost - jp nc, Function323e + jp nc, ClearAccumulator ; if not facing person or sign ld a, e ldh [hFFEB], a ld a, d @@ -144,14 +145,213 @@ Function30e8:: ; 00:30e8 ldh [hFFED], a ld a, [hl] ldh [hFFEE], a - ld hl, wcdb0 - set 1, [hl] - call Function3240 + ld hl, wTalkingTargetType + set 1, [hl] ; we're talking to a sign + call SetFFInAccumulator ret GetFacingPersonText:: ; 00:3103 callba Function776e ret nc - call Function319b + call TurnNPCTalkingTo + scf + ret + +Function3111:: ; 00:3111 + push hl + call PrepareTextbox + ld a, [wce63] + bit 1, a + call nz, PrintTextboxDebugNumbers ; if debug, print text IDs + pop hl + call TextboxIdle + ret + +Function3122:: ; 00:3122 + push hl + call PrepareTextbox + pop hl + +TextboxIdle:: ; 00:3127 + call PrintTextBoxText +.loop + ld a, [wJoypadFlags] + bit 5, a + res 5, a + ld [wJoypadFlags], a + jr nz, .escape ; if bit 5 of joyflags is set, escape + call GetJoypad + ldh a, [hJoyDown] + and A_BUTTON | B_BUTTON + jr nz, .escape ; if A or B are down, escape + call UpdateTime + call UpdateTimeOfDayPalettes + call DelayFrame + jr .loop +.escape + call TextboxCleanup + ret + +PrepareTextbox:: ; 00:314E + call ClearWindowData + ldh a, [hROMBank] + push af + ld a, 01 + call Bankswitch + call ReanchorBGMap_NoOAMUpdate + ld hl, $C390 ;in the tilemap in WRAM + ld b, 04 + ld c, $12 + call DrawTextBox + call WaitBGMap + call LoadFonts_NoOAMUpdate + pop af + call Bankswitch + ret + +TextboxCleanup ; 00:3171 + callab ReanchorBGMap_NoOAMUpdate + call UpdateSprites + xor a + ldh [hBGMapMode], a ;reset this + ld a, $90 + ldh [hWY], a ;set window Y to $90 + call Function318f + ld hl, wToolgearFlags + res 7, [hl] ; show toolgear + call InitToolgearBuffer + ret + +Function318f ; 00:318f + callab Function140ea + call Function0d02 + ret + +TurnNPCTalkingTo:: ; 00:319b + ldh a, [hObjectStructIndexBuffer] + call GetObjectStruct + ld hl, $0000 + add hl, bc ; bc is the address of the a'th object struct + ld a, [hl] + call CheckNonTurningSprite + jr c, .jump ;if it's a non-turning sprite, skip this + ld a, [wPlayerWalking] ; shouldn't this be direction? + xor 04 ; get opposite direction from player + ld hl, $0007 + add hl, bc ; get NPC's direction + ld [hl], a ; overwrite it + push bc + call UpdateSprites + pop bc +.jump + ld hl, $0001 + add hl, bc + ld a, [hl] + sub 02 + ldh [hFFEA], a + ret + +Function31C3:: ; 00:31C3 + ret + +CheckInlineTrainer:: ; 00:31C4 + ; passed de is the start of a map_object struct. if it's an inline trainer, write to relevant wram region. + ld hl, $0000 + add hl, de + ld a, [hl] + call GetObjectStruct ; de is the address of the number of object we want + call $31EB + jr nc, .escape ; if c flag isn't set, leave + ld hl, $000B ; map_object script + add hl, de + ld a, [hl] + cp b + jr c, .escape ;if action is less than b, return + ld hl, $0000 ; obj id + add hl, de + ld a, [hl] + add a, a ; objid*2 + ld hl, wCurrMapInlineTrainers + add a, l + ld l, a + jr nc, .noCarry + inc h +.noCarry + ld [hl], b ; store bc (distance, direction) in new hl + inc hl + ld [hl], c +.escape + ret + +GetInlineMapObject:: ; 00:31EB + ;bc is start of object struct. if c flag set, returns distance in B and direction in C + ld hl, $0010 ; offset for StandingMapX + add hl, bc + ld a, [wPlayerStandingMapX] + cp [hl] + jr z, .equalX ; if player x == object x + ld hl, $0011 ; offset for StandingMapY + add hl, bc + ld a, [wPlayerStandingMapY] + cp [hl] + jr z, .equalY ; if player y == object y and px != ox, jump + and a ; clears c for the ret + ret +.equalX ; player x == object x + ld hl, $0011 + add hl, bc + ld a, [wPlayerStandingMapY] + sub [hl] ; py - oy + jr z, .reset ; if py == oy, jump + jr nc, .setDown ; if py > oy, jump + cpl + inc a + ld b, a + ld c, 01 ; 1 in c means player has smaller Y, same x + scf ; sets c for the ret + ret +.setDown ; 3214 + ld b, a ; b is difference in y + ld c, 00 ; 0 in c means player has bigger Y, same x + scf ; set c + ret +.equalY ; 3219 + ld hl, $0010 + add hl, bc + ld a, [wPlayerStandingMapX] + sub [hl] + jr z, .reset ; if px == ox, jump (this is impossible) + jr nc, .setRight ; if px > ox, jump + cpl + inc a + ld b, a + ld c, 02 ; 2 in c means player has smaller x, equal y + scf + ret +.setRight ; 322C + ld b, a + ld c, 03 ; 3 in c means player has bigger x, equal y scf ret +.reset ; 3231 + and a ; clear c + ret + +CheckAPressedDebug ; 3233 + ld a, [wce63] + bit 1, a + ret z ; return if not debug + ldh a, [hJoyState] + bit A_BUTTON, a + ret + +ClearAccumulator:: ; 323E + xor a ; clear a + ret + +SetFFInAccumulator:: ; 3240 + xor a + dec a + ret + +; 3243 \ No newline at end of file diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 453c2f8..bf99129 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -49,19 +49,19 @@ Function38d8:: ld [wd637], a ret -Function38e3:: +TestWildBattleStart:: ldh a, [hJoyState] - and $f0 - ret z - call Function3233 - jp nz, Function323e + and D_PAD + ret z ; if no directions are down, don't try and trigger a wild encounter + call CheckAPressedDebug + jp nz, ClearAccumulator ; if b button is down, clear acc callab Function3ee3e ld a, [wBattleMode] and a - ret z + ret z ; if no battle, return ld a, $3 call WriteIntod637 - call Function3240 + call SetFFInAccumulator ret Function3904:: diff --git a/home/util.asm b/home/util.asm index 880513b..ccc990a 100644 --- a/home/util.asm +++ b/home/util.asm @@ -65,12 +65,13 @@ SkipNames:: ; 341f ret AddNTimes:: ; 3429 (0:3429) +; Adds bc to hl, a times and a ret z -.asm_342b +.loop add hl, bc dec a - jr nz, .asm_342b + jr nz, .loop ret ; 0x3430 diff --git a/home/window.asm b/home/window.asm index c2dc212..9e86453 100644 --- a/home/window.asm +++ b/home/window.asm @@ -17,7 +17,7 @@ RefreshScreen:: ret Function1fea:: - call Function3171 + call TextboxCleanup call ClearWindowData call InitToolgearBuffer ret -- cgit v1.2.3 From f123dd89d49f6f70d823947a47a3ce117d6cd01a Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sun, 17 Jun 2018 01:05:52 -0600 Subject: more npc code and some audio stuff, slimmin down the shim --- home/audio.asm | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ home/talk_to_npc.asm | 20 +++++++- 2 files changed, 145 insertions(+), 2 deletions(-) (limited to 'home') diff --git a/home/audio.asm b/home/audio.asm index 03a0990..e50abc1 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -140,3 +140,130 @@ PlaySFX:: ; 3d63 ret WaitPlaySFX:: ; 3d7f + call WaitSFX + call PlaySFX + ret + +WaitSFX:: ; 3d86 + push hl +.loop + ld hl, wChannel5Flags1 + bit 0, [hl] + jr nz, .loop + ld hl, wChannel6Flags1 + bit 0, [hl] + jr nz, .loop + ld hl, wChannel7Flags1 + bit 0, [hl] + jr nz, .loop + ld hl, wChannel8Flags1 + bit 0, [hl] + jr nz, .loop + pop hl + ret + +MaxVolume:: ; 3DA5 + ld a, $77 + ld [wVolume], a + ret + +LowVolume:: ; 3DAB + ld a, $33 + ld [wVolume], a + ret + +VolumeOff:: ; 3DB1 + xor a + ld [wVolume], a + ret + +UpdateSoundNTimes:: ; 3DB6 +.loop + and a + ret z + dec a + call UpdateSound + jr .loop + +FadeToMapMusic:: ; 3DBE + push hl + push de + push bc + push af + call GetMapMusic + ld a, [wMapMusic] + cp e + jr z, .jump + ld a, $08 + ld [wMusicFade], a + ld a, e + ld [wMusicFadeID], a + ld a, d + ld [wMusicFadeID+1], a + ld a, e + ld [wMapMusic], a +.jump + pop af + pop bc + pop de + pop hl + ret + +PlayMapMusic:: ; 3DE1 + push hl + push de + push bc + push af + call GetMapMusic + ld a, [wMapMusic] + cp e + jr z, .jump + push de + ld de, $0000 + call PlayMusic + call DelayFrame + pop de + ld a, e + ld [wMapMusic], a + call PlayMusic +.jump + pop af + pop bc + pop de + pop hl + ret + +SpecialMapMusic:: ; 3E05 + ld a, [wPlayerBikeSurfState] + and a + jr z, .normal + cp $02 + jr z, .state2 + ld de, $0009 + scf + ret + +.state2 ; 3E14 + ld de, $0000 + scf + ret + +.normal ; 3E19 + and a + ret + +GetMapMusic:: ; 3E1B + call SpecialMapMusic + ret c + ld a, [wMapPermissions] + cp $01 + jr z, .jump + cp $03 + jr z, .jump + ld de, $0002 + ret +.jump ; 3E2E + ld de, $0007 + ret + +; 3E32, this is likely not a function. \ No newline at end of file diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 1820692..3371b3c 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -260,7 +260,7 @@ CheckInlineTrainer:: ; 00:31C4 add hl, de ld a, [hl] call GetObjectStruct ; de is the address of the number of object we want - call $31EB + call GetInlineMapObject jr nc, .escape ; if c flag isn't set, leave ld hl, $000B ; map_object script add hl, de @@ -354,4 +354,20 @@ SetFFInAccumulator:: ; 3240 dec a ret -; 3243 \ No newline at end of file +Function3243:: ; 3243 + ldh a, [hROMBank] + push af + ld a, $03 + call Bankswitch + push hl + push de + push bc + call _TossItem + pop bc + pop de + pop hl + pop af + call Bankswitch + ret + +;3259 \ No newline at end of file -- cgit v1.2.3 From 130f5f1bb94ddcc609b5b5344a72d803b68a1102 Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sun, 17 Jun 2018 03:42:21 -0600 Subject: happy birthday, here's the main menu debug menu... menu --- home/unknown.asm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'home') diff --git a/home/unknown.asm b/home/unknown.asm index 6568b5d..3962377 100644 --- a/home/unknown.asm +++ b/home/unknown.asm @@ -53,10 +53,8 @@ Function094c:: push af ld a, BANK(Functionfe255) call Bankswitch - call Functionfe255 pop af call Bankswitch - - jp Function4031 + jp DebugMenu -- cgit v1.2.3 From b095e626305a4c99f8b14c46b46c1bf97fe00262 Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sun, 17 Jun 2018 11:16:28 -0600 Subject: some more tidying up --- home/map.asm | 10 ++-- home/map_objects.asm | 8 +-- home/overworld.asm | 4 +- home/talk_to_npc.asm | 144 ++++++++++++++++++++++++++------------------------ home/time.asm | 4 +- home/unknown_388f.asm | 2 +- 6 files changed, 87 insertions(+), 85 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index 1f7c27d..a13a2d4 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1612,9 +1612,7 @@ Function2ae5:: ret nz call OverworldStartButtonCheck ret nz - ld hl, PlaceWaitingText - ld a, $3 - call FarCall_hl + callab Functionc000 ldh a, [hMapEntryMethod] and a ret nz @@ -1634,7 +1632,7 @@ Function2b39:: ld hl, wJoypadFlags res 4, [hl] res 6, [hl] - ld hl, wce63 + ld hl, wDebugFlags res 6, [hl] res 7, [hl] ld hl, wVramState @@ -1714,8 +1712,8 @@ Function2ba8:: ; 00:2ba8 scf ret -Function2be5:: ; 00:2be5 - ld a, [wce63] +Function2be5:: ; 00:2be5 ; TODO + ld a, [wDebugFlags] bit 7, a ret nz ld a, [wMapGroup] diff --git a/home/map_objects.asm b/home/map_objects.asm index ca7ca0b..079897a 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -342,14 +342,14 @@ CheckNonTurningSprite:: ; 00:17de ld c, a ld b, $ff ld hl, .Data -.loop: ; 00:17e6 +.loop: ld a, [hli] cp b - jr z, .escape ; if a == $FF, escape + jr z, .escape cp c - jr nz, .loop ; if a != c, loop + jr nz, .loop scf -.escape: ; 00:17ee +.escape: pop bc pop hl ret diff --git a/home/overworld.asm b/home/overworld.asm index afa73cc..e1e7dfb 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -14,8 +14,8 @@ if DEBUG and (START | B_BUTTON) cp (START | B_BUTTON) jr nz, .regularMenu - ld a, [wce63] - bit 1, a + ld a, [wDebugFlags] + bit DEBUG_FIELD_F, a ret z ; debug disabled callba InGameDebugMenu jr CheckStartmenuSelectHook diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 3371b3c..69d59db 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -8,7 +8,7 @@ endc Function3025:: ld hl, .Text - call Function3111 + call StartTextboxWithDebug ret .Text: ; 00:302c @@ -85,13 +85,13 @@ PrintTextboxDebugNumbers:: ; 00:3085 ld a, [wTalkingTargetType] bit 0, a jr z, .CheckSign - ld de, hFFEA ; address if we're talking to an NPC + ld de, hFFEA jr .PrintNum .CheckSign: ; 00:3097 bit 1, a jr z, .PrintNum - ld de, hFFEE ; address if we're talking to a sign + ld de, hFFEE .PrintNum: ; 00:309e hlcoord 4, 12 @@ -114,8 +114,8 @@ QueueMapTextSubroutine:: ; 00:30b7 jp nc, Function30e8 ; if not talking to a person ld d, $0 ld e, a - ld a, [wce63] - bit 1, a + ld a, [wDebugFlags] + bit DEBUG_FIELD_F, a call nz, PrintTextboxDebugNumbers ; if debug, print these ld hl, wMapTextPtr ld a, [hli] @@ -157,38 +157,40 @@ GetFacingPersonText:: ; 00:3103 scf ret -Function3111:: ; 00:3111 +StartTextboxWithDebug:: ; 00:3111 + ; Identical to StartTextbox except it prints debug numbers if in debug mode. push hl call PrepareTextbox - ld a, [wce63] - bit 1, a - call nz, PrintTextboxDebugNumbers ; if debug, print text IDs + ld a, [wDebugFlags] + bit DEBUG_FIELD_F, a + call nz, PrintTextboxDebugNumbers pop hl call TextboxIdle ret -Function3122:: ; 00:3122 +StartTextbox:: ; 00:3122 push hl call PrepareTextbox pop hl TextboxIdle:: ; 00:3127 + ; Prints text, then waits for A or B to be pressed, unless bit 5 of JoypadFlags is set. call PrintTextBoxText -.loop +.Loop ld a, [wJoypadFlags] bit 5, a res 5, a ld [wJoypadFlags], a - jr nz, .escape ; if bit 5 of joyflags is set, escape + jr nz, .Escape call GetJoypad ldh a, [hJoyDown] and A_BUTTON | B_BUTTON - jr nz, .escape ; if A or B are down, escape + jr nz, .Escape call UpdateTime call UpdateTimeOfDayPalettes call DelayFrame - jr .loop -.escape + jr .Loop +.Escape call TextboxCleanup ret @@ -199,7 +201,7 @@ PrepareTextbox:: ; 00:314E ld a, 01 call Bankswitch call ReanchorBGMap_NoOAMUpdate - ld hl, $C390 ;in the tilemap in WRAM + hlcoord 0, 12 ;in the tilemap in WRAM ld b, 04 ld c, $12 call DrawTextBox @@ -213,12 +215,12 @@ TextboxCleanup ; 00:3171 callab ReanchorBGMap_NoOAMUpdate call UpdateSprites xor a - ldh [hBGMapMode], a ;reset this + ldh [hBGMapMode], a ld a, $90 - ldh [hWY], a ;set window Y to $90 + ldh [hWY], a call Function318f ld hl, wToolgearFlags - res 7, [hl] ; show toolgear + res 7, [hl] call InitToolgearBuffer ret @@ -228,23 +230,24 @@ Function318f ; 00:318f ret TurnNPCTalkingTo:: ; 00:319b + ; If an NPC is allowed to turn when talked to, turn it. ldh a, [hObjectStructIndexBuffer] call GetObjectStruct - ld hl, $0000 - add hl, bc ; bc is the address of the a'th object struct + ld hl, OBJECT_SPRITE + add hl, bc ld a, [hl] call CheckNonTurningSprite - jr c, .jump ;if it's a non-turning sprite, skip this - ld a, [wPlayerWalking] ; shouldn't this be direction? - xor 04 ; get opposite direction from player - ld hl, $0007 - add hl, bc ; get NPC's direction - ld [hl], a ; overwrite it + jr c, .Jump + ld a, [wPlayerWalking] + xor 04 + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld [hl], a push bc call UpdateSprites pop bc -.jump - ld hl, $0001 +.Jump + ld hl, OBJECT_MAP_OBJECT_INDEX add hl, bc ld a, [hl] sub 02 @@ -255,98 +258,99 @@ Function31C3:: ; 00:31C3 ret CheckInlineTrainer:: ; 00:31C4 - ; passed de is the start of a map_object struct. if it's an inline trainer, write to relevant wram region. - ld hl, $0000 + ; Passed de is the pointer to a map_object struct. If it's an inline trainer, write to relevant wram region. + ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, de ld a, [hl] - call GetObjectStruct ; de is the address of the number of object we want + call GetObjectStruct call GetInlineMapObject - jr nc, .escape ; if c flag isn't set, leave - ld hl, $000B ; map_object script + jr nc, .Escape + ld hl, MAPOBJECT_POINTER_HI add hl, de ld a, [hl] cp b - jr c, .escape ;if action is less than b, return - ld hl, $0000 ; obj id + jr c, .Escape + ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, de ld a, [hl] - add a, a ; objid*2 + add a, a ld hl, wCurrMapInlineTrainers add a, l ld l, a - jr nc, .noCarry + jr nc, .NoCarry inc h -.noCarry - ld [hl], b ; store bc (distance, direction) in new hl +.NoCarry + ld [hl], b inc hl ld [hl], c -.escape +.Escape ret GetInlineMapObject:: ; 00:31EB ;bc is start of object struct. if c flag set, returns distance in B and direction in C - ld hl, $0010 ; offset for StandingMapX + ld hl, OBJECT_NEXT_MAP_X add hl, bc ld a, [wPlayerStandingMapX] cp [hl] - jr z, .equalX ; if player x == object x - ld hl, $0011 ; offset for StandingMapY + jr z, .EqualX + ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld a, [wPlayerStandingMapY] cp [hl] - jr z, .equalY ; if player y == object y and px != ox, jump - and a ; clears c for the ret + jr z, .EqualY + and a ret -.equalX ; player x == object x - ld hl, $0011 +.EqualX + ld hl, OBJECT_NEXT_MAP_Y add hl, bc ld a, [wPlayerStandingMapY] - sub [hl] ; py - oy - jr z, .reset ; if py == oy, jump - jr nc, .setDown ; if py > oy, jump + sub [hl] + jr z, .Reset + jr nc, .SetDown cpl inc a ld b, a - ld c, 01 ; 1 in c means player has smaller Y, same x - scf ; sets c for the ret + ld c, UP + scf ret -.setDown ; 3214 - ld b, a ; b is difference in y - ld c, 00 ; 0 in c means player has bigger Y, same x - scf ; set c +.SetDown ; 3214 + ld b, a + ld c, DOWN + scf ret -.equalY ; 3219 - ld hl, $0010 +.EqualY ; 3219 + ld hl, OBJECT_NEXT_MAP_X add hl, bc ld a, [wPlayerStandingMapX] sub [hl] - jr z, .reset ; if px == ox, jump (this is impossible) - jr nc, .setRight ; if px > ox, jump + jr z, .Reset ; (this condition is impossible to meet) + jr nc, .SetRight cpl inc a ld b, a - ld c, 02 ; 2 in c means player has smaller x, equal y + ld c, LEFT scf ret -.setRight ; 322C +.SetRight ; 322C ld b, a - ld c, 03 ; 3 in c means player has bigger x, equal y + ld c, RIGHT scf ret -.reset ; 3231 - and a ; clear c +.Reset ; 3231 + and a ret CheckAPressedDebug ; 3233 - ld a, [wce63] - bit 1, a - ret z ; return if not debug + ; If in debug mode, returns a check on the A button. + ld a, [wDebugFlags] + bit DEBUG_FIELD_F, a + ret z ldh a, [hJoyState] bit A_BUTTON, a ret ClearAccumulator:: ; 323E - xor a ; clear a + xor a ret SetFFInAccumulator:: ; 3240 diff --git a/home/time.asm b/home/time.asm index 3eba96c..d82235d 100644 --- a/home/time.asm +++ b/home/time.asm @@ -32,8 +32,8 @@ UpdateTime:: ; 436 (0:0436) and $1f ldh [hRTCHours], a call CloseSRAM - ld a, [wce63] - bit 1, a + ld a, [wDebugFlags] + bit DEBUG_FIELD_F, a jr z, .asm_0478 ld a, [wd153] bit 7, a diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index bf99129..5fdad1c 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -92,7 +92,7 @@ Function3920:: ld hl, wJoypadFlags res 4, [hl] ld hl, .text - call Function3111 + call StartTextboxWithDebug call RotateFourPalettesLeft jp Init -- cgit v1.2.3 From c557bd661357b1371633a40b7ae6a8e2996de6e2 Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sun, 17 Jun 2018 23:04:49 -0600 Subject: main menu progress for the day, still have a bunch more to go. --- home/misc_32c8.asm | 4 ++-- home/text.asm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'home') diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm index 3eabb12..bb19d59 100644 --- a/home/misc_32c8.asm +++ b/home/misc_32c8.asm @@ -78,7 +78,7 @@ WaitPressedAny:: ; 369a CountSetBits:: ; 36b1 ; Count the number of bits set in b bytes at hl. -; Return to a, c, and wce37. +; Return to a, c, and wCountSetBitsResult. ld c, $0 .asm_36b3: ; 00:36b3 ld a, [hli] @@ -94,5 +94,5 @@ CountSetBits:: ; 36b1 dec b jr nz, .asm_36b3 ld a, c - ld [wce37], a + ld [wCountSetBitsResult], a ret diff --git a/home/text.asm b/home/text.asm index b3cd75c..20119dd 100644 --- a/home/text.asm +++ b/home/text.asm @@ -244,7 +244,7 @@ ENDM PrintMomsName:: print_name wMomsName PrintPlayerName:: print_name wPlayerName -PrintRivalName:: print_name wRivalsName +PrintRivalName:: print_name wRivalName TrainerChar:: print_name TrainerCharText TMChar:: print_name TMCharText -- cgit v1.2.3 From b44077ed3180b57a852db48f784312f6a1b0221a Mon Sep 17 00:00:00 2001 From: 2Tie Date: Mon, 18 Jun 2018 22:36:17 -0600 Subject: this was a silly mistake --- home/talk_to_npc.asm | 6 +++--- home/unknown_388f.asm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'home') diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 69d59db..4b2261b 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -340,13 +340,13 @@ GetInlineMapObject:: ; 00:31EB and a ret -CheckAPressedDebug ; 3233 - ; If in debug mode, returns a check on the A button. +CheckBPressedDebug ; 3233 + ; If in debug mode, returns a check on the B button. ld a, [wDebugFlags] bit DEBUG_FIELD_F, a ret z ldh a, [hJoyState] - bit A_BUTTON, a + bit B_BUTTON_F, a ret ClearAccumulator:: ; 323E diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 5fdad1c..447f6cf 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -53,7 +53,7 @@ TestWildBattleStart:: ldh a, [hJoyState] and D_PAD ret z ; if no directions are down, don't try and trigger a wild encounter - call CheckAPressedDebug + call CheckBPressedDebug jp nz, ClearAccumulator ; if b button is down, clear acc callab Function3ee3e ld a, [wBattleMode] -- cgit v1.2.3 From 67388aeeda060f7d08e7e2b6ca90097b978886f6 Mon Sep 17 00:00:00 2001 From: pfero Date: Sat, 23 Jun 2018 14:25:46 +0200 Subject: Disassemble all map attributes --- home/map.asm | 8 ++++---- home/tileset.asm | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index 8105781..63810dd 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1036,7 +1036,7 @@ Function275e:: ; 275e ; TODO: is this used? GetCoordOfUpperLeftCorner:: ; 277a - ld hl, wOverworldMap + ld hl, wOverworldMapBlocks ld a, [wXCoord] bit 0, a jr nz, .increment_then_halve1 @@ -1324,12 +1324,12 @@ ENDR ChangeMap:: ; 294d - ld hl, wOverworldMap - ld bc, wOverworldMapEnd - wOverworldMap + ld hl, wOverworldMapBlocks + ld bc, wOverworldMapBlocksEnd - wOverworldMapBlocks ld a, 0 call ByteFill - ld hl, wOverworldMap + ld hl, wOverworldMapBlocks ld a, [wMapWidth] ldh [hConnectedMapWidth], a add a, 6 diff --git a/home/tileset.asm b/home/tileset.asm index aabf249..38b9779 100644 --- a/home/tileset.asm +++ b/home/tileset.asm @@ -331,7 +331,7 @@ GetBlockLocation:: ; 2ef8 add a, 6 ld c, a ld b, 0 - ld hl, wOverworldMap + 1 + ld hl, wOverworldMapBlocks + 1 add hl, bc ld a, e srl a -- cgit v1.2.3 From 147d0964d8d8cddc4749f301692d495cd9b6f49a Mon Sep 17 00:00:00 2001 From: Tauwasser Date: Sun, 24 Jun 2018 23:09:15 +0200 Subject: hram: rename hTextErrno to hEventID Signed-off-by: Tauwasser --- home/text.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/text.asm b/home/text.asm index b3cd75c..d528d08 100644 --- a/home/text.asm +++ b/home/text.asm @@ -232,7 +232,7 @@ NullChar:: ; 00:0f66 ret .Text: - deciram hTextErrno, 1, 2 + deciram hEventID, 1, 2 text "エラー" done -- cgit v1.2.3 From 57481cc9421d2ea830480d3c1cb5b9f5c7d907aa Mon Sep 17 00:00:00 2001 From: Tauwasser Date: Sun, 24 Jun 2018 23:10:16 +0200 Subject: home/copy2: rename Function0d02 to RedrawPlayerSprite Signed-off-by: Tauwasser --- home/copy2.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/copy2.asm b/home/copy2.asm index 9baad62..7274d8d 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -2,7 +2,7 @@ INCLUDE "constants.asm" SECTION "Video Copy functions", ROM0[$0D02] -Function0d02:: +RedrawPlayerSprite:: jpab Function14000 LoadFont:: ; 00:0d0a -- cgit v1.2.3 From 906ea8bdfcf024cb5011948a319764047f8fa41f Mon Sep 17 00:00:00 2001 From: Tauwasser Date: Sun, 24 Jun 2018 23:15:07 +0200 Subject: engine: disassemble player movement (WIP) Signed-off-by: Tauwasser --- home/map.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index 8105781..8c03d9f 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1679,7 +1679,7 @@ Function2b87:: call GetJoypad call OverworldStartButtonCheck ret nz - callab Functionc000 + callab OverworldMovementCheck call Function2ba8 jr nc, .asm_2b87 callba Function824c -- cgit v1.2.3 From 3d44a334949f387304144dbb331a4b6f74fbdb79 Mon Sep 17 00:00:00 2001 From: 2Tie Date: Sun, 24 Jun 2018 16:43:11 -0600 Subject: all the non-dummy map scripts until Silent Hill are disassebled. five left! --- home/map.asm | 2 +- home/map_objects.asm | 3 ++- home/talk_to_npc.asm | 16 ++++++++-------- home/unknown_388f.asm | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'home') diff --git a/home/map.asm b/home/map.asm index a13a2d4..e295894 100644 --- a/home/map.asm +++ b/home/map.asm @@ -470,7 +470,7 @@ Function2407:: ; 00:2407 ld [wPlayerFacing], a ld a, $0 ld d, $0 - call Function19c0 + call SetObjectFacing ret MapSetup_Connection:: ; 2439 diff --git a/home/map_objects.asm b/home/map_objects.asm index 079897a..faa4bb9 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -663,7 +663,8 @@ Function19b5:: res 7, [hl] ret -Function19c0:: +SetObjectFacing:: ; 19C0 + ; a is NPC number, d is direction push de call CheckObjectVisibility pop de diff --git a/home/talk_to_npc.asm b/home/talk_to_npc.asm index 4b2261b..9edee7d 100644 --- a/home/talk_to_npc.asm +++ b/home/talk_to_npc.asm @@ -6,9 +6,9 @@ else SECTION "Unknown 3025", ROM0 [$2fe9] endc -Function3025:: +MapDefaultText:: ld hl, .Text - call StartTextboxWithDebug + call OpenTextbox ret .Text: ; 00:302c @@ -157,8 +157,8 @@ GetFacingPersonText:: ; 00:3103 scf ret -StartTextboxWithDebug:: ; 00:3111 - ; Identical to StartTextbox except it prints debug numbers if in debug mode. +OpenTextbox:: ; 00:3111 + ; Opens a textbox and waits for input push hl call PrepareTextbox ld a, [wDebugFlags] @@ -168,7 +168,7 @@ StartTextboxWithDebug:: ; 00:3111 call TextboxIdle ret -StartTextbox:: ; 00:3122 +OpenTextboxNoInput:: ; 00:3122 push hl call PrepareTextbox pop hl @@ -211,7 +211,7 @@ PrepareTextbox:: ; 00:314E call Bankswitch ret -TextboxCleanup ; 00:3171 +TextboxCleanup: ; 00:3171 callab ReanchorBGMap_NoOAMUpdate call UpdateSprites xor a @@ -224,7 +224,7 @@ TextboxCleanup ; 00:3171 call InitToolgearBuffer ret -Function318f ; 00:318f +Function318f: ; 00:318f callab Function140ea call Function0d02 ret @@ -340,7 +340,7 @@ GetInlineMapObject:: ; 00:31EB and a ret -CheckBPressedDebug ; 3233 +CheckBPressedDebug: ; 3233 ; If in debug mode, returns a check on the B button. ld a, [wDebugFlags] bit DEBUG_FIELD_F, a diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm index 447f6cf..1182506 100644 --- a/home/unknown_388f.asm +++ b/home/unknown_388f.asm @@ -92,7 +92,7 @@ Function3920:: ld hl, wJoypadFlags res 4, [hl] ld hl, .text - call StartTextboxWithDebug + call OpenTextbox call RotateFourPalettesLeft jp Init -- cgit v1.2.3 From 3c966f7df4170f58f8274f444977c5a29225d9be Mon Sep 17 00:00:00 2001 From: Pokeglitch Date: Mon, 25 Jun 2018 22:43:31 -0400 Subject: Disassembled all routines related to sprite movement/collisions. Added in constants --- home/copy2.asm | 2 +- home/map.asm | 16 ++++++++-------- home/map_objects.asm | 26 +++++++++++++++++--------- home/tileset.asm | 20 ++++++++++---------- 4 files changed, 36 insertions(+), 28 deletions(-) (limited to 'home') diff --git a/home/copy2.asm b/home/copy2.asm index 7274d8d..e74ef8b 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -3,7 +3,7 @@ INCLUDE "constants.asm" SECTION "Video Copy functions", ROM0[$0D02] RedrawPlayerSprite:: - jpab Function14000 + jpab _RedrawPlayerSprite LoadFont:: ; 00:0d0a jpab LoadFontGraphics diff --git a/home/map.asm b/home/map.asm index 8c03d9f..21e41c8 100644 --- a/home/map.asm +++ b/home/map.asm @@ -448,8 +448,8 @@ FadeIn:: ; 23e5 ; This is not OverworldFadeIn, but I don't know what it is ret Function2407:: ; 00:2407 - ld a, $2a - ld [wcb77], a + ld a, NO_MOVEMENT + ld [wPlayerMovement], a xor a ld [wPlayerAction], a ld a, [wPlayerFacing] @@ -505,7 +505,7 @@ CheckMovingOffEdgeOfMap:: ; 245e ret .down - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] sub 4 ld b, a ld a, [wMapHeight] @@ -516,7 +516,7 @@ CheckMovingOffEdgeOfMap:: ; 245e ret .up - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] sub 4 cp -1 jr z, .ok @@ -524,7 +524,7 @@ CheckMovingOffEdgeOfMap:: ; 245e ret .left - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] sub 4 cp -1 jr z, .ok @@ -532,7 +532,7 @@ CheckMovingOffEdgeOfMap:: ; 245e ret .right - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] sub 4 ld b, a ld a, [wMapWidth] @@ -701,10 +701,10 @@ WarpCheck:: ; 259f ret GetDestinationWarpPointer: ; 25b9 - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] sub 4 ld d, a - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] sub 4 ld e, a ld a, [wCurrMapWarpCount] diff --git a/home/map_objects.asm b/home/map_objects.asm index 70cba50..cc82ef3 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -334,26 +334,34 @@ Function17cb:: call Bankswitch ret -Function17de:: +; sets carry flag if the sprite data includes "in-motion" sprites +IsAnimatedSprite:: ; 00:17de push hl push bc ld c, a - ld b, $ff - ld hl, .Data -.asm_17e6: ; 00:17e6 + ld b, -1 + ld hl, .NonAnimatedSprites +.loop ld a, [hli] cp b - jr z, .asm_17ee + jr z, .done cp c - jr nz, .asm_17e6 + jr nz, .loop scf -.asm_17ee: ; 00:17ee +.done pop bc pop hl ret -.Data: ; 00:17f1 - db $51, $55, $56, $57, $58, $5a, $5b, $ff +.NonAnimatedSprites: ; 00:17f1 + db SPRITE_KABIGON + db SPRITE_POKE_BALL + db SPRITE_POKEDEX + db SPRITE_PAPER + db SPRITE_OLD_LINK_RECEPTIONIST + db SPRITE_EGG + db SPRITE_BOULDER + db -1 Function17f9:: call GetMapObject diff --git a/home/tileset.asm b/home/tileset.asm index aabf249..4929159 100644 --- a/home/tileset.asm +++ b/home/tileset.asm @@ -50,7 +50,7 @@ RefreshPlayerCoords:: ; 2d74 ld a, [wXCoord] add a, 4 ld d, a - ld hl, wPlayerStandingMapX + ld hl, wPlayerNextMapX sub [hl] ld [hl], d ld hl, wPlayerObjectXCoord @@ -61,7 +61,7 @@ RefreshPlayerCoords:: ; 2d74 ld a, [wYCoord] add a, 4 ld e, a - ld hl, wPlayerStandingMapY + ld hl, wPlayerNextMapY sub [hl] ld [hl], e ld hl, wPlayerObjectYCoord @@ -211,18 +211,18 @@ SaveScreen:: ; 2df1 RefreshTiles:: ; 2e52 call .left_right call .up_down - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] ld e, a call GetCoordTile ld [wPlayerStandingTile], a ret .up_down ; 2e67 - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] ld e, a push de inc e @@ -235,9 +235,9 @@ RefreshTiles:: ; 2e52 ret .left_right ; 2e80 - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] ld e, a push de dec d @@ -270,10 +270,10 @@ GetFacingTileCoord:: ; 2e99 ld h, [hl] ld l, a - ld a, [wPlayerStandingMapX] + ld a, [wPlayerNextMapX] add a, d ld d, a - ld a, [wPlayerStandingMapY] + ld a, [wPlayerNextMapY] add a, e ld e, a ld a, [hl] -- cgit v1.2.3 From e596d41c1790bb9b77c9e941aab5eb4b1305dbb5 Mon Sep 17 00:00:00 2001 From: obskyr Date: Tue, 3 Jul 2018 04:59:38 +0200 Subject: A few small formatting fixes --- home/oam_dma.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/oam_dma.asm b/home/oam_dma.asm index 42ecaaf..42c68e7 100644 --- a/home/oam_dma.asm +++ b/home/oam_dma.asm @@ -1,6 +1,6 @@ INCLUDE "constants.asm" -SECTION "OAM DMA", ROMX[$4153],BANK[1] +SECTION "OAM DMA", ROMX[$4153], BANK[$01] WriteOAMDMACodeToHRAM:: ; 4153 ld c, LOW(hOAMDMA) -- cgit v1.2.3