Magikarp functions moved to event/magikarp.asm

This commit is contained in:
PikalaxALT
2015-10-11 12:15:03 -04:00
parent d42330ed8b
commit 327faac497
14 changed files with 1240 additions and 1215 deletions

259
battle/misc.asm Normal file
View File

@@ -0,0 +1,259 @@
Functionfbd54: ; fbd54
xor a
ld [hBGMapMode], a ; $ff00+$d4
ld a, [hBattleTurn] ; $ff00+$e4
and a
jr z, .asm_fbd61
call Functionfbd96
jr .asm_fbd64
.asm_fbd61
call Functionfbd9d
.asm_fbd64
call ClearBox
jr Functionfbd91
Functionfbd69: ; fbd69 (3e:7d69)
callba BattleCommanda6
jr Functionfbd77
Functionfbd71: ; fbd71 (3e:7d71)
callba BattleCommanda7
Functionfbd77: ; fbd77 (3e:7d77)
xor a
ld [hBGMapMode], a ; $ff00+$d4
ld a, [hBattleTurn] ; $ff00+$e4
and a
jr z, .asm_fbd85
call Functionfbd96
xor a
jr .asm_fbd8a
.asm_fbd85
call Functionfbd9d
ld a, $31
.asm_fbd8a
ld [$ffad], a
predef FillBox
Functionfbd91: ; fbd91 (3e:7d91)
ld a, $1
ld [hBGMapMode], a ; $ff00+$d4
ret
Functionfbd96: ; fbd96 (3e:7d96)
hlcoord 12, 0
lb bc, 7, 7
ret
Functionfbd9d: ; fbd9d (3e:7d9d)
hlcoord 2, 6
lb bc, 6, 6
ret
DoWeatherModifiers: ; fbda4
ld de, .WeatherTypeModifiers
ld a, [Weather]
ld b, a
ld a, [wd265] ; move type
ld c, a
.CheckWeatherType
ld a, [de]
inc de
cp $ff
jr z, .asm_fbdc0
cp b
jr nz, .NextWeatherType
ld a, [de]
cp c
jr z, .ApplyModifier
.NextWeatherType
rept 2
inc de
endr
jr .CheckWeatherType
.asm_fbdc0
ld de, .WeatherMoveModifiers
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
ld c, a
.CheckWeatherMove
ld a, [de]
inc de
cp $ff
jr z, .done
cp b
jr nz, .NextWeatherMove
ld a, [de]
cp c
jr z, .ApplyModifier
.NextWeatherMove
rept 2
inc de
endr
jr .CheckWeatherMove
.ApplyModifier
xor a
ld [hMultiplicand + 0], a
ld hl, CurDamage
ld a, [hli]
ld [hMultiplicand + 1], a
ld a, [hl]
ld [hMultiplicand + 2], a
inc de
ld a, [de]
ld [hMultiplier], a
call Multiply
ld a, 10
ld [hDivisor], a
ld b, $4
call Divide
ld a, [hQuotient + 0]
and a
ld bc, -1
jr nz, .Update
ld a, [hQuotient + 1]
ld b, a
ld a, [hQuotient + 2]
ld c, a
or b
jr nz, .Update
ld bc, 1
.Update
ld a, b
ld [CurDamage], a
ld a, c
ld [CurDamage + 1], a
.done
ret
.WeatherTypeModifiers
db WEATHER_RAIN, WATER, 15
db WEATHER_RAIN, FIRE, 05
db WEATHER_SUN, FIRE, 15
db WEATHER_SUN, WATER, 05
db $ff
.WeatherMoveModifiers
db WEATHER_RAIN, EFFECT_SOLARBEAM, 05
db $ff
; fbe24
DoBadgeTypeBoosts: ; fbe24
ld a, [InLinkBattle]
and a
ret nz
ld a, [InBattleTowerBattle]
and a
ret nz
ld a, [hBattleTurn]
and a
ret nz
push de
push bc
ld hl, .BadgeTypes
ld a, [KantoBadges]
ld b, a
ld a, [JohtoBadges]
ld c, a
.CheckBadge
ld a, [hl]
cp $ff
jr z, .done
srl b
rr c
jr nc, .NextBadge
ld a, [wd265] ; move type
cp [hl]
jr z, .ApplyBoost
.NextBadge
inc hl
jr .CheckBadge
.ApplyBoost
ld a, [CurDamage]
ld h, a
ld d, a
ld a, [CurDamage + 1]
ld l, a
ld e, a
srl d
rr e
srl d
rr e
srl d
rr e
ld a, e
or d
jr nz, .asm_fbe6f
ld e, 1
.asm_fbe6f
add hl, de
jr nc, .Update
ld hl, $ffff
.Update
ld a, h
ld [CurDamage], a
ld a, l
ld [CurDamage + 1], a
.done
pop bc
pop de
ret
.BadgeTypes
db FLYING ; zephyrbadge
db BUG ; hivebadge
db NORMAL ; plainbadge
db GHOST ; fogbadge
db STEEL ; mineralbadge
db FIGHTING ; stormbadge
db ICE ; glacierbadge
db DRAGON ; risingbadge
db ROCK ; boulderbadge
db WATER ; cascadebadge
db ELECTRIC ; thunderbadge
db GRASS ; rainbowbadge
db POISON ; soulbadge
db PSYCHIC ; marshbadge
db FIRE ; volcanobadge
db GROUND ; earthbadge
db $ff
; fbe91

