Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
yenatch
2017-12-23 17:14:09 -05:00
1066 changed files with 16040 additions and 15625 deletions

View File

@@ -363,19 +363,6 @@ StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
ld [wcf64], a
ret
spintable_entry: MACRO
db \1
dw .wedge\2
dwcoord \3, \4
ENDM
; quadrants
const_def
const UPPER_LEFT
const UPPER_RIGHT
const LOWER_LEFT
const LOWER_RIGHT
StartTrainerBattle_SpinToBlack: ; 8c44f (23:444f)
xor a
ld [hBGMapMode], a
@@ -412,7 +399,19 @@ endr
ret
; 8c490 (23:4490)
; quadrants
const_def
const UPPER_LEFT
const UPPER_RIGHT
const LOWER_LEFT
const LOWER_RIGHT
.spintable ; 8c490
spintable_entry: MACRO
db \1
dw .wedge\2
dwcoord \3, \4
ENDM
spintable_entry UPPER_LEFT, 1, 1, 6
spintable_entry UPPER_LEFT, 2, 0, 3
spintable_entry UPPER_LEFT, 3, 1, 0
@@ -797,12 +796,6 @@ StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
sine_wave $100
; 8c768
zoombox: macro
; width, height, start y, start x
db \1, \2
dwcoord \3, \4
endm
StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
callba Function5602
ld de, .boxes
@@ -835,6 +828,11 @@ StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
; 8c792 (23:4792)
.boxes ; 8c792
zoombox: macro
; width, height, start y, start x
db \1, \2
dwcoord \3, \4
endm
zoombox 4, 2, 8, 8
zoombox 6, 4, 7, 7
zoombox 8, 6, 6, 6
@@ -864,3 +862,12 @@ StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
jr nz, .row
ret
; 8c7c9 (23:47c9)
Function8c7c9:
; XXX
ld a, $1
ld [hBGMapMode], a
call WaitBGMap
xor a
ld [hBGMapMode], a
ret

View File

@@ -1415,7 +1415,6 @@ else
endc
endm
cardflip_cursor 11, 2, .Impossible
cardflip_cursor 12, 2, .Impossible
cardflip_cursor 13, 2, .PokeGroupPair
@@ -1665,50 +1664,7 @@ CardFlip_InitAttrPals: ; e0c37 (38:4c37)
; e0c93 (38:4c93)
.palettes ; e0c93
RGB 31, 31, 31
RGB 17, 07, 31
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 29, 25, 00
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 13, 30
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 08, 17, 30
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 08, 31, 08
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 17, 07, 31
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 17, 07, 31
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 17, 07, 31
RGB 06, 19, 08
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 00, 00
RGB 31, 00, 00
INCLUDE "data/palettes/card_flip.pal"
; e0cdb
CardFlipLZ03: ; e0cdb
@@ -1727,16 +1683,5 @@ CardFlipLZ02: ; e0ea8
INCBIN "gfx/card_flip/card_flip_2.2bpp.lz"
CardFlipTilemap: ; e110c
db $ef, $15, $27, $2a, $2a, $06, $27, $2a, $2a, $06, $27
db $ef, $07, $27, $3e, $3f, $42, $43, $46, $47, $4a, $4b
db $ef, $17, $26, $40, $41, $44, $45, $48, $49, $4c, $4d
db $ef, $25, $04, $00, $01, $00, $01, $00, $01, $00, $01
db $ef, $05, $14, $10, $11, $10, $11, $10, $11, $10, $11
db $ef, $16, $24, $20, $21, $20, $21, $20, $21, $20, $21
db $ef, $25, $04, $00, $02, $00, $02, $00, $02, $00, $02
db $ef, $05, $14, $10, $12, $10, $12, $10, $12, $10, $12
db $ef, $16, $24, $20, $22, $20, $22, $20, $22, $20, $22
db $ef, $25, $04, $00, $03, $00, $03, $00, $03, $00, $03
db $ef, $05, $14, $10, $13, $10, $13, $10, $13, $10, $13
db $ef, $16, $24, $20, $23, $20, $23, $20, $23, $20, $23
INCBIN "gfx/card_flip/card_flip.tilemap"
; e1190

