summaryrefslogtreecommitdiff
path: root/main.asm
diff options
context:
space:
mode:
Diffstat (limited to 'main.asm')
-rw-r--r--main.asm6584
1 files changed, 5359 insertions, 1225 deletions
diff --git a/main.asm b/main.asm
index 0b99b9c22..89f7ed0a5 100644
--- a/main.asm
+++ b/main.asm
@@ -7,8 +7,8 @@ SECTION "rst8",HOME[$8] ; FarCall
jp FarJpHl
SECTION "rst10",HOME[$10] ; Bankswitch
- ld [$ff9d], a
- ld [$2000], a
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
ret
SECTION "rst18",HOME[$18] ; Unused
@@ -56,14 +56,14 @@ Start:
SECTION "start",HOME[$150]
-INCBIN "baserom.gbc",$150,$283 - $150
+INCBIN "baserom.gbc", $150, $283 - $150
VBlank: ; 283
INCLUDE "vblank.asm"
-DelayFrame: ; 0x45a
+DelayFrame: ; 45a
; Wait for one frame
ld a, 1
ld [VBlankOccurred], a
@@ -75,25 +75,26 @@ DelayFrame: ; 0x45a
and a
jr nz, .halt
ret
-; 0x468
+; 468
-DelayFrames: ; 0x468
+
+DelayFrames: ; 468
; Wait c frames
call DelayFrame
dec c
jr nz, DelayFrames
ret
-; 0x46f
+; 46f
+
RTC: ; 46f
; update time and time-sensitive palettes
; rtc enabled?
ld a, [$c2ce]
- cp $0
+ cp 0
ret z
-; update clock
call UpdateTime
; obj update on?
@@ -106,7 +107,9 @@ RTC: ; 46f
ret
; 485
-INCBIN "baserom.gbc",$485,$52f - $485
+
+INCBIN "baserom.gbc", $485, $52f - $485
+
IncGradGBPalTable_01: ; 52f
db %11111111 ; bgp
@@ -142,7 +145,9 @@ IncGradGBPalTable_01: ; 52f
db %00000000
; 547
-INCBIN "baserom.gbc",$547,$568 - $547
+
+INCBIN "baserom.gbc", $547, $568 - $547
+
DisableLCD: ; 568
; Turn the LCD off
@@ -186,6 +191,7 @@ DisableLCD: ; 568
ret
; 58a
+
EnableLCD: ; 58a
ld a, [rLCDC]
set 7, a ; lcd enable
@@ -193,19 +199,22 @@ EnableLCD: ; 58a
ret
; 591
+
AskTimer: ; 591
- INCBIN "baserom.gbc",$591,$59c - $591
+ INCBIN "baserom.gbc", $591, $59c - $591
; 59c
+
LatchClock: ; 59c
; latch clock counter data
- ld a, $0
- ld [$6000], a
- ld a, $1
- ld [$6000], a
+ ld a, 0
+ ld [MBC3LatchClock], a
+ ld a, 1
+ ld [MBC3LatchClock], a
ret
; 5a7
+
UpdateTime: ; 5a7
; get rtc data
call GetClock
@@ -218,43 +227,44 @@ UpdateTime: ; 5a7
ret
; 5b7
+
GetClock: ; 5b7
-; store clock data in $ff8d-$ff91
+; store clock data in hRTCDayHi-hRTCSeconds
; enable clock r/w
- ld a, $a
- ld [$0000], a
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
; get clock data
; stored 'backwards' in hram
call LatchClock
- ld hl, $4000
- ld de, $a000
+ ld hl, MBC3SRamBank
+ ld de, MBC3RTC
; seconds
- ld [hl], $8 ; S
+ ld [hl], RTC_S
ld a, [de]
and $3f
- ld [$ff91], a
+ ld [hRTCSeconds], a
; minutes
- ld [hl], $9 ; M
+ ld [hl], RTC_M
ld a, [de]
and $3f
- ld [$ff90], a
+ ld [hRTCMinutes], a
; hours
- ld [hl], $a ; H
+ ld [hl], RTC_H
ld a, [de]
and $1f
- ld [$ff8f], a
+ ld [hRTCHours], a
; day lo
- ld [hl], $b ; DL
+ ld [hl], RTC_DL
ld a, [de]
- ld [$ff8e], a
+ ld [hRTCDayLo], a
; day hi
- ld [hl], $c ; DH
+ ld [hl], RTC_DH
ld a, [de]
- ld [$ff8d], a
+ ld [hRTCDayHi], a
; cleanup
call CloseSRAM ; unlatch clock, disable clock r/w
@@ -267,16 +277,16 @@ FixDays: ; 5e8
; mod by 140
; check if day count > 255 (bit 8 set)
- ld a, [$ff8d] ; DH
+ ld a, [hRTCDayHi] ; DH
bit 0, a
jr z, .daylo
; reset dh (bit 8)
res 0, a
- ld [$ff8d], a ; DH
+ ld [hRTCDayHi], a ; DH
; mod 140
; mod twice since bit 8 (DH) was set
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
.modh
sub 140
jr nc, .modh
@@ -286,7 +296,7 @@ FixDays: ; 5e8
add 140
; update dl
- ld [$ff8e], a ; DL
+ ld [hRTCDayLo], a ; DL
; unknown output
ld a, $40 ; %1000000
@@ -294,7 +304,7 @@ FixDays: ; 5e8
.daylo
; quit if fewer than 140 days have passed
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
cp 140
jr c, .quit
@@ -305,7 +315,7 @@ FixDays: ; 5e8
add 140
; update dl
- ld [$ff8e], a ; DL
+ ld [hRTCDayLo], a ; DL
; unknown output
ld a, $20 ; %100000
@@ -327,10 +337,10 @@ FixDays: ; 5e8
FixTime: ; 61d
; add ingame time (set at newgame) to current time
; day hr min sec
-; store time in CurDay, $ff94, $ff96, $ff98
+; store time in CurDay, hHours, hMinutes, hSeconds
; second
- ld a, [$ff91] ; S
+ ld a, [hRTCSeconds] ; S
ld c, a
ld a, [StartSecond]
add c
@@ -338,11 +348,11 @@ FixTime: ; 61d
jr nc, .updatesec
add 60
.updatesec
- ld [$ff98], a
+ ld [hSeconds], a
; minute
ccf ; carry is set, so turn it off
- ld a, [$ff90] ; M
+ ld a, [hRTCMinutes] ; M
ld c, a
ld a, [StartMinute]
adc c
@@ -350,11 +360,11 @@ FixTime: ; 61d
jr nc, .updatemin
add 60
.updatemin
- ld [$ff96], a
+ ld [hMinutes], a
; hour
ccf ; carry is set, so turn it off
- ld a, [$ff8f] ; H
+ ld a, [hRTCHours] ; H
ld c, a
ld a, [StartHour]
adc c
@@ -362,11 +372,11 @@ FixTime: ; 61d
jr nc, .updatehr
add 24
.updatehr
- ld [$ff94], a
+ ld [hHours], a
; day
ccf ; carry is set, so turn it off
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
ld c, a
ld a, [StartDay]
adc c
@@ -374,48 +384,48 @@ FixTime: ; 61d
ret
; 658
-INCBIN "baserom.gbc",$658,$691 - $658
+INCBIN "baserom.gbc", $658, $691 - $658
SetClock: ; 691
; set clock data from hram
; enable clock r/w
- ld a, $a
- ld [$0000], a
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
; set clock data
; stored 'backwards' in hram
call LatchClock
- ld hl, $4000
- ld de, $a000
+ ld hl, MBC3SRamBank
+ ld de, MBC3RTC
; seems to be a halt check that got partially commented out
; this block is totally pointless
- ld [hl], $c
+ ld [hl], RTC_DH
ld a, [de]
bit 6, a ; halt
ld [de], a
; seconds
- ld [hl], $8 ; S
- ld a, [$ff91]
+ ld [hl], RTC_S
+ ld a, [hRTCSeconds]
ld [de], a
; minutes
- ld [hl], $9 ; M
- ld a, [$ff90]
+ ld [hl], RTC_M
+ ld a, [hRTCMinutes]
ld [de], a
; hours
- ld [hl], $a ; H
- ld a, [$ff8f]
+ ld [hl], RTC_H
+ ld a, [hRTCHours]
ld [de], a
; day lo
- ld [hl], $b ; DL
- ld a, [$ff8e]
+ ld [hl], RTC_DL
+ ld a, [hRTCDayLo]
ld [de], a
; day hi
- ld [hl], $c ; DH
- ld a, [$ff8d]
+ ld [hl], RTC_DH
+ ld a, [hRTCDayHi]
res 6, a ; make sure timer is active
ld [de], a
@@ -424,13 +434,13 @@ SetClock: ; 691
ret
; 6c4
-INCBIN "baserom.gbc",$6c4,$92e - $6c4
+INCBIN "baserom.gbc", $6c4, $92e - $6c4
INCLUDE "joypad.asm"
-INCBIN "baserom.gbc",$a1b,$b40 - $a1b
+INCBIN "baserom.gbc", $a1b, $b40 - $a1b
FarDecompress: ; b40
; Decompress graphics data at a:hl to de
@@ -438,7 +448,7 @@ FarDecompress: ; b40
; put a away for a sec
ld [$c2c4], a
; save bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
; bankswitch
ld a, [$c2c4]
@@ -808,124 +818,65 @@ UpdatePalsIfCGB: ; c2f
; return carry if successful
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
ret z
-
+
+
UpdateCGBPals: ; c33
; return carry if successful
; any pals to update?
- ld a, [$ffe5]
+ ld a, [hCGBPalUpdate]
and a
ret z
-
+
+
ForceUpdateCGBPals: ; c37
-; save wram bank
+
ld a, [rSVBK]
push af
-; bankswitch
ld a, 5 ; BANK(BGPals)
ld [rSVBK], a
-; get bg pal buffer
+
ld hl, BGPals ; 5:d080
-
-; update bg pals
+
+; copy 8 pals to bgpd
ld a, %10000000 ; auto increment, index 0
ld [rBGPI], a
- ld c, rBGPD - rJOYP
+ ld c, rBGPD % $100
ld b, 4 ; NUM_PALS / 2
-
.bgp
-; copy 16 bytes (8 colors / 2 pals) to bgpd
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
+ rept $10
ld a, [hli]
ld [$ff00+c], a
-; done?
+ endr
+
dec b
jr nz, .bgp
; hl is now 5:d0c0 OBPals
-; update obj pals
+; copy 8 pals to obpd
ld a, %10000000 ; auto increment, index 0
ld [rOBPI], a
ld c, rOBPD - rJOYP
ld b, 4 ; NUM_PALS / 2
-
.obp
-; copy 16 bytes (8 colors / 2 pals) to obpd
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
+ rept $10
ld a, [hli]
ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
- ld a, [hli]
- ld [$ff00+c], a
-; done?
+ endr
+
dec b
jr nz, .obp
-; restore wram bank
pop af
ld [rSVBK], a
+
; clear pal update queue
xor a
- ld [$ffe5], a
-; successfully updated palettes
+ ld [hCGBPalUpdate], a
+
scf
ret
; c9f
@@ -935,23 +886,22 @@ DmgToCgbBGPals: ; c9f
; exists to forego reinserting cgb-converted image data
; input: a -> bgp
+
ld [rBGP], a
push af
-
-; check cgb
- ld a, [$ffe6]
+
+ ld a, [hCGB]
and a
jr z, .end
-
+
push hl
push de
push bc
-; save wram bank
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
-; wram bank 5
+
ld a, 5
- ld [$ff70], a
+ ld [rSVBK], a
; copy & reorder bg pal buffer
ld hl, BGPals ; to
@@ -959,15 +909,15 @@ DmgToCgbBGPals: ; c9f
; order
ld a, [rBGP]
ld b, a
-; # pals
- ld c, 8 ; all pals
+; all pals
+ ld c, 8
call CopyPals
; request pal update
- ld a, $1
- ld [$ffe5], a
-; restore wram bank
+ ld a, 1
+ ld [hCGBPalUpdate], a
+
pop af
- ld [$ff70], a
+ ld [rSVBK], a
pop bc
pop de
pop hl
@@ -981,51 +931,50 @@ DmgToCgbObjPals: ; ccb
; exists to forego reinserting cgb-converted image data
; input: d -> obp1
-; e -> obp2
+; e -> obp2
+
ld a, e
ld [rOBP0], a
ld a, d
ld [rOBP1], a
-; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
ret z
-
+
push hl
push de
push bc
-; save wram bank
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
-; wram bank 5
- ld a, $5
- ld [$ff70], a
-
+
+ ld a, 5
+ ld [rSVBK], a
+
; copy & reorder obj pal buffer
- ; to
- ld hl, OBPals
- ; from
- ld de, Unkn2Pals
+ ld hl, OBPals ; to
+ ld de, Unkn2Pals ; from
; order
ld a, [rOBP0]
ld b, a
-; # pals
- ld c, 8 ; all pals
+; all pals
+ ld c, 8
call CopyPals
; request pal update
- ld a, $1
- ld [$ffe5], a
-; restore wram bank
+ ld a, 1
+ ld [hCGBPalUpdate], a
+
pop af
- ld [$ff70], a
+ ld [rSVBK], a
pop bc
pop de
pop hl
ret
; cf8
-INCBIN "baserom.gbc",$cf8,$d50 - $cf8
+
+INCBIN "baserom.gbc", $cf8, $d50 - $cf8
+
CopyPals: ; d50
; copy c palettes in order b from de to hl
@@ -1079,70 +1028,125 @@ CopyPals: ; d50
ret
; d79
-INCBIN "baserom.gbc",$d79,$e8d - $d79
-; copy bc bytes from a:hl to de
+INCBIN "baserom.gbc", $d79, $e8d - $d79
+
+
FarCopyBytes: ; e8d
- ld [$ff8b], a
- ld a, [$ff9d] ; save old bank
+; copy bc bytes from a:hl to de
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
+
call CopyBytes
+
pop af
rst Bankswitch
ret
; 0xe9b
-; copy bc*2 source bytes from a:hl to de, doubling each byte in process
+
FarCopyBytesDouble: ; e9b
- ld [$ff8b], a
- ld a, [$ff9d] ; save current bank
+; Copy bc bytes from a:hl to bc*2 bytes at de,
+; doubling each byte in the process.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
- rst Bankswitch ; bankswitch
- ld a, h ; switcheroo, de <> hl
+ ld a, [hBuffer]
+ rst Bankswitch
+
+; switcheroo, de <> hl
+ ld a, h
ld h, d
ld d, a
ld a, l
ld l, e
ld e, a
+
inc b
inc c
- jr .dec ; 0xeab $4
+ jr .dec
+
.loop
ld a, [de]
inc de
- ld [hli], a ; write twice
+ ld [hli], a
ld [hli], a
.dec
dec c
jr nz, .loop
dec b
jr nz, .loop
+
pop af
rst Bankswitch
ret
; 0xeba
-INCBIN "baserom.gbc",$eba,$fc8 - $eba
+INCBIN "baserom.gbc", $eba, $fb6 - $eba
+
+
+ClearBox: ; fb6
+; Fill a c*b box at hl with blank tiles.
+
+ ld a, " "
+.y
+ push bc
+ push hl
+.x
+ ld [hli], a
+ dec c
+ jr nz, .x
+ pop hl
+ ld bc, 20 ; screen width
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .y
+ ret
+; fc8
+
ClearTileMap: ; fc8
-; Fill the tile map with blank tiles
+; Fill TileMap with blank tiles.
+
ld hl, TileMap
- ld a, $7f ; blank tile
- ld bc, 360 ; length of TileMap
+ ld a, " "
+ ld bc, 360 ; screen dimensions 20*18
call ByteFill
-; We aren't done if the LCD is on
+; We aren't done if the LCD is on.
ld a, [rLCDC]
bit 7, a
ret z
jp WaitBGMap
; fdb
-INCBIN "baserom.gbc",$fdb,$ff1 - $fdb
+
+INCBIN "baserom.gbc", $fdb, $fe8 - $fdb
+
+
+TextBox: ; fe8
+; draw a text box of given location/size
+; ? hl
+; size bc
+; ? de
+
+; draw border
+ push bc
+ push hl
+ call TextBoxBorder
+ pop hl
+ pop bc
+; fill textbox area with palette 7
+ jr TextBoxPalette
+; ff1
+
TextBoxBorder: ; ff1
; draw a text box
@@ -1185,9 +1189,10 @@ TextBoxBorder: ; ff1
call NPlaceChar
ld [hl], "┘"
ret
-; 0x101e
+; 101e
+
-NPlaceChar: ; 0x101e
+NPlaceChar: ; 101e
; place a row of width c of identical characters
ld d,c
.loop\@
@@ -1195,13 +1200,64 @@ NPlaceChar: ; 0x101e
dec d
jr nz,.loop\@
ret
-; 0x1024
+; 1024
+
+
+TextBoxPalette: ; 1024
+; fill textbox area with pal 07
+; hl: tile address
+; b: height
+; c: width
+ ld de, AttrMap - TileMap
+ add hl, de
+ inc b
+ inc b
+ inc c
+ inc c
+ ld a, $07 ; palette
+.gotoy
+ push bc
+ push hl
+.gotox
+ ld [hli], a
+ dec c
+ jr nz, .gotox
+ pop hl
+ ld de, $0014 ; screen width in tiles (20)
+ add hl, de
+ pop bc
+ dec b
+ jr nz, .gotoy
+ ret
+; 103e
+
+
+SpeechTextBox: ; 103e
+; Standard textbox.
+ ld hl, $c590 ; tile 0, 12
+ ld b, $4 ; height
+ ld c, $12 ; width ; SCREEN_WIDTH - 2 (border)
+ jp TextBox
+; 1048
+
-INCBIN "baserom.gbc",$1024,$1078 - $1024
+INCBIN "baserom.gbc", $1048, $1065 - $1048
-PlaceString: ; $1078
+
+PrintTextBoxText: ; 1065
+ ld bc, $c5b9 ; TileMap(1,14)
+ call $13e5 ; PrintText
+ ret
+; 106c
+
+
+INCBIN "baserom.gbc", $106c, $1078 - $106c
+
+
+PlaceString: ; 1078
push hl
-PlaceNextChar:
+
+PlaceNextChar: ; 1079
ld a, [de]
cp "@"
jr nz, CheckDict
@@ -1215,7 +1271,7 @@ NextChar: ; 1083
inc de
jp PlaceNextChar
-CheckDict:
+CheckDict: ; 1087
cp $15
jp z, $117b
cp $4f
@@ -1329,10 +1385,12 @@ CheckDict:
jp NextChar
; 0x117b
-INCBIN "baserom.gbc",$117b,$1203 - $117b
+
+INCBIN "baserom.gbc", $117b, $1203 - $117b
+
Char5D:
- ld a, [$ffe4]
+ ld a, [hBattleTurn]
push de
and a
jr nz, .asm_120e ; 0x1207 $5
@@ -1365,7 +1423,7 @@ Char5D:
ld a, $e
rst FarCall
pop hl
- ld de, $d073
+ ld de, StringBuffer1
jr .asm_126a ; 0x1246 $22
.asm_1248
ld de, $d493
@@ -1400,14 +1458,14 @@ Char5DText: ; 0x1276
Char5BText: ; 0x127e
db "PC@"
-INCBIN "baserom.gbc",$1281,$1293 - $1281
+INCBIN "baserom.gbc", $1281, $1293 - $1281
Char56Text: ; 0x1293
db "…@"
Char5AText: ; 0x1295
db "Enemy @"
-INCBIN "baserom.gbc",$129c,$1356 - $129c
+INCBIN "baserom.gbc", $129c, $1356 - $129c
Char5F: ; 0x1356
; ends a Pokédex entry
@@ -1415,21 +1473,21 @@ Char5F: ; 0x1356
pop hl
ret
-INCBIN "baserom.gbc",$135a,$15d8 - $135a
+INCBIN "baserom.gbc", $135a, $15d8 - $135a
DMATransfer: ; 15d8
; DMA transfer
; return carry if successful
; anything to transfer?
- ld a, [$ffe8]
+ ld a, [hDMATransfer]
and a
ret z
; start transfer
ld [rHDMA5], a
; indicate that transfer has occurred
xor a
- ld [$ffe8], a
+ ld [hDMATransfer], a
; successful transfer
scf
ret
@@ -1443,14 +1501,14 @@ UpdateBGMapBuffer: ; 15e3
; return carry if successful
; any tiles to update?
- ld a, [$ffdb]
+ ld a, [hBGMapUpdate]
and a
ret z
; save wram bank
ld a, [rVBK]
push af
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; temp stack
ld hl, BGMapBufferPtrs
@@ -1531,7 +1589,7 @@ UpdateBGMapBuffer: ; 15e3
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1543,7 +1601,7 @@ UpdateBGMapBuffer: ; 15e3
; we don't need to update bg map until new tiles are loaded
xor a
- ld [$ffdb], a
+ ld [hBGMapUpdate], a
; successfully updated bg map
scf
@@ -1552,12 +1610,12 @@ UpdateBGMapBuffer: ; 15e3
WaitTop: ; 163a
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
and a
ret z
; wait until top third of bg map can be updated
- ld a, [$ffd5]
+ ld a, [hBGMapThird]
and a
jr z, .quit
@@ -1566,14 +1624,14 @@ WaitTop: ; 163a
.quit
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ret
; 164c
UpdateBGMap: ; 164c
; get mode
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
and a
ret z
@@ -1585,7 +1643,7 @@ UpdateBGMap: ; 164c
dec a ; ?
; save bg map address
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
ld a, [$ffd7]
ld h, a
@@ -1593,12 +1651,12 @@ UpdateBGMap: ; 164c
; bg map 1 ($9c00)
xor a
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, $9c
ld [$ffd7], a
; get mode again
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
push af
cp 3
call z, .tiles
@@ -1609,7 +1667,7 @@ UpdateBGMap: ; 164c
; restore bg map address
pop hl
ld a, l
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, h
ld [$ffd7], a
ret
@@ -1632,10 +1690,10 @@ UpdateBGMap: ; 164c
.getthird
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; # tiles to move down * 6 (which third?)
- ld a, [$ffd5]
+ ld a, [hBGMapThird]
and a ; 0
jr z, .top
dec a ; 1
@@ -1650,7 +1708,7 @@ UpdateBGMap: ; 164c
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; move 12 tiles down
ld de, $0180 ; bgm(0,12)
@@ -1668,7 +1726,7 @@ UpdateBGMap: ; 164c
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; move 6 tiles down
ld de, $00c0 ; bgm(0,6)
@@ -1683,14 +1741,14 @@ UpdateBGMap: ; 164c
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; start at middle next time
ld a, 1
.start
; which third to draw next update
- ld [$ffd5], a
+ ld [hBGMapThird], a
; # rows per third
ld a, 6 ; SCREEN_HEIGHT / 3
; # tiles from the edge of the screen to the next row
@@ -1754,7 +1812,7 @@ UpdateBGMap: ; 164c
jr nz, .row
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1780,7 +1838,7 @@ SafeLoadTiles2: ; 170a
GetTiles2: ; 1717
; load [$cf6c] tiles from [$cf6d-e] to [$cf6f-70]
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; sp = [$cf6d-e] tile source
ld hl, $cf6d
@@ -1856,7 +1914,7 @@ GetTiles2: ; 1717
ld [$cf6d], sp
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1892,7 +1950,7 @@ GetTiles: ; 177d
; load [$cf67] tiles from [$cf68-9] to [$cf6a-b]
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; sp = [$cf68-9] tile source
ld hl, $cf68
@@ -1971,7 +2029,7 @@ GetTiles: ; 177d
ld [$cf68], sp
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1997,7 +2055,7 @@ SafeTileAnimation: ; 17d3
; save affected banks
; switch to new banks
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af ; save bank
ld a, BANK(DoTileAnimation)
rst Bankswitch ; bankswitch
@@ -2025,7 +2083,7 @@ SafeTileAnimation: ; 17d3
ret
; 17ff
-INCBIN "baserom.gbc",$17ff,$185d - $17ff
+INCBIN "baserom.gbc", $17ff, $185d - $17ff
GetTileType: ; 185d
; checks the properties of a tile
@@ -2036,7 +2094,7 @@ GetTileType: ; 185d
ld e, a
ld d, $00
add hl, de
- ld a, [$ff9d] ; current bank
+ ld a, [hROMBank] ; current bank
push af
ld a, BANK(TileTypeTable)
rst Bankswitch
@@ -2050,7 +2108,7 @@ GetTileType: ; 185d
ret
; 1875
-INCBIN "baserom.gbc",$1875,$2063 - $1875
+INCBIN "baserom.gbc", $1875, $2063 - $1875
AskSerial: ; 2063
; send out a handshake while serial int is off
@@ -2090,7 +2148,7 @@ AskSerial: ; 2063
ret
; 208a
-INCBIN "baserom.gbc",$208a,$209e - $208a
+INCBIN "baserom.gbc", $208a, $209e - $208a
GameTimer: ; 209e
; precautionary
@@ -2220,7 +2278,7 @@ UpdateGameTimer: ; 20ad
ret
; 210f
-INCBIN "baserom.gbc",$210f,$261f - $210f
+INCBIN "baserom.gbc", $210f, $261f - $210f
PushScriptPointer: ; 261f
; used to call a script from asm
@@ -2244,7 +2302,7 @@ PushScriptPointer: ; 261f
ret
; 2631
-INCBIN "baserom.gbc",$2631,$26d4 - $2631
+INCBIN "baserom.gbc", $2631, $26d4 - $2631
GetScriptByte: ; 0x26d4
; Return byte at ScriptBank:ScriptPos in a.
@@ -2252,7 +2310,7 @@ GetScriptByte: ; 0x26d4
push hl
push bc
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
ld a, [ScriptBank]
@@ -2289,7 +2347,7 @@ ObjectEventText:
db "@"
; 0x26f7
-INCBIN "baserom.gbc",$26f7,$2bed-$26f7
+INCBIN "baserom.gbc", $26f7, $2bed-$26f7
GetMapHeaderPointer: ; 0x2bed
; Prior to calling this function, you must have switched banks so that
@@ -2342,7 +2400,7 @@ GetMapHeaderMember: ; 0x2c04
GetAnyMapHeaderMember: ; 0x2c0c
; bankswitch
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
ld a, BANK(MapGroupPointers)
rst Bankswitch
@@ -2359,7 +2417,7 @@ GetAnyMapHeaderMember: ; 0x2c0c
ret
; 0x2c1c
-INCBIN "baserom.gbc",$2c1c,$2c7d-$2c1c
+INCBIN "baserom.gbc", $2c1c, $2c7d-$2c1c
GetSecondaryMapHeaderPointer: ; 0x2c7d
; returns the current map's secondary map header pointer in hl.
@@ -2373,7 +2431,7 @@ GetSecondaryMapHeaderPointer: ; 0x2c7d
pop bc
ret
-INCBIN "baserom.gbc",$2c8a,$2caf-$2c8a
+INCBIN "baserom.gbc", $2c8a, $2caf-$2c8a
GetWorldMapLocation: ; 0x2caf
; given a map group/id in bc, return its location on the Pokégear map.
@@ -2389,17 +2447,17 @@ GetWorldMapLocation: ; 0x2caf
ret
; 0x2cbd
-INCBIN "baserom.gbc",$2cbd,$2d63-$2cbd
+INCBIN "baserom.gbc", $2cbd, $2d63-$2cbd
FarJpHl: ; 2d63
; Jump to a:hl.
; Preserves all registers besides a.
; Switch to the new bank.
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
call .hl
@@ -2451,7 +2509,7 @@ Predef: ; 2d83
ld [$cfb4], a
; save bank
- ld a, [$ff9d] ; current bank
+ ld a, [hROMBank] ; current bank
push af
; get Predef function to call
@@ -2500,7 +2558,7 @@ Predef: ; 2d83
ret
; 2dba
-INCBIN "baserom.gbc",$2dba,$2e6f-$2dba
+INCBIN "baserom.gbc", $2dba, $2e6f-$2dba
BitTable1Func: ; 0x2e6f
ld hl, $da72
@@ -2595,15 +2653,15 @@ RNG: ; 2f8c
; Added value
ld a, [rDIV]
ld b, a
- ld a, [$ffe1]
+ ld a, [hRandomAdd]
adc b
- ld [$ffe1], a
+ ld [hRandomAdd], a
; Subtracted value
ld a, [rDIV]
ld b, a
- ld a, [$ffe2]
+ ld a, [hRandomSub]
sbc b
- ld [$ffe2], a
+ ld [hRandomSub], a
pop bc
ret
; 2f9f
@@ -2614,7 +2672,7 @@ FarBattleRNG: ; 2f9f
; allowing link battles to remain in sync using a shared PRNG.
; Save bank
- ld a, [$ff9d] ; bank
+ ld a, [hROMBank] ; bank
push af
; Bankswitch
ld a, BANK(BattleRNG)
@@ -2641,14 +2699,14 @@ Function2fb1: ; 2fb1
ld b, a
push bc
.asm_2fbb
- call $2f8c
- ld a, [$ffe1]
+ call RNG
+ ld a, [hRandomAdd]
ld c, a
add b
jr c, .asm_2fbb
ld a, c
pop bc
- call $3110
+ call SimpleDivide
pop bc
ret
; 2fcb
@@ -2665,25 +2723,25 @@ OpenSRAM: ; 2fd1
; switch to sram bank a
push af
; latch clock data
- ld a, $1
- ld [$6000], a
+ ld a, 1
+ ld [MBC3LatchClock], a
; enable sram/clock write
- ld a, $a
- ld [$0000], a
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
; select sram bank
pop af
- ld [$4000], a
+ ld [MBC3SRamBank], a
ret
; 2fe1
CloseSRAM: ; 2fe1
; preserve a
push af
- ld a, $0
+ ld a, SRAM_DISABLE
; reset clock latch for next time
- ld [$6000], a
+ ld [MBC3LatchClock], a
; disable sram/clock write
- ld [$0000], a
+ ld [MBC3SRamEnable], a
pop af
ret
; 2fec
@@ -2692,7 +2750,7 @@ JpHl: ; 2fec
jp [hl]
; 2fed
-INCBIN "baserom.gbc",$2fed,$300b-$2fed
+INCBIN "baserom.gbc", $2fed, $300b-$2fed
ClearSprites: ; 300b
ld hl, Sprites
@@ -2775,31 +2833,31 @@ ByteFill: ; 0x3041
GetFarByte: ; 0x304d
; retrieve a single byte from a:hl, and return it in a.
; bankswitch to new bank
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
; get byte from new bank
ld a, [hl]
- ld [$ff8b], a
+ ld [hBuffer], a
; bankswitch to previous bank
pop af
rst Bankswitch
; return retrieved value in a
- ld a, [$ff8b]
+ ld a, [hBuffer]
ret
GetFarHalfword: ; 0x305d
; retrieve a halfword from a:hl, and return it in hl.
; bankswitch to new bank
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
; get halfword from new bank, put it in hl
@@ -2813,7 +2871,7 @@ GetFarHalfword: ; 0x305d
ret
; 0x306b
-INCBIN "baserom.gbc",$306b,$30d6-$306b
+INCBIN "baserom.gbc", $306b, $30d6-$306b
CopyName1: ; 30d6
ld hl, StringBuffer2
@@ -2836,7 +2894,7 @@ IsInArray: ; 30e1
ld c,a
.loop\@
ld a,[hl]
- cp a,$FF
+ cp a, $FF
jr z,.NotInArray\@
cp c
jr z,.InArray\@
@@ -2874,33 +2932,83 @@ AddNTimes: ; 0x30fe
ret
; 0x3105
-INCBIN "baserom.gbc",$3105,$3119-$3105
-
-Multiply: ; 0x3119
-; function to do multiplication
-; all values are big endian
-; INPUT
-; ffb4-ffb6 = multiplicand
-; ffb7 = multiplier
-; OUTPUT
-; ffb3-ffb6 = product
- INCBIN "baserom.gbc",$3119,$3124 - $3119
-; 0x3124
-
-Divide: ; 0x3124
-; function to do division
-; all values are big endian
-; INPUT
-; ffb3-ffb6 = dividend
-; ffb7 = divisor
-; b = number of bytes in the dividend (starting from ffb3)
-; OUTPUT
-; ffb4-ffb6 = quotient
-; ffb7 = remainder
- INCBIN "baserom.gbc",$3124,$3136 - $3124
-; 0x3136
-
-INCBIN "baserom.gbc",$3136,$313d - $3136
+
+SimpleMultiply: ; 3105
+; Return a * c.
+ and a
+ ret z
+
+ push bc
+ ld b, a
+ xor a
+.loop
+ add c
+ dec b
+ jr nz, .loop
+ pop bc
+ ret
+; 3110
+
+
+SimpleDivide: ; 3110
+; Divide a by c. Return quotient b and remainder a.
+ ld b, 0
+.loop
+ inc b
+ sub c
+ jr nc, .loop
+ dec b
+ add c
+ ret
+; 3119
+
+
+Multiply: ; 3119
+; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct.
+; All values are big endian.
+ push hl
+ push bc
+
+ callab _Multiply
+
+ pop bc
+ pop hl
+ ret
+; 3124
+
+
+Divide: ; 3124
+; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient.
+; All values are big endian.
+ push hl
+ push de
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_Divide)
+ rst Bankswitch
+
+ call _Divide
+
+ pop af
+ rst Bankswitch
+ pop bc
+ pop de
+ pop hl
+ ret
+; 3136
+
+
+SubtractSigned: ; 3136
+; Return a - b, sign in carry.
+ sub b
+ ret nc
+ cpl
+ add 1
+ scf
+ ret
+; 313d
+
PrintLetterDelay: ; 313d
; wait some frames before printing the next letter
@@ -2926,7 +3034,7 @@ PrintLetterDelay: ; 313d
push bc
; save oam update status
- ld hl, $ffd8
+ ld hl, hOAMUpdate
ld a, [hl]
push af
; orginally turned oam update off, commented out
@@ -2957,7 +3065,7 @@ PrintLetterDelay: ; 313d
jr nz, .wait
; wait one frame if holding a
- ld a, [$ffa8] ; joypad
+ ld a, [hJoyDown] ; joypad
bit 0, a ; A
jr z, .checkb
jr .delay
@@ -2981,7 +3089,7 @@ PrintLetterDelay: ; 313d
.end
; restore oam update flag (not touched in this fn anymore)
pop af
- ld [$ffd8], a
+ ld [hOAMUpdate], a
pop bc
pop de
pop hl
@@ -3004,7 +3112,7 @@ CopyDataUntil: ; 318c
ret
; 0x3198
-INCBIN "baserom.gbc",$3198,$31db - $3198
+INCBIN "baserom.gbc", $3198, $31db - $3198
StringCmp: ; 31db
; Compare strings, c bytes in length, at de and hl.
@@ -3019,27 +3127,50 @@ StringCmp: ; 31db
ret
; 0x31e4
-INCBIN "baserom.gbc",$31e4,$31f3 - $31e4
+
+CompareLong: ; 31e4
+; Compare bc bytes at de and hl. Return carry if they all match.
+
+ ld a, [de]
+ cp [hl]
+ jr nz, .Diff
+
+ inc de
+ inc hl
+ dec bc
+
+ ld a, b
+ or c
+ jr nz, CompareLong
+
+ scf
+ ret
+
+.Diff
+ and a
+ ret
+; 31f3
+
WhiteBGMap: ; 31f3
call ClearPalettes
WaitBGMap: ; 31f6
; Tell VBlank to update BG Map
ld a, 1 ; BG Map 0 tiles
- ld [$ffd4], a
+ ld [hBGMapMode], a
; Wait for it to do its magic
ld c, 4
call DelayFrames
ret
; 3200
-INCBIN "baserom.gbc",$3200,$3317 - $3200
+INCBIN "baserom.gbc", $3200, $3317 - $3200
ClearPalettes: ; 3317
; Make all palettes white
; For CGB we make all the palette colors white
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
@@ -3052,11 +3183,11 @@ ClearPalettes: ; 3317
.cgb
; Save WRAM bank
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
; WRAM bank 5
ld a, 5
- ld [$ff70], a
+ ld [rSVBK], a
; Fill BGPals and OBPals with $ffff (white)
ld hl, BGPals
ld bc, $0080
@@ -3064,10 +3195,10 @@ ClearPalettes: ; 3317
call ByteFill
; Restore WRAM bank
pop af
- ld [$ff70], a
+ ld [rSVBK], a
; Request palette update
ld a, 1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
ret
; 333e
@@ -3077,12 +3208,12 @@ GetSGBLayout: ; 3340
; load sgb packets unless dmg
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .dosgb
; check sgb
- ld a, [$ffe7]
+ ld a, [hSGB]
and a
ret z
@@ -3091,7 +3222,29 @@ GetSGBLayout: ; 3340
jp Predef
; 334e
-INCBIN "baserom.gbc",$334e,$335f - $334e
+
+SetHPPal: ; 334e
+; Set palette for hp bar pixel length e at hl.
+ call GetHPPal
+ ld [hl], d
+ ret
+; 3353
+
+
+GetHPPal: ; 3353
+; Get palette for hp bar pixel length e in d.
+
+ ld d, 0 ; green
+ ld a, e
+ cp 24
+ ret nc
+ inc d ; yellow
+ cp 10
+ ret nc
+ inc d ; red
+ ret
+; 335f
+
CountSetBits: ; 0x335f
; function to count how many bits are set in a string of bytes
@@ -3119,56 +3272,115 @@ CountSetBits: ; 0x335f
ret
; 0x3376
-INCBIN "baserom.gbc",$3376,$33ab - $3376
+
+GetWeekday: ; 3376
+ ld a, [CurDay]
+.loop
+ sub 7
+ jr nc, .loop
+ add 7
+ ret
+; 3380
+
+
+SetSeenAndCaughtMon: ; 3380
+ push af
+ ld c, a
+ ld hl, PokedexSeen
+ ld b, 1
+ call GetWramFlag
+ pop af
+ ; fallthrough
+; 338b
+
+SetCaughtMon: ; 338b
+ ld c, a
+ ld hl, PokedexCaught
+ ld b, 1
+ jr GetWramFlag
+; 3393
+
+CheckSeenMon: ; 3393
+ ld c, a
+ ld hl, PokedexSeen
+ ld b, 2
+ jr GetWramFlag
+; 339b
+
+CheckCaughtMon: ; 339b
+ ld c, a
+ ld hl, PokedexCaught
+ ld b, 2
+ ; fallthrough
+; 33a1
+
+GetWramFlag: ; 33a1
+ ld d, 0
+ ld a, PREDEF_FLAG
+ call Predef
+
+ ld a, c
+ and a
+ ret
+; 33ab
+
NamesPointerTable: ; 33ab
dbw BANK(PokemonNames), PokemonNames
dbw BANK(MoveNames), MoveNames
dbw $00, $0000
dbw BANK(ItemNames), ItemNames
- dbw $00, $ddff
- dbw $00, $d3a8
+ dbw $00, PartyMonOT
+ dbw $00, OTPartyMonOT
dbw BANK(TrainerClassNames), TrainerClassNames
dbw $04, $4b52
+; 33c3
+
GetName: ; 33c3
- ld a, [$ff9d]
+; Return name $cf60 from name list $cf61 in StringBuffer1.
+ ld a, [hROMBank]
push af
push hl
push bc
push de
ld a, [$cf61]
- cp $1
- jr nz, .asm_33e1 ; 0x33ce $11
+ cp 1 ; Pokemon names
+ jr nz, .NotPokeName
+
ld a, [$cf60]
ld [$d265], a
- call $343b
+ call GetPokemonName
ld hl, $000b
add hl, de
ld e, l
ld d, h
- jr .asm_3403 ; 0x33df $22
-.asm_33e1
+ jr .done
+
+.NotPokeName
ld a, [$cf61]
dec a
ld e, a
- ld d, $0
+ ld d, 0
ld hl, NamesPointerTable
add hl, de
add hl, de
add hl, de
ld a, [hli]
- rst Bankswitch ; Bankswitch
+ rst Bankswitch
ld a, [hli]
ld h, [hl]
ld l, a
+
ld a, [$cf60]
dec a
call GetNthString
- ld de, $d073
+
+ ld de, StringBuffer1
ld bc, $000d
call CopyBytes
-.asm_3403
+
+.done
ld a, e
ld [$d102], a
ld a, d
@@ -3179,9 +3391,8 @@ GetName: ; 33c3
pop af
rst Bankswitch
ret
-; 0x3411
+; 3411
-INCBIN "baserom.gbc",$3411,$3411 - $3411
GetNthString: ; 3411
; Starting at hl, this function returns the start address of the ath string.
@@ -3193,61 +3404,255 @@ GetNthString: ; 3411
.readChar
ld a, [hli]
cp c
- jr nz, .readChar ; 0x3419 $fc
+ jr nz, .readChar
dec b
- jr nz, .readChar ; 0x341c $f9
+ jr nz, .readChar
pop bc
ret
-; 0x3420
+; 3420
+
+
+GetBasePokemonName: ; 3420
+; Discards gender (Nidoran).
+ push hl
+ call GetPokemonName
+
+ ld hl, StringBuffer1
+.loop
+ ld a, [hl]
+ cp "@"
+ jr z, .quit
+ cp "♂"
+ jr z, .end
+ cp "♀"
+ jr z, .end
+ inc hl
+ jr .loop
+.end
+ ld [hl], "@"
+.quit
+ pop hl
+ ret
+
+; 343b
+
+
+GetPokemonName: ; 343b
+; Get Pokemon name $d265.
+
+ ld a, [hROMBank]
+ push af
+ push hl
+ ld a, BANK(PokemonNames)
+ rst Bankswitch
+
+; Each name is ten characters
+ ld a, [$d265]
+ dec a
+ ld d, 0
+ ld e, a
+ ld h, 0
+ ld l, a
+ add hl, hl
+ add hl, hl
+ add hl, de
+ add hl, hl
+ ld de, PokemonNames
+ add hl, de
+
+; Terminator
+ ld de, StringBuffer1
+ push de
+ ld bc, PKMN_NAME_LENGTH - 1
+ call CopyBytes
+ ld hl, StringBuffer1 + PKMN_NAME_LENGTH - 1
+ ld [hl], "@"
+ pop de
+
+ pop hl
+ pop af
+ rst Bankswitch
+ ret
+; 3468
-INCBIN "baserom.gbc",$3420,$3468 - $3420
GetItemName: ; 3468
+; Get item name $d265.
+
push hl
push bc
- ld a, [$d265] ; Get the item
- cp $bf ; Is it a TM?
- jr nc, .tm ; 0x346f $d
+ ld a, [$d265]
+
+ cp TM_01
+ jr nc, .TM
+
ld [$cf60], a
- ld a, $4 ; Item names
+ ld a, 4 ; Item names
ld [$cf61], a
call GetName
- jr .copied ; 0x347c $3
-.tm
- call $3487
-.copied
- ld de, $d073
+ jr .Copied
+.TM
+ call GetTMHMName
+.Copied
+ ld de, StringBuffer1
+ pop bc
+ pop hl
+ ret
+; 3487
+
+
+GetTMHMName: ; 3487
+; Get TM/HM name by item id $d265.
+
+ push hl
+ push de
+ push bc
+ ld a, [$d265]
+ push af
+
+; TM/HM prefix
+ cp HM_01
+ push af
+ jr c, .TM
+
+ ld hl, .HMText
+ ld bc, .HMTextEnd - .HMText
+ jr .asm_34a1
+
+.TM
+ ld hl, .TMText
+ ld bc, .TMTextEnd - .TMText
+
+.asm_34a1
+ ld de, StringBuffer1
+ call CopyBytes
+
+; TM/HM number
+ push de
+ ld a, [$d265]
+ ld c, a
+ callab GetTMHMNumber
+ pop de
+
+; HM numbers start from 51, not 1
+ pop af
+ ld a, c
+ jr c, .asm_34b9
+ sub NUM_TMS
+
+; Divide and mod by 10 to get the top and bottom digits respectively
+.asm_34b9
+ ld b, "0"
+.mod10
+ sub 10
+ jr c, .asm_34c2
+ inc b
+ jr .mod10
+.asm_34c2
+ add 10
+
+ push af
+ ld a, b
+ ld [de], a
+ inc de
+ pop af
+
+ ld b, "0"
+ add b
+ ld [de], a
+
+; End the string
+ inc de
+ ld a, "@"
+ ld [de], a
+
+ pop af
+ ld [$d265], a
pop bc
+ pop de
pop hl
ret
-; 0x3487
-INCBIN "baserom.gbc",$3487,$3856 - $3487
+.TMText
+ db "TM"
+.TMTextEnd
+ db "@"
+
+.HMText
+ db "HM"
+.HMTextEnd
+ db "@"
+; 34df
+
+
+IsHM: ; 34df
+ cp HM_01
+ jr c, .NotHM
+ scf
+ ret
+.NotHM
+ and a
+ ret
+; 34e7
+
-GetBaseStats: ; 3856
+IsHMMove: ; 34e7
+ ld hl, .HMMoves
+ ld de, 1
+ jp IsInArray
+
+.HMMoves
+ db CUT
+ db FLY
+ db SURF
+ db STRENGTH
+ db FLASH
+ db WATERFALL
+ db WHIRLPOOL
+ db $ff
+; 34f8
+
+
+GetMoveName: ; 34f8
+ push hl
+; move name
+ ld a, $2 ; move names
+ ld [$cf61], a
+; move id
+ ld a, [$d265]
+ ld [$cf60], a
+
+ call GetName
+ ld de, StringBuffer1
+ pop hl
+ ret
+; 350c
+
+
+INCBIN "baserom.gbc", $350c, $3856 - $350c
+
+
+GetBaseData: ; 3856
push bc
push de
push hl
-
-; Save bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
-; Bankswitch
- ld a, BANK(BaseStats)
+ ld a, BANK(BaseData)
rst Bankswitch
-; Egg doesn't have base stats
+; Egg doesn't have BaseData
ld a, [CurSpecies]
cp EGG
jr z, .egg
-; Get base stats
+; Get BaseData
dec a
- ld bc, BaseStats1 - BaseStats0
- ld hl, BaseStats
+ ld bc, BaseData1 - BaseData0
+ ld hl, BaseData
call AddNTimes
- ld de, CurBaseStats
- ld bc, BaseStats1 - BaseStats0
+ ld de, CurBaseData
+ ld bc, BaseData1 - BaseData0
call CopyBytes
jr .end
@@ -3256,12 +3661,12 @@ GetBaseStats: ; 3856
ld de, $7d9c
; Sprite dimensions
- ld b, $55
- ld hl, $d247
+ ld b, $55 ; 5x5
+ ld hl, BasePicSize
ld [hl], b
; ????
- ld hl, $d248
+ ld hl, BasePadding
ld [hl], e
inc hl
ld [hl], d
@@ -3274,44 +3679,43 @@ GetBaseStats: ; 3856
.end
; Replace Pokedex # with species
ld a, [CurSpecies]
- ld [CurBaseStats], a
+ ld [BaseDexNo], a
-; Restore bank
pop af
rst Bankswitch
-
pop hl
pop de
pop bc
ret
; 389c
-INCBIN "baserom.gbc",$389c,$38a2 - $389c
-GetNick: ; 38a2
-; get the nickname of a partymon
-; write nick to StringBuffer1
+GetCurNick; 389c
+ ld a, [CurPartyMon]
+ ld hl, PartyMonNicknames
-; input: a = which mon (0-5)
+GetNick: ; 38a2
+; Get nickname a from list hl.
push hl
push bc
- ; skip [a] nicks
+
call SkipNames
ld de, StringBuffer1
- ; write nick
+
push de
ld bc, PKMN_NAME_LENGTH
call CopyBytes
- ; error-check
pop de
+
callab CheckNickErrors
- ; we're done
+
pop bc
pop hl
ret
; 38bb
+
PrintBCDNumber: ; 38bb
; function to print a BCD (Binary-coded decimal) number
; de = address of BCD number
@@ -3407,54 +3811,464 @@ GetPartyParamLocation: ; 3917
; 3927
GetPartyLocation: ; 3927
-; Add the length of a PartyMon struct to hl a times
-; input:
-; a: partymon #
-; hl: partymon struct
- ld bc, $0030 ; PARTYMON_LENGTH
+; Add the length of a PartyMon struct to hl a times.
+ ld bc, PartyMon2 - PartyMon1
jp AddNTimes
; 392d
-INCBIN "baserom.gbc",$392d,$3b86 - $392d
+
+INCBIN "baserom.gbc", $392d, $3945 - $392d
+
+
+UserPartyAttr: ; 3945
+ push af
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .asm_394e
+ pop af
+ jr BattlePartyAttr
+.asm_394e
+ pop af
+ jr OTPartyAttr
+; 3951
+
+
+OpponentPartyAttr: ; 3951
+ push af
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_395a
+ pop af
+ jr BattlePartyAttr
+.asm_395a
+ pop af
+ jr OTPartyAttr
+; 395d
+
+
+BattlePartyAttr: ; 395d
+; Get attribute a from the active BattleMon's party struct.
+ push bc
+ ld c, a
+ ld b, 0
+ ld hl, PartyMons
+ add hl, bc
+ ld a, [CurBattleMon]
+ call GetPartyLocation
+ pop bc
+ ret
+; 396d
+
+
+OTPartyAttr: ; 396d
+; Get attribute a from the active EnemyMon's party struct.
+ push bc
+ ld c, a
+ ld b, 0
+ ld hl, OTPartyMon1Species
+ add hl, bc
+ ld a, [CurOTMon]
+ call GetPartyLocation
+ pop bc
+ ret
+; 397d
+
+
+ResetDamage: ; 397d
+ xor a
+ ld [CurDamage], a
+ ld [CurDamage + 1], a
+ ret
+; 3985
+
+SetPlayerTurn: ; 3985
+ xor a
+ ld [hBattleTurn], a
+ ret
+; 3989
+
+SetEnemyTurn: ; 3989
+ ld a, 1
+ ld [hBattleTurn], a
+ ret
+; 398e
+
+
+UpdateOpponentInParty: ; 398e
+ ld a, [hBattleTurn]
+ and a
+ jr z, UpdateEnemyMonInParty
+ jr UpdateBattleMonInParty
+; 3995
+
+UpdateUserInParty: ; 3995
+ ld a, [hBattleTurn]
+ and a
+ jr z, UpdateBattleMonInParty
+ jr UpdateEnemyMonInParty
+; 399c
+
+UpdateBattleMonInParty: ; 399c
+; Update level, status, current HP
+
+ ld a, [CurBattleMon]
+ ld hl, PartyMon1Level
+ call GetPartyLocation
+
+ ld d, h
+ ld e, l
+ ld hl, BattleMonLevel
+ ld bc, BattleMonMaxHP - BattleMonLevel
+ jp CopyBytes
+; 39b0
+
+UpdateEnemyMonInParty: ; 39b0
+; Update level, status, current HP
+
+; No wildmons.
+ ld a, [IsInBattle]
+ dec a
+ ret z
+
+ ld a, [CurOTMon]
+ ld hl, OTPartyMon1Level
+ call GetPartyLocation
+
+ ld d, h
+ ld e, l
+ ld hl, EnemyMonLevel
+ ld bc, EnemyMonMaxHP - EnemyMonLevel
+ jp CopyBytes
+; 39c9
+
+
+RefreshBattleHuds: ; 39c9
+ call UpdateBattleHuds
+ ld c, 3
+ call DelayFrames
+ jp WaitBGMap
+; 39d4
+
+UpdateBattleHuds: ; 39d4
+ ld a, $f
+ ld hl, $5f48
+ rst FarCall ; UpdatePlayerHud
+ ld a, $f
+ ld hl, $6036
+ rst FarCall ; UpdateEnemyHud
+ ret
+; 39e1
+
+
+CleanGetBattleVarPair: ; 39e1
+; Preserves hl.
+ push hl
+ call GetBattleVarPair
+ pop hl
+ ret
+; 39e7
+
+GetBattleVarPair: ; 39e7
+; Get variable from pair a, depending on whose turn it is.
+; There are 21 variable pairs.
+
+ push bc
+
+; get var pair
+ ld hl, .battlevarpairs
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; Enemy turn uses the second byte instead.
+; This lets battle variable calls be side-neutral.
+ ld a, [hBattleTurn]
+ and a
+ jr z, .getvar
+ inc hl
+
+.getvar
+; get var id
+ ld a, [hl]
+ ld c, a
+ ld b, $0
+
+; seek
+ ld hl, .vars
+ add hl, bc
+ add hl, bc
+
+; get var address
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld a, [hl]
+
+ pop bc
+ ret
+
+
+.battlevarpairs
+ dw .substatus1 ; 0
+ dw .substatus2 ; 1
+ dw .substatus3 ; 2
+ dw .substatus4 ; 3
+ dw .substatus5 ; 4
+ dw .substatus1opp ; 5
+ dw .substatus2opp ; 6
+ dw .substatus3opp ; 7
+ dw .substatus4opp ; 8
+ dw .substatus5opp ; 9
+ dw .status ; a
+ dw .statusopp ; b
+ dw .animation ; c
+ dw .effect ; d
+ dw .power ; e
+ dw .type ; f
+ dw .curmove ; 10
+ dw .lastcountermove ; 11
+ dw .lastcountermoveopp ; 12
+ dw .lastmove ; 13
+ dw .lastmoveopp ; 14
+
+ ; player enemy
+.substatus1
+ db $00, $01 ; PLAYER_SUBSTATUS1, ENEMY_SUBSTATUS1
+.substatus1opp
+ db $01, $00 ; ENEMY_SUBSTATUS1, PLAYER_SUBSTATUS1
+.substatus2
+ db $02, $03 ; PLAYER_SUBSTATUS2, ENEMY_SUBSTATUS2
+.substatus2opp
+ db $03, $02 ; ENEMY_SUBSTATUS2, PLAYER_SUBSTATUS2
+.substatus3
+ db $04, $05 ; PLAYER_SUBSTATUS3, ENEMY_SUBSTATUS3
+.substatus3opp
+ db $05, $04 ; ENEMY_SUBSTATUS3, PLAYER_SUBSTATUS3
+.substatus4
+ db $06, $07 ; PLAYER_SUBSTATUS4, ENEMY_SUBSTATUS4
+.substatus4opp
+ db $07, $06 ; ENEMY_SUBSTATUS4, PLAYER_SUBSTATUS4
+.substatus5
+ db $08, $09 ; PLAYER_SUBSTATUS5, ENEMY_SUBSTATUS5
+.substatus5opp
+ db $09, $08 ; ENEMY_SUBSTATUS5, PLAYER_SUBSTATUS5
+.status
+ db $0a, $0b ; PLAYER_STATUS, ENEMY_STATUS
+.statusopp
+ db $0b, $0a ; ENEMY_STATUS, PLAYER_STATUS
+.animation
+ db $0c, $0d ; PLAYER_MOVE_ANIMATION, ENEMY_MOVE_ANIMATION
+.effect
+ db $0e, $0f ; PLAYER_MOVE_EFFECT, ENEMY_MOVE_EFFECT
+.power
+ db $10, $11 ; PLAYER_MOVE_POWER, ENEMY_MOVE_POWER
+.type
+ db $12, $13 ; PLAYER_MOVE_TYPE, ENEMY_MOVE_TYPE
+.curmove
+ db $14, $15 ; PLAYER_CUR_MOVE, ENEMY_CUR_MOVE
+.lastcountermove
+ db $16, $17 ; ENEMY_LAST_COUNTER_MOVE, PLAYER_LAST_COUNTER_MOVE
+.lastcountermoveopp
+ db $17, $16 ; PLAYER_LAST_COUNTER_MOVE, ENEMY_LAST_COUNTER_MOVE
+.lastmove
+ db $18, $19 ; PLAYER_LAST_MOVE, ENEMY_LAST_MOVE
+.lastmoveopp
+ db $19, $18 ; ENEMY_LAST_MOVE, PLAYER_LAST_MOVE
+
+.vars
+ dw PlayerSubStatus1
+ dw EnemySubStatus1
+
+ dw PlayerSubStatus2
+ dw EnemySubStatus2
+
+ dw PlayerSubStatus3
+ dw EnemySubStatus3
+
+ dw PlayerSubStatus4
+ dw EnemySubStatus4
+
+ dw PlayerSubStatus5
+ dw EnemySubStatus5
+
+ dw BattleMonStatus
+ dw EnemyMonStatus
+
+ dw PlayerMoveAnimation
+ dw EnemyMoveAnimation
+
+ dw PlayerMoveEffect
+ dw EnemyMoveEffect
+
+ dw PlayerMovePower
+ dw EnemyMovePower
+
+ dw PlayerMoveType
+ dw EnemyMoveType
+
+ dw CurPlayerMove
+ dw CurEnemyMove
+
+ dw LastEnemyCounterMove
+ dw LastPlayerCounterMove
+
+ dw LastPlayerMove
+ dw LastEnemyMove
+; 3a90
+
+INCBIN "baserom.gbc", $3a90, $3ab2 - $3a90
+
+
+MobileTextBorder: ; 3ab2
+; For mobile link battles only.
+ ld a, [InLinkBattle]
+ cp 4
+ ret c
+; Draw a cell phone icon at the top right corner of the border.
+ ld hl, $c5a3 ; TileMap(19,12)
+ ld [hl], $5e ; cell phone top
+ ld hl, $c5b7 ; TileMap(19,13)
+ ld [hl], $5f ; cell phone bottom
+ ret
+; 3ac3
+
+
+BattleTextBox: ; 3ac3
+ push hl
+ call SpeechTextBox
+ call MobileTextBorder
+ call $1ad2 ; UpdateSprites
+ call $321c ; refresh?
+ pop hl
+ call PrintTextBoxText
+ ret
+; 3ad5
+
+
+FarBattleTextBox: ; 3ad5
+; Open a textbox and print text at 20:hl.
+
+ ld a, [hROMBank]
+ push af
+
+ ld a, $20
+ rst Bankswitch
+
+ call BattleTextBox
+
+ pop af
+ rst Bankswitch
+ ret
+; 3ae1
+
+
+INCBIN "baserom.gbc", $3ae1, $3b4e - $3ae1
+
+
+CleanSoundRestart: ; 3b4e
+
+ push hl
+ push de
+ push bc
+ push af
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(SoundRestart)
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ call SoundRestart
+
+ pop af
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ pop af
+ pop bc
+ pop de
+ pop hl
+ ret
+; 3b6a
+
+
+CleanUpdateSound: ; 3b6a
+
+ push hl
+ push de
+ push bc
+ push af
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(UpdateSound)
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ call UpdateSound
+
+ pop af
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ pop af
+ pop bc
+ pop de
+ pop hl
+ ret
+; 3b86
+
LoadMusicByte: ; 3b86
-; load music data into CurMusicByte
-; input:
-; a: bank
-; de: address
- ld [$ff9d], a
- ld [$2000], a ; bankswitch
+; CurMusicByte = [a:de]
+
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
ld a, [de]
ld [CurMusicByte], a
ld a, $3a ; manual bank restore
- ld [$ff9d], a
- ld [$2000], a ; bankswitch
+
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
ret
; 3b97
+
StartMusic: ; 3b97
-; input:
-; e = song number
+; Play music de.
+
push hl
push de
push bc
push af
- ld a, [$ff9d] ; save bank
+
+ ld a, [hROMBank]
push af
- ld a, BANK(LoadMusic)
- ld [$ff9d], a
- ld [$2000], a ; bankswitch
- ld a, e ; song number
+ ld a, BANK(LoadMusic) ; and BANK(SoundRestart)
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ ld a, e
and a
jr z, .nomusic
+
call LoadMusic
jr .end
+
.nomusic
call SoundRestart
+
.end
pop af
- ld [$ff9d], a ; restore bank
- ld [$2000], a
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
pop af
pop bc
pop de
@@ -3462,25 +4276,58 @@ StartMusic: ; 3b97
ret
; 3bbc
-INCBIN "baserom.gbc",$3bbc,$3be3 - $3bbc
+
+StartMusic2: ; 3bbc
+; Stop playing music, then play music de.
+
+ push hl
+ push de
+ push bc
+ push af
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(LoadMusic)
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ push de
+ ld de, MUSIC_NONE
+ call LoadMusic
+ call DelayFrame
+ pop de
+ call LoadMusic
+
+ pop af
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ pop af
+ pop bc
+ pop de
+ pop hl
+ ret
+
+; 3be3
+
PlayCryHeader: ; 3be3
; Play a cry given parameters in header de
-
+
push hl
push de
push bc
push af
-
+
; Save current bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
-
+
; Cry headers are stuck in one bank.
ld a, BANK(CryHeaders)
- ld [$ff9d], a
- ld [$2000], a
-
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
; Each header is 6 bytes long:
ld hl, CryHeaders
add hl, de
@@ -3489,36 +4336,30 @@ PlayCryHeader: ; 3be3
add hl, de
add hl, de
add hl, de
-
-; Header struct:
-; id
ld e, [hl]
inc hl
ld d, [hl]
inc hl
-; pitch
+
ld a, [hli]
ld [CryPitch], a
-; echo
ld a, [hli]
ld [CryEcho], a
-; length
ld a, [hli]
ld [CryLength], a
ld a, [hl]
ld [CryLength+1], a
-
-; That's it for the header
+
ld a, BANK(PlayCry)
- ld [$ff9d], a
- ld [$2000], a
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
call PlayCry
-
-; Restore bank
+
pop af
- ld [$ff9d], a
- ld [$2000], a
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
pop af
pop bc
@@ -3529,32 +4370,36 @@ PlayCryHeader: ; 3be3
StartSFX: ; 3c23
-; sfx id order is by priority (highest to lowest)
-; to disable this, remove the check!
-; input: de = sfx id
+; Play sound effect de.
+; Sound effects are ordered by priority (lowest to highest)
+
push hl
push de
push bc
push af
- ; is something already playing?
+
+; Is something already playing?
call CheckSFX
- jr nc, .asm_3c32
- ; only play sfx if it has priority
+ jr nc, .play
+; Does it have priority?
ld a, [CurSFX]
cp e
jr c, .quit
-.asm_3c32
- ld a, [$ff9d] ; save bank
+
+.play
+ ld a, [hROMBank]
push af
- ld a, $3a ; music bank
- ld [$ff9d], a
- ld [$2000], a ; bankswitch
+ ld a, BANK(LoadSFX)
+ ld [hROMBank], a
+ ld [MBC3RomBank], a ; bankswitch
+
ld a, e
ld [CurSFX], a
call LoadSFX
+
pop af
- ld [$ff9d], a ; restore bank
- ld [$2000], a ; bankswitch
+ ld [hROMBank], a
+ ld [MBC3RomBank], a ; bankswitch
.quit
pop af
pop bc
@@ -3563,36 +4408,42 @@ StartSFX: ; 3c23
ret
; 3c4e
-INCBIN "baserom.gbc",$3c4e,$3c55-$3c4e
+
+WaitPlaySFX: ; 3c4e
+ call WaitSFX
+ call StartSFX
+ ret
+; 3c55
+
WaitSFX: ; 3c55
; infinite loop until sfx is done playing
+
push hl
.loop
; ch5 on?
- ld hl, $c1cc ; Channel5Flags
+ ld hl, Channel5 + Channel1Flags - Channel1
bit 0, [hl]
jr nz, .loop
; ch6 on?
- ld hl, $c1fe ; Channel6Flags
+ ld hl, Channel6 + Channel1Flags - Channel1
bit 0, [hl]
jr nz, .loop
; ch7 on?
- ld hl, $c230 ; Channel7Flags
+ ld hl, Channel7 + Channel1Flags - Channel1
bit 0, [hl]
jr nz, .loop
; ch8 on?
- ld hl, $c262 ; Channel8Flags
+ ld hl, Channel8 + Channel1Flags - Channel1
bit 0, [hl]
jr nz, .loop
- ; we're done
pop hl
ret
; 3c74
-INCBIN "baserom.gbc",$3c74,$3c97-$3c74
+INCBIN "baserom.gbc", $3c74, $3c97-$3c74
MaxVolume: ; 3c97
ld a, $77 ; max
@@ -3612,7 +4463,7 @@ VolumeOff: ; 3ca3
ret
; 3ca8
-INCBIN "baserom.gbc",$3ca8,$3dde - $3ca8
+INCBIN "baserom.gbc", $3ca8, $3dde - $3ca8
CheckSFX: ; 3dde
; returns carry if sfx channels are active
@@ -3635,7 +4486,7 @@ CheckSFX: ; 3dde
ret
; 3dfe
-INCBIN "baserom.gbc",$3dfe,$3e10 - $3dfe
+INCBIN "baserom.gbc", $3dfe, $3e10 - $3dfe
ChannelsOff: ; 3e10
; Quickly turn off music channels
@@ -3659,12 +4510,12 @@ SFXChannelsOff: ; 3e21
ret
; 3e32
-INCBIN "baserom.gbc",$3e32,$3fb5 - $3e32
+INCBIN "baserom.gbc", $3e32, $3fb5 - $3e32
SECTION "bank1",DATA,BANK[$1]
-INCBIN "baserom.gbc",$4000,$617c - $4000
+INCBIN "baserom.gbc", $4000, $617c - $4000
IntroFadePalettes: ; 0x617c
db %01010100
@@ -3675,14 +4526,14 @@ IntroFadePalettes: ; 0x617c
db %11100100
; 6182
-INCBIN "baserom.gbc",$6182,$6274 - $6182
+INCBIN "baserom.gbc", $6182, $6274 - $6182
FarStartTitleScreen: ; 6274
callba StartTitleScreen
ret
; 627b
-INCBIN "baserom.gbc",$627b,$62bc - $627b
+INCBIN "baserom.gbc", $627b, $62bc - $627b
TitleScreenEntrance: ; 62bc
@@ -3723,7 +4574,7 @@ TitleScreenEntrance: ; 62bc
ld hl, $cf63
inc [hl]
xor a
- ld [$ffc6], a
+ ld [hLCDStatCustom], a
; Play the title screen music.
ld de, MUSIC_TITLE
@@ -3734,7 +4585,7 @@ TitleScreenEntrance: ; 62bc
ret
; 62f6
-INCBIN "baserom.gbc",$62f6,$669f - $62f6
+INCBIN "baserom.gbc", $62f6, $669f - $62f6
CheckNickErrors: ; 669f
; error-check monster nick before use
@@ -3814,7 +4665,212 @@ CheckNickErrors: ; 669f
db $ff ; end
; 66de
-INCBIN "baserom.gbc",$66de,$6eef - $66de
+
+_Multiply: ; 66de
+
+; hMultiplier is one byte.
+ ld a, 8
+ ld b, a
+
+ xor a
+ ld [hMultiplicand - 1], a
+ ld [hMathBuffer + 1], a
+ ld [hMathBuffer + 2], a
+ ld [hMathBuffer + 3], a
+ ld [hMathBuffer + 4], a
+
+
+.loop
+ ld a, [hMultiplier]
+ srl a
+ ld [hMultiplier], a
+ jr nc, .next
+
+ ld a, [hMathBuffer + 4]
+ ld c, a
+ ld a, [hMultiplicand + 2]
+ add c
+ ld [hMathBuffer + 4], a
+
+ ld a, [hMathBuffer + 3]
+ ld c, a
+ ld a, [hMultiplicand + 1]
+ adc c
+ ld [hMathBuffer + 3], a
+
+ ld a, [hMathBuffer + 2]
+ ld c, a
+ ld a, [hMultiplicand + 0]
+ adc c
+ ld [hMathBuffer + 2], a
+
+ ld a, [hMathBuffer + 1]
+ ld c, a
+ ld a, [hMultiplicand - 1]
+ adc c
+ ld [hMathBuffer + 1], a
+
+.next
+ dec b
+ jr z, .done
+
+
+; hMultiplicand <<= 1
+
+ ld a, [hMultiplicand + 2]
+ add a
+ ld [hMultiplicand + 2], a
+
+ ld a, [hMultiplicand + 1]
+ rla
+ ld [hMultiplicand + 1], a
+
+ ld a, [hMultiplicand + 0]
+ rla
+ ld [hMultiplicand + 0], a
+
+ ld a, [hMultiplicand - 1]
+ rla
+ ld [hMultiplicand - 1], a
+
+ jr .loop
+
+
+.done
+ ld a, [hMathBuffer + 4]
+ ld [hProduct + 3], a
+
+ ld a, [hMathBuffer + 3]
+ ld [hProduct + 2], a
+
+ ld a, [hMathBuffer + 2]
+ ld [hProduct + 1], a
+
+ ld a, [hMathBuffer + 1]
+ ld [hProduct + 0], a
+
+ ret
+; 673e
+
+
+_Divide: ; 673e
+ xor a
+ ld [hMathBuffer + 0], a
+ ld [hMathBuffer + 1], a
+ ld [hMathBuffer + 2], a
+ ld [hMathBuffer + 3], a
+ ld [hMathBuffer + 4], a
+
+ ld a, 9
+ ld e, a
+
+.loop
+ ld a, [hMathBuffer + 0]
+ ld c, a
+ ld a, [hDividend + 1]
+ sub c
+ ld d, a
+
+ ld a, [hDivisor]
+ ld c, a
+ ld a, [hDividend + 0]
+ sbc c
+ jr c, .asm_6767
+
+ ld [hDividend + 0], a
+
+ ld a, d
+ ld [hDividend + 1], a
+
+ ld a, [hMathBuffer + 4]
+ inc a
+ ld [hMathBuffer + 4], a
+
+ jr .loop
+
+.asm_6767
+ ld a, b
+ cp 1
+ jr z, .done
+
+ ld a, [hMathBuffer + 4]
+ add a
+ ld [hMathBuffer + 4], a
+
+ ld a, [hMathBuffer + 3]
+ rla
+ ld [hMathBuffer + 3], a
+
+ ld a, [hMathBuffer + 2]
+ rla
+ ld [hMathBuffer + 2], a
+
+ ld a, [hMathBuffer + 1]
+ rla
+ ld [hMathBuffer + 1], a
+
+ dec e
+ jr nz, .asm_6798
+
+ ld e, 8
+ ld a, [hMathBuffer + 0]
+ ld [hDivisor], a
+ xor a
+ ld [hMathBuffer + 0], a
+
+ ld a, [hDividend + 1]
+ ld [hDividend + 0], a
+
+ ld a, [hDividend + 2]
+ ld [hDividend + 1], a
+
+ ld a, [hDividend + 3]
+ ld [hDividend + 2], a
+
+.asm_6798
+ ld a, e
+ cp 1
+ jr nz, .asm_679e
+ dec b
+
+.asm_679e
+ ld a, [hDivisor]
+ srl a
+ ld [hDivisor], a
+
+ ld a, [hMathBuffer + 0]
+ rr a
+ ld [hMathBuffer + 0], a
+
+ jr .loop
+
+.done
+ ld a, [hDividend + 1]
+ ld [hDivisor], a
+
+ ld a, [hMathBuffer + 4]
+ ld [hDividend + 3], a
+
+ ld a, [hMathBuffer + 3]
+ ld [hDividend + 2], a
+
+ ld a, [hMathBuffer + 2]
+ ld [hDividend + 1], a
+
+ ld a, [hMathBuffer + 1]
+ ld [hDividend + 0], a
+
+ ret
+; 67c1
+
+
+ItemAttributes: ; 67c1
+INCLUDE "items/item_attributes.asm"
+; 6ec1
+
+
+INCBIN "baserom.gbc", $6ec1, $6eef - $6ec1
+
DrawGraphic: ; 6eef
; input:
@@ -3842,12 +4898,93 @@ DrawGraphic: ; 6eef
ret
; 6f07
-INCBIN "baserom.gbc",$6f07,$747b - $6f07
+
+INCBIN "baserom.gbc", $6f07, $7305 - $6f07
+
+
+SpecialGiveShuckle: ; 7305
+
+; Adding to the party.
+ xor a
+ ld [MonType], a
+
+; Level 15 Shuckle.
+ ld a, SHUCKLE
+ ld [CurPartySpecies], a
+ ld a, 15
+ ld [CurPartyLevel], a
+
+ ld a, PREDEF_ADDPARTYMON
+ call Predef
+ jr nc, .NotGiven
+
+; Caught data.
+ ld b, 0
+ ld a, $13
+ ld hl, $5ba3
+ rst FarCall
+
+; Holding a Berry.
+ ld bc, PartyMon2 - PartyMon1
+ ld a, [PartyCount]
+ dec a
+ push af
+ push bc
+ ld hl, PartyMon1Item
+ call AddNTimes
+ ld [hl], BERRY
+ pop bc
+ pop af
+
+; OT ID.
+ ld hl, PartyMon1ID
+ call AddNTimes
+ ld a, $2
+ ld [hli], a
+ ld [hl], $6
+
+; Nickname.
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMon1Nickname
+ call SkipNames
+ ld de, .Shuckie
+ call CopyName2
+
+; OT.
+ ld a, [PartyCount]
+ dec a
+ ld hl, PartyMon1OT
+ call SkipNames
+ ld de, .Mania
+ call CopyName2
+
+; Bittable2 flag for this event.
+ ld hl, $dc1e
+ set 5, [hl]
+
+ ld a, 1
+ ld [ScriptVar], a
+ ret
+
+.NotGiven
+ xor a
+ ld [ScriptVar], a
+ ret
+
+.Mania
+ db "MANIA@"
+.Shuckie
+ db "SHUCKIE@"
+; 737e
+
+
+INCBIN "baserom.gbc", $737e, $747b - $737e
SECTION "bank2",DATA,BANK[$2]
-INCBIN "baserom.gbc",$8000,$854b - $8000
+INCBIN "baserom.gbc", $8000, $854b - $8000
GetPredefFn: ; 854b
; input:
@@ -3907,7 +5044,7 @@ PredefPointers: ; 856b
dwb $4eef, $0a
dwb $4b3e, $0b
dwb $5f48, $0f
- dwb $6f6e, $0b
+ dwb FillBox, BANK(FillBox)
dwb $5873, $0f
dwb $6036, $0f
dwb $74c1, $0f
@@ -3965,7 +5102,7 @@ PredefPointers: ; 856b
dwb $43ff, $2d
; 864c
-INCBIN "baserom.gbc",$864c,$8a68 - $864c
+INCBIN "baserom.gbc", $864c, $8a68 - $864c
CheckShininess: ; 0x8a68
; given a pointer to Attack/Defense DV in bc, determine if monster is shiny.
@@ -3993,7 +5130,7 @@ CheckShininess: ; 0x8a68
and a ; clear carry flag
ret
-INCBIN "baserom.gbc",$8a88,$9a52-$8a88
+INCBIN "baserom.gbc", $8a88, $9a52-$8a88
CopyData: ; 0x9a52
; copy bc bytes of data from hl to de
@@ -4039,200 +5176,218 @@ DrawDefaultTiles: ; 0x9a64
ret
; 0x9a7a
-INCBIN "baserom.gbc",$9a7a,$a51e - $9a7a
+INCBIN "baserom.gbc", $9a7a, $a51e - $9a7a
SGBBorder:
INCBIN "gfx/misc/sgb_border.2bpp"
-INCBIN "baserom.gbc",$a8be,$a8d6 - $a8be
+INCBIN "baserom.gbc", $a8be, $a8d6 - $a8be
PokemonPalettes:
INCLUDE "gfx/pics/palette_pointers.asm"
-INCBIN "baserom.gbc",$b0ae,$b0d2 - $b0ae
+INCBIN "baserom.gbc", $b0ae, $b0d2 - $b0ae
TrainerPalettes:
INCLUDE "gfx/trainers/palette_pointers.asm"
-INCBIN "baserom.gbc",$b1de,$b825 - $b1de
+INCBIN "baserom.gbc", $b1de, $b319 - $b1de
+
+MornPal: ; 0xb319
+INCBIN "tilesets/morn.pal"
+; 0xb359
+
+DayPal: ; 0xb359
+INCBIN "tilesets/day.pal"
+; 0xb399
+
+NitePal: ; 0xb399
+INCBIN "tilesets/nite.pal"
+; 0xb3d9
+
+DarkPal: ; 0xb3d9
+INCBIN "tilesets/dark.pal"
+; 0xb419
+
+INCBIN "baserom.gbc", $b419, $b825 - $b419
SECTION "bank3",DATA,BANK[$3]
-INCBIN "baserom.gbc",$c000,$29
+INCBIN "baserom.gbc", $c000, $29
SpecialsPointers: ; 0xc029
- dbw $25,$7c28
- dbw $0a,$5ce8
- dbw $0a,$5d11
- dbw $0a,$5d92
- dbw $0a,$5e66
- dbw $0a,$5e82
- dbw $0a,$5efa
- dbw $0a,$5eee
- dbw $0a,$5c92
- dbw $0a,$5cf1
- dbw $0a,$5cfa
- dbw $0a,$5bfb
- dbw $0a,$5c7b
- dbw $0a,$5ec4
- dbw $0a,$5ed9
- dbw $0a,$5eaf
- dbw $0a,$5f47
- dbw $03,$42f6
- dbw $03,$4309
- dbw $41,$50b9
- dbw $03,$434a
- dbw $13,$59e5
- dbw $04,$7a12
- dbw $04,$7a31
- dbw $04,$75db
- dbw $3e,$7b32
- dbw $3e,$7cd2
- dbw $03,$4658
- dbw $05,$559a
- dbw $03,$42e7
- dbw $05,$66d6
- dbw $05,$672a
- dbw $05,$6936
- dbw $0b,$4547
- dbw $05,$6218
- dbw $23,$4c04
- dbw $03,$429d
- dbw $24,$4913
- dbw $03,$42c0
- dbw $03,$42cd
- dbw $03,$4355
- dbw $03,$4360
- dbw $03,$4373
- dbw $03,$4380
- dbw $03,$438d
- dbw $03,$43db
- dbw $23,$4084
- dbw $23,$4092
- dbw $23,$40b6
- dbw $23,$4079
- dbw $23,$40ab
- dbw $00,$0d91
- dbw $00,$31f3
- dbw $00,$0485
- dbw $00,$0fc8
- dbw $00,$1ad2
- dbw $00,$0e4a
- dbw $03,$4230
- dbw $03,$4252
+ dbw $25, $7c28
+ dbw $0a, $5ce8
+ dbw $0a, $5d11
+ dbw $0a, $5d92
+ dbw $0a, $5e66
+ dbw $0a, $5e82
+ dbw $0a, $5efa
+ dbw $0a, $5eee
+ dbw $0a, $5c92
+ dbw $0a, $5cf1
+ dbw $0a, $5cfa
+ dbw $0a, $5bfb
+ dbw $0a, $5c7b
+ dbw $0a, $5ec4
+ dbw $0a, $5ed9
+ dbw $0a, $5eaf
+ dbw $0a, $5f47
+ dbw $03, $42f6
+ dbw $03, $4309
+ dbw $41, $50b9
+ dbw $03, $434a
+ dbw $13, $59e5
+ dbw $04, $7a12
+ dbw $04, $7a31
+ dbw $04, $75db
+ dbw $3e, $7b32
+ dbw $3e, $7cd2
+ dbw $03, $4658
+ dbw $05, $559a
+ dbw $03, $42e7
+ dbw $05, $66d6
+ dbw $05, $672a
+ dbw $05, $6936
+ dbw $0b, $4547
+ dbw $05, $6218
+ dbw $23, $4c04
+ dbw $03, $429d
+ dbw $24, $4913
+ dbw $03, $42c0
+ dbw $03, $42cd
+ dbw $03, $4355
+ dbw $03, $4360
+ dbw $03, $4373
+ dbw $03, $4380
+ dbw $03, $438d
+ dbw $03, $43db
+ dbw $23, $4084
+ dbw $23, $4092
+ dbw $23, $40b6
+ dbw $23, $4079
+ dbw $23, $40ab
+ dbw $00, $0d91
+ dbw $00, $31f3
+ dbw $00, $0485
+ dbw $00, $0fc8
+ dbw $00, $1ad2
+ dbw $00, $0e4a
+ dbw $03, $4230
+ dbw $03, $4252
dbw BANK(WaitSFX),WaitSFX
- dbw $00,$3cdf
- dbw $00,$3d47
- dbw $04,$6324
- dbw $02,$4379
- dbw $03,$425a
- dbw $03,$4268
- dbw $03,$4276
- dbw $03,$4284
- dbw $03,$43ef
- dbw $05,$7421
- dbw $05,$7440
- dbw $04,$79a8
- dbw $03,$43fc
- dbw $09,$6feb
- dbw $09,$7043
- dbw $01,$7305
- dbw $01,$737e
- dbw $01,$73f7
+ dbw $00, $3cdf
+ dbw $00, $3d47
+ dbw $04, $6324
+ dbw $02, $4379
+ dbw $03, $425a
+ dbw $03, $4268
+ dbw $03, $4276
+ dbw $03, $4284
+ dbw $03, $43ef
+ dbw $05, $7421
+ dbw $05, $7440
+ dbw $04, $79a8
+ dbw $03, $43fc
+ dbw $09, $6feb
+ dbw $09, $7043
+ dbw BANK(SpecialGiveShuckle), SpecialGiveShuckle
+ dbw $01, $737e
+ dbw $01, $73f7
dbw BANK(SpecialCheckPokerus),SpecialCheckPokerus
- dbw $09,$4b25
- dbw $09,$4b4e
- dbw $09,$4ae8
- dbw $13,$587a
- dbw $03,$4434
- dbw $03,$4422
- dbw $13,$59d3
- dbw $22,$4018
- dbw $03,$42b9
- dbw $03,$42da
- dbw $01,$718d
- dbw $01,$71ac
- dbw $0a,$64ab
- dbw $0a,$651f
- dbw $0a,$6567
- dbw $05,$4209
- dbw $3e,$7841
+ dbw $09, $4b25
+ dbw $09, $4b4e
+ dbw $09, $4ae8
+ dbw $13, $587a
+ dbw $03, $4434
+ dbw $03, $4422
+ dbw $13, $59d3
+ dbw $22, $4018
+ dbw $03, $42b9
+ dbw $03, $42da
+ dbw $01, $718d
+ dbw $01, $71ac
+ dbw $0a, $64ab
+ dbw $0a, $651f
+ dbw $0a, $6567
+ dbw $05, $4209
+ dbw $3e, $7841
dbw BANK(SpecialSnorlaxAwake),SpecialSnorlaxAwake
- dbw $01,$7413
- dbw $01,$7418
- dbw $01,$741d
- dbw $03,$4472
- dbw $09,$65ee
+ dbw $01, $7413
+ dbw $01, $7418
+ dbw $01, $741d
+ dbw $03, $4472
+ dbw $09, $65ee
dbw BANK(SpecialGameboyCheck),SpecialGameboyCheck
dbw BANK(SpecialTrainerHouse),SpecialTrainerHouse
- dbw $05,$6dc7
+ dbw $05, $6dc7
dbw BANK(SpecialRoamMons), SpecialRoamMons
- dbw $03,$448f
- dbw $03,$449f
- dbw $03,$44ac
- dbw $46,$6c3e
- dbw $46,$7444
- dbw $46,$75e8
- dbw $46,$77e5
- dbw $46,$7879
- dbw $46,$7920
- dbw $46,$793b
- dbw $5c,$40b0
- dbw $5c,$40ba
- dbw $5c,$4114
- dbw $5c,$4215
- dbw $5c,$44e1
- dbw $5c,$421d
- dbw $5c,$4b44
- dbw $46,$7a38
- dbw $5c,$4bd3
- dbw $45,$7656
- dbw $00,$0150
- dbw $40,$51f1
- dbw $40,$5220
- dbw $40,$5225
- dbw $40,$5231
- dbw $12,$525b
- dbw $22,$6def
- dbw $47,$41ab
- dbw $5c,$4687
- dbw $22,$6e68
- dbw $5f,$5224
- dbw $5f,$52b6
- dbw $5f,$52ce
- dbw $5f,$753d
- dbw $40,$7612
+ dbw $03, $448f
+ dbw $03, $449f
+ dbw $03, $44ac
+ dbw $46, $6c3e
+ dbw $46, $7444
+ dbw $46, $75e8
+ dbw $46, $77e5
+ dbw $46, $7879
+ dbw $46, $7920
+ dbw $46, $793b
+ dbw $5c, $40b0
+ dbw $5c, $40ba
+ dbw $5c, $4114
+ dbw $5c, $4215
+ dbw $5c, $44e1
+ dbw $5c, $421d
+ dbw $5c, $4b44
+ dbw $46, $7a38
+ dbw $5c, $4bd3
+ dbw $45, $7656
+ dbw $00, $0150
+ dbw $40, $51f1
+ dbw $40, $5220
+ dbw $40, $5225
+ dbw $40, $5231
+ dbw $12, $525b
+ dbw $22, $6def
+ dbw $47, $41ab
+ dbw $5c, $4687
+ dbw $22, $6e68
+ dbw $5f, $5224
+ dbw $5f, $52b6
+ dbw $5f, $52ce
+ dbw $5f, $753d
+ dbw $40, $7612
dbw BANK(SpecialHoOhChamber),SpecialHoOhChamber
- dbw $40,$6142
- dbw $12,$589a
- dbw $12,$5bf9
- dbw $13,$70bc
- dbw $22,$6f6b
- dbw $22,$6fd4
+ dbw $40, $6142
+ dbw $12, $589a
+ dbw $12, $5bf9
+ dbw $13, $70bc
+ dbw $22, $6f6b
+ dbw $22, $6fd4
dbw BANK(SpecialDratini),SpecialDratini
- dbw $04,$5485
+ dbw $04, $5485
dbw BANK(SpecialBeastsCheck),SpecialBeastsCheck
dbw BANK(SpecialMonCheck),SpecialMonCheck
- dbw $03,$4225
- dbw $5c,$4bd2
- dbw $40,$766e
- dbw $40,$77eb
- dbw $40,$783c
- dbw $41,$60a2
- dbw $05,$4168
- dbw $40,$77c2
- dbw $41,$630f
- dbw $40,$7780
- dbw $40,$787b
- dbw $12,$6e12
- dbw $41,$47eb
- dbw $12,$6927
- dbw $24,$4a54
- dbw $24,$4a88
- dbw $03,$4224
-
-INCBIN "baserom.gbc",$c224,$c3e2 - $c224
+ dbw $03, $4225
+ dbw $5c, $4bd2
+ dbw $40, $766e
+ dbw $40, $77eb
+ dbw $40, $783c
+ dbw $41, $60a2
+ dbw $05, $4168
+ dbw $40, $77c2
+ dbw $41, $630f
+ dbw $40, $7780
+ dbw $40, $787b
+ dbw $12, $6e12
+ dbw $41, $47eb
+ dbw $12, $6927
+ dbw $24, $4a54
+ dbw $24, $4a88
+ dbw $03, $4224
+
+INCBIN "baserom.gbc", $c224, $c3e2 - $c224
ScriptReturnCarry: ; c3e2
jr c, .carry
@@ -4245,7 +5400,7 @@ ScriptReturnCarry: ; c3e2
ret
; c3ef
-INCBIN "baserom.gbc",$c3ef,$c419 - $c3ef
+INCBIN "baserom.gbc", $c3ef, $c419 - $c3ef
SpecialCheckPokerus: ; c419
; Check if a monster in your party has Pokerus
@@ -4253,7 +5408,7 @@ SpecialCheckPokerus: ; c419
jp ScriptReturnCarry
; c422
-INCBIN "baserom.gbc",$c422,$c43d - $c422
+INCBIN "baserom.gbc", $c422, $c43d - $c422
SpecialSnorlaxAwake: ; 0xc43d
; Check if the Poké Flute channel is playing, and if the player is standing
@@ -4297,22 +5452,22 @@ SpecialSnorlaxAwake: ; 0xc43d
ret
.ProximityCoords
- db $21,$08
- db $22,$0a
- db $23,$0a
- db $24,$08
- db $24,$09
+ db $21, $08
+ db $22, $0a
+ db $23, $0a
+ db $24, $08
+ db $24, $09
db $ff
-INCBIN "baserom.gbc",$c472,$c478 - $c472
+INCBIN "baserom.gbc", $c472, $c478 - $c472
SpecialGameboyCheck: ; c478
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
; check sgb
- ld a, [$ffe7]
+ ld a, [hSGB]
and a
jr nz, .sgb
; gb
@@ -4330,7 +5485,7 @@ SpecialGameboyCheck: ; c478
ld [ScriptVar], a
ret
-INCBIN "baserom.gbc",$c48f,$c4b9 - $c48f
+INCBIN "baserom.gbc", $c48f, $c4b9 - $c48f
SpecialTrainerHouse: ; 0xc4b9
ld a, 0
@@ -4339,10 +5494,10 @@ SpecialTrainerHouse: ; 0xc4b9
ld [ScriptVar], a
jp CloseSRAM
-INCBIN "baserom.gbc",$c4c7,$c5d2 - $c4c7
+INCBIN "baserom.gbc", $c4c7, $c5d2 - $c4c7
PrintNumber_PrintDigit: ; c5d2
-INCBIN "baserom.gbc",$c5d2,$c644 - $c5d2
+INCBIN "baserom.gbc", $c5d2, $c644 - $c5d2
PrintNumber_PrintLeadingZero: ; c644
; prints a leading zero unless they are turned off in the flags
@@ -4358,7 +5513,7 @@ PrintNumber_AdvancePointer: ; c64a
jr nz, .incrementPointer\@
bit 6, d ; left alignment or right alignment?
jr z, .incrementPointer\@
- ld a, [$ffb3] ; was H_PASTLEADINGZEROES
+ ld a, [hPastLeadingZeroes]
and a
ret z
.incrementPointer\@
@@ -4366,7 +5521,7 @@ PrintNumber_AdvancePointer: ; c64a
ret
; 0xc658
-INCBIN "baserom.gbc",$c658,$c706 - $c658
+INCBIN "baserom.gbc", $c658, $c706 - $c658
GetPartyNick: ; c706
; write CurPartyMon nickname to StringBuffer1-3
@@ -4460,7 +5615,7 @@ CheckPartyMove: ; c742
ret
; c779
-INCBIN "baserom.gbc",$c779,$c986 - $c779
+INCBIN "baserom.gbc", $c779, $c986 - $c779
UsedSurfScript: ; c986
; print "[MON] used SURF!"
@@ -4618,17 +5773,148 @@ AskSurfText: ; ca36
db "@" ; Want to SURF?
; ca3b
-INCBIN "baserom.gbc",$ca3b,$fa0b - $ca3b
+
+INCBIN "baserom.gbc", $ca3b, $d407 - $ca3b
+
+
+GetTMHMNumber: ; d407
+; Return the number of a TM/HM by item id c.
+
+ ld a, c
+
+; Skip any dummy items.
+ cp $c3 ; TM04-05
+ jr c, .done
+ cp $dc ; TM28-29
+ jr c, .skip
+
+ dec a
+.skip
+ dec a
+.done
+ sub TM_01
+ inc a
+ ld c, a
+ ret
+; d417
+
+
+GetNumberedTMHM: ; d417
+; Return the item id of a TM/HM by number c.
+
+ ld a, c
+
+; Skip any gaps.
+ cp 5
+ jr c, .done
+ cp 29
+ jr c, .skip
+
+ inc a
+.skip
+ inc a
+.done
+ add TM_01
+ dec a
+ ld c, a
+ ret
+; d427
+
+
+CheckTossableItem: ; d427
+; Return 1 in $d142 and carry if CurItem can't be removed from the bag.
+ ld a, 4
+ call GetItemAttr
+ bit 7, a
+ jr nz, Function0xd47f
+ and a
+ ret
+; d432
+
+CheckSelectableItem: ; d432
+; Return 1 in $d142 and carry if CurItem can't be selected.
+ ld a, 4
+ call GetItemAttr
+ bit 6, a
+ jr nz, Function0xd47f
+ and a
+ ret
+; d43d
+
+CheckItemPocket: ; d43d
+; Return the pocket for CurItem in $d142.
+ ld a, 5
+ call GetItemAttr
+ and $f
+ ld [$d142], a
+ ret
+; d448
+
+CheckItemContext: ; d448
+; Return the context for CurItem in $d142.
+ ld a, 6
+ call GetItemAttr
+ and $f
+ ld [$d142], a
+ ret
+; d453
+
+CheckItemMenu: ; d453
+; Return the menu for CurItem in $d142.
+ ld a, 6
+ call GetItemAttr
+ swap a
+ and $f
+ ld [$d142], a
+ ret
+; d460
+
+GetItemAttr: ; d460
+; Get attribute a of CurItem.
+
+ push hl
+ push bc
+
+ ld hl, ItemAttributes
+ ld c, a
+ ld b, 0
+ add hl, bc
+
+ xor a
+ ld [$d142], a
+
+ ld a, [CurItem]
+ dec a
+ ld c, a
+ ld a, 7
+ call AddNTimes
+ ld a, BANK(ItemAttributes)
+ call GetFarByte
+
+ pop bc
+ pop hl
+ ret
+; d47f
+
+Function0xd47f: ; d47f
+ ld a, 1
+ ld [$d142], a
+ scf
+ ret
+; d486
+
+
+INCBIN "baserom.gbc", $d486, $fa0b - $d486
SECTION "bank4",DATA,BANK[$4]
-INCBIN "baserom.gbc",$10000,$10b16 - $10000
+INCBIN "baserom.gbc", $10000, $10b16 - $10000
PackGFX:
INCBIN "gfx/misc/pack.2bpp"
-INCBIN "baserom.gbc",$113d6,$1167a - $113d6
+INCBIN "baserom.gbc", $113d6, $1167a - $113d6
TechnicalMachines: ; 0x1167a
db DYNAMICPUNCH
@@ -4689,7 +5975,7 @@ TechnicalMachines: ; 0x1167a
db WHIRLPOOL
db WATERFALL
-INCBIN "baserom.gbc",$116b3,$11ce7 - $116b3
+INCBIN "baserom.gbc", $116b3, $11ce7 - $116b3
NameInputLower:
db "a b c d e f g h i"
@@ -4718,7 +6004,7 @@ BoxNameInputUpper:
db "- ? ! ♂ ♀ / . , &"
db "lower DEL END "
-INCBIN "baserom.gbc",$11e5d,$12976 - $11e5d
+INCBIN "baserom.gbc", $11e5d, $12976 - $11e5d
OpenPartyMenu: ; $12976
ld a, [PartyCount]
@@ -4732,26 +6018,26 @@ OpenPartyMenu: ; $12976
.menu ; 12986
ld a, $14
ld hl, $404f
- rst $8 ; load gfx
+ rst FarCall ; load gfx
ld a, $14
ld hl, $4405
- rst $8 ; setup menu?
+ rst FarCall ; setup menu?
ld a, $14
ld hl, $43e0
- rst $8 ; load menu pokémon sprites
+ rst FarCall ; load menu pokémon sprites
.menunoreload ; 12998
ld a, BANK(WritePartyMenuTilemap)
ld hl, WritePartyMenuTilemap
- rst $8
+ rst FarCall
ld a, BANK(PrintPartyMenuText)
ld hl, PrintPartyMenuText
- rst $8
+ rst FarCall
call $31f6
call $32f9 ; load regular palettes?
call DelayFrame
ld a, BANK(PartyMenuSelect)
ld hl, PartyMenuSelect
- rst $8
+ rst FarCall
jr c, .return ; if cancelled or pressed B
call PokemonActionSubmenu
cp $3
@@ -4774,7 +6060,7 @@ OpenPartyMenu: ; $12976
ret
; 0x129d5
-INCBIN "baserom.gbc",$129d5,$12a88 - $129d5
+INCBIN "baserom.gbc", $129d5, $12a88 - $129d5
PokemonActionSubmenu ; 0x12a88
ld hl, $c5cd ; coord
@@ -4782,7 +6068,7 @@ PokemonActionSubmenu ; 0x12a88
call $0fb6 ; draw box
ld a, $9
ld hl, $4d19
- rst $8
+ rst FarCall
call $389c
ld a, [$cf74] ; menu selection?
ld hl, PokemonSubmenuActionPointerTable
@@ -4823,7 +6109,7 @@ PokemonSubmenuActionPointerTable: ; 0x12ab0
; no terminator?
; 0x12aec
-INCBIN "baserom.gbc",$12aec,$12e00 - $12aec
+INCBIN "baserom.gbc", $12aec, $12e00 - $12aec
OpenPartyStats: ; 12e00
call $1d6e
@@ -4839,7 +6125,7 @@ OpenPartyStats: ; 12e00
ret
; 0x12e1b
-INCBIN "baserom.gbc",$12e1b,$13b87 - $12e1b
+INCBIN "baserom.gbc", $12e1b, $13b87 - $12e1b
GetSquareRoot: ; 13b87
; Return the square root of de in b.
@@ -4876,11 +6162,11 @@ root set root+1
SECTION "bank5",DATA,BANK[$5]
-INCBIN "baserom.gbc",$14000,$14032 - $14000
+INCBIN "baserom.gbc", $14000, $14032 - $14000
GetTimeOfDay: ; 14032
; get time of day based on the current hour
- ld a, [$ff94] ; hour
+ ld a, [hHours] ; hour
ld hl, TimeOfDayTable
.check
@@ -4912,7 +6198,7 @@ TimeOfDayTable: ; 14044
db 24, $02 ; NITE
; 1404c
-INCBIN "baserom.gbc",$1404c,$152ab - $1404c
+INCBIN "baserom.gbc", $1404c, $152ab - $1404c
BlackoutPoints: ; 0x152ab
db GROUP_KRISS_HOUSE_2F, MAP_KRISS_HOUSE_2F, 3, 3
@@ -4945,70 +6231,185 @@ BlackoutPoints: ; 0x152ab
db GROUP_FAST_SHIP_CABINS_SW_SSW_NW, MAP_FAST_SHIP_CABINS_SW_SSW_NW, 6, 2
db $ff, $ff, $ff, $ff
-INCBIN "baserom.gbc",$1531f,$174ba - $1531f
+INCBIN "baserom.gbc", $1531f, $174ba - $1531f
SECTION "bank6",DATA,BANK[$6]
-Tileset03GFX: ; 18000
+Tileset03GFX: ; 0x18000
INCBIN "gfx/tilesets/03.lz"
-; 18605
+; 0x18605
+
+ db $00
-INCBIN "baserom.gbc", $18605, $19006 - $18605
+Tileset03Meta: ; 0x18606
+INCBIN "tilesets/03_metatiles.bin"
+; 0x18e06
-Tileset00GFX:
-Tileset01GFX: ; 19006
+Tileset03Coll: ; 0x18e06
+INCBIN "tilesets/03_collision.bin"
+; 0x19006
+
+Tileset00GFX: ; 0x19006
+Tileset01GFX: ; 0x19006
INCBIN "gfx/tilesets/01.lz"
-; 19c0d
+; 0x19c0d
+
+ db $00
-INCBIN "baserom.gbc", $19c0d, $1a60e - $19c0d
+Tileset00Meta: ; 0x19c0e
+Tileset01Meta: ; 0x19c0e
+INCBIN "tilesets/01_metatiles.bin"
+; 0x1a40e
-Tileset29GFX: ; 1a60e
+Tileset00Coll: ; 0x1a40e
+Tileset01Coll: ; 0x1a40e
+INCBIN "tilesets/01_collision.bin"
+; 0x1a60e
+
+Tileset29GFX: ; 0x1a60e
INCBIN "gfx/tilesets/29.lz"
-; 1af38
+; 0x1af38
-INCBIN "baserom.gbc", $1af38, $1b43e - $1af38
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
-Tileset20GFX: ; 1b43e
-INCBIN "gfx/tilesets/20.lz"
-; 1b8f1
+Tileset29Meta: ; 0x1af3e
+INCBIN "tilesets/29_metatiles.bin"
+; 0x1b33e
+
+Tileset29Coll: ; 0x1b33e
+INCBIN "tilesets/29_collision.bin"
+; 0x1b43e
-INCBIN "baserom.gbc", $1b8f1, $1bdfe - $1b8f1
+Tileset20GFX: ; 0x1b43e
+INCBIN "gfx/tilesets/20.lz"
+; 0x1b8f1
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset20Meta: ; 0x1b8fe
+INCBIN "tilesets/20_metatiles.bin"
+; 0x1bcfe
+
+Tileset20Coll: ; 0x1bcfe
+INCBIN "tilesets/20_collision.bin"
+; 0x1bdfe
SECTION "bank7",DATA,BANK[$7]
INCBIN "baserom.gbc", $1c000, $1c30c - $1c000
-Tileset07GFX: ; 1c30c
+Tileset07GFX: ; 0x1c30c
INCBIN "gfx/tilesets/07.lz"
-; 1c73b
+; 0x1c73b
+
+ db $00
-INCBIN "baserom.gbc", $1c73b, $1cc3c - $1c73b
+Tileset07Meta: ; 0x1c73c
+INCBIN "tilesets/07_metatiles.bin"
+; 0x1cb3c
-Tileset09GFX: ; 1cc3c
+Tileset07Coll: ; 0x1cb3c
+INCBIN "tilesets/07_collision.bin"
+; 0x1cc3c
+
+Tileset09GFX: ; 0x1cc3c
INCBIN "gfx/tilesets/09.lz"
-; 1d047
+; 0x1d047
-INCBIN "baserom.gbc", $1d047, $1d54c - $1d047
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
-Tileset06GFX: ; 1d54c
-INCBIN "gfx/tilesets/06.lz"
-; 1d924
+Tileset09Meta: ; 0x1d04c
+INCBIN "tilesets/09_metatiles.bin"
+; 0x1d44c
-INCBIN "baserom.gbc", $1d924, $1de2c - $1d924
+Tileset09Coll: ; 0x1d44c
+INCBIN "tilesets/09_collision.bin"
+; 0x1d54c
-Tileset13GFX: ; 1de2c
+Tileset06GFX: ; 0x1d54c
+INCBIN "gfx/tilesets/06.lz"
+; 0x1d924
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset06Meta: ; 0x1d92c
+INCBIN "tilesets/06_metatiles.bin"
+; 0x1dd2c
+
+Tileset06Coll: ; 0x1dd2c
+INCBIN "tilesets/06_collision.bin"
+; 0x1de2c
+
+Tileset13GFX: ; 0x1de2c
INCBIN "gfx/tilesets/13.lz"
-; 1e58c
+; 0x1e58c
-INCBIN "baserom.gbc", $1e58c, $1ea8c - $1e58c
+Tileset13Meta: ; 0x1e58c
+INCBIN "tilesets/13_metatiles.bin"
+; 0x1e98c
-Tileset24GFX: ; 1ea8c
-INCBIN "gfx/tilesets/24.lz"
-; 1ee0e
+Tileset13Coll: ; 0x1e98c
+INCBIN "tilesets/13_collision.bin"
+; 0x1ea8c
-INCBIN "baserom.gbc", $1ee0e, $1f31c - $1ee0e
+Tileset24GFX: ; 0x1ea8c
+INCBIN "gfx/tilesets/24.lz"
+; 0x1ee0e
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset24Meta: ; 0x1ee1c
+Tileset30Meta: ; 0x1ee1c
+INCBIN "tilesets/30_metatiles.bin"
+; 0x1f21c
+
+Tileset24Coll: ; 0x1f21c
+Tileset30Coll: ; 0x1f21c
+INCBIN "tilesets/30_collision.bin"
+; 0x1f31c
; Songs i
@@ -5021,35 +6422,116 @@ SECTION "bank8",DATA,BANK[$8]
INCBIN "baserom.gbc", $20000, $20181 - $20000
-Tileset23GFX: ; 20181
+Tileset23GFX: ; 0x20181
INCBIN "gfx/tilesets/23.lz"
-; 206d2
-
-INCBIN "baserom.gbc", $206d2, $20be1 - $206d2
-
-Tileset10GFX: ; 20be1
+; 0x206d2
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset23Meta: ; 0x206e1
+INCBIN "tilesets/23_metatiles.bin"
+; 0x20ae1
+
+Tileset23Coll: ; 0x20ae1
+INCBIN "tilesets/23_collision.bin"
+; 0x20be1
+
+Tileset10GFX: ; 0x20be1
INCBIN "gfx/tilesets/10.lz"
-; 213e0
+; 0x213e0
-INCBIN "baserom.gbc", $213e0, $218e1 - $213e0
+ db $00
-Tileset12GFX: ; 218e1
-INCBIN "gfx/tilesets/12.lz"
-; 22026
+Tileset10Meta: ; 0x213e1
+INCBIN "tilesets/10_metatiles.bin"
+; 0x217e1
-INCBIN "baserom.gbc", $22026, $22531 - $22026
+Tileset10Coll: ; 0x217e1
+INCBIN "tilesets/10_collision.bin"
+; 0x218e1
-Tileset14GFX: ; 22531
+Tileset12GFX: ; 0x218e1
+INCBIN "gfx/tilesets/12.lz"
+; 0x22026
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset12Meta: ; 0x22031
+INCBIN "tilesets/12_metatiles.bin"
+; 0x22431
+
+Tileset12Coll: ; 0x22431
+INCBIN "tilesets/12_collision.bin"
+; 0x22531
+
+Tileset14GFX: ; 0x22531
INCBIN "gfx/tilesets/14.lz"
-; 22ae2
+; 0x22ae2
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset14Meta: ; 0x22af1
+INCBIN "tilesets/14_metatiles.bin"
+; 0x22ef1
+
+Tileset14Coll: ; 0x22ef1
+INCBIN "tilesets/14_collision.bin"
+; 0x22ff1
+
+Tileset17GFX: ; 0x22ff1
+INCBIN "gfx/tilesets/17.lz"
+; 0x23391
-INCBIN "baserom.gbc", $22ae2, $22ff1 - $22ae2
+Tileset17Meta: ; 0x23391
+INCBIN "tilesets/17_metatiles.bin"
+; 0x23791
-Tileset17GFX: ; 22ff1
-INCBIN "gfx/tilesets/17.lz"
-; 23391
+Tileset17Coll: ; 0x23791
+INCBIN "tilesets/17_collision.bin"
+; 0x23891
-INCBIN "baserom.gbc",$23391,$23b11 - $23391
+; todo
+Tileset31Meta: ; 0x23891
+INCBIN "tilesets/31_metatiles.bin", $0, $280
+; 0x23b11
EggMovePointers: ; 0x23b11
INCLUDE "stats/egg_move_pointers.asm"
@@ -5059,7 +6541,7 @@ INCLUDE "stats/egg_moves.asm"
SECTION "bank9",DATA,BANK[$9]
-INCBIN "baserom.gbc",$24000,$270c4 - $24000
+INCBIN "baserom.gbc", $24000, $270c4 - $24000
GetTrainerDVs: ; 270c4
; get dvs based on trainer class
@@ -5154,12 +6636,20 @@ TrainerClassDVs ; 270d6
db $98, $88 ; mysticalman
; 2715c
-INCBIN "baserom.gbc",$2715c,$27a2d - $2715c
+INCBIN "baserom.gbc", $2715c, $271f4 - $2715c
+
+MoveEffectsPointers: ; 271f4
+INCLUDE "battle/moves/move_effects_pointers.asm"
+
+MoveEffects: ; 2732e
+INCLUDE "battle/moves/move_effects.asm"
+
+INCBIN "baserom.gbc", $27a28, $27a2d - $27a28
SECTION "bankA",DATA,BANK[$A]
-INCBIN "baserom.gbc",$28000,$2a2a0 - $28000
+INCBIN "baserom.gbc", $28000, $2a2a0 - $28000
SpecialRoamMons: ; 2a2a0
; initialize RoamMon structs
@@ -5206,7 +6696,7 @@ SpecialRoamMons: ; 2a2a0
ret
; 2a2ce
-INCBIN "baserom.gbc",$2a2ce,$2a5e9 - $2a2ce
+INCBIN "baserom.gbc", $2a2ce, $2a5e9 - $2a2ce
WildMons1: ; 0x2a5e9
@@ -5243,7 +6733,7 @@ INCBIN "gfx/misc/dude.lz"
SECTION "bankB",DATA,BANK[$B]
-INCBIN "baserom.gbc",$2C000,$2c1ef - $2C000
+INCBIN "baserom.gbc", $2C000, $2c1ef - $2C000
TrainerClassNames: ; 2c1ef
db "LEADER@"
@@ -5314,139 +6804,343 @@ TrainerClassNames: ; 2c1ef
db "ROCKET@"
db "MYSTICALMAN@"
-INCBIN "baserom.gbc",$2C41a,$2ee8f - $2C41a
-; XXX this is not the start of the routine
-; determine what music plays in battle
- ld a, [OtherTrainerClass] ; are we fighting a trainer?
+INCBIN "baserom.gbc", $2c41a, $2ee6c - $2c41a
+
+
+PlayBattleMusic: ; 2ee6c
+
+ push hl
+ push de
+ push bc
+
+ xor a
+ ld [MusicFade], a
+ ld de, MUSIC_NONE
+ call StartMusic
+ call DelayFrame
+ call MaxVolume
+
+ ld a, [BattleType]
+ cp BATTLETYPE_SUICUNE
+ ld de, MUSIC_SUICUNE_BATTLE
+ jp z, .done
+ cp BATTLETYPE_ROAMING
+ jp z, .done
+
+ ; Are we fighting a trainer?
+ ld a, [OtherTrainerClass]
and a
jr nz, .trainermusic
+
ld a, BANK(RegionCheck)
ld hl, RegionCheck
rst FarCall
ld a, e
and a
jr nz, .kantowild
- ld de, $0029 ; johto daytime wild battle music
- ld a, [TimeOfDay] ; check time of day
- cp $2 ; nighttime?
- jr nz, .done ; if no, then done
- ld de, $004a ; johto nighttime wild battle music
+
+ ld de, MUSIC_JOHTO_WILD_BATTLE
+ ld a, [TimeOfDay]
+ cp NITE
+ jr nz, .done
+ ld de, MUSIC_JOHTO_WILD_BATTLE_NIGHT
jr .done
+
.kantowild
- ld de, $0008 ; kanto wild battle music
+ ld de, MUSIC_KANTO_WILD_BATTLE
jr .done
.trainermusic
- ld de, $002f ; lance battle music
+ ld de, MUSIC_CHAMPION_BATTLE
cp CHAMPION
jr z, .done
cp RED
jr z, .done
; really, they should have included admins and scientists here too...
- ld de, $0031 ; rocket battle music
+ ld de, MUSIC_ROCKET_BATTLE
cp GRUNTM
jr z, .done
cp GRUNTF
jr z, .done
- ld de, $0006 ; kanto gym leader battle music
+ ld de, MUSIC_KANTO_GYM_LEADER_BATTLE
ld a, BANK(IsKantoGymLeader)
ld hl, IsKantoGymLeader
rst FarCall
jr c, .done
- ld de, $002e ; johto gym leader battle music
+ ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE
ld a, BANK(IsJohtoGymLeader)
ld hl, IsJohtoGymLeader
rst FarCall
jr c, .done
- ld de, $0030 ; rival battle music
+ ld de, MUSIC_RIVAL_BATTLE
ld a, [OtherTrainerClass]
cp RIVAL1
jr z, .done
cp RIVAL2
jr nz, .othertrainer
- ld a, [OtherTrainerID] ; which rival are we fighting?
- cp $4
- jr c, .done ; if it's not the fight inside Indigo Plateau, we're done
- ld de, $002f ; rival indigo plateau battle music
+
+ ld a, [OtherTrainerID]
+ cp 4 ; Rival in Indigo Plateau
+ jr c, .done
+ ld de, MUSIC_CHAMPION_BATTLE
jr .done
.othertrainer
ld a, [InLinkBattle]
and a
- jr nz, .linkbattle
+ jr nz, .johtotrainer
+
ld a, BANK(RegionCheck)
ld hl, RegionCheck
rst FarCall
ld a, e
and a
jr nz, .kantotrainer
-.linkbattle
- ld de, $002a ; johto trainer battle music
+
+.johtotrainer
+ ld de, MUSIC_JOHTO_TRAINER_BATTLE
jr .done
+
.kantotrainer
- ld de, $0007 ; kanto trainer battle music
+ ld de, MUSIC_KANTO_TRAINER_BATTLE
+
.done
- call $3b97
+ call StartMusic
+
pop bc
pop de
pop hl
ret
+; 2ef18
+
-INCBIN "baserom.gbc",$2ef18,$2ef9f - $2ef18
+ClearBattleRAM: ; 2ef18
+ xor a
+ ld [$d0ec], a
+ ld [$d0ee], a
+ ld hl, $d0d8
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
-SECTION "bankC",DATA,BANK[$C]
+ ld [$d0e4], a
+ ld [CriticalHit], a
+ ld [BattleMonSpecies], a
+ ld [$c664], a
+ ld [CurBattleMon], a
+ ld [$d232], a
+ ld [TimeOfDayPal], a
+ ld [PlayerTurnsTaken], a
+ ld [EnemyTurnsTaken], a
+ ld [EvolvableFlags], a
-Tileset15GFX: ; 30000
-INCBIN "gfx/tilesets/15.lz"
-; 304d7
+ ld hl, PlayerHPPal
+ ld [hli], a
+ ld [hl], a
-INCBIN "baserom.gbc", $304d7, $309e0 - $304d7
+ ld hl, BattleMonDVs
+ ld [hli], a
+ ld [hl], a
-Tileset25GFX: ; 309e0
-INCBIN "gfx/tilesets/25.lz"
-; 30e78
+ ld hl, EnemyMonDVs
+ ld [hli], a
+ ld [hl], a
-INCBIN "baserom.gbc", $30e78, $31380 - $30e78
+; Clear the entire BattleMons area
+ ld hl, EnemyMoveStruct
+ ld bc, $0139
+ xor a
+ call ByteFill
+
+ ld hl, $5867
+ ld a, $f
+ rst FarCall
+
+ call $1fbf
-Tileset27GFX: ; 31380
+ ld hl, $ffd6
+ xor a
+ ld [hli], a
+ ld [hl], $98
+ ret
+; 2ef6e
+
+
+FillBox: ; 2ef6e
+; Fill $c2c6-aligned box width b height c
+; with iterating tile starting from $ffad at hl.
+; Predef $13
+
+ ld de, 20
+
+ ld a, [$c2c6]
+ and a
+ jr nz, .left
+
+ ld a, [$ffad]
+.x1
+ push bc
+ push hl
+
+.y1
+ ld [hl], a
+ add hl, de
+ inc a
+ dec c
+ jr nz, .y1
+
+ pop hl
+ inc hl
+ pop bc
+ dec b
+ jr nz, .x1
+ ret
+
+.left
+; Right-aligned.
+ push bc
+ ld b, 0
+ dec c
+ add hl, bc
+ pop bc
+
+ ld a, [$ffad]
+.x2
+ push bc
+ push hl
+
+.y2
+ ld [hl], a
+ add hl, de
+ inc a
+ dec c
+ jr nz, .y2
+
+ pop hl
+ dec hl
+ pop bc
+ dec b
+ jr nz, .x2
+ ret
+; 2ef9f
+
+
+
+SECTION "bankC",DATA,BANK[$C]
+
+Tileset15GFX: ; 0x30000
+INCBIN "gfx/tilesets/15.lz"
+; 0x304d7
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset15Meta: ; 0x304e0
+INCBIN "tilesets/15_metatiles.bin"
+; 0x308e0
+
+Tileset15Coll: ; 0x308e0
+INCBIN "tilesets/15_collision.bin"
+; 0x309e0
+
+Tileset25GFX: ; 0x309e0
+INCBIN "gfx/tilesets/25.lz"
+; 0x30e78
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset25Meta: ; 0x30e80
+INCBIN "tilesets/25_metatiles.bin"
+; 0x31280
+
+Tileset25Coll: ; 0x31280
+INCBIN "tilesets/25_collision.bin"
+; 0x31380
+
+Tileset27GFX: ; 0x31380
INCBIN "gfx/tilesets/27.lz"
-; 318dc
+; 0x318dc
-INCBIN "baserom.gbc", $318dc, $31de0 - $318dc
+ db $00
+ db $00
+ db $00
+ db $00
-Tileset28GFX: ; 31de0
-INCBIN "gfx/tilesets/28.lz"
-; 321a6
+Tileset27Meta: ; 0x318e0
+INCBIN "tilesets/27_metatiles.bin"
+; 0x31ce0
-INCBIN "baserom.gbc", $321a6, $326b0 - $321a6
+Tileset27Coll: ; 0x31ce0
+INCBIN "tilesets/27_collision.bin"
+; 0x31de0
-Tileset30GFX: ; 326b0
+Tileset28GFX: ; 0x31de0
+INCBIN "gfx/tilesets/28.lz"
+; 0x321a6
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset28Meta: ; 0x321b0
+INCBIN "tilesets/28_metatiles.bin"
+; 0x325b0
+
+Tileset28Coll: ; 0x325b0
+INCBIN "tilesets/28_collision.bin"
+; 0x326b0
+
+Tileset30GFX: ; 0x326b0
INCBIN "gfx/tilesets/30.lz"
-; 329ed
+; 0x329ed
-INCBIN "baserom.gbc",$329ed,$333f0 - $329ed
+INCBIN "baserom.gbc", $329ed, $333f0 - $329ed
SECTION "bankD",DATA,BANK[$D]
-INCBIN "baserom.gbc",$34000,$34bb1 - $34000
+INCLUDE "battle/effect_commands.asm"
-TypeMatchup: ; 34bb1
-INCLUDE "battle/type_matchup.asm"
-; 34cfd
-INCBIN "baserom.gbc",$34cfd,$37ee2 - $34cfd
+SECTION "bankE",DATA,BANK[$E]
+INCBIN "baserom.gbc", $38000, $38591 - $38000
-SECTION "bankE",DATA,BANK[$E]
-INCBIN "baserom.gbc",$38000,$39999 - $38000
+AIScoring: ; 38591
+INCLUDE "battle/ai/scoring.asm"
+
+
+INCBIN "baserom.gbc", $3952d, $39999 - $3952d
+
TrainerGroups: ; 0x39999
INCLUDE "trainers/trainer_pointers.asm"
@@ -5456,7 +7150,91 @@ INCLUDE "trainers/trainers.asm"
SECTION "bankF",DATA,BANK[$F]
-INCBIN "baserom.gbc",$3C000,$3d123 - $3C000
+INCBIN "baserom.gbc", $3c000, $3cc83 - $3c000
+
+GetEighthMaxHP: ; 3cc83
+; output: bc
+ call GetQuarterMaxHP
+; assumes nothing can have 1024 or more hp
+; halve result
+ srl c
+; round up
+ ld a, c
+ and a
+ jr nz, .end
+ inc c
+.end
+ ret
+; 3cc8e
+
+
+GetQuarterMaxHP: ; 3cc8e
+; output: bc
+ call GetMaxHP
+
+; quarter result
+ srl b
+ rr c
+ srl b
+ rr c
+
+; assumes nothing can have 1024 or more hp
+; round up
+ ld a, c
+ and a
+ jr nz, .end
+ inc c
+.end
+ ret
+; 3cc9f
+
+
+GetHalfMaxHP: ; 3cc9f
+; output: bc
+ call GetMaxHP
+
+; halve reslut
+ srl b
+ rr c
+
+; floor = 1
+ ld a, c
+ or b
+ jr nz, .end
+ inc c
+.end
+ ret
+; 3ccac
+
+
+GetMaxHP: ; 3ccac
+; output: bc, $d1ea-b
+
+; player
+ ld hl, BattleMonMaxHP
+
+; whose turn?
+ ld a, [hBattleTurn]
+ and a
+ jr z, .gethp
+
+; enemy
+ ld hl, EnemyMonMaxHP
+
+.gethp
+ ld a, [hli]
+ ld [$d1eb], a
+ ld b, a
+
+ ld a, [hl]
+ ld [$d1ea], a
+ ld c, a
+ ret
+; 3ccc2
+
+
+INCBIN "baserom.gbc", $3ccc2, $3d123 - $3ccc2
+
; These functions check if the current opponent is a gym leader or one of a
; few other special trainers.
@@ -5511,13 +7289,13 @@ KantoGymLeaders:
db BLUE
db $ff
-INCBIN "baserom.gbc",$3d14e,$3ddc2 - $3d14e
+INCBIN "baserom.gbc", $3d14e, $3ddc2 - $3d14e
ld hl, RecoveredUsingText
jp $3ad5
; 0x3ddc8
-INCBIN "baserom.gbc",$3ddc8,$3e8eb - $3ddc8
+INCBIN "baserom.gbc", $3ddc8, $3e8eb - $3ddc8
LoadEnemyMon: ; 3e8eb
; Initialize enemy monster parameters
@@ -5529,7 +7307,7 @@ LoadEnemyMon: ; 3e8eb
; Clear the whole EnemyMon struct
xor a
ld hl, EnemyMonSpecies
- ld bc, $0027
+ ld bc, EnemyMonEnd - EnemyMon
call ByteFill
; We don't need to be here if we're in a link battle
@@ -5547,8 +7325,8 @@ LoadEnemyMon: ; 3e8eb
ld [CurSpecies], a
ld [CurPartySpecies], a
-; Grab the base stats for this species
- call GetBaseStats
+; Grab the BaseData for this species
+ call GetBaseData
; Let's get the item:
@@ -5567,13 +7345,13 @@ LoadEnemyMon: ; 3e8eb
.WildItem
-; In a wild battle, we pull from the item slots in base stats
+; In a wild battle, we pull from the item slots in BaseData
; Force Item1
; Used for Ho-Oh, Lugia and Snorlax encounters
ld a, [BattleType]
cp BATTLETYPE_FORCEITEM
- ld a, [$d241] ; BufferMonItem1
+ ld a, [BaseItems]
jr z, .UpdateItem
; Failing that, it's all up to chance
@@ -5584,16 +7362,16 @@ LoadEnemyMon: ; 3e8eb
; 25% chance of getting an item
call FarBattleRNG
- cp a, $c0 ; $c0/$100 = 75%
+ cp a, $c0
ld a, NO_ITEM
jr c, .UpdateItem
; From there, an 8% chance for Item2
call FarBattleRNG
- cp a, $14 ; 8% of 25% = 2% Item2
- ld a, [$d241] ; BaseStatsItem1
+ cp a, $14 ; 8% of 25% = 2% Item2
+ ld a, [BaseItems]
jr nc, .UpdateItem
- ld a, [$d242] ; BaseStatsItem2
+ ld a, [BaseItems+1]
.UpdateItem
@@ -5608,7 +7386,7 @@ LoadEnemyMon: ; 3e8eb
jr z, .InitDVs
; ????
- ld a, [$c671]
+ ld a, [EnemySubStatus5]
bit 3, a
jr z, .InitDVs
@@ -5795,7 +7573,7 @@ LoadEnemyMon: ; 3e8eb
.Happiness
; Set happiness
- ld a, 70 ; BASE_HAPPINESS
+ ld a, BASE_HAPPINESS
ld [EnemyMonHappiness], a
; Set level
ld a, [CurPartyLevel]
@@ -5890,8 +7668,8 @@ LoadEnemyMon: ; 3e8eb
.Moves
; ????
- ld hl, $d23d
- ld de, $d224
+ ld hl, BaseType1
+ ld de, EnemyMonType1
ld a, [hli]
ld [de], a
inc de
@@ -5950,52 +7728,54 @@ LoadEnemyMon: ; 3e8eb
call CopyBytes
.Finish
-; ????
- ld hl, $d237
- ld de, $d226
- ld b, 5 ; # bytes to copy
-; Copy $d237-a to $d226-9
+; Only the first five base stats are copied...
+ ld hl, BaseStats
+ ld de, EnemyMonBaseStats
+ ld b, BaseSpecialDefense - BaseStats
.loop
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .loop
-; Copy $d23f to $d22a
- ld a, [$d23f]
+
+ ld a, [BaseCatchRate]
ld [de], a
inc de
-; Copy $d240 to $d22b
- ld a, [$d240]
+
+ ld a, [BaseExp]
ld [de], a
-; copy TempEnemyMonSpecies to $d265
+
ld a, [TempEnemyMonSpecies]
ld [$d265], a
-; ????
- call $343b
-; If wild, we're done
+
+ call GetPokemonName
+
+; Did we catch it?
ld a, [IsInBattle]
and a
ret z
+
; Update enemy nick
ld hl, StringBuffer1
ld de, EnemyMonNick
ld bc, PKMN_NAME_LENGTH
call CopyBytes
-; ????
+
+; Caught this mon
ld a, [TempEnemyMonSpecies]
dec a
ld c, a
- ld b, $01
- ld hl, $deb9
- ld a, $03 ; PREDEF_
+ ld b, 1 ; set
+ ld hl, PokedexCaught
+ ld a, PREDEF_FLAG
call Predef
-; Fill EnemyMon stats
- ld hl, EnemyMonAtk
+
+ ld hl, EnemyMonStats
ld de, $c6c1
- ld bc, 2*(NUM_STATS-1) ; 2 bytes for each non-HP stat
+ ld bc, EnemyMonStatsEnd - EnemyMonStats
call CopyBytes
-; We're done
+
ret
; 3eb38
@@ -6243,92 +8023,118 @@ GetRoamMonDVs: ; 3fa19
INCBIN "baserom.gbc", $3fa31, $3fc8b - $3fa31
-; I have no clue what most of this does
-BattleStartMessage:
- ld a, [$d22d]
+BattleStartMessage ; 3fc8b
+ ld a, [IsInBattle]
dec a
- jr z, .asm_3fcaa ; 0x3fc8f $19
- ld de, $005e
- call $3c23
+ jr z, .asm_3fcaa
+
+ ld de, SFX_SHINE
+ call StartSFX
call WaitSFX
- ld c, $14
- call $0468
+
+ ld c, 20
+ call DelayFrames
+
ld a, $e
ld hl, $5939
rst FarCall
- ld hl, $47a9
- jr .asm_3fd0e ; 0x3fca8 $64
+
+ ld hl, WantsToBattleText
+ jr .asm_3fd0e
+
.asm_3fcaa
call $5a79
- jr nc, .asm_3fcc2 ; 0x3fcad $13
+ jr nc, .asm_3fcc2
+
xor a
ld [$cfca], a
- ld a, $1
- ld [$ffe4], a
- ld a, $1
+ ld a, 1
+ ld [hBattleTurn], a
+ ld a, 1
ld [$c689], a
ld de, $0101
call $6e17
+
.asm_3fcc2
ld a, $f
ld hl, $6b38
rst FarCall
- jr c, .messageSelection ; 0x3fcc8 $21
+ jr c, .asm_3fceb
+
ld a, $13
ld hl, $6a44
rst FarCall
- jr c, .asm_3fce0 ; 0x3fcd0 $e
- ld hl, $c4ac
+ jr c, .asm_3fce0
+
+ hlcoord 12, 0
ld d, $0
ld e, $1
ld a, $47
- call $2d83
- jr .messageSelection ; 0x3fcde $b
+ call Predef
+ jr .asm_3fceb
+
.asm_3fce0
- ld a, $f
- ld [$c2bd], a
- ld a, [$d204]
+ ld a, $0f
+ ld [CryTracks], a
+ ld a, [TempEnemyMonSpecies]
call $37b6
-.messageSelection
- ld a, [$d230]
- cp $4
- jr nz, .asm_3fcfd ; 0x3fcf0 $b
+
+.asm_3fceb
+ ld a, [BattleType]
+ cp BATTLETYPE_FISH
+ jr nz, .asm_3fcfd
+
ld a, $41
ld hl, $6086
rst FarCall
+
ld hl, HookedPokemonAttackedText
- jr .asm_3fd0e ; 0x3fcfb $11
+ jr .asm_3fd0e
+
.asm_3fcfd
ld hl, PokemonFellFromTreeText
- cp $8
- jr z, .asm_3fd0e ; 0x3fd02 $a
+ cp BATTLETYPE_TREE
+ jr z, .asm_3fd0e
ld hl, WildPokemonAppearedText2
cp $b
- jr z, .asm_3fd0e ; 0x3fd09 $3
+ jr z, .asm_3fd0e
ld hl, WildPokemonAppearedText
+
.asm_3fd0e
push hl
ld a, $b
ld hl, $4000
rst FarCall
+
pop hl
- call $3ad5
+ call FarBattleTextBox
+
call $7830
+
ret nz
+
ld c, $2
ld a, $13
ld hl, $6a0a
rst FarCall
+
ret
-; 0x3fd26
+; 3fd26
+
+
+ dw $0000 ; padding
+
+
+BattleCommandPointers: ; 3fd28
+
+INCLUDE "battle/effect_command_pointers.asm"
-INCBIN "baserom.gbc",$3fd26,$3fe86 - $3fd26
SECTION "bank10",DATA,BANK[$10]
-INCBIN "baserom.gbc",$40000,$40c65-$40000
+INCBIN "baserom.gbc", $40000, $40c65-$40000
AlphabeticalPokedexOrder: ; 0x40c65
INCLUDE "stats/pokedex/order_alpha.asm"
@@ -6336,12 +8142,12 @@ INCLUDE "stats/pokedex/order_alpha.asm"
NewPokedexOrder: ; 0x40d60
INCLUDE "stats/pokedex/order_new.asm"
-INCBIN "baserom.gbc",$40e5b,$41afb-$40e5b
+INCBIN "baserom.gbc", $40e5b, $41afb-$40e5b
Moves: ; 0x41afb
INCLUDE "battle/moves/moves.asm"
-INCBIN "baserom.gbc",$421d8,$425b1-$421d8
+INCBIN "baserom.gbc", $421d8, $425b1-$421d8
EvosAttacksPointers: ; 0x425b1
INCLUDE "stats/evos_attacks_pointers.asm"
@@ -6351,22 +8157,400 @@ INCLUDE "stats/evos_attacks.asm"
SECTION "bank11",DATA,BANK[$11]
-INCBIN "baserom.gbc",$44000,$44378 - $44000
+FruitTreeScript: ; 44000
+ 3callasm BANK(GetCurTreeFruit), GetCurTreeFruit
+ loadfont
+ copybytetovar CurFruit
+ itemtotext $0, $0
+ 2writetext FruitBearingTreeText
+ keeptextopen
+ 3callasm BANK(TryResetFruitTrees), TryResetFruitTrees
+ 3callasm BANK(CheckFruitTree), CheckFruitTree
+ iffalse .fruit
+ 2writetext NothingHereText
+ closetext
+ 2jump .end
+
+.fruit
+ 2writetext HeyItsFruitText
+ copybytetovar CurFruit
+ giveitem $ff, 1
+ iffalse .packisfull
+ keeptextopen
+ 2writetext ObtainedFruitText
+ 3callasm BANK(PickedFruitTree), PickedFruitTree
+ specialsound
+ itemnotify
+ 2jump .end
+
+.packisfull
+ keeptextopen
+ 2writetext FruitPackIsFullText
+ closetext
+
+.end
+ loadmovesprites
+ end
+; 44041
+
+GetCurTreeFruit: ; 44041
+ ld a, [CurFruitTree]
+ dec a
+ call GetFruitTreeItem
+ ld [CurFruit], a
+ ret
+; 4404c
+
+TryResetFruitTrees: ; 4404c
+ ld hl, $dc1e
+ bit 4, [hl]
+ ret nz
+ jp ResetFruitTrees
+; 44055
+
+CheckFruitTree: ; 44055
+ ld b, 2
+ call GetFruitTreeFlag
+ ld a, c
+ ld [ScriptVar], a
+ ret
+; 4405f
+
+PickedFruitTree: ; 4405f
+ ld a, $41
+ ld hl, $609b
+ rst FarCall ; empty function
+
+ ld b, 1
+ jp GetFruitTreeFlag
+; 4406a
+
+ResetFruitTrees: ; 4406a
+ xor a
+ ld hl, FruitTreeFlags
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld hl, $dc1e
+ set 4, [hl]
+ ret
+; 44078
+
+GetFruitTreeFlag: ; 44078
+ push hl
+ push de
+ ld a, [CurFruitTree]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeFlags
+ call BitTableFunc
+ pop de
+ pop hl
+ ret
+; 4408a
+
+GetFruitTreeItem: ; 4408a
+ push hl
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeItems
+ add hl, de
+ ld a, [hl]
+ pop de
+ pop hl
+ ret
+; 44097
+
+FruitTreeItems: ; 44097
+ db BERRY
+ db BERRY
+ db BERRY
+ db BERRY
+ db PSNCUREBERRY
+ db PSNCUREBERRY
+ db BITTER_BERRY
+ db BITTER_BERRY
+ db PRZCUREBERRY
+ db PRZCUREBERRY
+ db MYSTERYBERRY
+ db MYSTERYBERRY
+ db ICE_BERRY
+ db ICE_BERRY
+ db MINT_BERRY
+ db BURNT_BERRY
+ db RED_APRICORN
+ db BLU_APRICORN
+ db BLK_APRICORN
+ db WHT_APRICORN
+ db PNK_APRICORN
+ db GRN_APRICORN
+ db YLW_APRICORN
+ db BERRY
+ db PSNCUREBERRY
+ db BITTER_BERRY
+ db PRZCUREBERRY
+ db ICE_BERRY
+ db MINT_BERRY
+ db BURNT_BERRY
+; 440b5
+
+FruitBearingTreeText: ; 440b5
+ text_jump _FruitBearingTreeText, BANK(_FruitBearingTreeText)
+ db "@"
+; 440ba
+
+HeyItsFruitText: ; 440ba
+ text_jump _HeyItsFruitText, BANK(_HeyItsFruitText)
+ db "@"
+; 440bf
+
+ObtainedFruitText: ; 440bf
+ text_jump _ObtainedFruitText, BANK(_ObtainedFruitText)
+ db "@"
+; 440c4
+
+FruitPackIsFullText: ; 440c4
+ text_jump _FruitPackIsFullText, BANK(_FruitPackIsFullText)
+ db "@"
+; 440c9
+
+NothingHereText: ; 440c9
+ text_jump _NothingHereText, BANK(_NothingHereText)
+ db "@"
+; 440ce
+
+
+
+AIChooseMove: ; 440ce
+; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
+; Pick the move with the lowest score.
+
+; Wildmons attack at random.
+ ld a, [IsInBattle]
+ dec a
+ ret z
+
+ ld a, [InLinkBattle]
+ and a
+ ret nz
+
+; No use picking a move if there's no choice.
+ ld a, $f
+ ld hl, $68d1
+ rst FarCall ; CheckLockedEnemyMove
+ ret nz
+
+
+; The default score is 20. Unusable moves are given a score of 80.
+ ld a, 20
+ ld hl, Buffer1
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+
+; Don't pick disabled moves.
+ ld a, [EnemyDisabledMove]
+ and a
+ jr z, .CheckPP
+
+ ld hl, EnemyMonMove1
+ ld c, 0
+.CheckDisabledMove
+ cp [hl]
+ jr z, .ScoreDisabledMove
+ inc c
+ inc hl
+ jr .CheckDisabledMove
+.ScoreDisabledMove
+ ld hl, Buffer1
+ ld b, 0
+ add hl, bc
+ ld [hl], 80
+
+; Don't pick moves with 0 PP.
+.CheckPP
+ ld hl, Buffer1 - 1
+ ld de, EnemyMonPP
+ ld b, 0
+.CheckMovePP
+ inc b
+ ld a, b
+ cp EnemyMonMovesEnd - EnemyMonMoves + 1
+ jr z, .ApplyLayers
+ inc hl
+ ld a, [de]
+ inc de
+ and $3f
+ jr nz, .CheckMovePP
+ ld [hl], 80
+ jr .CheckMovePP
+
+
+; Apply AI scoring layers depending on the trainer class.
+.ApplyLayers
+ ld hl, $559f ; TrainerAI + 3 ; e:559c-5771
+
+ ld a, [$cfc0]
+ bit 0, a
+ jr nz, .asm_4412f
+
+ ld a, [TrainerClass]
+ dec a
+ ld bc, 7 ; Trainer2AI - Trainer1AI
+ call AddNTimes
+
+.asm_4412f
+ ld bc, (CHECK_FLAG << 8) | 0
+ push bc
+ push hl
+
+.CheckLayer
+ pop hl
+ pop bc
+
+ ld a, c
+ cp 16 ; up to 16 scoring layers
+ jr z, .asm_4415e
+
+ push bc
+ ld d, $e ; BANK(TrainerAI)
+ ld a, PREDEF_FLAG
+ call Predef
+ ld d, c
+ pop bc
+
+ inc c
+ push bc
+ push hl
+
+ ld a, d
+ and a
+ jr z, .CheckLayer
+
+ ld hl, AIScoringPointers
+ dec c
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, BANK(AIScoring)
+ call FarJpHl
+
+ jr .CheckLayer
+
+.asm_4415e
+ ld hl, Buffer1
+ ld de, EnemyMonMoves
+ ld c, EnemyMonMovesEnd - EnemyMonMoves
+.asm_44166
+ ld a, [de]
+ inc de
+ and a
+ jr z, .asm_4415e
+
+ dec [hl]
+ jr z, .asm_44174
+
+ inc hl
+ dec c
+ jr z, .asm_4415e
+
+ jr .asm_44166
+
+.asm_44174
+ ld a, c
+.asm_44175
+ inc [hl]
+ dec hl
+ inc a
+ cp EnemyMonMovesEnd - EnemyMonMoves + 1
+ jr nz, .asm_44175
+
+ ld hl, Buffer1
+ ld de, EnemyMonMoves
+ ld c, EnemyMonMovesEnd - EnemyMonMoves
+.asm_44184
+ ld a, [de]
+ and a
+ jr nz, .asm_44189
+ ld [hl], a
+.asm_44189
+ ld a, [hl]
+ dec a
+ jr z, .asm_44191
+ xor a
+ ld [hli], a
+ jr .asm_44193
+.asm_44191
+ ld a, [de]
+ ld [hli], a
+.asm_44193
+ inc de
+ dec c
+ jr nz, .asm_44184
+
+.asm_44197
+ ld hl, Buffer1
+ call RNG
+ and 3
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .asm_44197
+
+ ld [CurEnemyMove], a
+ ld a, c
+ ld [CurEnemyMoveNum], a
+ ret
+; 441af
+
+
+AIScoringPointers: ; 441af
+ dw AIScoring_RedStatus
+ dw AIScoring_RedStatMods
+ dw AIScoring_RedSuperEffective
+ dw AIScoring_Offensive
+ dw AIScoring_Smart
+ dw AIScoring_Opportunist
+ dw AIScoring_Aggressive
+ dw AIScoring_Cautious
+ dw AIScoring_StatusImmunity
+ dw AIScoring_Risky
+ dw AIScoring_None
+ dw AIScoring_None
+ dw AIScoring_None
+ dw AIScoring_None
+ dw AIScoring_None
+ dw AIScoring_None
+; 441cf
+
+
+INCBIN "baserom.gbc", $441cf, $44378 - $441cf
+
PokedexDataPointerTable: ; 0x44378
INCLUDE "stats/pokedex/entry_pointers.asm"
-INCBIN "baserom.gbc",$4456e,$44997 - $4456e
+
+INCBIN "baserom.gbc", $4456e, $44997 - $4456e
SECTION "bank12",DATA,BANK[$12]
-INCBIN "baserom.gbc",$48000,$48e9b - $48000
+INCBIN "baserom.gbc", $48000, $48e9b - $48000
PackFGFX:
INCBIN "gfx/misc/pack_f.2bpp"
-INCBIN "baserom.gbc",$4925b,$49962 - $4925b
+INCBIN "baserom.gbc", $4925b, $49962 - $4925b
SpecialCelebiGFX:
INCBIN "gfx/special/celebi/leaf.2bpp"
@@ -6375,7 +8559,7 @@ INCBIN "gfx/special/celebi/2.2bpp"
INCBIN "gfx/special/celebi/3.2bpp"
INCBIN "gfx/special/celebi/4.2bpp"
-INCBIN "baserom.gbc",$49aa2,$49d24 - $49aa2
+INCBIN "baserom.gbc", $49aa2, $49d24 - $49aa2
ContinueText: ; 0x49d24
db "CONTINUE@"
@@ -6472,7 +8656,7 @@ StudiumMenu: ; 0x49d9e
db MOBILE_STUDIUM
db $ff
-INCBIN "baserom.gbc",$49da4,$4a6e8 - $49da4
+INCBIN "baserom.gbc", $49da4, $4a6e8 - $49da4
SpecialBeastsCheck: ; 0x4a6e8
; Check if the player owns all three legendary beasts.
@@ -6732,12 +8916,143 @@ UpdateOTPointer: ; 0x4a83a
ret
; 0x4a843
-INCBIN "baserom.gbc",$4a843,$4ae78 - $4a843
+INCBIN "baserom.gbc", $4a843, $4ae78 - $4a843
SECTION "bank13",DATA,BANK[$13]
-INCBIN "baserom.gbc",$4C000,$4ce1f - $4C000
+INCBIN "baserom.gbc", $4c000, $4c075 - $4c000
+
+Tileset03PalMap: ; 0x4c075
+INCBIN "tilesets/03_palette_map.bin"
+; 0x4c0e5
+
+Tileset00PalMap: ; 0x4c0e5
+Tileset01PalMap: ; 0x4c0e5
+INCBIN "tilesets/01_palette_map.bin"
+; 0x4c155
+
+Tileset02PalMap: ; 0x4c155
+INCBIN "tilesets/02_palette_map.bin"
+; 0x4c1c5
+
+Tileset05PalMap: ; 0x4c1c5
+INCBIN "tilesets/05_palette_map.bin"
+; 0x4c235
+
+Tileset06PalMap: ; 0x4c235
+INCBIN "tilesets/06_palette_map.bin"
+; 0x4c2a5
+
+Tileset07PalMap: ; 0x4c2a5
+INCBIN "tilesets/07_palette_map.bin"
+; 0x4c315
+
+Tileset08PalMap: ; 0x4c315
+INCBIN "tilesets/08_palette_map.bin"
+; 0x4c385
+
+Tileset09PalMap: ; 0x4c385
+INCBIN "tilesets/09_palette_map.bin"
+; 0x4c3f5
+
+Tileset10PalMap: ; 0x4c3f5
+INCBIN "tilesets/10_palette_map.bin"
+; 0x4c465
+
+Tileset11PalMap: ; 0x4c465
+INCBIN "tilesets/11_palette_map.bin"
+; 0x4c4d5
+
+Tileset12PalMap: ; 0x4c4d5
+INCBIN "tilesets/12_palette_map.bin"
+; 0x4c545
+
+Tileset13PalMap: ; 0x4c545
+INCBIN "tilesets/13_palette_map.bin"
+; 0x4c5b5
+
+Tileset14PalMap: ; 0x4c5b5
+INCBIN "tilesets/14_palette_map.bin"
+; 0x4c625
+
+Tileset15PalMap: ; 0x4c625
+INCBIN "tilesets/15_palette_map.bin"
+; 0x4c695
+
+Tileset16PalMap: ; 0x4c695
+INCBIN "tilesets/16_palette_map.bin"
+; 0x4c705
+
+Tileset23PalMap: ; 0x4c705
+INCBIN "tilesets/23_palette_map.bin"
+; 0x4c775
+
+Tileset24PalMap: ; 0x4c775
+Tileset30PalMap: ; 0x4c775
+INCBIN "tilesets/30_palette_map.bin"
+; 0x4c7e5
+
+Tileset25PalMap: ; 0x4c7e5
+INCBIN "tilesets/25_palette_map.bin"
+; 0x4c855
+
+Tileset26PalMap: ; 0x4c855
+Tileset32PalMap: ; 0x4c855
+Tileset33PalMap: ; 0x4c855
+Tileset34PalMap: ; 0x4c855
+Tileset35PalMap: ; 0x4c855
+Tileset36PalMap: ; 0x4c855
+INCBIN "tilesets/36_palette_map.bin"
+; 0x4c8c5
+
+Tileset27PalMap: ; 0x4c8c5
+INCBIN "tilesets/27_palette_map.bin"
+; 0x4c935
+
+Tileset17PalMap: ; 0x4c935
+INCBIN "tilesets/17_palette_map.bin"
+; 0x4c9a5
+
+Tileset28PalMap: ; 0x4c9a5
+INCBIN "tilesets/28_palette_map.bin"
+; 0x4ca15
+
+Tileset18PalMap: ; 0x4ca15
+INCBIN "tilesets/18_palette_map.bin"
+; 0x4ca85
+
+Tileset19PalMap: ; 0x4ca85
+INCBIN "tilesets/19_palette_map.bin"
+; 0x4caf5
+
+Tileset20PalMap: ; 0x4caf5
+INCBIN "tilesets/20_palette_map.bin"
+; 0x4cb65
+
+INCBIN "baserom.gbc", $4cb65, $4cbd5-$4cb65
+
+Tileset29PalMap: ; 0x4cbd5
+INCBIN "tilesets/29_palette_map.bin"
+; 0x4cc45
+
+Tileset31PalMap: ; 0x4cc45
+INCBIN "tilesets/31_palette_map.bin"
+; 0x4ccb5
+
+Tileset21PalMap: ; 0x4ccb5
+INCBIN "tilesets/21_palette_map.bin"
+; 0x4cd25
+
+Tileset22PalMap: ; 0x4cd25
+INCBIN "tilesets/22_palette_map.bin"
+; 0x4cd95
+
+Tileset04PalMap: ; 0x4cd95
+INCBIN "tilesets/04_palette_map.bin"
+; 0x4ce05
+
+INCBIN "baserom.gbc", $4ce05, $4ce1f - $4ce05
TileTypeTable: ; 4ce1f
; 256 tiletypes
@@ -6779,7 +9094,309 @@ TileTypeTable: ; 4ce1f
db $00, $00, $00, $00, $00, $00, $00, $0f
; 4cf1f
-INCBIN "baserom.gbc",$4cf1f,$4d860 - $4cf1f
+INCBIN "baserom.gbc", $4cf1f, $4d596 - $4cf1f
+
+Tilesets:
+
+Tileset00: ; 0x4d596
+ dbw BANK(Tileset00GFX), Tileset00GFX
+ dbw BANK(Tileset00Meta), Tileset00Meta
+ dbw BANK(Tileset00Coll), Tileset00Coll
+ dw Tileset00Anim
+ dw $0000
+ dw Tileset00PalMap
+
+Tileset01: ; 0x4d5a5
+ dbw BANK(Tileset01GFX), Tileset01GFX
+ dbw BANK(Tileset01Meta), Tileset01Meta
+ dbw BANK(Tileset01Coll), Tileset01Coll
+ dw Tileset01Anim
+ dw $0000
+ dw Tileset01PalMap
+
+Tileset02: ; 0x4d5b4
+ dbw BANK(Tileset02GFX), Tileset02GFX
+ dbw BANK(Tileset02Meta), Tileset02Meta
+ dbw BANK(Tileset02Coll), Tileset02Coll
+ dw Tileset02Anim
+ dw $0000
+ dw Tileset02PalMap
+
+Tileset03: ; 0x4d5c3
+ dbw BANK(Tileset03GFX), Tileset03GFX
+ dbw BANK(Tileset03Meta), Tileset03Meta
+ dbw BANK(Tileset03Coll), Tileset03Coll
+ dw Tileset03Anim
+ dw $0000
+ dw Tileset03PalMap
+
+Tileset04: ; 0x4d5d2
+ dbw BANK(Tileset04GFX), Tileset04GFX
+ dbw BANK(Tileset04Meta), Tileset04Meta
+ dbw BANK(Tileset04Coll), Tileset04Coll
+ dw Tileset04Anim
+ dw $0000
+ dw Tileset04PalMap
+
+Tileset05: ; 0x4d5e1
+ dbw BANK(Tileset05GFX), Tileset05GFX
+ dbw BANK(Tileset05Meta), Tileset05Meta
+ dbw BANK(Tileset05Coll), Tileset05Coll
+ dw Tileset05Anim
+ dw $0000
+ dw Tileset05PalMap
+
+Tileset06: ; 0x4d5f0
+ dbw BANK(Tileset06GFX), Tileset06GFX
+ dbw BANK(Tileset06Meta), Tileset06Meta
+ dbw BANK(Tileset06Coll), Tileset06Coll
+ dw Tileset06Anim
+ dw $0000
+ dw Tileset06PalMap
+
+Tileset07: ; 0x4d5ff
+ dbw BANK(Tileset07GFX), Tileset07GFX
+ dbw BANK(Tileset07Meta), Tileset07Meta
+ dbw BANK(Tileset07Coll), Tileset07Coll
+ dw Tileset07Anim
+ dw $0000
+ dw Tileset07PalMap
+
+Tileset08: ; 0x4d60e
+ dbw BANK(Tileset08GFX), Tileset08GFX
+ dbw BANK(Tileset08Meta), Tileset08Meta
+ dbw BANK(Tileset08Coll), Tileset08Coll
+ dw Tileset08Anim
+ dw $0000
+ dw Tileset08PalMap
+
+Tileset09: ; 0x4d61d
+ dbw BANK(Tileset09GFX), Tileset09GFX
+ dbw BANK(Tileset09Meta), Tileset09Meta
+ dbw BANK(Tileset09Coll), Tileset09Coll
+ dw Tileset09Anim
+ dw $0000
+ dw Tileset09PalMap
+
+Tileset10: ; 0x4d62c
+ dbw BANK(Tileset10GFX), Tileset10GFX
+ dbw BANK(Tileset10Meta), Tileset10Meta
+ dbw BANK(Tileset10Coll), Tileset10Coll
+ dw Tileset10Anim
+ dw $0000
+ dw Tileset10PalMap
+
+Tileset11: ; 0x4d63b
+ dbw BANK(Tileset11GFX), Tileset11GFX
+ dbw BANK(Tileset11Meta), Tileset11Meta
+ dbw BANK(Tileset11Coll), Tileset11Coll
+ dw Tileset11Anim
+ dw $0000
+ dw Tileset11PalMap
+
+Tileset12: ; 0x4d64a
+ dbw BANK(Tileset12GFX), Tileset12GFX
+ dbw BANK(Tileset12Meta), Tileset12Meta
+ dbw BANK(Tileset12Coll), Tileset12Coll
+ dw Tileset12Anim
+ dw $0000
+ dw Tileset12PalMap
+
+Tileset13: ; 0x4d659
+ dbw BANK(Tileset13GFX), Tileset13GFX
+ dbw BANK(Tileset13Meta), Tileset13Meta
+ dbw BANK(Tileset13Coll), Tileset13Coll
+ dw Tileset13Anim
+ dw $0000
+ dw Tileset13PalMap
+
+Tileset14: ; 0x4d668
+ dbw BANK(Tileset14GFX), Tileset14GFX
+ dbw BANK(Tileset14Meta), Tileset14Meta
+ dbw BANK(Tileset14Coll), Tileset14Coll
+ dw Tileset14Anim
+ dw $0000
+ dw Tileset14PalMap
+
+Tileset15: ; 0x4d677
+ dbw BANK(Tileset15GFX), Tileset15GFX
+ dbw BANK(Tileset15Meta), Tileset15Meta
+ dbw BANK(Tileset15Coll), Tileset15Coll
+ dw Tileset15Anim
+ dw $0000
+ dw Tileset15PalMap
+
+Tileset16: ; 0x4d686
+ dbw BANK(Tileset16GFX), Tileset16GFX
+ dbw BANK(Tileset16Meta), Tileset16Meta
+ dbw BANK(Tileset16Coll), Tileset16Coll
+ dw Tileset16Anim
+ dw $0000
+ dw Tileset16PalMap
+
+Tileset17: ; 0x4d695
+ dbw BANK(Tileset17GFX), Tileset17GFX
+ dbw BANK(Tileset17Meta), Tileset17Meta
+ dbw BANK(Tileset17Coll), Tileset17Coll
+ dw Tileset17Anim
+ dw $0000
+ dw Tileset17PalMap
+
+Tileset18: ; 0x4d6a4
+ dbw BANK(Tileset18GFX), Tileset18GFX
+ dbw BANK(Tileset18Meta), Tileset18Meta
+ dbw BANK(Tileset18Coll), Tileset18Coll
+ dw Tileset18Anim
+ dw $0000
+ dw Tileset18PalMap
+
+Tileset19: ; 0x4d6b3
+ dbw BANK(Tileset19GFX), Tileset19GFX
+ dbw BANK(Tileset19Meta), Tileset19Meta
+ dbw BANK(Tileset19Coll), Tileset19Coll
+ dw Tileset19Anim
+ dw $0000
+ dw Tileset19PalMap
+
+Tileset20: ; 0x4d6c2
+ dbw BANK(Tileset20GFX), Tileset20GFX
+ dbw BANK(Tileset20Meta), Tileset20Meta
+ dbw BANK(Tileset20Coll), Tileset20Coll
+ dw Tileset20Anim
+ dw $0000
+ dw Tileset20PalMap
+
+Tileset21: ; 0x4d6d1
+ dbw BANK(Tileset21GFX), Tileset21GFX
+ dbw BANK(Tileset21Meta), Tileset21Meta
+ dbw BANK(Tileset21Coll), Tileset21Coll
+ dw Tileset21Anim
+ dw $0000
+ dw Tileset21PalMap
+
+Tileset22: ; 0x4d6e0
+ dbw BANK(Tileset22GFX), Tileset22GFX
+ dbw BANK(Tileset22Meta), Tileset22Meta
+ dbw BANK(Tileset22Coll), Tileset22Coll
+ dw Tileset22Anim
+ dw $0000
+ dw Tileset22PalMap
+
+Tileset23: ; 0x4d6ef
+ dbw BANK(Tileset23GFX), Tileset23GFX
+ dbw BANK(Tileset23Meta), Tileset23Meta
+ dbw BANK(Tileset23Coll), Tileset23Coll
+ dw Tileset23Anim
+ dw $0000
+ dw Tileset23PalMap
+
+Tileset24: ; 0x4d6fe
+ dbw BANK(Tileset24GFX), Tileset24GFX
+ dbw BANK(Tileset24Meta), Tileset24Meta
+ dbw BANK(Tileset24Coll), Tileset24Coll
+ dw Tileset24Anim
+ dw $0000
+ dw Tileset24PalMap
+
+Tileset25: ; 0x4d70d
+ dbw BANK(Tileset25GFX), Tileset25GFX
+ dbw BANK(Tileset25Meta), Tileset25Meta
+ dbw BANK(Tileset25Coll), Tileset25Coll
+ dw Tileset25Anim
+ dw $0000
+ dw Tileset25PalMap
+
+Tileset26: ; 0x4d71c
+ dbw BANK(Tileset26GFX), Tileset26GFX
+ dbw BANK(Tileset26Meta), Tileset26Meta
+ dbw BANK(Tileset26Coll), Tileset26Coll
+ dw Tileset26Anim
+ dw $0000
+ dw Tileset26PalMap
+
+Tileset27: ; 0x4d72b
+ dbw BANK(Tileset27GFX), Tileset27GFX
+ dbw BANK(Tileset27Meta), Tileset27Meta
+ dbw BANK(Tileset27Coll), Tileset27Coll
+ dw Tileset27Anim
+ dw $0000
+ dw Tileset27PalMap
+
+Tileset28: ; 0x4d73a
+ dbw BANK(Tileset28GFX), Tileset28GFX
+ dbw BANK(Tileset28Meta), Tileset28Meta
+ dbw BANK(Tileset28Coll), Tileset28Coll
+ dw Tileset28Anim
+ dw $0000
+ dw Tileset28PalMap
+
+Tileset29: ; 0x4d749
+ dbw BANK(Tileset29GFX), Tileset29GFX
+ dbw BANK(Tileset29Meta), Tileset29Meta
+ dbw BANK(Tileset29Coll), Tileset29Coll
+ dw Tileset29Anim
+ dw $0000
+ dw Tileset29PalMap
+
+Tileset30: ; 0x4d758
+ dbw BANK(Tileset30GFX), Tileset30GFX
+ dbw BANK(Tileset30Meta), Tileset30Meta
+ dbw BANK(Tileset30Coll), Tileset30Coll
+ dw Tileset30Anim
+ dw $0000
+ dw Tileset30PalMap
+
+Tileset31: ; 0x4d767
+ dbw BANK(Tileset31GFX), Tileset31GFX
+ dbw BANK(Tileset31Meta), Tileset31Meta
+ dbw BANK(Tileset31Coll), Tileset31Coll
+ dw Tileset31Anim
+ dw $0000
+ dw Tileset31PalMap
+
+Tileset32: ; 0x4d776
+ dbw BANK(Tileset32GFX), Tileset32GFX
+ dbw BANK(Tileset32Meta), Tileset32Meta
+ dbw BANK(Tileset32Coll), Tileset32Coll
+ dw Tileset32Anim
+ dw $0000
+ dw Tileset32PalMap
+
+Tileset33: ; 0x4d785
+ dbw BANK(Tileset33GFX), Tileset33GFX
+ dbw BANK(Tileset33Meta), Tileset33Meta
+ dbw BANK(Tileset33Coll), Tileset33Coll
+ dw Tileset33Anim
+ dw $0000
+ dw Tileset33PalMap
+
+Tileset34: ; 0x4d794
+ dbw BANK(Tileset34GFX), Tileset34GFX
+ dbw BANK(Tileset34Meta), Tileset34Meta
+ dbw BANK(Tileset34Coll), Tileset34Coll
+ dw Tileset34Anim
+ dw $0000
+ dw Tileset34PalMap
+
+Tileset35: ; 0x4d7a3
+ dbw BANK(Tileset35GFX), Tileset35GFX
+ dbw BANK(Tileset35Meta), Tileset35Meta
+ dbw BANK(Tileset35Coll), Tileset35Coll
+ dw Tileset35Anim
+ dw $0000
+ dw Tileset35PalMap
+
+Tileset36: ; 0x4d7b2
+ dbw BANK(Tileset36GFX), Tileset36GFX
+ dbw BANK(Tileset36Meta), Tileset36Meta
+ dbw BANK(Tileset36Coll), Tileset36Coll
+ dw Tileset36Anim
+ dw $0000
+ dw Tileset36PalMap
+
+; 0x4d7c1
+
+INCBIN "baserom.gbc", $4d7c1, $4d860 - $4d7c1
CheckPokerus: ; 4d860
; Return carry if a monster in your party has Pokerus
@@ -6808,7 +9425,7 @@ CheckPokerus: ; 4d860
ret
; 4d87a
-INCBIN "baserom.gbc",$4d87a,$4dc8a - $4d87a
+INCBIN "baserom.gbc", $4d87a, $4dc8a - $4d87a
StatsScreenInit: ; 4dc8a
ld hl, StatsScreenMain
@@ -6833,7 +9450,7 @@ StatsScreenInit: ; 4dc8a
call $1ad2
ld a, $3e
ld hl, $753e
- rst $8 ; this loads graphics
+ rst FarCall ; this loads graphics
pop hl
call JpHl
call $31f3
@@ -6871,7 +9488,7 @@ StatsScreenMain: ; 0x4dcd2
ret
; 0x4dcf7
-INCBIN "baserom.gbc",$4dcf7,$4dd2a - $4dcf7
+INCBIN "baserom.gbc", $4dcf7, $4dd2a - $4dcf7
StatsScreenPointerTable: ; 4dd2a
dw $5d72 ; regular pokémon
@@ -6885,7 +9502,7 @@ StatsScreenPointerTable: ; 4dd2a
; 4dd3a
-INCBIN "baserom.gbc",$4dd3a,$4dda1 - $4dd3a
+INCBIN "baserom.gbc", $4dd3a, $4dda1 - $4dd3a
EggStatsInit: ; 4dda1
call EggStatsScreen
@@ -6895,7 +9512,7 @@ EggStatsInit: ; 4dda1
ret
; 0x4ddac
-INCBIN "baserom.gbc",$4ddac,$4e21e - $4ddac
+INCBIN "baserom.gbc", $4ddac, $4e21e - $4ddac
IDNoString: ; 4e21e
db $73, "№.@"
@@ -6904,13 +9521,13 @@ OTString: ; 4e222
db "OT/@"
; 4e226
-INCBIN "baserom.gbc",$4e226,$4e33a - $4e226
+INCBIN "baserom.gbc", $4e226, $4e33a - $4e226
EggStatsScreen: ; 4e33a
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld hl, $cda1
- call $334e ; SetHPPal
+ call SetHPPal
ld b, $3
call GetSGBLayout
call $5f8f
@@ -6951,12 +9568,13 @@ EggStatsScreen: ; 4e33a
call $3786
ld a, $41
ld hl, $402d
- rst $8
+ rst FarCall
call $6497
- ld a, [$d129]
- cp $6
+
+ ld a, [TempMonHappiness]
+ cp 6
ret nc
- ld de, $00bb
+ ld de, SFX_2_BOOPS
call StartSFX
ret
; 0x4e3c0
@@ -6981,18 +9599,18 @@ EggALotMoreTimeString: ; 0x4e46e
; 0x4e497
-INCBIN "baserom.gbc",$4e497,$4e831 - $4e497
+INCBIN "baserom.gbc", $4e497, $4e831 - $4e497
EvolutionGFX:
INCBIN "gfx/evo/bubble_large.2bpp"
INCBIN "gfx/evo/bubble.2bpp"
-INCBIN "baserom.gbc",$4e881,$4f31c - $4e881
+INCBIN "baserom.gbc", $4e881, $4f31c - $4e881
SECTION "bank14",DATA,BANK[$14]
-INCBIN "baserom.gbc",$50000,$5005f-$50000
+INCBIN "baserom.gbc", $50000, $5005f-$50000
WritePartyMenuTilemap: ; 0x5005f
ld hl, Options
@@ -7000,7 +9618,7 @@ WritePartyMenuTilemap: ; 0x5005f
push af
set 4, [hl] ; Disable text delay
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld hl, TileMap
ld bc, $0168
ld a, " "
@@ -7021,7 +9639,7 @@ WritePartyMenuTilemap: ; 0x5005f
ret
; 0x50089
-INCBIN "baserom.gbc",$50089,$50457-$50089
+INCBIN "baserom.gbc", $50089, $50457-$50089
PartyMenuSelect: ; 0x50457
; sets carry if exitted menu.
@@ -7047,13 +9665,15 @@ PartyMenuSelect: ; 0x50457
add hl, bc
ld a, [hl]
ld [CurPartySpecies], a
- ld de, $0008
+
+ ld de, SFX_READ_TEXT_2
call StartSFX
call WaitSFX
and a
ret
+
.exitmenu
- ld de, $0008
+ ld de, SFX_READ_TEXT_2
call StartSFX
call WaitSFX
scf
@@ -7124,11 +9744,93 @@ ToWhichPKMNString: ; 0x50549
YouHaveNoPKMNString: ; 0x50556
db "You have no ", $e1, $e2, "!@"
-INCBIN "baserom.gbc",$50566,$5097B-$50566
-dw Normal, Fighting, Flying, Poison, Ground, Rock, Bird, Bug, Ghost, Steel
-dw Normal, Normal, Normal, Normal, Normal, Normal, Normal, Normal, Normal
-dw UnknownType, Fire, Water, Grass, Electric, Psychic, Ice, Dragon, Dark
+INCBIN "baserom.gbc", $50566, $5093a - $50566
+
+
+PrintMoveType: ; 5093a
+; Print the type of move b at hl.
+
+ push hl
+ ld a, b
+ dec a
+ ld bc, Move2 - Move1
+ ld hl, Moves
+ call AddNTimes
+ ld de, StringBuffer1
+ ld a, BANK(Moves)
+ call FarCopyBytes
+ ld a, [StringBuffer1 + PlayerMoveType - PlayerMoveStruct]
+ pop hl
+
+ ld b, a
+; 50953
+
+PrintType: ; 50953
+; Print type b at hl.
+ ld a, b
+
+ push hl
+ add a
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+
+ jp PlaceString
+; 50964
+
+
+LoadTypeName: ; 50964
+; Copy the name of type $d265 to StringBuffer1.
+ ld a, [$d265]
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, StringBuffer1
+ ld bc, $000d
+ jp CopyBytes
+; 5097b
+
+
+TypeNames: ; 5097b
+ dw Normal
+ dw Fighting
+ dw Flying
+ dw Poison
+ dw Ground
+ dw Rock
+ dw Bird
+ dw Bug
+ dw Ghost
+ dw Steel
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw UnknownType
+ dw Fire
+ dw Water
+ dw Grass
+ dw Electric
+ dw Psychic
+ dw Ice
+ dw Dragon
+ dw Dark
Normal:
db "NORMAL@"
@@ -7168,6 +9870,8 @@ Dragon:
db "DRAGON@"
Dark:
db "DARK@"
+; 50a28
+
INCBIN "baserom.gbc", $50a28, $50bdd - $50a28
@@ -7252,12 +9956,12 @@ GetGender: ; 50bdd
push bc
ld a, [CurPartySpecies]
dec a
- ld hl, BaseStats + 13 ; BASE_GENDER
- ld bc, BaseStats1 - BaseStats
+ ld hl, BaseData + BaseGender - CurBaseData
+ ld bc, BaseData1 - BaseData
call AddNTimes
pop bc
- ld a, BANK(BaseStats)
+ ld a, BANK(BaseData)
call GetFarByte
@@ -7292,13 +9996,13 @@ GetGender: ; 50bdd
INCBIN "baserom.gbc", $50c50, $51424 - $50c50
-BaseStats:
+BaseData:
INCLUDE "stats/base_stats.asm"
PokemonNames:
INCLUDE "stats/pokemon_names.asm"
-INCBIN "baserom.gbc",$53D84,$53e2e - $53D84
+INCBIN "baserom.gbc", $53D84, $53e2e - $53D84
SECTION "bank15",DATA,BANK[$15]
@@ -7519,7 +10223,7 @@ INCLUDE "maps/Route12SuperRodHouse.asm"
SECTION "bank20",DATA,BANK[$20]
-INCBIN "baserom.gbc",$80000,$80430-$80000
+INCBIN "baserom.gbc", $80000, $80430-$80000
GetFlag2: ; 80430
; Do action b on flag de from BitTable2
@@ -7611,7 +10315,7 @@ INCLUDE "bittable2.asm"
; 80648
-INCBIN "baserom.gbc",$80648,$80730-$80648
+INCBIN "baserom.gbc", $80648, $80730-$80648
BattleText_0x80730: ; 0x80730
db $0, $52, " picked up", $4f
@@ -7648,7 +10352,7 @@ WildPokemonAppearedText2: ; 0x80793
db "appeared!", $58
; 0x807a9
-BattleText_0x807a9: ; 0x807a9
+WantsToBattleText: ; 0x807a9
db $0, $3f, $4f
db "wants to battle!", $58
; 0x807bd
@@ -7708,7 +10412,7 @@ BattleText_0x80880: ; 0x80880
db $0, $59, $4f
db "recovered with", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, ".", $58
; 0x80899
@@ -7716,7 +10420,7 @@ BattleText_0x80899: ; 0x80899
db $0, $5a, $4f
db "recovered PP using", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, ".", $58
; 0x808b6
@@ -7732,13 +10436,13 @@ BattleText_0x808d2: ; 0x808d2
; 0x808e7
BattleText_0x808e7: ; 0x808e7
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " #MON's", $4f
db "LIGHT SCREEN fell!", $58
; 0x80905
BattleText_0x80905: ; 0x80905
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " #MON's", $4f
db "REFLECT faded!", $58
; 0x8091f
@@ -7885,7 +10589,7 @@ BattleText_0x80b89: ; 0x80b89
db $0, $5a, $4f
db "fled using a", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x80ba0
@@ -7902,14 +10606,14 @@ RecoveredUsingText: ; 0x80bc2
db $0, $59, $4f
db "recovered using a", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x80bde
BattleText_0x80bde: ; 0x80bde
db $0, $5a, "'s", $4f
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, $55
db "activated!", $58
; 0x80bf3
@@ -7953,7 +10657,7 @@ BattleText_0x80c8a: ; 0x80c8a
; 0x80c9c
BattleText_0x80c9c: ; 0x80c9c
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " grew to", $4f
db "level @"
deciram $d143, $13
@@ -7980,65 +10684,65 @@ BattleText_0x80cd1: ; 0x80cd1
db "is angry!", $58
; 0x80ce7
-BattleText_0x80ce7: ; 0x80ce7
+FastAsleepText: ; 0x80ce7
db $0, $5a, $4f
db "is fast asleep!", $58
; 0x80cfa
-BattleText_0x80cfa: ; 0x80cfa
+WokeUpText: ; 0x80cfa
db $0, $5a, $4f
db "woke up!", $58
; 0x80d06
-BattleText_0x80d06: ; 0x80d06
+FrozenSolidText: ; 0x80d06
db $0, $5a, $4f
db "is frozen solid!", $58
; 0x80d1a
-BattleText_0x80d1a: ; 0x80d1a
+FlinchedText: ; 0x80d1a
db $0, $5a, $4f
db "flinched!", $58
; 0x80d27
-BattleText_0x80d27: ; 0x80d27
+MustRechargeText: ; 0x80d27
db $0, $5a, $4f
db "must recharge!", $58
; 0x80d39
-BattleText_0x80d39: ; 0x80d39
+DisabledNoMoreText: ; 0x80d39
db $0, $5a, "'s", $4f
db "disabled no more!", $58
; 0x80d4f
-BattleText_0x80d4f: ; 0x80d4f
+IsConfusedText: ; 0x80d4f
db $0, $5a, $4f
db "is confused!", $58
; 0x80d5f
-BattleText_0x80d5f: ; 0x80d5f
+HurtItselfText: ; 0x80d5f
db $0, "It hurt itself in", $4f
db "its confusion!", $58
; 0x80d81
-BattleText_0x80d81: ; 0x80d81
+ConfusedNoMoreText: ; 0x80d81
db $0, $5a, "'s", $4f
db "confused no more!", $58
; 0x80d97
-BattleText_0x80d97: ; 0x80d97
+BecameConfusedText: ; 0x80d97
db $0, $59, $4f
db "became confused!", $58
; 0x80dab
BattleText_0x80dab: ; 0x80dab
db $0, "A @"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " rid", $4f
db $59, $55
db "of its confusion.", $58
; 0x80dcc
-BattleText_0x80dcc: ; 0x80dcc
+AlreadyConfusedText: ; 0x80dcc
db $0, $59, "'s", $4f
db "already confused!", $58
; 0x80de2
@@ -8047,7 +10751,7 @@ BattleText_0x80de2: ; 0x80de2
db $0, $5a, "'s", $4f
db "hurt by", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x80df5
@@ -8055,123 +10759,123 @@ BattleText_0x80df5: ; 0x80df5
db $0, $5a, $4f
db "was released from", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x80e11
-BattleText_0x80e11: ; 0x80e11
+UsedBindText: ; 0x80e11
db $0, $5a, $4f
db "used BIND on", $55
db $59, "!", $58
; 0x80e24
-BattleText_0x80e24: ; 0x80e24
+WhirlpoolTrapText: ; 0x80e24
db $0, $59, $4f
db "was trapped!", $58
; 0x80e34
-BattleText_0x80e34: ; 0x80e34
+FireSpinTrapText: ; 0x80e34
db $0, $59, $4f
db "was trapped!", $58
; 0x80e44
-BattleText_0x80e44: ; 0x80e44
+WrappedByText: ; 0x80e44
db $0, $59, $4f
db "was WRAPPED by", $55
db $5a, "!", $58
; 0x80e59
-BattleText_0x80e59: ; 0x80e59
+ClampedByText: ; 0x80e59
db $0, $59, $4f
db "was CLAMPED by", $55
db $5a, "!", $58
; 0x80e6e
-BattleText_0x80e6e: ; 0x80e6e
+StoringEnergyText: ; 0x80e6e
db $0, $5a, $4f
db "is storing energy!", $58
; 0x80e84
-BattleText_0x80e84: ; 0x80e84
+UnleashedEnergyText: ; 0x80e84
db $0, $5a, $4f
db "unleashed energy!", $58
; 0x80e99
-BattleText_0x80e99: ; 0x80e99
+HungOnText: ; 0x80e99
db $0, $59, $4f
db "hung on with", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x80eb0
-BattleText_0x80eb0: ; 0x80eb0
+EnduredText: ; 0x80eb0
db $0, $59, $4f
db "ENDURED the hit!", $58
; 0x80ec4
-BattleText_0x80ec4: ; 0x80ec4
+InLoveWithText: ; 0x80ec4
db $0, $5a, $4f
db "is in love with", $55
db $59, "!", $58
; 0x80eda
-BattleText_0x80eda: ; 0x80eda
+InfatuationText: ; 0x80eda
db $0, $5a, "'s", $4f
db "infatuation kept", $55
db "it from attacking!", $58
; 0x80f02
-BattleText_0x80f02: ; 0x80f02
+DisabledMoveText: ; 0x80f02
db $0, $5a, "'s", $4f
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " is", $55
db "DISABLED!", $58
; 0x80f19
-BattleText_0x80f19: ; 0x80f19
+LoafingAroundText: ; 0x80f19
text_from_ram $c621
db $0, " is", $4f
db "loafing around.", $58
; 0x80f31
-BattleText_0x80f31: ; 0x80f31
+BeganToNapText: ; 0x80f31
text_from_ram $c621
db $0, " began", $4f
db "to nap!", $58
; 0x80f44
-BattleText_0x80f44: ; 0x80f44
+WontObeyText: ; 0x80f44
text_from_ram $c621
db $0, " won't", $4f
db "obey!", $58
; 0x80f54
-BattleText_0x80f54: ; 0x80f54
+TurnedAwayText: ; 0x80f54
text_from_ram $c621
db $0, " turned", $4f
db "away!", $58
; 0x80f66
-BattleText_0x80f66: ; 0x80f66
+IgnoredOrdersText: ; 0x80f66
text_from_ram $c621
db $0, " ignored", $4f
db "orders!", $58
; 0x80f7b
-BattleText_0x80f7b: ; 0x80f7b
+IgnoredSleepingText: ; 0x80f7b
text_from_ram $c621
db $0, " ignored", $4f
db "orders…sleeping!", $58
; 0x80f99
-BattleText_0x80f99: ; 0x80f99
+NoPPLeftText: ; 0x80f99
db $0, "But no PP is left", $4f
db "for the move!", $58
; 0x80fba
-BattleText_0x80fba: ; 0x80fba
+HasNoPPLeftText: ; 0x80fba
db $0, $5a, $4f
db "has no PP left for", $55
db "@"
@@ -8179,172 +10883,172 @@ BattleText_0x80fba: ; 0x80fba
db $0, "!", $58
; 0x80fd7
-BattleText_0x80fd7: ; 0x80fd7
+WentToSleepText: ; 0x80fd7
db $0, $5a, $4f
db "went to sleep!", $57
; 0x80fe9
-BattleText_0x80fe9: ; 0x80fe9
+RestedText: ; 0x80fe9
db $0, $5a, $4f
db "fell asleep and", $55
db "became healthy!", $57
; 0x8100c
-BattleText_0x8100c: ; 0x8100c
+RegainedHealthText: ; 0x8100c
db $0, $5a, $4f
db "regained health!", $58
; 0x81020
-BattleText_0x81020: ; 0x81020
+AttackMissedText: ; 0x81020
db $0, $5a, "'s", $4f
db "attack missed!", $58
; 0x81033
-BattleText_0x81033: ; 0x81033
+AttackMissed2Text: ; 0x81033
db $0, $5a, "'s", $4f
db "attack missed!", $58
; 0x81046
-BattleText_0x81046: ; 0x81046
+CrashedText: ; 0x81046
db $0, $5a, $4f
db "kept going and", $55
db "crashed!", $58
; 0x81061
-BattleText_0x81061: ; 0x81061
+UnaffectedText: ; 0x81061
db $0, $59, "'s", $4f
db "unaffected!", $58
; 0x81071
-BattleText_0x81071: ; 0x81071
+DoesntAffectText: ; 0x81071
db $0, "It doesn't affect", $4f
db $59, "!", $58
; 0x81086
-BattleText_0x81086: ; 0x81086
+CriticalHitText: ; 0x81086
db $0, "A critical hit!", $58
; 0x81097
-BattleText_0x81097: ; 0x81097
+OneHitKOText: ; 0x81097
db $0, "It's a one-hit KO!", $58
; 0x810aa
-BattleText_0x810aa: ; 0x810aa
+SuperEffectiveText: ; 0x810aa
db $0, "It's super-", $4f
db "effective!", $58
; 0x810c1
-BattleText_0x810c1: ; 0x810c1
+NotVeryEffectiveText: ; 0x810c1
db $0, "It's not very", $4f
db "effective…", $58
; 0x810da
-BattleText_0x810da: ; 0x810da
+TookDownWithItText: ; 0x810da
db $0, $59, $4f
db "took down with it,", $55
db $5a, "!", $58
; 0x810f3
-BattleText_0x810f3: ; 0x810f3
+RageBuildingText: ; 0x810f3
db $0, $5a, "'s", $4f
db "RAGE is building!", $58
; 0x81109
-BattleText_0x81109: ; 0x81109
+GotAnEncoreText: ; 0x81109
db $0, $59, $4f
db "got an ENCORE!", $58
; 0x8111b
-BattleText_0x8111b: ; 0x8111b
+SharedPainText: ; 0x8111b
db $0, "The battlers", $4f
db "shared pain!", $58
; 0x81136
-BattleText_0x81136: ; 0x81136
+TookAimText: ; 0x81136
db $0, $5a, $4f
db "took aim!", $58
; 0x81143
-BattleText_0x81143: ; 0x81143
+SketchedText: ; 0x81143
db $0, $5a, $4f
db "SKETCHED", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x81156
-BattleText_0x81156: ; 0x81156
+DestinyBondEffectText: ; 0x81156
db $0, $5a, "'s", $4f
db "trying to take its", $55
db "opponent with it!", $58
; 0x8117f
-BattleText_0x8117f: ; 0x8117f
+SpiteEffectText: ; 0x8117f
db $0, $59, "'s", $4f
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " was", $55
db "reduced by @"
deciram $d265, $11
db $0, "!", $58
; 0x811a0
-BattleText_0x811a0: ; 0x811a0
+BellChimedText: ; 0x811a0
db $0, "A bell chimed!", $4f
db $58
; 0x811b1
-BattleText_0x811b1: ; 0x811b1
+FellAsleepText: ; 0x811b1
db $0, $59, $4f
db "fell asleep!", $58
; 0x811c1
-BattleText_0x811c1: ; 0x811c1
+AlreadyAsleepText: ; 0x811c1
db $0, $59, "'s", $4f
db "already asleep!", $58
; 0x811d5
-BattleText_0x811d5: ; 0x811d5
+WasPoisonedText: ; 0x811d5
db $0, $59, $4f
db "was poisoned!", $58
; 0x811e6
-BattleText_0x811e6: ; 0x811e6
+BadlyPoisonedText: ; 0x811e6
db $0, $59, "'s", $4f
db "badly poisoned!", $58
; 0x811fa
-BattleText_0x811fa: ; 0x811fa
+AlreadyPoisonedText: ; 0x811fa
db $0, $59, "'s", $4f
db "already poisoned!", $58
; 0x81210
-BattleText_0x81210: ; 0x81210
+SuckedHealthText: ; 0x81210
db $0, "Sucked health from", $4f
db $59, "!", $58
; 0x81227
-BattleText_0x81227: ; 0x81227
+DreamEatenText: ; 0x81227
db $0, $59, "'s", $4f
db "dream was eaten!", $58
; 0x8123c
-BattleText_0x8123c: ; 0x8123c
+WasBurnedText: ; 0x8123c
db $0, $59, $4f
db "was burned!", $58
; 0x8124b
-BattleText_0x8124b: ; 0x8124b
+DefrostedOpponentText: ; 0x8124b
db $0, $59, $4f
db "was defrosted!", $58
; 0x8125d
-BattleText_0x8125d: ; 0x8125d
+WasFrozenText: ; 0x8125d
db $0, $59, $4f
db "was frozen solid!", $58
; 0x81272
-BattleText_0x81272: ; 0x81272
+WontRiseAnymoreText: ; 0x81272
db $0, $5a, "'s", $4f
db "@"
text_from_ram $d086
@@ -8352,7 +11056,7 @@ BattleText_0x81272: ; 0x81272
db "rise anymore!", $58
; 0x8128f
-BattleText_0x8128f: ; 0x8128f
+WontDropAnymoreText: ; 0x8128f
db $0, $59, "'s", $4f
db "@"
text_from_ram $d086
@@ -8360,349 +11064,349 @@ BattleText_0x8128f: ; 0x8128f
db "drop anymore!", $58
; 0x812ac
-BattleText_0x812ac: ; 0x812ac
+FledFromBattleText: ; 0x812ac
db $0, $5a, $4f
db "fled from battle!", $58
; 0x812c1
-BattleText_0x812c1: ; 0x812c1
+FledInFearText: ; 0x812c1
db $0, $59, $4f
db "fled in fear!", $58
; 0x812d2
-BattleText_0x812d2: ; 0x812d2
+BlownAwayText: ; 0x812d2
db $0, $59, $4f
db "was blown away!", $58
; 0x812e5
-BattleText_0x812e5: ; 0x812e5
+PlayerHitTimesText: ; 0x812e5
db $0, "Hit @"
deciram $c682, $11
db $0, " times!", $58
; 0x812f8
-BattleText_0x812f8: ; 0x812f8
+EnemyHitTimesText: ; 0x812f8
db $0, "Hit @"
deciram $c684, $11
db $0, " times!", $58
; 0x8130b
-BattleText_0x8130b: ; 0x8130b
+MistText: ; 0x8130b
db $0, $5a, "'s", $4f
db "shrouded in MIST!", $58
; 0x81321
-BattleText_0x81321: ; 0x81321
+ProtectedByMistText: ; 0x81321
db $0, $59, "'s", $4f
db "protected by MIST.", $58
; 0x81338
-BattleText_0x81338: ; 0x81338
+GettingPumpedText: ; 0x81338
interpret_data
db $0, $5a, "'s", $4f
db "getting pumped!", $58
; 0x8134d
-BattleText_0x8134d: ; 0x8134d
+RecoilText: ; 0x8134d
db $0, $5a, "'s", $4f
db "hit with recoil!", $58
; 0x81362
-BattleText_0x81362: ; 0x81362
+MadeSubstituteText: ; 0x81362
db $0, $5a, $4f
db "made a SUBSTITUTE!", $58
; 0x81378
-BattleText_0x81378: ; 0x81378
+HasSubstituteText: ; 0x81378
db $0, $5a, $4f
db "has a SUBSTITUTE!", $58
; 0x8138d
-BattleText_0x8138d: ; 0x8138d
+TooWeakSubText: ; 0x8138d
db $0, "Too weak to make", $4f
db "a SUBSTITUTE!", $58
; 0x813ad
-BattleText_0x813ad: ; 0x813ad
+SubTookDamageText: ; 0x813ad
db $0, "The SUBSTITUTE", $4f
db "took damage for", $55
db $59, "!", $58
; 0x813d0
-BattleText_0x813d0: ; 0x813d0
+SubFadedText: ; 0x813d0
db $0, $59, "'s", $4f
db "SUBSTITUTE faded!", $58
; 0x813e6
-BattleText_0x813e6: ; 0x813e6
+LearnedMoveText: ; 0x813e6
db $0, $5a, $4f
db "learned", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x813f8
-BattleText_0x813f8: ; 0x813f8
+WasSeededText: ; 0x813f8
db $0, $59, $4f
db "was seeded!", $58
; 0x81407
-BattleText_0x81407: ; 0x81407
+EvadedText: ; 0x81407
db $0, $59, $4f
db "evaded the attack!", $58
; 0x8141d
-BattleText_0x8141d: ; 0x8141d
+WasDisabledText: ; 0x8141d
db $0, $59, "'s", $4f
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, " was", $55
db "DISABLED!", $58
; 0x81435
-BattleText_0x81435: ; 0x81435
+CoinsScatteredText: ; 0x81435
db $0, "Coins scattered", $4f
db "everywhere!", $58
; 0x81452
-BattleText_0x81452: ; 0x81452
+TransformedTypeText: ; 0x81452
db $0, $5a, $4f
db "transformed into", $55
db "the @"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "-type!", $58
; 0x81476
-BattleText_0x81476: ; 0x81476
+EliminatedStatsText: ; 0x81476
db $0, "All stat changes", $4f
db "were eliminated!", $58
; 0x81499
-BattleText_0x81499: ; 0x81499
+TransformedText: ; 0x81499
db $0, $5a, $4f
db "TRANSFORMED into", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x814b4
-BattleText_0x814b4: ; 0x814b4
+LightScreenEffectText: ; 0x814b4
db $0, $5a, "'s", $4f
db "SPCL.DEF rose!", $58
; 0x814c7
-BattleText_0x814c7: ; 0x814c7
+ReflectEffectText: ; 0x814c7
db $0, $5a, "'s", $4f
db "DEFENSE rose!", $58
; 0x814d9
-BattleText_0x814d9: ; 0x814d9
+NothingHappenedText: ; 0x814d9
db $0, "But nothing", $4f
db "happened.", $58
; 0x814f0
-BattleText_0x814f0: ; 0x814f0
+ButItFailedText: ; 0x814f0
db $0, "But it failed!", $58
; 0x81500
-BattleText_0x81500: ; 0x81500
+ItFailedText: ; 0x81500
db $0, "It failed!", $58
; 0x8150c
-BattleText_0x8150c: ; 0x8150c
+DidntAffect1Text: ; 0x8150c
db $0, "It didn't affect", $4f
db $59, "!", $58
; 0x81520
-BattleText_0x81520: ; 0x81520
+DidntAffect2Text: ; 0x81520
db $0, "It didn't affect", $4f
db $59, "!", $58
; 0x81534
-BattleText_0x81534: ; 0x81534
+HPIsFullText: ; 0x81534
db $0, $5a, "'s", $4f
db "HP is full!", $58
; 0x81544
-BattleText_0x81544: ; 0x81544
+DraggedOutText: ; 0x81544
db $0, $5a, $4f
db "was dragged out!", $58
; 0x81558
-BattleText_0x81558: ; 0x81558
+ParalyzedText: ; 0x81558
db $0, $59, "'s", $4f
db "paralyzed! Maybe", $55
db "it can't attack!", $58
; 0x8157d
-BattleText_0x8157d: ; 0x8157d
+FullyParalyzedText: ; 0x8157d
db $0, $5a, "'s", $4f
db "fully paralyzed!", $58
; 0x81592
-BattleText_0x81592: ; 0x81592
+AlreadyParalyzedText: ; 0x81592
db $0, $59, "'s", $4f
db "already paralyzed!", $58
; 0x815a9
-BattleText_0x815a9: ; 0x815a9
+ProtectedByText: ; 0x815a9
db $0, $59, "'s", $4f
db "protected by", $55
db "@"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, "!", $58
; 0x815c1
-BattleText_0x815c1: ; 0x815c1
+MirrorMoveFailedText: ; 0x815c1
db $0, "The MIRROR MOVE", $4e, "failed!", $58
; 0x815da
-BattleText_0x815da: ; 0x815da
+StoleText: ; 0x815da
db $0, $5a, $4f
db "stole @"
- text_from_ram $d073
+ text_from_ram StringBuffer1
db $0, $55
db "from its foe!", $58
; 0x815f7
-BattleText_0x815f7: ; 0x815f7
+CantEscapeNowText: ; 0x815f7
db $0, $59, $4f
db "can't escape now!", $58
; 0x8160b
-BattleText_0x8160b: ; 0x8160b
+StartedNightmareText: ; 0x8160b
db $0, $59, $4f
db "started to have a", $55
db "NIGHTMARE!", $58
; 0x8162b
-BattleText_0x8162b: ; 0x8162b
+WasDefrostedText: ; 0x8162b
db $0, $5a, $4f
db "was defrosted!", $58
; 0x8163d
-BattleText_0x8163d: ; 0x8163d
+PutACurseText: ; 0x8163d
db $0, $5a, $4f
db "cut its own HP and", $51
db "put a CURSE on", $4f
db $59, "!", $58
; 0x81665
-BattleText_0x81665: ; 0x81665
+ProtectedItselfText: ; 0x81665
db $0, $5a, $4f
db "PROTECTED itself!", $58
; 0x8167a
-BattleText_0x8167a: ; 0x8167a
+ProtectingItselfText: ; 0x8167a
db $0, $59, "'s", $4f
db "PROTECTING itself!", $57
; 0x81691
-BattleText_0x81691: ; 0x81691
+SpikesText: ; 0x81691
db $0, "SPIKES scattered", $4f
db "all around", $55
db $59, "!", $58
; 0x816b1
-BattleText_0x816b1: ; 0x816b1
+IdentifiedText: ; 0x816b1
db $0, $5a, $4f
db "identified", $55
db $59, "!", $58
; 0x816c2
-BattleText_0x816c2: ; 0x816c2
+StartPerishText: ; 0x816c2
db $0, "Both #MON will", $4f
db "faint in 3 turns!", $58
; 0x816e4
-BattleText_0x816e4: ; 0x816e4
+SandstormBrewedText: ; 0x816e4
db $0, "A SANDSTORM", $4f
db "brewed!", $58
; 0x816f9
-BattleText_0x816f9: ; 0x816f9
+BracedItselfText: ; 0x816f9
db $0, $5a, $4f
db "braced itself!", $58
; 0x8170b
-BattleText_0x8170b: ; 0x8170b
+FellInLoveText: ; 0x8170b
db $0, $59, $4f
db "fell in love!", $58
; 0x8171c
-BattleText_0x8171c: ; 0x8171c
+CoveredByVeilText: ; 0x8171c
db $0, $5a, "'s", $4f
db "covered by a veil!", $58
; 0x81733
-BattleText_0x81733: ; 0x81733
+SafeguardProtectText: ; 0x81733
db $0, $59, $4f
db "is protected by", $55
db "SAFEGUARD!", $58
; 0x81751
-BattleText_0x81751: ; 0x81751
+MagnitudeText: ; 0x81751
db $0, "Magnitude @"
deciram $d265, $11
db $0, "!", $58
; 0x81764
-BattleText_0x81764: ; 0x81764
+ReleasedByText: ; 0x81764
db $0, $5a, $4f
db "was released by", $55
db $59, "!", $58
; 0x8177a
-BattleText_0x8177a: ; 0x8177a
+ShedLeechSeedText: ; 0x8177a
db $0, $5a, $4f
db "shed LEECH SEED!", $58
; 0x8178e
-BattleText_0x8178e: ; 0x8178e
+BlewSpikesText: ; 0x8178e
db $0, $5a, $4f
db "blew away SPIKES!", $58
; 0x817a3
-BattleText_0x817a3: ; 0x817a3
+DownpourText: ; 0x817a3
db $0, "A downpour", $4f
db "started!", $58
; 0x817b8
-BattleText_0x817b8: ; 0x817b8
+SunGotBrightText: ; 0x817b8
db $0, "The sunlight got", $4f
db "bright!", $58
; 0x817d2
-BattleText_0x817d2: ; 0x817d2
+BellyDrumText: ; 0x817d2
db $0, $5a, $4f
db "cut its HP and", $55
db "maximized ATTACK!", $58
; 0x817f6
-BattleText_0x817f6: ; 0x817f6
+CopiedStatsText: ; 0x817f6
db $0, $5a, $4f
db "copied the stat", $51
db "changes of", $4f
db $59, "!", $58
; 0x81817
-BattleText_0x81817: ; 0x81817
+ForesawAttackText: ; 0x81817
db $0, $5a, $4f
db "foresaw an attack!", $58
; 0x8182d
-BattleText_0x8182d: ; 0x8182d
- text_from_ram $d073
+BeatUpAttackText: ; 0x8182d
+ text_from_ram StringBuffer1
db $0, "'s", $4f
db "attack!", $57
; 0x8183b
-BattleText_0x8183b: ; 0x8183b
+RefusedGiftText: ; 0x8183b
db $0, $59, $4f
db "refused the gift!", $58
; 0x81850
-BattleText_0x81850: ; 0x81850
+IgnoredOrders2Text: ; 0x81850
db $0, $5a, $4f
db "ignored orders!", $58
; 0x81863
@@ -8718,12 +11422,12 @@ BattleText_0x8188e: ; 0x8188e
db "left today!", $57
; 0x818ac
-INCBIN "baserom.gbc",$818ac,$81fe3-$818ac
+INCBIN "baserom.gbc", $818ac, $81fe3-$818ac
DebugColorTestGFX:
INCBIN "gfx/debug/color_test.2bpp"
-INCBIN "baserom.gbc",$82153,$823c8-$82153
+INCBIN "baserom.gbc", $82153, $823c8-$82153
SECTION "bank21",DATA,BANK[$21]
@@ -8981,7 +11685,7 @@ HallOfFame3: ; 0x8640e
ld a, $5
ld hl, $4da0
- rst $8
+ rst FarCall
ld hl, $d95e
ld a, [hl]
cp $c8
@@ -8990,11 +11694,11 @@ HallOfFame3: ; 0x8640e
.asm_86436
ld a, $5
ld hl, $4b85
- rst $8
+ rst FarCall
call $653f
ld a, $5
ld hl, $4b5f
- rst $8
+ rst FarCall
xor a
ld [$c2cd], a
call $64c3
@@ -9002,7 +11706,7 @@ HallOfFame3: ; 0x8640e
ld b, a
ld a, $42
ld hl, $5847
- rst $8
+ rst FarCall
ret
; 0x86455
@@ -9010,7 +11714,7 @@ INCBIN "baserom.gbc", $86455, $88000 - $86455
SECTION "bank22",DATA,BANK[$22]
-INCBIN "baserom.gbc",$88000,$8832c - $88000
+INCBIN "baserom.gbc", $88000, $8832c - $88000
GetPlayerIcon: ; 8832c
; Get the player icon corresponding to gender
@@ -9031,7 +11735,7 @@ GetPlayerIcon: ; 8832c
ret
; 8833e
-INCBIN "baserom.gbc",$8833e,$896ff - $8833e
+INCBIN "baserom.gbc", $8833e, $896ff - $8833e
ClearScreenArea: ; 0x896ff
; clears an area of the screen
@@ -9068,7 +11772,7 @@ ClearScreenArea: ; 0x896ff
ret
; 0x8971f
-INCBIN "baserom.gbc",$8971f,$8addb - $8971f
+INCBIN "baserom.gbc", $8971f, $8addb - $8971f
SpecialHoOhChamber: ; 0x8addb
ld hl, PartySpecies
@@ -9083,7 +11787,7 @@ SpecialHoOhChamber: ; 0x8addb
ret
; 0x8adef
-INCBIN "baserom.gbc",$8adef,$8b170 - $8adef
+INCBIN "baserom.gbc", $8adef, $8b170 - $8adef
SpecialDratini: ; 0x8b170
; if ScriptVar is 0 or 1, change the moveset of the last Dratini in the party.
@@ -9138,8 +11842,8 @@ SpecialDratini: ; 0x8b170
; get the PP of the new move
dec a
- ld hl, Moves + 5
- ld bc, Move1 - Move0
+ ld hl, Moves + PlayerMovePP - PlayerMoveStruct
+ ld bc, Move2 - Move1
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
@@ -9196,12 +11900,12 @@ GetNthPartyMon: ; 0x8b1ce
scf
ret
-INCBIN "baserom.gbc",$8b1e1,$8ba24-$8b1e1
+INCBIN "baserom.gbc", $8b1e1, $8ba24-$8b1e1
SECTION "bank23",DATA,BANK[$23]
-INCBIN "baserom.gbc",$8c000,$8c011 - $8c000
+INCBIN "baserom.gbc", $8c000, $8c011 - $8c000
TimeOfDayPals: ; 8c011
; return carry if pals are changed
@@ -9311,7 +12015,7 @@ UpdateTimePals: ; 8c070
ret
; 8c079
-INCBIN "baserom.gbc",$8c079,$8c117 - $8c079
+INCBIN "baserom.gbc", $8c079, $8c117 - $8c079
GetTimePalette: ; 8c117
; get time of day
@@ -9380,11 +12084,11 @@ DmgToCgbTimePals: ; 8c14e
ret
; 8c15e
-INCBIN "baserom.gbc",$8c15e,$8c17c - $8c15e
+INCBIN "baserom.gbc", $8c15e, $8c17c - $8c15e
GetTimePalFade: ; 8c17c
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
@@ -9575,7 +12279,7 @@ GetTimePalFade: ; 8c17c
db %00000000
; 8c20f
-INCBIN "baserom.gbc",$8c20f,$8e9ac - $8c20f
+INCBIN "baserom.gbc", $8c20f, $8e9ac - $8c20f
GetSpeciesIcon: ; 8e9ac
; Load species icon into VRAM at tile a
@@ -9589,7 +12293,7 @@ GetSpeciesIcon: ; 8e9ac
ret
; 8e9bc
-INCBIN "baserom.gbc",$8e9bc,$8e9de - $8e9bc
+INCBIN "baserom.gbc", $8e9bc, $8e9de - $8e9bc
GetIconGFX: ; 8e9de
call GetIcon_a
@@ -9659,7 +12363,7 @@ GetGFXUnlessMobile: ; 8ea3f
jp $dc9
; 8ea4a
-INCBIN "baserom.gbc",$8ea4a,$8eab3 - $8ea4a
+INCBIN "baserom.gbc", $8ea4a, $8eab3 - $8ea4a
ReadMonMenuIcon: ; 8eab3
cp EGG
@@ -10013,7 +12717,7 @@ BigmonIcon: INCBIN "gfx/icon/bigmon.2bpp" ; 0x8fe8d
SECTION "bank24",DATA,BANK[$24]
-INCBIN "baserom.gbc",$90000,$909F2-$90000
+INCBIN "baserom.gbc", $90000, $909F2-$90000
dw Sunday
dw Monday
@@ -10294,18 +12998,18 @@ TownMapBGUpdate: ; 91ee4
; BG Map address
ld a, l
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, h
ld [$ffd7], a
; Only update palettes on CGB
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr z, .tiles
; BG Map mode 2 (palettes)
ld a, 2
- ld [$ffd4], a
+ ld [hBGMapMode], a
; The BG Map is updated in thirds, so we wait
; 3 frames to update the whole screen's palettes.
@@ -10318,7 +13022,7 @@ TownMapBGUpdate: ; 91ee4
; Turn off BG Map update
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ret
; 91eff
@@ -10494,7 +13198,14 @@ INCBIN "baserom.gbc", $91fff, $92168 - $91fff
KantoMap:
INCBIN "baserom.gbc", $92168, $922d1 - $92168
-INCBIN "baserom.gbc", $922d1, $93a31 - $922d1
+
+INCBIN "baserom.gbc", $922d1, $92402 - $922d1
+
+
+INCLUDE "stats/wild/fish.asm"
+
+
+INCBIN "baserom.gbc", $926c7, $93a31 - $926c7
SECTION "bank25",DATA,BANK[$25]
@@ -10533,11 +13244,11 @@ INCLUDE "maps/map_headers.asm"
INCLUDE "maps/second_map_headers.asm"
-INCBIN "baserom.gbc",$966b0,$96cb1 - $966b0
+INCBIN "baserom.gbc", $966b0, $96cb1 - $966b0
INCLUDE "scripting.asm"
-INCBIN "baserom.gbc",$97c20,$35e
+INCBIN "baserom.gbc", $97c20, $35e
SECTION "bank26",DATA,BANK[$26]
@@ -10595,12 +13306,12 @@ INCLUDE "maps/BattleTowerOutside.asm"
SECTION "bank28",DATA,BANK[$28]
-INCBIN "baserom.gbc",$a0000,$a1eca - $a0000
+INCBIN "baserom.gbc", $a0000, $a1eca - $a0000
SECTION "bank29",DATA,BANK[$29]
-INCBIN "baserom.gbc",$a4000,$a64ad - $a4000
+INCBIN "baserom.gbc", $a4000, $a64ad - $a4000
SECTION "bank2A",DATA,BANK[$2A]
@@ -10625,7 +13336,9 @@ Route28_BlockData: ; 0xa8492
INCBIN "maps/Route28.blk"
; 0xa8546
-INCBIN "baserom.gbc",$a8546,$a8552 - $a8546
+BetaHerosHouse_BlockData: ; 0xa8546
+ INCBIN "maps/BetaHerosHouse.blk"
+; 0xa8552
CeladonCity_BlockData: ; 0xa8552
INCBIN "maps/CeladonCity.blk"
@@ -10643,25 +13356,33 @@ ElmsHouse_BlockData: ; 0xa8930
INCBIN "maps/ElmsHouse.blk"
; 0xa8940
-INCBIN "baserom.gbc",$a8940,$5a
+BetaSproutTower1_BlockData: ; 0xa8940
+ INCBIN "maps/BetaSproutTower1.blk"
+; 0xa899a
Route11_BlockData: ; 0xa899a
INCBIN "maps/Route11.blk"
; 0xa8a4e
-INCBIN "baserom.gbc",$a8a4e,$a8aa8 - $a8a4e
+BetaSproutTower5_BlockData: ; 0xa8a4e
+ INCBIN "maps/BetaSproutTower5.blk"
+; 0xa8aa8
Route15_BlockData: ; 0xa8aa8
INCBIN "maps/Route15.blk"
; 0xa8b5c
-INCBIN "baserom.gbc",$a8b5c,$24
+BetaSproutTower9_BlockData: ; 0xa8b5c
+ INCBIN "maps/BetaSproutTower9.blk"
+; 0xa8b80
Route19_BlockData: ; 0xa8b80
INCBIN "maps/Route19.blk"
; 0xa8c34
-INCBIN "baserom.gbc",$a8c34,$a8d9c - $a8c34
+BetaBlackthornCity_BlockData: ; 0xa8c34
+ INCBIN "maps/BetaBlackthornCity.blk"
+; 0xa8d9c
Route10South_BlockData: ; 0xa8d9c
INCBIN "maps/Route10South.blk"
@@ -10707,7 +13428,9 @@ Route24_BlockData: ; 0xa95ff
INCBIN "maps/Route24.blk"
; 0xa9659
-INCBIN "baserom.gbc",$a9659,$a97c1 - $a9659
+BetaVioletCity_BlockData: ; 0xa9659
+ INCBIN "maps/BetaVioletCity.blk"
+; 0xa97c1
Route3_BlockData: ; 0xa97c1
INCBIN "maps/Route3.blk"
@@ -10717,19 +13440,33 @@ PewterCity_BlockData: ; 0xa98cf
INCBIN "maps/PewterCity.blk"
; 0xa9a37
-INCBIN "baserom.gbc",$a9a37,$a9bf9 - $a9a37
+BetaIlexForest_BlockData: ; 0xa9a37
+ INCBIN "maps/BetaIlexForest.blk"
+; 0xa9b9f
+
+BetaSproutTower2_BlockData: ; 0xa9b9f
+ INCBIN "maps/BetaSproutTower2.blk"
+; 0xa9bf9
Route12_BlockData: ; 0xa9bf9
INCBIN "maps/Route12.blk"
; 0xa9d07
-INCBIN "baserom.gbc",$a9d07,$168
+BetaGoldenrodCity_BlockData: ; 0xa9d07
+ INCBIN "maps/BetaGoldenrodCity.blk"
+; 0xa9e6f
Route20_BlockData: ; 0xa9e6f
INCBIN "maps/Route20.blk"
; 0xa9f7d
-INCBIN "baserom.gbc",$a9f7d,$a9ff7 - $a9f7d
+BetaSproutTower6_BlockData: ; 0xa9f7d
+ INCBIN "maps/BetaSproutTower6.blk"
+; 0xa9fd7
+
+BetaPokecenterMainHouse_BlockData: ; 0xa9fd7
+ INCBIN "maps/BetaPokecenterMainHouse.blk"
+; 0xa9ff7
Route30_BlockData: ; 0xa9ff7
INCBIN "maps/Route30.blk"
@@ -10759,7 +13496,9 @@ Route38_BlockData: ; 0xaa759
INCBIN "maps/Route38.blk"
; 0xaa80d
-INCBIN "baserom.gbc",$aa80d,$5a
+BetaCianwoodCity_BlockData: ; 0xaa80d
+ INCBIN "maps/BetaCianwoodCity.blk"
+; 0xaa867
OlivineVoltorbHouse_BlockData: ; 0xaa867
INCBIN "maps/OlivineVoltorbHouse.blk"
@@ -10769,7 +13508,13 @@ SafariZoneFuchsiaGateBeta_BlockData: ; 0xaa877
INCBIN "maps/SafariZoneFuchsiaGateBeta.blk"
; 0xaa88b
-INCBIN "baserom.gbc",$aa88b,$aaa4d - $aa88b
+BetaTeakCity_BlockData: ; 0xaa88b
+ INCBIN "maps/BetaTeakCity.blk"
+; 0xaa9f3
+
+BetaCherrygroveCity_BlockData: ; 0xaa9f3
+ INCBIN "maps/BetaCherrygroveCity.blk"
+; 0xaaa4d
CinnabarIsland_BlockData: ; 0xaaa4d
INCBIN "maps/CinnabarIsland.blk"
@@ -10783,7 +13528,9 @@ Route8_BlockData: ; 0xaab5b
INCBIN "maps/Route8.blk"
; 0xaac0f
-INCBIN "baserom.gbc",$aac0f,$aac69 - $aac0f
+BetaSproutTower3_BlockData: ; 0xaac0f
+ INCBIN "maps/BetaSproutTower3.blk"
+; 0xaac69
ViridianCity_BlockData: ; 0xaac69
INCBIN "maps/ViridianCity.blk"
@@ -10797,13 +13544,17 @@ Route21_BlockData: ; 0xaaedf
INCBIN "maps/Route21.blk"
; 0xaaf93
-INCBIN "baserom.gbc",$aaf93,$aafed - $aaf93
+BetaSproutTower7_BlockData: ; 0xaaf93
+ INCBIN "maps/BetaSproutTower7.blk"
+; 0xaafed
Route17_BlockData: ; 0xaafed
INCBIN "maps/Route17.blk"
; 0xab1af
-INCBIN "baserom.gbc",$ab1af,$ab209 - $ab1af
+BetaMahoganyTown_BlockData: ; 0xab1af
+ INCBIN "maps/BetaMahoganyTown.blk"
+; 0xab209
Route31_BlockData: ; 0xab209
INCBIN "maps/Route31.blk"
@@ -10833,13 +13584,21 @@ Route38EcruteakGate_BlockData: ; 0xab6af
INCBIN "maps/Route38EcruteakGate.blk"
; 0xab6c3
-INCBIN "baserom.gbc",$ab6c3,$ab82b - $ab6c3
+BetaAzaleaTown_BlockData: ; 0xab6c3
+ INCBIN "maps/BetaAzaleaTown.blk"
+; 0xab82b
VermilionCity_BlockData: ; 0xab82b
INCBIN "maps/VermilionCity.blk"
; 0xab993
-INCBIN "baserom.gbc",$ab993,$abb55 - $ab993
+BetaOlivineCity_BlockData: ; 0xab993
+ INCBIN "maps/BetaOlivineCity.blk"
+; 0xabafb
+
+BetaNewBarkTown_BlockData: ; 0xabafb
+ INCBIN "maps/BetaNewBarkTown.blk"
+; 0xabb55
ElmsLab_BlockData: ; 0xabb55
INCBIN "maps/ElmsLab.blk"
@@ -10872,7 +13631,9 @@ Route14_BlockData: ; 0xac000
INCBIN "maps/Route14.blk"
; 0xac0b4
-INCBIN "baserom.gbc",$ac0b4,$5a
+BetaSproutTower8_BlockData: ; 0xac0b4
+ INCBIN "maps/BetaSproutTower8.blk"
+; 0xac10e
OlivineMart_BlockData: ; 0xac10e
INCBIN "maps/OlivineMart.blk"
@@ -10882,19 +13643,41 @@ Route10North_BlockData: ; 0xac126
INCBIN "maps/Route10North.blk"
; 0xac180
-INCBIN "baserom.gbc",$ac180,$168
+BetaLakeOfRage_BlockData: ; 0xac180
+ INCBIN "maps/BetaLakeOfRage.blk"
+; 0xac2e8
OlivinePokeCenter1F_BlockData: ; 0xac2e8
INCBIN "maps/OlivinePokeCenter1F.blk"
; 0xac2fc
-INCBIN "baserom.gbc",$ac2fc,$ac340 - $ac2fc
+BetaPewterMuseumOfScience1F_BlockData: ; 0xac2fc
+ INCBIN "maps/BetaPewterMuseumOfScience1F.blk"
+; 0xac324
+
+BetaPewterMuseumOfScience2F_BlockData: ; 0xac324
+ INCBIN "maps/BetaPewterMuseumOfScience2F.blk"
+; 0xac340
EarlsPokemonAcademy_BlockData: ; 0xac340
INCBIN "maps/EarlsPokemonAcademy.blk"
; 0xac360
-INCBIN "baserom.gbc",$ac360,$ac3b4 - $ac360
+BetaCinnabarIslandPokemonLabHallway_BlockData: ; 0xac360
+ INCBIN "maps/BetaCinnabarIslandPokemonLabHallway.blk"
+; 0xac384
+
+BetaCinnabarIslandPokemonLabRoom1_BlockData: ; 0xac384
+ INCBIN "maps/BetaCinnabarIslandPokemonLabRoom1.blk"
+; 0xac394
+
+BetaCinnabarIslandPokemonLabRoom2_BlockData: ; 0xac394
+ INCBIN "maps/BetaCinnabarIslandPokemonLabRoom2.blk"
+; 0xac3a4
+
+BetaCinnabarIslandPokemonLabRoom3_BlockData: ; 0xac3a4
+ INCBIN "maps/BetaCinnabarIslandPokemonLabRoom3.blk"
+; 0xac3b4
GoldenrodDeptStore1F_BlockData: ; 0xac3b4
INCBIN "maps/GoldenrodDeptStore1F.blk"
@@ -10940,7 +13723,9 @@ CeladonMansionRoof_BlockData: ; 0xac4b4
INCBIN "maps/CeladonMansionRoof.blk"
; 0xac4c8
-INCBIN "baserom.gbc",$ac4c8,$ac4d8 - $ac4c8
+BetaHouse_BlockData: ; 0xac4c8
+ INCBIN "maps/BetaHouse.blk"
+; 0xac4d8
CeladonGameCorner_BlockData: ; 0xac4d8
INCBIN "maps/CeladonGameCorner.blk"
@@ -10962,7 +13747,9 @@ EcruteakLugiaSpeechHouse_BlockData: ; 0xac54f
INCBIN "maps/EcruteakLugiaSpeechHouse.blk"
; 0xac55f
-INCBIN "baserom.gbc",$ac55f,$5a
+BetaCave_BlockData: ; 0xac55f
+ INCBIN "maps/BetaCave.blk"
+; 0xac5b9
UnionCaveB1F_BlockData: ; 0xac5b9
INCBIN "maps/UnionCaveB1F.blk"
@@ -10984,7 +13771,9 @@ Route6UndergroundEntrance_BlockData: ; 0xac9f1
INCBIN "maps/Route6UndergroundEntrance.blk"
; 0xaca01
-INCBIN "baserom.gbc",$aca01,$10
+BetaPokecenterTradeStation_BlockData: ; 0xaca01
+ INCBIN "maps/BetaPokecenterTradeStation.blk"
+; 0xaca11
KurtsHouse_BlockData: ; 0xaca11
INCBIN "maps/KurtsHouse.blk"
@@ -10998,7 +13787,9 @@ RuinsofAlphOutside_BlockData: ; 0xaca8b
INCBIN "maps/RuinsofAlphOutside.blk"
; 0xacb3f
-INCBIN "baserom.gbc",$acb3f,$acb53 - $acb3f
+BetaAlphRuinUnsolvedPuzzleRoom_BlockData: ; 0xacb3f
+ INCBIN "maps/BetaAlphRuinUnsolvedPuzzleRoom.blk"
+; 0xacb53
RuinsofAlphInnerChamber_BlockData: ; 0xacb53
INCBIN "maps/RuinsofAlphInnerChamber.blk"
@@ -11012,19 +13803,25 @@ SproutTower1F_BlockData: ; 0xacbf3
INCBIN "maps/SproutTower1F.blk"
; 0xacc43
-INCBIN "baserom.gbc",$acc43,$acc4d - $acc43
+BetaSproutTowerCutOut1_BlockData: ; 0xacc43
+ INCBIN "maps/BetaSproutTowerCutOut1.blk"
+; 0xacc4d
SproutTower2F_BlockData: ; 0xacc4d
INCBIN "maps/SproutTower2F.blk"
; 0xacc9d
-INCBIN "baserom.gbc",$acc9d,$acca7 - $acc9d
+BetaSproutTowerCutOut2_BlockData: ; 0xacc9d
+ INCBIN "maps/BetaSproutTowerCutOut2.blk"
+; 0xacca7
SproutTower3F_BlockData: ; 0xacca7
INCBIN "maps/SproutTower3F.blk"
; 0xaccf7
-INCBIN "baserom.gbc",$accf7,$acd01 - $accf7
+BetaSproutTowerCutOut3_BlockData: ; 0xaccf7
+ INCBIN "maps/BetaSproutTowerCutOut3.blk"
+; 0xacd01
RadioTower1F_BlockData: ; 0xacd01
INCBIN "maps/RadioTower1F.blk"
@@ -11126,7 +13923,9 @@ UndergroundWarehouse_BlockData: ; 0xadf1c
INCBIN "maps/UndergroundWarehouse.blk"
; 0xadf76
-INCBIN "baserom.gbc",$adf76,$19
+BetaElevator_BlockData: ; 0xadf76
+ INCBIN "maps/BetaElevator.blk"
+; 0xadf8f
TinTower1F_BlockData: ; 0xadf8f
INCBIN "maps/TinTower1F.blk"
@@ -11176,7 +13975,9 @@ BurnedTowerB1F_BlockData: ; 0xae36d
INCBIN "maps/BurnedTowerB1F.blk"
; 0xae3c7
-INCBIN "baserom.gbc",$ae3c7,$ae4d5 - $ae3c7
+BetaCaveTestMap_BlockData: ; 0xae3c7
+ INCBIN "maps/BetaCaveTestMap.blk"
+; 0xae4d5
MountMortar1FOutside_BlockData: ; 0xae4d5
INCBIN "maps/MountMortar1FOutside.blk"
@@ -11258,7 +14059,21 @@ SilverCaveRoom3_BlockData: ; 0xaf399
INCBIN "maps/SilverCaveRoom3.blk"
; 0xaf44d
-INCBIN "baserom.gbc",$af44d,$438
+BetaRocketHideout1_BlockData: ; 0xaf44d
+ INCBIN "maps/BetaRocketHideout1.blk"
+; 0xaf55b
+
+BetaRocketHideout2_BlockData: ; 0xaf55b
+ INCBIN "maps/BetaRocketHideout2.blk"
+; 0xaf669
+
+BetaEmptyHouse_BlockData: ; 0xaf669
+ INCBIN "maps/BetaEmptyHouse.blk"
+; 0xaf777
+
+BetaRocketHideout3_BlockData: ; 0xaf777
+ INCBIN "maps/BetaRocketHideout3.blk"
+; 0xaf885
MahoganyMart1F_BlockData: ; 0xaf885
INCBIN "maps/MahoganyMart1F.blk"
@@ -11276,7 +14091,9 @@ TeamRocketBaseB3F_BlockData: ; 0xaf9a3
INCBIN "maps/TeamRocketBaseB3F.blk"
; 0xafa2a
-INCBIN "baserom.gbc",$afa2a,$afa84 - $afa2a
+BetaRoute23EarlyVersion_BlockData: ; 0xafa2a
+ INCBIN "maps/BetaRoute23EarlyVersion.blk"
+; 0xafa84
IndigoPlateauPokeCenter1F_BlockData: ; 0xafa84
INCBIN "maps/IndigoPlateauPokeCenter1F.blk"
@@ -11322,7 +14139,9 @@ OlivineGym_BlockData: ; 0xafc7b
INCBIN "maps/OlivineGym.blk"
; 0xafca3
-INCBIN "baserom.gbc",$afca3,$afcb7 - $afca3
+BetaUnknown_BlockData: ; 0xafca3
+ INCBIN "maps/BetaUnknown.blk"
+; 0xafcb7
CianwoodGym_BlockData: ; 0xafcb7
INCBIN "maps/CianwoodGym.blk"
@@ -11363,7 +14182,9 @@ OlivineLighthouse6F_BlockData: ; 0xaff00
SECTION "bank2C",DATA,BANK[$2C]
-INCBIN "baserom.gbc",$b0000,$b0023 - $b0000
+BetaCave2_BlockData: ; 0xb0000
+ INCBIN "maps/BetaCave2.blk"
+; 0xb0023
SlowpokeWellB1F_BlockData: ; 0xb0023
INCBIN "maps/SlowpokeWellB1F.blk"
@@ -11421,7 +14242,9 @@ FastShipB1F_BlockData: ; 0xb0680
INCBIN "maps/FastShipB1F.blk"
; 0xb0700
-INCBIN "baserom.gbc",$b0700,$10
+BetaSsAquaInsideCutOut_BlockData: ; 0xb0700
+ INCBIN "maps/BetaSsAquaInsideCutOut.blk"
+; 0xb0710
FastShipCabins_NNW_NNE_NE_BlockData: ; 0xb0710
INCBIN "maps/FastShipCabins_NNW_NNE_NE.blk"
@@ -11535,13 +14358,17 @@ CeladonGym_BlockData: ; 0xb0cb5
INCBIN "maps/CeladonGym.blk"
; 0xb0ce2
-INCBIN "baserom.gbc",$b0ce2,$b0cf6 - $b0ce2
+BetaHouse2_BlockData: ; 0xb0ce2
+ INCBIN "maps/BetaHouse2.blk"
+; 0xb0cf6
CeladonCafe_BlockData: ; 0xb0cf6
INCBIN "maps/CeladonCafe.blk"
; 0xb0d0e
-INCBIN "baserom.gbc",$b0d0e,$18
+BetaCeladonMansion_BlockData: ; 0xb0d0e
+ INCBIN "maps/BetaCeladonMansion.blk"
+; 0xb0d26
RockTunnel1F_BlockData: ; 0xb0d26
INCBIN "maps/RockTunnel1F.blk"
@@ -11695,7 +14522,9 @@ BattleTowerOutside_BlockData: ; 0xb1a6e
INCBIN "maps/BattleTowerOutside.blk"
; 0xb1afa
-INCBIN "baserom.gbc",$b1afa,$28
+BetaBlank_BlockData: ; 0xb1afa
+ INCBIN "maps/BetaBlank.blk"
+; 0xb1b22
GoldenrodDeptStoreRoof_BlockData: ; 0xb1b22
INCBIN "maps/GoldenrodDeptStoreRoof.blk"
@@ -11704,41 +14533,124 @@ GoldenrodDeptStoreRoof_BlockData: ; 0xb1b22
SECTION "bank2D",DATA,BANK[$2D]
-Tileset21GFX: ; b4000
+Tileset21GFX: ; 0xb4000
INCBIN "gfx/tilesets/21.lz"
-; b4893
-
-INCBIN "baserom.gbc", $b4893, $b4da0 - $b4893
-
-Tileset22GFX: ; b4da0
+; 0xb4893
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset21Meta: ; 0xb48a0
+INCBIN "tilesets/21_metatiles.bin"
+; 0xb4ca0
+
+Tileset21Coll: ; 0xb4ca0
+INCBIN "tilesets/21_collision.bin"
+; 0xb4da0
+
+Tileset22GFX: ; 0xb4da0
INCBIN "gfx/tilesets/22.lz"
-; b50d1
+; 0xb50d1
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset22Meta: ; 0xb50e0
+INCBIN "tilesets/22_metatiles.bin"
+; 0xb54e0
+
+Tileset22Coll: ; 0xb54e0
+INCBIN "tilesets/22_collision.bin"
+; 0xb55e0
+
+Tileset08GFX: ; 0xb55e0
+INCBIN "gfx/tilesets/08.lz"
+; 0xb59db
-INCBIN "baserom.gbc", $b50d1, $b55e0 - $b50d1
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
-Tileset08GFX: ; b55e0
-INCBIN "gfx/tilesets/08.lz"
-; b59db
+Tileset08Meta: ; 0xb59e0
+INCBIN "tilesets/08_metatiles.bin"
+; 0xb5de0
-INCBIN "baserom.gbc", $b59db, $b5ee0 - $b59db
+Tileset08Coll: ; 0xb5de0
+INCBIN "tilesets/08_collision.bin"
+; 0xb5ee0
-Tileset02GFX:
-Tileset04GFX: ; b5ee0
+Tileset02GFX: ; 0xb5ee0
+Tileset04GFX: ; 0xb5ee0
INCBIN "gfx/tilesets/04.lz"
-; b6ae7
+; 0xb6ae7
-INCBIN "baserom.gbc", $b6ae7, $b74e8 - $b6ae7
+ db $00
-Tileset16GFX: ; b74e8
-INCBIN "gfx/tilesets/16.lz"
-; b799a
+Tileset02Meta: ; 0xb6ae8
+INCBIN "tilesets/02_metatiles.bin"
+; 0xb72e8
-INCBIN "baserom.gbc", $b799a, $b7ea8 - $b799a
+Tileset02Coll: ; 0xb72e8
+INCBIN "tilesets/02_collision.bin"
+; 0xb74e8
+
+Tileset16GFX: ; 0xb74e8
+INCBIN "gfx/tilesets/16.lz"
+; 0xb799a
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset16Meta: ; 0xb79a8
+INCBIN "tilesets/16_metatiles.bin"
+; 0xb7da8
+
+Tileset16Coll: ; 0xb7da8
+INCBIN "tilesets/16_collision.bin"
+; 0xb7ea8
SECTION "bank2E",DATA,BANK[$2E]
-INCBIN "baserom.gbc",$B8000,$b8219 - $b8000
+INCBIN "baserom.gbc", $B8000, $b8219 - $b8000
Functionb8219: ; b8219
; deals strictly with rockmon encounter
@@ -11796,7 +14708,7 @@ GetTreeMonEncounterTable: ; b823f
ret
; b825e
-INCBIN "baserom.gbc",$B825E,$b82c5 - $b825e
+INCBIN "baserom.gbc", $B825E, $b82c5 - $b825e
WildRockMonMapTable: ; b82c5
db GROUP_CIANWOOD_CITY, MAP_CIANWOOD_CITY, $07
@@ -11978,12 +14890,12 @@ WildRockMonTable: ; b83de
db $ff ; end
; b83e5
-INCBIN "baserom.gbc",$b83e5,$b9e8b - $b83e5
+INCBIN "baserom.gbc", $b83e5, $b9e8b - $b83e5
SECTION "bank2F",DATA,BANK[$2F]
-INCBIN "baserom.gbc",$bc000,$bc09c - $bc000
+INCBIN "baserom.gbc", $bc000, $bc09c - $bc000
PokeCenterNurseScript: ; bc09c
; Talking to a nurse in a Pokemon Center
@@ -12116,7 +15028,7 @@ PokeCenterNurseScript: ; bc09c
end
; bc162
-INCBIN "baserom.gbc",$bc162,$bcea5-$bc162
+INCBIN "baserom.gbc", $bc162, $bcea5-$bc162
UnusedPhoneScript: ; 0xbcea5
3writetext BANK(UnusedPhoneText), UnusedPhoneText
@@ -12172,13 +15084,13 @@ UnknownScript_0xbcee7: ; 0xbcee7
.violet ; 0xbcf15
displaylocation $7 ; sprout tower
- 3call $3,$4edf
+ 3call $3, $4edf
.azalea ; 0xbcf1b
displaylocation $d ; slowpoke well
- 3call $3,$4edf
+ 3call $3, $4edf
.goldenrod ; 0xbcf21
displaylocation $11 ; radio tower
- 3call $3,$4edf
+ 3call $3, $4edf
3writetext $6d, $411c
keeptextopen
2jump UnknownScript_0xbcf37
@@ -12407,27 +15319,27 @@ ElmPhoneScript2: ; 0xbd081
specialphonecall $0000
end
-INCBIN "baserom.gbc",$bd0d0,$be699-$bd0d0
+INCBIN "baserom.gbc", $bd0d0, $be699-$bd0d0
SECTION "bank30",DATA,BANK[$30]
-INCBIN "baserom.gbc",$c0000,$c3fc0 - $c0000
+INCBIN "baserom.gbc", $c0000, $c3fc0 - $c0000
SECTION "bank31",DATA,BANK[$31]
-INCBIN "baserom.gbc",$c4000,$c7f80 - $c4000
+INCBIN "baserom.gbc", $c4000, $c7f80 - $c4000
SECTION "bank32",DATA,BANK[$32]
-INCBIN "baserom.gbc",$c8000,$cbe2b - $c8000
+INCBIN "baserom.gbc", $c8000, $cbe2b - $c8000
SECTION "bank33",DATA,BANK[$33]
-INCBIN "baserom.gbc",$cc000, $cfd9e - $cc000
+INCBIN "baserom.gbc", $cc000, $cfd9e - $cc000
; Songs iii
@@ -12505,40 +15417,121 @@ INCLUDE "gfx/pics/unown_frames.asm"
SECTION "bank37",DATA,BANK[$37]
-Tileset31GFX: ; dc000
+Tileset31GFX: ; 0xdc000
INCBIN "gfx/tilesets/31.lz"
-; dc3ce
+; 0xdc3ce
-INCBIN "baserom.gbc", $dc3ce, $dc3d0 - $dc3ce
+ db $00
+ db $00
-Tileset18GFX: ; dc3d0
+Tileset18GFX: ; 0xdc3d0
INCBIN "gfx/tilesets/18.lz"
-; dcc4e
+; 0xdcc4e
-INCBIN "baserom.gbc", $dcc4e, $dd150 - $dcc4e
+ db $00
+ db $00
-Tileset05GFX: ; dd150
-INCBIN "gfx/tilesets/05.lz"
-; dd5f8
+Tileset18Meta: ; 0xdcc50
+INCBIN "tilesets/18_metatiles.bin"
+; 0xdd050
-INCBIN "baserom.gbc", $dd5f8, $ddb00 - $dd5f8
+Tileset18Coll: ; 0xdd050
+INCBIN "tilesets/18_collision.bin"
+; 0xdd150
-Tileset19GFX: ; ddb00
+Tileset05GFX: ; 0xdd150
+INCBIN "gfx/tilesets/05.lz"
+; 0xdd5f8
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset05Meta: ; 0xdd600
+INCBIN "tilesets/05_metatiles.bin"
+; 0xdda00
+
+Tileset05Coll: ; 0xdda00
+INCBIN "tilesets/05_collision.bin"
+; 0xddb00
+
+Tileset19GFX: ; 0xddb00
INCBIN "gfx/tilesets/19.lz"
-; ddf64
+; 0xddf64
+
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+
+Tileset19Meta: ; 0xddf70
+INCBIN "tilesets/19_metatiles.bin"
+; 0xde370
+
+Tileset19Coll: ; 0xde370
+INCBIN "tilesets/19_collision.bin"
+; 0xde470
+
+Tileset31Coll: ; 0xde470
+INCBIN "tilesets/31_collision.bin"
+; 0xde570
+
+Tileset11GFX: ; 0xde570
+INCBIN "gfx/tilesets/11.lz"
+; 0xde98a
-INCBIN "baserom.gbc", $ddf64, $de570 - $ddf64
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
+ db $00
-Tileset11GFX: ; de570
-INCBIN "gfx/tilesets/11.lz"
-; de98a
+Tileset11Meta: ; 0xde990
+INCBIN "tilesets/11_metatiles.bin"
+; 0xded90
+
+Tileset11Coll: ; 0xded90
+INCBIN "tilesets/11_collision.bin"
+; 0xdee90
+
+Tileset04Meta: ; 0xdee90
+INCBIN "tilesets/04_metatiles.bin"
+; 0xdf690
+
+Tileset04Coll: ; 0xdf690
+INCBIN "tilesets/04_collision.bin"
+; 0xdf890
-INCBIN "baserom.gbc", $de98a, $dfd14 - $de98a
+Tileset32Meta: ; 0xdf890
+INCBIN "tilesets/32_metatiles.bin"
+; 0xdfc90
+
+Tileset32Coll: ; 0xdfc90
+Tileset33Coll: ; 0xdfc90
+Tileset34Coll: ; 0xdfc90
+Tileset35Coll: ; 0xdfc90
+Tileset36Coll: ; 0xdfc90
+INCBIN "tilesets/36_collision.bin"
+; 0xdfd90
SECTION "bank38",DATA,BANK[$38]
-INCBIN "baserom.gbc",$e0000,$e37f9 - $e0000
+INCBIN "baserom.gbc", $e0000, $e37f9 - $e0000
SECTION "bank39",DATA,BANK[$39]
@@ -12846,13 +15839,13 @@ Music_BugCatchingContest: INCLUDE "audio/music/bugcatchingcontest.asm"
SECTION "bank3E",DATA,BANK[$3E]
FontExtra:
-INCBIN "gfx/misc/font_extra.2bpp",$0,$200
+INCBIN "gfx/misc/font_extra.2bpp", $0, $200
Font:
-INCBIN "gfx/misc/font.1bpp",$0,$400
+INCBIN "gfx/misc/font.1bpp", $0, $400
FontBattleExtra:
-INCBIN "gfx/misc/font_battle_extra.2bpp",$0,$200
+INCBIN "gfx/misc/font_battle_extra.2bpp", $0, $200
INCBIN "baserom.gbc", $f8800, $f8ba0 - $f8800
@@ -12864,14 +15857,737 @@ INCBIN "baserom.gbc", $f8ea3, $fbbfc - $f8ea3
INCLUDE "battle/magikarp_length.asm"
-INCBIN "baserom.gbc",$fbccf,$fbe91 - $fbccf
+INCBIN "baserom.gbc", $fbccf, $fbda4 - $fbccf
+
+
+DoWeatherModifiers: ; fbda4
+
+ ld de, .WeatherTypeModifiers
+ ld a, [Weather]
+ ld b, a
+ ld a, [$d265] ; 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
+ inc de
+ inc de
+ jr .CheckWeatherType
+
+
+.asm_fbdc0
+ ld de, .WeatherMoveModifiers
+
+ ld a, BATTLE_VARS_MOVE_EFFECT
+ call CleanGetBattleVarPair
+ 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
+ inc de
+ inc de
+ jr .CheckWeatherMove
+
+.ApplyModifier
+ xor a
+ ld [$ffb4], a
+ ld hl, CurDamage
+ ld a, [hli]
+ ld [$ffb5], a
+ ld a, [hl]
+ ld [$ffb6], a
+
+ inc de
+ ld a, [de]
+ ld [$ffb7], a
+
+ call Multiply
+
+ ld a, 10
+ ld [$ffb7], a
+ ld b, $4
+ call Divide
+
+ ld a, [$ffb4]
+ and a
+ ld bc, $ffff
+ jr nz, .Update
+
+ ld a, [$ffb5]
+ ld b, a
+ ld a, [$ffb6]
+ 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, [$cfc0]
+ 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, [$d265] ; 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 [$d257], 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
SECTION "bank3F",DATA,BANK[$3F]
-DoTileAnimation:
+DoTileAnimation: ; fc000
+; Iterate over a given pointer array of animation functions
+; (one per frame).
+; Typically in wra1, vra0
+
+; Beginning of animation pointer array
+ ld a, [TileSetAnim]
+ ld e, a
+ ld a, [TileSetAnim + 1]
+ ld d, a
+
+; Play this frame.
+ ld a, [hTileAnimFrame] ; frame count
+ ld l, a
+ inc a
+ ld [hTileAnimFrame], a
+
+; Each pointer has:
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ add hl, de
+
+; 2-byte parameter (all functions take input de)
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+
+; Function address
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ jp [hl]
+; fc01b
+
+Tileset00Anim: ; 0xfc01b
+Tileset02Anim: ; 0xfc01b
+Tileset03Anim: ; 0xfc01b
+; param, function
+ dw $9140, AnimateWaterTile
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, TileAnimationPalette
+ dw $0000, WaitTileAnimation
+ dw $0000, AnimateFlowerTile
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc047
+
+Tileset25Anim: ; 0xfc047
+; param, function
+ dw $9140, AnimateWaterTile
+ dw $0000, WaitTileAnimation
+ dw $95f0, $4387
+ dw $0000, WaitTileAnimation
+ dw $0000, TileAnimationPalette
+ dw $0000, WaitTileAnimation
+ dw $0000, AnimateFlowerTile
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc073
+
+Tileset31Anim: ; 0xfc073
+; param, function
+ dw $0000, $445c
+ dw $0000, $44c4
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, $44f2
+ dw $0000, $451c
+ dw $0000, AnimateFlowerTile
+ dw $9140, AnimateWaterTile
+ dw $0000, TileAnimationPalette
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc0a3
+
+Tileset01Anim: ; 0xfc0a3
+; param, function
+ dw $9140, AnimateWaterTile
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, TileAnimationPalette
+ dw $0000, WaitTileAnimation
+ dw $0000, AnimateFlowerTile
+ dw $4a98, AnimateWhirlpoolTile
+ dw $4a9c, AnimateWhirlpoolTile
+ dw $4aa0, AnimateWhirlpoolTile
+ dw $4aa4, AnimateWhirlpoolTile
+ dw $0000, WaitTileAnimation
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc0d7
+
+INCBIN "baserom.gbc", $fc0d7, $fc12f-$fc0d7
+
+Tileset09Anim: ; 0xfc12f
+; param, function
+ dw $9140, AnimateWaterTile
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, TileAnimationPalette
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc15f
+
+Tileset15Anim: ; 0xfc15f
+; param, function
+ dw $0000, $45eb
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, $45cc
+ dw $0000, WaitTileAnimation
+ dw $0000, NextTileFrame8
+ dw $0000, DoneTileAnimation
+; 0xfc17f
+
+INCBIN "baserom.gbc", $fc17f, $fc1e7-$fc17f
+
+Tileset24Anim: ; 0xfc1e7
+Tileset30Anim: ; 0xfc1e7
+; param, function
+ dw $9140, $46a2
+ dw $0000, $471e
+ dw $cf41, $4309
+ dw $0000, $471e
+ dw $9140, $4696
+ dw $0000, $471e
+ dw $0000, TileAnimationPalette
+ dw $0000, $471e
+ dw $9400, $46a2
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $9400, $4696
+ dw $0000, $471e
+ dw $0000, DoneTileAnimation
+; 0xfc233
+
+Tileset29Anim: ; 0xfc233
+; param, function
+ dw $9350, $46a2
+ dw $0000, $471e
+ dw $cf41, $4309
+ dw $0000, $471e
+ dw $9350, $4696
+ dw $0000, $471e
+ dw $0000, TileAnimationPalette
+ dw $0000, $471e
+ dw $9310, $46a2
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $cf41, $436a
+ dw $0000, $471e
+ dw $9310, $4696
+ dw $0000, $471e
+ dw $0000, DoneTileAnimation
+; 0xfc27f
+
+Tileset23Anim: ; 0xfc27f
+; param, function
+ dw $4770, $4645
+ dw $4774, $4645
+ dw $4768, $4645
+ dw $476c, $4645
+ dw $4760, $4645
+ dw $4764, $4645
+ dw $4758, $4645
+ dw $475c, $4645
+ dw $4750, $4645
+ dw $4754, $4645
+ dw $0000, NextTileFrame
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, DoneTileAnimation
+; 0xfc2bf
+
+INCBIN "baserom.gbc", $fc2bf, $fc2e7-$fc2bf
+
+Tileset04Anim: ; 0xfc2e7
+Tileset05Anim: ; 0xfc2e7
+Tileset06Anim: ; 0xfc2e7
+Tileset07Anim: ; 0xfc2e7
+Tileset08Anim: ; 0xfc2e7
+Tileset10Anim: ; 0xfc2e7
+Tileset11Anim: ; 0xfc2e7
+Tileset12Anim: ; 0xfc2e7
+Tileset13Anim: ; 0xfc2e7
+Tileset14Anim: ; 0xfc2e7
+Tileset16Anim: ; 0xfc2e7
+Tileset17Anim: ; 0xfc2e7
+Tileset18Anim: ; 0xfc2e7
+Tileset19Anim: ; 0xfc2e7
+Tileset20Anim: ; 0xfc2e7
+Tileset21Anim: ; 0xfc2e7
+Tileset22Anim: ; 0xfc2e7
+Tileset26Anim: ; 0xfc2e7
+Tileset27Anim: ; 0xfc2e7
+Tileset28Anim: ; 0xfc2e7
+Tileset32Anim: ; 0xfc2e7
+Tileset33Anim: ; 0xfc2e7
+Tileset34Anim: ; 0xfc2e7
+Tileset35Anim: ; 0xfc2e7
+Tileset36Anim: ; 0xfc2e7
+; param, function
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, WaitTileAnimation
+ dw $0000, DoneTileAnimation
+; 0xfc2fb
+
+DoneTileAnimation: ; fc2fb
+; Reset the animation command loop.
+ xor a
+ ld [hTileAnimFrame], a
+
+WaitTileAnimation: ; fc2fe
+; Do nothing this frame.
+ ret
+; fc2ff
+
+NextTileFrame8: ; fc2ff
+ ld a, [TileAnimationTimer]
+ inc a
+ and a, 7
+ ld [TileAnimationTimer], a
+ ret
+; fc309
+
+INCBIN "baserom.gbc", $fc309, $fc402 - $fc309
+
+AnimateWaterTile: ; fc402
+; Draw a water tile for the current frame in VRAM tile at de.
+
+; Save sp in bc (see WriteTile).
+ ld hl, [sp+0]
+ ld b, h
+ ld c, l
+
+ ld a, [TileAnimationTimer]
+
+; 4 tile graphics, updated every other frame.
+ and 3 << 1
+
+; 2 x 8 = 16 bytes per tile
+ add a
+ add a
+ add a
+
+ add WaterTileFrames % $100
+ ld l, a
+ ld a, 0
+ adc WaterTileFrames / $100
+ ld h, a
+
+; Stack now points to the start of the tile for this frame.
+ ld sp, hl
+
+ ld l, e
+ ld h, d
+
+ jp WriteTile
+; fc41c
+
+WaterTileFrames: ; fc41c
+; Frames 0-3
+; INCBIN "gfx/tilesets/water.2bpp"
+INCBIN "baserom.gbc", $fc41c, $fc45c - $fc41c
+; fc45c
+
+INCBIN "baserom.gbc", $fc45c, $fc56d - $fc45c
+
+AnimateFlowerTile: ; fc56d
+; No parameters.
+
+; Save sp in bc (see WriteTile).
+ ld hl, [sp+0]
+ ld b, h
+ ld c, l
+
+; Alternate tile graphc every other frame
+ ld a, [TileAnimationTimer]
+ and 1 << 1
+ ld e, a
+
+; CGB has different color mappings for flowers.
+ ld a, [hCGB]
+ and 1
+
+ add e
+ swap a ; << 4 (16 bytes)
+ ld e, a
+ ld d, 0
+ ld hl, FlowerTileFrames
+ add hl, de
+ ld sp, hl
+
+ ld hl, VTiles2 + $30 ; tile 4
+
+ jp WriteTile
+; fc58c
+
+FlowerTileFrames: ; fc58c
+; frame 0 dmg
+; frame 0 cgb
+; frame 1 dmg
+; frame 1 sgb
+; INCBIN "gfx/tilesets/flower.2bpp"
+INCBIN "baserom.gbc", $fc58c, $fc5cc - $fc58c
+; fc5cc
+
+INCBIN "baserom.gbc", $fc5cc, $fc673 - $fc5cc
+
+NextTileFrame: ; fc673
+ ld hl, TileAnimationTimer
+ inc [hl]
+ ret
+; fc678
+
+
+AnimateWhirlpoolTile: ; fc678
+; Update whirlpool tile using struct at de.
+
+; Struct:
+; VRAM address
+; Address of the first tile
+
+; Only does one of 4 tiles at a time.
+
+; Save sp in bc (see WriteTile).
+ ld hl, [sp+0]
+ ld b, h
+ ld c, l
+
+; de = VRAM address
+ ld l, e
+ ld h, d
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+; Tile address is now at hl.
+
+; Get the tile for this frame.
+ ld a, [TileAnimationTimer]
+ and %11 ; 4 frames x2
+ swap a ; * 16 bytes per tile
+
+ add [hl]
+ inc hl
+ ld h, [hl]
+ ld l, a
+ ld a, 0
+ adc h
+ ld h, a
+
+; Stack now points to the desired frame.
+ ld sp, hl
+
+ ld l, e
+ ld h, d
+
+ jr WriteTile
+; fc696
+
+
+WriteTileFromBuffer: ; fc696
+; Write tiledata at $cf41 to de.
+; $cf41 is loaded to sp for WriteTile.
+
+ ld hl, [sp+0]
+ ld b, h
+ ld c, l
+
+ ld hl, $cf41
+ ld sp, hl
+
+ ld h, d
+ ld l, e
+ jr WriteTile
+; fc6a2
+
+
+WriteTileToBuffer: ; fc6a2
+; Write tiledata de to $cf41.
+; de is loaded to sp for WriteTile.
+
+ ld hl, [sp+0]
+ ld b, h
+ ld c, l
+
+ ld h, d
+ ld l, e
+ ld sp, hl
+
+ ld hl, $cf41
+
+ ; fallthrough
+
+WriteTile: ; fc6ac
+; Write one 8x8 tile ($10 bytes) from sp to hl.
-INCBIN "baserom.gbc",$FC000,$fcdc2-$fc000
+; Warning: sp is saved in bc so we can abuse pop.
+; sp is restored to address bc. Save sp in bc before calling.
+
+ pop de
+ ld [hl], e
+ inc hl
+ ld [hl], d
+
+rept 7
+ pop de
+ inc hl
+ ld [hl], e
+ inc hl
+ ld [hl], d
+endr
+
+; restore sp
+ ld h, b
+ ld l, c
+ ld sp, hl
+ ret
+; fc6d7
+
+
+TileAnimationPalette: ; fc6d7
+; Transition between color values 0-2 for color 0 in palette 3.
+
+; No palette changes on DMG.
+ ld a, [hCGB]
+ and a
+ ret z
+
+; We don't want to mess with non-standard palettes.
+ ld a, [$ff47] ; BGP
+ cp %11100100
+ ret nz
+
+; Only update on even frames.
+ ld a, [TileAnimationTimer]
+ ld l, a
+ and 1 ; odd
+ ret nz
+
+; Ready for BGPD input...
+ ld a, %10011000 ; auto increment, index $18 (pal 3 color 0)
+ ld [rBGPI], a
+
+ ld a, [rSVBK]
+ push af
+ ld a, 5 ; wra5: gfx
+ ld [rSVBK], a
+
+; Update color 0 in order 0 1 2 1
+
+ ld a, l
+ and %110 ; frames 0 2 4 6
+
+ jr z, .color0
+
+ cp 4
+ jr z, .color2
+
+.color1
+ ld hl, $d01a ; pal 3 color 1
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+ jr .end
+
+.color0
+ ld hl, $d018 ; pal 3 color 0
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+ jr .end
+
+.color2
+ ld hl, $d01c ; pal 3 color 2
+ ld a, [hli]
+ ld [rBGPD], a
+ ld a, [hli]
+ ld [rBGPD], a
+
+.end
+ pop af
+ ld [rSVBK], a
+ ret
+; fc71e
+
+INCBIN "baserom.gbc", $fc71e, $fcdc2 - $fc71e
LoadTradesPointer: ; 0xfcdc2
ld d, 0
@@ -12889,7 +16605,7 @@ LoadTradesPointer: ; 0xfcdc2
ret
; 0xfcdd7
-INCBIN "baserom.gbc",$fcdd7,$fce58-$fcdd7
+INCBIN "baserom.gbc", $fcdd7, $fce58-$fcdd7
Trades: ; 0xfce58
; byte 1: dialog
@@ -12903,56 +16619,415 @@ Trades: ; 0xfce58
; byte 31 gender
; byte 32 XXX always zero?
- db 0,ABRA,MACHOP,"MUSCLE@@@@@",$37,$66,GOLD_BERRY,$54,$92,"MIKE@@@@@@@",0,0
- db 0,BELLSPROUT,ONIX,"ROCKY@@@@@@",$96,$66,BITTER_BERRY,$1e,$bf,"KYLE@@@@@@@",0,0
- db 1,KRABBY,VOLTORB,"VOLTY@@@@@@",$98,$88,PRZCUREBERRY,$05,$72,"TIM@@@@@@@@",0,0
- db 3,DRAGONAIR,DODRIO,"DORIS@@@@@@",$77,$66,SMOKE_BALL,$1b,$01,"EMY@@@@@@@@",2,0
- db 2,HAUNTER,XATU,"PAUL@@@@@@@",$96,$86,MYSTERYBERRY,$00,$3d,"CHRIS@@@@@@",0,0
- db 3,CHANSEY,AERODACTYL,"AEROY@@@@@@",$96,$66,GOLD_BERRY,$7b,$67,"KIM@@@@@@@@",0,0
- db 0,DUGTRIO,MAGNETON,"MAGGIE@@@@@",$96,$66,METAL_COAT,$a2,$c3,"FOREST@@@@@",0,0
+ db 0,ABRA,MACHOP,"MUSCLE@@@@@", $37, $66,GOLD_BERRY, $54, $92,"MIKE@@@@@@@",0,0
+ db 0,BELLSPROUT,ONIX,"ROCKY@@@@@@", $96, $66,BITTER_BERRY, $1e, $bf,"KYLE@@@@@@@",0,0
+ db 1,KRABBY,VOLTORB,"VOLTY@@@@@@", $98, $88,PRZCUREBERRY, $05, $72,"TIM@@@@@@@@",0,0
+ db 3,DRAGONAIR,DODRIO,"DORIS@@@@@@", $77, $66,SMOKE_BALL, $1b, $01,"EMY@@@@@@@@",2,0
+ db 2,HAUNTER,XATU,"PAUL@@@@@@@", $96, $86,MYSTERYBERRY, $00, $3d,"CHRIS@@@@@@",0,0
+ db 3,CHANSEY,AERODACTYL,"AEROY@@@@@@", $96, $66,GOLD_BERRY, $7b, $67,"KIM@@@@@@@@",0,0
+ db 0,DUGTRIO,MAGNETON,"MAGGIE@@@@@", $96, $66,METAL_COAT, $a2, $c3,"FOREST@@@@@",0,0
-INCBIN "baserom.gbc",$fcf38,$fd1d2-$fcf38
+INCBIN "baserom.gbc", $fcf38, $fd1d2-$fcf38
SECTION "bank40",DATA,BANK[$40]
-INCBIN "baserom.gbc",$100000,$10389d - $100000
+INCBIN "baserom.gbc", $100000, $10389d - $100000
SECTION "bank41",DATA,BANK[$41]
-INCBIN "baserom.gbc",$104000,$104350 - $104000
+INCBIN "baserom.gbc", $104000, $104350 - $104000
INCBIN "gfx/ow/misc.2bpp"
-INCBIN "baserom.gbc",$1045b0,$105258 - $1045b0
+INCBIN "baserom.gbc", $1045b0, $105258 - $1045b0
MysteryGiftGFX:
INCBIN "gfx/misc/mystery_gift.2bpp"
-INCBIN "baserom.gbc",$105688,$105930 - $105688
+INCBIN "baserom.gbc", $105688, $105930 - $105688
; japanese mystery gift gfx
INCBIN "gfx/misc/mystery_gift_jp.2bpp"
-INCBIN "baserom.gbc",$105db0,$105ef6 - $105db0
+
+DisplayUsedMoveText: ; 105db0
+; battle command 03
+ ld hl, UsedMoveText
+ call BattleTextBox
+ jp WaitBGMap
+; 105db9
+
+
+UsedMoveText: ; 105db9
+
+; this is a stream of text and asm from 105db9 to 105ef6
+
+; print actor name
+ text_jump _ActorNameText, BANK(_ActorNameText)
+ start_asm
+
+; ????
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .start
+
+; append used move list
+ ld a, [PlayerMoveAnimation]
+ call UpdateUsedMoves
+
+.start
+; get address for last move
+ ld a, $13 ; last move
+ call GetBattleVarPair
+ ld d, h
+ ld e, l
+
+; get address for last counter move
+ ld a, $11
+ call GetBattleVarPair
+
+; get move animation (id)
+ ld a, $c ; move animation
+ call CleanGetBattleVarPair
+ ld [$d265], a
+
+; check actor ????
+ push hl
+ callba Function0x34548
+ pop hl
+ jr nz, .grammar
+
+; update last move
+ ld a, [$d265]
+ ld [hl], a
+ ld [de], a
+
+.grammar
+ call GetMoveGrammar
+; $d265 now contains MoveGrammar
+
+
+; everything except 'instead' made redundant in localization
+
+; check obedience
+ ld a, [$c6f4]
+ and a
+ ld hl, UsedMove2Text
+ ret nz
+
+; check move grammar
+ ld a, [$d265]
+ cp $3
+ ld hl, UsedMove2Text
+ ret c
+ ld hl, UsedMove1Text
+ ret
+; 105e04
+
+UsedMove1Text: ; 105e04
+ text_jump _UsedMove1Text, BANK(_UsedMove1Text)
+ start_asm
+ jr Function105e10
+; 105e0b
+
+UsedMove2Text: ; 105e0b
+ text_jump _UsedMove2Text, BANK(_UsedMove2Text)
+ start_asm
+; 105e10
+
+Function105e10: ; 105e10
+; check obedience
+ ld a, [$c6f4]
+ and a
+ jr z, GetMoveNameText
+; print "instead,"
+ ld hl, UsedInsteadText
+ ret
+; 105e1a
+
+UsedInsteadText: ; 105e1a
+ text_jump _UsedInsteadText, BANK(_UsedInsteadText)
+ start_asm
+; 105e1f
+
+GetMoveNameText: ; 105e1f
+ ld hl, MoveNameText
+ ret
+; 105e23
+
+MoveNameText: ; 105e23
+ text_jump _MoveNameText, BANK(_MoveNameText)
+ start_asm
+; 105e28
+
+GetUsedMoveTextEnder: ; 105e28
+; get start address
+ ld hl, .endusedmovetexts
+
+; get move id
+ ld a, [$d265]
+
+; 2-byte pointer
+ add a
+
+; seek
+ push bc
+ ld b, $0
+ ld c, a
+ add hl, bc
+ pop bc
+
+; get pointer to usedmovetext ender
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+; 105e39
+
+.endusedmovetexts ; 105e39
+ dw EndUsedMove1Text
+ dw EndUsedMove2Text
+ dw EndUsedMove3Text
+ dw EndUsedMove4Text
+ dw EndUsedMove5Text
+; 105e43
+
+EndUsedMove1Text: ; 105e43
+ text_jump _EndUsedMove1Text, BANK(_EndUsedMove1Text)
+ db "@"
+; 105e48
+EndUsedMove2Text: ; 105e48
+ text_jump _EndUsedMove2Text, BANK(_EndUsedMove2Text)
+ db "@"
+; 105e4d
+EndUsedMove3Text: ; 105e4d
+ text_jump _EndUsedMove3Text, BANK(_EndUsedMove3Text)
+ db "@"
+; 105e52
+EndUsedMove4Text: ; 105e52
+ text_jump _EndUsedMove4Text, BANK(_EndUsedMove4Text)
+ db "@"
+; 105e57
+EndUsedMove5Text: ; 105e57
+ text_jump _EndUsedMove5Text, BANK(_EndUsedMove5Text)
+ db "@"
+; 105e5c
+
+
+GetMoveGrammar: ; 105e5c
+; store move grammar type in $d265
+
+ push bc
+; c = move id
+ ld a, [$d265]
+ ld c, a
+ ld b, $0
+
+; read grammar table
+ ld hl, MoveGrammar
+.loop
+ ld a, [hli]
+; end of table?
+ cp $ff
+ jr z, .end
+; match?
+ cp c
+ jr z, .end
+; advance grammar type at $00
+ and a
+ jr nz, .loop
+; next grammar type
+ inc b
+ jr .loop
+
+.end
+; $d265 now contains move grammar
+ ld a, b
+ ld [$d265], a
+
+; we're done
+ pop bc
+ ret
+; 105e7a
+
+MoveGrammar: ; 105e7a
+; made redundant in localization
+; each move is given an identifier for what usedmovetext to use (0-4):
+
+; 0
+ db SWORDS_DANCE
+ db GROWTH
+ db STRENGTH
+ db HARDEN
+ db MINIMIZE
+ db SMOKESCREEN
+ db WITHDRAW
+ db DEFENSE_CURL
+ db EGG_BOMB
+ db SMOG
+ db BONE_CLUB
+ db FLASH
+ db SPLASH
+ db ACID_ARMOR
+ db BONEMERANG
+ db REST
+ db SHARPEN
+ db SUBSTITUTE
+ db MIND_READER
+ db SNORE
+ db PROTECT
+ db SPIKES
+ db ENDURE
+ db ROLLOUT
+ db SWAGGER
+ db SLEEP_TALK
+ db HIDDEN_POWER
+ db PSYCH_UP
+ db EXTREMESPEED
+ db 0 ; end set
+
+; 1
+ db RECOVER
+ db TELEPORT
+ db BIDE
+ db SELFDESTRUCT
+ db AMNESIA
+ db FLAIL
+ db 0 ; end set
+
+; 2
+ db MEDITATE
+ db AGILITY
+ db MIMIC
+ db DOUBLE_TEAM
+ db BARRAGE
+ db TRANSFORM
+ db STRUGGLE
+ db SCARY_FACE
+ db 0 ; end set
+
+; 3
+ db POUND
+ db SCRATCH
+ db VICEGRIP
+ db WING_ATTACK
+ db FLY
+ db BIND
+ db SLAM
+ db HORN_ATTACK
+ db WRAP
+ db THRASH
+ db TAIL_WHIP
+ db LEER
+ db BITE
+ db GROWL
+ db ROAR
+ db SING
+ db PECK
+ db ABSORB
+ db STRING_SHOT
+ db EARTHQUAKE
+ db FISSURE
+ db DIG
+ db TOXIC
+ db SCREECH
+ db METRONOME
+ db LICK
+ db CLAMP
+ db CONSTRICT
+ db POISON_GAS
+ db BUBBLE
+ db SLASH
+ db SPIDER_WEB
+ db NIGHTMARE
+ db CURSE
+ db FORESIGHT
+ db CHARM
+ db ATTRACT
+ db ROCK_SMASH
+ db 0 ; end set
+
+; all other moves = 4
+ db $ff ; end
+; 105ed0
+
+
+UpdateUsedMoves: ; 105ed0
+; append move a to PlayerUsedMoves unless it has already been used
+
+ push bc
+; start of list
+ ld hl, PlayerUsedMoves
+; get move id
+ ld b, a
+; loop count
+ ld c, NUM_MOVES
+
+.loop
+; get move from the list
+ ld a, [hli]
+; not used yet?
+ and a
+ jr z, .add
+; already used?
+ cp b
+ jr z, .quit
+; next byte
+ dec c
+ jr nz, .loop
+
+; if the list is full and the move hasn't already been used
+; shift the list back one byte, deleting the first move used
+; this can occur with struggle or a new learned move
+ ld hl, PlayerUsedMoves + 1
+; 1 = 2
+ ld a, [hld]
+ ld [hli], a
+; 2 = 3
+ inc hl
+ ld a, [hld]
+ ld [hli], a
+; 3 = 4
+ inc hl
+ ld a, [hld]
+ ld [hl], a
+; 4 = new move
+ ld a, b
+ ld [PlayerUsedMoves + 3], a
+ jr .quit
+
+.add
+; go back to the byte we just inced from
+ dec hl
+; add the new move
+ ld [hl], b
+
+.quit
+; list updated
+ pop bc
+ ret
+; 105ef6
+
+
HallOfFame2: ; 0x105ef6
ret
-INCBIN "baserom.gbc",$105ef7,$106078 - $105ef7
+INCBIN "baserom.gbc", $105ef7, $106078 - $105ef7
HallOfFame1: ; 0x106078
ret
-INCBIN "baserom.gbc",$106079,$1060bb - $106079
+INCBIN "baserom.gbc", $106079, $1060bb - $106079
Function1060bb: ; 1060bb
; commented out
ret
; 1060bc
-INCBIN "baserom.gbc",$1060bc,$106dbc - $1060bc
+INCBIN "baserom.gbc", $1060bc, $106dbc - $1060bc
SECTION "bank42",DATA,BANK[$42]
@@ -12981,7 +17056,7 @@ StartTitleScreen: ; 10ed67
; Turn BG Map update off
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
; Reset timing variables
ld hl, $cf63
@@ -13111,11 +17186,11 @@ StartTitleScreen: ; 10ed67
call $6f06
; Save WRAM bank
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
; WRAM bank 5
ld a, 5
- ld [$ff70], a
+ ld [rSVBK], a
; Update palette colors
ld hl, TitleScreenPalettes
@@ -13130,17 +17205,17 @@ StartTitleScreen: ; 10ed67
; Restore WRAM bank
pop af
- ld [$ff70], a
+ ld [rSVBK], a
; LY/SCX trickery starts here
; Save WRAM bank
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
; WRAM bank 5
ld a, 5
- ld [$ff70], a
+ ld [rSVBK], a
; Make alternating lines come in from opposite sides
@@ -13166,11 +17241,11 @@ StartTitleScreen: ; 10ed67
; Let LCD Stat know we're messing around with SCX
ld a, rSCX - rJOYP
- ld [$ffc6], a
+ ld [hLCDStatCustom], a
; Restore WRAM bank
pop af
- ld [$ff70], a
+ ld [rSVBK], a
; Reset audio
@@ -13193,17 +17268,17 @@ StartTitleScreen: ; 10ed67
ld [$ffd2], a
ld a, $1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
; Update BG Map 0 (bank 0)
- ld [$ffd4], a
+ ld [hBGMapMode], a
xor a
ld [$d002], a
; Play starting sound effect
call SFXChannelsOff
- ld de, $0065
+ ld de, SFX_TITLE_SCREEN_ENTRANCE
call StartSFX
ret
@@ -13339,7 +17414,7 @@ TitleScreenPalettes:
SECTION "bank44",DATA,BANK[$44]
-INCBIN "baserom.gbc",$110000,$110fad - $110000
+INCBIN "baserom.gbc", $110000, $110fad - $110000
URIPrefix: ; 0x110fad
ascii "http://"
@@ -13352,11 +17427,11 @@ HTTPUtilityURL: ; 0x110ffc
HTTPRankingURL: ; 0x111020
ascii "gameboy.datacenter.ne.jp/cgb/ranking"
-INCBIN "baserom.gbc",$111044,$113f84 - $111044
+INCBIN "baserom.gbc", $111044, $113f84 - $111044
SECTION "bank45",DATA,BANK[$45]
-INCBIN "baserom.gbc",$114000,$117a7f - $114000
+INCBIN "baserom.gbc", $114000, $117a7f - $114000
; everything from here to the end of the bank is related to the
; Mobile Stadium option from the continue/newgame menu.
@@ -13483,7 +17558,7 @@ Function117b31:
jp Function117cdd
Function117b4f:
- ld a, [$ffa7]
+ ld a, [hJoyPressed]
cp $2
jr z, .asm_117ba4 ; 0x117b53 $4f
cp $1
@@ -13541,7 +17616,7 @@ Function117b4f:
Function117bb6:
call Function117c89
ld a, $1
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld a, $46
ld hl, $4284
rst FarCall
@@ -13565,10 +17640,10 @@ Function117bb6:
ld [$cf63], a
ret
.asm_117be7
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
ld a, $3
- ld [$ff70], a
+ ld [rSVBK], a
ld a, [$cd89]
and $1
jr nz, .asm_117c16 ; 0x117bf3 $21
@@ -13592,20 +17667,20 @@ Function117bb6:
jr .asm_117c20 ; 0x117c14 $a
.asm_117c16
pop af
- ld [$ff70], a
+ ld [rSVBK], a
ld a, $d3
ld [$c300], a
jr .asm_117bd0 ; 0x117c1e $b0
.asm_117c20
pop af
- ld [$ff70], a
+ ld [rSVBK], a
ld a, $5c
ld hl, $6eb9
rst FarCall
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
ld a, $3
- ld [$ff70], a
+ ld [rSVBK], a
ld a, $7
call GetSRAMBank
ld hl, $d002
@@ -13614,7 +17689,7 @@ Function117bb6:
call CopyBytes
call CloseSRAM
pop af
- ld [$ff70], a
+ ld [rSVBK], a
jp Function117cdd
Function117c4a:
@@ -13627,10 +17702,10 @@ Function117c4a:
rst FarCall
ld hl, MobileStadiumSuccessText
call $1057
- ld a, [$ff70]
+ ld a, [rSVBK]
push af
ld a, $5
- ld [$ff70], a
+ ld [rSVBK], a
ld hl, $d000
ld de, $0008
ld c, $8
@@ -13646,7 +17721,7 @@ Function117c4a:
jr nz, .asm_117c71 ; 0x117c7b $f4
call $04b6
pop af
- ld [$ff70], a
+ ld [rSVBK], a
ld a, $80
ld [$cf63], a
ret
@@ -13682,10 +17757,10 @@ Function117c89:
ret
Data117cbc: ; 0x117cbc
- db $40,$0c,$00,$11,$13,$00,$00,$00
+ db $40, $0c, $00, $11, $13, $00, $00, $00
Data117cc4: ; 0x117cc4
- db $40,$07,$0e,$0b,$13,$00,$00,$00 ; XXX what is this
+ db $40, $07, $0e, $0b, $13, $00, $00, $00 ; XXX what is this
YesNo117ccc: ; 0x117ccc
db "はい", $4e ; Yes
@@ -13700,14 +17775,14 @@ MobileStadiumSuccessText: ; 0x117cd8
db "@"
Function117cdd: ; 0x117cdd
- ld hl,$cf63
+ ld hl, $cf63
inc [hl]
ret
SECTION "bank46",DATA,BANK[$46]
-INCBIN "baserom.gbc",$118000,$118ba5 - $118000
+INCBIN "baserom.gbc", $118000, $118ba5 - $118000
ExchangeDownloadURL: ; 0x118ba5
ascii "http://gameboy.datacenter.ne.jp/cgb/download?name=/01/CGB-BXTJ/exchange/index.txt"
@@ -13734,11 +17809,11 @@ IndexDownloadURL: ; 0x118ce4
db $0
-INCBIN "baserom.gbc",$118d35,$11bc9e - $118d35
+INCBIN "baserom.gbc", $118d35, $11bc9e - $118d35
SECTION "bank47",DATA,BANK[$47]
-INCBIN "baserom.gbc",$11c000,$11f686 - $11c000
+INCBIN "baserom.gbc", $11c000, $11f686 - $11c000
SECTION "bank48",DATA,BANK[$48]
@@ -14565,17 +18640,17 @@ INCBIN "gfx/pics/201r/back.lz"
SECTION "bank5B",DATA,BANK[$5B]
-INCBIN "baserom.gbc",$16c000,$16d7fe - $16c000
+INCBIN "baserom.gbc", $16c000, $16d7fe - $16c000
SECTION "bank5C",DATA,BANK[$5C]
-INCBIN "baserom.gbc",$170000,$17367f - $170000
+INCBIN "baserom.gbc", $170000, $17367f - $170000
SECTION "bank5D",DATA,BANK[$5D]
-INCBIN "baserom.gbc",$174000,$177561 - $174000
+INCBIN "baserom.gbc", $174000, $177561 - $174000
SECTION "bank5E",DATA,BANK[$5E]
@@ -14593,17 +18668,17 @@ Music_SuicuneBattle: INCLUDE "audio/music/suicunebattle.asm"
Music_BattleTowerLobby: INCLUDE "audio/music/battletowerlobby.asm"
Music_MobileCenter: INCLUDE "audio/music/mobilecenter.asm"
-INCBIN "baserom.gbc",$17982d, $1799ef - $17982d
+INCBIN "baserom.gbc", $17982d, $1799ef - $17982d
MobileAdapterGFX:
INCBIN "gfx/misc/mobile_adapter.2bpp"
-INCBIN "baserom.gbc",$17a68f, $17b629 - $17a68f
+INCBIN "baserom.gbc", $17a68f, $17b629 - $17a68f
SECTION "bank5F",DATA,BANK[$5F]
-INCBIN "baserom.gbc",$17c000,$17ff6c - $17c000
+INCBIN "baserom.gbc", $17c000, $17ff6c - $17c000
SECTION "bank60",DATA,BANK[$60]
@@ -14619,6 +18694,12 @@ INCLUDE "maps/LancesRoom.asm"
INCLUDE "maps/HallOfFame.asm"
+; Pokedex entries I
+; 001-064
+
+INCLUDE "stats/pokedex/entries_1.asm"
+
+
SECTION "bank61",DATA,BANK[$61]
; Map Scripts XIV
@@ -14901,7 +18982,36 @@ INCLUDE "stats/pokedex/entries_2.asm"
SECTION "bank6F",DATA,BANK[$6F]
-INCBIN "baserom.gbc",$1bc000,$1be08d - $1bc000
+_FruitBearingTreeText: ; 0x1bc000
+ db $0, "It's a fruit-", $4f
+ db "bearing tree.", $57
+; 0x1bc01c
+
+_HeyItsFruitText: ; 0x1bc01c
+ db $0, "Hey! It's", $4f
+ db "@"
+ text_from_ram StringBuffer3
+ db $0, "!", $57
+; 0x1bc02d
+
+_ObtainedFruitText: ; 0x1bc02d
+ db $0, "Obtained", $4f
+ db "@"
+ text_from_ram StringBuffer3
+ db $0, "!", $57
+; 0x1bc03e
+
+_FruitPackIsFullText: ; 0x1bc03e
+ db $0, "But the PACK is", $4f
+ db "full…", $57
+; 0x1bc055
+
+_NothingHereText: ; 0x1bc055
+ db $0, "There's nothing", $4f
+ db "here…", $57
+; 0x1bc06b
+
+INCBIN "baserom.gbc", $1bc06b, $1be08d - $1bc06b
SECTION "bank70",DATA,BANK[$70]
@@ -14994,16 +19104,26 @@ SECTION "bank77",DATA,BANK[$77]
INCBIN "baserom.gbc", $1dc000, $1dc5a1 - $1dc000
-Tileset26GFX:
-Tileset32GFX:
-Tileset33GFX:
-Tileset34GFX:
-Tileset35GFX:
-Tileset36GFX: ; 1dc5a1
-INCBIN "gfx/tilesets/26.lz"
-; 1dd1a8
+Tileset26GFX: ; 0x1dc5a1
+Tileset32GFX: ; 0x1dc5a1
+Tileset33GFX: ; 0x1dc5a1
+Tileset34GFX: ; 0x1dc5a1
+Tileset35GFX: ; 0x1dc5a1
+Tileset36GFX: ; 0x1dc5a1
+INCBIN "gfx/tilesets/36.lz"
+; 0x1dd1a8
+
+ db $00
+
+Tileset26Meta: ; 0x1dd1a9
+INCBIN "tilesets/26_metatiles.bin"
+; 0x1dd5a9
+
+Tileset26Coll: ; 0x1dd5a9
+INCBIN "tilesets/26_collision.bin"
+; 0x1dd6a9
-INCBIN "baserom.gbc", $1dd1a8, $1de29f - $1dd1a8
+INCBIN "baserom.gbc", $1dd6a9, $1de29f - $1dd6a9
DudeAutoInput_A: ; 1de29f
@@ -15035,18 +19155,32 @@ DudeAutoInput_DownA: ; 1de2af
; 1de2c5
-INCBIN "baserom.gbc",$1de2c5,$1de2e4 - $1de2c5
+INCBIN "baserom.gbc", $1de2c5, $1de2e4 - $1de2c5
PokegearGFX: ; 1de2e4
INCBIN "gfx/misc/pokegear.lz"
; 1de5c7
-INCBIN "baserom.gbc",$1de5c7,$1df238 - $1de5c7
+INCBIN "baserom.gbc", $1de5c7, $1df238 - $1de5c7
SECTION "bank78",DATA,BANK[$78]
-INCBIN "baserom.gbc",$1e0000,$1e1000 - $1e0000
+Tileset33Meta: ; 0x1e0000
+INCBIN "tilesets/33_metatiles.bin"
+; 0x1e0400
+
+Tileset34Meta: ; 0x1e0400
+INCBIN "tilesets/34_metatiles.bin"
+; 0x1e0800
+
+Tileset35Meta: ; 0x1e0800
+INCBIN "tilesets/35_metatiles.bin"
+; 0x1e0c00
+
+Tileset36Meta: ; 0x1e0c00
+INCBIN "tilesets/36_metatiles.bin"
+; 0x1e1000
SECTION "bank79",DATA,BANK[$79]
@@ -15057,26 +19191,26 @@ SECTION "bank7A",DATA,BANK[$7A]
SECTION "bank7B",DATA,BANK[$7B]
-INCBIN "baserom.gbc",$1ec000,$1ecf02 - $1ec000
+INCBIN "baserom.gbc", $1ec000, $1ecf02 - $1ec000
SECTION "bank7C",DATA,BANK[$7C]
-INCBIN "baserom.gbc",$1f0000,$1f09d8 - $1f0000
+INCBIN "baserom.gbc", $1f0000, $1f09d8 - $1f0000
SECTION "bank7D",DATA,BANK[$7D]
-INCBIN "baserom.gbc",$1f4000,$1f636a - $1f4000
+INCBIN "baserom.gbc", $1f4000, $1f636a - $1f4000
SECTION "bank7E",DATA,BANK[$7E]
-INCBIN "baserom.gbc",$1f8000,$1fb8a8 - $1f8000
+INCBIN "baserom.gbc", $1f8000, $1fb8a8 - $1f8000
SECTION "bank7F",DATA,BANK[$7F]
SECTION "stadium2",DATA[$8000-$220],BANK[$7F]
-INCBIN "baserom.gbc",$1ffde0,$220
+INCBIN "baserom.gbc", $1ffde0, $220