View File

@@ -116,6 +116,11 @@ BATTLETOWER_NROFTRAINERS EQU 7
NUM_WILDMONS_PER_AREA_TIME_OF_DAY EQU 7
WILDMON_GRASS_STRUCTURE_LENGTH EQU 2 + 3 * (1 + 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY)
PRINTNUM_MONEY EQU %00100000
PRINTNUM_RIGHTALIGN EQU %01000000
PRINTNUM_LEADINGZEROS EQU %10000000
PRINTNUM_MONEY_F EQU 5
PRINTNUM_RIGHTALIGN_F EQU 6
PRINTNUM_LEADINGZEROS_F EQU 7
PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F
PRINTNUM_RIGHTALIGN EQU 1 << PRINTNUM_RIGHTALIGN_F
PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F

View File

@@ -217,7 +217,7 @@ Function4013c: ; 4013c (10:413c)
call ByteFill
callba Function1de171
hlcoord 0, 17
ld de, Unknown_407f2
ld de, String_START_SEARCH
call Function40acd
ld a, $7
ld [wc7d3], a
@@ -246,7 +246,7 @@ Function4013c: ; 4013c (10:413c)
call Function41148
callba Function1de171
hlcoord 0, 17
ld de, Unknown_407f2
ld de, String_START_SEARCH
call Function40acd
ld a, $7
ld [wc7d3], a
@@ -1068,7 +1068,7 @@ Function40741: ; 40741
Function4074c: ; 4074c (10:474c)
hlcoord 0, 17
ld de, Unknown_407f2
ld de, String_START_SEARCH
call Function40acd
ld a, $32
hlcoord 0, 0
@@ -1081,27 +1081,27 @@ Function4074c: ; 4074c (10:474c)
ld bc, $607
call Function40ad5
hlcoord 1, 11
ld de, Unknown_407e1
ld de, String_SEEN
call Function40acd
ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen)
ld b, EndPokedexSeen - PokedexSeen
call CountSetBits
ld de, wd265
hlcoord 5, 12
ld bc, $103
lb bc, 1, 3
call PrintNum
hlcoord 1, 14
ld de, Unknown_407e6
ld de, String_OWN
call Function40acd
ld hl, PokedexCaught
ld b, EndPokedexCaught - PokedexCaught
call CountSetBits
ld de, wd265
hlcoord 5, 15
ld bc, $103
lb bc, 1, 3
call PrintNum
hlcoord 1, 17
ld de, Unknown_407ea
ld de, String_SELECT_OPTION
call Function40acd
hlcoord 8, 1
ld b, $7
@@ -1123,13 +1123,13 @@ Function4074c: ; 4074c (10:474c)
ret
; 407e1 (10:47e1)
Unknown_407e1: ; 407e1
String_SEEN: ; 407e1
db "SEEN", $ff
Unknown_407e6: ; 407e6
String_OWN: ; 407e6
db "OWN", $ff
Unknown_407ea: ; 407ea
String_SELECT_OPTION: ; 407ea
db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
Unknown_407f2: ; 407f2
String_START_SEARCH: ; 407f2
db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH
; 407fd
@@ -1270,7 +1270,7 @@ Function40962: ; 40962 (10:4962)
call PlaceString
ld de, wc7d7
hlcoord 1, 16
ld bc, $103
lb bc, 1, 3
call PrintNum
hlcoord 8, 0
ld [hl], $59

