Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix hack #1

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7ffe941
Fix fast options
TiKevin83 Oct 31, 2023
8f54868
Fix scripted encounter animations before obtaining a pokemon
TiKevin83 Oct 31, 2023
33916b9
inline documentation for fork
TiKevin83 Oct 31, 2023
1a5da8f
Fix poke doll sequence break
TiKevin83 Oct 31, 2023
b6f4d28
Do the bugfix patches as an if def flag
TiKevin83 Nov 1, 2023
5046d68
Add bugfix code for gen 1 miss, gen 1 miss critical, and critical rates
TiKevin83 Nov 2, 2023
45364c6
Simplify bugfix if defs with else
TiKevin83 Nov 2, 2023
8349773
Badge boost related bugfixes
TiKevin83 Nov 2, 2023
84c3b8b
Surge cans bugfix
TiKevin83 Nov 3, 2023
001963c
Fixes for trainer fly and more documentation
TiKevin83 Nov 3, 2023
4915fea
Conditionally remove unused code for trainer fly fixes to compile
TiKevin83 Nov 4, 2023
603e589
Add a flag to block intentional save corruption via power off during …
TiKevin83 Nov 4, 2023
f13ba97
Prevent power off and on defeating random number generation by saving…
TiKevin83 Nov 4, 2023
e89b646
fix some other known bugs
TiKevin83 Nov 4, 2023
cfa14cb
Switch saved rng to luckytyphlosion's xorshift implementation
TiKevin83 Nov 4, 2023
86befae
Fix power off during save flag
TiKevin83 Nov 4, 2023
600d1ba
bugfix the bugfixes
TiKevin83 Nov 5, 2023
b4c91dd
Adjust unused code removal for trainer fly bugfix space, this line is…
TiKevin83 Nov 5, 2023
b44d69b
fixes for pikawalk
TiKevin83 Nov 5, 2023
69da0a8
Refine the pikawalk bugfix behavior
TiKevin83 Nov 5, 2023
70d87f5
Optimizations and documentation improvement
TiKevin83 Nov 5, 2023
9a13315
some cleanup
TiKevin83 Nov 6, 2023
110a3c9
Actually fix fast options
TiKevin83 Nov 7, 2023
8a63067
continuing to port fixes from pokered archives
TiKevin83 Nov 8, 2023
fe3b98a
finish fixing route 17 sign text
TiKevin83 Nov 8, 2023
4be4771
continuing to port fixes from pokered archives
TiKevin83 Nov 8, 2023
5959797
Port more fixes from pret archives
TiKevin83 Nov 8, 2023
1ca0700
fix leaving mr fujis house
TiKevin83 Nov 8, 2023
a79cabc
fix xorshift rng algorithm
TiKevin83 Nov 9, 2023
1e58b16
remove rdiv bit mix and save full 32 bits of rng state
TiKevin83 Nov 9, 2023
987bb20
Fix accuracy scaling of Rage, Thrash, and Petal Dance
TiKevin83 Nov 11, 2023
8fbd745
actually fix XorshiftRandom
TiKevin83 Nov 12, 2023
7171707
actually fix x item badge boost reapplication
TiKevin83 Nov 12, 2023
2188a81
Fix bugs with healing and switch out text
TiKevin83 Nov 13, 2023
d502a16
Update README.md
TiKevin83 Nov 14, 2023
473c50c
commit v1.0 IPS patch
TiKevin83 Dec 30, 2023
ccd1415
Remove broken substitute change identified in test routing
TiKevin83 Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["donaldhays.rgbds-z80"]
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ ifeq ($(DEBUG),1)
RGBASMFLAGS += -E
endif

ifeq ($(BUGFIX),1)
RGBASMFLAGS += -D _BUGFIX
endif

$(pokeyellow_debug_obj): RGBASMFLAGS += -D _DEBUG
$(pokeyellow_vc_obj): RGBASMFLAGS += -D _YELLOW_VC

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pokémon Yellow [![Build Status][ci-badge]][ci]
# Pokémon Yellow Fort Knox Edition [![Build Status][ci-badge]][ci]

This is a disassembly of Pokémon Yellow.

Expand All @@ -10,6 +10,13 @@ It builds the following ROMs:

To set up the repository, see [**INSTALL.md**](INSTALL.md).

## Fort Knox Edition

This version includes the ability to optionally compile with a set of bugfix patches I'm calling Fort Knox Edition:

`make BUGFIX=1`

