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:
Bryan Bishop 2013-08-31 12:47:23 -05:00
commit 12c1d874b9
29 changed files with 5268 additions and 3498 deletions

View File

@ -7,8 +7,8 @@ PNG_GFX := $(shell find gfx/ -type f -name '*.png')
LZ_GFX := $(shell find gfx/ -type f -name '*.lz') LZ_GFX := $(shell find gfx/ -type f -name '*.lz')
TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp') TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp')
all: pokecrystal.gbc all: baserom.gbc pokecrystal.gbc
cmp baserom.gbc $< cmp baserom.gbc pokecrystal.gbc
clean: clean:
rm -f pokecrystal.o pokecrystal.gbc rm -f pokecrystal.o pokecrystal.gbc
@echo 'rm -f $(TEXTFILES:.asm=.tx)' @echo 'rm -f $(TEXTFILES:.asm=.tx)'
@ -19,6 +19,8 @@ pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constan
.asm.tx: .asm.tx:
$(eval TEXTQUEUE := $(TEXTQUEUE) $<) $(eval TEXTQUEUE := $(TEXTQUEUE) $<)
@rm -f $@ @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 pokecrystal.gbc: pokecrystal.o
rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $< rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<

View File

@ -129,7 +129,7 @@ AIScoring_RedStatMods: ; 385e0
jr .checkmove jr .checkmove
.discourage .discourage
call RNG call Random
cp 30 cp 30
jr c, .checkmove jr c, .checkmove
inc [hl] inc [hl]
@ -430,7 +430,7 @@ AIScoring_LeechHit: ; 387f7
ret ret
.asm_38815 .asm_38815
call RNG call Random
cp $64 cp $64
ret c ret c
@ -575,7 +575,7 @@ AIScoring_Explosion: ; 388a6
call AICheckEnemyQuarterHP call AICheckEnemyQuarterHP
ret nc ret nc
call RNG call Random
cp 20 cp 20
ret c ret c
@ -588,7 +588,7 @@ AIScoring_Explosion: ; 388a6
AIScoring_DreamEater: ; 388ca AIScoring_DreamEater: ; 388ca
call RNG call Random
cp $19 cp $19
ret c ret c
@ -612,7 +612,7 @@ AIScoring_EvasionUp: ; 388d4
bit 0, a bit 0, a
jr nz, .asm_388ef jr nz, .asm_388ef
call RNG call Random
cp $b2 cp $b2
jr nc, .asm_38911 jr nc, .asm_38911
@ -628,7 +628,7 @@ AIScoring_EvasionUp: ; 388d4
jr nc, .asm_3890f jr nc, .asm_3890f
call RNG call Random
cp $a cp $a
jr c, .asm_388ef jr c, .asm_388ef
@ -683,7 +683,7 @@ AIScoring_EvasionUp: ; 388d4
ret ret
.asm_38938 .asm_38938
call RNG call Random
cp $50 cp $50
ret c ret c
dec [hl] dec [hl]
@ -744,7 +744,7 @@ AIScoring_MirrorMove: ; 3895b
call AICompareSpeed call AICompareSpeed
ret nc ret nc
call RNG call Random
cp $19 cp $19
ret c ret c
@ -766,7 +766,7 @@ AIScoring_AccuracyDown: ; 38985
bit 0, a bit 0, a
jr nz, .asm_3899d jr nz, .asm_3899d
call RNG call Random
cp $b2 cp $b2
jr nc, .asm_389bf jr nc, .asm_389bf
@ -782,7 +782,7 @@ AIScoring_AccuracyDown: ; 38985
jr nc, .asm_389bd jr nc, .asm_389bd
call RNG call Random
cp $a cp $a
jr c, .asm_3899d jr c, .asm_3899d
@ -837,7 +837,7 @@ AIScoring_AccuracyDown: ; 38985
ret ret
.asm_389e6 .asm_389e6
call RNG call Random
cp $50 cp $50
ret c ret c
dec [hl] dec [hl]
@ -878,7 +878,7 @@ AIScoring_Haze: ; 389f5
.asm_38a12 .asm_38a12
pop hl pop hl
call RNG call Random
cp $28 cp $28
ret c ret c
dec [hl] dec [hl]
@ -894,7 +894,7 @@ AIScoring_Haze: ; 389f5
AIScoring_Bide: ; 38a1e AIScoring_Bide: ; 38a1e
call AICheckEnemyMaxHP call AICheckEnemyMaxHP
ret c ret c
call RNG call Random
cp $19 cp $19
ret c ret c
inc [hl] inc [hl]
@ -926,7 +926,7 @@ AIScoring_Moonlight: ; 38a3a
ret ret
.asm_38a45 .asm_38a45
call RNG call Random
cp $19 cp $19
ret c ret c
dec [hl] dec [hl]
@ -948,7 +948,7 @@ AIScoring_LightScreen:
AIScoring_Reflect: ; 38a54 AIScoring_Reflect: ; 38a54
call AICheckEnemyMaxHP call AICheckEnemyMaxHP
ret c ret c
call RNG call Random
cp $14 cp $14
ret c ret c
inc [hl] inc [hl]
@ -1041,7 +1041,7 @@ AIScoring_Unused2B: ; 38a9c
ret c ret c
.asm_38acd .asm_38acd
call RNG call Random
cp $c8 cp $c8
ret c ret c
@ -1061,7 +1061,7 @@ AIScoring_Unused2B: ; 38a9c
AIScoring_Confuse: ; 38adb AIScoring_Confuse: ; 38adb
call AICheckPlayerHalfHP call AICheckPlayerHalfHP
ret c ret c
call RNG call Random
cp $19 cp $19
jr c, .asm_38ae7 jr c, .asm_38ae7
inc [hl] inc [hl]
@ -1156,7 +1156,7 @@ AIScoring_SpeedDownHit: ; 38b40
ret nz ret nz
call AICompareSpeed call AICompareSpeed
ret c ret c
call RNG call Random
cp 30 cp 30
ret c ret c
dec [hl] dec [hl]
@ -1183,7 +1183,7 @@ AIScoring_HyperBeam: ; 38b63
ret ret
.asm_38b72 .asm_38b72
call RNG call Random
cp 40 cp 40
ret c ret c
inc [hl] inc [hl]
@ -1334,7 +1334,7 @@ AIScoring_Counter: ; 38bf1
.asm_38c30 .asm_38c30
call RNG call Random
cp $64 cp $64
jr c, .asm_38c38 jr c, .asm_38c38
@ -1388,7 +1388,7 @@ AIScoring_Encore: ; 38c3b
jr nc, .asm_38c81 jr nc, .asm_38c81
.asm_38c78 .asm_38c78
call RNG call Random
cp $46 cp $46
ret c ret c
dec [hl] dec [hl]
@ -1527,7 +1527,7 @@ AIScoring_Spite: ; 38cd5
cp $f cp $f
jr nc, .asm_38d0b jr nc, .asm_38d0b
call RNG call Random
cp $64 cp $64
ret nc ret nc
@ -1536,7 +1536,7 @@ AIScoring_Spite: ; 38cd5
ret ret
.asm_38d0d .asm_38d0d
call RNG call Random
cp $64 cp $64
ret c ret c
dec [hl] dec [hl]
@ -1700,7 +1700,7 @@ AIScoring_Conversion2: ; 38d98
ret ret
.asm_38dc9 .asm_38dc9
call RNG call Random
cp $19 cp $19
ret c ret c
@ -1722,7 +1722,7 @@ AIScoring_Disable: ; 38dd1
pop hl pop hl
jr nc, .asm_38dee jr nc, .asm_38dee
call RNG call Random
cp 100 cp 100
ret c ret c
dec [hl] dec [hl]
@ -1734,7 +1734,7 @@ AIScoring_Disable: ; 38dd1
ret nz ret nz
.asm_38df3 .asm_38df3
call RNG call Random
cp 20 cp 20
ret c ret c
inc [hl] inc [hl]
@ -1961,7 +1961,7 @@ AIScoring_Protect: ; 38ed2
inc [hl] inc [hl]
.asm_38f14 .asm_38f14
call RNG call Random
cp 20 cp 20
ret c ret c
inc [hl] inc [hl]
@ -1985,14 +1985,14 @@ AIScoring_Foresight: ; 38f1d
cp GHOST cp GHOST
jr z, .asm_38f41 jr z, .asm_38f41
call RNG call Random
cp 20 cp 20
ret c ret c
inc [hl] inc [hl]
ret ret
.asm_38f41 .asm_38f41
call RNG call Random
cp 100 cp 100
ret c ret c
dec [hl] dec [hl]
@ -2169,7 +2169,7 @@ AIScoring_Rollout: ; 38fef
cp 8 cp 8
jr nc, .asm_39020 jr nc, .asm_39020
call RNG call Random
cp 200 cp 200
ret nc ret nc
dec [hl] dec [hl]
@ -2196,7 +2196,7 @@ AIScoring_Attract: ; 39026
ret ret
.asm_39032 .asm_39032
call RNG call Random
cp 200 cp 200
ret nc ret nc
dec [hl] dec [hl]
@ -2558,7 +2558,7 @@ AIScoring_MirrorCoat: ; 3918b
.asm_391ca .asm_391ca
call RNG call Random
cp 100 cp 100
jr c, .asm_391d2 jr c, .asm_391d2
dec [hl] dec [hl]
@ -2634,7 +2634,7 @@ AIScoring_Solarbeam: ; 3920b
cp WEATHER_RAIN cp WEATHER_RAIN
ret nz ret nz
call RNG call Random
cp 25 ; 1/10 cp 25 ; 1/10
ret c ret c
@ -2657,7 +2657,7 @@ AIScoring_Thunder: ; 39225
cp WEATHER_SUN cp WEATHER_SUN
ret nz ret nz
call RNG call Random
cp 25 ; 1/10 cp 25 ; 1/10
ret c ret c
@ -3150,7 +3150,7 @@ AIScoring_Cautious: ; 39418
pop hl pop hl
jr nc, .asm_39425 jr nc, .asm_39425
call RNG call Random
cp 230 cp 230
ret nc ret nc
@ -3274,7 +3274,7 @@ AIScoring_Risky: ; 394a9
call AICheckEnemyMaxHP call AICheckEnemyMaxHP
jr c, .nextmove jr c, .nextmove
call RNG call Random
cp 200 ; 1/5 cp 200 ; 1/5
jr c, .nextmove jr c, .nextmove
@ -3347,14 +3347,14 @@ AIGetEnemyMove: ; 39508
Function_0x39521: ; 39521 Function_0x39521: ; 39521
call RNG call Random
cp 50 ; 1/5 cp 50 ; 1/5
ret ret
; 39527 ; 39527
Function_0x39527: ; 39527 Function_0x39527: ; 39527
call RNG call Random
cp $80 ; 1/2 cp $80 ; 1/2
ret ret
; 3952d ; 3952d

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@ INCLUDE "constants/map_constants.asm"
INCLUDE "constants/item_constants.asm" INCLUDE "constants/item_constants.asm"
INCLUDE "constants/trainer_constants.asm" INCLUDE "constants/trainer_constants.asm"
INCLUDE "constants/script_constants.asm" INCLUDE "constants/script_constants.asm"
INCLUDE "constants/event_flags.asm"
INCLUDE "constants/engine_flags.asm"
INCLUDE "constants/music_constants.asm" INCLUDE "constants/music_constants.asm"
@ -231,6 +233,7 @@ PREDEF_PRINT_MOVE_DESCRIPTION EQU $11
PREDEF_UPDATE_PLAYER_HUD EQU $12 PREDEF_UPDATE_PLAYER_HUD EQU $12
PREDEF_FILL_BOX EQU $13 PREDEF_FILL_BOX EQU $13
PREDEF_UPDATE_ENEMY_HUD EQU $15 PREDEF_UPDATE_ENEMY_HUD EQU $15
PREDEF_START_BATTLE EQU $16
PREDEF_FILL_IN_EXP_BAR EQU $17 PREDEF_FILL_IN_EXP_BAR EQU $17
PREDEF_FILLMOVES EQU $1B PREDEF_FILLMOVES EQU $1B
PREDEF_GET_GENDER EQU $24 PREDEF_GET_GENDER EQU $24
@ -243,6 +246,7 @@ PREDEF_PRINT_TYPE EQU $2B
PREDEF_GET_UNOWN_LETTER EQU $2D PREDEF_GET_UNOWN_LETTER EQU $2D
PREDEF_LOAD_SGB_LAYOUT EQU $31 PREDEF_LOAD_SGB_LAYOUT EQU $31
PREDEF_CHECK_CONTEST_MON EQU $33 PREDEF_CHECK_CONTEST_MON EQU $33
PREDEF_BATTLE_TRANSITION EQU $34
PREDEF_PARTYMON_ITEM_NAME EQU $3B PREDEF_PARTYMON_ITEM_NAME EQU $3B
PREDEF_DECOMPRESS EQU $40 PREDEF_DECOMPRESS EQU $40

