Skip to content

Commit

Permalink
Untangle overworld Pokémon from trainers and possibly more
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanqui committed Dec 4, 2014
1 parent 06c6ca1 commit 7537f87
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 62 deletions.
5 changes: 3 additions & 2 deletions audio.asm
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,10 @@ PlayBattleMusic:: ; 0x90c6
ld a, MUSIC_GYM_LEADER_BATTLE
jr .playSong
.notGymLeaderBattle
ld a, [wIsTrainerBattle]
and a
jr z, .wildBattle
ld a, [W_CUROPPONENT]
cp $c8
jr c, .wildBattle
cp SONY3 + $c8
jr z, .finalBattle
cp LANCE + $c8
Expand Down
4 changes: 3 additions & 1 deletion constants/sprite_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ SPRITE_LYING_OLD_MAN EQU $48
ITEM EQU $80
TRAINER EQU $40

OW_POKEMON EQU $80

BOULDER_MOVEMENT_BYTE_2 EQU $10

; sprite facing directions
SPRITE_FACING_DOWN EQU $00
SPRITE_FACING_UP EQU $04
SPRITE_FACING_LEFT EQU $08
SPRITE_FACING_RIGHT EQU $0C
SPRITE_FACING_RIGHT EQU $0C
11 changes: 0 additions & 11 deletions constants/wram_constants.asm
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@

SPRITEBUFFERSIZE EQU 7*7 * 8 ; 7 * 7 (tiles) * 8 (bytes per tile)

; Overload W_GRASSMONS
wd893 EQU $d893 ; W_GRASSMONS + 11
wd896 EQU $d896 ; W_GRASSMONS + 14

; Overload enemy party data
W_WATERRATE EQU $d8a4 ; wEnemyMon1Species
W_WATERMONS EQU $d8a5 ; wEnemyMon1Species + 1

; Overload enemy stat modifiers
wTradeMonNick EQU $cd1e ; wPlayerMonAccuracyMod

18 changes: 9 additions & 9 deletions data/mapObjects/powerplant.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ PowerPlantObject: ; 0x1e3bf (size=135)
db $0 ; signs

db $e ; people
db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, TRAINER | $1, VOLTORB, 40
db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, TRAINER | $2, VOLTORB, 40
db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, TRAINER | $3, VOLTORB, 40
db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, TRAINER | $4, ELECTRODE, 43
db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, TRAINER | $5, VOLTORB, 40
db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, TRAINER | $6, VOLTORB, 40
db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, TRAINER | $7, ELECTRODE, 43
db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, TRAINER | $8, VOLTORB, 40
db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, TRAINER | $9, ZAPDOS, 50
db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, TRAINER | $1, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, TRAINER | $2, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, TRAINER | $3, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, TRAINER | $4, ELECTRODE, 43 | OW_POKEMON
db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, TRAINER | $5, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, TRAINER | $6, VOLTORB, 40 | OW_POKEMON
db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, TRAINER | $7, ELECTRODE, 43 | OW_POKEMON
db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, TRAINER | $8, VOLTORB, 40 | OW_POKEMON
db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, TRAINER | $9, ZAPDOS, 50 | OW_POKEMON
db SPRITE_BALL, $19 + 4, $7 + 4, $ff, $ff, ITEM | $a, CARBOS
db SPRITE_BALL, $3 + 4, $1c + 4, $ff, $ff, ITEM | $b, HP_UP
db SPRITE_BALL, $3 + 4, $22 + 4, $ff, $ff, ITEM | $c, RARE_CANDY
Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/seafoamislands5.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SeafoamIslands5Object: ; 0x468bc (size=62)
db $3 ; people
db SPRITE_BOULDER, $f + 4, $4 + 4, $ff, $ff, $1 ; person
db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, $ff, $2 ; person
db SPRITE_BIRD, $1 + 4, $6 + 4, $ff, $d0, TRAINER | $3, ARTICUNO, 50
db SPRITE_BIRD, $1 + 4, $6 + 4, $ff, $d0, TRAINER | $3, ARTICUNO, 50 | OW_POKEMON

; warp-to
EVENT_DISP SEAFOAM_ISLANDS_5_WIDTH, $11, $14 ; SEAFOAM_ISLANDS_4
Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/unknowndungeon3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ UnknownDungeon3Object: ; 0x45f36 (size=34)
db $0 ; signs

db $3 ; people
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, TRAINER | $1, MEWTWO, 70
db SPRITE_SLOWBRO, $d + 4, $1b + 4, $ff, $d0, TRAINER | $1, MEWTWO, 70 | OW_POKEMON
db SPRITE_BALL, $9 + 4, $10 + 4, $ff, $ff, ITEM | $2, ULTRA_BALL
db SPRITE_BALL, $1 + 4, $12 + 4, $ff, $ff, ITEM | $3, MAX_REVIVE