View File

@@ -1,3 +1,114 @@
Special_CheckMagikarpLength: ; fbb32
; Returns 3 if you select a Magikarp that beats the previous record.
; Returns 2 if you select a Magikarp, but the current record is longer.
; Returns 1 if you press B in the Pokemon selection menu.
; Returns 0 if the Pokemon you select is not a Magikarp.
; Let's start by selecting a Magikarp.
callba SelectMonFromParty
jr c, .declined
ld a, [CurPartySpecies]
cp MAGIKARP
jr nz, .not_magikarp
; Now let's compute its length based on its DVs and ID.
ld a, [CurPartyMon]
ld hl, PartyMon1Species
ld bc, PartyMon2 - PartyMon1
call AddNTimes
push hl
ld bc, MON_DVS
add hl, bc
ld d, h
ld e, l
pop hl
ld bc, MON_ID
add hl, bc
ld b, h
ld c, l
call CalcMagikarpLength
call PrintMagikarpLength
callba MagikarpLength_Mobile
ld hl, .MeasureItText
call PrintText
; Did we beat the record?
ld hl, Buffer1
ld de, wBestMagikarpLengthFeet
ld c, 2
call StringCmp
jr nc, .not_long_enough
; NEW RECORD!!! Let's save that.
ld hl, Buffer1
ld de, wBestMagikarpLengthFeet
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
inc de
ld a, [CurPartyMon]
ld hl, PartyMonOT
call SkipNames
call CopyBytes
ld a, 3
ld [ScriptVar], a
ret
.not_long_enough
ld a, 2
ld [ScriptVar], a
ret
.declined
ld a, 1
ld [ScriptVar], a
ret
.not_magikarp
xor a
ld [ScriptVar], a
ret
; fbba9
.MeasureItText: ; 0xfbba9
; Let me measure that MAGIKARP. …Hm, it measures @ .
text_jump UnknownText_0x1c1203
db "@"
; 0xfbbae
Magikarp_LoadFeetInchesChars: ; fbbae
ld hl, VTiles2 + "<FOOT>" * $10
ld de, .feetinchchars
lb bc, BANK(.feetinchchars), 2
call Request2bpp
ret
; fbbbb
.feetinchchars: ; fbbb
INCBIN "gfx/unknown/0fbbbb.2bpp"
; fbbdb
PrintMagikarpLength: ; fbbdb
call Magikarp_LoadFeetInchesChars
ld hl, StringBuffer1
ld de, Buffer1
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
call PrintNum
ld [hl], "<FOOT>"
inc hl
ld de, Buffer2
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
call PrintNum
ld [hl], "<INCH>"
inc hl
ld [hl], "@"
ret
; fbbfc
CalcMagikarpLength: ; fbbfc
; Return Magikarp's length (in mm) at MagikarpLength (big endian).
;
@@ -213,3 +324,22 @@ endr
dwb 65410, 2
dwb 65510, 1 ; not used
; fbcd2
Special_MagikarpHouseSign: ; fbcd2
ld a, [wBestMagikarpLengthFeet]
ld [Buffer1], a
ld a, [wBestMagikarpLengthInches]
ld [Buffer2], a
call PrintMagikarpLength
ld hl, .CurrentRecordtext
call PrintText
ret
; fbce8
.CurrentRecordtext: ; 0xfbce8
; "CURRENT RECORD"
text_jump UnknownText_0x1c123a
db "@"
; 0xfbced

