diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2018-04-04 23:56:40 -0400 |
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2018-04-04 23:56:40 -0400 |
| commit | 81306889e33c599f8015bc4e653929bb7de00967 (patch) | |
| tree | 7a812968ba565a13ef400cdcb5230e6e8185a1ec /engine/events | |
| parent | 145efc13535fbc9d8ab2786d29209d97aebf0481 (diff) | |
| parent | f750d4f4185529cfb440ac7825d202ebcf160766 (diff) | |
Merge branch 'master' of https://github.com/pret/pokecrystal
Diffstat (limited to 'engine/events')
39 files changed, 552 insertions, 83 deletions
diff --git a/engine/events/basement_key.asm b/engine/events/basement_key.asm index 879c86a34..879c86a34 100755..100644 --- a/engine/events/basement_key.asm +++ b/engine/events/basement_key.asm diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm index d2e3b1c4c..d2e3b1c4c 100755..100644 --- a/engine/events/battle_tower/battle_tower.asm +++ b/engine/events/battle_tower/battle_tower.asm diff --git a/engine/events/battle_tower/trainer_text.asm b/engine/events/battle_tower/trainer_text.asm index c4bcedf64..c4bcedf64 100755..100644 --- a/engine/events/battle_tower/trainer_text.asm +++ b/engine/events/battle_tower/trainer_text.asm diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm index 3e3b16b21..3e3b16b21 100755..100644 --- a/engine/events/bug_contest/contest_2.asm +++ b/engine/events/bug_contest/contest_2.asm diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm index a338e83ec..a338e83ec 100755..100644 --- a/engine/events/bug_contest/judging.asm +++ b/engine/events/bug_contest/judging.asm diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm index f4f36e402..f4f36e402 100755..100644 --- a/engine/events/card_key.asm +++ b/engine/events/card_key.asm diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 99c22f49f..99c22f49f 100755..100644 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm diff --git a/engine/events/checksave.asm b/engine/events/checksave.asm new file mode 100644 index 000000000..2280f0e53 --- /dev/null +++ b/engine/events/checksave.asm @@ -0,0 +1,20 @@ +CheckSave:: ; 4cffe + ld a, BANK(sCheckValue1) ; BANK(sCheckValue2) + call GetSRAMBank + ld a, [sCheckValue1] + ld b, a + ld a, [sCheckValue2] + ld c, a + call CloseSRAM + ld a, b + cp SAVE_CHECK_VALUE_1 + jr nz, .ok + ld a, c + cp SAVE_CHECK_VALUE_2 + jr nz, .ok + ld c, $1 + ret + +.ok + ld c, $0 + ret diff --git a/engine/events/checktime.asm b/engine/events/checktime.asm new file mode 100644 index 000000000..4c7d033ff --- /dev/null +++ b/engine/events/checktime.asm @@ -0,0 +1,19 @@ +CheckTime:: ; c000 + ld a, [wTimeOfDay] + ld hl, .TimeOfDayTable + ld de, 2 + call IsInArray + inc hl + ld c, [hl] + ret c + + xor a + ld c, a + ret + +.TimeOfDayTable: ; c012 + db MORN_F, MORN + db DAY_F, DAY + db NITE_F, NITE + db NITE_F, NITE + db -1 diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm index 4b256da28..4b256da28 100755..100644 --- a/engine/events/daycare.asm +++ b/engine/events/daycare.asm diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm new file mode 100644 index 000000000..5d0482cc4 --- /dev/null +++ b/engine/events/diploma.asm @@ -0,0 +1,93 @@ +_Diploma: ; 1dd702 + call PlaceDiplomaOnScreen + call WaitPressAorB_BlinkCursor + ret +; 1dd709 + +PlaceDiplomaOnScreen: ; 1dd709 + call ClearBGPalettes + call ClearTileMap + call ClearSprites + call DisableLCD + ld hl, DiplomaGFX + ld de, vTiles2 + call Decompress + ld hl, DiplomaPage1Tilemap + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + ld de, .Player + hlcoord 2, 5 + call PlaceString + ld de, .EmptyString + hlcoord 15, 5 + call PlaceString + ld de, wPlayerName + hlcoord 9, 5 + call PlaceString + ld de, .Certification + hlcoord 2, 8 + call PlaceString + call EnableLCD + call WaitBGMap + ld b, SCGB_DIPLOMA + call GetSGBLayout + call SetPalettes + call DelayFrame + ret +; 1dd760 + +.Player: + db "PLAYER@" + +.EmptyString: + db "@" + +.Certification: + db "This certifies" + next "that you have" + next "completed the" + next "new #DEX." + next "Congratulations!" + db "@" +; 1dd7ae + +PrintDiplomaPage2: ; 1dd7ae + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, $7f + call ByteFill + ld hl, DiplomaPage2Tilemap + decoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + ld de, .GameFreak + hlcoord 8, 0 + call PlaceString + ld de, .PlayTime + hlcoord 3, 15 + call PlaceString + hlcoord 12, 15 + ld de, wGameTimeHours + lb bc, 2, 4 + call PrintNum + ld [hl], $67 ; colon + inc hl + ld de, wGameTimeMinutes + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 + call PrintNum + ret +; 1dd7f0 + +.PlayTime: db "PLAY TIME@" +.GameFreak: db "GAME FREAK@" +; 1dd805 + +DiplomaGFX: ; 1dd805 +INCBIN "gfx/diploma/diploma.2bpp.lz" + +DiplomaPage1Tilemap: ; 1ddc4b +INCBIN "gfx/diploma/page1.tilemap" + +DiplomaPage2Tilemap: ; 1dddb3 +INCBIN "gfx/diploma/page2.tilemap" diff --git a/engine/events/elevator.asm b/engine/events/elevator.asm index bcad170d4..bcad170d4 100755..100644 --- a/engine/events/elevator.asm +++ b/engine/events/elevator.asm diff --git a/engine/events/engine_flags.asm b/engine/events/engine_flags.asm new file mode 100644 index 000000000..acda9ede7 --- /dev/null +++ b/engine/events/engine_flags.asm @@ -0,0 +1,86 @@ +EngineFlagAction:: ; 80430 +; Do action b on engine flag de +; +; b = 0: reset flag +; = 1: set flag +; > 1: check flag, result in c +; +; Setting/resetting does not return a result. + + +; 16-bit flag ids are considered invalid, but it's nice +; to know that the infrastructure is there. + + ld a, d + cp 0 + jr z, .ceiling + jr c, .read ; cp 0 can't set carry! + jr .invalid + +; There are only $a2 engine flags, so +; anything beyond that is invalid too. + +.ceiling + ld a, e + cp NUM_ENGINE_FLAGS + jr c, .read + +; Invalid flags are treated as flag 00. + +.invalid + xor a + ld e, a + ld d, a + +; Get this flag's location. + +.read + ld hl, EngineFlags +; location + add hl, de + add hl, de +; bit + add hl, de + +; location + ld e, [hl] + inc hl + ld d, [hl] + inc hl +; bit + ld c, [hl] + +; What are we doing with this flag? + + ld a, b + cp 1 + jr c, .reset ; b = 0 + jr z, .set ; b = 1 + +; Return the given flag in c. +.check + ld a, [de] + and c + ld c, a + ret + +; Set the given flag. +.set + ld a, [de] + or c + ld [de], a + ret + +; Reset the given flag. +.reset + ld a, c + cpl ; AND all bits except the one in question + ld c, a + ld a, [de] + and c + ld [de], a + ret +; 80462 + + +INCLUDE "data/engine_flags.asm" diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 2fc30d25c..2fc30d25c 100755..100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm diff --git a/engine/events/loadfishinggfx.asm b/engine/events/fishing_gfx.asm index 3d3ab0ba0..3d3ab0ba0 100644 --- a/engine/events/loadfishinggfx.asm +++ b/engine/events/fishing_gfx.asm diff --git a/engine/events/forced_movement.asm b/engine/events/forced_movement.asm index 2d03659ff..2d03659ff 100755..100644 --- a/engine/events/forced_movement.asm +++ b/engine/events/forced_movement.asm diff --git a/engine/events/haircut.asm b/engine/events/haircut.asm new file mode 100644 index 000000000..0e4400235 --- /dev/null +++ b/engine/events/haircut.asm @@ -0,0 +1,82 @@ +BillsGrandfather: ; 73f7 + farcall SelectMonFromParty + jr c, .cancel + ld a, [wCurPartySpecies] + ld [wScriptVar], a + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + jp CopyPokemonName_Buffer1_Buffer3 + +.cancel + xor a + ld [wScriptVar], a + ret + +YoungerHaircutBrother: ; 7413 + ld hl, HappinessData_YoungerHaircutBrother + jr HaircutOrGrooming + +OlderHaircutBrother: ; 7418 + ld hl, HappinessData_OlderHaircutBrother + jr HaircutOrGrooming + +DaisysGrooming: ; 741d + ld hl, HappinessData_DaisysGrooming + ; fallthrough + +HaircutOrGrooming: ; 7420 + push hl + farcall SelectMonFromParty + pop hl + jr c, .nope + ld a, [wCurPartySpecies] + cp EGG + jr z, .egg + push hl + call GetCurNick + call CopyPokemonName_Buffer1_Buffer3 + pop hl + call Random +; Bug: Subtracting $ff from $ff fails to set c. +; This can result in overflow into the next data array. +; In the case of getting a grooming from Daisy, we bleed +; into CopyPokemonName_Buffer1_Buffer3, which passes +; $d0 to ChangeHappiness and returns $73 to the script. +; The end result is that there is a 0.4% chance your +; Pokemon's happiness will not change at all. +.loop + sub [hl] + jr c, .ok + inc hl + inc hl + inc hl + jr .loop + +.ok + inc hl + ld a, [hli] + ld [wScriptVar], a + ld c, [hl] + call ChangeHappiness + ret + +.nope + xor a + ld [wScriptVar], a + ret + +.egg + ld a, 1 + ld [wScriptVar], a + ret + +INCLUDE "data/events/happiness_probabilities.asm" + +CopyPokemonName_Buffer1_Buffer3: ; 746e + ld hl, wStringBuffer1 + ld de, wStringBuffer3 + ld bc, MON_NAME_LENGTH + jp CopyBytes + +DummyPredef1: ; 747a + ret diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm index b6b547aae..b6b547aae 100755..100644 --- a/engine/events/halloffame.asm +++ b/engine/events/halloffame.asm diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm index 998e7e07a..998e7e07a 100755..100644 --- a/engine/events/happiness_egg.asm +++ b/engine/events/happiness_egg.asm diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm index 955449280..955449280 100755..100644 --- a/engine/events/heal_machine_anim.asm +++ b/engine/events/heal_machine_anim.asm diff --git a/engine/events/itemfinder.asm b/engine/events/itemfinder.asm index 71aaa5b69..71aaa5b69 100755..100644 --- a/engine/events/itemfinder.asm +++ b/engine/events/itemfinder.asm diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm index 6f2aa2d1f..6f2aa2d1f 100755..100644 --- a/engine/events/magnet_train.asm +++ b/engine/events/magnet_train.asm diff --git a/engine/events/misc_scripts.asm b/engine/events/misc_scripts.asm index b79889f72..b79889f72 100755..100644 --- a/engine/events/misc_scripts.asm +++ b/engine/events/misc_scripts.asm diff --git a/engine/events/mom_phone.asm b/engine/events/mom_phone.asm index de19a3674..de19a3674 100755..100644 --- a/engine/events/mom_phone.asm +++ b/engine/events/mom_phone.asm diff --git a/engine/events/money.asm b/engine/events/money.asm new file mode 100644 index 000000000..585c85618 --- /dev/null +++ b/engine/events/money.asm @@ -0,0 +1,221 @@ +GiveMoney:: ; 15fd7 + ld a, 3 + call AddMoney + ld bc, MaxMoney + ld a, 3 + call CompareMoney + jr z, .not_maxed_out + jr c, .not_maxed_out + ld hl, MaxMoney + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + scf + ret + +.not_maxed_out + and a + ret +; 15ff7 + +MaxMoney: ; 15ff7 + dt MAX_MONEY +; 15ffa + + +TakeMoney:: ; 15ffa + ld a, 3 + call SubtractMoney + jr nc, .okay + ; leave with 0 money + xor a + ld [de], a + inc de + ld [de], a + inc de + ld [de], a + scf + ret + +.okay + and a + ret +; 1600b + +CompareMoney:: ; 1600b + ld a, 3 +CompareFunds: ; 1600d +; a: number of bytes +; bc: start addr of amount (big-endian) +; de: start addr of account (big-endian) + push hl + push de + push bc + ld h, b + ld l, c + ld c, 0 + ld b, a +.loop1 + dec a + jr z, .done + inc de + inc hl + jr .loop1 + +.done + and a +.loop2 + ld a, [de] + sbc [hl] + jr z, .okay + inc c + +.okay + dec de + dec hl + dec b + jr nz, .loop2 + jr c, .set_carry + ld a, c + and a + jr .skip_carry + +.set_carry + ld a, 1 + and a + scf +.skip_carry + pop bc + pop de + pop hl + ret +; 16035 + +SubtractMoney: ; 16035 + ld a, 3 +SubtractFunds: ; 16037 +; a: number of bytes +; bc: start addr of amount (big-endian) +; de: start addr of account (big-endian) + push hl + push de + push bc + ld h, b + ld l, c + ld b, a + ld c, 0 +.loop + dec a + jr z, .done + inc de + inc hl + jr .loop + +.done + and a +.loop2 + ld a, [de] + sbc [hl] + ld [de], a + dec de + dec hl + dec b + jr nz, .loop2 + pop bc + pop de + pop hl + ret +; 16053 + +AddMoney: ; 16053 + ld a, 3 +AddFunds: ; 16055 +; a: number of bytes +; bc: start addr of amount (big-endian) +; de: start addr of account (big-endian) + push hl + push de + push bc + + ld h, b + ld l, c + ld b, a +.loop1 + dec a + jr z, .done + inc de + inc hl + jr .loop1 + +.done + and a +.loop2 + ld a, [de] + adc [hl] + ld [de], a + dec de + dec hl + dec b + jr nz, .loop2 + + pop bc + pop de + pop hl + ret +; 1606f + +GiveCoins:: ; 1606f + ld a, 2 + ld de, wCoins + call AddFunds + ld a, 2 + ld bc, .maxcoins + call CompareFunds + jr c, .not_maxed + ld hl, .maxcoins + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + scf + ret + +.not_maxed + and a + ret +; 1608d + +.maxcoins ; 1608d + bigdw MAX_COINS +; 1608f + + +TakeCoins:: ; 1608f + ld a, 2 + ld de, wCoins + call SubtractFunds + jr nc, .okay + ; leave with 0 coins + xor a + ld [de], a + inc de + ld [de], a + scf + ret + +.okay + and a + ret +; 160a1 + +CheckCoins:: ; 160a1 + ld a, 2 + ld de, wCoins + jp CompareFunds +; 160a9 diff --git a/engine/events/npc_trade.asm b/engine/events/npc_trade.asm index d3991a28c..d3991a28c 100755..100644 --- a/engine/events/npc_trade.asm +++ b/engine/events/npc_trade.asm diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index f9d67f0bd..f9d67f0bd 100755..100644 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm diff --git a/engine/events/play_slow_cry.asm b/engine/events/play_slow_cry.asm new file mode 100644 index 000000000..1f27a7ca4 --- /dev/null +++ b/engine/events/play_slow_cry.asm @@ -0,0 +1,31 @@ +PlaySlowCry: ; fb841 + ld a, [wScriptVar] + call LoadCry + jr c, .done + + ld hl, wCryPitch + ld a, [hli] + ld h, [hl] + ld l, a + ld bc, -$140 + add hl, bc + ld a, l + ld [wCryPitch], a + ld a, h + ld [wCryPitch + 1], a + ld hl, wCryLength + ld a, [hli] + ld h, [hl] + ld l, a + ld bc, $60 + add hl, bc + ld a, l + ld [wCryLength], a + ld a, h + ld [wCryLength + 1], a + farcall _PlayCry + call WaitSFX + +.done + ret +; fb877 diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm index 5ea094db9..5ea094db9 100755..100644 --- a/engine/events/poisonstep.asm +++ b/engine/events/poisonstep.asm diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index 42284aeab..42284aeab 100755..100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm diff --git a/engine/events/pokepic.asm b/engine/events/pokepic.asm index e11c45f9b..e11c45f9b 100755..100644 --- a/engine/events/pokepic.asm +++ b/engine/events/pokepic.asm diff --git a/engine/events/print_photo.asm b/engine/events/print_photo.asm index d8350a530..d8350a530 100755..100644 --- a/engine/events/print_photo.asm +++ b/engine/events/print_photo.asm diff --git a/engine/events/prof_oaks_pc.asm b/engine/events/prof_oaks_pc.asm index b80efe75b..b80efe75b 100755..100644 --- a/engine/events/prof_oaks_pc.asm +++ b/engine/events/prof_oaks_pc.asm diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm index 2cb5e37a1..2cb5e37a1 100755..100644 --- a/engine/events/sacred_ash.asm +++ b/engine/events/sacred_ash.asm diff --git a/engine/events/specials_2.asm b/engine/events/shuckle.asm index 9a83b982b..99fcd7924 100755..100644 --- a/engine/events/specials_2.asm +++ b/engine/events/shuckle.asm @@ -140,86 +140,3 @@ ReturnShuckle: ; 737e ld a, SHUCKIE_FAINTED ld [wScriptVar], a ret - -BillsGrandfather: ; 73f7 - farcall SelectMonFromParty - jr c, .cancel - ld a, [wCurPartySpecies] - ld [wScriptVar], a - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - jp CopyPokemonName_Buffer1_Buffer3 - -.cancel - xor a - ld [wScriptVar], a - ret - -YoungerHaircutBrother: ; 7413 - ld hl, HappinessData_YoungerHaircutBrother - jr HaircutOrGrooming - -OlderHaircutBrother: ; 7418 - ld hl, HappinessData_OlderHaircutBrother - jr HaircutOrGrooming - -DaisysGrooming: ; 741d - ld hl, HappinessData_DaisysGrooming - ; fallthrough - -HaircutOrGrooming: ; 7420 - push hl - farcall SelectMonFromParty - pop hl - jr c, .nope - ld a, [wCurPartySpecies] - cp EGG - jr z, .egg - push hl - call GetCurNick - call CopyPokemonName_Buffer1_Buffer3 - pop hl - call Random -; Bug: Subtracting $ff from $ff fails to set c. -; This can result in overflow into the next data array. -; In the case of getting a grooming from Daisy, we bleed -; into CopyPokemonName_Buffer1_Buffer3, which passes -; $d0 to ChangeHappiness and returns $73 to the script. -; The end result is that there is a 0.4% chance your -; Pokemon's happiness will not change at all. -.loop - sub [hl] - jr c, .ok - inc hl - inc hl - inc hl - jr .loop - -.ok - inc hl - ld a, [hli] - ld [wScriptVar], a - ld c, [hl] - call ChangeHappiness - ret - -.nope - xor a - ld [wScriptVar], a - ret - -.egg - ld a, 1 - ld [wScriptVar], a - ret - -INCLUDE "data/events/happiness_probabilities.asm" - -CopyPokemonName_Buffer1_Buffer3: ; 746e - ld hl, wStringBuffer1 - ld de, wStringBuffer3 - ld bc, MON_NAME_LENGTH - jp CopyBytes - -DummyPredef1: ; 747a - ret diff --git a/engine/events/squirtbottle.asm b/engine/events/squirtbottle.asm index f6ab00951..f6ab00951 100755..100644 --- a/engine/events/squirtbottle.asm +++ b/engine/events/squirtbottle.asm diff --git a/engine/events/sweet_scent.asm b/engine/events/sweet_scent.asm index 509d9775d..509d9775d 100755..100644 --- a/engine/events/sweet_scent.asm +++ b/engine/events/sweet_scent.asm diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm index 6d55004f4..6d55004f4 100755..100644 --- a/engine/events/treemons.asm +++ b/engine/events/treemons.asm diff --git a/engine/events/whiteout.asm b/engine/events/whiteout.asm index 4bf656055..4bf656055 100755..100644 --- a/engine/events/whiteout.asm +++ b/engine/events/whiteout.asm |