163
constants/engine_flags.asm Normal file
View 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

View 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

View File

@ -1,3 +1,5 @@
NUM_POKEMON EQU 251
BULBASAUR EQU 1 BULBASAUR EQU 1
IVYSAUR EQU 2 IVYSAUR EQU 2
VENUSAUR EQU 3 VENUSAUR EQU 3

431
engine/copy.asm Normal file
View 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
View 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

View File

@ -79,7 +79,7 @@ Init: ; 17d
or c or c
jr nz, .asm_1b1 jr nz, .asm_1b1
ld sp, Stack - 1 ld sp, Stack
; Clear HRAM ; Clear HRAM
ld a, [hCGB] ld a, [hCGB]

View File

@ -273,3 +273,219 @@ StopAutoInput: ; a0a
ret ret
; a1b ; 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
View 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
View 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

View File

@ -308,7 +308,7 @@ Script_2writetext: ; 0x96e9b
ld h, a ld h, a
ld a, [ScriptBank] ld a, [ScriptBank]
ld b, a ld b, a
call $269a call Function269a
ret ret
; 0x96eab ; 0x96eab
@ -323,7 +323,7 @@ Script_3writetext: ; 0x96eab
ld l, a ld l, a
call GetScriptByte call GetScriptByte
ld h, a ld h, a
call $269a call Function269a
ret ret
; 0x96ebb ; 0x96ebb
@ -348,7 +348,7 @@ Script_repeattext: ; 0x96ebb
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
call $269a call Function269a
ret ret
.asm_96ed8 .asm_96ed8
ret ret
@ -357,7 +357,7 @@ Script_repeattext: ; 0x96ebb
Script_closetext: ; 0x96ed9 Script_closetext: ; 0x96ed9
; script command 0x54 ; script command 0x54
jp $0a46 jp Functiona46
; 0x96edc ; 0x96edc
Script_keeptextopen: ; 0x96edc Script_keeptextopen: ; 0x96edc
@ -367,8 +367,8 @@ Script_keeptextopen: ; 0x96edc
push af push af
ld a, $1 ld a, $1
ld [$ffd8], a ld [$ffd8], a
call $31f6 call WaitBGMap
call $0aaf call Functionaaf
pop af pop af
ld [$ffd8], a ld [$ffd8], a
ret ret
@ -377,7 +377,7 @@ Script_keeptextopen: ; 0x96edc
Script_yesorno: ; 0x96eed Script_yesorno: ; 0x96eed
; script command 0x4e ; script command 0x4e
call $1dcf call Function1dcf
ld a, $0 ld a, $0
jr c, .asm_96ef6 ; 0x96ef2 $2 jr c, .asm_96ef6 ; 0x96ef2 $2
ld a, $1 ld a, $1
@ -397,16 +397,16 @@ Script_loadmenudata: ; 0x96efa
ld h, a ld h, a
ld de, $1d35 ld de, $1d35
ld a, [ScriptBank] ld a, [ScriptBank]
call $26b7 call Function26b7
call $1ad2 call Function1ad2
ret ret
; 0x96f0f ; 0x96f0f
Script_writebackup: ; 0x96f0f Script_writebackup: ; 0x96f0f
; script command 0x50 ; script command 0x50
call $1c17 call Function1c17
call $1ad2 call Function1ad2
ret ret
; 0x96f16 ; 0x96f16
@ -470,7 +470,7 @@ Script_storetext: ; 0x96f52
; pointer (PointerLabelBeforeBank) ; pointer (PointerLabelBeforeBank)
; memory (SingleByteParam) ; memory (SingleByteParam)
call $106c call Function106c
call GetScriptByte call GetScriptByte
ld c, a ld c, a
ld a, $47 ld a, $47
@ -539,7 +539,7 @@ Script_verbosegiveitem2: ; 0x96f8e
ld a, [de] ld a, [de]
ld [$d10c], a ld [$d10c], a
ld hl, $d892 ld hl, $d892
call $2f66 call Function2f66
ld a, $1 ld a, $1
jr c, .asm_96fb0 ; 0x96fad $1 jr c, .asm_96fb0 ; 0x96fad $1
xor a xor a
@ -561,7 +561,7 @@ Script_itemnotify: ; 0x96fc6
call CurItemName call CurItemName
ld b, BANK(PutItemInPocketText) ld b, BANK(PutItemInPocketText)
ld hl, PutItemInPocketText ld hl, PutItemInPocketText
call $269a call Function269a
ret ret
; 0x96fd5 ; 0x96fd5
@ -572,7 +572,7 @@ Script_pocketisfull: ; 0x96fd5
call CurItemName call CurItemName
ld b, BANK(PocketIsFullText) ld b, BANK(PocketIsFullText)
ld hl, PocketIsFullText ld hl, PocketIsFullText
call $269a call Function269a
ret ret
; 0x96fe4 ; 0x96fe4
@ -732,7 +732,7 @@ Script_askforphonenumber: ; 0x970be
; parameters: ; parameters:
; number (SingleByteParam) ; number (SingleByteParam)
call $1dcf call Function1dcf
jr c, .asm_970d6 ; 0x970c1 $13 jr c, .asm_970d6 ; 0x970c1 $13
call GetScriptByte call GetScriptByte
ld c, a ld c, a
@ -814,7 +814,7 @@ Script_trainertext: ; 0x9710f
ld l, a ld l, a
ld a, [$d03e] ld a, [$d03e]
ld b, a ld b, a
call $269a call Function269a
ret ret
; 0x97125 ; 0x97125
@ -843,7 +843,7 @@ Script_trainerstatus: ; 0x97132
ld d, [hl] ld d, [hl]
call GetScriptByte call GetScriptByte
ld b, a ld b, a
call BitTable1Func call EventFlagAction
ld a, c ld a, c
and a and a
ret z ret z
@ -907,7 +907,7 @@ Script_playrammusic: ; 0x9717a
Script_playmapmusic: ; 0x97185 Script_playmapmusic: ; 0x97185
; script command 0x82 ; script command 0x82
call $3cdf call Function3cdf
ret ret
; 0x97189 ; 0x97189
@ -988,7 +988,7 @@ Script_cry: ; 0x971d1
jr nz, .asm_971df ; 0x971da $3 jr nz, .asm_971df ; 0x971da $3
ld a, [$c2dd] ld a, [$c2dd]
.asm_971df .asm_971df
call $37ce call Function37ce
ret ret
; 0x971e3 ; 0x971e3
@ -1039,7 +1039,7 @@ Function971fa: ; 971fa
ld h, a ld h, a
ld a, [ScriptBank] ld a, [ScriptBank]
ld b, a ld b, a
call $26c7 call Function26c7
ret c ret c
ld a, SCRIPT_WAIT_MOVEMENT ld a, SCRIPT_WAIT_MOVEMENT
ld [ScriptMode], a ld [ScriptMode], a
@ -1145,13 +1145,13 @@ Script_spriteface: ; 0x97274
Unknown_0x9728b: ; 0x9728b Unknown_0x9728b: ; 0x9728b
ld a, d ld a, d
push de push de
call $18de call Function18de
jr c, .asm_972b9 ; 0x97290 $27 jr c, .asm_972b9 ; 0x97290 $27
ld hl, $0000 ld hl, $0000
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
push bc push bc
call $1836 call Function1836
pop bc pop bc
jr c, .asm_972b9 ; 0x9729c $1b jr c, .asm_972b9 ; 0x9729c $1b
ld hl, $0004 ld hl, $0004
@ -1160,13 +1160,13 @@ Unknown_0x9728b: ; 0x9728b
jr nz, .asm_972b9 ; 0x972a4 $13 jr nz, .asm_972b9 ; 0x972a4 $13
pop de pop de
ld a, e ld a, e
call $1af8 call Function1af8
ld hl, $d0ed ld hl, $d0ed
bit 6, [hl] bit 6, [hl]
jr nz, .asm_972b5 ; 0x972b0 $3 jr nz, .asm_972b5 ; 0x972b0 $3
call Unknown_0x972bc call Unknown_0x972bc
.asm_972b5 .asm_972b5
call $1ad2 call Function1ad2
ret ret
.asm_972b9 .asm_972b9
pop de pop de
@ -1175,7 +1175,7 @@ Unknown_0x9728b: ; 0x9728b
; 0x972bc ; 0x972bc
Unknown_0x972bc: ; 0x972bc Unknown_0x972bc: ; 0x972bc
call $217a call Function217a
ld hl, TileMap ld hl, TileMap
ld bc, $0168 ld bc, $0168
.asm_972c5 .asm_972c5
@ -1211,7 +1211,7 @@ Script_appear: ; 0x972dd
call GetScriptByte call GetScriptByte
call Unknown_0x971e3 call Unknown_0x971e3
call $1956 call Function1956
ld a, [$ffaf] ld a, [$ffaf]
ld b, $0 ld b, $0
call Unknown_0x9730b call Unknown_0x9730b
@ -1229,7 +1229,7 @@ Script_disappear: ; 0x972ee
jr nz, .asm_972fa ; 0x972f6 $2 jr nz, .asm_972fa ; 0x972f6 $2
ld a, [$ffe0] ld a, [$ffe0]
.asm_972fa .asm_972fa
call $199f call Function199f
ld a, [$ffaf] ld a, [$ffaf]
ld b, $1 ld b, $1
call Unknown_0x9730b call Unknown_0x9730b
@ -1241,7 +1241,7 @@ Script_disappear: ; 0x972ee
Unknown_0x9730b: ; 0x9730b Unknown_0x9730b: ; 0x9730b
push bc push bc
call $18d2 call GetMapObject
ld hl, $000c ld hl, $000c
add hl, bc add hl, bc
pop bc pop bc
@ -1256,7 +1256,7 @@ Unknown_0x9730b: ; 0x9730b
xor a xor a
ret ret
.asm_97321 .asm_97321
call BitTable1Func call EventFlagAction
ret ret
; 0x97325 ; 0x97325
@ -1497,9 +1497,9 @@ Script_loadtrainer: ; 0x97424
Script_startbattle: ; 0x97436 Script_startbattle: ; 0x97436
; script command 0x5f ; script command 0x5f
call $2879 call Function2879
ld a, $16 ld a, PREDEF_START_BATTLE
call $2d83 call Predef
ld a, [$d0ee] ld a, [$d0ee]
and $3f and $3f
ld [$c2dd], a ld [$c2dd], a
@ -1513,7 +1513,7 @@ Script_catchtutorial: ; 0x97447
call GetScriptByte call GetScriptByte
ld [$d230], a ld [$d230], a
call $2879 call Function2879
ld a, $13 ld a, $13
ld hl, $6554 ld hl, $6554
rst $8 rst $8
@ -1559,7 +1559,7 @@ Script_reloadmap: ; 0x97491
ld a, $f3 ld a, $f3
ld [$ff9f], a ld [$ff9f], a
ld a, $1 ld a, $1
call $261b call Function261b
call StopScript call StopScript
ret ret
; 0x974a2 ; 0x974a2
@ -1835,7 +1835,7 @@ Script_priorityjump: ; 0x975aa
Script_checktriggers: ; 0x975c2 Script_checktriggers: ; 0x975c2
; script command 0x13 ; script command 0x13
call $211b call Function211b
jr z, .asm_975cb ; 0x975c5 $4 jr z, .asm_975cb ; 0x975c5 $4
ld [$c2dd], a ld [$c2dd], a
ret ret
@ -1855,7 +1855,7 @@ Script_checkmaptriggers: ; 0x975d1
ld b, a ld b, a
call GetScriptByte call GetScriptByte
ld c, a ld c, a
call $2147 call Function2147
ld a, d ld a, d
or e or e
jr z, .asm_975e5 ; 0x975de $5 jr z, .asm_975e5 ; 0x975de $5
@ -1894,7 +1894,7 @@ Script_domaptrigger: ; 0x975f5
; fallthrough ; fallthrough
Unknown_975fd: ; 0x975fd Unknown_975fd: ; 0x975fd
call $2147 call Function2147
ld a, d ld a, d
or e or e
jr z, .asm_97608 ; 0x97602 $4 jr z, .asm_97608 ; 0x97602 $4
@ -1988,7 +1988,7 @@ Script_random: ; 0x97640
ld b, a ld b, a
.asm_97653 .asm_97653
push bc push bc
call $2f8c call Random
pop bc pop bc
ld a, [$ffe1] ld a, [$ffe1]
cp b cp b
@ -1996,7 +1996,7 @@ Script_random: ; 0x97640
jr .asm_97666 ; 0x9765d $7 jr .asm_97666 ; 0x9765d $7
.asm_9765f .asm_9765f
push bc push bc
call $2f8c call Random
pop bc pop bc
ld a, [$ffe1] ld a, [$ffe1]
.asm_97666 .asm_97666
@ -2004,7 +2004,7 @@ Script_random: ; 0x97640
ld a, [$c2dd] ld a, [$c2dd]
ld c, a ld c, a
pop af pop af
call $3110 call SimpleDivide
ld [$c2dd], a ld [$c2dd], a
ret ret
; 0x97673 ; 0x97673
@ -2091,7 +2091,7 @@ Script_pokenamemem: ; 0x976ae
ld a, [$c2dd] ld a, [$c2dd]
.asm_976b7 .asm_976b7
ld [$d265], a ld [$d265], a
call $343b call GetPokemonName
ld de, StringBuffer1 ld de, StringBuffer1
Unknown_976c0: ; 0x976c0 Unknown_976c0: ; 0x976c0
@ -2205,7 +2205,7 @@ Script_readmoney: ; 0x97732
call Unknown_0x97861 call Unknown_0x97861
ld hl, StringBuffer1 ld hl, StringBuffer1
ld bc, $4306 ld bc, $4306
call $3198 call PrintNum
ld de, StringBuffer1 ld de, StringBuffer1
jp Unknown_976c0 jp Unknown_976c0
; 0x97747 ; 0x97747
@ -2217,9 +2217,9 @@ Script_readcoins: ; 0x97747
call Unknown_0x97771 call Unknown_0x97771
ld hl, StringBuffer1 ld hl, StringBuffer1
ld de, $d855 ld de, Coins
ld bc, $4206 ld bc, $4206
call $3198 call PrintNum
ld de, StringBuffer1 ld de, StringBuffer1
jp Unknown_976c0 jp Unknown_976c0
; 0x9775c ; 0x9775c
@ -2233,7 +2233,7 @@ Script_RAM2MEM: ; 0x9775c
ld de, $c2dd ld de, $c2dd
ld hl, StringBuffer1 ld hl, StringBuffer1
ld bc, $4103 ld bc, $4103
call $3198 call PrintNum
ld de, StringBuffer1 ld de, StringBuffer1
jp Unknown_976c0 jp Unknown_976c0
; 0x97771 ; 0x97771
@ -2320,7 +2320,7 @@ Script_giveitem: ; 0x977ca
call GetScriptByte call GetScriptByte
ld [$d10c], a ld [$d10c], a
ld hl, $d892 ld hl, $d892
call $2f66 call Function2f66
jr nc, .asm_977eb ; 0x977e3 $6 jr nc, .asm_977eb ; 0x977e3 $6
ld a, $1 ld a, $1
ld [$c2dd], a ld [$c2dd], a
@ -2346,7 +2346,7 @@ Script_takeitem: ; 0x977f0
ld a, $ff ld a, $ff
ld [$d107], a ld [$d107], a
ld hl, $d892 ld hl, $d892
call $2f53 call Function2f53
ret nc ret nc
ld a, $1 ld a, $1
ld [$c2dd], a ld [$c2dd], a
@ -2363,7 +2363,7 @@ Script_checkitem: ; 0x97812
call GetScriptByte call GetScriptByte
ld [$d106], a ld [$d106], a
ld hl, $d892 ld hl, $d892
call $2f79 call PickUpItem
ret nc ret nc
ld a, $1 ld a, $1
ld [$c2dd], a ld [$c2dd], a
@ -2677,7 +2677,7 @@ Script_setbit1: ; 0x97988
call GetScriptByte call GetScriptByte
ld d, a ld d, a
ld b, $1 ld b, $1
call BitTable1Func call EventFlagAction
ret ret
; 0x97996 ; 0x97996
@ -2691,7 +2691,7 @@ Script_clearbit1: ; 0x97996
call GetScriptByte call GetScriptByte
ld d, a ld d, a
ld b, $0 ld b, $0
call BitTable1Func call EventFlagAction
ret ret
; 0x979a4 ; 0x979a4
@ -2705,7 +2705,7 @@ Script_checkbit1: ; 0x979a4
call GetScriptByte call GetScriptByte
ld d, a ld d, a
ld b, $2 ld b, $2
call BitTable1Func call EventFlagAction
ld a, c ld a, c
and a and a
jr z, .asm_979b7 ; 0x979b3 $2 jr z, .asm_979b7 ; 0x979b3 $2
@ -2839,7 +2839,7 @@ Script_warp: ; 0x97a1d
ld a, $f1 ld a, $f1
ld [$ff9f], a ld [$ff9f], a
ld a, $1 ld a, $1
call $261b call Function261b
call StopScript call StopScript
ret ret
.asm_97a4a .asm_97a4a
@ -2851,7 +2851,7 @@ Script_warp: ; 0x97a1d
ld a, $fb ld a, $fb
ld [$ff9f], a ld [$ff9f], a
ld a, $1 ld a, $1
call $261b call Function261b
call StopScript call StopScript
ret ret
; 0x97a65 ; 0x97a65
@ -2935,8 +2935,8 @@ Script_changemap: ; 0x97ab3
ld [$d1a1], a ld [$d1a1], a
call GetScriptByte call GetScriptByte
ld [$d1a2], a ld [$d1a2], a
call $24e4 call Function24e4
call $2879 call Function2879
ret ret
; 0x97acc ; 0x97acc
@ -2953,10 +2953,10 @@ Script_changeblock: ; 0x97acc
call GetScriptByte call GetScriptByte
add $4 add $4
ld e, a ld e, a
call $2a66 call Function2a66
call GetScriptByte call GetScriptByte
ld [hl], a ld [hl], a
call $2879 call Function2879
ret ret
; 0x97ae3 ; 0x97ae3
@ -2965,19 +2965,19 @@ Script_reloadmappart: ; 0x97ae3
xor a xor a
ld [$ffd4], a ld [$ffd4], a
call $2173 call Function2173
call $2914 call Function2914
ld a, $41 ld a, $41
ld hl, $4061 ld hl, $4061
rst $8 rst $8
call $1ad2 call Function1ad2
ret ret
; 0x97af6 ; 0x97af6
Script_warpcheck: ; 0x97af6 Script_warpcheck: ; 0x97af6
; script command 0x8e ; script command 0x8e
call $224a call Function224a
ret nc ret nc
callba Function966d0 callba Function966d0
ret ret
@ -2996,7 +2996,7 @@ Script_newloadmap: ; 0x97b08
call GetScriptByte call GetScriptByte
ld [$ff9f], a ld [$ff9f], a
ld a, $1 ld a, $1
call $261b call Function261b
call StopScript call StopScript
ret ret
; 0x97b16 ; 0x97b16
@ -3011,7 +3011,7 @@ Script_reloadandreturn: ; 0x97b16
Script_loadfont: ; 0x97b1c Script_loadfont: ; 0x97b1c
; script command 0x47 ; script command 0x47
call $2e08 call Function2e08
ret ret
; 0x97b20 ; 0x97b20
@ -3020,7 +3020,7 @@ Script_refreshscreen: ; 0x97b20
; parameters: ; parameters:
; dummy (SingleByteParam) ; dummy (SingleByteParam)
call $2dba call ResetWindow
call GetScriptByte call GetScriptByte
ret ret
; 0x97b27 ; 0x97b27
@ -3043,8 +3043,8 @@ LoadMoveSpritesScript: ; 97b2e
Script_loadmovesprites: ; 0x97b2f Script_loadmovesprites: ; 0x97b2f
; script command 0x49 ; script command 0x49
call $2e20 call Function2e20
call $2dcf call Function2dcf
ret ret
; 0x97b36 ; 0x97b36
@ -3206,7 +3206,7 @@ Script_credits: ; 0x97bf3
DisplayCredits: DisplayCredits:
call Script_resetfuncs call Script_resetfuncs
ld a, $3 ld a, $3
call $261b call Function261b
call StopScript call StopScript
ret ret
; 0x97c05 ; 0x97c05