Expand Down
2 changes: 1 addition & 1 deletion data/mapObjects/victoryroad2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ VictoryRoad2Object: ; 0x51915 (size=154)
db SPRITE_BLACK_HAIR_BOY_1, $8 + 4, $13 + 4, $ff, $d0, TRAINER | $3, TAMER + $C8, $5
db SPRITE_BLACK_HAIR_BOY_2, $2 + 4, $4 + 4, $ff, $d0, TRAINER | $4, POKEMANIAC + $C8, $6
db SPRITE_BLACK_HAIR_BOY_2, $3 + 4, $1a + 4, $ff, $d2, TRAINER | $5, JUGGLER + $C8, $5
db SPRITE_BIRD, $5 + 4, $b + 4, $ff, $d1, TRAINER | $6, MOLTRES, 50
db SPRITE_BIRD, $5 + 4, $b + 4, $ff, $d1, TRAINER | $6, MOLTRES, 50 | OW_POKEMON
db SPRITE_BALL, $5 + 4, $1b + 4, $ff, $ff, ITEM | $7, TM_17
db SPRITE_BALL, $9 + 4, $12 + 4, $ff, $ff, ITEM | $8, FULL_HEAL
db SPRITE_BALL, $b + 4, $9 + 4, $ff, $ff, ITEM | $9, TM_05
Expand Down
8 changes: 5 additions & 3 deletions data/pokedex_entries.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,8 @@ VictreebelDexEntry: ; 40fd1 (10:4fd1)

MissingNoDexEntry: ; 40fe5 (10:4fe5)
db "???@"
db 10 ; 1.0 m
db 100 ; 10.0 kg
db 0,"コメント さくせいちゅう@" ; コメント作成中 (Comment to be written)
db 0, 0
dw 0000
text "No entry"
dex
db "@"
6 changes: 3 additions & 3 deletions engine/battle/1c.asm
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ BattleTransitions: ; 709d2 (1c:49d2)
dw BattleTransition_Split ; %111

GetBattleTransitionID_WildOrTrainer: ; 709e2 (1c:49e2)
ld a, [W_CUROPPONENT]
cp $c8
jr nc, .trainer
ld a, [wIsTrainerBattle]
and a
jr nz, .trainer
res 0, c
ret
.trainer
Expand Down
12 changes: 9 additions & 3 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,8 @@ TrainerBattleVictory: ; 3c696 (f:4696)
ld de, wPlayerMoney + 2
ld hl, wd07b
ld c, $3
xor a
ld [wIsTrainerBattle], a
predef_jump AddBCDPredef

MoneyForWinningText: ; 3c6e4 (f:46e4)
Expand Down Expand Up @@ -1198,6 +1200,8 @@ ChooseNextMon: ; 3c7d8 (f:47d8)
; called when player is out of usable mons.
; prints approriate lose message, sets carry flag if player blacked out (special case for initial rival fight)
HandlePlayerBlackOut: ; 3c837 (f:4837)
xor a
ld [wIsTrainerBattle], a
ld a, [W_ISLINKBATTLE]
cp $4
jr z, .notSony1Battle
Expand Down Expand Up @@ -6769,9 +6773,11 @@ asm_3ef3d: ; 3ef3d (f:6f3d)
push af
res 1, [hl]
callab Func_525af
ld a, [wEnemyMonSpecies2]
sub $c8
jp c, InitWildBattle
ld a, [wIsTrainerBattle]
and a
jp z, InitWildBattle
ld a, [wEnemyMonSpecies2]
sub $c8
ld [W_TRAINERCLASS], a
call GetTrainerInformation
callab ReadTrainer
Expand Down
48 changes: 42 additions & 6 deletions engine/menu/debug_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ DebugMenu:
call PrintDebugMenuItem
ld de,DebugMenuItem2
call PrintDebugMenuItem
ld de,DebugMenuItem3
call PrintDebugMenuItem
ld de,DebugMenuItem4
call PrintDebugMenuItem
ld de,DebugMenuItem5
call PrintDebugMenuItem
ld de,DebugMenuItem6
call PrintDebugMenuItem
ld hl,wd730
res 6,[hl] ; turn pauses between printing letters back on
Expand Down Expand Up @@ -73,6 +81,12 @@ DebugMenu:
cp a, 1
jp z, DebugMenuFly
cp a, 2
jp z, DebugMenu251
cp a, 3
jp z, DebugMenuMasterB

CloseDebugMenu::
ret
Expand All @@ -91,12 +105,13 @@ PrintDebugMenuItem: ; 71bb (1:71bb)
add hl,de
ret