247
engine/caught_data.asm Normal file
View File

@@ -0,0 +1,247 @@
CheckPartyFullAfterContest: ; 4d9e5
ld a, [wContestMon]
and a
jp z, .DidntCatchAnything
ld [CurPartySpecies], a
ld [CurSpecies], a
call GetBaseData
ld hl, PartyCount
ld a, [hl]
cp 6
jp nc, .TryAddToBox
inc a
ld [hl], a
ld c, a
ld b, $0
add hl, bc
ld a, [wContestMon]
ld [hli], a
ld [CurSpecies], a
ld a, $ff
ld [hl], a
ld hl, PartyMon1Species
ld a, [PartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
ld hl, wContestMon
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
ld a, [PartyCount]
dec a
ld hl, PartyMonOT
call SkipNames
ld d, h
ld e, l
ld hl, PlayerName
call CopyBytes
ld a, [CurPartySpecies]
ld [wd265], a
call GetPokemonName
ld hl, StringBuffer1
ld de, wMonOrItemNameBuffer
ld bc, PKMN_NAME_LENGTH
call CopyBytes
call GiveANickname_YesNo
jr c, .Party_SkipNickname
ld a, [PartyCount]
dec a
ld [CurPartyMon], a
xor a
ld [MonType], a
ld de, wMonOrItemNameBuffer
callab InitNickname
.Party_SkipNickname:
ld a, [PartyCount]
dec a
ld hl, PartyMonNicknames
call SkipNames
ld d, h
ld e, l
ld hl, wMonOrItemNameBuffer
call CopyBytes
ld a, [PartyCount]
dec a
ld hl, PartyMon1Level
call GetPartyLocation
ld a, [hl]
ld [CurPartyLevel], a
call SetCaughtData
ld a, [PartyCount]
dec a
ld hl, PartyMon1CaughtLocation
call GetPartyLocation
ld a, [hl]
and $80
ld b, $13
or b
ld [hl], a
xor a
ld [wContestMon], a
and a
ld [ScriptVar], a
ret
.TryAddToBox: ; 4daa3
ld a, BANK(sBoxCount)
call GetSRAMBank
ld hl, sBoxCount
ld a, [hl]
cp MONS_PER_BOX
call CloseSRAM
jr nc, .BoxFull
xor a
ld [CurPartyMon], a
ld hl, wContestMon
ld de, wBufferMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
ld hl, PlayerName
ld de, wBufferMonOT
ld bc, NAME_LENGTH
call CopyBytes
callab InsertPokemonIntoBox
ld a, [CurPartySpecies]
ld [wd265], a
call GetPokemonName
call GiveANickname_YesNo
ld hl, StringBuffer1
jr c, .Box_SkipNickname
ld a, BOXMON
ld [MonType], a
ld de, wMonOrItemNameBuffer
callab InitNickname
ld hl, wMonOrItemNameBuffer
.Box_SkipNickname:
ld a, BANK(sBoxMonNicknames)
call GetSRAMBank
ld de, sBoxMonNicknames
ld bc, PKMN_NAME_LENGTH
call CopyBytes
call CloseSRAM
.BoxFull:
ld a, BANK(sBoxMon1Level)
call GetSRAMBank
ld a, [sBoxMon1Level]
ld [CurPartyLevel], a
call CloseSRAM
call SetBoxMonCaughtData
ld a, BANK(sBoxMon1CaughtLocation)
call GetSRAMBank
ld hl, sBoxMon1CaughtLocation
ld a, [hl]
and $80
ld b, $13
or b
ld [hl], a
call CloseSRAM
xor a
ld [wContestMon], a
ld a, $1
ld [ScriptVar], a
ret
.DidntCatchAnything: ; 4db35
ld a, $2
ld [ScriptVar], a
ret
GiveANickname_YesNo: ; 4db3b
ld hl, TextJump_GiveANickname
call PrintText
jp YesNoBox
TextJump_GiveANickname: ; 0x4db44
; Give a nickname to the @ you received?
text_jump UnknownText_0x1c12fc
db "@"
SetCaughtData: ; 4db49
ld a, [PartyCount]
dec a
ld hl, PartyMon1CaughtLevel
call GetPartyLocation
SetBoxmonOrEggmonCaughtData: ; 4db53
ld a, [TimeOfDay]
inc a
rrca
rrca
ld b, a
ld a, [CurPartyLevel]
or b
ld [hli], a
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
cp MAP_POKECENTER_2F
jr nz, .NotPokecenter2F
ld a, b
cp GROUP_POKECENTER_2F
jr nz, .NotPokecenter2F
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
ld c, a
.NotPokecenter2F:
call GetWorldMapLocation
ld b, a
ld a, [PlayerGender]
rrca
or b
ld [hl], a
ret
SetBoxMonCaughtData: ; 4db83
ld a, BANK(sBoxMon1CaughtLevel)
call GetSRAMBank
ld hl, sBoxMon1CaughtLevel
call SetBoxmonOrEggmonCaughtData
call CloseSRAM
ret
SetGiftBoxMonCaughtData: ; 4db92
push bc
ld a, BANK(sBoxMon1CaughtLevel)
call GetSRAMBank
ld hl, sBoxMon1CaughtLevel
pop bc
call SetGiftMonCaughtData
call CloseSRAM
ret
SetGiftPartyMonCaughtData: ; 4dba3
ld a, [PartyCount]
dec a
ld hl, PartyMon1CaughtLevel
push bc
call GetPartyLocation
pop bc
SetGiftMonCaughtData: ; 4dbaf
xor a
ld [hli], a
ld a, $7e
rrc b
or b
ld [hl], a
ret
SetEggMonCaughtData: ; 4dbb8 (13:5bb8)
ld a, [CurPartyMon]
ld hl, PartyMon1CaughtLevel
call GetPartyLocation
ld a, [CurPartyLevel]
push af
ld a, $1
ld [CurPartyLevel], a
call SetBoxmonOrEggmonCaughtData
pop af
ld [CurPartyLevel], a
ret

1071
engine/cgb_layouts.asm Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
CheckBattleScene: ; 4ea44
; Return carry if battle scene is turned off.
ld a, 0
ld hl, wLinkMode
call GetFarWRAMByte
cp LINK_MOBILE
jr z, .mobile
ld a, [Options]
bit BATTLE_SCENE, a
jr nz, .off
and a
ret
.mobile
ld a, [wcd2f]
and a
jr nz, .from_wram
ld a, $4
call GetSRAMBank
ld a, [$a60c]
ld c, a
call CloseSRAM
ld a, c
bit 0, c
jr z, .off
and a
ret
.from_wram
ld a, $5
ld hl, w5_dc00
call GetFarWRAMByte
bit 0, a
jr z, .off
and a
ret
.off
scf
ret

View File

@@ -0,0 +1,74 @@
CheckNickErrors:: ; 669f
; error-check monster nick before use
; must be a peace offering to gamesharkers
; input: de = nick location
push bc
push de
ld b, PKMN_NAME_LENGTH
.checkchar
; end of nick?
ld a, [de]
cp "@" ; terminator
jr z, .end
; check if this char is a text command
ld hl, .textcommands
dec hl
.loop
; next entry
inc hl
; reached end of commands table?
ld a, [hl]
cp -1
jr z, .done
; is the current char between this value (inclusive)...
ld a, [de]
cp [hl]
inc hl
jr c, .loop
; ...and this one?
cp [hl]
jr nc, .loop
; replace it with a "?"
ld a, "?"
ld [de], a
jr .loop
.done
; next char
inc de
; reached end of nick without finding a terminator?
dec b
jr nz, .checkchar
; change nick to "?@"
pop de
push de
ld a, "?"
ld [de], a
inc de
ld a, "@"
ld [de], a
.end
; if the nick has any errors at this point it's out of our hands
pop de
pop bc
ret
.textcommands ; 66cf
; table defining which characters are actually text commands
; format:
; ≥ <
db "<START>", TX_BOX + 1
db "<PLAY_G>", $18 + 1
db $1d, "%" + 1
db $35, "<GREEN>" + 1
db "<ENEMY>", "<ENEMY>" + 1
db "<MOM>", "<TM>" + 1
db "<ROCKET>", "┘" + 1
db -1 ; end

19
engine/check_time.asm Normal file
View File

@@ -0,0 +1,19 @@
CheckTime:: ; c000
ld a, [TimeOfDay]
ld hl, TimeOfDayTable
ld de, 2
call IsInArray
inc hl
ld c, [hl]
ret c
xor a
ld c, a
ret
TimeOfDayTable: ; c012
db MORN_F, MORN
db DAY_F, DAY
db NITE_F, NITE
db NITE_F, NITE
db -1

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
ConsumeHeldItem: ; 27192
push hl
push de
push bc
ld a, [hBattleTurn]
and a
ld hl, OTPartyMon1Item
ld de, EnemyMonItem
ld a, [CurOTMon]
jr z, .theirturn
ld hl, PartyMon1Item
ld de, BattleMonItem
ld a, [CurBattleMon]
.theirturn
push hl
push af
ld a, [de]
ld b, a
callba GetItemHeldEffect
ld hl, .ConsumableEffects
.loop
ld a, [hli]
cp b
jr z, .ok
inc a
jr nz, .loop
pop af
pop hl
pop bc
pop de
pop hl
ret
.ok
xor a
ld [de], a
pop af
pop hl
call GetPartyLocation
ld a, [hBattleTurn]
and a
jr nz, .ourturn
ld a, [wBattleMode]
dec a
jr z, .done
.ourturn
ld [hl], $0
.done
pop bc
pop de
pop hl
ret
.ConsumableEffects: ; 271de
; Consumable items?
db HELD_BERRY
db HELD_2
db HELD_5
db HELD_HEAL_POISON
db HELD_HEAL_FREEZE
db HELD_HEAL_BURN
db HELD_HEAL_SLEEP
db HELD_HEAL_PARALYZE
db HELD_HEAL_STATUS
db HELD_30
db HELD_ATTACK_UP
db HELD_DEFENSE_UP
db HELD_SPEED_UP
db HELD_SP_ATTACK_UP
db HELD_SP_DEFENSE_UP
db HELD_ACCURACY_UP
db HELD_EVASION_UP
db HELD_38
db HELD_71
db HELD_ESCAPE
db HELD_CRITICAL_UP
db -1

File diff suppressed because it is too large Load Diff

336
engine/crystal_colors.asm Executable file
View File

@@ -0,0 +1,336 @@
GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
ld a, b
cp SCGB_RAM
jr nz, .not_ram
ld a, [SGBPredef]
.not_ram
push af
callba ResetBGPals
pop af
ld l, a
ld h, 0
add hl, hl
ld de, .dw
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .done
push de
jp hl
.done
ret
; 49330 (12:5330)
.dw ; 49330
dw MG_Mobile_Layout00
dw MG_Mobile_Layout01
dw MG_Mobile_Layout02
; 49336
MG_Mobile_Layout_FillBox: ; 49336
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .row
ret
; 49346
MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
hlcoord 0, 0, AttrMap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
ret
MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
ld de, UnknBGPals
ld hl, Palette_493e1
ld bc, 5 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
ld de, UnknBGPals palette PAL_BG_TEXT
ld hl, Palette_TextBG7
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
ret
MG_Mobile_Layout00: ; 4936e (12:536e)
call MG_Mobile_Layout_LoadPals
call MG_Mobile_Layout_WipeAttrMap
call MG_Mobile_Layout_CreatePalBoxes
callba ApplyAttrMap
callba ApplyPals
ret
MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
hlcoord 0, 0, AttrMap
lb bc, 4, 1
ld a, $1
call MG_Mobile_Layout_FillBox
lb bc, 2, 1
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 6, 1
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 1, 0, AttrMap
ld a, $1
lb bc, 3, 18
call MG_Mobile_Layout_FillBox
lb bc, 2, 18
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 12, 18
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 19, 0, AttrMap
lb bc, 4, 1
ld a, $1
call MG_Mobile_Layout_FillBox
lb bc, 2, 1
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 6, 1
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 0, 12, AttrMap
ld bc, 6 * SCREEN_WIDTH
ld a, $7
call ByteFill
ret
; 493e1 (12:53e1)
Palette_493e1: ; 493e1
INCLUDE "data/palettes/mg_mobile.pal"
; 49409
LoadOW_BGPal7:: ; 49409
ld hl, Palette_TextBG7
ld de, UnknBGPals palette PAL_BG_TEXT
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
ret
; 49418
Palette_TextBG7: ; 49418
RGB 31, 31, 31
RGB 08, 19, 28
RGB 05, 05, 16
RGB 00, 00, 00
; 49420
Function49420:: ; 49420 (12:5420)
ld hl, MansionPalette4
ld de, UnknBGPals palette PAL_BG_ROOF
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
ret
; 4942f (12:542f)
MG_Mobile_Layout01: ; 4942f
call MG_Mobile_Layout_LoadPals
ld de, UnknBGPals palette PAL_BG_TEXT
ld hl, Palette_49478
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
call MG_Mobile_Layout_WipeAttrMap
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
hlcoord 0, 14, AttrMap
ld bc, 4 * SCREEN_WIDTH
ld a, $7
call ByteFill
ld a, [wd002]
bit 6, a
jr z, .asm_49464
call Function49480
jr .asm_49467
.asm_49464
call Function49496
.asm_49467
callba ApplyAttrMap
callba ApplyPals
ld a, $1
ld [hCGBPalUpdate], a
ret
; 49478
Palette_49478: ; 49478
RGB 31, 31, 31
RGB 26, 31, 00
RGB 20, 16, 03
RGB 00, 00, 00
; 49480
Function49480: ; 49480
hlcoord 0, 0, AttrMap
lb bc, 4, SCREEN_WIDTH
ld a, $7
call MG_Mobile_Layout_FillBox
hlcoord 0, 2, AttrMap
ld a, $4
ld [hl], a
hlcoord 19, 2, AttrMap
ld [hl], a
ret
; 49496
Function49496: ; 49496
hlcoord 0, 0, AttrMap
lb bc, 2, SCREEN_WIDTH
ld a, $7
call MG_Mobile_Layout_FillBox
hlcoord 0, 1, AttrMap
ld a, $4
ld [hl], a
hlcoord 19, 1, AttrMap
ld [hl], a
ret
; 494ac
INCLUDE "tilesets/special_palettes.asm"
MG_Mobile_Layout02: ; 49706
ld hl, Palette_49732
ld de, UnknBGPals
ld bc, 1 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
callba ApplyPals
call MG_Mobile_Layout_WipeAttrMap
callba ApplyAttrMap
ld hl, Palette_4973a
ld de, UnknOBPals
ld bc, 1 palettes
ld a, BANK(UnknOBPals)
call FarCopyWRAM
ret
; 49732
Palette_49732: ; 49732
RGB 31, 31, 31
RGB 23, 16, 07
RGB 23, 07, 07
RGB 03, 07, 20
; 4973a
Palette_4973a: ; 4973a
RGB 00, 00, 00
RGB 07, 05, 31
RGB 14, 18, 31
RGB 31, 31, 31
; 49742
Function49742: ; 49742
ld hl, Palette_49757
ld de, UnknBGPals
ld bc, $40
ld a, $5
call FarCopyWRAM
callba ApplyPals
ret
; 49757
Palette_49757: ; 49757
INCLUDE "data/palettes/49757.pal"
; 49797
_InitMG_Mobile_LinkTradePalMap: ; 49797
hlcoord 0, 0, AttrMap
lb bc, 16, 2
ld a, $4
call MG_Mobile_Layout_FillBox
ld a, $3
ldcoord_a 0, 1, AttrMap
ldcoord_a 0, 14, AttrMap
hlcoord 2, 0, AttrMap
lb bc, 8, 18
ld a, $5
call MG_Mobile_Layout_FillBox
hlcoord 2, 8, AttrMap
lb bc, 8, 18
ld a, $6
call MG_Mobile_Layout_FillBox
hlcoord 0, 16, AttrMap
lb bc, 2, SCREEN_WIDTH
ld a, $4
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 6, 1, AttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 17, 1, AttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 6, 9, AttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 17, 9, AttrMap
call MG_Mobile_Layout_FillBox
ld a, $2
hlcoord 2, 16, AttrMap
ld [hli], a
ld a, $7
ld [hli], a
ld [hli], a
ld [hli], a
ld a, $2
ld [hl], a
hlcoord 2, 17, AttrMap
ld a, $3
ld bc, 6
call ByteFill
ret
; 49811
LoadTradeRoomBGPals: ; 49811
ld hl, TradeRoomPalette
ld de, UnknBGPals palette PAL_BG_GREEN
ld bc, 6 palettes
ld a, BANK(UnknBGPals)
call FarCopyWRAM
callba ApplyPals
ret
; 49826
TradeRoomPalette: ; 49826
INCLUDE "data/palettes/trade_room.pal"
; 49856
InitMG_Mobile_LinkTradePalMap: ; 49856
call _InitMG_Mobile_LinkTradePalMap
ret
; 4985a
Unknown_4985a: ; unreferenced
db $ab, $03, $57, $24, $ac, $0e, $13, $32
db $be, $30, $5b, $4c, $47, $60, $ed, $f2
db $ab, $03, $55, $26, $aa, $0a, $13, $3a
db $be, $28, $33, $24, $6e, $71, $df, $b0
db $a8, $00, $e5, $e0, $9a, $fc, $f4, $2c
db $fe, $4c, $a3, $5e, $c6, $3a, $ab, $4d
db $a8, $00, $b5, $b0, $de, $e8, $fc, $1c
db $ba, $66, $f7, $0e, $ba, $5e, $43, $bd

File diff suppressed because it is too large Load Diff

View File

@@ -159,7 +159,7 @@ Function819a7: ; 819a7
ld [rSVBK], a
ld hl, Palette_819f4
ld de, BGPals
ld bc, $80
ld bc, 16 palettes
call CopyBytes
ld a, $80
ld [rBGPI], a
@@ -193,93 +193,10 @@ Function819a7: ; 819a7
; 819f4
Palette_819f4: ; 819f4
; white
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
; red
RGB 31, 00, 00
RGB 31, 00, 00
RGB 31, 00, 00
RGB 00, 00, 00
; green
RGB 00, 31, 00
RGB 00, 31, 00
RGB 00, 31, 00
RGB 00, 00, 00
; blue
RGB 00, 00, 31
RGB 00, 00, 31
RGB 00, 00, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
INCLUDE "data/palettes/debug/bg.pal"
Palette_81a34: ; 81a34
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
RGB 31, 31, 31
RGB 31, 31, 31
RGB 31, 31, 31
RGB 00, 00, 00
; red
RGB 31, 31, 31
RGB 31, 00, 00
RGB 31, 00, 00
RGB 00, 00, 00
; green
RGB 31, 31, 31
RGB 00, 31, 00
RGB 00, 31, 00
RGB 00, 00, 00
; blue
RGB 31, 31, 31
RGB 00, 00, 31
RGB 00, 00, 31
RGB 00, 00, 00
INCLUDE "data/palettes/debug/ob.pal"
; 81a74
Function81a74: ; 81a74

View File

@@ -1374,3 +1374,13 @@ _GetDecorationSprite: ; 27085
ld a, c
ret
; 27092
PadCoords_de: ; 27092
ld a, d
add 4
ld d, a
ld a, e
add 4
ld e, a
call GetBlockLocation
ret

625
engine/dma_transfer.asm Executable file

File diff suppressed because it is too large Load Diff

19
engine/empty_sram.asm Normal file
View File

@@ -0,0 +1,19 @@
EmptyAllSRAMBanks: ; 4cf1f
ld a, $0
call .EmptyBank
ld a, $1
call .EmptyBank
ld a, $2
call .EmptyBank
ld a, $3
call .EmptyBank
ret
.EmptyBank: ; 4cf34
call GetSRAMBank
ld hl, SRAM_Begin
ld bc, SRAM_End - SRAM_Begin
xor a
call ByteFill
call CloseSRAM
ret

129
engine/european_mail.asm Normal file
View File

@@ -0,0 +1,129 @@
IsMailEuropean: ; 1de5c8
; return 1 if French
; return 2 if German
; return 3 if Italian
; return 4 if Spanish
; return 0 if none of the above
ld c, $0
ld hl, sPartyMon1MailAuthorNationality - sPartyMon1Mail
add hl, de
ld a, [hli]
cp "E"
ret nz
ld a, [hli]
inc c
cp "F"
ret z
inc c
cp "G"
ret z
inc c
cp "I"
ret z
inc c
cp "S"
ret z
ld c, $0
ret
; The regular font.
StandardEnglishFont: ; 1de5e6
INCBIN "gfx/font/english.1bpp"
; An extended font.
FrenchGermanFont: ; 1de9e6
INCBIN "gfx/font/french_german.1bpp"
; An even more extended font.
SpanishItalianFont: ; 1dede6
INCBIN "gfx/font/spanish_italian.1bpp"
HandleFrenchGermanMail: ; 1df1e6
; called if mail is french or german
; fix 's 't 'v
ld b, sPartyMon1MailAuthor - sPartyMon1Mail
ld h, d
ld l, e
.loop
ld a, [hl]
cp $dc ; 's in french/german font
jr nz, .check_intermediate_chars
ld a, "'s"
jr .replace
.check_intermediate_chars
sub "'s"
jr c, .dont_replace
cp "'v" - "'s" + 1
jr nc, .dont_replace
add $cd
.replace
ld [hl], a
.dont_replace
inc hl
dec b
jr nz, .loop
ret
LireLeCourrierAnglais:
DeutenEnglischenPost: ; 1df203
; Cette fonction convertit certains des caractères anglais pour
; leur équivalent dans le jeu de caractères français.
; Diese Funktion wandelt bestimmte englische Zeichen, um ihre
; Entsprechung in der Deutschen-Zeichensatz.
ld b, sPartyMon1MailAuthor - sPartyMon1Mail
ld h, d
ld l, e
.loop
ld a, [hl]
cp "'s"
jr nz, .check_intermediate_chars
ld a, $dc
jr .replace
.check_intermediate_chars
sub $cd
jr c, .dont_replace
cp "'v" - "'s" + 1
jr nc, .dont_replace
add "'s"
.replace
ld [hl], a
.dont_replace
inc hl
dec b
jr nz, .loop
ret
HandleSpanishItalianMail: ; 1df220
LeerCorreosIngleses:
LeggiPostaInglese:
; This function converts certain characters between
; the English and Spanish/Italian character sets.
; Esta función convierte ciertos caracteres entre
; el juego de caracteres Inglés y Español.
; Questa funzione converte alcuni caratteri tra
; l'inglese e il set di caratteri italiani.
ld b, sPartyMon1MailAuthor - sPartyMon1Mail
ld h, d
ld l, e
.loop
ld a, [hl]
and $f0
cp $d0
jr nz, .dont_replace
ld a, [hl]
add $8
and $f
or $d0
ld [hl], a
.dont_replace
inc hl
dec b
jr nz, .loop
ret

162
engine/experience.asm Normal file
View File

@@ -0,0 +1,162 @@
CalcLevel: ; 50e1b
ld a, [TempMonSpecies]
ld [CurSpecies], a
call GetBaseData
ld d, 1
.next_level
inc d
ld a, d
cp (MAX_LEVEL + 1) % $100
jr z, .got_level
call CalcExpAtLevel
push hl
ld hl, TempMonExp + 2
ld a, [hProduct + 3]
ld c, a
ld a, [hld]
sub c
ld a, [hProduct + 2]
ld c, a
ld a, [hld]
sbc c
ld a, [hProduct + 1]
ld c, a
ld a, [hl]
sbc c
pop hl
jr nc, .next_level
.got_level
dec d
ret
CalcExpAtLevel: ; 50e47
; (a/b)*n**3 + c*n**2 + d*n - e
ld a, [BaseGrowthRate]
add a
add a
ld c, a
ld b, 0
ld hl, GrowthRates
add hl, bc
; Cube the level
call .LevelSquared
ld a, d
ld [hMultiplier], a
call Multiply
; Multiply by a
ld a, [hl]
and $f0
swap a
ld [hMultiplier], a
call Multiply
; Divide by b
ld a, [hli]
and $f
ld [hDivisor], a
ld b, 4
call Divide
; Push the cubic term to the stack
ld a, [hQuotient + 0]
push af
ld a, [hQuotient + 1]
push af
ld a, [hQuotient + 2]
push af
; Square the level and multiply by the lower 7 bits of c
call .LevelSquared
ld a, [hl]
and $7f
ld [hMultiplier], a
call Multiply
; Push the absolute value of the quadratic term to the stack
ld a, [hProduct + 1]
push af
ld a, [hProduct + 2]
push af
ld a, [hProduct + 3]
push af
ld a, [hli]
push af
; Multiply the level by d
xor a
ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
ld a, d
ld [hMultiplicand + 2], a
ld a, [hli]
ld [hMultiplier], a
call Multiply
; Subtract e
ld b, [hl]
ld a, [hProduct + 3]
sub b
ld [hMultiplicand + 2], a
ld b, $0
ld a, [hProduct + 2]
sbc b
ld [hMultiplicand + 1], a
ld a, [hProduct + 1]
sbc b
ld [hMultiplicand], a
; If bit 7 of c is set, c is negative; otherwise, it's positive
pop af
and $80
jr nz, .subtract
; Add c*n**2 to (d*n - e)
pop bc
ld a, [hProduct + 3]
add b
ld [hMultiplicand + 2], a
pop bc
ld a, [hProduct + 2]
adc b
ld [hMultiplicand + 1], a
pop bc
ld a, [hProduct + 1]
adc b
ld [hMultiplicand], a
jr .done_quadratic
.subtract
; Subtract c*n**2 from (d*n - e)
pop bc
ld a, [hProduct + 3]
sub b
ld [hMultiplicand + 2], a
pop bc
ld a, [hProduct + 2]
sbc b
ld [hMultiplicand + 1], a
pop bc
ld a, [hProduct + 1]
sbc b
ld [hMultiplicand], a
.done_quadratic
; Add (a/b)*n**3 to (d*n - e +/- c*n**2)
pop bc
ld a, [hProduct + 3]
add b
ld [hMultiplicand + 2], a
pop bc
ld a, [hProduct + 2]
adc b
ld [hMultiplicand + 1], a
pop bc
ld a, [hProduct + 1]
adc b
ld [hMultiplicand], a
ret
.LevelSquared: ; 50eed
xor a
ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
ld a, d
ld [hMultiplicand + 2], a
ld [hMultiplier], a
jp Multiply
INCLUDE "data/growth_rates.asm"

70
engine/flag_predef.asm Normal file
View File

@@ -0,0 +1,70 @@
FlagPredef: ; 4d7c1
; Perform action b on flag c in flag array hl.
; If checking a flag, check flag array d:hl unless d is 0.
; For longer flag arrays, see FlagAction.
push hl
push bc
; Divide by 8 to get the byte we want.
push bc
srl c
srl c
srl c
ld b, 0
add hl, bc
pop bc
; Which bit we want from the byte
ld a, c
and 7
ld c, a
; Shift left until we can mask the bit
ld a, 1
jr z, .shifted
.shift
add a
dec c
jr nz, .shift
.shifted
ld c, a
; What are we doing to this flag?
dec b
jr z, .set ; 1
dec b
jr z, .check ; 2
.reset
ld a, c
cpl
and [hl]
ld [hl], a
jr .done
.set
ld a, [hl]
or c
ld [hl], a
jr .done
.check
ld a, d
cp 0
jr nz, .farcheck
ld a, [hl]
and c
jr .done
.farcheck
call GetFarByte
and c
.done
pop bc
pop hl
ld c, a
ret

Some files were not shown because too many files have changed in this diff Show More