summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluckytyphlosion <alan.rj.huang@gmail.com>2016-05-22 22:11:08 -0400
committerluckytyphlosion <alan.rj.huang@gmail.com>2016-05-22 22:11:08 -0400
commitcc7a16ee5abe95bf20e566baff9679840cb243de (patch)
tree0dc7967452cddd12df5b2b102e10ff038434ad16
parentf3de3a20dfccb8a57cdf9feb860bf1e89a733f50 (diff)
Bank15 misc functions
-rw-r--r--engine/battle/experience.asm42
-rwxr-xr-xengine/menu/diploma.asm113
-rw-r--r--engine/menu/diploma_1.asm17
-rwxr-xr-xengine/overworld/trainers.asm72
-rwxr-xr-xmain.asm26
5 files changed, 92 insertions, 178 deletions
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index 0480bfcb..f43a7354 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -1,4 +1,4 @@
-GainExperience: ; 5524f (15:524f)
+GainExperience: ; 5524f (15:525f)
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z ; return if link battle
@@ -43,17 +43,17 @@ GainExperience: ; 5524f (15:524f)
inc de
jr .nextBaseStat
.maxStatExp ; if the upper byte also overflowed, then we have hit the max stat exp
- ld a, $ff
+ dec a ; a is 0 from previous check
ld [de], a
inc de
ld [de], a
.nextBaseStat
dec c
- jr z, .asm_552a1
+ jr z, .statExpDone
inc de
inc de
jr .gainStatExpLoop
-.asm_552a1
+.statExpDone
xor a
ld [H_MULTIPLICAND], a
ld [H_MULTIPLICAND + 1], a
@@ -233,13 +233,19 @@ GainExperience: ; 5524f (15:524f)
.recalcStatChanges
xor a ; battle mon
ld [wCalculateWhoseStats], a
- callab CalculateModifiedStats
- callab ApplyBurnAndParalysisPenaltiesToPlayer
- callab ApplyBadgeStatBoosts
- callab DrawPlayerHUDAndHPBar
- callab PrintEmptyString
+ ld hl, CalculateModifiedStats
+ call Bankswitch15ToF
+ ld hl, ApplyBurnAndParalysisPenaltiesToPlayer
+ call Bankswitch15ToF
+ ld hl, ApplyBadgeStatBoosts
+ call Bankswitch15ToF
+ ld hl, DrawPlayerHUDAndHPBar
+ call Bankswitch15ToF
+ ld hl, PrintEmptyString
+ call Bankswitch15ToF
call SaveScreenTilesToBuffer1
.printGrewLevelText
+ callabd_ModifyPikachuHappiness PIKAHAPPY_LEVELUP
ld hl, GrewLevelText
call PrintText
xor a ; PLAYER_PARTY_DATA
@@ -291,7 +297,7 @@ GainExperience: ; 5524f (15:524f)
predef_jump FlagActionPredef ; set the fought current enemy flag for the mon that is currently out
; divide enemy base stats, catch rate, and base exp by the number of mons gaining exp
-DivideExpDataByNumMonsGainingExp: ; 5546c (15:546c)
+DivideExpDataByNumMonsGainingExp: ; 5547b (15:547b)
ld a, [wPartyGainExpFlags]
ld b, a
xor a
@@ -325,7 +331,7 @@ DivideExpDataByNumMonsGainingExp: ; 5546c (15:546c)
ret
; multiplies exp by 1.5
-BoostExp: ; 5549f (15:549f)
+BoostExp: ; 554ae (15:54ae)
ld a, [H_QUOTIENT + 2]
ld b, a
ld a, [H_QUOTIENT + 3]
@@ -339,7 +345,11 @@ BoostExp: ; 5549f (15:549f)
ld [H_QUOTIENT + 2], a
ret
-GainedText: ; 554b2 (15:54b2)
+Bankswitch15ToF: ; 554c1 (15:54c1)
+ ld b, BANK(BattleCore)
+ jp Bankswitch
+
+GainedText: ; 554c6 (15:54c6)
TX_FAR _GainedText
TX_ASM
ld a, [wBoostExpByExpAll]
@@ -353,20 +363,20 @@ GainedText: ; 554b2 (15:54b2)
ld hl, BoostedText
ret
-WithExpAllText: ; 554cb (15:54cb)
+WithExpAllText: ; 554df (15:54df)
TX_FAR _WithExpAllText
TX_ASM
ld hl, ExpPointsText
ret
-BoostedText: ; 554d4 (15:54d4)
+BoostedText: ; 554e8 (15:54e8)
TX_FAR _BoostedText
-ExpPointsText: ; 554d8 (15:54d8)
+ExpPointsText: ; 554ec (15:54ec)
TX_FAR _ExpPointsText
db "@"
-GrewLevelText: ; 554dd (15:54dd)
+GrewLevelText: ; 554f1 (15:54f1)
TX_FAR _GrewLevelText
db $0b
db "@"
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
deleted file mode 100755
index cb6e6e03..00000000
--- a/engine/menu/diploma.asm
+++ /dev/null
@@ -1,113 +0,0 @@
-DisplayDiploma: ; 566e2 (15:66e2)
- call SaveScreenTilesToBuffer2
- call GBPalWhiteOutWithDelay3
- call ClearScreen
- xor a
- ld [wUpdateSpritesEnabled], a
- ld hl, wd730
- set 6, [hl]
- call DisableLCD
- ld hl, CircleTile
- ld de, vChars2 + $700
- ld bc, $0010
- ld a, BANK(CircleTile)
- call FarCopyData
- coord hl, 0, 0
- lb bc, 16, 18
- predef Diploma_TextBoxBorder
- ld hl, DiplomaTextPointersAndCoords
- ld c, $5
-.asm_56715
- push bc
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- push hl
- ld h, [hl]
- ld l, a
- call PlaceString
- pop hl
- inc hl
- pop bc
- dec c
- jr nz, .asm_56715
- coord hl, 10, 4
- ld de, wPlayerName
- call PlaceString
- callba DrawPlayerCharacter
-
-; Move the player 33 pixels right and set the priority bit so he appears
-; behind the background layer.
- ld hl, wOAMBuffer + $01
- lb bc, $80, $28
-.adjustPlayerGfxLoop
- ld a, [hl] ; X
- add 33
- ld [hli], a
- inc hl
- ld a, b
- ld [hli], a ; attributes
- inc hl
- dec c
- jr nz, .adjustPlayerGfxLoop
-
- call EnableLCD
- callba LoadTrainerInfoTextBoxTiles
- ld b, SET_PAL_GENERIC
- call RunPaletteCommand
- call Delay3
- call GBPalNormal
- ld a, $90
- ld [rOBP0], a
- call WaitForTextScrollButtonPress
- ld hl, wd730
- res 6, [hl]
- call GBPalWhiteOutWithDelay3
- call RestoreScreenTilesAndReloadTilePatterns
- call Delay3
- jp GBPalNormal
-
-UnusedPlayerNameLengthFunc: ; 56777 (15:6777)
-; Unused function that does a calculation involving the length of the player's
-; name.
- ld hl, wPlayerName
- ld bc, $ff00
-.loop
- ld a, [hli]
- cp "@"
- ret z
- dec c
- jr .loop
-
-DiplomaTextPointersAndCoords: ; 56784 (15:6784)
- dw DiplomaText
- dwCoord 5, 2
- dw DiplomaPlayer
- dwCoord 3, 4
- dw DiplomaEmptyText
- dwCoord 15, 4
- dw DiplomaCongrats
- dwCoord 2, 6
- dw DiplomaGameFreak
- dwCoord 9, 16
-
-DiplomaText:
- db $70,"Diploma",$70,"@"
-
-DiplomaPlayer:
- db "Player@"
-
-DiplomaEmptyText:
- db "@"
-
-DiplomaCongrats:
- db "Congrats! This"
- next "diploma certifies"
- next "that you have"
- next "completed your"
- next "#DEX.@"
-
-DiplomaGameFreak:
- db "GAME FREAK@"
diff --git a/engine/menu/diploma_1.asm b/engine/menu/diploma_1.asm
new file mode 100644
index 00000000..db156115
--- /dev/null
+++ b/engine/menu/diploma_1.asm
@@ -0,0 +1,17 @@
+DisplayDiploma: ; 56714 (15:6714)
+ call SaveScreenTilesToBuffer2
+ call GBPalWhiteOutWithDelay3
+ call ClearScreen
+ xor a
+ ld [wUpdateSpritesEnabled], a
+ ld hl, wd730
+ set 6, [hl]
+ callab _DisplayDiploma
+ call WaitForTextScrollButtonPress
+ ld hl, wd730
+ res 6, [hl]
+ call GBPalWhiteOutWithDelay3
+ call ReloadTilesetTilePatterns
+ call RestoreScreenTilesAndReloadTilePatterns
+ call Delay3
+ jp GBPalNormal \ No newline at end of file
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index 66ae20ce..9dee81bd 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -1,23 +1,23 @@
-_GetSpritePosition1: ; 567f9 (15:67f9)
+_GetSpritePosition1: ; 56745 (15:6745)
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
- ld a, [hli]
+ ld a, [hli] ; c1x4 (screen Y pos)
ld [$ffeb], a
inc hl
- ld a, [hl]
+ ld a, [hl] ; c1x6 (screen X pos)
ld [$ffec], a
- ld de, $fe
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
- ld a, [hli]
+ ld a, [hli] ; c2x4 (map Y pos)
ld [$ffed], a
- ld a, [hl]
+ ld a, [hl] ; c2x5 (map X pos)
ld [$ffee], a
ret
-_GetSpritePosition2: ; 56819 (15:6819)
+_GetSpritePosition2: ; 56765 (15:6765)
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
@@ -28,7 +28,7 @@ _GetSpritePosition2: ; 56819 (15:6819)
inc hl
ld a, [hl] ; c1x6 (screen X pos)
ld [wSavedSpriteScreenX], a
- ld de, $104 - $6
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
ld [wSavedSpriteMapY], a
@@ -36,7 +36,7 @@ _GetSpritePosition2: ; 56819 (15:6819)
ld [wSavedSpriteMapX], a
ret
-_SetSpritePosition1: ; 5683d (15:683d)
+_SetSpritePosition1: ; 56789 (15:6789)
ld hl, wSpriteStateData1
ld de, $4
ld a, [wSpriteIndex]
@@ -47,7 +47,7 @@ _SetSpritePosition1: ; 5683d (15:683d)
inc hl
ld a, [$ffec] ; c1x6 (screen X pos)
ld [hl], a
- ld de, $104 - $6
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [$ffed] ; c2x4 (map Y pos)
ld [hli], a
@@ -55,36 +55,36 @@ _SetSpritePosition1: ; 5683d (15:683d)
ld [hl], a
ret
-_SetSpritePosition2: ; 5685d (15:685d)
+_SetSpritePosition2: ; 567a9 (15:67a9)
ld hl, wSpriteStateData1
- ld de, $0004
+ ld de, $4
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [wSavedSpriteScreenY]
- ld [hli], a
+ ld [hli], a ; c1x4 (screen Y pos)
inc hl
ld a, [wSavedSpriteScreenX]
- ld [hl], a
- ld de, $00fe
+ ld [hl], a ; c1x6 (screen X pos)
+ ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6)
add hl, de
ld a, [wSavedSpriteMapY]
- ld [hli], a
+ ld [hli], a ; c2x4 (map Y pos)
ld a, [wSavedSpriteMapX]
- ld [hl], a
+ ld [hl], a ; c2x5 (map X pos)
ret
-TrainerWalkUpToPlayer: ; 56881 (15:6881)
+TrainerWalkUpToPlayer: ; 567cd (15:67cd)
ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a
call ReadTrainerScreenPosition
ld a, [wTrainerFacingDirection]
- and a
+ and a ; SPRITE_FACING_DOWN
jr z, .facingDown
- cp $4
+ cp SPRITE_FACING_UP
jr z, .facingUp
- cp $8
+ cp SPRITE_FACING_LEFT
jr z, .facingLeft
jr .facingRight
.facingDown
@@ -148,8 +148,8 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881)
jp MoveSprite_
; input: de = offset within sprite entry
-; output: de = pointer to sprite data
-GetSpriteDataPointer: ; 56903 (15:6903)
+; output: hl = pointer to sprite data
+GetSpriteDataPointer: ; 5684f (15:684f)
push de
add hl, de
ld a, [H_SPRITEINDEX]
@@ -161,7 +161,7 @@ GetSpriteDataPointer: ; 56903 (15:6903)
ret
; tests if this trainer is in the right position to engage the player and do so if she is.
-TrainerEngage: ; 5690f (15:690f)
+TrainerEngage: ; 5685b (15:685b)
push hl
push de
ld a, [wTrainerSpriteOffset]
@@ -225,21 +225,21 @@ TrainerEngage: ; 5690f (15:690f)
set 0, [hl]
call EngageMapTrainer
ld a, $ff
-.noEngage: ; 56988 (15:6988)
+.noEngage
ld [wTrainerSpriteOffset], a
pop de
pop hl
ret
; reads trainer's Y position to wTrainerScreenY and X position to wTrainerScreenX
-ReadTrainerScreenPosition: ; 5698e (15:698e)
+ReadTrainerScreenPosition: ; 568da (15:68da)
ld a, [wTrainerSpriteOffset]
add $4
ld d, $0
ld e, a
ld hl, wSpriteStateData1
add hl, de
- ld a, [hl]
+ ld a, [hl] ; c1x4 (sprite Y pos)
ld [wTrainerScreenY], a
ld a, [wTrainerSpriteOffset]
add $6
@@ -247,7 +247,7 @@ ReadTrainerScreenPosition: ; 5698e (15:698e)
ld e, a
ld hl, wSpriteStateData1
add hl, de
- ld a, [hl]
+ ld a, [hl] ; c1x6 (sprite X pos)
ld [wTrainerScreenX], a
ret
@@ -262,13 +262,13 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
jr .notInLine ; player too far away
.checkIfLinedUp
ld a, [wTrainerFacingDirection] ; sprite facing direction
- cp $0 ; down
+ cp SPRITE_FACING_DOWN ; down
jr z, .checkXCoord
- cp $4 ; up
+ cp SPRITE_FACING_UP ; up
jr z, .checkXCoord
- cp $8 ; left
+ cp SPRITE_FACING_LEFT ; left
jr z, .checkYCoord
- cp $c ; right
+ cp SPRITE_FACING_RIGHT ; right
jr z, .checkYCoord
jr .notInLine
.checkXCoord
@@ -290,7 +290,7 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
ret
; tests if the player is in front of the sprite (rather than behind it)
-CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
+CheckPlayerIsInFrontOfSprite: ; 5692f (15:692f)
ld a, [wCurMap]
cp POWER_PLANT
jp z, .engage ; bypass this for power plant to get voltorb fake items to work
@@ -315,21 +315,21 @@ CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
ld a, [hl] ; c1x6 (sprite screen X pos)
ld [wTrainerScreenX], a
ld a, [wTrainerFacingDirection] ; facing direction
- cp $0
+ cp SPRITE_FACING_DOWN
jr nz, .notFacingDown
ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
jr c, .engage ; sprite above player
jr .noEngage ; sprite below player
.notFacingDown
- cp $4
+ cp SPRITE_FACING_UP
jr nz, .notFacingUp
ld a, [wTrainerScreenY] ; sprite screen Y pos
cp $3c
jr nc, .engage ; sprite below player
jr .noEngage ; sprite above player
.notFacingUp
- cp $8
+ cp SPRITE_FACING_LEFT
jr nz, .notFacingLeft
ld a, [wTrainerScreenX] ; sprite screen X pos
cp $40
diff --git a/main.asm b/main.asm
index 07cd0c41..d223c83b 100755
--- a/main.asm
+++ b/main.asm
@@ -728,18 +728,16 @@ INCLUDE "engine/hidden_object_functions14.asm"
SECTION "bank15",ROMX,BANK[$15]
dr $54000,$5525f
-GainExperience: ; 5525f (15:525f)
- dr $5525f,$56745
-_GetSpritePosition1: ; 56745 (15:6745)
- dr $56745,$56765
-_GetSpritePosition2: ; 56765 (15:6765)
- dr $56765,$56789
-_SetSpritePosition1: ; 56789 (15:6789)
- dr $56789,$567a9
-_SetSpritePosition2: ; 567a9 (15:67a9)
- dr $567a9,$567cd
-TrainerWalkUpToPlayer: ; 567cd (15:67cd)
- dr $567cd,$58000
+
+INCLUDE "engine/battle/experience.asm"
+
+ dr $554f7,$56714
+
+INCLUDE "engine/menu/diploma_1.asm"
+
+INCLUDE "engine/overworld/trainers.asm"
+
+
SECTION "bank16",ROMX,BANK[$16]
dr $58000,$58d99
@@ -865,7 +863,9 @@ Func_e8d35:: ; e8d35 (3a:4d35)
Func_e8e79: ; e8e79 (3a:4e79)
dr $e8e79,$e928a
SurfingPikachu2Graphics: INCBIN "gfx/surfing_pikachu_2.2bpp"
- dr $e988a,$e9bfa
+ dr $e988a,$e9a08
+_DisplayDiploma: ; e9a08 (3a:5a08)
+ dr $e9a08,$e9bfa
SurfingPikachu3Graphics: INCBIN "gfx/surfing_pikachu_3.t1.2bpp"