408
engine/serial.asm Normal file
View 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
View 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

View File

@ -6,6 +6,8 @@
; This prevents the display and audio output from lagging. ; This prevents the display and audio output from lagging.
VBlank: ; 283
push af push af
push bc push bc
push de push de
@ -26,7 +28,7 @@
ld l, a ld l, a
; down to business ; down to business
call JpHl call _hl_
; since this is called once per frame ; since this is called once per frame
call GameTimer call GameTimer

2
extras

@ -1 +1 @@
Subproject commit 4c56a6c57a4c21acff5dcf5aa1c23138f0a743c3 Subproject commit 4998994c9a624f6298f8a54a665c788825c3e8f9

View File

@ -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 6 Halt (0=Active, 1=Stop Timer)
; Bit 7 Day Counter Carry Bit (1=Counter Overflow) ; 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 ; Hardware registers
rJOYP EQU $ff00 ; Joypad (R/W) rJOYP EQU $ff00 ; Joypad (R/W)
rSB EQU $ff01 ; Serial transfer data (R/W) rSB EQU $ff01 ; Serial transfer data (R/W)
rSC EQU $ff02 ; Serial Transfer Control (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) rDIV EQU $ff04 ; Divider Register (R/W)
rTIMA EQU $ff05 ; Timer counter (R/W) rTIMA EQU $ff05 ; Timer counter (R/W)
rTMA EQU $ff06 ; Timer Modulo (R/W) rTMA EQU $ff06 ; Timer Modulo (R/W)
rTAC EQU $ff07 ; Timer Control (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) rIF EQU $ff0f ; Interrupt Flag (R/W)
rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W) rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W)
rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W) rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W)

