From 7213916cccb5b62c71fee301531e49160defb2df Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 14 Jun 2013 01:09:23 -0400 Subject: [PATCH 1/7] DrawIntroPlayerPic --- main.asm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/main.asm b/main.asm index d2ad9097e..d25453e16 100644 --- a/main.asm +++ b/main.asm @@ -5130,9 +5130,7 @@ OakSpeech: ; 0x5f99 call ClearTileMap xor a ld [CurPartySpecies], a - ld a, $22 - ld hl, $4874 - rst $8 + callba DrawIntroPlayerPic ld b, $1c call GetSGBLayout call $616a @@ -13124,7 +13122,53 @@ GetPlayerIcon: ; 8832c ret ; 8833e -INCBIN "baserom.gbc", $8833e, $88ec9 - $8833e + +INCBIN "baserom.gbc", $8833e, $88874 - $8833e + + +DrawIntroPlayerPic: ; 88874 +; Draw the player pic at (6,4). + +; Get class + ld e, 0 + ld a, [PlayerGender] + bit 0, a + jr z, .GotClass + ld e, 1 +.GotClass + ld a, e + ld [TrainerClass], a + +; Load pic + ld de, ChrisPic + ld a, [PlayerGender] + bit 0, a + jr z, .GotPic + ld de, KrisPic +.GotPic + ld hl, VTiles2 + ld b, BANK(ChrisPic) + ld c, $31 + call $f82 + +; Draw + xor a + ld [$ffad], a + hlcoord 6, 4 + ld bc, $0707 + ld a, $13 + call Predef + ret +; 888a9 + + +ChrisPic: ; 888a9 +INCBIN "baserom.gbc", $888a9, $88bb9 - $888a9 +; 88bb9 + +KrisPic: ; 88bb9 +INCBIN "baserom.gbc", $88bb9, $88ec9 - $88bb9 +; 88ec9 GetKrisBackpic: ; 88ec9 From 2f21ff4ef5f4b26801463db720be32f55cfaf7d4 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 14 Jun 2013 02:19:35 -0400 Subject: [PATCH 2/7] gbz80disasm: only use gbhw/hram constants >= 0xff00 --- extras/gbz80disasm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index c1d129c82..4975108a9 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -583,7 +583,7 @@ def find_label(local_address, bank_id=0): if local_address in wram_labels.keys(): return wram_labels[local_address][-1] for constants in [gbhw_constants, hram_constants]: - if local_address in constants.keys(): + if local_address in constants.keys() and local_address >= 0xff00: return constants[local_address] return None From ef6767f1a9bf1f29c009103c355b7c91cd33297a Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 14 Jun 2013 02:29:46 -0400 Subject: [PATCH 3/7] OakSpeech formatting --- main.asm | 92 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/main.asm b/main.asm index d25453e16..7958c1bf6 100644 --- a/main.asm +++ b/main.asm @@ -5079,11 +5079,13 @@ INCBIN "baserom.gbc", $4000, $5f99 - $4000 OakSpeech: ; 0x5f99 ld a, $24 ld hl, $4672 - rst $8 + rst FarCall call $04dd call ClearTileMap - ld de, $002b + + ld de, MUSIC_ROUTE_30 call StartMusic + call $04a3 call $04b6 xor a @@ -5091,49 +5093,62 @@ OakSpeech: ; 0x5f99 ld a, POKEMON_PROF ld [TrainerClass], a call $619c + ld b, $1c call GetSGBLayout call $616a + ld hl, OakText1 call PrintText call $04b6 call ClearTileMap + ld a, $c2 ld [$cf60], a ld [CurPartySpecies], a call $3856 - ld hl, $c4f6 + + hlcoord 6, 4 call $3786 + xor a ld [$d123], a ld [$d124], a + ld b, $1c call GetSGBLayout call $6182 + ld hl, OakText2 call PrintText ld hl, OakText4 call PrintText call $04b6 call ClearTileMap + xor a ld [CurPartySpecies], a ld a, POKEMON_PROF ld [TrainerClass], a call $619c + ld b, $1c call GetSGBLayout call $616a + ld hl, OakText5 call PrintText call $04b6 call ClearTileMap + xor a ld [CurPartySpecies], a callba DrawIntroPlayerPic + ld b, $1c call GetSGBLayout call $616a + ld hl, OakText6 call PrintText call NamePlayer @@ -5147,7 +5162,7 @@ OakText1: ; 0x6045 OakText2: ; 0x604a TX_FAR _OakText2 - db 8 + start_asm ld a,WOOPER call $37ce call $3c55 @@ -5175,53 +5190,58 @@ OakText7: ; 0x606f db "@" NamePlayer: ; 0x6074 - ld a, BANK(MovePlayerPicRight) - ld hl, MovePlayerPicRight - rst $8 - ld a, BANK(ShowPlayerNamingChoices) - ld hl, ShowPlayerNamingChoices - rst $8 + callba MovePlayerPicRight + callba ShowPlayerNamingChoices ld a, [$cfa9] dec a - jr z, .asm_6096 ; 0x6084 $10 + jr z, .NewName call $60fa ld a, $2 ld hl, $4c1d - rst $8 - ld a, BANK(MovePlayerPicLeft) - ld hl, MovePlayerPicLeft - rst $8 + rst FarCall + callba MovePlayerPicLeft ret -.asm_6096 - ld b, $1 - ld de, $d47d + +.NewName + ld b, 1 + ld de, PlayerName ld a, $4 ld hl, $56c1 - rst $8 + rst FarCall + call $04b6 - call $0fc8 + call ClearTileMap + call $0e5f call WaitBGMap + xor a - ld [$d108], a + ld [CurPartySpecies], a ld a, $22 ld hl, $4874 - rst $8 - ld b, $1c - call $3340 - call $04f0 - ld hl, $d47d - ld de, $60d3 - ld a, [$d472] - bit 0, a - jr z, .asm_60cf ; 0x60ca $3 - ld de, $60de -.asm_60cf - call $2ef9 - ret -; 0x60d3 + rst FarCall -INCBIN "baserom.gbc", $60d3, $617c - $60d3 + ld b, $1c + call GetSGBLayout + call $04f0 + + ld hl, PlayerName + ld de, .Chris + ld a, [PlayerGender] + bit 0, a + jr z, .asm_60cf + ld de, .Kris +.asm_60cf + call InitString + ret + +.Chris + db "CHRIS@@@@@@" +.Kris + db "KRIS@@@@@@@" +; 60e9 + +INCBIN "baserom.gbc", $60e9, $617c - $60e9 IntroFadePalettes: ; 0x617c db %01010100 From dfb241619203a2b1b9eb389055cbe0ff31baa7a0 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 15 Jun 2013 14:11:50 -0400 Subject: [PATCH 4/7] gbz80disasm: fix labels outside of banks 0 and 1 --- extras/gbz80disasm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index 4975108a9..2dc57e579 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -577,7 +577,7 @@ def find_label(local_address, bank_id=0): if local_address < 0x8000: for label_entry in all_labels: - if label_entry["address"] == local_address: + if label_entry["address"] & 0x7fff == local_address: if label_entry["bank"] == bank_id or label_entry["bank"] == 0: return label_entry["label"] if local_address in wram_labels.keys(): From a4235e11bfe379f410f07aaab3b8a887a5d917ed Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 16 Jun 2013 01:22:15 -0400 Subject: [PATCH 5/7] symfile: fix address handling --- extras/sym.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/sym.py b/extras/sym.py index 445abb155..cc580fa67 100644 --- a/extras/sym.py +++ b/extras/sym.py @@ -10,7 +10,7 @@ def make_sym_from_json(filename = '../pokecrystal.sym', j = 'labels.json'): # todo: delete and remake labels.json at runtime with open(filename, 'w') as sym: for label in json.load(open(j)): - sym.write('{0:x}:{1:x} {2}\n'.format(label['bank'], label['address']&0x3fff, label['label'])) + sym.write('{0:x}:{1:x} {2}\n'.format(label['bank'], label['address']%0x4000 + (0x4000 if label['bank'] else 0), label['label'])) def make_sym_from_mapfile(filename = '../pokecrystal.sym', mapfile = '../mapfile.txt'): From 869de91bd55f9bbd764744e7918476584ce5d768 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 17 Jun 2013 18:19:45 -0400 Subject: [PATCH 6/7] LostBattle and HalveMoney --- battle_constants.asm | 1 + main.asm | 136 ++++++++++++++++++++++++++++++++++++++++++- text/battle.asm | 4 +- wram.asm | 5 ++ 4 files changed, 142 insertions(+), 4 deletions(-) diff --git a/battle_constants.asm b/battle_constants.asm index ee450c984..a1858da1f 100644 --- a/battle_constants.asm +++ b/battle_constants.asm @@ -40,6 +40,7 @@ TRAINER_BATTLE EQU 2 ; battle types BATTLETYPE_NORMAL EQU $00 +BATTLETYPE_CANLOSE EQU $01 BATTLETYPE_TUTORIAL EQU $03 BATTLETYPE_FISH EQU $04 BATTLETYPE_ROAMING EQU $05 diff --git a/main.asm b/main.asm index 7958c1bf6..b582b29c4 100644 --- a/main.asm +++ b/main.asm @@ -6983,7 +6983,34 @@ BoxNameInputUpper: db "- ? ! ♂ ♀ / . , &" db "lower DEL END " -INCBIN "baserom.gbc", $11e5d, $125cd - $11e5d + +INCBIN "baserom.gbc", $11e5d, $12513 - $11e5d + + +HalveMoney: ; 12513 + +; Empty function... + ld a, $41 + ld hl, $60c7 + rst FarCall + +; Halve the player's money. + ld hl, Money + ld a, [hl] + srl a + ld [hli], a + ld a, [hl] + rra + ld [hli], a + ld a, [hl] + rra + ld [hl], a + ret +; 12527 + + +INCBIN "baserom.gbc", $12527, $125cd - $12527 + OpenMenu: ; 0x125cd call $1fbf @@ -9383,7 +9410,112 @@ KantoGymLeaders: db BLUE db $ff -INCBIN "baserom.gbc", $3d14e, $3ddc2 - $3d14e + +INCBIN "baserom.gbc", $3d14e, $3d38e - $3d14e + + +LostBattle: ; 3d38e + ld a, 1 + ld [BattleEnded], a + + ld a, [$cfc0] + bit 0, a + jr nz, .asm_3d3bd + + ld a, [BattleType] + cp BATTLETYPE_CANLOSE + jr nz, .asm_3d3e3 + +; Remove the enemy from the screen. + hlcoord 0, 0 + ld bc, $0815 + call ClearBox + call $6bd8 + + ld c, 40 + call DelayFrames + + ld a, [$c2cc] + bit 0, a + jr nz, .asm_3d3bc + call $3718 +.asm_3d3bc + ret + +.asm_3d3bd +; Remove the enemy from the screen. + hlcoord 0, 0 + ld bc, $0815 + call ClearBox + call $6bd8 + + ld c, 40 + call DelayFrames + + call $6dd1 + ld c, 2 + ld a, $47 + ld hl, $4000 + rst FarCall + call $0a80 + call ClearTileMap + call WhiteBGMap + ret + +.asm_3d3e3 + ld a, [InLinkBattle] + and a + jr nz, .LostLinkBattle + +; Greyscale + ld b, 0 + call GetSGBLayout + call $32f9 + jr .end + +.LostLinkBattle + call UpdateEnemyMonInParty + call $4f35 + jr nz, .asm_3d40a + ld hl, TiedAgainstText + ld a, [$d0ee] + and $c0 + add 2 + ld [$d0ee], a + jr .asm_3d412 + +.asm_3d40a + ld hl, LostAgainstText + call $52f1 + jr z, .asm_3d417 + +.asm_3d412 + call FarBattleTextBox + +.end + scf + ret + +.asm_3d417 +; Remove the enemy from the screen. + hlcoord 0, 0 + ld bc, $0815 + call ClearBox + call $6bd8 + + ld c, 40 + call DelayFrames + + ld c, $3 + ld a, $13 + ld hl, $6a0a + rst FarCall + scf + ret +; 3d432 + + +INCBIN "baserom.gbc", $3d432, $3ddc2 - $3d432 ld hl, RecoveredUsingText jp $3ad5 diff --git a/text/battle.asm b/text/battle.asm index cab8fc4a2..dae8c1c3b 100644 --- a/text/battle.asm +++ b/text/battle.asm @@ -176,7 +176,7 @@ BattleText_0x809da: ; 0x809da db "was defeated!", $58 ; 0x809eb -BattleText_0x809eb: ; 0x809eb +TiedAgainstText: ; 0x809eb db $0, "Tied against", $4f db $3f, "!", $58 ; 0x809fc @@ -219,7 +219,7 @@ BattleText_0x80a93: ; 0x80a93 db "good #MON!", $58 ; 0x80ab9 -BattleText_0x80ab9: ; 0x80ab9 +LostAgainstText: ; 0x80ab9 db $0, "Lost against", $4f db $3f, "!", $58 ; 0x80aca diff --git a/wram.asm b/wram.asm index 0f7096ebf..b1204bb8c 100644 --- a/wram.asm +++ b/wram.asm @@ -778,6 +778,11 @@ LastEnemyMove: ; c71c ds 1 +SECTION "battle",BSS[$c734] +BattleEnded: ; c734 + ds 1 + + SECTION "overworldmap",BSS[$c800] OverworldMap: ; c800 ds 1300 From 20c0c0e233a7599b1f21e05ddefbd67d0d17504c Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 17 Jun 2013 18:31:11 -0400 Subject: [PATCH 7/7] BadgeStatBoosts --- main.asm | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/main.asm b/main.asm index b582b29c4..3dd69c930 100644 --- a/main.asm +++ b/main.asm @@ -10136,7 +10136,99 @@ CheckUnownLetter: ; 3eb75 ; 3ebc7 -INCBIN "baserom.gbc", $3ebc7, $3edd8 - $3ebc7 +INCBIN "baserom.gbc", $3ebc7, $3ed4a - $3ebc7 + + +BadgeStatBoosts: ; 3ed4a +; Raise BattleMon stats depending on which badges have been obtained. + +; Every other badge boosts a stat, starting from the first. + +; ZephyrBadge: Attack +; PlainBadge: Speed +; MineralBadge: Defense +; GlacierBadge: Special Attack +; RisingBadge: Special Defense + +; The boosted stats are in order, except PlainBadge and MineralBadge's boosts are swapped. + + ld a, [$cfc0] + and a + ret nz + + ld a, [JohtoBadges] + +; Swap badges 3 (PlainBadge) and 5 (MineralBadge). + ld d, a + and %00000100 + add a + add a + ld b, a + ld a, d + and %00010000 + rrca + rrca + ld c, a + ld a, d + and %11101011 + or b + or c + ld b, a + + ld hl, BattleMonAtk + ld c, 4 +.CheckBadge + ld a, b + srl b + call c, BoostStat + inc hl + inc hl +; Check every other badge. + srl b + dec c + jr nz, .CheckBadge +; And the last one (RisingBadge) too. + srl a + call c, BoostStat + ret +; 3ed7c + + +BoostStat: ; 3ed7c +; Raise stat at hl by 1/8. + + ld a, [hli] + ld d, a + ld e, [hl] + srl d + rr e + srl d + rr e + srl d + rr e + ld a, [hl] + add e + ld [hld], a + ld a, [hl] + adc d + ld [hli], a + +; Cap at 999. + ld a, [hld] + sub 999 % $100 + ld a, [hl] + sbc 999 / $100 + ret c + ld a, 999 / $100 + ld [hli], a + ld a, 999 % $100 + ld [hld], a + ret +; 3ed9f + + +INCBIN "baserom.gbc", $3ed9f, $3edd8 - $3ed9f + BattleRNG: ; 3edd8 ; If the normal RNG is used in a link battle it'll desync.