750
event/mom.asm Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -75,12 +75,12 @@ Function2ebb:: ; 2ebb
ret
; 2ec6
Function2ec6:: ; 2ec6
xor_a:: ; 2ec6
xor a
ret
; 2ec8
Function2ec8:: ; 2ec8
xor_a_dec_a:: ; 2ec8
xor a
dec a
ret
@@ -1760,7 +1760,7 @@ Function383d:: ; 383d
Function3842:: ; 3842
ld [wd265], a
ld de, wd265
ld b, 1 << 6 + 1
ld b, PRINTNUM_RIGHTALIGN | 1
jp PrintNum
; 384d

View File

@@ -331,7 +331,7 @@ Functiona57:: ; a57
jr z, .asm_a63
ld a, [hJoyDown]
.asm_a63
ld [$ffa9], a
ld [hJoyLast], a
ld a, [hJoyPressed]
and a
jr z, .asm_a70
@@ -344,7 +344,7 @@ Functiona57:: ; a57
and a
jr z, .asm_a7a
xor a
ld [$ffa9], a
ld [hJoyLast], a
ret
.asm_a7a

View File

@@ -972,7 +972,7 @@ Text_09:: ; 14d2
ld a, b
and $f0
swap a
set 6, a
set PRINTNUM_RIGHTALIGN_F, a
ld b, a
call PrintNum
ld b, h

View File

@@ -10,6 +10,9 @@
charmap "└", $7d
charmap "┘", $7e
charmap " ", $7f
charmap "<FOOT>", $6e
charmap "<INCH>", $6f
charmap "A", $80
charmap "B", $81

1249
main.asm

File diff suppressed because it is too large Load Diff

View File

@@ -1843,7 +1843,7 @@ Function100b9f: ; 100b9f
callba Function3e786
ret z
call Function100dd8
jp c, Function2ec8
jp c, xor_a_dec_a
call Function100e72
call Function100bc2
push af

View File

@@ -4359,9 +4359,9 @@ Function17f382: ; 17f382
ld de, $b2f4
.asm_17f3ab
ld a, $82
ld a, PRINTNUM_LEADINGZEROS | 2
ld b, a
ld a, $3
ld a, 3
ld c, a
call PrintNum
call CloseSRAM

View File

@@ -1222,7 +1222,7 @@ UnknownText_0x1c123a: ; 1c123a
text_from_ram StringBuffer1
text " caught by"
line "@"
text_from_ram wdfe9 + 1
text_from_ram wBestMagikarpLengthInches + 1
text_waitbutton
db "@"
; 1c1260

View File

@@ -1191,6 +1191,7 @@ CurSpecies:: ; cf60
wcf61:: ds 2
wcf63:: ds 1
wNrOfBeatenBattleTowerTrainers::
wMomBankDigitCursorPosition::
wcf64:: ds 1
IF !DEF(CRYSTAL11)
wPokedexStatus::
@@ -2579,9 +2580,9 @@ wdfe4:: ds 1
wdfe5:: ds 1
wdfe6:: ds 1
wdfe7:: ds 1
wdfe8:: ds 1
wdfe9:: ds 1
ds 1
wBestMagikarpLengthFeet:: ds 1
wBestMagikarpLengthInches:: ds 1
wMagikarpRecordHoldersName:: ds 1
ds 1
wdfec:: ds 1
ds 3