View File

@ -41,6 +41,9 @@ hMathBuffer EQU $ffb8
hLCDStatCustom EQU $ffc6 hLCDStatCustom EQU $ffc6
hSerialSend EQU $ffcd
hSerialReceive EQU $ffce
hSCX EQU $ffcf hSCX EQU $ffcf
hSCY EQU $ffd0 hSCY EQU $ffd0
hWX EQU $ffd1 hWX EQU $ffd1

View File

@ -166,7 +166,7 @@ ParkBall: ; e8a2
.asm_e98e .asm_e98e
ld b, a ld b, a
ld [MagikarpLength], a ld [MagikarpLength], a
call RNG call Random
cp b cp b
ld a, $0 ld a, $0
@ -1212,7 +1212,7 @@ BitterBerry: ; f16a
call $7789 call $7789
ld hl, $4d81 ld hl, $4d81
call FarBattleTextBox call StdBattleTextBox
ld a, $0 ld a, $0

5031
main.asm

File diff suppressed because it is too large Load Diff

View File

@ -12,35 +12,46 @@ from extras.pokemontools.crystal import (
Signpost, Signpost,
PeopleEvent, PeopleEvent,
DataByteWordMacro, DataByteWordMacro,
ItemFragment,
text_command_classes, text_command_classes,
movement_command_classes, movement_command_classes,
music_classes, music_classes,
effect_classes, effect_classes,
) )
even_more_macros = [ def load_pokecrystal_macros():
Warp, """
XYTrigger, Construct a list of macros that are needed for pokecrystal preprocessing.
Signpost, """
PeopleEvent, ourmacros = []
DataByteWordMacro,
ItemFragment,
]
macros = command_classes even_more_macros = [
macros += even_more_macros Warp,
macros += [each[1] for each in text_command_classes] XYTrigger,
macros += movement_command_classes Signpost,
macros += music_classes PeopleEvent,
macros += effect_classes DataByteWordMacro,
]
def preprocess(macros): ourmacros += command_classes
ourmacros += even_more_macros
ourmacros += [each[1] for each in text_command_classes]
ourmacros += movement_command_classes
ourmacros += music_classes
ourmacros += effect_classes
return ourmacros
def preprocess(macro_table, lines=None):
""" """
Entry point for the preprocessor. Entry point for the preprocessor.
""" """
return preprocessor.preprocess(macros) return preprocessor.preprocess(macro_table, lines=lines)
def main():
macros = load_pokecrystal_macros()
macro_table = preprocessor.make_macro_table(macros)
preprocess(macro_table)
# only run against stdin when not included as a module # only run against stdin when not included as a module
if __name__ == "__main__": if __name__ == "__main__":
preprocess(macros) main()

