mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Merge pull request #713 from Rangi42/master
Miscellaneous fixes, including one for the Pokédex design flaw by ax6
This commit is contained in:
commit
9cd59db9ae
@ -78,6 +78,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b
|
|||||||
- [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites)
|
- [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites)
|
||||||
- [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pokémon-species)
|
- [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pokémon-species)
|
||||||
- [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution)
|
- [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution)
|
||||||
|
- [`ReadObjectEvents` overflows into `wObjectMasks`](#readobjectevents-overflows-into-wobjectmasks)
|
||||||
- [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1)
|
- [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1)
|
||||||
- [`BattleAnimCmd_ClearObjs` only clears the first 6⅔ objects](#battleanimcmd_clearobjs-only-clears-the-first-6-objects)
|
- [`BattleAnimCmd_ClearObjs` only clears the first 6⅔ objects](#battleanimcmd_clearobjs-only-clears-the-first-6-objects)
|
||||||
|
|
||||||
@ -341,7 +342,7 @@ As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") impli
|
|||||||
call GetBattleVarAddr
|
call GetBattleVarAddr
|
||||||
push af
|
push af
|
||||||
set SUBSTATUS_CONFUSED, [hl]
|
set SUBSTATUS_CONFUSED, [hl]
|
||||||
+ ld a, [hBattleTurn]
|
+ ldh a, [hBattleTurn]
|
||||||
+ and a
|
+ and a
|
||||||
+ ld hl, wEnemyConfuseCount
|
+ ld hl, wEnemyConfuseCount
|
||||||
+ jr z, .set_confuse_count
|
+ jr z, .set_confuse_count
|
||||||
@ -349,7 +350,7 @@ As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") impli
|
|||||||
+.set_confuse_count
|
+.set_confuse_count
|
||||||
+ call BattleRandom
|
+ call BattleRandom
|
||||||
+ and %11
|
+ and %11
|
||||||
+ add a, 2
|
+ add 2
|
||||||
+ ld [hl], a
|
+ ld [hl], a
|
||||||
ld a, BATTLE_VARS_MOVE_ANIM
|
ld a, BATTLE_VARS_MOVE_ANIM
|
||||||
call GetBattleVarAddr
|
call GetBattleVarAddr
|
||||||
@ -2145,6 +2146,39 @@ This supports up to six entries.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## `ReadObjectEvents` overflows into `wObjectMasks`
|
||||||
|
|
||||||
|
**Fix:** Edit `ReadObjectEvents` in [home/map.asm](https://github.com/pret/pokecrystal/blob/master/home/map.asm):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
-; get NUM_OBJECTS - [wCurMapObjectEventCount]
|
||||||
|
+; get NUM_OBJECTS - [wCurMapObjectEventCount] - 1
|
||||||
|
ld a, [wCurMapObjectEventCount]
|
||||||
|
ld c, a
|
||||||
|
- ld a, NUM_OBJECTS ; - 1
|
||||||
|
+ ld a, NUM_OBJECTS - 1
|
||||||
|
sub c
|
||||||
|
jr z, .skip
|
||||||
|
- ; jr c, .skip
|
||||||
|
+ jr c, .skip
|
||||||
|
|
||||||
|
; could have done "inc hl" instead
|
||||||
|
ld bc, 1
|
||||||
|
add hl, bc
|
||||||
|
-; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
|
||||||
|
-; Bleeds into wObjectMasks due to a bug. Uncomment the above code to fix.
|
||||||
|
ld bc, MAPOBJECT_LENGTH
|
||||||
|
.loop
|
||||||
|
ld [hl], 0
|
||||||
|
inc hl
|
||||||
|
ld [hl], -1
|
||||||
|
dec hl
|
||||||
|
add hl, bc
|
||||||
|
dec a
|
||||||
|
jr nz, .loop
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## `ClearWRAM` only clears WRAM bank 1
|
## `ClearWRAM` only clears WRAM bank 1
|
||||||
|
|
||||||
**Fix:** Edit `ClearWRAM` in [home/init.asm](https://github.com/pret/pokecrystal/blob/master/home/init.asm):
|
**Fix:** Edit `ClearWRAM` in [home/init.asm](https://github.com/pret/pokecrystal/blob/master/home/init.asm):
|
||||||
|
@ -513,7 +513,124 @@ PokedexShow_GetDexEntryBank:
|
|||||||
db BANK("Pokedex Entries 193-251")
|
db BANK("Pokedex Entries 193-251")
|
||||||
```
|
```
|
||||||
|
|
||||||
**Fix:** Use `dba` instead of `dw` in `PokedexDataPointerTable`. Then edit [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) to contain a single copy of the `PokedexDataPointerTable` lookup code, updated to work with 3-byte `dba` entries and get the bank from the first entry byte. Delete the three separate lookup routines and use the new one (placed in [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) so it can be called from any bank.)
|
**Fix:**
|
||||||
|
|
||||||
|
Use `dba` instead of `dw` in `PokedexDataPointerTable`.
|
||||||
|
|
||||||
|
Delete `GetPokedexEntryBank` and `PokedexShow_GetDexEntryBank`. You can also delete `NUM_DEX_ENTRY_BANKS` from [constants/pokemon_data_constants.asm](https://github.com/pret/pokecrystal/blob/master/constants/pokemon_data_constants.asm).
|
||||||
|
|
||||||
|
Edit [engine/pokedex/pokedex_2.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokedex/pokedex_2.asm):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
GetDexEntryPointer:
|
||||||
|
; return dex entry pointer b:de
|
||||||
|
push hl
|
||||||
|
ld hl, PokedexDataPointerTable
|
||||||
|
ld a, b
|
||||||
|
dec a
|
||||||
|
ld d, 0
|
||||||
|
ld e, a
|
||||||
|
add hl, de
|
||||||
|
add hl, de
|
||||||
|
- ld e, [hl]
|
||||||
|
- inc hl
|
||||||
|
- ld d, [hl]
|
||||||
|
- push de
|
||||||
|
- rlca
|
||||||
|
- rlca
|
||||||
|
- maskbits NUM_DEX_ENTRY_BANKS
|
||||||
|
- ld hl, .PokedexEntryBanks
|
||||||
|
- ld d, 0
|
||||||
|
- ld e, a
|
||||||
|
- add hl, de
|
||||||
|
- ld b, [hl]
|
||||||
|
- pop de
|
||||||
|
+ add hl, de
|
||||||
|
+ ; b = bank
|
||||||
|
+ ld a, [hli]
|
||||||
|
+ ld b, a
|
||||||
|
+ ; de = address
|
||||||
|
+ ld a, [hli]
|
||||||
|
+ ld e, a
|
||||||
|
+ ld d, [hl]
|
||||||
|
pop hl
|
||||||
|
ret
|
||||||
|
-
|
||||||
|
-.PokedexEntryBanks:
|
||||||
|
- db BANK("Pokedex Entries 001-064")
|
||||||
|
- db BANK("Pokedex Entries 065-128")
|
||||||
|
- db BANK("Pokedex Entries 129-192")
|
||||||
|
- db BANK("Pokedex Entries 193-251")
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit [engine/items/item_effects.asm](https://github.com/pret/pokecrystal/blob/master/engine/items/item_effects.asm):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
HeavyBallMultiplier:
|
||||||
|
; subtract 20 from catch rate if weight < 102.4 kg
|
||||||
|
; else add 0 to catch rate if weight < 204.8 kg
|
||||||
|
; else add 20 to catch rate if weight < 307.2 kg
|
||||||
|
; else add 30 to catch rate if weight < 409.6 kg
|
||||||
|
; else add 40 to catch rate (never happens)
|
||||||
|
ld a, [wEnemyMonSpecies]
|
||||||
|
ld hl, PokedexDataPointerTable
|
||||||
|
dec a
|
||||||
|
ld e, a
|
||||||
|
ld d, 0
|
||||||
|
add hl, de
|
||||||
|
add hl, de
|
||||||
|
+ add hl, de
|
||||||
|
+ ; d = bank, hl = address
|
||||||
|
+ ld a, BANK(PokedexDataPointerTable)
|
||||||
|
+ call GetFarByte
|
||||||
|
+ push af
|
||||||
|
+ inc hl
|
||||||
|
ld a, BANK(PokedexDataPointerTable)
|
||||||
|
call GetFarHalfword
|
||||||
|
+ pop de
|
||||||
|
|
||||||
|
.SkipText:
|
||||||
|
- call GetPokedexEntryBank
|
||||||
|
+ ld a, d
|
||||||
|
call GetFarByte
|
||||||
|
inc hl
|
||||||
|
cp "@"
|
||||||
|
jr nz, .SkipText
|
||||||
|
|
||||||
|
- call GetPokedexEntryBank
|
||||||
|
+ ld a, d
|
||||||
|
push bc
|
||||||
|
inc hl
|
||||||
|
inc hl
|
||||||
|
call GetFarHalfword
|
||||||
|
```
|
||||||
|
|
||||||
|
And edit [engine/pokegear/radio.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokegear/radio.asm):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
PokedexShow2:
|
||||||
|
ld a, [wCurPartySpecies]
|
||||||
|
dec a
|
||||||
|
ld hl, PokedexDataPointerTable
|
||||||
|
ld c, a
|
||||||
|
ld b, 0
|
||||||
|
add hl, bc
|
||||||
|
add hl, bc
|
||||||
|
+ add hl, bc
|
||||||
|
+ b = bank
|
||||||
|
+ ld a, BANK(PokedexDataPointerTable)
|
||||||
|
+ call GetFarByte
|
||||||
|
+ ld b, a
|
||||||
|
+ inc hl
|
||||||
|
+ ; hl = address
|
||||||
|
ld a, BANK(PokedexDataPointerTable)
|
||||||
|
call GetFarHalfword
|
||||||
|
- call PokedexShow_GetDexEntryBank
|
||||||
|
+ ld a, b
|
||||||
|
push af
|
||||||
|
push hl
|
||||||
|
call CopyDexEntryPart1
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Identical sine wave code and data is repeated five times
|
## Identical sine wave code and data is repeated five times
|
||||||
|
@ -126,7 +126,7 @@ INCLUDE "data/events/bug_contest_winners.asm"
|
|||||||
|
|
||||||
BugContest_GetPlayersResult:
|
BugContest_GetPlayersResult:
|
||||||
ld hl, wBugContestThirdPlaceWinnerID
|
ld hl, wBugContestThirdPlaceWinnerID
|
||||||
ld de, - BUG_CONTESTANT_SIZE
|
ld de, -BUG_CONTESTANT_SIZE
|
||||||
ld b, 3 ; 3rd, 2nd, or 1st
|
ld b, 3 ; 3rd, 2nd, or 1st
|
||||||
.loop
|
.loop
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
|
@ -318,7 +318,7 @@ AddOrSubtractY:
|
|||||||
ld hl, wCurSpriteOAMFlags
|
ld hl, wCurSpriteOAMFlags
|
||||||
bit OAM_Y_FLIP, [hl]
|
bit OAM_Y_FLIP, [hl]
|
||||||
jr z, .ok
|
jr z, .ok
|
||||||
; 8 - a
|
; -8 - a
|
||||||
add $8
|
add $8
|
||||||
xor $ff
|
xor $ff
|
||||||
inc a
|
inc a
|
||||||
@ -333,7 +333,7 @@ AddOrSubtractX:
|
|||||||
ld hl, wCurSpriteOAMFlags
|
ld hl, wCurSpriteOAMFlags
|
||||||
bit OAM_X_FLIP, [hl]
|
bit OAM_X_FLIP, [hl]
|
||||||
jr z, .ok
|
jr z, .ok
|
||||||
; 8 - a
|
; -8 - a
|
||||||
add $8
|
add $8
|
||||||
xor $ff
|
xor $ff
|
||||||
inc a
|
inc a
|
||||||
|
@ -2318,7 +2318,7 @@ Function56cd:
|
|||||||
jr c, .ok3
|
jr c, .ok3
|
||||||
sub BG_MAP_WIDTH
|
sub BG_MAP_WIDTH
|
||||||
.ok3
|
.ok3
|
||||||
ldh [hUsedSpriteIndex], a
|
ldh [hCurSpriteXCoord], a
|
||||||
ld a, [wPlayerBGMapOffsetY]
|
ld a, [wPlayerBGMapOffsetY]
|
||||||
ld e, a
|
ld e, a
|
||||||
ld hl, OBJECT_SPRITE_Y_OFFSET
|
ld hl, OBJECT_SPRITE_Y_OFFSET
|
||||||
@ -2347,7 +2347,7 @@ Function56cd:
|
|||||||
jr c, .ok6
|
jr c, .ok6
|
||||||
sub BG_MAP_HEIGHT
|
sub BG_MAP_HEIGHT
|
||||||
.ok6
|
.ok6
|
||||||
ldh [hUsedSpriteTile], a
|
ldh [hCurSpriteYCoord], a
|
||||||
ld hl, OBJECT_PALETTE
|
ld hl, OBJECT_PALETTE
|
||||||
add hl, bc
|
add hl, bc
|
||||||
bit BIG_OBJECT_F, [hl]
|
bit BIG_OBJECT_F, [hl]
|
||||||
@ -2360,18 +2360,18 @@ Function56cd:
|
|||||||
ld e, a
|
ld e, a
|
||||||
.ok7
|
.ok7
|
||||||
ld a, d
|
ld a, d
|
||||||
ldh [hFFBF], a
|
ldh [hCurSpriteXPixel], a
|
||||||
.loop
|
.loop
|
||||||
ldh a, [hFFBF]
|
ldh a, [hCurSpriteXPixel]
|
||||||
ld d, a
|
ld d, a
|
||||||
ldh a, [hUsedSpriteTile]
|
ldh a, [hCurSpriteYCoord]
|
||||||
add e
|
add e
|
||||||
dec a
|
dec a
|
||||||
cp SCREEN_HEIGHT
|
cp SCREEN_HEIGHT
|
||||||
jr nc, .ok9
|
jr nc, .ok9
|
||||||
ld b, a
|
ld b, a
|
||||||
.next
|
.next
|
||||||
ldh a, [hUsedSpriteIndex]
|
ldh a, [hCurSpriteXCoord]
|
||||||
add d
|
add d
|
||||||
dec a
|
dec a
|
||||||
cp SCREEN_WIDTH
|
cp SCREEN_WIDTH
|
||||||
@ -2856,7 +2856,7 @@ InitSprites:
|
|||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
and $ff ^ (1 << 7)
|
and $ff ^ (1 << 7)
|
||||||
ldh [hFFC1], a
|
ldh [hCurSpriteTile], a
|
||||||
xor a
|
xor a
|
||||||
bit 7, [hl]
|
bit 7, [hl]
|
||||||
jr nz, .skip1
|
jr nz, .skip1
|
||||||
@ -2885,7 +2885,7 @@ InitSprites:
|
|||||||
jr z, .skip4
|
jr z, .skip4
|
||||||
or PRIORITY
|
or PRIORITY
|
||||||
.skip4
|
.skip4
|
||||||
ldh [hFFC2], a
|
ldh [hCurSpriteOAMFlags], a
|
||||||
ld hl, OBJECT_SPRITE_X
|
ld hl, OBJECT_SPRITE_X
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
@ -2896,7 +2896,7 @@ InitSprites:
|
|||||||
ld e, a
|
ld e, a
|
||||||
ld a, [wPlayerBGMapOffsetX]
|
ld a, [wPlayerBGMapOffsetX]
|
||||||
add e
|
add e
|
||||||
ldh [hFFBF], a
|
ldh [hCurSpriteXPixel], a
|
||||||
ld hl, OBJECT_SPRITE_Y
|
ld hl, OBJECT_SPRITE_Y
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
@ -2907,7 +2907,7 @@ InitSprites:
|
|||||||
ld e, a
|
ld e, a
|
||||||
ld a, [wPlayerBGMapOffsetY]
|
ld a, [wPlayerBGMapOffsetY]
|
||||||
add e
|
add e
|
||||||
ldh [hFFC0], a
|
ldh [hCurSpriteYPixel], a
|
||||||
ld hl, OBJECT_FACING_STEP
|
ld hl, OBJECT_FACING_STEP
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
@ -2932,19 +2932,19 @@ InitSprites:
|
|||||||
cp LOW(wVirtualOAMEnd)
|
cp LOW(wVirtualOAMEnd)
|
||||||
jr nc, .full
|
jr nc, .full
|
||||||
.addsprite
|
.addsprite
|
||||||
ldh a, [hFFC0]
|
ldh a, [hCurSpriteYPixel]
|
||||||
add [hl]
|
add [hl]
|
||||||
inc hl
|
inc hl
|
||||||
ld [bc], a ; y
|
ld [bc], a ; y
|
||||||
inc c
|
inc c
|
||||||
ldh a, [hFFBF]
|
ldh a, [hCurSpriteXPixel]
|
||||||
add [hl]
|
add [hl]
|
||||||
inc hl
|
inc hl
|
||||||
ld [bc], a ; x
|
ld [bc], a ; x
|
||||||
inc c
|
inc c
|
||||||
ld e, [hl]
|
ld e, [hl]
|
||||||
inc hl
|
inc hl
|
||||||
ldh a, [hFFC1]
|
ldh a, [hCurSpriteTile]
|
||||||
bit ABSOLUTE_TILE_ID_F, e
|
bit ABSOLUTE_TILE_ID_F, e
|
||||||
jr z, .nope1
|
jr z, .nope1
|
||||||
xor a
|
xor a
|
||||||
@ -2956,7 +2956,7 @@ InitSprites:
|
|||||||
ld a, e
|
ld a, e
|
||||||
bit RELATIVE_ATTRIBUTES_F, a
|
bit RELATIVE_ATTRIBUTES_F, a
|
||||||
jr z, .nope2
|
jr z, .nope2
|
||||||
ldh a, [hFFC2]
|
ldh a, [hCurSpriteOAMFlags]
|
||||||
or e
|
or e
|
||||||
.nope2
|
.nope2
|
||||||
and OBP_NUM | X_FLIP | Y_FLIP | PRIORITY
|
and OBP_NUM | X_FLIP | Y_FLIP | PRIORITY
|
||||||
|
@ -596,8 +596,7 @@ ReadObjectEvents::
|
|||||||
ld bc, 1
|
ld bc, 1
|
||||||
add hl, bc
|
add hl, bc
|
||||||
; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
|
; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
|
||||||
; Bleeds into wObjectMasks due to a bug. Uncomment the above subtraction
|
; Bleeds into wObjectMasks due to a bug. Uncomment the above code to fix.
|
||||||
; to fix.
|
|
||||||
ld bc, MAPOBJECT_LENGTH
|
ld bc, MAPOBJECT_LENGTH
|
||||||
.loop
|
.loop
|
||||||
ld [hl], 0
|
ld [hl], 0
|
||||||
|
13
hram.asm
13
hram.asm
@ -95,12 +95,17 @@ NEXTU ; ffb3
|
|||||||
hMGStatusFlags:: db ; ffbc
|
hMGStatusFlags:: db ; ffbc
|
||||||
ENDU ; ffbd
|
ENDU ; ffbd
|
||||||
|
|
||||||
|
UNION
|
||||||
hUsedSpriteIndex:: db ; ffbd
|
hUsedSpriteIndex:: db ; ffbd
|
||||||
hUsedSpriteTile:: db ; ffbe
|
hUsedSpriteTile:: db ; ffbe
|
||||||
hFFBF:: db ; ffbf
|
NEXTU
|
||||||
hFFC0:: db ; ffc0
|
hCurSpriteXCoord:: db ; ffbd
|
||||||
hFFC1:: db ; ffc1
|
hCurSpriteYCoord:: db ; ffbe
|
||||||
hFFC2:: db ; ffc2
|
hCurSpriteXPixel:: db ; ffbf
|
||||||
|
hCurSpriteYPixel:: db ; ffc0
|
||||||
|
hCurSpriteTile:: db ; ffc1
|
||||||
|
hCurSpriteOAMFlags:: db ; ffc2
|
||||||
|
ENDU
|
||||||
|
|
||||||
UNION ; ffc3
|
UNION ; ffc3
|
||||||
hMoneyTemp:: ds 3 ; ffc3
|
hMoneyTemp:: ds 3 ; ffc3
|
||||||
|
Loading…
Reference in New Issue
Block a user