DebugMenuItem0:
db "WTW@"
DebugMenuItem1:
db "FLY@"
DebugMenuItem2:
db "LV.100@"
DebugMenuItem0: db "WTW@"
DebugMenuItem1: db "FLY@"
DebugMenuItem2: db "Wild 251@"
DebugMenuItem3: db "MasterB@"
DebugMenuItem4: db "-@"
DebugMenuItem5: db "-@"
DebugMenuItem6: db "-@"

DebugMenuWTW:
ld a, 1
Expand All @@ -110,3 +125,24 @@ DebugMenuFly:
ld [hl], a
call ChooseFlyDestination
ret

DebugMenu251:
ld hl, wd72d
res 4, [hl]
ld hl, wd72e
res 4, [hl]
ld a, 251
ld [W_CUROPPONENT], a
ld a, 5
ld [W_CURENEMYLVL], a
ret

DebugMenuMasterB:
ld hl, wNumBagItems
inc [hl]
inc hl
ld a, 1
ld [hli], a
ld a, 99
ld [hl], a
ret
20 changes: 15 additions & 5 deletions home.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2381,9 +2381,8 @@ EndTrainerBattle:: ; 3275 (0:3275)
ld c, a
ld b, $1
call TrainerFlagAction ; flag trainer as fought
ld a, [W_ENEMYMONORTRAINERCLASS]
cp $c8
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld a, [wIsTrainerBattle]
jr nz, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld hl, W_MISSABLEOBJECTLIST
ld de, $2
ld a, [wSpriteIndex]
Expand All @@ -2393,6 +2392,8 @@ EndTrainerBattle:: ; 3275 (0:3275)
ld [wcc4d], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
xor a
ld [wIsTrainerBattle], a
ld hl, wd730
bit 4, [hl]
res 4, [hl]
Expand All @@ -2418,9 +2419,10 @@ InitBattleEnemyParameters:: ; 32d7 (0:32d7)
ld a, [wEngagedTrainerClass]
ld [W_CUROPPONENT], a ; wd059
ld [W_ENEMYMONORTRAINERCLASS], a
cp $c8
ld a, [wIsTrainerBattle]
and a
jr z, .noTrainer
ld a, [wEngagedTrainerSet] ; wcd2e
jr c, .noTrainer
ld [W_TRAINERNO], a ; wd05d
ret
.noTrainer
Expand Down Expand Up @@ -2519,6 +2521,14 @@ EngageMapTrainer:: ; 336a (0:336a)
ld a, [hli] ; load trainer class
ld [wEngagedTrainerClass], a
ld a, [hl] ; load trainer mon set
bit 7, a
jr nz, .pokemon
ld [wEnemyMonAttackMod], a ; wcd2e
ld a, 1
ld [wIsTrainerBattle], a
jp PlayTrainerMusic
.pokemon
and $7F
ld [wEnemyMonAttackMod], a ; wcd2e
jp PlayTrainerMusic

Expand Down
29 changes: 13 additions & 16 deletions wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ wc0ee:: ds 1
wc0ef:: ds 1
wc0f0:: ds 1
wc0f1:: ds 1
wc0f2:: ds 12 ;14
wc0f2:: ds 11 ;14

wHaltAudio:: ds 1
wSFXDontWait:: ds 1
wIsTrainerBattle:: ds 1

SECTION "Sprite State Data", WRAM0[$c100]

Expand Down Expand Up @@ -2031,6 +2032,16 @@ W_GRASSRATE:: ; d887
W_GRASSMONS:: ; d888
ds 20

; Overload W_GRASSMONS
wd893:: ds 3
wd896:: ds 3

; Overload enemy party data
W_WATERRATE:: ds 1
W_WATERMONS:: ds 20

; Overload enemy stat modifiers
wTradeMonNick:: ds 11

wEnemyPartyCount:: ds 1 ; d89c
wEnemyPartyMons:: ds PARTY_LENGTH + 1 ; d89d
Expand Down Expand Up @@ -2099,21 +2110,7 @@ wBoxMonOT:: ds 11 * MONS_PER_BOX ; dd2a
wBoxMonNicks:: ds 11 * MONS_PER_BOX ; de06
wBoxMonNicksEnd:: ; dee2

SECTION "Splash", WRAMX, BANK[1]
wVWFLetterNum:: ds 1
wVWFChar:: ds 1
wVWFTileLoc:: ds 2
wVWFFirstTileNum:: ds 1
wVWFCurTileNum:: ds 1
wVWFCurTileCol:: ds 1
wVWFNumTilesUsed:: ds 1
wVWFCharWidth:: ds 1

wVWFBuildArea0:: ds 8
wVWFBuildArea1:: ds 8
wVWFBuildArea2:: ds 8
wVWFBuildArea3:: ds 8
wVWFCopyArea:: ds $10
SECTION "Empty", WRAMX, BANK[1]


SECTION "Stack", WRAMX[$dfff], BANK[1]
Expand Down

0 comments on commit 7537f87

Please sign in to comment.