Many of these patches are sourced from the research done on [pokered](https://github.com/pret/pokered/wiki/%5BARCHIVED%5D-Bugs-and-Glitches) which is now defunct and archived. Some patches were also written specifically for this project (badge boosts, fast options) and some were collaborations with other Pokemon Speedrun community members including CasualPokePlayer and luckytyphlosion (statistically validated PRNG).

## See also

Expand Down
10 changes: 9 additions & 1 deletion audio/engine_1.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1241,13 +1241,21 @@ Audio1_InitPitchSlideVars:
; This means that the result will be 0x200 greater than it should be if the
; low byte of the current frequency is greater than the low byte of the
; target frequency.
IF DEF(_BUGFIX)
push af
ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
pop af
ld a, [hl]
sbc b
ELSE
ld a, d
sbc b
ld d, a

ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
ld a, [hl]
ENDC
sub d
ld d, a
ld b, 0
Expand Down
7 changes: 6 additions & 1 deletion data/battle_anims/subanimations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,12 @@ Subanim_0Circle_1Square_TossBack:
db FRAMEBLOCK_47, BASECOORD_B0, FRAMEBLOCKMODE_00

Subanim_0CirclesCentering:
subanim SUBANIMTYPE_COORDFLIP, 6 ; should be SUBANIMTYPE_HVFLIP
; fix animation when AI uses double edge
IF DEF(_BUGFIX)
subanim SUBANIMTYPE_HVFLIP, 6
ELSE
subanim SUBANIMTYPE_COORDFLIP, 6
ENDC
db FRAMEBLOCK_44, BASECOORD_64, FRAMEBLOCKMODE_00
db FRAMEBLOCK_45, BASECOORD_65, FRAMEBLOCKMODE_00
db FRAMEBLOCK_46, BASECOORD_66, FRAMEBLOCKMODE_00
Expand Down
21 changes: 16 additions & 5 deletions data/maps/dungeon_maps.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
; GetBattleTransitionID_IsDungeonMap fails to recognize
; VICTORY_ROAD_2F, VICTORY_ROAD_3F, all ROCKET_HIDEOUT maps,
; POKEMON_MANSION_1F, SEAFOAM_ISLANDS_[B1F-B4F], POWER_PLANT,
; DIGLETTS_CAVE, and SILPH_CO_[9-11]F as dungeon maps

; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is equal to one of these maps
DungeonMaps1:
db VIRIDIAN_FOREST
db ROCK_TUNNEL_1F
db SEAFOAM_ISLANDS_1F
db ROCK_TUNNEL_B1F
; fix missing dungeon maps
IF DEF(_BUGFIX)
db POKEMON_MANSION_1F
db VICTORY_ROAD_2F
db VICTORY_ROAD_3F
db POWER_PLANT
db DIGLETTS_CAVE
ENDC
db -1 ; end

; GetBattleTransitionID_IsDungeonMap checks if wCurMap
Expand All @@ -24,4 +27,12 @@ DungeonMaps2:
; SILPH_CO_[2-8]F, POKEMON_MANSION[2F-B1F], SAFARI_ZONE, and
; CERULEAN_CAVE maps, except for SILPH_CO_1F
db SILPH_CO_2F, CERULEAN_CAVE_1F
IF DEF(_BUGFIX)
; SILPH_CO_[9-11]F
db SILPH_CO_9F, SILPH_CO_11F
; SEAFOAM_ISLANDS_[B1F-B4F]
db SEAFOAM_ISLANDS_B1F, SEAFOAM_ISLANDS_B4F
; all ROCKET_HIDEOUT maps
db ROCKET_HIDEOUT_B1F, ROCKET_HIDEOUT_B4F
ENDC
db -1 ; end
4 changes: 4 additions & 0 deletions data/maps/objects/Route17.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Route17_Object:
bg_event 9, 87, 14 ; Route17Text14
bg_event 9, 111, 15 ; Route17Text15
bg_event 9, 141, 16 ; Route17Text16
; fix the sign at Route 16 showing Celadon <-> Fuchsia when read from the front
IF DEF(_BUGFIX)
bg_event 5, -1, 17 ; Route17Text17
ENDC

def_object_events
object_event 12, 19, SPRITE_BIKER, STAY, LEFT, 1, OPP_CUE_BALL, 4
Expand Down
16 changes: 16 additions & 0 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,10 @@ AdjustOAMBlockYPos2:
add b
cp 112
jr c, .skipSettingPreviousEntrysAttribute
; fix swag boulder
IF !DEF(_BUGFIX)
dec hl
ENDC
ld a, 160 ; bug, sets previous OAM entry's attribute
ld [hli], a
.skipSettingPreviousEntrysAttribute
Expand Down Expand Up @@ -1931,7 +1934,11 @@ _AnimationSlideMonOff:
sub 7
; This has the same problem as above, but it has no visible effect because
; the lower right tile is in the first column to slide off the screen.
IF DEF(_BUGFIX)
cp $31
ELSE
cp $30
ENDC
ret c
ld a, " "
ret
Expand Down Expand Up @@ -1969,6 +1976,11 @@ AnimationWavyScreen:
ld c, $ff
ld hl, WavyScreenLineOffsets
.loop
; Fix the wave effect for the top 3 lines of the screen
IF DEF(_BUGFIX)
ld a, [hl]
ldh [hSCX], a
ENDC
push hl
.innerLoop
call WavyScreen_SetSCX
Expand All @@ -1985,6 +1997,10 @@ AnimationWavyScreen:
dec c
jr nz, .loop
xor a
; Fix the wave effect for the top 3 lines of the screen
IF DEF(_BUGFIX)
ldh [hSCX], a
ENDC
ldh [hWY], a
call SaveScreenTilesToBuffer2
call ClearScreen
Expand Down
7 changes: 7 additions & 0 deletions engine/battle/battle_transitions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ GetBattleTransitionID_WildOrTrainer:
ret

GetBattleTransitionID_CompareLevels:
; This section fixes undefined behavior in the Pikachu cutscene
; Due to not yet having obtained a pokemon
IF DEF(_BUGFIX)
ld a, [wPartyCount]
cp 0
jr z, .highLevelEnemy
ENDC
ld hl, wPartyMon1HP
.faintedLoop
ld a, [hli]
Expand Down
12 changes: 12 additions & 0 deletions engine/battle/common_text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ PlayerMon2Text:
ld b, [hl]
ld a, [de]
sbc b
; original code ignores underflow, if we underflow, print default text
IF DEF(_BUGFIX)
jr c, .gainedHP
ENDC
ldh [hMultiplicand + 1], a
ld a, 25
ldh [hMultiplier], a
Expand Down Expand Up @@ -234,6 +238,14 @@ PlayerMon2Text:
ret c
ld hl, GoodText ; HP went down 70% or more
ret
; fallback to default text for underflow
IF DEF(_BUGFIX)
.gainedHP
pop bc
pop de
ld hl, EnoughText
ret
ENDC

EnoughText:
text_far _EnoughText
Expand Down
Loading