mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Merge branch 'master' into refactor-preprocessor
Conflicts: preprocessor.py Also bump the extras submodule to a version of pokemontools with a suitable version of the preprocessor. The changes from 'master' for preprocessor.py have been inserted into pokemontools prior to the submodule bump.
This commit is contained in:
commit
12c1d874b9
6
Makefile
6
Makefile
@ -7,8 +7,8 @@ PNG_GFX := $(shell find gfx/ -type f -name '*.png')
|
||||
LZ_GFX := $(shell find gfx/ -type f -name '*.lz')
|
||||
TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp')
|
||||
|
||||
all: pokecrystal.gbc
|
||||
cmp baserom.gbc $<
|
||||
all: baserom.gbc pokecrystal.gbc
|
||||
cmp baserom.gbc pokecrystal.gbc
|
||||
clean:
|
||||
rm -f pokecrystal.o pokecrystal.gbc
|
||||
@echo 'rm -f $(TEXTFILES:.asm=.tx)'
|
||||
@ -19,6 +19,8 @@ pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constan
|
||||
.asm.tx:
|
||||
$(eval TEXTQUEUE := $(TEXTQUEUE) $<)
|
||||
@rm -f $@
|
||||
baserom.gbc:
|
||||
python -c "import os; assert 'baserom.gbc' in os.listdir('.'), 'Wait! Need baserom.gbc first. Check README and INSTALL for details.';"
|
||||
|
||||
pokecrystal.gbc: pokecrystal.o
|
||||
rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<
|
||||
|
@ -129,7 +129,7 @@ AIScoring_RedStatMods: ; 385e0
|
||||
jr .checkmove
|
||||
|
||||
.discourage
|
||||
call RNG
|
||||
call Random
|
||||
cp 30
|
||||
jr c, .checkmove
|
||||
inc [hl]
|
||||
@ -430,7 +430,7 @@ AIScoring_LeechHit: ; 387f7
|
||||
ret
|
||||
|
||||
.asm_38815
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $64
|
||||
ret c
|
||||
@ -575,7 +575,7 @@ AIScoring_Explosion: ; 388a6
|
||||
call AICheckEnemyQuarterHP
|
||||
ret nc
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 20
|
||||
ret c
|
||||
|
||||
@ -588,7 +588,7 @@ AIScoring_Explosion: ; 388a6
|
||||
|
||||
|
||||
AIScoring_DreamEater: ; 388ca
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $19
|
||||
ret c
|
||||
@ -612,7 +612,7 @@ AIScoring_EvasionUp: ; 388d4
|
||||
bit 0, a
|
||||
jr nz, .asm_388ef
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $b2
|
||||
jr nc, .asm_38911
|
||||
@ -628,7 +628,7 @@ AIScoring_EvasionUp: ; 388d4
|
||||
|
||||
jr nc, .asm_3890f
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $a
|
||||
jr c, .asm_388ef
|
||||
@ -683,7 +683,7 @@ AIScoring_EvasionUp: ; 388d4
|
||||
ret
|
||||
|
||||
.asm_38938
|
||||
call RNG
|
||||
call Random
|
||||
cp $50
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -744,7 +744,7 @@ AIScoring_MirrorMove: ; 3895b
|
||||
call AICompareSpeed
|
||||
|
||||
ret nc
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $19
|
||||
ret c
|
||||
@ -766,7 +766,7 @@ AIScoring_AccuracyDown: ; 38985
|
||||
bit 0, a
|
||||
jr nz, .asm_3899d
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $b2
|
||||
jr nc, .asm_389bf
|
||||
@ -782,7 +782,7 @@ AIScoring_AccuracyDown: ; 38985
|
||||
|
||||
jr nc, .asm_389bd
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $a
|
||||
jr c, .asm_3899d
|
||||
@ -837,7 +837,7 @@ AIScoring_AccuracyDown: ; 38985
|
||||
ret
|
||||
|
||||
.asm_389e6
|
||||
call RNG
|
||||
call Random
|
||||
cp $50
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -878,7 +878,7 @@ AIScoring_Haze: ; 389f5
|
||||
|
||||
.asm_38a12
|
||||
pop hl
|
||||
call RNG
|
||||
call Random
|
||||
cp $28
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -894,7 +894,7 @@ AIScoring_Haze: ; 389f5
|
||||
AIScoring_Bide: ; 38a1e
|
||||
call AICheckEnemyMaxHP
|
||||
ret c
|
||||
call RNG
|
||||
call Random
|
||||
cp $19
|
||||
ret c
|
||||
inc [hl]
|
||||
@ -926,7 +926,7 @@ AIScoring_Moonlight: ; 38a3a
|
||||
ret
|
||||
|
||||
.asm_38a45
|
||||
call RNG
|
||||
call Random
|
||||
cp $19
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -948,7 +948,7 @@ AIScoring_LightScreen:
|
||||
AIScoring_Reflect: ; 38a54
|
||||
call AICheckEnemyMaxHP
|
||||
ret c
|
||||
call RNG
|
||||
call Random
|
||||
cp $14
|
||||
ret c
|
||||
inc [hl]
|
||||
@ -1041,7 +1041,7 @@ AIScoring_Unused2B: ; 38a9c
|
||||
ret c
|
||||
|
||||
.asm_38acd
|
||||
call RNG
|
||||
call Random
|
||||
cp $c8
|
||||
ret c
|
||||
|
||||
@ -1061,7 +1061,7 @@ AIScoring_Unused2B: ; 38a9c
|
||||
AIScoring_Confuse: ; 38adb
|
||||
call AICheckPlayerHalfHP
|
||||
ret c
|
||||
call RNG
|
||||
call Random
|
||||
cp $19
|
||||
jr c, .asm_38ae7
|
||||
inc [hl]
|
||||
@ -1156,7 +1156,7 @@ AIScoring_SpeedDownHit: ; 38b40
|
||||
ret nz
|
||||
call AICompareSpeed
|
||||
ret c
|
||||
call RNG
|
||||
call Random
|
||||
cp 30
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -1183,7 +1183,7 @@ AIScoring_HyperBeam: ; 38b63
|
||||
ret
|
||||
|
||||
.asm_38b72
|
||||
call RNG
|
||||
call Random
|
||||
cp 40
|
||||
ret c
|
||||
inc [hl]
|
||||
@ -1334,7 +1334,7 @@ AIScoring_Counter: ; 38bf1
|
||||
|
||||
|
||||
.asm_38c30
|
||||
call RNG
|
||||
call Random
|
||||
cp $64
|
||||
jr c, .asm_38c38
|
||||
|
||||
@ -1388,7 +1388,7 @@ AIScoring_Encore: ; 38c3b
|
||||
jr nc, .asm_38c81
|
||||
|
||||
.asm_38c78
|
||||
call RNG
|
||||
call Random
|
||||
cp $46
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -1527,7 +1527,7 @@ AIScoring_Spite: ; 38cd5
|
||||
cp $f
|
||||
jr nc, .asm_38d0b
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp $64
|
||||
ret nc
|
||||
|
||||
@ -1536,7 +1536,7 @@ AIScoring_Spite: ; 38cd5
|
||||
ret
|
||||
|
||||
.asm_38d0d
|
||||
call RNG
|
||||
call Random
|
||||
cp $64
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -1700,7 +1700,7 @@ AIScoring_Conversion2: ; 38d98
|
||||
ret
|
||||
|
||||
.asm_38dc9
|
||||
call RNG
|
||||
call Random
|
||||
|
||||
cp $19
|
||||
ret c
|
||||
@ -1722,7 +1722,7 @@ AIScoring_Disable: ; 38dd1
|
||||
pop hl
|
||||
jr nc, .asm_38dee
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 100
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -1734,7 +1734,7 @@ AIScoring_Disable: ; 38dd1
|
||||
ret nz
|
||||
|
||||
.asm_38df3
|
||||
call RNG
|
||||
call Random
|
||||
cp 20
|
||||
ret c
|
||||
inc [hl]
|
||||
@ -1961,7 +1961,7 @@ AIScoring_Protect: ; 38ed2
|
||||
inc [hl]
|
||||
|
||||
.asm_38f14
|
||||
call RNG
|
||||
call Random
|
||||
cp 20
|
||||
ret c
|
||||
inc [hl]
|
||||
@ -1985,14 +1985,14 @@ AIScoring_Foresight: ; 38f1d
|
||||
cp GHOST
|
||||
jr z, .asm_38f41
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 20
|
||||
ret c
|
||||
inc [hl]
|
||||
ret
|
||||
|
||||
.asm_38f41
|
||||
call RNG
|
||||
call Random
|
||||
cp 100
|
||||
ret c
|
||||
dec [hl]
|
||||
@ -2169,7 +2169,7 @@ AIScoring_Rollout: ; 38fef
|
||||
cp 8
|
||||
jr nc, .asm_39020
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 200
|
||||
ret nc
|
||||
dec [hl]
|
||||
@ -2196,7 +2196,7 @@ AIScoring_Attract: ; 39026
|
||||
ret
|
||||
|
||||
.asm_39032
|
||||
call RNG
|
||||
call Random
|
||||
cp 200
|
||||
ret nc
|
||||
dec [hl]
|
||||
@ -2558,7 +2558,7 @@ AIScoring_MirrorCoat: ; 3918b
|
||||
|
||||
|
||||
.asm_391ca
|
||||
call RNG
|
||||
call Random
|
||||
cp 100
|
||||
jr c, .asm_391d2
|
||||
dec [hl]
|
||||
@ -2634,7 +2634,7 @@ AIScoring_Solarbeam: ; 3920b
|
||||
cp WEATHER_RAIN
|
||||
ret nz
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 25 ; 1/10
|
||||
ret c
|
||||
|
||||
@ -2657,7 +2657,7 @@ AIScoring_Thunder: ; 39225
|
||||
cp WEATHER_SUN
|
||||
ret nz
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 25 ; 1/10
|
||||
ret c
|
||||
|
||||
@ -3150,7 +3150,7 @@ AIScoring_Cautious: ; 39418
|
||||
pop hl
|
||||
jr nc, .asm_39425
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 230
|
||||
ret nc
|
||||
|
||||
@ -3274,7 +3274,7 @@ AIScoring_Risky: ; 394a9
|
||||
call AICheckEnemyMaxHP
|
||||
jr c, .nextmove
|
||||
|
||||
call RNG
|
||||
call Random
|
||||
cp 200 ; 1/5
|
||||
jr c, .nextmove
|
||||
|
||||
@ -3347,14 +3347,14 @@ AIGetEnemyMove: ; 39508
|
||||
|
||||
|
||||
Function_0x39521: ; 39521
|
||||
call RNG
|
||||
call Random
|
||||
cp 50 ; 1/5
|
||||
ret
|
||||
; 39527
|
||||
|
||||
|
||||
Function_0x39527: ; 39527
|
||||
call RNG
|
||||
call Random
|
||||
cp $80 ; 1/2
|
||||
ret
|
||||
; 3952d
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,8 @@ INCLUDE "constants/map_constants.asm"
|
||||
INCLUDE "constants/item_constants.asm"
|
||||
INCLUDE "constants/trainer_constants.asm"
|
||||
INCLUDE "constants/script_constants.asm"
|
||||
INCLUDE "constants/event_flags.asm"
|
||||
INCLUDE "constants/engine_flags.asm"
|
||||
INCLUDE "constants/music_constants.asm"
|
||||
|
||||
|
||||
@ -231,6 +233,7 @@ PREDEF_PRINT_MOVE_DESCRIPTION EQU $11
|
||||
PREDEF_UPDATE_PLAYER_HUD EQU $12
|
||||
PREDEF_FILL_BOX EQU $13
|
||||
PREDEF_UPDATE_ENEMY_HUD EQU $15
|
||||
PREDEF_START_BATTLE EQU $16
|
||||
PREDEF_FILL_IN_EXP_BAR EQU $17
|
||||
PREDEF_FILLMOVES EQU $1B
|
||||
PREDEF_GET_GENDER EQU $24
|
||||
@ -243,6 +246,7 @@ PREDEF_PRINT_TYPE EQU $2B
|
||||
PREDEF_GET_UNOWN_LETTER EQU $2D
|
||||
PREDEF_LOAD_SGB_LAYOUT EQU $31
|
||||
PREDEF_CHECK_CONTEST_MON EQU $33
|
||||
PREDEF_BATTLE_TRANSITION EQU $34
|
||||
PREDEF_PARTYMON_ITEM_NAME EQU $3B
|
||||
PREDEF_DECOMPRESS EQU $40
|
||||
|
||||
|
163
constants/engine_flags.asm
Normal file
163
constants/engine_flags.asm
Normal file
@ -0,0 +1,163 @@
|
||||
ENGINE_RADIO_CARD EQU $00
|
||||
ENGINE_MAP_CARD EQU $01
|
||||
ENGINE_PHONE_CARD EQU $02
|
||||
ENGINE_EXPN_CARD EQU $03
|
||||
ENGINE_POKEGEAR EQU $04
|
||||
ENGINE_DAYCARE_MONS_ARE_COMPATIBLE EQU $05
|
||||
ENGINE_DAYCARE_MAN_HAS_MON EQU $06
|
||||
ENGINE_DAYCARE_LADY_HAS_MON EQU $07
|
||||
ENGINE_MOM_SAVING_MONEY EQU $08
|
||||
ENGINE_DST EQU $09
|
||||
ENGINE_0A EQU $0a
|
||||
ENGINE_POKEDEX EQU $0b
|
||||
ENGINE_UNOWN_DEX EQU $0c
|
||||
ENGINE_POKERUS EQU $0d
|
||||
ENGINE_ROCKET_SIGNAL_ON_CH20 EQU $0e
|
||||
ENGINE_CREDITS_SKIP EQU $0f
|
||||
ENGINE_BUG_CONTEST_ON EQU $10
|
||||
ENGINE_BUG_CONTEST_TIMER EQU $11
|
||||
ENGINE_ROCKETS_IN_RADIO_TOWER EQU $12
|
||||
ENGINE_BIKE_SHOP_CALL_ENABLED EQU $13
|
||||
ENGINE_14 EQU $14
|
||||
ENGINE_GIVE_POKERUS EQU $15
|
||||
ENGINE_16 EQU $16
|
||||
ENGINE_ROCKETS_IN_MAHOGANY EQU $17
|
||||
ENGINE_STRENGTH_ACTIVE EQU $18
|
||||
ENGINE_ALWAYS_ON_BIKE EQU $19
|
||||
ENGINE_DOWNHILL EQU $1a
|
||||
ENGINE_ZEPHYRBADGE EQU $1b
|
||||
ENGINE_HIVEBADGE EQU $1c
|
||||
ENGINE_PLAINBADGE EQU $1d
|
||||
ENGINE_FOGBADGE EQU $1e
|
||||
ENGINE_MINERALBADGE EQU $1f
|
||||
ENGINE_STORMBADGE EQU $20
|
||||
ENGINE_GLACIERBADGE EQU $21
|
||||
ENGINE_RISINGBADGE EQU $22
|
||||
ENGINE_BOULDERBADGE EQU $23
|
||||
ENGINE_CASCADEBADGE EQU $24
|
||||
ENGINE_THUNDERBADGE EQU $25
|
||||
ENGINE_RAINBOWBADGE EQU $26
|
||||
ENGINE_SOULBADGE EQU $27
|
||||
ENGINE_MARSHBADGE EQU $28
|
||||
ENGINE_VOLCANOBADGE EQU $29
|
||||
ENGINE_EARTHBADGE EQU $2a
|
||||
ENGINE_UNLOCKED_UNOWNS_1 EQU $2b
|
||||
ENGINE_UNLOCKED_UNOWNS_2 EQU $2c
|
||||
ENGINE_UNLOCKED_UNOWNS_3 EQU $2d
|
||||
ENGINE_UNLOCKED_UNOWNS_4 EQU $2e
|
||||
ENGINE_UNLOCKED_UNOWNS_5 EQU $2f
|
||||
ENGINE_UNLOCKED_UNOWNS_6 EQU $30
|
||||
ENGINE_UNLOCKED_UNOWNS_7 EQU $31
|
||||
ENGINE_UNLOCKED_UNOWNS_8 EQU $32
|
||||
ENGINE_FLYPOINT_KRISS_HOUSE EQU $33
|
||||
ENGINE_FLYPOINT_VIRIDIAN_POKECENTER EQU $34
|
||||
ENGINE_FLYPOINT_PALLET EQU $35
|
||||
ENGINE_FLYPOINT_VIRIDIAN EQU $36
|
||||
ENGINE_FLYPOINT_PEWTER EQU $37
|
||||
ENGINE_FLYPOINT_CERULEAN EQU $38
|
||||
ENGINE_FLYPOINT_ROCK_TUNNEL EQU $39
|
||||
ENGINE_FLYPOINT_VERMILION EQU $3a
|
||||
ENGINE_FLYPOINT_LAVENDER EQU $3b
|
||||
ENGINE_FLYPOINT_SAFFRON EQU $3c
|
||||
ENGINE_FLYPOINT_CELADON EQU $3d
|
||||
ENGINE_FLYPOINT_FUCHSIA EQU $3e
|
||||
ENGINE_FLYPOINT_CINNABAR EQU $3f
|
||||
ENGINE_FLYPOINT_INDIGO_PLATEAU EQU $40
|
||||
ENGINE_FLYPOINT_NEW_BARK EQU $41
|
||||
ENGINE_FLYPOINT_CHERRYGROVE EQU $42
|
||||
ENGINE_FLYPOINT_VIOLET EQU $43
|
||||
ENGINE_FLYPOINT_AZALEA EQU $44
|
||||
ENGINE_FLYPOINT_CIANWOOD EQU $45
|
||||
ENGINE_FLYPOINT_GOLDENROD EQU $46
|
||||
ENGINE_FLYPOINT_OLIVINE EQU $47
|
||||
ENGINE_FLYPOINT_ECRUTEAK EQU $48
|
||||
ENGINE_FLYPOINT_MAHOGANY EQU $49
|
||||
ENGINE_FLYPOINT_LAKE_OF_RAGE EQU $4a
|
||||
ENGINE_FLYPOINT_BLACKTHORN EQU $4b
|
||||
ENGINE_FLYPOINT_SILVER_CAVE EQU $4c
|
||||
ENGINE_FLYPOINT_UNUSED EQU $4d
|
||||
ENGINE_LUCKY_NUMBER_SHOW EQU $4e
|
||||
ENGINE_4F EQU $4f
|
||||
ENGINE_KURT_MAKING_BALLS EQU $50
|
||||
ENGINE_51 EQU $51
|
||||
ENGINE_SPECIAL_WILDDATA EQU $52
|
||||
ENGINE_TIME_CAPSULE EQU $53
|
||||
ENGINE_ALL_FRUIT_TREES EQU $54
|
||||
ENGINE_SHUCKLE_GIVEN EQU $55
|
||||
ENGINE_GOLDENROD_UNDERGROUND_MERCHANT_CLOSED EQU $56
|
||||
ENGINE_FOUGHT_IN_TRAINER_HALL_TODAY EQU $57
|
||||
ENGINE_MT_MOON_SQUARE_CLEFAIRY EQU $58
|
||||
ENGINE_UNION_CAVE_LAPRAS EQU $59
|
||||
ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT EQU $5a
|
||||
ENGINE_GOLDENROD_MALL_5F_HAPPINESS_EVENT EQU $5b
|
||||
ENGINE_TEA_IN_BLUES_HOUSE EQU $5c
|
||||
ENGINE_INDIGO_PLATEAU_RIVAL_FIGHT EQU $5d
|
||||
ENGINE_5E EQU $5e
|
||||
ENGINE_5F EQU $5f
|
||||
ENGINE_60 EQU $60
|
||||
ENGINE_GOLDENROD_DEPT_STORE_SALE_IS_ON EQU $61
|
||||
ENGINE_62 EQU $62
|
||||
ENGINE_PLAYER_IS_FEMALE EQU $63
|
||||
ENGINE_HAVE_EXAMINED_GS_BALL EQU $64
|
||||
ENGINE_JACK EQU $65
|
||||
ENGINE_HUEY EQU $66
|
||||
ENGINE_GAVEN EQU $67
|
||||
ENGINE_BETH EQU $68
|
||||
ENGINE_JOSE EQU $69
|
||||
ENGINE_REENA EQU $6a
|
||||
ENGINE_JOEY EQU $6b
|
||||
ENGINE_WADE EQU $6c
|
||||
ENGINE_RALPH EQU $6d
|
||||
ENGINE_LIZ EQU $6e
|
||||
ENGINE_ANTHONY EQU $6f
|
||||
ENGINE_TODD EQU $70
|
||||
ENGINE_GINA EQU $71
|
||||
ENGINE_ARNIE EQU $72
|
||||
ENGINE_ALAN EQU $73
|
||||
ENGINE_DANA EQU $74
|
||||
ENGINE_CHAD EQU $75
|
||||
ENGINE_TULLY EQU $76
|
||||
ENGINE_BRENT EQU $77
|
||||
ENGINE_TIFFANY EQU $78
|
||||
ENGINE_VANCE EQU $79
|
||||
ENGINE_WILTON EQU $7a
|
||||
ENGINE_PARRY EQU $7b
|
||||
ENGINE_ERIN EQU $7c
|
||||
ENGINE_BEVERLY_HAS_NUGGET EQU $7d
|
||||
ENGINE_JOSE_HAS_STAR_PIECE EQU $7e
|
||||
ENGINE_WADE_HAS_ITEM EQU $7f
|
||||
ENGINE_GINA_HAS_LEAF_STONE EQU $80
|
||||
ENGINE_ALAN_HAS_FIRE_STONE EQU $81
|
||||
ENGINE_LIZ_HAS_THUNDERSTONE EQU $82
|
||||
ENGINE_DEREK_HAS_NUGGET EQU $83
|
||||
ENGINE_TULLY_HAS_WATER_STONE EQU $84
|
||||
ENGINE_TIFFANY_HAS_PINK_BOW EQU $85
|
||||
ENGINE_WILTON_HAS_ITEM EQU $86
|
||||
ENGINE_87 EQU $87
|
||||
ENGINE_88 EQU $88
|
||||
ENGINE_89 EQU $89
|
||||
ENGINE_8A EQU $8a
|
||||
ENGINE_8B EQU $8b
|
||||
ENGINE_8C EQU $8c
|
||||
ENGINE_8D EQU $8d
|
||||
ENGINE_8E EQU $8e
|
||||
ENGINE_8F EQU $8f
|
||||
ENGINE_90 EQU $90
|
||||
ENGINE_91 EQU $91
|
||||
ENGINE_92 EQU $92
|
||||
ENGINE_93 EQU $93
|
||||
ENGINE_94 EQU $94
|
||||
ENGINE_95 EQU $95
|
||||
ENGINE_96 EQU $96
|
||||
ENGINE_97 EQU $97
|
||||
ENGINE_98 EQU $98
|
||||
ENGINE_99 EQU $99
|
||||
ENGINE_9A EQU $9a
|
||||
ENGINE_9B EQU $9b
|
||||
ENGINE_9C EQU $9c
|
||||
ENGINE_9D EQU $9d
|
||||
ENGINE_9E EQU $9e
|
||||
ENGINE_KRIS_IN_CABLE_CLUB EQU $9f
|
||||
ENGINE_DUNSPARCE_SWARM EQU $a0
|
||||
ENGINE_YANMA_SWARM EQU $a1
|
||||
|
6
constants/event_flags.asm
Normal file
6
constants/event_flags.asm
Normal file
@ -0,0 +1,6 @@
|
||||
EVENT_FOUGHT_SUDOWOODO EQU $02a
|
||||
EVENT_FOUGHT_HO_OH EQU $317
|
||||
EVENT_FOUGHT_LUGIA EQU $318
|
||||
EVENT_FOUGHT_SUICUNE EQU $335
|
||||
EVENT_FOUGHT_SNORLAX EQU $750
|
||||
|
@ -1,3 +1,5 @@
|
||||
NUM_POKEMON EQU 251
|
||||
|
||||
BULBASAUR EQU 1
|
||||
IVYSAUR EQU 2
|
||||
VENUSAUR EQU 3
|
||||
|
431
engine/copy.asm
Normal file
431
engine/copy.asm
Normal file
@ -0,0 +1,431 @@
|
||||
; Functions to copy data from ROM.
|
||||
|
||||
|
||||
Functiondc9: ; dc9
|
||||
ld a, [rLCDC]
|
||||
bit 7, a
|
||||
jp z, Copy2bpp
|
||||
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, BANK(Function104284)
|
||||
rst Bankswitch
|
||||
call Function104284
|
||||
pop af
|
||||
rst Bankswitch
|
||||
|
||||
ret
|
||||
; ddc
|
||||
|
||||
Functionddc: ; ddc
|
||||
ld a, [rLCDC]
|
||||
bit 7, a
|
||||
jp z, Copy1bpp
|
||||
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, BANK(Function1042b2)
|
||||
rst Bankswitch
|
||||
call Function1042b2
|
||||
pop af
|
||||
rst Bankswitch
|
||||
|
||||
ret
|
||||
; def
|
||||
|
||||
Functiondef: ; def
|
||||
ld [hBuffer], a
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, [hBuffer]
|
||||
rst Bankswitch
|
||||
call FarCopyBytesDouble
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; dfd
|
||||
|
||||
Functiondfd: ; dfd
|
||||
dec c
|
||||
ld a, [hBGMapMode]
|
||||
push af
|
||||
xor a
|
||||
ld [hBGMapMode], a
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, b
|
||||
rst Bankswitch
|
||||
|
||||
.asm_e09
|
||||
ld a, d
|
||||
ld [rHDMA1], a
|
||||
ld a, e
|
||||
and $f0
|
||||
ld [rHDMA2], a
|
||||
ld a, h
|
||||
and $1f
|
||||
ld [rHDMA3], a
|
||||
ld a, l
|
||||
and $f0
|
||||
ld [rHDMA4], a
|
||||
ld a, c
|
||||
cp $8
|
||||
jr c, .asm_e3c
|
||||
sub $8
|
||||
ld c, a
|
||||
ld a, $f
|
||||
ld [hDMATransfer], a
|
||||
call DelayFrame
|
||||
ld a, l
|
||||
add $0
|
||||
ld l, a
|
||||
ld a, h
|
||||
adc $1
|
||||
ld h, a
|
||||
ld a, e
|
||||
add $0
|
||||
ld e, a
|
||||
ld a, d
|
||||
adc $1
|
||||
ld d, a
|
||||
jr .asm_e09
|
||||
|
||||
.asm_e3c
|
||||
ld a, c
|
||||
and $7f
|
||||
ld [hDMATransfer], a
|
||||
call DelayFrame
|
||||
pop af
|
||||
rst Bankswitch
|
||||
|
||||
pop af
|
||||
ld [hBGMapMode], a
|
||||
ret
|
||||
; e4a
|
||||
|
||||
|
||||
|
||||
Functione4a: ; e4a
|
||||
ld a, $5
|
||||
ld hl, $4135
|
||||
rst FarCall
|
||||
ret
|
||||
; e51
|
||||
|
||||
|
||||
|
||||
Functione51: ; e51
|
||||
ld a, $3e
|
||||
ld hl, $7449
|
||||
rst FarCall
|
||||
ret
|
||||
; e58
|
||||
|
||||
Functione58: ; e58
|
||||
ld a, $3e
|
||||
ld hl, $74be
|
||||
rst FarCall
|
||||
ret
|
||||
; e5f
|
||||
|
||||
|
||||
|
||||
Functione5f: ; e5f
|
||||
ld a, $3e
|
||||
ld hl, $748a
|
||||
rst FarCall
|
||||
ld a, $3e
|
||||
ld hl, $74b0
|
||||
rst FarCall
|
||||
ret
|
||||
; e6c
|
||||
|
||||
Functione6c: ; e6c
|
||||
ld a, $3e
|
||||
ld hl, $74b0
|
||||
rst FarCall
|
||||
ret
|
||||
; e73
|
||||
|
||||
Functione73: ; e73
|
||||
push de
|
||||
ld a, $0
|
||||
call GetSRAMBank
|
||||
push bc
|
||||
ld de, $a000
|
||||
ld a, b
|
||||
call FarDecompress
|
||||
pop bc
|
||||
pop hl
|
||||
ld de, $a000
|
||||
call Request2bpp
|
||||
call CloseSRAM
|
||||
ret
|
||||
; e8d
|
||||
|
||||
|
||||
|
||||
FarCopyBytes: ; e8d
|
||||
; copy bc bytes from a:hl to de
|
||||
|
||||
ld [hBuffer], a
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, [hBuffer]
|
||||
rst Bankswitch
|
||||
|
||||
call CopyBytes
|
||||
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; 0xe9b
|
||||
|
||||
|
||||
FarCopyBytesDouble: ; e9b
|
||||
; 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, [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
|
||||
|
||||
.loop
|
||||
ld a, [de]
|
||||
inc de
|
||||
ld [hli], a
|
||||
ld [hli], a
|
||||
.dec
|
||||
dec c
|
||||
jr nz, .loop
|
||||
dec b
|
||||
jr nz, .loop
|
||||
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; 0xeba
|
||||
|
||||
|
||||
Request2bpp: ; eba
|
||||
ld a, [hBGMapMode]
|
||||
push af
|
||||
xor a
|
||||
ld [hBGMapMode], a
|
||||
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, b
|
||||
rst Bankswitch
|
||||
|
||||
ld a, [$ffd3]
|
||||
push af
|
||||
|
||||
ld a, $8
|
||||
ld [$ffd3], a
|
||||
ld a, [InLinkBattle]
|
||||
cp $4
|
||||
jr nz, .asm_edc
|
||||
ld a, [$ffe9]
|
||||
and a
|
||||
jr nz, .asm_edc
|
||||
ld a, $6
|
||||
ld [$ffd3], a
|
||||
|
||||
.asm_edc
|
||||
ld a, e
|
||||
ld [$cf68], a
|
||||
ld a, d
|
||||
ld [$cf69], a
|
||||
ld a, l
|
||||
ld [$cf6a], a
|
||||
ld a, h
|
||||
ld [$cf6b], a
|
||||
|
||||
.asm_eec
|
||||
ld a, c
|
||||
ld hl, $ffd3
|
||||
cp [hl]
|
||||
jr nc, .asm_f08
|
||||
|
||||
ld [$cf67], a
|
||||
.wait
|
||||
call DelayFrame
|
||||
ld a, [$cf67]
|
||||
and a
|
||||
jr nz, .wait
|
||||
|
||||
pop af
|
||||
ld [$ffd3], a
|
||||
|
||||
pop af
|
||||
rst Bankswitch
|
||||
|
||||
pop af
|
||||
ld [hBGMapMode], a
|
||||
ret
|
||||
|
||||
.asm_f08
|
||||
ld a, [$ffd3]
|
||||
ld [$cf67], a
|
||||
.asm_f0d
|
||||
call DelayFrame
|
||||
ld a, [$cf67]
|
||||
and a
|
||||
jr nz, .asm_f0d
|
||||
ld a, c
|
||||
ld hl, $ffd3
|
||||
sub [hl]
|
||||
ld c, a
|
||||
jr .asm_eec
|
||||
; f1e
|
||||
|
||||
|
||||
Request1bpp: ; f1e
|
||||
ld a, [hBGMapMode]
|
||||
push af
|
||||
xor a
|
||||
ld [hBGMapMode], a
|
||||
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, b
|
||||
rst Bankswitch
|
||||
|
||||
ld a, [$ffd3]
|
||||
push af
|
||||
|
||||
ld a, $8
|
||||
ld [$ffd3], a
|
||||
ld a, [InLinkBattle]
|
||||
cp $4
|
||||
jr nz, .asm_f40
|
||||
ld a, [$ffe9]
|
||||
and a
|
||||
jr nz, .asm_f40
|
||||
ld a, $6
|
||||
ld [$ffd3], a
|
||||
|
||||
.asm_f40
|
||||
ld a, e
|
||||
ld [$cf6d], a
|
||||
ld a, d
|
||||
ld [$cf6e], a
|
||||
ld a, l
|
||||
ld [$cf6f], a
|
||||
ld a, h
|
||||
ld [$cf70], a
|
||||
.asm_f50
|
||||
ld a, c
|
||||
ld hl, $ffd3
|
||||
cp [hl]
|
||||
jr nc, .asm_f6c
|
||||
|
||||
ld [$cf6c], a
|
||||
.wait
|
||||
call DelayFrame
|
||||
ld a, [$cf6c]
|
||||
and a
|
||||
jr nz, .wait
|
||||
|
||||
pop af
|
||||
ld [$ffd3], a
|
||||
|
||||
pop af
|
||||
rst Bankswitch
|
||||
|
||||
pop af
|
||||
ld [hBGMapMode], a
|
||||
ret
|
||||
|
||||
.asm_f6c
|
||||
ld a, [$ffd3]
|
||||
ld [$cf6c], a
|
||||
.asm_f71
|
||||
call DelayFrame
|
||||
ld a, [$cf6c]
|
||||
and a
|
||||
jr nz, .asm_f71
|
||||
ld a, c
|
||||
ld hl, $ffd3
|
||||
sub [hl]
|
||||
ld c, a
|
||||
jr .asm_f50
|
||||
; f82
|
||||
|
||||
|
||||
Get2bpp: ; f82
|
||||
ld a, [rLCDC]
|
||||
bit 7, a
|
||||
jp nz, Request2bpp
|
||||
|
||||
Copy2bpp: ; f89
|
||||
; copy c 2bpp tiles from b:de to hl
|
||||
|
||||
push hl
|
||||
ld h, d
|
||||
ld l, e
|
||||
pop de
|
||||
|
||||
; bank
|
||||
ld a, b
|
||||
|
||||
; bc = c * $10
|
||||
push af
|
||||
swap c
|
||||
ld a, $f
|
||||
and c
|
||||
ld b, a
|
||||
ld a, $f0
|
||||
and c
|
||||
ld c, a
|
||||
pop af
|
||||
|
||||
jp FarCopyBytes
|
||||
; f9d
|
||||
|
||||
|
||||
Get1bpp: ; f9d
|
||||
ld a, [rLCDC]
|
||||
bit 7, a
|
||||
jp nz, Request1bpp
|
||||
|
||||
Copy1bpp: ; fa4
|
||||
; copy c 1bpp tiles from b:de to hl
|
||||
|
||||
push de
|
||||
ld d, h
|
||||
ld e, l
|
||||
|
||||
; bank
|
||||
ld a, b
|
||||
|
||||
; bc = c * $10 / 2
|
||||
push af
|
||||
ld h, 0
|
||||
ld l, c
|
||||
add hl, hl
|
||||
add hl, hl
|
||||
add hl, hl
|
||||
ld b, h
|
||||
ld c, l
|
||||
pop af
|
||||
|
||||
pop hl
|
||||
jp FarCopyBytesDouble
|
||||
; fb6
|
||||
|
134
engine/fade.asm
Normal file
134
engine/fade.asm
Normal file
@ -0,0 +1,134 @@
|
||||
; Functions to fade the screen in and out.
|
||||
|
||||
|
||||
Function48c: ; 48c
|
||||
ld a, [TimeOfDayPal]
|
||||
ld b, a
|
||||
ld hl, IncGradGBPalTable_11
|
||||
ld a, l
|
||||
sub b
|
||||
ld l, a
|
||||
jr nc, .asm_499
|
||||
dec h
|
||||
|
||||
.asm_499
|
||||
ld a, [hli]
|
||||
ld [rBGP], a
|
||||
ld a, [hli]
|
||||
ld [rOBP0], a
|
||||
ld a, [hli]
|
||||
ld [rOBP1], a
|
||||
ret
|
||||
; 4a3
|
||||
|
||||
|
||||
Function4a3: ; 4a3
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_4af
|
||||
ld hl, IncGradGBPalTable_00
|
||||
ld b, 4
|
||||
jr FadeOut
|
||||
|
||||
.asm_4af
|
||||
ld hl, IncGradGBPalTable_08
|
||||
ld b, 4
|
||||
jr FadeOut
|
||||
; 4b6
|
||||
|
||||
Function4b6: ; 4b6
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_4c2
|
||||
ld hl, IncGradGBPalTable_05
|
||||
ld b, 3
|
||||
jr FadeOut
|
||||
|
||||
.asm_4c2
|
||||
ld hl, IncGradGBPalTable_13
|
||||
ld b, 3
|
||||
; 4c7
|
||||
|
||||
FadeOut: ; 4c7
|
||||
push de
|
||||
ld a, [hli]
|
||||
call DmgToCgbBGPals
|
||||
ld a, [hli]
|
||||
ld e, a
|
||||
ld a, [hli]
|
||||
ld d, a
|
||||
call DmgToCgbObjPals
|
||||
ld c, 8
|
||||
call DelayFrames
|
||||
pop de
|
||||
dec b
|
||||
jr nz, FadeOut
|
||||
ret
|
||||
; 4dd
|
||||
|
||||
Function4dd: ; 4dd
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_4e9
|
||||
ld hl, IncGradGBPalTable_04 - 1
|
||||
ld b, 4
|
||||
jr FadeIn
|
||||
|
||||
.asm_4e9
|
||||
ld hl, IncGradGBPalTable_12 - 1
|
||||
ld b, 4
|
||||
jr FadeIn
|
||||
; 4f0
|
||||
|
||||
Function4f0: ; 4f0
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_4fc
|
||||
ld hl, IncGradGBPalTable_07 - 1
|
||||
ld b, 3
|
||||
jr FadeIn
|
||||
|
||||
.asm_4fc
|
||||
ld hl, IncGradGBPalTable_15 - 1
|
||||
ld b, 3
|
||||
; fallthrough
|
||||
; 501
|
||||
|
||||
FadeIn: ; 501
|
||||
push de
|
||||
ld a, [hld]
|
||||
ld d, a
|
||||
ld a, [hld]
|
||||
ld e, a
|
||||
call DmgToCgbObjPals
|
||||
ld a, [hld]
|
||||
call DmgToCgbBGPals
|
||||
ld c, 8
|
||||
call DelayFrames
|
||||
pop de
|
||||
dec b
|
||||
jr nz, FadeIn
|
||||
ret
|
||||
; 517
|
||||
|
||||
|
||||
; 517
|
||||
IncGradGBPalTable_00: db %11111111, %11111111, %11111111
|
||||
IncGradGBPalTable_01: db %11111110, %11111110, %11111110
|
||||
IncGradGBPalTable_02: db %11111001, %11111001, %11111001
|
||||
IncGradGBPalTable_03: db %11100100, %11100100, %11100100
|
||||
IncGradGBPalTable_04: db %11100100, %11100100, %11100100
|
||||
IncGradGBPalTable_05: db %10010000, %10010000, %10010000
|
||||
IncGradGBPalTable_06: db %01000000, %01000000, %01000000
|
||||
IncGradGBPalTable_07: db %00000000, %00000000, %00000000
|
||||
; bgp obp1 obp2
|
||||
IncGradGBPalTable_08: db %11111111, %11111111, %11111111
|
||||
IncGradGBPalTable_09: db %11111110, %11111110, %11111000
|
||||
IncGradGBPalTable_10: db %11111001, %11100100, %11100100
|
||||
IncGradGBPalTable_11: db %11100100, %11010000, %11100000
|
||||
IncGradGBPalTable_12: db %11100100, %11010000, %11100000
|
||||
IncGradGBPalTable_13: db %10010000, %10000000, %10010000
|
||||
IncGradGBPalTable_14: db %01000000, %01000000, %01000000
|
||||
IncGradGBPalTable_15: db %00000000, %00000000, %00000000
|
||||
; 547
|
||||
|
@ -79,7 +79,7 @@ Init: ; 17d
|
||||
or c
|
||||
jr nz, .asm_1b1
|
||||
|
||||
ld sp, Stack - 1
|
||||
ld sp, Stack
|
||||
|
||||
; Clear HRAM
|
||||
ld a, [hCGB]
|
||||
|
@ -273,3 +273,219 @@ StopAutoInput: ; a0a
|
||||
ret
|
||||
; a1b
|
||||
|
||||
|
||||
Functiona1b: ; a1b
|
||||
|
||||
call DelayFrame
|
||||
|
||||
push bc
|
||||
call Functiona57
|
||||
pop bc
|
||||
|
||||
ld a, [hJoyDown]
|
||||
cp D_UP | SELECT | BUTTON_B
|
||||
jr z, .asm_a34
|
||||
|
||||
ld a, [$ffa9]
|
||||
and START | BUTTON_A
|
||||
jr nz, .asm_a34
|
||||
|
||||
dec c
|
||||
jr nz, Functiona1b
|
||||
|
||||
and a
|
||||
ret
|
||||
|
||||
.asm_a34
|
||||
scf
|
||||
ret
|
||||
; a36
|
||||
|
||||
|
||||
Functiona36: ; a36
|
||||
call DelayFrame
|
||||
call GetJoypadPublic
|
||||
ld a, [hJoyPressed]
|
||||
and BUTTON_A | BUTTON_B
|
||||
ret nz
|
||||
call RTC
|
||||
jr Functiona36
|
||||
; a46
|
||||
|
||||
Functiona46: ; a46
|
||||
ld a, [hOAMUpdate]
|
||||
push af
|
||||
ld a, 1
|
||||
ld [hOAMUpdate], a
|
||||
call WaitBGMap
|
||||
call Functiona36
|
||||
pop af
|
||||
ld [hOAMUpdate], a
|
||||
ret
|
||||
; a57
|
||||
|
||||
Functiona57: ; a57
|
||||
call GetJoypadPublic
|
||||
ld a, [$ffaa]
|
||||
and a
|
||||
ld a, [hJoyPressed]
|
||||
jr z, .asm_a63
|
||||
ld a, [hJoyDown]
|
||||
.asm_a63
|
||||
ld [$ffa9], a
|
||||
ld a, [hJoyPressed]
|
||||
and a
|
||||
jr z, .asm_a70
|
||||
ld a, 15
|
||||
ld [TextDelayFrames], a
|
||||
ret
|
||||
|
||||
.asm_a70
|
||||
ld a, [TextDelayFrames]
|
||||
and a
|
||||
jr z, .asm_a7a
|
||||
xor a
|
||||
ld [$ffa9], a
|
||||
ret
|
||||
|
||||
.asm_a7a
|
||||
ld a, 5
|
||||
ld [TextDelayFrames], a
|
||||
ret
|
||||
; a80
|
||||
|
||||
Functiona80: ; a80
|
||||
ld a, [$ffaf]
|
||||
push af
|
||||
ld a, [$ffb0]
|
||||
push af
|
||||
xor a
|
||||
ld [$ffaf], a
|
||||
ld a, $6
|
||||
ld [$ffb0], a
|
||||
.asm_a8d
|
||||
push hl
|
||||
ld hl, $c606
|
||||
call Functionb06
|
||||
pop hl
|
||||
call Functiona57
|
||||
ld a, [$ffa9]
|
||||
and $3
|
||||
jr z, .asm_a8d
|
||||
pop af
|
||||
ld [$ffb0], a
|
||||
pop af
|
||||
ld [$ffaf], a
|
||||
ret
|
||||
; aa5
|
||||
|
||||
Functionaa5: ; aa5
|
||||
call Functiona57
|
||||
ld a, [$ffa9]
|
||||
and BUTTON_A | BUTTON_B
|
||||
jr z, Functionaa5
|
||||
ret
|
||||
; aaf
|
||||
|
||||
Functionaaf: ; aaf
|
||||
ld a, [InLinkBattle]
|
||||
and a
|
||||
jr nz, .asm_ac1
|
||||
call Functionac6
|
||||
push de
|
||||
ld de, SFX_READ_TEXT_2
|
||||
call StartSFX
|
||||
pop de
|
||||
ret
|
||||
|
||||
.asm_ac1
|
||||
ld c, 65
|
||||
jp DelayFrames
|
||||
; ac6
|
||||
|
||||
Functionac6: ; ac6
|
||||
ld a, [hOAMUpdate]
|
||||
push af
|
||||
ld a, $1
|
||||
ld [hOAMUpdate], a
|
||||
ld a, [InputType]
|
||||
or a
|
||||
jr z, .asm_ad9
|
||||
callba Function1de28a
|
||||
.asm_ad9
|
||||
call Functionaf5
|
||||
call Functiona57
|
||||
ld a, [hJoyPressed]
|
||||
and $3
|
||||
jr nz, .asm_af1
|
||||
call RTC
|
||||
ld a, $1
|
||||
ld [hBGMapMode], a
|
||||
call DelayFrame
|
||||
jr .asm_ad9
|
||||
|
||||
.asm_af1
|
||||
pop af
|
||||
ld [hOAMUpdate], a
|
||||
ret
|
||||
; af5
|
||||
|
||||
Functionaf5: ; af5
|
||||
ld a, [$ff9b]
|
||||
and $10
|
||||
jr z, .asm_aff
|
||||
ld a, $ee
|
||||
jr .asm_b02
|
||||
|
||||
.asm_aff
|
||||
ld a, [$c605]
|
||||
|
||||
.asm_b02
|
||||
ld [$c606], a
|
||||
ret
|
||||
; b06
|
||||
|
||||
Functionb06: ; b06
|
||||
push bc
|
||||
ld a, [hl]
|
||||
ld b, a
|
||||
ld a, $ee
|
||||
cp b
|
||||
pop bc
|
||||
jr nz, .asm_b27
|
||||
ld a, [$ffaf]
|
||||
dec a
|
||||
ld [$ffaf], a
|
||||
ret nz
|
||||
ld a, [$ffb0]
|
||||
dec a
|
||||
ld [$ffb0], a
|
||||
ret nz
|
||||
ld a, $7a
|
||||
ld [hl], a
|
||||
ld a, $ff
|
||||
ld [$ffaf], a
|
||||
ld a, $6
|
||||
ld [$ffb0], a
|
||||
ret
|
||||
|
||||
.asm_b27
|
||||
ld a, [$ffaf]
|
||||
and a
|
||||
ret z
|
||||
dec a
|
||||
ld [$ffaf], a
|
||||
ret nz
|
||||
dec a
|
||||
ld [$ffaf], a
|
||||
ld a, [$ffb0]
|
||||
dec a
|
||||
ld [$ffb0], a
|
||||
ret nz
|
||||
ld a, $6
|
||||
ld [$ffb0], a
|
||||
ld a, $ee
|
||||
ld [hl], a
|
||||
ret
|
||||
; b40
|
||||
|
||||
|
81
engine/lcd.asm
Normal file
81
engine/lcd.asm
Normal file
@ -0,0 +1,81 @@
|
||||
; LCD handling
|
||||
|
||||
|
||||
Function547: ; 547
|
||||
ld a, [hLCDStatCustom]
|
||||
cp rSCX & $ff
|
||||
ret nz
|
||||
ld c, a
|
||||
ld a, [LYOverrides]
|
||||
ld [$ff00+c], a
|
||||
ret
|
||||
; 552
|
||||
|
||||
|
||||
LCD: ; 552
|
||||
push af
|
||||
ld a, [hLCDStatCustom]
|
||||
and a
|
||||
jr z, .done
|
||||
|
||||
; At this point it's assumed we're in WRAM bank 5!
|
||||
push bc
|
||||
ld a, [rLY]
|
||||
ld c, a
|
||||
ld b, LYOverrides >> 8
|
||||
ld a, [bc]
|
||||
ld b, a
|
||||
ld a, [hLCDStatCustom]
|
||||
ld c, a
|
||||
ld a, b
|
||||
ld [$ff00+c], a
|
||||
pop bc
|
||||
|
||||
.done
|
||||
pop af
|
||||
reti
|
||||
; 568
|
||||
|
||||
|
||||
DisableLCD: ; 568
|
||||
; Turn the LCD off
|
||||
|
||||
; Don't need to do anything if the LCD is already off
|
||||
ld a, [rLCDC]
|
||||
bit 7, a ; lcd enable
|
||||
ret z
|
||||
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld a, [rIE]
|
||||
ld b, a
|
||||
|
||||
; Disable VBlank
|
||||
res 0, a ; vblank
|
||||
ld [rIE], a
|
||||
|
||||
.wait
|
||||
; Wait until VBlank would normally happen
|
||||
ld a, [rLY]
|
||||
cp 145
|
||||
jr nz, .wait
|
||||
|
||||
ld a, [rLCDC]
|
||||
and %01111111 ; lcd enable off
|
||||
ld [rLCDC], a
|
||||
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld a, b
|
||||
ld [rIE], a
|
||||
ret
|
||||
; 58a
|
||||
|
||||
|
||||
EnableLCD: ; 58a
|
||||
ld a, [rLCDC]
|
||||
set 7, a ; lcd enable
|
||||
ld [rLCDC], a
|
||||
ret
|
||||
; 591
|
||||
|
347
engine/palettes.asm
Normal file
347
engine/palettes.asm
Normal file
@ -0,0 +1,347 @@
|
||||
; Functions dealing with palettes.
|
||||
|
||||
|
||||
UpdatePalsIfCGB: ; c2f
|
||||
; update bgp data from BGPals
|
||||
; update obp data from OBPals
|
||||
; return carry if successful
|
||||
|
||||
; check cgb
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
ret z
|
||||
|
||||
|
||||
UpdateCGBPals: ; c33
|
||||
; return carry if successful
|
||||
; any pals to update?
|
||||
ld a, [hCGBPalUpdate]
|
||||
and a
|
||||
ret z
|
||||
|
||||
|
||||
ForceUpdateCGBPals: ; c37
|
||||
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
ld a, 5 ; BANK(BGPals)
|
||||
ld [rSVBK], a
|
||||
|
||||
ld hl, BGPals ; 5:d080
|
||||
|
||||
; copy 8 pals to bgpd
|
||||
ld a, %10000000 ; auto increment, index 0
|
||||
ld [rBGPI], a
|
||||
ld c, rBGPD % $100
|
||||
ld b, 4 ; NUM_PALS / 2
|
||||
.bgp
|
||||
rept $10
|
||||
ld a, [hli]
|
||||
ld [$ff00+c], a
|
||||
endr
|
||||
|
||||
dec b
|
||||
jr nz, .bgp
|
||||
|
||||
; hl is now 5:d0c0 OBPals
|
||||
|
||||
; 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
|
||||
rept $10
|
||||
ld a, [hli]
|
||||
ld [$ff00+c], a
|
||||
endr
|
||||
|
||||
dec b
|
||||
jr nz, .obp
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
|
||||
; clear pal update queue
|
||||
xor a
|
||||
ld [hCGBPalUpdate], a
|
||||
|
||||
scf
|
||||
ret
|
||||
; c9f
|
||||
|
||||
|
||||
DmgToCgbBGPals: ; c9f
|
||||
; exists to forego reinserting cgb-converted image data
|
||||
|
||||
; input: a -> bgp
|
||||
|
||||
ld [rBGP], a
|
||||
push af
|
||||
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .end
|
||||
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
|
||||
ld a, 5
|
||||
ld [rSVBK], a
|
||||
|
||||
; copy & reorder bg pal buffer
|
||||
ld hl, BGPals ; to
|
||||
ld de, Unkn1Pals ; from
|
||||
; order
|
||||
ld a, [rBGP]
|
||||
ld b, a
|
||||
; all pals
|
||||
ld c, 8
|
||||
call CopyPals
|
||||
; request pal update
|
||||
ld a, 1
|
||||
ld [hCGBPalUpdate], a
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
.end
|
||||
pop af
|
||||
ret
|
||||
; ccb
|
||||
|
||||
|
||||
DmgToCgbObjPals: ; ccb
|
||||
; exists to forego reinserting cgb-converted image data
|
||||
|
||||
; input: d -> obp1
|
||||
; e -> obp2
|
||||
|
||||
ld a, e
|
||||
ld [rOBP0], a
|
||||
ld a, d
|
||||
ld [rOBP1], a
|
||||
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
ret z
|
||||
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
|
||||
ld a, 5
|
||||
ld [rSVBK], a
|
||||
|
||||
; copy & reorder obj pal buffer
|
||||
ld hl, OBPals ; to
|
||||
ld de, Unkn2Pals ; from
|
||||
; order
|
||||
ld a, [rOBP0]
|
||||
ld b, a
|
||||
; all pals
|
||||
ld c, 8
|
||||
call CopyPals
|
||||
; request pal update
|
||||
ld a, 1
|
||||
ld [hCGBPalUpdate], a
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
ret
|
||||
; cf8
|
||||
|
||||
|
||||
Functioncf8: ; cf8
|
||||
ld [rOBP0], a
|
||||
push af
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_d22
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
ld a, $5
|
||||
ld [rSVBK], a
|
||||
ld hl, $d0c0
|
||||
ld de, MartPointer
|
||||
ld a, [rOBP0]
|
||||
ld b, a
|
||||
ld c, $1
|
||||
call CopyPals
|
||||
ld a, $1
|
||||
ld [hCGBPalUpdate], a
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
.asm_d22
|
||||
pop af
|
||||
ret
|
||||
; d24
|
||||
|
||||
Functiond24: ; d24
|
||||
ld [rOBP1], a
|
||||
push af
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_d4e
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
ld a, $5
|
||||
ld [rSVBK], a
|
||||
ld hl, $d0c8
|
||||
ld de, $d048
|
||||
ld a, [rOBP1]
|
||||
ld b, a
|
||||
ld c, $1
|
||||
call CopyPals
|
||||
ld a, $1
|
||||
ld [hCGBPalUpdate], a
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
.asm_d4e
|
||||
pop af
|
||||
ret
|
||||
; d50
|
||||
|
||||
|
||||
|
||||
CopyPals: ; d50
|
||||
; copy c palettes in order b from de to hl
|
||||
|
||||
push bc
|
||||
ld c, 4 ; NUM_PAL_COLORS
|
||||
.loop
|
||||
push de
|
||||
push hl
|
||||
|
||||
; get pal color
|
||||
ld a, b
|
||||
and %11 ; color
|
||||
; 2 bytes per color
|
||||
add a
|
||||
ld l, a
|
||||
ld h, 0
|
||||
add hl, de
|
||||
ld e, [hl]
|
||||
inc hl
|
||||
ld d, [hl]
|
||||
|
||||
; dest
|
||||
pop hl
|
||||
; write color
|
||||
ld [hl], e
|
||||
inc hl
|
||||
ld [hl], d
|
||||
inc hl
|
||||
; next pal color
|
||||
srl b
|
||||
srl b
|
||||
; source
|
||||
pop de
|
||||
; done pal?
|
||||
dec c
|
||||
jr nz, .loop
|
||||
|
||||
; de += 8 (next pal)
|
||||
ld a, 8 ; NUM_PAL_COLORS * 2 ; bytes per pal
|
||||
add e
|
||||
jr nc, .ok
|
||||
inc d
|
||||
.ok
|
||||
ld e, a
|
||||
|
||||
; how many more pals?
|
||||
pop bc
|
||||
dec c
|
||||
jr nz, CopyPals
|
||||
ret
|
||||
; d79
|
||||
|
||||
|
||||
Functiond79: ; d79
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
ret z
|
||||
ld a, 1
|
||||
ld [rVBK], a
|
||||
ld hl, VTiles0
|
||||
ld bc, $2000
|
||||
xor a
|
||||
call ByteFill
|
||||
ld a, 0
|
||||
ld [rVBK], a
|
||||
ret
|
||||
; d90
|
||||
|
||||
|
||||
Functiond90: ; d90
|
||||
ret
|
||||
; d91
|
||||
|
||||
|
||||
Functiond91: ; d91
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
ret z
|
||||
ld a, [rSVBK]
|
||||
push af
|
||||
ld a, 5 ; BANK(BGPals)
|
||||
ld [rSVBK], a
|
||||
ld hl, BGPals
|
||||
ld bc, $40 + $10
|
||||
xor a
|
||||
call ByteFill
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ld a, 1
|
||||
ld [hCGBPalUpdate], a
|
||||
call DelayFrame
|
||||
ret
|
||||
; db1
|
||||
|
||||
|
||||
Functiondb1: ; db1
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, BANK(Function4c000)
|
||||
rst Bankswitch
|
||||
call Function4c000
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; dbd
|
||||
|
||||
Functiondbd: ; dbd
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
ld a, BANK(Function4c03f)
|
||||
rst Bankswitch
|
||||
call Function4c03f
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; dc9
|
||||
|
@ -308,7 +308,7 @@ Script_2writetext: ; 0x96e9b
|
||||
ld h, a
|
||||
ld a, [ScriptBank]
|
||||
ld b, a
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
; 0x96eab
|
||||
|
||||
@ -323,7 +323,7 @@ Script_3writetext: ; 0x96eab
|
||||
ld l, a
|
||||
call GetScriptByte
|
||||
ld h, a
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
; 0x96ebb
|
||||
|
||||
@ -348,7 +348,7 @@ Script_repeattext: ; 0x96ebb
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
.asm_96ed8
|
||||
ret
|
||||
@ -357,7 +357,7 @@ Script_repeattext: ; 0x96ebb
|
||||
Script_closetext: ; 0x96ed9
|
||||
; script command 0x54
|
||||
|
||||
jp $0a46
|
||||
jp Functiona46
|
||||
; 0x96edc
|
||||
|
||||
Script_keeptextopen: ; 0x96edc
|
||||
@ -367,8 +367,8 @@ Script_keeptextopen: ; 0x96edc
|
||||
push af
|
||||
ld a, $1
|
||||
ld [$ffd8], a
|
||||
call $31f6
|
||||
call $0aaf
|
||||
call WaitBGMap
|
||||
call Functionaaf
|
||||
pop af
|
||||
ld [$ffd8], a
|
||||
ret
|
||||
@ -377,7 +377,7 @@ Script_keeptextopen: ; 0x96edc
|
||||
Script_yesorno: ; 0x96eed
|
||||
; script command 0x4e
|
||||
|
||||
call $1dcf
|
||||
call Function1dcf
|
||||
ld a, $0
|
||||
jr c, .asm_96ef6 ; 0x96ef2 $2
|
||||
ld a, $1
|
||||
@ -397,16 +397,16 @@ Script_loadmenudata: ; 0x96efa
|
||||
ld h, a
|
||||
ld de, $1d35
|
||||
ld a, [ScriptBank]
|
||||
call $26b7
|
||||
call $1ad2
|
||||
call Function26b7
|
||||
call Function1ad2
|
||||
ret
|
||||
; 0x96f0f
|
||||
|
||||
Script_writebackup: ; 0x96f0f
|
||||
; script command 0x50
|
||||
|
||||
call $1c17
|
||||
call $1ad2
|
||||
call Function1c17
|
||||
call Function1ad2
|
||||
ret
|
||||
; 0x96f16
|
||||
|
||||
@ -470,7 +470,7 @@ Script_storetext: ; 0x96f52
|
||||
; pointer (PointerLabelBeforeBank)
|
||||
; memory (SingleByteParam)
|
||||
|
||||
call $106c
|
||||
call Function106c
|
||||
call GetScriptByte
|
||||
ld c, a
|
||||
ld a, $47
|
||||
@ -539,7 +539,7 @@ Script_verbosegiveitem2: ; 0x96f8e
|
||||
ld a, [de]
|
||||
ld [$d10c], a
|
||||
ld hl, $d892
|
||||
call $2f66
|
||||
call Function2f66
|
||||
ld a, $1
|
||||
jr c, .asm_96fb0 ; 0x96fad $1
|
||||
xor a
|
||||
@ -561,7 +561,7 @@ Script_itemnotify: ; 0x96fc6
|
||||
call CurItemName
|
||||
ld b, BANK(PutItemInPocketText)
|
||||
ld hl, PutItemInPocketText
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
; 0x96fd5
|
||||
|
||||
@ -572,7 +572,7 @@ Script_pocketisfull: ; 0x96fd5
|
||||
call CurItemName
|
||||
ld b, BANK(PocketIsFullText)
|
||||
ld hl, PocketIsFullText
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
; 0x96fe4
|
||||
|
||||
@ -732,7 +732,7 @@ Script_askforphonenumber: ; 0x970be
|
||||
; parameters:
|
||||
; number (SingleByteParam)
|
||||
|
||||
call $1dcf
|
||||
call Function1dcf
|
||||
jr c, .asm_970d6 ; 0x970c1 $13
|
||||
call GetScriptByte
|
||||
ld c, a
|
||||
@ -814,7 +814,7 @@ Script_trainertext: ; 0x9710f
|
||||
ld l, a
|
||||
ld a, [$d03e]
|
||||
ld b, a
|
||||
call $269a
|
||||
call Function269a
|
||||
ret
|
||||
; 0x97125
|
||||
|
||||
@ -843,7 +843,7 @@ Script_trainerstatus: ; 0x97132
|
||||
ld d, [hl]
|
||||
call GetScriptByte
|
||||
ld b, a
|
||||
call BitTable1Func
|
||||
call EventFlagAction
|
||||
ld a, c
|
||||
and a
|
||||
ret z
|
||||
@ -907,7 +907,7 @@ Script_playrammusic: ; 0x9717a
|
||||
Script_playmapmusic: ; 0x97185
|
||||
; script command 0x82
|
||||
|
||||
call $3cdf
|
||||
call Function3cdf
|
||||
ret
|
||||
; 0x97189
|
||||
|
||||
@ -988,7 +988,7 @@ Script_cry: ; 0x971d1
|
||||
jr nz, .asm_971df ; 0x971da $3
|
||||
ld a, [$c2dd]
|
||||
.asm_971df
|
||||
call $37ce
|
||||
call Function37ce
|
||||
ret
|
||||
; 0x971e3
|
||||
|
||||
@ -1039,7 +1039,7 @@ Function971fa: ; 971fa
|
||||
ld h, a
|
||||
ld a, [ScriptBank]
|
||||
ld b, a
|
||||
call $26c7
|
||||
call Function26c7
|
||||
ret c
|
||||
ld a, SCRIPT_WAIT_MOVEMENT
|
||||
ld [ScriptMode], a
|
||||
@ -1145,13 +1145,13 @@ Script_spriteface: ; 0x97274
|
||||
Unknown_0x9728b: ; 0x9728b
|
||||
ld a, d
|
||||
push de
|
||||
call $18de
|
||||
call Function18de
|
||||
jr c, .asm_972b9 ; 0x97290 $27
|
||||
ld hl, $0000
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
push bc
|
||||
call $1836
|
||||
call Function1836
|
||||
pop bc
|
||||
jr c, .asm_972b9 ; 0x9729c $1b
|
||||
ld hl, $0004
|
||||
@ -1160,13 +1160,13 @@ Unknown_0x9728b: ; 0x9728b
|
||||
jr nz, .asm_972b9 ; 0x972a4 $13
|
||||
pop de
|
||||
ld a, e
|
||||
call $1af8
|
||||
call Function1af8
|
||||
ld hl, $d0ed
|
||||
bit 6, [hl]
|
||||
jr nz, .asm_972b5 ; 0x972b0 $3
|
||||
call Unknown_0x972bc
|
||||
.asm_972b5
|
||||
call $1ad2
|
||||
call Function1ad2
|
||||
ret
|
||||
.asm_972b9
|
||||
pop de
|
||||
@ -1175,7 +1175,7 @@ Unknown_0x9728b: ; 0x9728b
|
||||
; 0x972bc
|
||||
|
||||
Unknown_0x972bc: ; 0x972bc
|
||||
call $217a
|
||||
call Function217a
|
||||
ld hl, TileMap
|
||||
ld bc, $0168
|
||||
.asm_972c5
|
||||
@ -1211,7 +1211,7 @@ Script_appear: ; 0x972dd
|
||||
|
||||
call GetScriptByte
|
||||
call Unknown_0x971e3
|
||||
call $1956
|
||||
call Function1956
|
||||
ld a, [$ffaf]
|
||||
ld b, $0
|
||||
call Unknown_0x9730b
|
||||
@ -1229,7 +1229,7 @@ Script_disappear: ; 0x972ee
|
||||
jr nz, .asm_972fa ; 0x972f6 $2
|
||||
ld a, [$ffe0]
|
||||
.asm_972fa
|
||||
call $199f
|
||||
call Function199f
|
||||
ld a, [$ffaf]
|
||||
ld b, $1
|
||||
call Unknown_0x9730b
|
||||
@ -1241,7 +1241,7 @@ Script_disappear: ; 0x972ee
|
||||
|
||||
Unknown_0x9730b: ; 0x9730b
|
||||
push bc
|
||||
call $18d2
|
||||
call GetMapObject
|
||||
ld hl, $000c
|
||||
add hl, bc
|
||||
pop bc
|
||||
@ -1256,7 +1256,7 @@ Unknown_0x9730b: ; 0x9730b
|
||||
xor a
|
||||
ret
|
||||
.asm_97321
|
||||
call BitTable1Func
|
||||
call EventFlagAction
|
||||
ret
|
||||
; 0x97325
|
||||
|
||||
@ -1497,9 +1497,9 @@ Script_loadtrainer: ; 0x97424
|
||||
Script_startbattle: ; 0x97436
|
||||
; script command 0x5f
|
||||
|
||||
call $2879
|
||||
ld a, $16
|
||||
call $2d83
|
||||
call Function2879
|
||||
ld a, PREDEF_START_BATTLE
|
||||
call Predef
|
||||
ld a, [$d0ee]
|
||||
and $3f
|
||||
ld [$c2dd], a
|
||||
@ -1513,7 +1513,7 @@ Script_catchtutorial: ; 0x97447
|
||||
|
||||
call GetScriptByte
|
||||
ld [$d230], a
|
||||
call $2879
|
||||
call Function2879
|
||||
ld a, $13
|
||||
ld hl, $6554
|
||||
rst $8
|
||||
@ -1559,7 +1559,7 @@ Script_reloadmap: ; 0x97491
|
||||
ld a, $f3
|
||||
ld [$ff9f], a
|
||||
ld a, $1
|
||||
call $261b
|
||||
call Function261b
|
||||
call StopScript
|
||||
ret
|
||||
; 0x974a2
|
||||
@ -1835,7 +1835,7 @@ Script_priorityjump: ; 0x975aa
|
||||
Script_checktriggers: ; 0x975c2
|
||||
; script command 0x13
|
||||
|
||||
call $211b
|
||||
call Function211b
|
||||
jr z, .asm_975cb ; 0x975c5 $4
|
||||
ld [$c2dd], a
|
||||
ret
|
||||
@ -1855,7 +1855,7 @@ Script_checkmaptriggers: ; 0x975d1
|
||||
ld b, a
|
||||
call GetScriptByte
|
||||
ld c, a
|
||||
call $2147
|
||||
call Function2147
|
||||
ld a, d
|
||||
or e
|
||||
jr z, .asm_975e5 ; 0x975de $5
|
||||
@ -1894,7 +1894,7 @@ Script_domaptrigger: ; 0x975f5
|
||||
; fallthrough
|
||||
|
||||
Unknown_975fd: ; 0x975fd
|
||||
call $2147
|
||||
call Function2147
|
||||
ld a, d
|
||||
or e
|
||||
jr z, .asm_97608 ; 0x97602 $4
|
||||
@ -1988,7 +1988,7 @@ Script_random: ; 0x97640
|
||||
ld b, a
|
||||
.asm_97653
|
||||
push bc
|
||||
call $2f8c
|
||||
call Random
|
||||
pop bc
|
||||
ld a, [$ffe1]
|
||||
cp b
|
||||
@ -1996,7 +1996,7 @@ Script_random: ; 0x97640
|
||||
jr .asm_97666 ; 0x9765d $7
|
||||
.asm_9765f
|
||||
push bc
|
||||
call $2f8c
|
||||
call Random
|
||||
pop bc
|
||||
ld a, [$ffe1]
|
||||
.asm_97666
|
||||
@ -2004,7 +2004,7 @@ Script_random: ; 0x97640
|
||||
ld a, [$c2dd]
|
||||
ld c, a
|
||||
pop af
|
||||
call $3110
|
||||
call SimpleDivide
|
||||
ld [$c2dd], a
|
||||
ret
|
||||
; 0x97673
|
||||
@ -2091,7 +2091,7 @@ Script_pokenamemem: ; 0x976ae
|
||||
ld a, [$c2dd]
|
||||
.asm_976b7
|
||||
ld [$d265], a
|
||||
call $343b
|
||||
call GetPokemonName
|
||||
ld de, StringBuffer1
|
||||
|
||||
Unknown_976c0: ; 0x976c0
|
||||
@ -2205,7 +2205,7 @@ Script_readmoney: ; 0x97732
|
||||
call Unknown_0x97861
|
||||
ld hl, StringBuffer1
|
||||
ld bc, $4306
|
||||
call $3198
|
||||
call PrintNum
|
||||
ld de, StringBuffer1
|
||||
jp Unknown_976c0
|
||||
; 0x97747
|
||||
@ -2217,9 +2217,9 @@ Script_readcoins: ; 0x97747
|
||||
|
||||
call Unknown_0x97771
|
||||
ld hl, StringBuffer1
|
||||
ld de, $d855
|
||||
ld de, Coins
|
||||
ld bc, $4206
|
||||
call $3198
|
||||
call PrintNum
|
||||
ld de, StringBuffer1
|
||||
jp Unknown_976c0
|
||||
; 0x9775c
|
||||
@ -2233,7 +2233,7 @@ Script_RAM2MEM: ; 0x9775c
|
||||
ld de, $c2dd
|
||||
ld hl, StringBuffer1
|
||||
ld bc, $4103
|
||||
call $3198
|
||||
call PrintNum
|
||||
ld de, StringBuffer1
|
||||
jp Unknown_976c0
|
||||
; 0x97771
|
||||
@ -2320,7 +2320,7 @@ Script_giveitem: ; 0x977ca
|
||||
call GetScriptByte
|
||||
ld [$d10c], a
|
||||
ld hl, $d892
|
||||
call $2f66
|
||||
call Function2f66
|
||||
jr nc, .asm_977eb ; 0x977e3 $6
|
||||
ld a, $1
|
||||
ld [$c2dd], a
|
||||
@ -2346,7 +2346,7 @@ Script_takeitem: ; 0x977f0
|
||||
ld a, $ff
|
||||
ld [$d107], a
|
||||
ld hl, $d892
|
||||
call $2f53
|
||||
call Function2f53
|
||||
ret nc
|
||||
ld a, $1
|
||||
ld [$c2dd], a
|
||||
@ -2363,7 +2363,7 @@ Script_checkitem: ; 0x97812
|
||||
call GetScriptByte
|
||||
ld [$d106], a
|
||||
ld hl, $d892
|
||||
call $2f79
|
||||
call PickUpItem
|
||||
ret nc
|
||||
ld a, $1
|
||||
ld [$c2dd], a
|
||||
@ -2677,7 +2677,7 @@ Script_setbit1: ; 0x97988
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $1
|
||||
call BitTable1Func
|
||||
call EventFlagAction
|
||||
ret
|
||||
; 0x97996
|
||||
|
||||
@ -2691,7 +2691,7 @@ Script_clearbit1: ; 0x97996
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $0
|
||||
call BitTable1Func
|
||||
call EventFlagAction
|
||||
ret
|
||||
; 0x979a4
|
||||
|
||||
@ -2705,7 +2705,7 @@ Script_checkbit1: ; 0x979a4
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $2
|
||||
call BitTable1Func
|
||||
call EventFlagAction
|
||||
ld a, c
|
||||
and a
|
||||
jr z, .asm_979b7 ; 0x979b3 $2
|
||||
@ -2839,7 +2839,7 @@ Script_warp: ; 0x97a1d
|
||||
ld a, $f1
|
||||
ld [$ff9f], a
|
||||
ld a, $1
|
||||
call $261b
|
||||
call Function261b
|
||||
call StopScript
|
||||
ret
|
||||
.asm_97a4a
|
||||
@ -2851,7 +2851,7 @@ Script_warp: ; 0x97a1d
|
||||
ld a, $fb
|
||||
ld [$ff9f], a
|
||||
ld a, $1
|
||||
call $261b
|
||||
call Function261b
|
||||
call StopScript
|
||||
ret
|
||||
; 0x97a65
|
||||
@ -2935,8 +2935,8 @@ Script_changemap: ; 0x97ab3
|
||||
ld [$d1a1], a
|
||||
call GetScriptByte
|
||||
ld [$d1a2], a
|
||||
call $24e4
|
||||
call $2879
|
||||
call Function24e4
|
||||
call Function2879
|
||||
ret
|
||||
; 0x97acc
|
||||
|
||||
@ -2953,10 +2953,10 @@ Script_changeblock: ; 0x97acc
|
||||
call GetScriptByte
|
||||
add $4
|
||||
ld e, a
|
||||
call $2a66
|
||||
call Function2a66
|
||||
call GetScriptByte
|
||||
ld [hl], a
|
||||
call $2879
|
||||
call Function2879
|
||||
ret
|
||||
; 0x97ae3
|
||||
|
||||
@ -2965,19 +2965,19 @@ Script_reloadmappart: ; 0x97ae3
|
||||
|
||||
xor a
|
||||
ld [$ffd4], a
|
||||
call $2173
|
||||
call $2914
|
||||
call Function2173
|
||||
call Function2914
|
||||
ld a, $41
|
||||
ld hl, $4061
|
||||
rst $8
|
||||
call $1ad2
|
||||
call Function1ad2
|
||||
ret
|
||||
; 0x97af6
|
||||
|
||||
Script_warpcheck: ; 0x97af6
|
||||
; script command 0x8e
|
||||
|
||||
call $224a
|
||||
call Function224a
|
||||
ret nc
|
||||
callba Function966d0
|
||||
ret
|
||||
@ -2996,7 +2996,7 @@ Script_newloadmap: ; 0x97b08
|
||||
call GetScriptByte
|
||||
ld [$ff9f], a
|
||||
ld a, $1
|
||||
call $261b
|
||||
call Function261b
|
||||
call StopScript
|
||||
ret
|
||||
; 0x97b16
|
||||
@ -3011,7 +3011,7 @@ Script_reloadandreturn: ; 0x97b16
|
||||
Script_loadfont: ; 0x97b1c
|
||||
; script command 0x47
|
||||
|
||||
call $2e08
|
||||
call Function2e08
|
||||
ret
|
||||
; 0x97b20
|
||||
|
||||
@ -3020,7 +3020,7 @@ Script_refreshscreen: ; 0x97b20
|
||||
; parameters:
|
||||
; dummy (SingleByteParam)
|
||||
|
||||
call $2dba
|
||||
call ResetWindow
|
||||
call GetScriptByte
|
||||
ret
|
||||
; 0x97b27
|
||||
@ -3043,8 +3043,8 @@ LoadMoveSpritesScript: ; 97b2e
|
||||
Script_loadmovesprites: ; 0x97b2f
|
||||
; script command 0x49
|
||||
|
||||
call $2e20
|
||||
call $2dcf
|
||||
call Function2e20
|
||||
call Function2dcf
|
||||
ret
|
||||
; 0x97b36
|
||||
|
||||
@ -3206,7 +3206,7 @@ Script_credits: ; 0x97bf3
|
||||
DisplayCredits:
|
||||
call Script_resetfuncs
|
||||
ld a, $3
|
||||
call $261b
|
||||
call Function261b
|
||||
call StopScript
|
||||
ret
|
||||
; 0x97c05
|
||||
|
408
engine/serial.asm
Normal file
408
engine/serial.asm
Normal file
@ -0,0 +1,408 @@
|
||||
Serial: ; 6ef
|
||||
; The serial interrupt.
|
||||
|
||||
push af
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
|
||||
ld a, [$ffc9]
|
||||
and a
|
||||
jr nz, .asm_71c
|
||||
|
||||
ld a, [$c2d4]
|
||||
bit 0, a
|
||||
jr nz, .asm_721
|
||||
|
||||
ld a, [$ffcb]
|
||||
inc a
|
||||
jr z, .asm_726
|
||||
|
||||
ld a, [rSB]
|
||||
ld [hSerialReceive], a
|
||||
|
||||
ld a, [hSerialSend]
|
||||
ld [rSB], a
|
||||
|
||||
ld a, [$ffcb]
|
||||
cp $2
|
||||
jr z, .asm_752
|
||||
|
||||
ld a, 0 << rSC_ON
|
||||
ld [rSC], a
|
||||
ld a, 1 << rSC_ON
|
||||
ld [rSC], a
|
||||
jr .asm_752
|
||||
|
||||
.asm_71c
|
||||
call Function3e80
|
||||
jr .asm_75a
|
||||
|
||||
.asm_721
|
||||
call Function2057
|
||||
jr .asm_75a
|
||||
|
||||
.asm_726
|
||||
ld a, [rSB]
|
||||
cp $1
|
||||
jr z, .asm_730
|
||||
cp $2
|
||||
jr nz, .asm_752
|
||||
|
||||
.asm_730
|
||||
ld [hSerialReceive], a
|
||||
ld [$ffcb], a
|
||||
cp $2
|
||||
jr z, .asm_74f
|
||||
|
||||
xor a
|
||||
ld [rSB], a
|
||||
ld a, $3
|
||||
ld [rDIV], a
|
||||
|
||||
.asm_73f
|
||||
ld a, [rDIV]
|
||||
bit 7, a
|
||||
jr nz, .asm_73f
|
||||
|
||||
ld a, 0 << rSC_ON
|
||||
ld [rSC], a
|
||||
ld a, 1 << rSC_ON
|
||||
ld [rSC], a
|
||||
jr .asm_752
|
||||
|
||||
.asm_74f
|
||||
xor a
|
||||
ld [rSB], a
|
||||
|
||||
.asm_752
|
||||
ld a, $1
|
||||
ld [$ffca], a
|
||||
ld a, $fe
|
||||
ld [hSerialSend], a
|
||||
|
||||
.asm_75a
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
pop af
|
||||
reti
|
||||
; 75f
|
||||
|
||||
Function75f: ; 75f
|
||||
ld a, $1
|
||||
ld [$ffcc], a
|
||||
.asm_763
|
||||
ld a, [hl]
|
||||
ld [hSerialSend], a
|
||||
call Function78a
|
||||
push bc
|
||||
ld b, a
|
||||
inc hl
|
||||
ld a, $30
|
||||
.asm_76e
|
||||
dec a
|
||||
jr nz, .asm_76e
|
||||
ld a, [$ffcc]
|
||||
and a
|
||||
ld a, b
|
||||
pop bc
|
||||
jr z, .asm_782
|
||||
dec hl
|
||||
cp $fd
|
||||
jr nz, .asm_763
|
||||
xor a
|
||||
ld [$ffcc], a
|
||||
jr .asm_763
|
||||
|
||||
.asm_782
|
||||
ld [de], a
|
||||
inc de
|
||||
dec bc
|
||||
ld a, b
|
||||
or c
|
||||
jr nz, .asm_763
|
||||
ret
|
||||
; 78a
|
||||
|
||||
Function78a: ; 78a
|
||||
xor a
|
||||
ld [$ffca], a
|
||||
ld a, [$ffcb]
|
||||
cp $2
|
||||
jr nz, .asm_79b
|
||||
ld a, $1
|
||||
ld [rSC], a
|
||||
ld a, $81
|
||||
ld [rSC], a
|
||||
|
||||
.asm_79b
|
||||
ld a, [$ffca]
|
||||
and a
|
||||
jr nz, .asm_7e5
|
||||
ld a, [$ffcb]
|
||||
cp $1
|
||||
jr nz, .asm_7c0
|
||||
call Function82b
|
||||
jr z, .asm_7c0
|
||||
call .asm_825
|
||||
push hl
|
||||
ld hl, $cf5c
|
||||
inc [hl]
|
||||
jr nz, .asm_7b7
|
||||
dec hl
|
||||
inc [hl]
|
||||
|
||||
.asm_7b7
|
||||
pop hl
|
||||
call Function82b
|
||||
jr nz, .asm_79b
|
||||
jp Function833
|
||||
|
||||
.asm_7c0
|
||||
ld a, [rIE]
|
||||
and $f
|
||||
cp $8
|
||||
jr nz, .asm_79b
|
||||
ld a, [$cf5d]
|
||||
dec a
|
||||
ld [$cf5d], a
|
||||
jr nz, .asm_79b
|
||||
ld a, [$cf5e]
|
||||
dec a
|
||||
ld [$cf5e], a
|
||||
jr nz, .asm_79b
|
||||
ld a, [$ffcb]
|
||||
cp $1
|
||||
jr z, .asm_7e5
|
||||
ld a, $ff
|
||||
.asm_7e2
|
||||
dec a
|
||||
jr nz, .asm_7e2
|
||||
|
||||
.asm_7e5
|
||||
xor a
|
||||
ld [$ffca], a
|
||||
ld a, [rIE]
|
||||
and $f
|
||||
sub $8
|
||||
jr nz, .asm_7f8
|
||||
ld [$cf5d], a
|
||||
ld a, $50
|
||||
ld [$cf5e], a
|
||||
|
||||
.asm_7f8
|
||||
ld a, [hSerialReceive]
|
||||
cp $fe
|
||||
ret nz
|
||||
call Function82b
|
||||
jr z, .asm_813
|
||||
push hl
|
||||
ld hl, $cf5c
|
||||
ld a, [hl]
|
||||
dec a
|
||||
ld [hld], a
|
||||
inc a
|
||||
jr nz, .asm_80d
|
||||
dec [hl]
|
||||
|
||||
.asm_80d
|
||||
pop hl
|
||||
call Function82b
|
||||
jr z, Function833
|
||||
|
||||
.asm_813
|
||||
ld a, [rIE]
|
||||
and $f
|
||||
cp $8
|
||||
ld a, $fe
|
||||
ret z
|
||||
ld a, [hl]
|
||||
ld [hSerialSend], a
|
||||
call DelayFrame
|
||||
jp Function78a
|
||||
|
||||
.asm_825
|
||||
ld a, $f
|
||||
.asm_827
|
||||
dec a
|
||||
jr nz, .asm_827
|
||||
ret
|
||||
; 82b
|
||||
|
||||
Function82b: ; 82b
|
||||
push hl
|
||||
ld hl, $cf5b
|
||||
ld a, [hli]
|
||||
or [hl]
|
||||
pop hl
|
||||
ret
|
||||
; 833
|
||||
|
||||
Function833: ; 833
|
||||
dec a
|
||||
ld [$cf5b], a
|
||||
ld [$cf5c], a
|
||||
ret
|
||||
; 83b
|
||||
|
||||
Function83b: ; 83b
|
||||
ld hl, $cf56
|
||||
ld de, $cf51
|
||||
ld c, $2
|
||||
ld a, $1
|
||||
ld [$ffcc], a
|
||||
.asm_847
|
||||
call DelayFrame
|
||||
ld a, [hl]
|
||||
ld [hSerialSend], a
|
||||
call Function78a
|
||||
ld b, a
|
||||
inc hl
|
||||
ld a, [$ffcc]
|
||||
and a
|
||||
ld a, $0
|
||||
ld [$ffcc], a
|
||||
jr nz, .asm_847
|
||||
ld a, b
|
||||
ld [de], a
|
||||
inc de
|
||||
dec c
|
||||
jr nz, .asm_847
|
||||
ret
|
||||
; 862
|
||||
|
||||
Function862: ; 862
|
||||
call Function309d
|
||||
callab Function4000
|
||||
call Function87d
|
||||
jp Function30b4
|
||||
; 871
|
||||
|
||||
|
||||
Function871: ; 871
|
||||
call Function309d
|
||||
callab Function4000
|
||||
jp Function87d
|
||||
; 87d
|
||||
|
||||
|
||||
|
||||
Function87d: ; 87d
|
||||
ld a, $ff
|
||||
ld [$cf52], a
|
||||
.asm_882
|
||||
call Function8c1
|
||||
call DelayFrame
|
||||
call Function82b
|
||||
jr z, .asm_89e
|
||||
push hl
|
||||
ld hl, $cf5c
|
||||
dec [hl]
|
||||
jr nz, .asm_89d
|
||||
dec hl
|
||||
dec [hl]
|
||||
jr nz, .asm_89d
|
||||
pop hl
|
||||
xor a
|
||||
jp Function833
|
||||
|
||||
.asm_89d
|
||||
pop hl
|
||||
|
||||
.asm_89e
|
||||
ld a, [$cf52]
|
||||
inc a
|
||||
jr z, .asm_882
|
||||
ld b, $a
|
||||
.asm_8a6
|
||||
call DelayFrame
|
||||
call Function8c1
|
||||
dec b
|
||||
jr nz, .asm_8a6
|
||||
ld b, $a
|
||||
.asm_8b1
|
||||
call DelayFrame
|
||||
call Function908
|
||||
dec b
|
||||
jr nz, .asm_8b1
|
||||
ld a, [$cf52]
|
||||
ld [$cf51], a
|
||||
ret
|
||||
; 8c1
|
||||
|
||||
Function8c1: ; 8c1
|
||||
push bc
|
||||
ld b, $60
|
||||
ld a, [InLinkBattle]
|
||||
cp $1
|
||||
jr z, .asm_8d7
|
||||
ld b, $60
|
||||
jr c, .asm_8d7
|
||||
cp $2
|
||||
ld b, $70
|
||||
jr z, .asm_8d7
|
||||
ld b, $80
|
||||
|
||||
.asm_8d7
|
||||
call Function8f3
|
||||
ld a, [$cf56]
|
||||
add b
|
||||
ld [hSerialSend], a
|
||||
ld a, [$ffcb]
|
||||
cp $2
|
||||
jr nz, .asm_8ee
|
||||
ld a, $1
|
||||
ld [rSC], a
|
||||
ld a, $81
|
||||
ld [rSC], a
|
||||
|
||||
.asm_8ee
|
||||
call Function8f3
|
||||
pop bc
|
||||
ret
|
||||
; 8f3
|
||||
|
||||
Function8f3: ; 8f3
|
||||
ld a, [hSerialReceive]
|
||||
ld [$cf51], a
|
||||
and $f0
|
||||
cp b
|
||||
ret nz
|
||||
xor a
|
||||
ld [hSerialReceive], a
|
||||
ld a, [$cf51]
|
||||
and $f
|
||||
ld [$cf52], a
|
||||
ret
|
||||
; 908
|
||||
|
||||
Function908: ; 908
|
||||
xor a
|
||||
ld [hSerialSend], a
|
||||
ld a, [$ffcb]
|
||||
cp $2
|
||||
ret nz
|
||||
ld a, $1
|
||||
ld [rSC], a
|
||||
ld a, $81
|
||||
ld [rSC], a
|
||||
ret
|
||||
; 919
|
||||
|
||||
Function919: ; 919
|
||||
ld a, [InLinkBattle]
|
||||
and a
|
||||
ret nz
|
||||
ld a, $2
|
||||
ld [rSB], a
|
||||
xor a
|
||||
ld [hSerialReceive], a
|
||||
ld a, $0
|
||||
ld [rSC], a
|
||||
ld a, $80
|
||||
ld [rSC], a
|
||||
ret
|
||||
; 92e
|
||||
|
||||
|
311
engine/time.asm
Normal file
311
engine/time.asm
Normal file
@ -0,0 +1,311 @@
|
||||
; Functions relating to the timer interrupt and the real-time-clock.
|
||||
|
||||
|
||||
AskTimer: ; 591
|
||||
push af
|
||||
ld a, [$ffe9]
|
||||
and a
|
||||
jr z, .asm_59a
|
||||
call Timer
|
||||
|
||||
.asm_59a
|
||||
pop af
|
||||
reti
|
||||
; 59c
|
||||
|
||||
|
||||
LatchClock: ; 59c
|
||||
; latch clock counter data
|
||||
ld a, 0
|
||||
ld [MBC3LatchClock], a
|
||||
ld a, 1
|
||||
ld [MBC3LatchClock], a
|
||||
ret
|
||||
; 5a7
|
||||
|
||||
|
||||
UpdateTime: ; 5a7
|
||||
call GetClock
|
||||
call FixDays
|
||||
call FixTime
|
||||
callba GetTimeOfDay
|
||||
ret
|
||||
; 5b7
|
||||
|
||||
|
||||
GetClock: ; 5b7
|
||||
; store clock data in hRTCDayHi-hRTCSeconds
|
||||
|
||||
; enable clock r/w
|
||||
ld a, SRAM_ENABLE
|
||||
ld [MBC3SRamEnable], a
|
||||
|
||||
; clock data is 'backwards' in hram
|
||||
|
||||
call LatchClock
|
||||
ld hl, MBC3SRamBank
|
||||
ld de, MBC3RTC
|
||||
|
||||
ld [hl], RTC_S
|
||||
ld a, [de]
|
||||
and $3f
|
||||
ld [hRTCSeconds], a
|
||||
|
||||
ld [hl], RTC_M
|
||||
ld a, [de]
|
||||
and $3f
|
||||
ld [hRTCMinutes], a
|
||||
|
||||
ld [hl], RTC_H
|
||||
ld a, [de]
|
||||
and $1f
|
||||
ld [hRTCHours], a
|
||||
|
||||
ld [hl], RTC_DL
|
||||
ld a, [de]
|
||||
ld [hRTCDayLo], a
|
||||
|
||||
ld [hl], RTC_DH
|
||||
ld a, [de]
|
||||
ld [hRTCDayHi], a
|
||||
|
||||
; unlatch clock / disable clock r/w
|
||||
call CloseSRAM
|
||||
ret
|
||||
; 5e8
|
||||
|
||||
|
||||
FixDays: ; 5e8
|
||||
; fix day count
|
||||
; mod by 140
|
||||
|
||||
; check if day count > 255 (bit 8 set)
|
||||
ld a, [hRTCDayHi] ; DH
|
||||
bit 0, a
|
||||
jr z, .daylo
|
||||
; reset dh (bit 8)
|
||||
res 0, a
|
||||
ld [hRTCDayHi], a ; DH
|
||||
|
||||
; mod 140
|
||||
; mod twice since bit 8 (DH) was set
|
||||
ld a, [hRTCDayLo] ; DL
|
||||
.modh
|
||||
sub 140
|
||||
jr nc, .modh
|
||||
.modl
|
||||
sub 140
|
||||
jr nc, .modl
|
||||
add 140
|
||||
|
||||
; update dl
|
||||
ld [hRTCDayLo], a ; DL
|
||||
|
||||
; unknown output
|
||||
ld a, $40 ; %1000000
|
||||
jr .set
|
||||
|
||||
.daylo
|
||||
; quit if fewer than 140 days have passed
|
||||
ld a, [hRTCDayLo] ; DL
|
||||
cp 140
|
||||
jr c, .quit
|
||||
|
||||
; mod 140
|
||||
.mod
|
||||
sub 140
|
||||
jr nc, .mod
|
||||
add 140
|
||||
|
||||
; update dl
|
||||
ld [hRTCDayLo], a ; DL
|
||||
|
||||
; unknown output
|
||||
ld a, $20 ; %100000
|
||||
|
||||
.set
|
||||
; update clock with modded day value
|
||||
push af
|
||||
call SetClock
|
||||
pop af
|
||||
scf
|
||||
ret
|
||||
|
||||
.quit
|
||||
xor a
|
||||
ret
|
||||
; 61d
|
||||
|
||||
|
||||
FixTime: ; 61d
|
||||
; add ingame time (set at newgame) to current time
|
||||
; day hr min sec
|
||||
; store time in CurDay, hHours, hMinutes, hSeconds
|
||||
|
||||
; second
|
||||
ld a, [hRTCSeconds] ; S
|
||||
ld c, a
|
||||
ld a, [StartSecond]
|
||||
add c
|
||||
sub 60
|
||||
jr nc, .updatesec
|
||||
add 60
|
||||
.updatesec
|
||||
ld [hSeconds], a
|
||||
|
||||
; minute
|
||||
ccf ; carry is set, so turn it off
|
||||
ld a, [hRTCMinutes] ; M
|
||||
ld c, a
|
||||
ld a, [StartMinute]
|
||||
adc c
|
||||
sub 60
|
||||
jr nc, .updatemin
|
||||
add 60
|
||||
.updatemin
|
||||
ld [hMinutes], a
|
||||
|
||||
; hour
|
||||
ccf ; carry is set, so turn it off
|
||||
ld a, [hRTCHours] ; H
|
||||
ld c, a
|
||||
ld a, [StartHour]
|
||||
adc c
|
||||
sub 24
|
||||
jr nc, .updatehr
|
||||
add 24
|
||||
.updatehr
|
||||
ld [hHours], a
|
||||
|
||||
; day
|
||||
ccf ; carry is set, so turn it off
|
||||
ld a, [hRTCDayLo] ; DL
|
||||
ld c, a
|
||||
ld a, [StartDay]
|
||||
adc c
|
||||
ld [CurDay], a
|
||||
ret
|
||||
; 658
|
||||
|
||||
Function658: ; 658
|
||||
xor a
|
||||
ld [StringBuffer2], a
|
||||
ld a, $0
|
||||
ld [$d089], a
|
||||
jr .asm_677
|
||||
|
||||
call UpdateTime
|
||||
ld a, [hHours]
|
||||
ld [$d087], a
|
||||
ld a, [hMinutes]
|
||||
ld [$d088], a
|
||||
ld a, [hSeconds]
|
||||
ld [$d089], a
|
||||
jr .asm_677
|
||||
|
||||
.asm_677
|
||||
ld a, $5
|
||||
ld hl, $40ed
|
||||
rst FarCall
|
||||
ret
|
||||
; 67e
|
||||
|
||||
|
||||
|
||||
Function67e: ; 67e
|
||||
call Function685
|
||||
call SetClock
|
||||
ret
|
||||
; 685
|
||||
|
||||
Function685: ; 685
|
||||
xor a
|
||||
ld [hRTCSeconds], a
|
||||
ld [hRTCMinutes], a
|
||||
ld [hRTCHours], a
|
||||
ld [hRTCDayLo], a
|
||||
ld [hRTCDayHi], a
|
||||
ret
|
||||
; 691
|
||||
|
||||
|
||||
SetClock: ; 691
|
||||
; set clock data from hram
|
||||
|
||||
; enable clock r/w
|
||||
ld a, SRAM_ENABLE
|
||||
ld [MBC3SRamEnable], a
|
||||
|
||||
; set clock data
|
||||
; stored 'backwards' in hram
|
||||
|
||||
call LatchClock
|
||||
ld hl, MBC3SRamBank
|
||||
ld de, MBC3RTC
|
||||
|
||||
; seems to be a halt check that got partially commented out
|
||||
; this block is totally pointless
|
||||
ld [hl], RTC_DH
|
||||
ld a, [de]
|
||||
bit 6, a ; halt
|
||||
ld [de], a
|
||||
|
||||
; seconds
|
||||
ld [hl], RTC_S
|
||||
ld a, [hRTCSeconds]
|
||||
ld [de], a
|
||||
; minutes
|
||||
ld [hl], RTC_M
|
||||
ld a, [hRTCMinutes]
|
||||
ld [de], a
|
||||
; hours
|
||||
ld [hl], RTC_H
|
||||
ld a, [hRTCHours]
|
||||
ld [de], a
|
||||
; day lo
|
||||
ld [hl], RTC_DL
|
||||
ld a, [hRTCDayLo]
|
||||
ld [de], a
|
||||
; day hi
|
||||
ld [hl], RTC_DH
|
||||
ld a, [hRTCDayHi]
|
||||
res 6, a ; make sure timer is active
|
||||
ld [de], a
|
||||
|
||||
; cleanup
|
||||
call CloseSRAM ; unlatch clock, disable clock r/w
|
||||
ret
|
||||
; 6c4
|
||||
|
||||
|
||||
Function6c4: ; 6c4
|
||||
xor a
|
||||
push af
|
||||
ld a, $0
|
||||
call GetSRAMBank
|
||||
pop af
|
||||
ld [$ac60], a
|
||||
call CloseSRAM
|
||||
ret
|
||||
; 6d3
|
||||
|
||||
Function6d3: ; 6d3
|
||||
ld hl, $ac60
|
||||
push af
|
||||
ld a, $0
|
||||
call GetSRAMBank
|
||||
pop af
|
||||
or [hl]
|
||||
ld [hl], a
|
||||
call CloseSRAM
|
||||
ret
|
||||
; 6e3
|
||||
|
||||
Function6e3: ; 6e3
|
||||
ld a, $0
|
||||
call GetSRAMBank
|
||||
ld a, [$ac60]
|
||||
call CloseSRAM
|
||||
ret
|
||||
; 6ef
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
; This prevents the display and audio output from lagging.
|
||||
|
||||
|
||||
VBlank: ; 283
|
||||
push af
|
||||
push bc
|
||||
push de
|
||||
@ -26,7 +28,7 @@
|
||||
ld l, a
|
||||
|
||||
; down to business
|
||||
call JpHl
|
||||
call _hl_
|
||||
|
||||
; since this is called once per frame
|
||||
call GameTimer
|
||||
|
2
extras
2
extras
@ -1 +1 @@
|
||||
Subproject commit 4c56a6c57a4c21acff5dcf5aa1c23138f0a743c3
|
||||
Subproject commit 4998994c9a624f6298f8a54a665c788825c3e8f9
|
14
gbhw.asm
14
gbhw.asm
@ -21,15 +21,29 @@ RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag
|
||||
; Bit 6 Halt (0=Active, 1=Stop Timer)
|
||||
; Bit 7 Day Counter Carry Bit (1=Counter Overflow)
|
||||
|
||||
; interrupt flags
|
||||
VBLANK EQU 0
|
||||
LCD_STAT EQU 1
|
||||
TIMER EQU 2
|
||||
SERIAL EQU 3
|
||||
JOYPAD EQU 4
|
||||
|
||||
; Hardware registers
|
||||
rJOYP EQU $ff00 ; Joypad (R/W)
|
||||
rSB EQU $ff01 ; Serial transfer data (R/W)
|
||||
rSC EQU $ff02 ; Serial Transfer Control (R/W)
|
||||
rSC_ON EQU 7
|
||||
rSC_CGB EQU 1
|
||||
rSC_CLOCK EQU 0
|
||||
rDIV EQU $ff04 ; Divider Register (R/W)
|
||||
rTIMA EQU $ff05 ; Timer counter (R/W)
|
||||
rTMA EQU $ff06 ; Timer Modulo (R/W)
|
||||
rTAC EQU $ff07 ; Timer Control (R/W)
|
||||
rTAC_ON EQU 2
|
||||
rTAC_4096_HZ EQU 0
|
||||
rTAC_262144_HZ EQU 1
|
||||
rTAC_65536_HZ EQU 2
|
||||
rTAC_16384_HZ EQU 3
|
||||
rIF EQU $ff0f ; Interrupt Flag (R/W)
|
||||
rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W)
|
||||
rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user