From 17d6c0d0f7de10572f15a99323d834c2ab4af6ff Mon Sep 17 00:00:00 2001 From: xeons Date: Fri, 30 Mar 2012 21:36:54 -0500 Subject: Forced biking or surfing map handling functions hg-commit-id: 7980878962c4 --- extras/gbz80disasm.py | 3 +- main.asm | 85 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index 80d169e5..ae8f0f6f 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -604,7 +604,8 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): bank_id = 0 if original_offset > 0x8000: bank_id = original_offset / 0x4000 - print "bank id is: " + str(bank_id) + #print "bank id is: " + str(bank_id) + print "Function{0:x}:".format(original_offset); last_hl_address = None #for when we're scanning the main map script last_a_address = None diff --git a/main.asm b/main.asm index 4fef3f9f..da5f5fad 100644 --- a/main.asm +++ b/main.asm @@ -470,8 +470,8 @@ EnterMap: ; 3A6 call Bankswitch ; display fly/teleport in graphical effect call $2429 ; move sprites .didNotFlyOrTeleportIn\@ - ld b,$03 - ld hl,$438b + ld b,BANK(CheckForceBikeOrSurf) + ld hl,CheckForceBikeOrSurf call Bankswitch ; handle currents in SF islands and forced bike riding in cycling road ld hl,$d72d res 5,[hl] @@ -2849,8 +2849,17 @@ SwitchToMapRomBank: ; 12BC pop bc pop hl ret + +INCBIN "baserom.gbc",$12DA,$12ED-$12DA -INCBIN "baserom.gbc",$12DA,$12F8 - $12DA +;appears to be called twice inside function $C38B +;if $d700,$d11a == $1 then biking +;if $d700,$d11a == $2 then surfing +ForceBikeOrSurf: ; 12ED + ld b,5 ;graphics bank 5 + ld hl,LoadPlayerSpriteGraphics ;load player sprite graphics + call Bankswitch ;loads bank 5 and then calls LoadPlayerSpriteGraphics + jp $2307 ;update map/player state? ; this is used to check if the player wants to interrupt the opening sequence at several points ; XXX is this used anywhere else? @@ -10795,7 +10804,75 @@ MapHeaderBanks: ; 423D db BANK(Bruno_h) db BANK(Agatha_h) -INCBIN "baserom.gbc",$C335,$C766-$C335 +INCBIN "baserom.gbc",$C335,$C38B-$C335 + +CheckForceBikeOrSurf: ; C38B + ld hl, $D732 + bit 5, [hl] + ret nz + ld hl, ForcedBikeSurfMaps + ld a, [W_YCOORD] + ld b, a + ld a, [W_XCOORD] + ld c, a + ld a, [W_CURMAP] + ld d, a +.loop\0 + ld a, [hli] + cp $ff + ret z ;if we reach FF then it's not part of the list + cp d ;compare to current map + jr nz, .incorrectMap\0 + ld a, [hli] + cp b ;compare y-coord + jr nz, .incorrectY\0 + ld a, [hli] + cp c ;compare x-coord + jr nz, .loop\0 ; incorrect x-coord, check next item + ld a, [W_CURMAP] + cp SEAFOAM_ISLANDS_4 + ld a, $2 + ld [$d666], a + jr z, .forceSurfing\0 + ld a, [$d35e] + cp SEAFOAM_ISLANDS_5 + ld a, $2 + ld [$d668], a + jr z, .forceSurfing\0 + ;force bike riding + ld hl, $d732 + set 5, [hl] + ld a, $1 + ld [$d700], a + ld [$d11a], a + jp ForceBikeOrSurf +.incorrectMap\0 + inc hl +.incorrectY\0 + inc hl + jr .loop\0 +.forceSurfing\0 + ld a, $2 + ld [$d700], a + ld [$d11a], a + jp ForceBikeOrSurf +; 0xc3e6 + +ForcedBikeSurfMaps: ;C3e6 +; map id, y, x +db ROUTE_16,$0A,$11 +db ROUTE_16,$0B,$11 +db ROUTE_18,$08,$21 +db ROUTE_18,$09,$21 +db SEAFOAM_ISLANDS_4,$07,$12 +db SEAFOAM_ISLANDS_4,$07,$13 +db SEAFOAM_ISLANDS_5,$0E,$04 +db SEAFOAM_ISLANDS_5,$0E,$05 +db $FF ;end +; 0xc3ff + +INCBIN "baserom.gbc",$C3FF,$C766-$C3FF + ld hl, TilesetsHeadPtr INCBIN "baserom.gbc",$C769,$C7BE-$C769 -- cgit v1.2.3 From 18f52b7cdcf957ff7c7eab902a8e90d7cf0935e9 Mon Sep 17 00:00:00 2001 From: xeons Date: Fri, 30 Mar 2012 21:55:29 -0500 Subject: fix a few things I did wrong hg-commit-id: 919adffe4381 --- extras/gbz80disasm.py | 3 +-- main.asm | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index ae8f0f6f..80d169e5 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -604,8 +604,7 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): bank_id = 0 if original_offset > 0x8000: bank_id = original_offset / 0x4000 - #print "bank id is: " + str(bank_id) - print "Function{0:x}:".format(original_offset); + print "bank id is: " + str(bank_id) last_hl_address = None #for when we're scanning the main map script last_a_address = None diff --git a/main.asm b/main.asm index da5f5fad..7fd3affe 100644 --- a/main.asm +++ b/main.asm @@ -10810,35 +10810,35 @@ CheckForceBikeOrSurf: ; C38B ld hl, $D732 bit 5, [hl] ret nz - ld hl, ForcedBikeSurfMaps + ld hl, ForcedBikeOrSurfMaps ld a, [W_YCOORD] ld b, a ld a, [W_XCOORD] ld c, a ld a, [W_CURMAP] ld d, a -.loop\0 +.loop\@ ld a, [hli] cp $ff ret z ;if we reach FF then it's not part of the list cp d ;compare to current map - jr nz, .incorrectMap\0 + jr nz, .incorrectMap\@ ld a, [hli] cp b ;compare y-coord - jr nz, .incorrectY\0 + jr nz, .incorrectY\@ ld a, [hli] cp c ;compare x-coord - jr nz, .loop\0 ; incorrect x-coord, check next item + jr nz, .loop\@ ; incorrect x-coord, check next item ld a, [W_CURMAP] cp SEAFOAM_ISLANDS_4 ld a, $2 ld [$d666], a - jr z, .forceSurfing\0 + jr z, .forceSurfing\@ ld a, [$d35e] cp SEAFOAM_ISLANDS_5 ld a, $2 ld [$d668], a - jr z, .forceSurfing\0 + jr z, .forceSurfing\@ ;force bike riding ld hl, $d732 set 5, [hl] @@ -10846,19 +10846,19 @@ CheckForceBikeOrSurf: ; C38B ld [$d700], a ld [$d11a], a jp ForceBikeOrSurf -.incorrectMap\0 +.incorrectMap\@ inc hl -.incorrectY\0 +.incorrectY\@ inc hl - jr .loop\0 -.forceSurfing\0 + jr .loop\@ +.forceSurfing\@ ld a, $2 ld [$d700], a ld [$d11a], a jp ForceBikeOrSurf ; 0xc3e6 -ForcedBikeSurfMaps: ;C3e6 +ForcedBikeOrSurfMaps: ;C3e6 ; map id, y, x db ROUTE_16,$0A,$11 db ROUTE_16,$0B,$11 -- cgit v1.2.3 From 3870ca7703c8d152e6b849925c9eef333414929d Mon Sep 17 00:00:00 2001 From: xeons Date: Sat, 7 Apr 2012 00:24:45 +0100 Subject: disassembled and named some general functions hg-commit-id: 16b81dc4ca99 --- main.asm | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/main.asm b/main.asm index 7fd3affe..df3dc81e 100644 --- a/main.asm +++ b/main.asm @@ -6900,7 +6900,22 @@ LoadHpBarAndStatusTilePatterns: ; 36C0 ld bc,(BANK(HpBarAndStatusGraphics) << 8 | $1e) jp CopyVideoData ; if LCD is on, transfer during V-blank -INCBIN "baserom.gbc",$36E0,$3739 - $36E0 +;Fills memory range with the specified byte. +;input registers a = fill_byte, bc = length, hl = address +FillMemory: ;36E0 + push de + ld d, a +.loop\@ + ld a, d + ldi [hl], a + dec bc + ld a, b + or c + jr nz, .loop\@ + pop de + ret + +INCBIN "baserom.gbc",$36EB,$3739 - $36EB DelayFrames: ; 3739 ; wait n frames, where n is the value in c @@ -7932,7 +7947,24 @@ Predef: ; 3E6D ld [$2000],a ret -INCBIN "baserom.gbc",$3E94,$4000 - $3E94 +;loads hl from cc4f, de from cc51, and bc from cc53 +Load16BitRegisters: ;3e94 + ld a, [$cc4f] + ld h, a + ld a, [$cc50] + ld l, a + ld a, [$cc51] + ld d, a + ld a, [$cc52] + ld e, a + ld a, [$cc53] + ld b, a + ld a, [$cc54] + ld c, a + ret +; 0x3ead + +INCBIN "baserom.gbc",$3EAD,$4000 - $3EAD SECTION "bank1",DATA,BANK[$1] -- cgit v1.2.3