View File

@ -1,16 +1,28 @@
# coding: utf-8 # coding: utf-8
"""
# Starting a new python process to preprocess each source file Starting a new python process to preprocess each source file creates too much
# creates too much overhead. Instead, a list of files to preprocess overhead. Instead, a list of files to preprocess is fed into a script run from
# is fed into a script run from a single process. a single process.
"""
import os import os
import sys import sys
import preprocessor import preprocessor
if __name__ == '__main__': def main():
macros = preprocessor.load_pokecrystal_macros()
macro_table = preprocessor.preprocessor.make_macro_table(macros)
stdout = sys.stdout
for source in sys.argv[1:]: for source in sys.argv[1:]:
dest = os.path.splitext(source)[0] + '.tx' dest = os.path.splitext(source)[0] + '.tx'
sys.stdin = open(source, 'r') sys.stdin = open(source, 'r')
sys.stdout = open(dest, 'w') sys.stdout = open(dest, 'w')
preprocessor.preprocess(preprocessor.macros) preprocessor.preprocess(macro_table)
# reset stdout
sys.stdout = stdout
if __name__ == '__main__':
main()

View File

@ -1,4 +1,254 @@
Function1f8000: ; 1f8000
ld a, [rSVBK]
push af
ld a, $3
ld [rSVBK], a
xor a
ld hl, $d100
ld bc, $00e0
call ByteFill
ld a, $ff
ld [$d10c], a
ld [$d147], a
ld [$d182], a
ld de, $d100
ld a, [hRandomAdd]
ld b, a
.asm_1f8022
call Random
ld a, [hRandomAdd]
add b
ld b, a
and $1f
cp $15
jr nc, .asm_1f8022
ld b, a
ld a, $1
call GetSRAMBank
ld c, $7
ld hl, $be48
.asm_1f803a
ld a, [hli]
cp b
jr z, .asm_1f8022
dec c
jr nz, .asm_1f803a
ld hl, $be48
ld a, [$be46]
ld c, a
ld a, b
ld b, 0
add hl, bc
ld [hl], a
call CloseSRAM
push af
ld hl, BattleTowerTrainers
ld bc, 11
call AddNTimes
ld bc, 11
call CopyBytes
call Function1f8081
pop af
ld hl, Function1f8000
ld bc, $0024
call AddNTimes
ld bc, $0024
.asm_1f8070
ld a, $7c
call GetFarByte
ld [de], a
inc hl
inc de
dec bc
ld a, b
or c
jr nz, .asm_1f8070
pop af
ld [rSVBK], a
ret
; 1f8081
Function1f8081: ; 1f8081
ld c, $3
push bc
ld a, $1
call GetSRAMBank
.asm_1f8089
ld a, [$d800]
dec a
ld hl, BattleTowerMons
ld bc, BattleTowerMons2 - BattleTowerMons1
call AddNTimes
ld a, [hRandomAdd]
ld b, a
.asm_1f8099
call Random
ld a, [hRandomAdd]
add b
ld b, a
and $1f
cp (BattleTowerMons2 - BattleTowerMons1) / ($3b)
jr nc, .asm_1f8099
ld bc, $3b
call AddNTimes
ld a, [hli]
ld b, a
ld a, [hld]
ld c, a
ld a, [$d10b]
cp b
jr z, .asm_1f8089
ld a, [$d10c]
cp c
jr z, .asm_1f8089
ld a, [$d146]
cp b
jr z, .asm_1f8089
ld a, [$d147]
cp c
jr z, .asm_1f8089
ld a, [$d181]
cp b
jr z, .asm_1f8089
ld a, [$d182]
cp c
jr z, .asm_1f8089
ld a, [$be51]
cp b
jr z, .asm_1f8089
ld a, [$be52]
cp b
jr z, .asm_1f8089
ld a, [$be53]
cp b
jr z, .asm_1f8089
ld a, [$be54]
cp b
jr z, .asm_1f8089
ld a, [$be55]
cp b
jr z, .asm_1f8089
ld a, [$be56]
cp b
jr z, .asm_1f8089
ld bc, $3b
call CopyBytes
ld a, [$d265]
push af
push de
ld hl, -$3b
add hl, de
ld a, [hl]
ld [$d265], a
ld bc, $0030
add hl, bc
push hl
call GetPokemonName
ld h, d
ld l, e
pop de
ld bc, $000b
call CopyBytes
pop de
pop af
ld [$d265], a
pop bc
dec c
jp nz, $4083
ld a, [$be51]
ld [$be54], a
ld a, [$be52]
ld [$be55], a
ld a, [$be53]
ld [$be56], a
ld a, [$d10b]
ld [$be51], a
ld a, [$d146]
ld [$be52], a
ld a, [$d181]
ld [$be53], a
call CloseSRAM
ret
; 1f814e
BattleTowerTrainers: ; 1f814e
db "HANSON@@@@", FISHER
db "SAWYER@@@@", POKEMANIAC
db "MASUDA@@@@", GUITARIST
db "NICKEL@@@@", SCIENTIST
db "OLSON@@@@@", POKEFANM
db "ZABOROWSKI", LASS
db "WRIGHT@@@@", YOUNGSTER
db "ALEXANDER@", HIKER
db "KAWAKAMI@@", TEACHER
db "BICKETT@@@", POKEFANM
db "SAITO@@@@@", KIMONO_GIRL
db "CRAWFORD@@", BOARDER
db "DIAZ@@@@@@", PICNICKER
db "ERICKSON@@", BIKER
db "FAIRFIELD@", JUGGLER
db "HUNTER@@@@", POKEFANF
db "HILL@@@@@@", FIREBREATHER
db "JAVIER@@@@", SWIMMERF
db "KAUFMAN@@@", SWIMMERM
db "LANCASTER@", SKIER
db "McMAHILL@@", CAMPER
db "OBRIEN@@@@", GENTLEMAN
db "FROST@@@@@", BEAUTY
db "MORSE@@@@@", SUPER_NERD
db "YUFUNE@@@@", BLACKBELT_T
db "RAJAN@@@@@", COOLTRAINERF
db "RODRIGUEZ@", OFFICER
db "SANTIAGO@@", PSYCHIC_T
db "STOCK@@@@@", POKEFANM
db "THURMAN@@@", SCIENTIST
db "VALENTINO@", BEAUTY
db "WAGNER@@@@", CAMPER
db "YATES@@@@@", BIRD_KEEPER
db "ANDREWS@@@", PICNICKER
db "BAHN@@@@@@", POKEMANIAC
db "MORI@@@@@@", SCIENTIST
db "BUCKMAN@@@", SAGE
db "COBB@@@@@@", SCHOOLBOY
db "HUGHES@@@@", FISHER
db "ARITA@@@@@", KIMONO_GIRL
db "EASTON@@@@", PSYCHIC_T
db "FREEMAN@@@", CAMPER
db "GIESE@@@@@", LASS
db "HATCHER@@@", GENTLEMAN
db "JACKSON@@@", POKEFANF
db "KAHN@@@@@@", POKEMANIAC
db "LEONG@@@@@", YOUNGSTER
db "MARINO@@@@", TEACHER
db "NEWMAN@@@@", SAILOR
db "NGUYEN@@@@", BLACKBELT_T
db "OGDEN@@@@@", SUPER_NERD
db "PARK@@@@@@", COOLTRAINERF
db "RAINE@@@@@", SWIMMERM
db "SELLS@@@@@", BIRD_KEEPER
db "ROCKWELL@@", BOARDER
db "THORNTON@@", LASS
db "TURNER@@@@", OFFICER
db "VAN DYKE@@", SKIER
db "WALKER@@@@", SCHOOLBOY
db "MEYER@@@@@", SWIMMERF
db "JOHNSON@@@", YOUNGSTER
db "ADAMS@@@@@", GUITARIST
db "SMITH@@@@@", BUG_CATCHER
db "TAJIRI@@@@", BUG_CATCHER
db "BAKER@@@@@", POKEMANIAC
db "COLLINS@@@", SCIENTIST
db "SMART@@@@@", SUPER_NERD
db "DYKSTRA@@@", SWIMMERF
db "EATON@@@@@", BIKER
db "WONG@@@@@@", FIREBREATHER
; 1f8450
BattleTowerMons: ; 1f8450
BattleTowerMons1: BattleTowerMons1:

465
stats/odd_eggs.asm Normal file
View File

@ -0,0 +1,465 @@
GiveOddEgg: ; 1fb4b6
; Figure out which egg to give.
call Random
ld hl, .Probabilities
ld c, 0
ld b, c
.next
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, d
cp $ff
jr nz, .first
ld a, e
cp $ff
jr z, .done
.first
ld a, [hRandomSub]
cp d
jr c, .done
jr z, .second
jr .good
.second
ld a, [hRandomAdd]
cp e
jr c, .done
jr z, .done
.good
inc bc
jr .next
.done
ld hl, OddEggs
ld a, OddEgg2 - OddEgg1
call AddNTimes
ld de, EnemyMoveAnimation
ld bc, $0046
call CopyBytes
ld a, EGG_TICKET
ld [CurItem], a
ld a, $1
ld [$d10c], a
ld a, $ff
ld [$d107], a
ld hl, NumItems
call Function2f53
ld a, EGG
ld [$cd2a], a
ld a, $29
ld [$cd20], a
ld a, $cd
ld [$cd21], a
ld a, $8
ld [$cd22], a
ld a, $c6
ld [$cd23], a
ld hl, .Odd
ld de, $cd2b
ld bc, $000b
call CopyBytes
ld a, $2b
ld [$cd24], a
ld a, $cd
ld [$cd25], a
ld a, $38
ld [$cd26], a
ld a, $c6
ld [$cd27], a
callba Function11b98f
ret
; 1fb546
.Odd
db "ODD@@@@@@@@@"
.Probabilities
dw $147a ; 92% -> 8%
dw $170a ; 91% -> 1%
dw $3fff ; 75% -> 16%
dw $47ad ; 72% -> 3%
dw $70a3 ; 56% -> 16%
dw $7851 ; 53% -> 3%
dw $9c28 ; 39% -> 14%
dw $a147 ; 37% -> 2%
dw $bae0 ; 27% -> 10%
dw $bfff ; 25% -> 2%
dw $deb7 ; 13% -> 12%
dw $e3d6 ; 11% -> 2%
dw $fd6f ; 1% -> 10%
dw $ffff ; 0% -> 1%
; 1fb56e
OddEggs: ; 1fb56e
OddEgg1:
db PICHU
db NO_ITEM
db THUNDERSHOCK, CHARM, DIZZY_PUNCH, NONE
dw 02048 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 30, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 17 ; Max HP
bigdw 9 ; Atk
bigdw 6 ; Def
bigdw 11 ; Spd
bigdw 8 ; SAtk
bigdw 8 ; SDef
db "EGG@@@@@@@@"
OddEgg2:
db PICHU
db NO_ITEM
db THUNDERSHOCK, CHARM, DIZZY_PUNCH, NONE
dw 00256 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 30, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 17 ; Max HP
bigdw 9 ; Atk
bigdw 7 ; Def
bigdw 12 ; Spd
bigdw 9 ; SAtk
bigdw 9 ; SDef
db "EGG@@@@@@@@"
db CLEFFA
db NO_ITEM
db POUND, CHARM, DIZZY_PUNCH, NONE
dw 04096 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 35, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 20 ; Max HP
bigdw 7 ; Atk
bigdw 7 ; Def
bigdw 6 ; Spd
bigdw 9 ; SAtk
bigdw 10 ; SDef
db "EGG@@@@@@@@"
db CLEFFA
db NO_ITEM
db POUND, CHARM, DIZZY_PUNCH, NONE
dw 00768 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 35, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 20 ; Max HP
bigdw 7 ; Atk
bigdw 8 ; Def
bigdw 7 ; Spd
bigdw 10 ; SAtk
bigdw 11 ; SDef
db "EGG@@@@@@@@"
db IGGLYBUFF
db NO_ITEM
db SING, CHARM, DIZZY_PUNCH, NONE
dw 04096 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 15, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 24 ; Max HP
bigdw 8 ; Atk
bigdw 6 ; Def
bigdw 6 ; Spd
bigdw 9 ; SAtk
bigdw 7 ; SDef
db "EGG@@@@@@@@"
db IGGLYBUFF
db NO_ITEM
db SING, CHARM, DIZZY_PUNCH, NONE
dw 00768 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 15, 20, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 24 ; Max HP
bigdw 8 ; Atk
bigdw 7 ; Def
bigdw 7 ; Spd
bigdw 10 ; SAtk
bigdw 8 ; SDef
db "EGG@@@@@@@@"
db SMOOCHUM
db NO_ITEM
db POUND, LICK, DIZZY_PUNCH, NONE
dw 03584 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 35, 30, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 8 ; Atk
bigdw 6 ; Def
bigdw 11 ; Spd
bigdw 13 ; SAtk
bigdw 11 ; SDef
db "EGG@@@@@@@@"
db SMOOCHUM
db NO_ITEM
db POUND, LICK, DIZZY_PUNCH, NONE
dw 00512 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 35, 30, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 8 ; Atk
bigdw 7 ; Def
bigdw 12 ; Spd
bigdw 14 ; SAtk
bigdw 12 ; SDef
db "EGG@@@@@@@@"
db MAGBY
db NO_ITEM
db EMBER, DIZZY_PUNCH, NONE, NONE
dw 02560 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 25, 10, 0, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 12 ; Atk
bigdw 8 ; Def
bigdw 13 ; Spd
bigdw 12 ; SAtk
bigdw 10 ; SDef
db "EGG@@@@@@@@"
db MAGBY
db NO_ITEM
db EMBER, DIZZY_PUNCH, NONE, NONE
dw 00512 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 25, 10, 0, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 12 ; Atk
bigdw 9 ; Def
bigdw 14 ; Spd
bigdw 13 ; SAtk
bigdw 11 ; SDef
db "EGG@@@@@@@@"
db ELEKID
db NO_ITEM
db QUICK_ATTACK, LEER, DIZZY_PUNCH, NONE
dw 03072 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 30, 30, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 11 ; Atk
bigdw 8 ; Def
bigdw 14 ; Spd
bigdw 11 ; SAtk
bigdw 10 ; SDef
db "EGG@@@@@@@@"
db ELEKID
db NO_ITEM
db QUICK_ATTACK, LEER, DIZZY_PUNCH, NONE
dw 00512 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 30, 30, 10, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 19 ; Max HP
bigdw 11 ; Atk
bigdw 9 ; Def
bigdw 15 ; Spd
bigdw 12 ; SAtk
bigdw 11 ; SDef
db "EGG@@@@@@@@"
db TYROGUE
db NO_ITEM
db TACKLE, DIZZY_PUNCH, NONE, NONE
dw 02560 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $0, $0 ; DVs
db 35, 10, 0, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 18 ; Max HP
bigdw 8 ; Atk
bigdw 8 ; Def
bigdw 8 ; Spd
bigdw 8 ; SAtk
bigdw 8 ; SDef
db "EGG@@@@@@@@"
db TYROGUE
db NO_ITEM
db TACKLE, DIZZY_PUNCH, NONE, NONE
dw 00256 ; OT ID
dt 125 ; Exp
; Stat exp
bigdw 0
bigdw 0
bigdw 0
bigdw 0
bigdw 0
db $2a, $aa ; DVs
db 35, 10, 0, 0 ; PP
db 20 ; Happiness
db 0, 0, 0 ; Pokerus, Caught data
db 5 ; Level
db 0, 0 ; Status
bigdw 0 ; HP
bigdw 18 ; Max HP
bigdw 8 ; Atk
bigdw 9 ; Def
bigdw 9 ; Spd
bigdw 9 ; SAtk
bigdw 9 ; SDef
db "EGG@@@@@@@@"

