Skip to content

Commit

Permalink
Identify the remaining (non-mobile) uses of another WRAM union
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Oct 29, 2020
1 parent ea426a8 commit bcc0d63
Show file tree
Hide file tree
Showing 21 changed files with 259 additions and 199 deletions.
2 changes: 1 addition & 1 deletion data/text/common_3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _LinkAbnormalMonText::

_LinkAskTradeForText::
text "Trade @"
text_ram wd004
text_ram wBufferTrademonNick
text_start
line "for @"
text_ram wStringBuffer1
Expand Down
4 changes: 2 additions & 2 deletions docs/bugs_and_glitches.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,15 @@ This bug affects Attract, Curse, Foresight, Mean Look, Mimic, Nightmare, Spider

```diff
.got_mon
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld hl, wPartyMonNicknames
call GetNick
ld a, MON_HP
call GetBeatupMonLocation
ld a, [hli]
or [hl]
jp z, .beatup_fail ; fainted
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld c, a
ld a, [wCurBattleMon]
- ; BUG: this can desynchronize link battles
Expand Down
24 changes: 12 additions & 12 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7438,13 +7438,13 @@ AnimateExpBar:
jp nc, .finish

ldh a, [hProduct + 3]
ld [wd004], a
ld [wExperienceGained + 2], a
push af
ldh a, [hProduct + 2]
ld [wd003], a
ld [wExperienceGained + 1], a
push af
xor a
ld [wd002], a
ld [wExperienceGained], a
xor a ; PARTYMON
ld [wMonType], a
predef CopyMonToTempMon
Expand All @@ -7456,10 +7456,10 @@ AnimateExpBar:
call CalcExpBar
push bc
ld hl, wTempMonExp + 2
ld a, [wd004]
ld a, [wExperienceGained + 2]
add [hl]
ld [hld], a
ld a, [wd003]
ld a, [wExperienceGained + 1]
adc [hl]
ld [hld], a
jr nc, .NoOverflow
Expand Down Expand Up @@ -8788,7 +8788,7 @@ AddLastLinkBattleToLinkRecord:
.FindOpponentAndAppendRecord:
ld b, NUM_LINK_BATTLE_RECORDS
ld hl, sLinkBattleRecord1End - 1
ld de, wd002
ld de, wLinkBattleRecordBuffer
.loop3
push bc
push de
Expand Down Expand Up @@ -8817,16 +8817,16 @@ AddLastLinkBattleToLinkRecord:
add b
add b
ld e, a
ld d, $0
ld hl, wd002
ld d, 0
ld hl, wLinkBattleRecordBuffer
add hl, de
push hl
ld a, c
add c
add c
ld e, a
ld d, $0
ld hl, wd002
ld d, 0
ld hl, wLinkBattleRecordBuffer
add hl, de
ld d, h
ld e, l
Expand Down Expand Up @@ -8858,7 +8858,7 @@ AddLastLinkBattleToLinkRecord:
ld hl, sLinkBattleRecord
call AddNTimes
push hl
ld de, wd002
ld de, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
pop hl
Expand All @@ -8872,7 +8872,7 @@ AddLastLinkBattleToLinkRecord:
push hl
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
ld hl, wd002
ld hl, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
pop de
call CopyBytes
Expand Down
20 changes: 10 additions & 10 deletions engine/battle/move_effects/beat_up.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BattleCommand_BeatUp:
call DelayFrames
xor a
ld [wPlayerRolloutCount], a
ld [wd002], a
ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .got_mon

Expand All @@ -23,18 +23,18 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wPartyCount]
sub b
ld [wd002], a
ld [wCurBeatUpPartyMon], a

.got_mon
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld hl, wPartyMonNicknames
call GetNick
ld a, MON_HP
call GetBeatupMonLocation
ld a, [hli]
or [hl]
jp z, .beatup_fail ; fainted
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld c, a
ld a, [wCurBattleMon]
; BUG: this can desynchronize link battles
Expand Down Expand Up @@ -88,7 +88,7 @@ BattleCommand_BeatUp:

xor a
ld [wEnemyRolloutCount], a
ld [wd002], a
ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .enemy_got_mon

Expand All @@ -97,7 +97,7 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wOTPartyCount]
sub b
ld [wd002], a
ld [wCurBeatUpPartyMon], a

.enemy_got_mon
ld a, [wBattleMode]
Expand All @@ -112,7 +112,7 @@ BattleCommand_BeatUp:
and a
jr nz, .link_or_tower

ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld c, a
ld b, 0
ld hl, wOTPartySpecies
Expand All @@ -123,7 +123,7 @@ BattleCommand_BeatUp:
jr .got_enemy_nick

.link_or_tower
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld hl, wOTPartyMonNicknames
ld bc, NAME_LENGTH
call AddNTimes
Expand All @@ -137,7 +137,7 @@ BattleCommand_BeatUp:
or [hl]
jp z, .beatup_fail

ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
ld b, a
ld a, [wCurOTMon]
cp b
Expand Down Expand Up @@ -217,7 +217,7 @@ GetBeatupMonLocation:
ld hl, wOTPartyMon1Species

.got_species
ld a, [wd002]
ld a, [wCurBeatUpPartyMon]
add hl, bc
call GetPartyLocation
pop bc
Expand Down
2 changes: 1 addition & 1 deletion engine/events/print_unown_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ RotateUnownFrontpic:
ld a, b
ld [hli], a
push hl
ld hl, wd003
ld hl, wPrintedUnownTileSource + 1
call .CountSetBit
pop hl
ld a, b
Expand Down
10 changes: 5 additions & 5 deletions engine/events/prof_oaks_pc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ Rate:
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
call CountSetBits
ld [wd002], a
ld [wTempPokedexSeenCount], a
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
ld [wd003], a
ld [wTempPokedexCaughtCount], a

; print appropriate rating
call .UpdateRatingBuffers
ld hl, OakPCText3
call PrintText
call JoyWaitAorB
ld a, [wd003]
ld a, [wTempPokedexCaughtCount]
ld hl, OakRatings
call FindOakRating
push de
Expand All @@ -57,10 +57,10 @@ Rate:

.UpdateRatingBuffers:
ld hl, wStringBuffer3
ld de, wd002
ld de, wTempPokedexSeenCount
call .UpdateRatingBuffer
ld hl, wStringBuffer4
ld de, wd003
ld de, wTempPokedexCaughtCount
call .UpdateRatingBuffer
ret

Expand Down
6 changes: 3 additions & 3 deletions engine/games/unown_puzzle.asm
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,13 @@ CheckSolvedUnownPuzzle:

RedrawUnownPuzzlePieces:
call GetCurrentPuzzlePieceVTileCorner
ld [wd002], a
ld [wUnownPuzzleCornerTile], a
xor a
call GetUnownPuzzleCoordData ; get pixel positions
ld a, [hli]
ld b, [hl]
ld c, a
ld a, [wd002]
ld a, [wUnownPuzzleCornerTile]
cp $e0
jr z, .NoPiece
ld hl, .OAM_HoldingPiece
Expand All @@ -532,7 +532,7 @@ RedrawUnownPuzzlePieces:
add c
ld [de], a ; x
inc de
ld a, [wd002]
ld a, [wUnownPuzzleCornerTile]
add [hl]
ld [de], a ; tile id
inc hl
Expand Down
29 changes: 15 additions & 14 deletions engine/items/item_effects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2166,11 +2166,12 @@ INCLUDE "data/items/x_stats.asm"
PokeFluteEffect:
ld a, [wBattleMode]
and a
jr nz, .dummy
.dummy
jr nz, .in_battle
; overworld flute code was dummied out here

.in_battle
xor a
ld [wd002], a
ld [wPokeFluteCuredSleep], a

ld b, $ff ^ SLP

Expand All @@ -2193,7 +2194,7 @@ PokeFluteEffect:
and b
ld [hl], a

ld a, [wd002]
ld a, [wPokeFluteCuredSleep]
and a
ld hl, .PlayedFluteText
jp z, PrintText
Expand All @@ -2202,22 +2203,22 @@ PokeFluteEffect:

ld a, [wLowHealthAlarm]
and 1 << DANGER_ON_F
jr nz, .dummy2
.dummy2
jr nz, .dummy
; more code was dummied out here
.dummy
ld hl, .FluteWakeUpText
jp PrintText

.CureSleep:
ld de, PARTYMON_STRUCT_LENGTH
ld c, PARTY_LENGTH

.loop
ld a, [hl]
push af
and SLP
jr z, .not_asleep
ld a, 1
ld [wd002], a
ld a, TRUE
ld [wPokeFluteCuredSleep], a
.not_asleep
pop af
and b
Expand Down Expand Up @@ -2290,7 +2291,7 @@ ItemfinderEffect:

RestorePPEffect:
ld a, [wCurItem]
ld [wd002], a
ld [wTempRestorePPItem], a

.loop
; Party Screen opens to choose on which mon to use the Item
Expand All @@ -2299,14 +2300,14 @@ RestorePPEffect:
jp c, PPRestoreItem_Cancel

.loop2
ld a, [wd002]
ld a, [wTempRestorePPItem]
cp MAX_ELIXER
jp z, Elixer_RestorePPofAllMoves
cp ELIXER
jp z, Elixer_RestorePPofAllMoves

ld hl, RaiseThePPOfWhichMoveText
ld a, [wd002]
ld a, [wTempRestorePPItem]
cp PP_UP
jr z, .ppup
ld hl, RestoreThePPOfWhichMoveText
Expand Down Expand Up @@ -2337,7 +2338,7 @@ RestorePPEffect:
call CopyName1
pop hl

ld a, [wd002]
ld a, [wTempRestorePPItem]
cp PP_UP
jp nz, Not_PP_Up

Expand Down Expand Up @@ -2486,7 +2487,7 @@ RestorePP:
cp b
jr nc, .dont_restore

ld a, [wd002]
ld a, [wTempRestorePPItem]
cp MAX_ELIXER
jr z, .restore_all
cp MAX_ETHER
Expand Down
Loading

0 comments on commit bcc0d63

Please sign in to comment.