View File

@ -39,7 +39,7 @@ Fish: ; 9241a
; Fish for monsters with rod b from encounter data in FishGroup at hl. ; Fish for monsters with rod b from encounter data in FishGroup at hl.
; Return monster e at level d. ; Return monster e at level d.
call RNG call Random
; Got a bite? ; Got a bite?
cp [hl] cp [hl]
@ -59,7 +59,7 @@ Fish: ; 9241a
ld l, a ld l, a
; Encounter chance for this monster: ; Encounter chance for this monster:
call RNG call Random
.CheckEncounter .CheckEncounter
cp [hl] cp [hl]

235
wram.asm
View File

@ -13,9 +13,9 @@ VBGMap1:
SECTION "WRAMBank0",WRAM0[$c000] SECTION "WRAMBank0",WRAM0[$c000]
SECTION "stack",WRAM0[$c000] SECTION "stack",WRAM0[$c0ff]
ds $100 Stack: ; c0ff
Stack: ; c100 ds -$100
SECTION "audio",WRAM0[$c100] SECTION "audio",WRAM0[$c100]
@ -1627,7 +1627,12 @@ SATURDAY EQU 6
PlayerSprite: ; d4d8 PlayerSprite: ; d4d8
ds 1 ds 1
ds 5 ds 3
PlayerPalette: ; d4dc
ds 1
ds 1
PlayerDirection: ; d4de PlayerDirection: ; d4de
; uses bits 2 and 3 / $0c / %00001100 ; uses bits 2 and 3 / $0c / %00001100
@ -1637,8 +1642,17 @@ PlayerDirection: ; d4de
; $11 right ; $11 right
ds 1 ds 1
ds 2
PlayerAction: ; d4e1
; 1 standing
; 2 walking
; 4 spinning
; 6 fishing
ds 1
ds 2
SECTION "MapEngine",WRAMX[$d4e4],BANK[1]
StandingTile: ; d4e4 StandingTile: ; d4e4
ds 1 ds 1
StandingTile2: ; d4e5 StandingTile2: ; d4e5
@ -1698,7 +1712,10 @@ StatusFlags2: ; d84d
Money: ; d84e Money: ; d84e
ds 3 ds 3
ds 6 ds 4
Coins: ; d855
ds 2
Badges: Badges:
JohtoBadges: ; d857 JohtoBadges: ; d857
@ -1729,6 +1746,11 @@ Balls: ; d8d8
ds 25 ds 25
BallsEnd BallsEnd
PCItems: ; d8f1
ds 101
PCItemsEnd
SECTION "overworld",WRAMX[$d95b],BANK[1] SECTION "overworld",WRAMX[$d95b],BANK[1]
WhichRegisteredItem: ; d95b WhichRegisteredItem: ; d95b
REGISTERED_POCKET EQU %11000000 REGISTERED_POCKET EQU %11000000
@ -1753,23 +1775,16 @@ UndergroundSwitchPositions: ; d963
FarfetchdPosition: ; d964 FarfetchdPosition: ; d964
ds 1 ; which position the ilex farfetch'd is in ds 1 ; which position the ilex farfetch'd is in
SECTION "Events",WRAMX[$dad4],BANK[1] SECTION "Events",WRAMX[$da72],BANK[1]
EventFlags: ; da72
;RoomDecorations: ; dac6 ;RoomDecorations: ; dac6
; db 7
HoOhEvent: ; dad4
ds 1
LugiaEvent: ; dad5
ds 1
; TODO
;SuicuneEvent: ; dad8 (tin tower)
;TeamRocketAzaleaTownAttackEvent: ; db51 ;TeamRocketAzaleaTownAttackEvent: ; db51
;SudowoodoEvent: ; db51
;PoliceAtElmsLabEvent: ; db52 ;PoliceAtElmsLabEvent: ; db52
;SalesmanMahoganyTownEvent: ; db5c ;SalesmanMahoganyTownEvent: ; db5c
;RedGyaradosEvent: ; db5c ;RedGyaradosEvent: ; db5c
ds 250
; db6c
SECTION "BoxNames",WRAMX[$db75],BANK[1] SECTION "BoxNames",WRAMX[$db75],BANK[1]
; 8 chars + $50 ; 8 chars + $50
@ -1982,6 +1997,7 @@ PartyMon5Nickname: ; de6d
ds 11 ds 11
PartyMon6Nickname: ; de78 PartyMon6Nickname: ; de78
ds 11 ds 11
PartyMonNicknamesEnd
SECTION "Pokedex",WRAMX[$de99],BANK[1] SECTION "Pokedex",WRAMX[$de99],BANK[1]
PokedexSeen: ; de99 PokedexSeen: ; de99
@ -2090,12 +2106,189 @@ RoamMon3DVs: ; dfe2
SECTION "WRAMBank5",WRAMX[$d000],BANK[5] SECTION "WRAMBank5",WRAMX[$d000],BANK[5]
; 8 4-color palettes ; 8 4-color palettes
Unkn1Pals: Unkn1Pals: ; d000
ds $40 ds $40
Unkn2Pals: Unkn2Pals: ; d040
ds $40 ds $40
BGPals: BGPals: ; d080
ds $40 ds $40
OBPals: OBPals: ; d0c0
ds $40 ds $40
LYOverrides: ; d100
ds 144
LYOverridesEnd
SECTION "SRAMBank1",SRAM,BANK[1]
SECTION "BoxMons",SRAM[$ad10],BANK[1]
BoxCount: ; ad10
ds 1
BoxSpecies: ; ad11
ds 20
ds 1
BoxMons:
BoxMon1:
BoxMon1Species: ; ad26
ds 1
BoxMon1Item: ; ad27
ds 1
BoxMon1Moves: ; ad28
ds 4
BoxMon1ID: ; ad2c
ds 2
BoxMon1Exp: ; ad2e
ds 3
BoxMon1HPExp: ; ad31
ds 2
BoxMon1AtkExp: ; ad33
ds 2
BoxMon1DefExp: ; ad35
ds 2
BoxMon1SpdExp: ; ad37
ds 2
BoxMon1SpcExp: ; ad39
ds 2
BoxMon1DVs: ; ad3b
ds 2
BoxMon1PP: ; ad3d
ds 4
BoxMon1Happiness: ; ad41
ds 1
BoxMon1PokerusStatus: ; ad42
ds 1
BoxMon1CaughtData:
BoxMon1CaughtTime:
BoxMon1CaughtLevel: ; ad43
ds 1
BoxMon1CaughtGender:
BoxMon1CaughtLocation: ; ad44
ds 1
BoxMon1Level: ; ad45
ds 1
BoxMon2: ; ad46
ds 32
BoxMon3: ; ad66
ds 32
BoxMon4: ; ad86
ds 32
BoxMon5: ; ada6
ds 32
BoxMon6: ; adc6
ds 32
BoxMon7: ; ade6
ds 32
BoxMon8: ; ae06
ds 32
BoxMon9: ; ae26
ds 32
BoxMon10: ; ae46
ds 32
BoxMon11: ; ae66
ds 32
BoxMon12: ; ae86
ds 32
BoxMon13: ; aea6
ds 32
BoxMon14: ; aec6
ds 32
BoxMon15: ; aee6
ds 32
BoxMon16: ; af06
ds 32
BoxMon17: ; af26
ds 32
BoxMon18: ; af46
ds 32
BoxMon19: ; af66
ds 32
BoxMon20: ; af86
ds 32
BoxMonOT:
BoxMon1OT: ; afa6
ds 11
BoxMon2OT: ; afb1
ds 11
BoxMon3OT: ; afbc
ds 11
BoxMon4OT: ; afc7
ds 11
BoxMon5OT: ; afd2
ds 11
BoxMon6OT: ; afdd
ds 11
BoxMon7OT: ; afe8
ds 11
BoxMon8OT: ; aff3
ds 11
BoxMon9OT: ; affe
ds 11
BoxMon10OT: ; b009
ds 11
BoxMon11OT: ; b014
ds 11
BoxMon12OT: ; b01f
ds 11
BoxMon13OT: ; b02a
ds 11
BoxMon14OT: ; b035
ds 11
BoxMon15OT: ; b040
ds 11
BoxMon16OT: ; b04b
ds 11
BoxMon17OT: ; b056
ds 11
BoxMon18OT: ; b061
ds 11
BoxMon19OT: ; b06c
ds 11
BoxMon20OT: ; b077
ds 11
BoxMonNicknames:
BoxMon1Nickname: ; b082
ds 11
BoxMon2Nickname: ; b08d
ds 11
BoxMon3Nickname: ; b098
ds 11
BoxMon4Nickname: ; b0a3
ds 11
BoxMon5Nickname: ; b0ae
ds 11
BoxMon6Nickname: ; b0b9
ds 11
BoxMon7Nickname: ; b0c4
ds 11
BoxMon8Nickname: ; b0cf
ds 11
BoxMon9Nickname: ; b0da
ds 11
BoxMon10Nickname: ; b0e5
ds 11
BoxMon11Nickname: ; b0f0
ds 11
BoxMon12Nickname: ; b0fb
ds 11
BoxMon13Nickname: ; b106
ds 11
BoxMon14Nickname: ; b111
ds 11
BoxMon15Nickname: ; b11c
ds 11
BoxMon16Nickname: ; b127
ds 11
BoxMon17Nickname: ; b132
ds 11
BoxMon18Nickname: ; b13d
ds 11
BoxMon19Nickname: ; b148
ds 11
BoxMon20Nickname: ; b153
ds 11
BoxMonNicknamesEnd