ref: 0fdbdb43a794358b5ed484114486e2992d520338
parent: 112de1c1726669d4e36db015622f74f78dbf2a66
parent: b4968a9ab7dbe596354351d06458598805d37445
author: Bryan Bishop <[email protected]>
date: Fri Dec 6 19:50:26 EST 2013
Merge pull request #217 from yenatch/more-objects compile and link multiple objects
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,10 @@
*.gbc
*.gb
+# rgbds extras
+*.map
+*.sym
+
# generated
*.tx
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,19 @@
TEXTFILES := $(shell find ./ -type f -name '*.asm' | grep -v globals.asm)
TEXTQUEUE :=
-OBJS := pokecrystal.o
+CRYSTAL_OBJS := \
+wram.o \
+main.o \
+engine/events.o \
+engine/scripting_crystal.o \
+engine/events_2.o \
+stats/egg_moves_crystal.o \
+stats/evos_attacks_crystal.o
+OBJS := $(CRYSTAL_OBJS)
+
+ROMS := pokecrystal.gbc
+
PNGS := $(shell find gfx/ -type f -name '*.png')
LZS := $(shell find gfx/ -type f -name '*.lz')
_2BPPS := $(shell find gfx/ -type f -name '*.2bpp')
@@ -21,10 +32,11 @@
) \
)
-all: baserom.gbc globals.asm pokecrystal.gbc
+all: baserom.gbc globals.asm $(ROMS)
cmp baserom.gbc pokecrystal.gbc
clean:
- rm -f pokecrystal.o pokecrystal.gbc
+ rm -f $(ROMS)
+ rm -f $(OBJS)
rm -f globals.asm globals.tx
@echo 'Removing preprocessed .tx files...'
@rm -f $(TEXTFILES:.asm=.tx)
@@ -45,7 +57,7 @@
$(OBJS): $$(patsubst %.o,%.tx,$$@) $$(patsubst %.asm,%.tx,$$(OBJ_$$(patsubst %.o,%,$$@)))
rgbasm -o $@ $(@:.o=.tx)
-pokecrystal.gbc: $(OBJS)
+pokecrystal.gbc: $(CRYSTAL_OBJS)
rgblink -n pokecrystal.sym -m pokecrystal.map -o pokecrystal.gbc $^
rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
--- a/constants.asm
+++ b/constants.asm
@@ -1,10 +1,3 @@
-_CRYSTAL EQU 1
-
-if _CRYSTAL
-VERSION EQU 0
-else
-VERSION EQU 1
-endc
; wram constants
; MonType: ; cf5f
--- /dev/null
+++ b/engine/events.asm
@@ -1,0 +1,1112 @@
+INCLUDE "includes.asm"
+
+SECTION "events", ROMX, BANK[$25]
+
+Function966b0: ; 966b0
+ xor a
+ ld [$d432], a
+.asm_966b4
+ ld a, [$d432]
+ ld hl, .pointers
+ rst JumpTable
+ ld a, [$d432]
+ cp 3 ; done
+ jr nz, .asm_966b4
+.done
+ ret
+
+.pointers
+ dw Function96724
+ dw Function9673e
+ dw Function96773
+ dw .done
+; 966cb
+
+
+Function966cb: ; 966cb
+ xor a
+ ld [ScriptFlags3], a
+ ret
+; 966d0
+
+Function966d0: ; 966d0
+ ld a, $ff
+ ld [ScriptFlags3], a
+ ret
+; 966d6
+
+Function966d6: ; 966d6
+ ld hl, ScriptFlags3
+ bit 5, [hl]
+ ret
+; 966dc
+
+Function966dc: ; 966dc
+ ld hl, ScriptFlags3
+ res 2, [hl]
+ ret
+; 966e2
+
+Function966e2: ; 966e2
+ ld hl, ScriptFlags3
+ res 1, [hl]
+ ret
+; 966e8
+
+Function966e8: ; 966e8
+ ld hl, ScriptFlags3
+ res 0, [hl]
+ ret
+; 966ee
+
+Function966ee: ; 966ee
+ ld hl, ScriptFlags3
+ res 4, [hl]
+ ret
+; 966f4
+
+Function966f4: ; 966f4
+ ld hl, ScriptFlags3
+ set 2, [hl]
+ ret
+; 966fa
+
+Function966fa: ; 966fa
+ ld hl, ScriptFlags3
+ set 1, [hl]
+ ret
+; 96700
+
+Function96700: ; 96700
+ ld hl, ScriptFlags3
+ set 0, [hl]
+ ret
+; 96706
+
+Function96706: ; 96706
+ ld hl, ScriptFlags3
+ set 4, [hl]
+ ret
+; 9670c
+
+Function9670c: ; 9670c
+ ld hl, ScriptFlags3
+ bit 2, [hl]
+ ret
+; 96712
+
+Function96712: ; 96712
+ ld hl, ScriptFlags3
+ bit 1, [hl]
+ ret
+; 96718
+
+Function96718: ; 96718
+ ld hl, ScriptFlags3
+ bit 0, [hl]
+ ret
+; 9671e
+
+Function9671e: ; 9671e
+ ld hl, ScriptFlags3
+ bit 4, [hl]
+ ret
+; 96724
+
+
+Function96724: ; 96724
+ xor a
+ ld [ScriptVar], a
+ xor a
+ ld [ScriptRunning], a
+ ld hl, $d432
+ ld bc, $3e
+ call ByteFill
+ callba Function113e5
+ call ClearJoypadPublic
+ ; fallthrough
+; 9673e
+
+
+Function9673e: ; 9673e
+ xor a
+ ld [$d453], a
+ ld [$d454], a
+ call Function968d1
+ callba Function15363
+ call Function966cb
+ ld a, [$ff9f]
+ cp $f7
+ jr nz, .asm_9675a
+ call Function966d0
+.asm_9675a
+ ld a, [$ff9f]
+ cp $f3
+ jr nz, .asm_96764
+ xor a
+ ld [PoisonStepCount], a
+.asm_96764
+ xor a
+ ld [$ff9f], a
+ ld a, $2
+ ld [$d432], a
+ ret
+; 9676d
+
+
+Function9676d: ; 9676d
+ ld c, 30
+ call DelayFrames
+ ret
+; 96773
+
+
+Function96773: ; 96773
+ call ResetOverworldDelay
+ call Function967c1
+ callba Function97e08
+ call DoEvents
+ ld a, [$d432]
+ cp 2
+ ret nz
+ call Function967d1
+ call NextOverworldFrame
+ call Function967e1
+ call Function967f4
+ ret
+; 96795
+
+
+DoEvents: ; 96795
+ ld a, [$d433]
+ ld hl, .pointers
+ rst JumpTable
+ ret
+
+.pointers
+ dw Function967a1
+ dw Function967ae
+; 967a1
+
+Function967a1: ; 967a1
+ call PlayerEvents
+ call Function966cb
+ callba ScriptEvents
+ ret
+; 967ae
+
+Function967ae: ; 967ae
+ ret
+; 967af
+
+
+MaxOverworldDelay: ; 967af
+ db 2
+; 967b0
+
+ResetOverworldDelay: ; 967b0
+ ld a, [MaxOverworldDelay]
+ ld [OverworldDelay], a
+ ret
+; 967b7
+
+NextOverworldFrame: ; 967b7
+ ld a, [OverworldDelay]
+ and a
+ ret z
+ ld c, a
+ call DelayFrames
+ ret
+; 967c1
+
+
+Function967c1: ; 967c1
+ ld a, [$d433]
+ cp 1
+ ret z
+ call UpdateTime
+ call GetJoypadPublic
+ call TimeOfDayPals
+ ret
+; 967d1
+
+Function967d1: ; 967d1
+ callba Function576a
+ callba Functiond497
+ call Function96812
+ ret
+; 967e1
+
+Function967e1: ; 967e1
+ callba Function5920
+ callba Functiond4d2
+ callba Functionb8098
+ ret
+; 967f4
+
+Function967f4: ; 967f4
+ ld a, [$d150]
+ bit 5, a
+ jr z, .asm_96806
+ bit 6, a
+ jr z, .asm_9680c
+ bit 4, a
+ jr nz, .asm_9680c
+ call Function966d0
+
+.asm_96806
+ ld a, $0
+ ld [$d433], a
+ ret
+
+.asm_9680c
+ ld a, $1
+ ld [$d433], a
+ ret
+; 96812
+
+Function96812: ; 96812
+ ld hl, $d150
+ bit 6, [hl]
+ ret z
+ callba Function81ca
+
+ ret
+; 9681f
+
+
+PlayerEvents: ; 9681f
+
+ xor a
+
+ ld a, [ScriptRunning]
+ and a
+ ret nz
+
+ call Function968e4
+
+ call CheckTrainerBattle3
+ jr c, .asm_96848
+
+ call CheckTileEvent
+ jr c, .asm_96848
+
+ call Function97c30
+ jr c, .asm_96848
+
+ call Function968ec
+ jr c, .asm_96848
+
+ call Function9693a
+ jr c, .asm_96848
+
+ call OWPlayerInput
+ jr c, .asm_96848
+
+ xor a
+ ret
+
+
+.asm_96848
+ push af
+ callba Function96c56
+ pop af
+
+ ld [ScriptRunning], a
+ call Function96beb
+ ld a, [ScriptRunning]
+ cp 4
+ jr z, .asm_96865
+ cp 9
+ jr z, .asm_96865
+
+ xor a
+ ld [$c2da], a
+
+.asm_96865
+ scf
+ ret
+; 96867
+
+
+CheckTrainerBattle3: ; 96867
+ nop
+ nop
+ call CheckTrainerBattle2
+ jr nc, .asm_96872
+ ld a, 1
+ scf
+ ret
+
+.asm_96872
+ xor a
+ ret
+; 96874
+
+
+CheckTileEvent: ; 96874
+; Check for warps, tile triggers or wild battles.
+
+ call Function9670c
+ jr z, .asm_96886
+
+ callba Function104820
+ jr c, .asm_968a6
+
+ call Function2238
+ jr c, .asm_968aa
+
+.asm_96886
+ call Function96712
+ jr z, .asm_96890
+
+ call Function2ad4
+ jr c, .asm_968ba
+
+.asm_96890
+ call Function96718
+ jr z, .asm_96899
+
+ call CountStep
+ ret c
+
+.asm_96899
+ call Function9671e
+ jr z, .asm_968a4
+
+ call Function97cc0
+ ret c
+ jr .asm_968a4
+
+.asm_968a4
+ xor a
+ ret
+
+.asm_968a6
+ ld a, 4
+ scf
+ ret
+
+.asm_968aa
+ ld a, [StandingTile]
+ call CheckPitTile
+ jr nz, .asm_968b6
+ ld a, 6
+ scf
+ ret
+
+.asm_968b6
+ ld a, 5
+ scf
+ ret
+
+.asm_968ba
+ ld hl, MovementAnimation
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptHeaderBank
+ call CallScript
+ ret
+; 968c7
+
+
+Function968c7: ; 968c7
+ ld hl, $d452
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+ ret z
+ scf
+ ret
+; 968d1
+
+Function968d1: ; 968d1
+ ld a, 5
+ ld [$d452], a
+ ret
+; 968d7
+
+Function968d7: ; 968d7
+ ret
+; 968d8
+
+Function968d8: ; 968d8
+ ld a, [$d452]
+ cp 2
+ ret nc
+ ld a, 2
+ ld [$d452], a
+ ret
+; 968e4
+
+Function968e4: ; 968e4
+ call Function966d6
+ ret z
+ call Function2f3e
+ ret
+; 968ec
+
+Function968ec: ; 968ec
+ ld a, [$dc07]
+ and a
+ jr z, .asm_96938
+
+ ld c, a
+ call Function211b
+ cp c
+ jr nc, .asm_96938
+
+ ld e, a
+ ld d, 0
+ ld hl, $dc08
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+
+ call GetMapScriptHeaderBank
+ call GetFarHalfword
+ call GetMapScriptHeaderBank
+ call CallScript
+
+ ld hl, ScriptFlags
+ res 3, [hl]
+
+ callba Function96c56
+ callba ScriptEvents
+
+ ld hl, ScriptFlags
+ bit 3, [hl]
+ jr z, .asm_96938
+
+ ld hl, $d44f
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [$d44e]
+ call CallScript
+ scf
+ ret
+
+.asm_96938
+ xor a
+ ret
+; 9693a
+
+Function9693a: ; 9693a
+ ld a, [InLinkBattle]
+ and a
+ jr nz, .asm_96964
+ ld hl, StatusFlags2
+ bit 2, [hl]
+ jr z, .asm_96951
+ callba Function114a4
+ jr c, .asm_96966
+ xor a
+ ret
+
+.asm_96951
+ callba Function11452
+ callba Function114e7
+ callba Function90074
+ ret c
+
+.asm_96964
+ xor a
+ ret
+
+.asm_96966
+ ld a, $4
+ ld hl, $75f8
+ call CallScript
+ scf
+ ret
+; 96970
+
+Function96970: ; 96970
+ ld a, 8
+ scf
+ ret
+; 96974
+
+
+OWPlayerInput: ; 96974
+
+ call PlayerMovement
+ ret c
+ and a
+ jr nz, .NoAction
+
+; Can't perform button actions while sliding on ice.
+ callba Function80404
+ jr c, .NoAction
+
+ call CheckAPressOW
+ jr c, .Action
+
+ call CheckMenuOW
+ jr c, .Action
+
+.NoAction
+ xor a
+ ret
+
+.Action
+ push af
+ callba Function80422
+ pop af
+ scf
+ ret
+; 96999
+
+
+CheckAPressOW: ; 96999
+ ld a, [hJoyPressed]
+ and A_BUTTON
+ ret z
+ call TryObjectEvent
+ ret c
+ call TryReadSign
+ ret c
+ call Function97c5f
+ ret c
+ xor a
+ ret
+; 969ac
+
+
+PlayTalkObject: ; 969ac
+ push de
+ ld de, SFX_READ_TEXT_2
+ call PlaySFX
+ pop de
+ ret
+; 969b5
+
+
+TryObjectEvent: ; 969b5
+ callba CheckFacingObject
+ jr c, .IsObject
+ xor a
+ ret
+
+.IsObject
+ call PlayTalkObject
+ ld a, [hConnectedMapWidth]
+ call Function1ae5
+ ld hl, $0001
+ add hl, bc
+ ld a, [hl]
+ ld [$ffe0], a
+
+ ld a, [$ffe0]
+ call GetMapObject
+ ld hl, $0008
+ add hl, bc
+ ld a, [hl]
+ and $f
+
+; Bug: If IsInArray returns nc, data at bc will be executed as code.
+ push bc
+ ld de, 3
+ ld hl, .data_969ee
+ call IsInArray
+ jr nc, .asm_969ec
+ pop bc
+
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+
+.asm_969ec
+ xor a
+ ret
+
+.data_969ee
+ dbw 0, .zero
+ dbw 1, .one
+ dbw 2, .two
+ dbw 3, .three
+ dbw 4, .four
+ dbw 5, .five
+ dbw 6, .six
+ db $ff
+; 96a04
+
+.zero ; 96a04
+ ld hl, $000a
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptHeaderBank
+ call CallScript
+; ld a, -1
+ ret
+; 96a12
+
+.one ; 96a12
+ ld hl, $000a
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptHeaderBank
+ ld de, EngineBuffer1
+ ld bc, 2
+ call FarCopyBytes
+ ld a, 3
+ scf
+ ret
+; 96a29
+
+.two ; 96a29
+ call Function3674
+ ld a, 2
+ scf
+ ret
+; 96a30
+
+.three ; 96a30
+ xor a
+ ret
+; 96a32
+
+.four ; 96a32
+ xor a
+ ret
+; 96a34
+
+.five ; 96a34
+ xor a
+ ret
+; 96a36
+
+.six ; 96a36
+ xor a
+ ret
+; 96a38
+
+
+TryReadSign: ; 96a38
+ call CheckFacingSign
+ jr c, .IsSign
+ xor a
+ ret
+
+.IsSign
+ ld a, [MartPointer]
+ ld hl, .signs
+ rst JumpTable
+ ret
+
+.signs
+ dw .read
+ dw .up
+ dw .down
+ dw .right
+ dw .left
+ dw .ifset
+ dw .ifnotset
+ dw .itemifset
+ dw .asm_96aa2
+; 96a59
+
+.up
+ ld b, UP << 2
+ jr .checkdir
+.down
+ ld b, DOWN << 2
+ jr .checkdir
+.right
+ ld b, RIGHT << 2
+ jr .checkdir
+.left
+ ld b, LEFT << 2
+ jr .checkdir
+
+.checkdir
+ ld a, [PlayerDirection]
+ and %1100
+ cp b
+ jp nz, .dontread
+
+.read
+ call PlayTalkObject
+ ld hl, $d041
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptHeaderBank
+ call CallScript
+ scf
+ ret
+
+.itemifset
+ call CheckSignFlag
+ jp nz, .dontread
+ call PlayTalkObject
+ call GetMapScriptHeaderBank
+ ld de, EngineBuffer1
+ ld bc, 3
+ call FarCopyBytes
+ ld a, $4
+ ld hl, $7625
+ call CallScript
+ scf
+ ret
+
+.asm_96aa2
+ call CheckSignFlag
+ jr nz, .dontread
+ call GetMapScriptHeaderBank
+ ld de, EngineBuffer1
+ ld bc, 3
+ call FarCopyBytes
+ jr .dontread
+
+.ifset
+ call CheckSignFlag
+ jr z, .dontread
+ jr .asm_96ac1
+
+.ifnotset
+ call CheckSignFlag
+ jr nz, .dontread
+
+.asm_96ac1
+ push hl
+ call PlayTalkObject
+ pop hl
+ inc hl
+ inc hl
+ call GetMapScriptHeaderBank
+ call GetFarHalfword
+ call GetMapScriptHeaderBank
+ call CallScript
+ scf
+ ret
+
+.dontread
+ xor a
+ ret
+; 96ad8
+
+
+CheckSignFlag: ; 96ad8
+ ld hl, $d041
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ push hl
+ call GetMapScriptHeaderBank
+ call GetFarHalfword
+ ld e, l
+ ld d, h
+ ld b, $2
+ call EventFlagAction
+ ld a, c
+ and a
+ pop hl
+ ret
+; 96af0
+
+
+PlayerMovement: ; 96af0
+ callba DoPlayerMovement
+ ld a, c
+ ld hl, .pointers
+ rst JumpTable
+ ld a, c
+ ret
+; 96afd
+
+.pointers
+ dw .zero
+ dw .one
+ dw .two
+ dw .three
+ dw .four
+ dw .five
+ dw .six
+ dw .seven
+
+.zero
+.four ; 96b0d
+ xor a
+ ld c, a
+ ret
+; 96b10
+
+.seven ; 96b10
+ call Function968d7 ; empty
+ xor a
+ ld c, a
+ ret
+; 96b16
+
+.one ; 96b16
+ ld a, 5
+ ld c, a
+ scf
+ ret
+; 96b1b
+
+.two ; 96b1b
+ ld a, 9
+ ld c, a
+ scf
+ ret
+; 96b20
+
+.three ; 96b20
+; force the player to move in some direction
+ ld a, $4
+ ld hl, $653d
+ call CallScript
+; ld a, -1
+ ld c, a
+ scf
+ ret
+; 96b2b
+
+.five
+.six ; 96b2b
+ ld a, -1
+ ld c, a
+ and a
+ ret
+; 96b30
+
+
+CheckMenuOW: ; 96b30
+ xor a
+ ld [$ffa0], a
+ ld [$ffa1], a
+ ld a, [hJoyPressed]
+
+ bit 2, a ; SELECT
+ jr nz, .Select
+
+ bit 3, a ; START
+ jr z, .NoMenu
+
+ ld a, BANK(StartMenuScript)
+ ld hl, StartMenuScript
+ call CallScript
+ scf
+ ret
+
+.NoMenu
+ xor a
+ ret
+
+.Select
+ call PlayTalkObject
+ ld a, BANK(SelectMenuScript)
+ ld hl, SelectMenuScript
+ call CallScript
+ scf
+ ret
+; 96b58
+
+
+StartMenuScript: ; 96b58
+ 3callasm BANK(StartMenu), StartMenu
+ 2jump StartMenuCallback
+; 96b5f
+
+SelectMenuScript: ; 96b5f
+ 3callasm BANK(SelectMenu), SelectMenu
+ 2jump SelectMenuCallback
+; 96b66
+
+StartMenuCallback:
+SelectMenuCallback: ; 96b66
+ copybytetovar $ffa0
+ if_equal $80, .Script
+ if_equal $ff, .Asm
+ end
+; 96b72
+
+.Script ; 96b72
+ 2ptjump $d0e8
+; 96b75
+
+.Asm ; 96b75
+ 2ptcallasm $d0e8
+ end
+; 96b79
+
+
+CountStep: ; 96b79
+ ld a, [InLinkBattle]
+ and a
+ jr nz, .asm_96bc9
+
+ callba Function90136
+ jr c, .asm_96bcb
+
+ call Function96bd7
+ jr c, .asm_96bcb
+
+ ld hl, PoisonStepCount
+ inc [hl]
+ ld hl, StepCount
+ inc [hl]
+ jr nz, .asm_96b9c
+
+ callba StepHappiness
+
+.asm_96b9c
+ ld a, [StepCount]
+ cp $80
+ jr nz, .asm_96bab
+
+ callba Function16f3e
+ jr nz, .asm_96bcf
+
+.asm_96bab
+ callba DaycareStep
+
+ ld hl, PoisonStepCount
+ ld a, [hl]
+ cp 4
+ jr c, .asm_96bc3
+ ld [hl], 0
+
+ callba Function505da
+ jr c, .asm_96bcb
+
+.asm_96bc3
+ callba Function97db3
+
+.asm_96bc9
+ xor a
+ ret
+
+.asm_96bcb
+ ld a, -1
+ scf
+ ret
+
+.asm_96bcf
+ ld a, 8
+ scf
+ ret
+; 96bd3
+
+
+Function96bd3: ; 96bd3
+ ld a, $7
+ scf
+ ret
+; 96bd7
+
+Function96bd7: ; 96bd7
+ ld a, [$dca1]
+ and a
+ ret z
+ dec a
+ ld [$dca1], a
+ ret nz
+ ld a, $4
+ ld hl, $7619
+ call CallScript
+ scf
+ ret
+; 96beb
+
+Function96beb: ; 96beb
+ ld a, [ScriptRunning]
+ and a
+ ret z
+ cp $ff
+ ret z
+ cp $a
+ ret nc
+
+ ld c, a
+ ld b, 0
+ ld hl, ScriptPointers96c0c
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld [ScriptBank], a
+ ld a, [hli]
+ ld [ScriptPos], a
+ ld a, [hl]
+ ld [ScriptPos + 1], a
+ ret
+; 96c0c
+
+ScriptPointers96c0c: ; 96c0c
+ dbw BANK(UnknownScript_0x96c2d), UnknownScript_0x96c2d
+ dbw BANK(UnknownScript_0xbe675), UnknownScript_0xbe675
+ dbw BANK(UnknownScript_0xbe66a), UnknownScript_0xbe66a
+ dbw BANK(UnknownScript_0x122ce), UnknownScript_0x122ce
+ dbw BANK(UnknownScript_0x96c4d), UnknownScript_0x96c4d
+ dbw BANK(UnknownScript_0x96c34), UnknownScript_0x96c34
+ dbw BANK(FallIntoMapScript), FallIntoMapScript
+ dbw BANK(UnknownScript_0x124c8), UnknownScript_0x124c8
+ dbw BANK(UnknownScript_0x96c2f), UnknownScript_0x96c2f
+ dbw BANK(UnknownScript_0x96c4f), UnknownScript_0x96c4f
+ dbw BANK(UnknownScript_0x96c2d), UnknownScript_0x96c2d
+; 96c2d
+
+UnknownScript_0x96c2d: ; 96c2d
+ end
+; 96c2e
+
+UnknownScript_0x96c2e: ; 96c2e
+ end
+; 96c2f
+
+UnknownScript_0x96c2f: ; 96c2f
+ 3callasm $05, $6f5e
+ end
+; 96c34
+
+UnknownScript_0x96c34: ; 96c34
+ warpsound
+ newloadmap $f5
+ end
+; 96c38
+
+FallIntoMapScript: ; 96c38
+ newloadmap $f6
+ playsound SFX_KINESIS
+ applymovement $0, MovementData_0x96c48
+ playsound SFX_STRENGTH
+ 2call UnknownScript_0x96c4a
+ end
+; 96c48
+
+MovementData_0x96c48: ; 96c48
+ skyfall
+ step_end
+; 96c4a
+
+UnknownScript_0x96c4a: ; 96c4a
+ earthquake 16
+ end
+; 96c4d
+
+UnknownScript_0x96c4d: ; 96c4d
+ reloadandreturn $f7
+; 96c4f
+
+UnknownScript_0x96c4f: ; 96c4f
+ deactivatefacing $3
+ 3callasm BANK(Function96706), Function96706
+ end
+; 96c56
+
--- /dev/null
+++ b/engine/events_2.asm
@@ -1,0 +1,647 @@
+INCLUDE "includes.asm"
+
+; More overworld event handling.
+
+SECTION "events2", ROMX, BANK[$25]
+
+Function97c28: ; 97c28
+ ld hl, StatusFlags2
+ res 1, [hl]
+ res 2, [hl]
+ ret
+; 97c30
+
+Function97c30: ; 97c30
+ ld a, [$d45c]
+ and a
+ ret z
+ ld hl, $d45e
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [$d45d]
+ call CallScript
+ scf
+ push af
+ xor a
+ ld hl, $d45c
+ ld bc, 8
+ call ByteFill
+ pop af
+ ret
+; 97c4f
+
+Function97c4f: ; 97c4f
+ ld hl, $d45c
+ ld a, [hl]
+ and a
+ ret nz
+ ld [hl], 1
+ inc hl
+ ld [hl], b
+ inc hl
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ scf
+ ret
+; 97c5f
+
+Function97c5f: ; 97c5f
+ call GetFacingTileCoord
+ ld [EngineBuffer1], a
+ ld c, a
+ callba Function1365b
+ jr c, .asm_97cb9
+
+ call CheckCutTreeTile
+ jr nz, .whirlpool
+ callba TryCutOW
+ jr .asm_97cb9
+
+.whirlpool
+ ld a, [EngineBuffer1]
+ call CheckWhirlpoolTile
+ jr nz, .waterfall
+ callba TryWhirlpoolOW
+ jr .asm_97cb9
+
+.waterfall
+ ld a, [EngineBuffer1]
+ call CheckWaterfallTile
+ jr nz, .headbutt
+ callba TryWaterfallOW
+ jr .asm_97cb9
+
+.headbutt
+ ld a, [EngineBuffer1]
+ call CheckHeadbuttTreeTile
+ jr nz, .surf
+ callba TryHeadbuttOW
+ jr c, .asm_97cb9
+ jr .asm_97cb7
+
+.surf
+ callba TrySurfOW
+ jr nc, .asm_97cb7
+ jr .asm_97cb9
+
+.asm_97cb7
+ xor a
+ ret
+
+.asm_97cb9
+ call PlayClickSFX
+ ld a, $ff
+ scf
+ ret
+; 97cc0
+
+
+Function97cc0: ; 97cc0
+; Rock Smash encounter
+
+ call Function968c7
+ jr c, .asm_97ce2
+ call Function97cfd
+ jr nc, .asm_97ce2
+ ld hl, StatusFlags2
+ bit 2, [hl]
+ jr nz, .asm_97cdb
+ callba Function2a0e7
+ jr nz, .asm_97ce2
+ jr .asm_97ce6
+
+.asm_97cdb
+ call Function97d23
+ jr nc, .asm_97ce2
+ jr .asm_97ced
+
+.asm_97ce2
+ ld a, 1
+ and a
+ ret
+
+.asm_97ce6
+ ld a, BANK(RockSmashBattleScript)
+ ld hl, RockSmashBattleScript
+ jr .asm_97cf4
+
+.asm_97ced
+ ld a, BANK(UnknownScript_0x135eb)
+ ld hl, UnknownScript_0x135eb
+ jr .asm_97cf4
+
+.asm_97cf4
+ call CallScript
+ scf
+ ret
+; 97cf9
+
+RockSmashBattleScript: ; 97cf9
+ battlecheck
+ startbattle
+ returnafterbattle
+ end
+; 97cfd
+
+Function97cfd: ; 97cfd
+ ld hl, StatusFlags
+ bit 5, [hl]
+ jr nz, .asm_97d21
+ ld a, [$d19a]
+ cp $4
+ jr z, .asm_97d17
+ cp $7
+ jr z, .asm_97d17
+ callba Function149dd
+ jr nc, .asm_97d21
+
+.asm_97d17
+ ld a, [StandingTile]
+ call CheckIceTile
+ jr z, .asm_97d21
+ scf
+ ret
+
+.asm_97d21
+ and a
+ ret
+; 97d23
+
+Function97d23: ; 97d23
+ call Function97d64
+ ret nc
+ call Function97d31
+ callba Function2a1df
+ ret
+; 97d31
+
+Function97d31: ; 97d31
+; Pick a random mon out of ContestMons.
+
+.asm_97d31
+ call Random
+ cp 100 << 1
+ jr nc, .asm_97d31
+ srl a
+
+ ld hl, ContestMons
+ ld de, 4
+.CheckMon
+ sub [hl]
+ jr c, .GotMon
+ add hl, de
+ jr .CheckMon
+
+.GotMon
+ inc hl
+
+; Species
+ ld a, [hli]
+ ld [$d22e], a
+
+; Min level
+ ld a, [hli]
+ ld d, a
+
+; Max level
+ ld a, [hl]
+
+ sub d
+ jr nz, .RandomLevel
+
+; If min and max are the same.
+ ld a, d
+ jr .GotLevel
+
+.RandomLevel
+; Get a random level between the min and max.
+ ld c, a
+ inc c
+ call Random
+ ld a, [hRandomAdd]
+ call SimpleDivide
+ add d
+
+.GotLevel
+ ld [CurPartyLevel], a
+
+ xor a
+ ret
+; 97d64
+
+Function97d64: ; 97d64
+ ld a, [StandingTile]
+ call Function188e
+ ld b, $66
+ jr z, .asm_97d70
+ ld b, $33
+
+.asm_97d70
+ callba Function2a124
+ callba Function2a138
+ call Random
+ ld a, [hRandomAdd]
+ cp b
+ ret c
+ ld a, 1
+ and a
+ ret
+; 97d87
+
+ContestMons: ; 97d87
+ ; %, species, min, max
+ db 20, CATERPIE, 7, 18
+ db 20, WEEDLE, 7, 18
+ db 10, METAPOD, 9, 18
+ db 10, KAKUNA, 9, 18
+ db 5, BUTTERFREE, 12, 15
+ db 5, BEEDRILL, 12, 15
+ db 10, VENONAT, 10, 16
+ db 10, PARAS, 10, 17
+ db 5, SCYTHER, 13, 14
+ db 5, PINSIR, 13, 14
+ db -1, VENOMOTH, 30, 40
+; 97db3
+
+Function97db3: ; 97db3
+ nop
+ nop
+ ; fallthrough
+; 97db5
+
+Function97db5: ; 97db5
+ ld hl, StatusFlags2
+ bit 4, [hl]
+ jr z, .asm_97df7
+ ld a, [PlayerState]
+ cp $1
+ jr nz, .asm_97df7
+ call Function2d05
+ and a
+ jr nz, .asm_97df7
+ ld hl, $dca2
+ ld a, [hli]
+ ld d, a
+ ld e, [hl]
+ cp $ff
+ jr nz, .asm_97dd8
+ ld a, e
+ cp $ff
+ jr z, .asm_97ddc
+
+.asm_97dd8
+ inc de
+ ld [hl], e
+ dec hl
+ ld [hl], d
+
+.asm_97ddc
+ ld a, d
+ cp $4
+ jr c, .asm_97df7
+ ld a, [$dc31]
+ and a
+ jr nz, .asm_97df7
+ ld a, $6
+ ld [$dc31], a
+ xor a
+ ld [$dc32], a
+ ld hl, StatusFlags2
+ res 4, [hl]
+ scf
+ ret
+
+.asm_97df7
+ xor a
+ ret
+; 97df9
+
+Function97df9: ; 97df9
+ ld hl, $d6de
+ ld de, $0006
+ ld c, $4
+ xor a
+.asm_97e02
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .asm_97e02
+ ret
+; 97e08
+
+Function97e08: ; 97e08
+ ld hl, $d6de
+ xor a
+.asm_97e0c
+ ld [hConnectionStripLength], a
+ ld a, [hl]
+ and a
+ jr z, .asm_97e19
+ push hl
+ ld b, h
+ ld c, l
+ call Function97e79
+ pop hl
+
+.asm_97e19
+ ld de, $0006
+ add hl, de
+ ld a, [hConnectionStripLength]
+ inc a
+ cp $4
+ jr nz, .asm_97e0c
+ ret
+; 97e25
+
+Function97e25: ; 97e25
+ ld hl, $d6de
+ ld bc, 6
+ call AddNTimes
+ ld b, h
+ ld c, l
+ ret
+; 97e31
+
+Function97e31: ; 97e31
+ push bc
+ push de
+ call Function97e45
+ ld d, h
+ ld e, l
+ pop hl
+ pop bc
+ ret c
+ ld a, b
+ ld bc, $0005
+ call FarCopyBytes
+ xor a
+ ld [hl], a
+ ret
+; 97e45
+
+Function97e45: ; 97e45
+ ld hl, $d6de
+ ld de, $0006
+ ld c, $4
+.asm_97e4d
+ ld a, [hl]
+ and a
+ jr z, .asm_97e57
+ add hl, de
+ dec c
+ jr nz, .asm_97e4d
+ scf
+ ret
+
+.asm_97e57
+ ld a, $4
+ sub c
+ and a
+ ret
+; 97e5c
+
+Function97e5c: ; 97e5c
+ ld hl, $d6de
+ ld de, $0006
+ ld c, $4
+.asm_97e64
+ ld a, [hl]
+ cp b
+ jr z, .asm_97e6e
+ add hl, de
+ dec c
+ jr nz, .asm_97e64
+ and a
+ ret
+
+.asm_97e6e
+ xor a
+ ld [hl], a
+ scf
+ ret
+; 97e72
+
+Function97e72: ; 97e72
+ ld hl, $0000
+ add hl, bc
+ ld [hl], 0
+ ret
+; 97e79
+
+Function97e79: ; 97e79
+ ld hl, $0000
+ add hl, bc
+ ld a, [hl]
+ cp 5
+ jr c, .asm_97e83
+ xor a
+
+.asm_97e83
+ ld e, a
+ ld d, 0
+ ld hl, Table97e94
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ push af
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop af
+ rst FarCall
+ ret
+; 97e94
+
+Table97e94: ; 97e94
+ dbw BANK(Function97eb7), Function97eb7
+ dbw BANK(Function97eb8), Function97eb8
+ dbw BANK(Function97f42), Function97f42
+ dbw BANK(Function97ef9), Function97ef9
+ dbw BANK(Function97ebc), Function97ebc
+; 97ea3
+
+Function97ea3: ; 97ea3
+ ld hl, $0005
+ add hl, bc
+ ld a, [hl]
+ pop hl
+ rst JumpTable
+ ret
+; 97eab
+
+Function97eab: ; 97eab
+ ld hl, $0005
+ add hl, bc
+ inc [hl]
+ ret
+; 97eb1
+
+Function97eb1: ; 97eb1
+ ld hl, $0005
+ add hl, bc
+ dec [hl]
+ ret
+; 97eb7
+
+Function97eb7: ; 97eb7
+ ret
+; 97eb8
+
+Function97eb8: ; 97eb8
+ call Function2f3e
+ ret
+; 97ebc
+
+Function97ebc: ; 97ebc
+ call Function97ea3
+ dw Function97ec3
+ dw Function97ecd
+; 97ec3
+
+Function97ec3: ; 97ec3
+ ld a, [hSCY]
+ ld hl, $0004
+ add hl, bc
+ ld [hl], a
+ call Function97eab
+; 97ecd
+
+Function97ecd: ; 97ecd
+ ld hl, $0001
+ add hl, bc
+ ld a, [hl]
+ dec a
+ ld [hl], a
+ jr z, .asm_97eee
+ and $1
+ jr z, .asm_97ee4
+ ld hl, $0002
+ add hl, bc
+ ld a, [hSCY]
+ sub [hl]
+ ld [hSCY], a
+ ret
+
+.asm_97ee4
+ ld hl, $0002
+ add hl, bc
+ ld a, [hSCY]
+ add [hl]
+ ld [hSCY], a
+ ret
+
+.asm_97eee
+ ld hl, $0004
+ add hl, bc
+ ld a, [hl]
+ ld [hSCY], a
+ call Function97e72
+ ret
+; 97ef9
+
+Function97ef9: ; 97ef9
+ call Function97ea3
+ dw Function97f02
+ dw Function97f0a
+ dw Function97f1b
+; 97f02
+
+Function97f02: ; 97f02
+ call Function97f38
+ jr z, Function97f2c
+ call Function97eab
+; 97f0a
+
+Function97f0a: ; 97f0a
+ call Function97f38
+ jr z, Function97f2c
+ call Function97eab
+
+ ld hl, $0002
+ add hl, bc
+ ld a, [hl]
+ ld [$d173], a
+ ret
+; 97f1b
+
+Function97f1b: ; 97f1b
+ call Function97f38
+ jr z, Function97f2c
+ call Function97eb1
+
+ ld hl, $0003
+ add hl, bc
+ ld a, [hl]
+ ld [$d173], a
+ ret
+; 97f2c
+
+Function97f2c: ; 97f2c
+ ld a, $7f
+ ld [$d173], a
+ ld hl, $0005
+ add hl, bc
+ ld [hl], 0
+ ret
+; 97f38
+
+Function97f38: ; 97f38
+ push bc
+ ld bc, $d4d6
+ call GetSpriteDirection
+ and a
+ pop bc
+ ret
+; 97f42
+
+Function97f42: ; 97f42
+ ld de, $d4d6
+ ld a, $d
+.asm_97f47
+ push af
+
+ ld hl, $0000
+ add hl, de
+ ld a, [hl]
+ and a
+ jr z, .asm_97f71
+
+ ld hl, $0003
+ add hl, de
+ ld a, [hl]
+ cp $19
+ jr nz, .asm_97f71
+
+ ld hl, $000e
+ add hl, de
+ ld a, [hl]
+ call CheckPitTile
+ jr nz, .asm_97f71
+
+ ld hl, $0007
+ add hl, de
+ ld a, [hl]
+ cp $ff
+ jr nz, .asm_97f71
+ call Function3567
+ jr c, .asm_97f7c
+
+.asm_97f71
+ ld hl, $0028
+ add hl, de
+ ld d, h
+ ld e, l
+
+ pop af
+ dec a
+ jr nz, .asm_97f47
+ ret
+
+.asm_97f7c
+ pop af
+ ret
+; 97f7e
+
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -1,3 +1,75 @@
+; Event scripting commands.
+
+
+Function96c56: ; 96c56
+ push af
+ ld a, 1
+ ld [ScriptMode], a
+ pop af
+ ret
+; 96c5e
+
+
+ScriptEvents: ; 96c5e
+ call StartScript
+.loop
+ ld a, [ScriptMode]
+ ld hl, .modes
+ rst JumpTable
+ call CheckScript
+ jr nz, .loop
+ ret
+; 96c6e
+
+.modes ; 96c6e
+ dw EndScript
+ dw RunScriptCommand
+ dw WaitScriptMovement
+ dw WaitScript
+
+EndScript: ; 96c76
+ call StopScript
+ ret
+; 96c7a
+
+WaitScript: ; 96c7a
+ call StopScript
+
+ ld hl, ScriptDelay
+ dec [hl]
+ ret nz
+
+ callba Function58b9
+
+ ld a, SCRIPT_READ
+ ld [ScriptMode], a
+ call StartScript
+ ret
+; 96c91
+
+WaitScriptMovement: ; 96c91
+ call StopScript
+
+ ld hl, VramState
+ bit 7, [hl]
+ ret nz
+
+ callba Function58b9
+
+ ld a, SCRIPT_READ
+ ld [ScriptMode], a
+ call StartScript
+ ret
+; 96ca9
+
+RunScriptCommand: ; 96ca9
+ call GetScriptByte
+ ld hl, ScriptCommandTable
+ rst JumpTable
+ ret
+; 96cb1
+
+
ScriptCommandTable: ; 0x96cb1
dw Script_2call
dw Script_3call
@@ -81,7 +153,9 @@
dw Script_loadmenudata
dw Script_writebackup
dw Script_jumptextfaceplayer
+IF _CRYSTAL
dw Script_3jumptext
+ENDC
dw Script_jumptext
dw Script_closetext
dw Script_keeptextopen
@@ -279,6 +353,9 @@
end
; 0x96e81
+
+IF _CRYSTAL
+
Script_3jumptext: ; 0x96e81
; script command 0x52
; parameters:
@@ -295,6 +372,9 @@
jp ScriptJump
; 0x96e9b
+ENDC
+
+
Script_2writetext: ; 0x96e9b
; script command 0x4c
; parameters:
@@ -3117,7 +3197,7 @@
call Function261b
call StopScript
ret
-; 0x97c05
+; 0x97c051
Script_wait: ; 0x97c05
; script command 0xa8
@@ -3145,4 +3225,14 @@
ld [$c2dd], a
ret
; 0x97c20
+
+
+Function97c20: ; 97c20
+ ld a, [.byte]
+ ld [ScriptVar], a
+ ret
+
+.byte
+ db 0
+; 97c28
--- /dev/null
+++ b/engine/scripting_crystal.asm
@@ -1,0 +1,5 @@
+INCLUDE "pokecrystal.asm"
+INCLUDE "includes.asm"
+
+SECTION "scripting", ROMX, BANK[$25]
+INCLUDE "engine/scripting.asm"
--- /dev/null
+++ b/includes.asm
@@ -1,0 +1,2 @@
+INCLUDE "globals.asm"
+INCLUDE "constants.asm"
--- a/main.asm
+++ b/main.asm
@@ -1,3 +1,6 @@
+INCLUDE "includes.asm"
+
+
SECTION "bank0",ROM0
INCLUDE "rst.asm"
@@ -31420,10 +31423,7 @@
INCLUDE "tilesets/data_3.asm"
-EggMovePointers: ; 0x23b11
-INCLUDE "stats/egg_move_pointers.asm"
-INCLUDE "stats/egg_moves.asm"
SECTION "bank9",ROMX,BANK[$9]
@@ -54676,10 +54676,7 @@
; 425b1
-EvosAttacksPointers: ; 0x425b1
-INCLUDE "stats/evos_attacks_pointers.asm"
-INCLUDE "stats/evos_attacks.asm"
SECTION "bank11",ROMX,BANK[$11]
@@ -85550,1874 +85547,11 @@
SECTION "bank25",ROMX,BANK[$25]
-MapGroupPointers: ; 0x94000
-; pointers to the first map header of each map group
- dw MapGroup1
- dw MapGroup2
- dw MapGroup3
- dw MapGroup4
- dw MapGroup5
- dw MapGroup6
- dw MapGroup7
- dw MapGroup8
- dw MapGroup9
- dw MapGroup10
- dw MapGroup11
- dw MapGroup12
- dw MapGroup13
- dw MapGroup14
- dw MapGroup15
- dw MapGroup16
- dw MapGroup17
- dw MapGroup18
- dw MapGroup19
- dw MapGroup20
- dw MapGroup21
- dw MapGroup22
- dw MapGroup23
- dw MapGroup24
- dw MapGroup25
- dw MapGroup26
-
-
INCLUDE "maps/map_headers.asm"
-
INCLUDE "maps/second_map_headers.asm"
-Function966b0: ; 966b0
- xor a
- ld [$d432], a
-.asm_966b4
- ld a, [$d432]
- ld hl, .pointers
- rst JumpTable
- ld a, [$d432]
- cp 3 ; done
- jr nz, .asm_966b4
-.done
- ret
-.pointers
- dw Function96724
- dw Function9673e
- dw Function96773
- dw .done
-; 966cb
-
-
-Function966cb: ; 966cb
- xor a
- ld [ScriptFlags3], a
- ret
-; 966d0
-
-Function966d0: ; 966d0
- ld a, $ff
- ld [ScriptFlags3], a
- ret
-; 966d6
-
-Function966d6: ; 966d6
- ld hl, ScriptFlags3
- bit 5, [hl]
- ret
-; 966dc
-
-Function966dc: ; 966dc
- ld hl, ScriptFlags3
- res 2, [hl]
- ret
-; 966e2
-
-Function966e2: ; 966e2
- ld hl, ScriptFlags3
- res 1, [hl]
- ret
-; 966e8
-
-Function966e8: ; 966e8
- ld hl, ScriptFlags3
- res 0, [hl]
- ret
-; 966ee
-
-Function966ee: ; 966ee
- ld hl, ScriptFlags3
- res 4, [hl]
- ret
-; 966f4
-
-Function966f4: ; 966f4
- ld hl, ScriptFlags3
- set 2, [hl]
- ret
-; 966fa
-
-Function966fa: ; 966fa
- ld hl, ScriptFlags3
- set 1, [hl]
- ret
-; 96700
-
-Function96700: ; 96700
- ld hl, ScriptFlags3
- set 0, [hl]
- ret
-; 96706
-
-Function96706: ; 96706
- ld hl, ScriptFlags3
- set 4, [hl]
- ret
-; 9670c
-
-Function9670c: ; 9670c
- ld hl, ScriptFlags3
- bit 2, [hl]
- ret
-; 96712
-
-Function96712: ; 96712
- ld hl, ScriptFlags3
- bit 1, [hl]
- ret
-; 96718
-
-Function96718: ; 96718
- ld hl, ScriptFlags3
- bit 0, [hl]
- ret
-; 9671e
-
-Function9671e: ; 9671e
- ld hl, ScriptFlags3
- bit 4, [hl]
- ret
-; 96724
-
-
-Function96724: ; 96724
- xor a
- ld [ScriptVar], a
- xor a
- ld [ScriptRunning], a
- ld hl, $d432
- ld bc, $3e
- call ByteFill
- callba Function113e5
- call ClearJoypadPublic
- ; fallthrough
-; 9673e
-
-
-Function9673e: ; 9673e
- xor a
- ld [$d453], a
- ld [$d454], a
- call Function968d1
- callba Function15363
- call Function966cb
- ld a, [$ff9f]
- cp $f7
- jr nz, .asm_9675a
- call Function966d0
-.asm_9675a
- ld a, [$ff9f]
- cp $f3
- jr nz, .asm_96764
- xor a
- ld [PoisonStepCount], a
-.asm_96764
- xor a
- ld [$ff9f], a
- ld a, $2
- ld [$d432], a
- ret
-; 9676d
-
-
-Function9676d: ; 9676d
- ld c, 30
- call DelayFrames
- ret
-; 96773
-
-
-Function96773: ; 96773
- call ResetOverworldDelay
- call Function967c1
- callba Function97e08
- call DoEvents
- ld a, [$d432]
- cp 2
- ret nz
- call Function967d1
- call NextOverworldFrame
- call Function967e1
- call Function967f4
- ret
-; 96795
-
-
-DoEvents: ; 96795
- ld a, [$d433]
- ld hl, .pointers
- rst JumpTable
- ret
-
-.pointers
- dw Function967a1
- dw Function967ae
-; 967a1
-
-Function967a1: ; 967a1
- call PlayerEvents
- call Function966cb
- callba ScriptEvents
- ret
-; 967ae
-
-Function967ae: ; 967ae
- ret
-; 967af
-
-
-MaxOverworldDelay: ; 967af
- db 2
-; 967b0
-
-ResetOverworldDelay: ; 967b0
- ld a, [MaxOverworldDelay]
- ld [OverworldDelay], a
- ret
-; 967b7
-
-NextOverworldFrame: ; 967b7
- ld a, [OverworldDelay]
- and a
- ret z
- ld c, a
- call DelayFrames
- ret
-; 967c1
-
-
-Function967c1: ; 967c1
- ld a, [$d433]
- cp 1
- ret z
- call UpdateTime
- call GetJoypadPublic
- call TimeOfDayPals
- ret
-; 967d1
-
-Function967d1: ; 967d1
- callba Function576a
- callba Functiond497
- call Function96812
- ret
-; 967e1
-
-Function967e1: ; 967e1
- callba Function5920
- callba Functiond4d2
- callba Functionb8098
- ret
-; 967f4
-
-Function967f4: ; 967f4
- ld a, [$d150]
- bit 5, a
- jr z, .asm_96806
- bit 6, a
- jr z, .asm_9680c
- bit 4, a
- jr nz, .asm_9680c
- call Function966d0
-
-.asm_96806
- ld a, $0
- ld [$d433], a
- ret
-
-.asm_9680c
- ld a, $1
- ld [$d433], a
- ret
-; 96812
-
-Function96812: ; 96812
- ld hl, $d150
- bit 6, [hl]
- ret z
- callba Function81ca
-
- ret
-; 9681f
-
-
-PlayerEvents: ; 9681f
-
- xor a
-
- ld a, [ScriptRunning]
- and a
- ret nz
-
- call Function968e4
-
- call CheckTrainerBattle3
- jr c, .asm_96848
-
- call CheckTileEvent
- jr c, .asm_96848
-
- call Function97c30
- jr c, .asm_96848
-
- call Function968ec
- jr c, .asm_96848
-
- call Function9693a
- jr c, .asm_96848
-
- call OWPlayerInput
- jr c, .asm_96848
-
- xor a
- ret
-
-
-.asm_96848
- push af
- callba Function96c56
- pop af
-
- ld [ScriptRunning], a
- call Function96beb
- ld a, [ScriptRunning]
- cp 4
- jr z, .asm_96865
- cp 9
- jr z, .asm_96865
-
- xor a
- ld [$c2da], a
-
-.asm_96865
- scf
- ret
-; 96867
-
-
-CheckTrainerBattle3: ; 96867
- nop
- nop
- call CheckTrainerBattle2
- jr nc, .asm_96872
- ld a, 1
- scf
- ret
-
-.asm_96872
- xor a
- ret
-; 96874
-
-
-CheckTileEvent: ; 96874
-; Check for warps, tile triggers or wild battles.
-
- call Function9670c
- jr z, .asm_96886
-
- callba Function104820
- jr c, .asm_968a6
-
- call Function2238
- jr c, .asm_968aa
-
-.asm_96886
- call Function96712
- jr z, .asm_96890
-
- call Function2ad4
- jr c, .asm_968ba
-
-.asm_96890
- call Function96718
- jr z, .asm_96899
-
- call CountStep
- ret c
-
-.asm_96899
- call Function9671e
- jr z, .asm_968a4
-
- call Function97cc0
- ret c
- jr .asm_968a4
-
-.asm_968a4
- xor a
- ret
-
-.asm_968a6
- ld a, 4
- scf
- ret
-
-.asm_968aa
- ld a, [StandingTile]
- call CheckPitTile
- jr nz, .asm_968b6
- ld a, 6
- scf
- ret
-
-.asm_968b6
- ld a, 5
- scf
- ret
-
-.asm_968ba
- ld hl, MovementAnimation
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call GetMapScriptHeaderBank
- call CallScript
- ret
-; 968c7
-
-
-Function968c7: ; 968c7
- ld hl, $d452
- ld a, [hl]
- and a
- ret z
- dec [hl]
- ret z
- scf
- ret
-; 968d1
-
-Function968d1: ; 968d1
- ld a, 5
- ld [$d452], a
- ret
-; 968d7
-
-Function968d7: ; 968d7
- ret
-; 968d8
-
-Function968d8: ; 968d8
- ld a, [$d452]
- cp 2
- ret nc
- ld a, 2
- ld [$d452], a
- ret
-; 968e4
-
-Function968e4: ; 968e4
- call Function966d6
- ret z
- call Function2f3e
- ret
-; 968ec
-
-Function968ec: ; 968ec
- ld a, [$dc07]
- and a
- jr z, .asm_96938
-
- ld c, a
- call Function211b
- cp c
- jr nc, .asm_96938
-
- ld e, a
- ld d, 0
- ld hl, $dc08
- ld a, [hli]
- ld h, [hl]
- ld l, a
- add hl, de
- add hl, de
- add hl, de
- add hl, de
-
- call GetMapScriptHeaderBank
- call GetFarHalfword
- call GetMapScriptHeaderBank
- call CallScript
-
- ld hl, ScriptFlags
- res 3, [hl]
-
- callba Function96c56
- callba ScriptEvents
-
- ld hl, ScriptFlags
- bit 3, [hl]
- jr z, .asm_96938
-
- ld hl, $d44f
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [$d44e]
- call CallScript
- scf
- ret
-
-.asm_96938
- xor a
- ret
-; 9693a
-
-Function9693a: ; 9693a
- ld a, [InLinkBattle]
- and a
- jr nz, .asm_96964
- ld hl, StatusFlags2
- bit 2, [hl]
- jr z, .asm_96951
- callba Function114a4
- jr c, .asm_96966
- xor a
- ret
-
-.asm_96951
- callba Function11452
- callba Function114e7
- callba Function90074
- ret c
-
-.asm_96964
- xor a
- ret
-
-.asm_96966
- ld a, $4
- ld hl, $75f8
- call CallScript
- scf
- ret
-; 96970
-
-Function96970: ; 96970
- ld a, 8
- scf
- ret
-; 96974
-
-
-OWPlayerInput: ; 96974
-
- call PlayerMovement
- ret c
- and a
- jr nz, .NoAction
-
-; Can't perform button actions while sliding on ice.
- callba Function80404
- jr c, .NoAction
-
- call CheckAPressOW
- jr c, .Action
-
- call CheckMenuOW
- jr c, .Action
-
-.NoAction
- xor a
- ret
-
-.Action
- push af
- callba Function80422
- pop af
- scf
- ret
-; 96999
-
-
-CheckAPressOW: ; 96999
- ld a, [hJoyPressed]
- and A_BUTTON
- ret z
- call TryObjectEvent
- ret c
- call TryReadSign
- ret c
- call Function97c5f
- ret c
- xor a
- ret
-; 969ac
-
-
-PlayTalkObject: ; 969ac
- push de
- ld de, SFX_READ_TEXT_2
- call PlaySFX
- pop de
- ret
-; 969b5
-
-
-TryObjectEvent: ; 969b5
- callba CheckFacingObject
- jr c, .IsObject
- xor a
- ret
-
-.IsObject
- call PlayTalkObject
- ld a, [hConnectedMapWidth]
- call Function1ae5
- ld hl, $0001
- add hl, bc
- ld a, [hl]
- ld [$ffe0], a
-
- ld a, [$ffe0]
- call GetMapObject
- ld hl, $0008
- add hl, bc
- ld a, [hl]
- and $f
-
-; Bug: If IsInArray returns nc, data at bc will be executed as code.
- push bc
- ld de, 3
- ld hl, .data_969ee
- call IsInArray
- jr nc, .asm_969ec
- pop bc
-
- inc hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-
-.asm_969ec
- xor a
- ret
-
-.data_969ee
- dbw 0, .zero
- dbw 1, .one
- dbw 2, .two
- dbw 3, .three
- dbw 4, .four
- dbw 5, .five
- dbw 6, .six
- db $ff
-; 96a04
-
-.zero ; 96a04
- ld hl, $000a
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call GetMapScriptHeaderBank
- call CallScript
-; ld a, -1
- ret
-; 96a12
-
-.one ; 96a12
- ld hl, $000a
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call GetMapScriptHeaderBank
- ld de, EngineBuffer1
- ld bc, 2
- call FarCopyBytes
- ld a, 3
- scf
- ret
-; 96a29
-
-.two ; 96a29
- call Function3674
- ld a, 2
- scf
- ret
-; 96a30
-
-.three ; 96a30
- xor a
- ret
-; 96a32
-
-.four ; 96a32
- xor a
- ret
-; 96a34
-
-.five ; 96a34
- xor a
- ret
-; 96a36
-
-.six ; 96a36
- xor a
- ret
-; 96a38
-
-
-TryReadSign: ; 96a38
- call CheckFacingSign
- jr c, .IsSign
- xor a
- ret
-
-.IsSign
- ld a, [MartPointer]
- ld hl, .signs
- rst JumpTable
- ret
-
-.signs
- dw .read
- dw .up
- dw .down
- dw .right
- dw .left
- dw .ifset
- dw .ifnotset
- dw .itemifset
- dw .asm_96aa2
-; 96a59
-
-.up
- ld b, UP << 2
- jr .checkdir
-.down
- ld b, DOWN << 2
- jr .checkdir
-.right
- ld b, RIGHT << 2
- jr .checkdir
-.left
- ld b, LEFT << 2
- jr .checkdir
-
-.checkdir
- ld a, [PlayerDirection]
- and %1100
- cp b
- jp nz, .dontread
-
-.read
- call PlayTalkObject
- ld hl, $d041
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call GetMapScriptHeaderBank
- call CallScript
- scf
- ret
-
-.itemifset
- call CheckSignFlag
- jp nz, .dontread
- call PlayTalkObject
- call GetMapScriptHeaderBank
- ld de, EngineBuffer1
- ld bc, 3
- call FarCopyBytes
- ld a, $4
- ld hl, $7625
- call CallScript
- scf
- ret
-
-.asm_96aa2
- call CheckSignFlag
- jr nz, .dontread
- call GetMapScriptHeaderBank
- ld de, EngineBuffer1
- ld bc, 3
- call FarCopyBytes
- jr .dontread
-
-.ifset
- call CheckSignFlag
- jr z, .dontread
- jr .asm_96ac1
-
-.ifnotset
- call CheckSignFlag
- jr nz, .dontread
-
-.asm_96ac1
- push hl
- call PlayTalkObject
- pop hl
- inc hl
- inc hl
- call GetMapScriptHeaderBank
- call GetFarHalfword
- call GetMapScriptHeaderBank
- call CallScript
- scf
- ret
-
-.dontread
- xor a
- ret
-; 96ad8
-
-
-CheckSignFlag: ; 96ad8
- ld hl, $d041
- ld a, [hli]
- ld h, [hl]
- ld l, a
- push hl
- call GetMapScriptHeaderBank
- call GetFarHalfword
- ld e, l
- ld d, h
- ld b, $2
- call EventFlagAction
- ld a, c
- and a
- pop hl
- ret
-; 96af0
-
-
-PlayerMovement: ; 96af0
- callba DoPlayerMovement
- ld a, c
- ld hl, .pointers
- rst JumpTable
- ld a, c
- ret
-; 96afd
-
-.pointers
- dw .zero
- dw .one
- dw .two
- dw .three
- dw .four
- dw .five
- dw .six
- dw .seven
-
-.zero
-.four ; 96b0d
- xor a
- ld c, a
- ret
-; 96b10
-
-.seven ; 96b10
- call Function968d7 ; empty
- xor a
- ld c, a
- ret
-; 96b16
-
-.one ; 96b16
- ld a, 5
- ld c, a
- scf
- ret
-; 96b1b
-
-.two ; 96b1b
- ld a, 9
- ld c, a
- scf
- ret
-; 96b20
-
-.three ; 96b20
-; force the player to move in some direction
- ld a, $4
- ld hl, $653d
- call CallScript
-; ld a, -1
- ld c, a
- scf
- ret
-; 96b2b
-
-.five
-.six ; 96b2b
- ld a, -1
- ld c, a
- and a
- ret
-; 96b30
-
-
-CheckMenuOW: ; 96b30
- xor a
- ld [$ffa0], a
- ld [$ffa1], a
- ld a, [hJoyPressed]
-
- bit 2, a ; SELECT
- jr nz, .Select
-
- bit 3, a ; START
- jr z, .NoMenu
-
- ld a, BANK(StartMenuScript)
- ld hl, StartMenuScript
- call CallScript
- scf
- ret
-
-.NoMenu
- xor a
- ret
-
-.Select
- call PlayTalkObject
- ld a, BANK(SelectMenuScript)
- ld hl, SelectMenuScript
- call CallScript
- scf
- ret
-; 96b58
-
-
-StartMenuScript: ; 96b58
- 3callasm BANK(StartMenu), StartMenu
- 2jump StartMenuCallback
-; 96b5f
-
-SelectMenuScript: ; 96b5f
- 3callasm BANK(SelectMenu), SelectMenu
- 2jump SelectMenuCallback
-; 96b66
-
-StartMenuCallback:
-SelectMenuCallback: ; 96b66
- copybytetovar $ffa0
- if_equal $80, .Script
- if_equal $ff, .Asm
- end
-; 96b72
-
-.Script ; 96b72
- 2ptjump $d0e8
-; 96b75
-
-.Asm ; 96b75
- 2ptcallasm $d0e8
- end
-; 96b79
-
-
-CountStep: ; 96b79
- ld a, [InLinkBattle]
- and a
- jr nz, .asm_96bc9
-
- callba Function90136
- jr c, .asm_96bcb
-
- call Function96bd7
- jr c, .asm_96bcb
-
- ld hl, PoisonStepCount
- inc [hl]
- ld hl, StepCount
- inc [hl]
- jr nz, .asm_96b9c
-
- callba StepHappiness
-
-.asm_96b9c
- ld a, [StepCount]
- cp $80
- jr nz, .asm_96bab
-
- callba Function16f3e
- jr nz, .asm_96bcf
-
-.asm_96bab
- callba DaycareStep
-
- ld hl, PoisonStepCount
- ld a, [hl]
- cp 4
- jr c, .asm_96bc3
- ld [hl], 0
-
- callba Function505da
- jr c, .asm_96bcb
-
-.asm_96bc3
- callba Function97db3
-
-.asm_96bc9
- xor a
- ret
-
-.asm_96bcb
- ld a, -1
- scf
- ret
-
-.asm_96bcf
- ld a, 8
- scf
- ret
-; 96bd3
-
-
-Function96bd3: ; 96bd3
- ld a, $7
- scf
- ret
-; 96bd7
-
-Function96bd7: ; 96bd7
- ld a, [$dca1]
- and a
- ret z
- dec a
- ld [$dca1], a
- ret nz
- ld a, $4
- ld hl, $7619
- call CallScript
- scf
- ret
-; 96beb
-
-Function96beb: ; 96beb
- ld a, [ScriptRunning]
- and a
- ret z
- cp $ff
- ret z
- cp $a
- ret nc
-
- ld c, a
- ld b, 0
- ld hl, ScriptPointers96c0c
- add hl, bc
- add hl, bc
- add hl, bc
- ld a, [hli]
- ld [ScriptBank], a
- ld a, [hli]
- ld [ScriptPos], a
- ld a, [hl]
- ld [ScriptPos + 1], a
- ret
-; 96c0c
-
-ScriptPointers96c0c: ; 96c0c
- dbw BANK(UnknownScript_0x96c2d), UnknownScript_0x96c2d
- dbw BANK(UnknownScript_0xbe675), UnknownScript_0xbe675
- dbw BANK(UnknownScript_0xbe66a), UnknownScript_0xbe66a
- dbw BANK(UnknownScript_0x122ce), UnknownScript_0x122ce
- dbw BANK(UnknownScript_0x96c4d), UnknownScript_0x96c4d
- dbw BANK(UnknownScript_0x96c34), UnknownScript_0x96c34
- dbw BANK(FallIntoMapScript), FallIntoMapScript
- dbw BANK(UnknownScript_0x124c8), UnknownScript_0x124c8
- dbw BANK(UnknownScript_0x96c2f), UnknownScript_0x96c2f
- dbw BANK(UnknownScript_0x96c4f), UnknownScript_0x96c4f
- dbw BANK(UnknownScript_0x96c2d), UnknownScript_0x96c2d
-; 96c2d
-
-UnknownScript_0x96c2d: ; 96c2d
- end
-; 96c2e
-
-UnknownScript_0x96c2e: ; 96c2e
- end
-; 96c2f
-
-UnknownScript_0x96c2f: ; 96c2f
- 3callasm $05, $6f5e
- end
-; 96c34
-
-UnknownScript_0x96c34: ; 96c34
- warpsound
- newloadmap $f5
- end
-; 96c38
-
-FallIntoMapScript: ; 96c38
- newloadmap $f6
- playsound SFX_KINESIS
- applymovement $0, MovementData_0x96c48
- playsound SFX_STRENGTH
- 2call UnknownScript_0x96c4a
- end
-; 96c48
-
-MovementData_0x96c48: ; 96c48
- skyfall
- step_end
-; 96c4a
-
-UnknownScript_0x96c4a: ; 96c4a
- earthquake 16
- end
-; 96c4d
-
-UnknownScript_0x96c4d: ; 96c4d
- reloadandreturn $f7
-; 96c4f
-
-UnknownScript_0x96c4f: ; 96c4f
- deactivatefacing $3
- 3callasm BANK(Function96706), Function96706
- end
-; 96c56
-
-
-Function96c56: ; 96c56
- push af
- ld a, 1
- ld [ScriptMode], a
- pop af
- ret
-; 96c5e
-
-
-ScriptEvents: ; 96c5e
- call StartScript
-.loop
- ld a, [ScriptMode]
- ld hl, .modes
- rst JumpTable
- call CheckScript
- jr nz, .loop
- ret
-; 96c6e
-
-.modes ; 96c6e
- dw EndScript
- dw RunScriptCommand
- dw WaitScriptMovement
- dw WaitScript
-
-EndScript: ; 96c76
- call StopScript
- ret
-; 96c7a
-
-WaitScript: ; 96c7a
- call StopScript
-
- ld hl, ScriptDelay
- dec [hl]
- ret nz
-
- callba Function58b9
-
- ld a, SCRIPT_READ
- ld [ScriptMode], a
- call StartScript
- ret
-; 96c91
-
-WaitScriptMovement: ; 96c91
- call StopScript
-
- ld hl, VramState
- bit 7, [hl]
- ret nz
-
- callba Function58b9
-
- ld a, SCRIPT_READ
- ld [ScriptMode], a
- call StartScript
- ret
-; 96ca9
-
-RunScriptCommand: ; 96ca9
- call GetScriptByte
- ld hl, ScriptCommandTable
- rst JumpTable
- ret
-; 96cb1
-
-
-INCLUDE "engine/scripting.asm"
-
-
-Function97c20: ; 97c20
- ld a, [.byte]
- ld [ScriptVar], a
- ret
-
-.byte
- db 0
-; 97c28
-
-Function97c28: ; 97c28
- ld hl, StatusFlags2
- res 1, [hl]
- res 2, [hl]
- ret
-; 97c30
-
-Function97c30: ; 97c30
- ld a, [$d45c]
- and a
- ret z
- ld hl, $d45e
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [$d45d]
- call CallScript
- scf
- push af
- xor a
- ld hl, $d45c
- ld bc, 8
- call ByteFill
- pop af
- ret
-; 97c4f
-
-Function97c4f: ; 97c4f
- ld hl, $d45c
- ld a, [hl]
- and a
- ret nz
- ld [hl], 1
- inc hl
- ld [hl], b
- inc hl
- ld [hl], e
- inc hl
- ld [hl], d
- scf
- ret
-; 97c5f
-
-Function97c5f: ; 97c5f
- call GetFacingTileCoord
- ld [EngineBuffer1], a
- ld c, a
- callba Function1365b
- jr c, .asm_97cb9
-
- call CheckCutTreeTile
- jr nz, .whirlpool
- callba TryCutOW
- jr .asm_97cb9
-
-.whirlpool
- ld a, [EngineBuffer1]
- call CheckWhirlpoolTile
- jr nz, .waterfall
- callba TryWhirlpoolOW
- jr .asm_97cb9
-
-.waterfall
- ld a, [EngineBuffer1]
- call CheckWaterfallTile
- jr nz, .headbutt
- callba TryWaterfallOW
- jr .asm_97cb9
-
-.headbutt
- ld a, [EngineBuffer1]
- call CheckHeadbuttTreeTile
- jr nz, .surf
- callba TryHeadbuttOW
- jr c, .asm_97cb9
- jr .asm_97cb7
-
-.surf
- callba TrySurfOW
- jr nc, .asm_97cb7
- jr .asm_97cb9
-
-.asm_97cb7
- xor a
- ret
-
-.asm_97cb9
- call PlayClickSFX
- ld a, $ff
- scf
- ret
-; 97cc0
-
-
-Function97cc0: ; 97cc0
-; Rock Smash encounter
-
- call Function968c7
- jr c, .asm_97ce2
- call Function97cfd
- jr nc, .asm_97ce2
- ld hl, StatusFlags2
- bit 2, [hl]
- jr nz, .asm_97cdb
- callba Function2a0e7
- jr nz, .asm_97ce2
- jr .asm_97ce6
-
-.asm_97cdb
- call Function97d23
- jr nc, .asm_97ce2
- jr .asm_97ced
-
-.asm_97ce2
- ld a, 1
- and a
- ret
-
-.asm_97ce6
- ld a, BANK(RockSmashBattleScript)
- ld hl, RockSmashBattleScript
- jr .asm_97cf4
-
-.asm_97ced
- ld a, BANK(UnknownScript_0x135eb)
- ld hl, UnknownScript_0x135eb
- jr .asm_97cf4
-
-.asm_97cf4
- call CallScript
- scf
- ret
-; 97cf9
-
-RockSmashBattleScript: ; 97cf9
- battlecheck
- startbattle
- returnafterbattle
- end
-; 97cfd
-
-Function97cfd: ; 97cfd
- ld hl, StatusFlags
- bit 5, [hl]
- jr nz, .asm_97d21
- ld a, [$d19a]
- cp $4
- jr z, .asm_97d17
- cp $7
- jr z, .asm_97d17
- callba Function149dd
- jr nc, .asm_97d21
-
-.asm_97d17
- ld a, [StandingTile]
- call CheckIceTile
- jr z, .asm_97d21
- scf
- ret
-
-.asm_97d21
- and a
- ret
-; 97d23
-
-Function97d23: ; 97d23
- call Function97d64
- ret nc
- call Function97d31
- callba Function2a1df
- ret
-; 97d31
-
-Function97d31: ; 97d31
-; Pick a random mon out of ContestMons.
-
-.asm_97d31
- call Random
- cp 100 << 1
- jr nc, .asm_97d31
- srl a
-
- ld hl, ContestMons
- ld de, 4
-.CheckMon
- sub [hl]
- jr c, .GotMon
- add hl, de
- jr .CheckMon
-
-.GotMon
- inc hl
-
-; Species
- ld a, [hli]
- ld [$d22e], a
-
-; Min level
- ld a, [hli]
- ld d, a
-
-; Max level
- ld a, [hl]
-
- sub d
- jr nz, .RandomLevel
-
-; If min and max are the same.
- ld a, d
- jr .GotLevel
-
-.RandomLevel
-; Get a random level between the min and max.
- ld c, a
- inc c
- call Random
- ld a, [hRandomAdd]
- call SimpleDivide
- add d
-
-.GotLevel
- ld [CurPartyLevel], a
-
- xor a
- ret
-; 97d64
-
-Function97d64: ; 97d64
- ld a, [StandingTile]
- call Function188e
- ld b, $66
- jr z, .asm_97d70
- ld b, $33
-
-.asm_97d70
- callba Function2a124
- callba Function2a138
- call Random
- ld a, [hRandomAdd]
- cp b
- ret c
- ld a, 1
- and a
- ret
-; 97d87
-
-ContestMons: ; 97d87
- ; %, species, min, max
- db 20, CATERPIE, 7, 18
- db 20, WEEDLE, 7, 18
- db 10, METAPOD, 9, 18
- db 10, KAKUNA, 9, 18
- db 5, BUTTERFREE, 12, 15
- db 5, BEEDRILL, 12, 15
- db 10, VENONAT, 10, 16
- db 10, PARAS, 10, 17
- db 5, SCYTHER, 13, 14
- db 5, PINSIR, 13, 14
- db -1, VENOMOTH, 30, 40
-; 97db3
-
-Function97db3: ; 97db3
- nop
- nop
- ; fallthrough
-; 97db5
-
-Function97db5: ; 97db5
- ld hl, StatusFlags2
- bit 4, [hl]
- jr z, .asm_97df7
- ld a, [PlayerState]
- cp $1
- jr nz, .asm_97df7
- call Function2d05
- and a
- jr nz, .asm_97df7
- ld hl, $dca2
- ld a, [hli]
- ld d, a
- ld e, [hl]
- cp $ff
- jr nz, .asm_97dd8
- ld a, e
- cp $ff
- jr z, .asm_97ddc
-
-.asm_97dd8
- inc de
- ld [hl], e
- dec hl
- ld [hl], d
-
-.asm_97ddc
- ld a, d
- cp $4
- jr c, .asm_97df7
- ld a, [$dc31]
- and a
- jr nz, .asm_97df7
- ld a, $6
- ld [$dc31], a
- xor a
- ld [$dc32], a
- ld hl, StatusFlags2
- res 4, [hl]
- scf
- ret
-
-.asm_97df7
- xor a
- ret
-; 97df9
-
-Function97df9: ; 97df9
- ld hl, $d6de
- ld de, $0006
- ld c, $4
- xor a
-.asm_97e02
- ld [hl], a
- add hl, de
- dec c
- jr nz, .asm_97e02
- ret
-; 97e08
-
-Function97e08: ; 97e08
- ld hl, $d6de
- xor a
-.asm_97e0c
- ld [hConnectionStripLength], a
- ld a, [hl]
- and a
- jr z, .asm_97e19
- push hl
- ld b, h
- ld c, l
- call Function97e79
- pop hl
-
-.asm_97e19
- ld de, $0006
- add hl, de
- ld a, [hConnectionStripLength]
- inc a
- cp $4
- jr nz, .asm_97e0c
- ret
-; 97e25
-
-Function97e25: ; 97e25
- ld hl, $d6de
- ld bc, 6
- call AddNTimes
- ld b, h
- ld c, l
- ret
-; 97e31
-
-Function97e31: ; 97e31
- push bc
- push de
- call Function97e45
- ld d, h
- ld e, l
- pop hl
- pop bc
- ret c
- ld a, b
- ld bc, $0005
- call FarCopyBytes
- xor a
- ld [hl], a
- ret
-; 97e45
-
-Function97e45: ; 97e45
- ld hl, $d6de
- ld de, $0006
- ld c, $4
-.asm_97e4d
- ld a, [hl]
- and a
- jr z, .asm_97e57
- add hl, de
- dec c
- jr nz, .asm_97e4d
- scf
- ret
-
-.asm_97e57
- ld a, $4
- sub c
- and a
- ret
-; 97e5c
-
-Function97e5c: ; 97e5c
- ld hl, $d6de
- ld de, $0006
- ld c, $4
-.asm_97e64
- ld a, [hl]
- cp b
- jr z, .asm_97e6e
- add hl, de
- dec c
- jr nz, .asm_97e64
- and a
- ret
-
-.asm_97e6e
- xor a
- ld [hl], a
- scf
- ret
-; 97e72
-
-Function97e72: ; 97e72
- ld hl, $0000
- add hl, bc
- ld [hl], 0
- ret
-; 97e79
-
-Function97e79: ; 97e79
- ld hl, $0000
- add hl, bc
- ld a, [hl]
- cp 5
- jr c, .asm_97e83
- xor a
-
-.asm_97e83
- ld e, a
- ld d, 0
- ld hl, Table97e94
- add hl, de
- add hl, de
- add hl, de
- ld a, [hli]
- push af
- ld a, [hli]
- ld h, [hl]
- ld l, a
- pop af
- rst FarCall
- ret
-; 97e94
-
-Table97e94: ; 97e94
- dbw BANK(Function97eb7), Function97eb7
- dbw BANK(Function97eb8), Function97eb8
- dbw BANK(Function97f42), Function97f42
- dbw BANK(Function97ef9), Function97ef9
- dbw BANK(Function97ebc), Function97ebc
-; 97ea3
-
-Function97ea3: ; 97ea3
- ld hl, $0005
- add hl, bc
- ld a, [hl]
- pop hl
- rst JumpTable
- ret
-; 97eab
-
-Function97eab: ; 97eab
- ld hl, $0005
- add hl, bc
- inc [hl]
- ret
-; 97eb1
-
-Function97eb1: ; 97eb1
- ld hl, $0005
- add hl, bc
- dec [hl]
- ret
-; 97eb7
-
-Function97eb7: ; 97eb7
- ret
-; 97eb8
-
-Function97eb8: ; 97eb8
- call Function2f3e
- ret
-; 97ebc
-
-Function97ebc: ; 97ebc
- call Function97ea3
- dw Function97ec3
- dw Function97ecd
-; 97ec3
-
-Function97ec3: ; 97ec3
- ld a, [hSCY]
- ld hl, $0004
- add hl, bc
- ld [hl], a
- call Function97eab
-; 97ecd
-
-Function97ecd: ; 97ecd
- ld hl, $0001
- add hl, bc
- ld a, [hl]
- dec a
- ld [hl], a
- jr z, .asm_97eee
- and $1
- jr z, .asm_97ee4
- ld hl, $0002
- add hl, bc
- ld a, [hSCY]
- sub [hl]
- ld [hSCY], a
- ret
-
-.asm_97ee4
- ld hl, $0002
- add hl, bc
- ld a, [hSCY]
- add [hl]
- ld [hSCY], a
- ret
-
-.asm_97eee
- ld hl, $0004
- add hl, bc
- ld a, [hl]
- ld [hSCY], a
- call Function97e72
- ret
-; 97ef9
-
-Function97ef9: ; 97ef9
- call Function97ea3
- dw Function97f02
- dw Function97f0a
- dw Function97f1b
-; 97f02
-
-Function97f02: ; 97f02
- call Function97f38
- jr z, Function97f2c
- call Function97eab
-; 97f0a
-
-Function97f0a: ; 97f0a
- call Function97f38
- jr z, Function97f2c
- call Function97eab
-
- ld hl, $0002
- add hl, bc
- ld a, [hl]
- ld [$d173], a
- ret
-; 97f1b
-
-Function97f1b: ; 97f1b
- call Function97f38
- jr z, Function97f2c
- call Function97eb1
-
- ld hl, $0003
- add hl, bc
- ld a, [hl]
- ld [$d173], a
- ret
-; 97f2c
-
-Function97f2c: ; 97f2c
- ld a, $7f
- ld [$d173], a
- ld hl, $0005
- add hl, bc
- ld [hl], 0
- ret
-; 97f38
-
-Function97f38: ; 97f38
- push bc
- ld bc, $d4d6
- call GetSpriteDirection
- and a
- pop bc
- ret
-; 97f42
-
-Function97f42: ; 97f42
- ld de, $d4d6
- ld a, $d
-.asm_97f47
- push af
-
- ld hl, $0000
- add hl, de
- ld a, [hl]
- and a
- jr z, .asm_97f71
-
- ld hl, $0003
- add hl, de
- ld a, [hl]
- cp $19
- jr nz, .asm_97f71
-
- ld hl, $000e
- add hl, de
- ld a, [hl]
- call CheckPitTile
- jr nz, .asm_97f71
-
- ld hl, $0007
- add hl, de
- ld a, [hl]
- cp $ff
- jr nz, .asm_97f71
- call Function3567
- jr c, .asm_97f7c
-
-.asm_97f71
- ld hl, $0028
- add hl, de
- ld d, h
- ld e, l
-
- pop af
- dec a
- jr nz, .asm_97f47
- ret
-
-.asm_97f7c
- pop af
- ret
-; 97f7e
-
-
-
SECTION "bank26",ROMX,BANK[$26]
; Map Scripts XI
@@ -87474,7 +85608,9 @@
SECTION "bank28",ROMX,BANK[$28]
-INCBIN "baserom.gbc",$a0000,$a1eca - $a0000
+INCBIN "baserom.gbc",$a0000,$a0c28 - $a0000
+
+INCLUDE "text/buena.asm"
SECTION "bank29",ROMX,BANK[$29]
--- a/maps/map_headers.asm
+++ b/maps/map_headers.asm
@@ -1,3 +1,32 @@
+MapGroupPointers: ; 0x94000
+; pointers to the first map header of each map group
+ dw MapGroup1
+ dw MapGroup2
+ dw MapGroup3
+ dw MapGroup4
+ dw MapGroup5
+ dw MapGroup6
+ dw MapGroup7
+ dw MapGroup8
+ dw MapGroup9
+ dw MapGroup10
+ dw MapGroup11
+ dw MapGroup12
+ dw MapGroup13
+ dw MapGroup14
+ dw MapGroup15
+ dw MapGroup16
+ dw MapGroup17
+ dw MapGroup18
+ dw MapGroup19
+ dw MapGroup20
+ dw MapGroup21
+ dw MapGroup22
+ dw MapGroup23
+ dw MapGroup24
+ dw MapGroup25
+ dw MapGroup26
+
MapGroup1:
--- a/pokecrystal.asm
+++ b/pokecrystal.asm
@@ -1,5 +1,2 @@
-INCLUDE "globals.asm"
-
-INCLUDE "constants.asm"
-INCLUDE "wram.asm"
-INCLUDE "main.asm"
+_CRYSTAL EQU 1
+VERSION EQU 0
--- a/stats/egg_move_pointers.asm
+++ b/stats/egg_move_pointers.asm
@@ -1,3 +1,4 @@
+EggMovePointers: ; 0x23b11
dw BulbasaurEggMoves
dw NoEggMoves
dw NoEggMoves
--- /dev/null
+++ b/stats/egg_moves_crystal.asm
@@ -1,0 +1,6 @@
+INCLUDE "pokecrystal.asm"
+INCLUDE "includes.asm"
+
+SECTION "eggmoves", ROMX, BANK[$8]
+INCLUDE "stats/egg_move_pointers.asm"
+INCLUDE "stats/egg_moves.asm"
--- /dev/null
+++ b/stats/evos_attacks_crystal.asm
@@ -1,0 +1,6 @@
+INCLUDE "pokecrystal.asm"
+INCLUDE "includes.asm"
+
+SECTION "evosattacks", ROMx, BANK[$10]
+INCLUDE "stats/evos_attacks_pointers.asm"
+INCLUDE "stats/evos_attacks.asm"
--- a/stats/evos_attacks_pointers.asm
+++ b/stats/evos_attacks_pointers.asm
@@ -2,6 +2,7 @@
; These are grouped together since they're both checked at level-up.
+EvosAttacksPointers: ; 0x425b1
dw BulbasaurEvosAttacks
dw IvysaurEvosAttacks
dw VenusaurEvosAttacks
--- /dev/null
+++ b/text/buena.asm
@@ -1,0 +1,389 @@
+UnknownText_0xa0c28: ; 0xa0c28
+ db $0, "Hi, this is BUENA…", $51
+ db "Oh! Good morning,", $4f
+ db $14, "!", $51
+ db "I'm kind of foggy", $4f
+ db "in the morning…", $57
+; 0xa0c72
+
+UnknownText_0xa0c72: ; 0xa0c72
+ db $0, "Hi, this is BUENA…", $4f
+ db "Oh! Hi, ", $14, "!", $51
+ db "Do you tune into", $4f
+ db "BUENA's show?", $57
+; 0xa0caf
+
+UnknownText_0xa0caf: ; 0xa0caf
+ db $0, "This is BUENA.", $4f
+ db "I can't come to", $51
+ db "the phone right", $4f
+ db "now.", $51
+ db "If you want to", $4f
+ db "chat, tune into", $51
+ db "BUENA's PASSWORD", $4f
+ db "on the radio and", $51
+ db "give me a call", $4f
+ db "after midnight!", $57
+; 0xa0d42
+
+UnknownText_0xa0d42: ; 0xa0d42
+ db $0, "Hi, this is BUENA…", $4f
+ db "Oh! Hi, ", $14, "!", $51
+ db "I just got off", $4f
+ db "work. ", $51
+ db "Let me tell you,", $4f
+ db "I'm exhausted!", $57
+; 0xa0d96
+
+UnknownText_0xa0d96: ; 0xa0d96
+ db $0, $14, "!", $4f
+ db "Hi, it's BUENA!", $51
+ db "I got up early, so", $4f
+ db "I decided to call!", $57
+; 0xa0dcf
+
+UnknownText_0xa0dcf: ; 0xa0dcf
+ db $0, $14, "!", $4f
+ db "Hi, it's BUENA!", $51
+ db "I needed someone", $4f
+ db "to chat with!", $57
+; 0xa0e01
+
+UnknownText_0xa0e01: ; 0xa0e01
+ db $0, $14, "!", $4f
+ db "Hi, it's BUENA!", $51
+ db "I'm just on my", $4f
+ db "break.", $57
+; 0xa0e29
+
+UnknownText_0xa0e29: ; 0xa0e29
+ db $0, $14, "!", $4f
+ db "Hi, it's BUENA!", $51
+ db "I couldn't sleep,", $4f
+ db "so I called you.", $57
+; 0xa0e5e
+
+UnknownText_0xa0e5e: ; 0xa0e5e
+ db $0, "Oh. Hi, ", $14, "!", $51
+ db "You are how?", $51
+ db "Aiyee! This isn't", $4f
+ db "the time for me to", $51
+ db "be cracking silly", $4f
+ db "gag greetings!", $51
+ db "The RADIO TOWER is", $4f
+ db "in deep trouble!", $51
+ db $14, ", you'd", $4f
+ db "better be careful!", $57
+; 0xa0efb
+
+UnknownText_0xa0efb: ; 0xa0efb
+ db $0, "The other day, I", $4f
+ db "went out to eat", $51
+ db "with DJ BEN!", $4f
+ db "Isn't it great?", $51
+ db "Not only that, he", $4f
+ db "said the music on", $51
+ db "my program is", $4f
+ db "cool!", $51
+ db "Oh, wow! Like,", $4f
+ db "what should I do?", $51
+ db "…Oops, I have to", $4f
+ db "get ready for my", $51
+ db "show! I'll catch", $4f
+ db "you later!", $57
+; 0xa0fcf
+
+UnknownText_0xa0fcf: ; 0xa0fcf
+ db $0, "You know the", $4f
+ db "receptionist at", $55
+ db "the RADIO TOWER?", $51
+ db "'Welcome,' is all", $4f
+ db "she ever says.", $51
+ db "But she's really", $4f
+ db "the chattiest", $51
+ db "person at the", $4f
+ db "RADIO TOWER.", $51
+ db "So she must be", $4f
+ db "holding back.", $51
+ db "Isn't that fun to", $4f
+ db "know?", $51
+ db "Catch you later!", $57
+; 0xa109d
+
+UnknownText_0xa109d: ; 0xa109d
+ db $0, "Tell me, ", $14, ".", $4f
+ db "Have you ever won", $51
+ db "a prize on the", $4f
+ db "LUCKY NUMBER SHOW?", $51
+ db "REED moans that", $4f
+ db "he's never won, so", $51
+ db "he vows to keep", $4f
+ db "the show on the", $55
+ db "air till he does.", $51
+ db "Let's chat again!", $57
+; 0xa1143
+
+UnknownText_0xa1143: ; 0xa1143
+ db $0, "You know, last", $4f
+ db "night…", $51
+ db "I was so stressed", $4f
+ db "out from work, I", $51
+ db "ate a ton of junk", $4f
+ db "food!", $51
+ db "MARY and I have", $4f
+ db "this deal about", $55
+ db "losing weight…", $51
+ db "This won't do…", $51
+ db "Huh? What's the", $4f
+ db "weight?", $51
+ db "This has to be a", $4f
+ db "total secret!", $51
+ db "MARY weighs…", $51
+ db "Aiyee! M-MARY!", $51
+ db "Uh… Um… I… Sorry,", $4f
+ db "wrong number!", $57
+; 0xa1244
+
+UnknownText_0xa1244: ; 0xa1244
+ db $0, "Yesterday, PROF.", $4f
+ db "OAK was in the", $51
+ db "studio to tape his", $4f
+ db "show.", $51
+ db "So I went over and", $4f
+ db "introduced myself.", $51
+ db "Get this--he tunes", $4f
+ db "in to my program!", $51
+ db "Oh! Here comes", $4f
+ db "PROF.OAK again!", $51
+ db "I'm going to chat", $4f
+ db "him up again!", $51
+ db "Catch you later!", $57
+; 0xa1318
+
+UnknownText_0xa1318: ; 0xa1318
+ db $0, "…Cough, cough!", $51
+ db "Uhm sorry uh got", $4f
+ db "uh code dite now.", $51
+ db "Buh uma pro so uh", $4f
+ db "hav to cover id ub", $51
+ db "so no un notice", $4f
+ db "while uhm on air.", $51
+ db "Uh fidz muh voice", $4f
+ db "now.", $51
+ db "I'll catch you on", $4f
+ db "the fly. This has", $55
+ db "been BUENA!", $57
+; 0xa13d8
+
+UnknownText_0xa13d8: ; 0xa13d8
+ db $0, "Hey, ", $14, ".", $4f
+ db "You won that RADIO", $51
+ db "CARD by beating", $4f
+ db "the quiz at the", $51
+ db "reception desk,", $4f
+ db "didn't you?", $51
+ db "Guess what? I made", $4f
+ db "up the questions!", $51
+ db "…Were they too", $4f
+ db "easy for you?", $51
+ db "Well, let's chat", $4f
+ db "again!", $57
+; 0xa1488
+
+UnknownText_0xa1488: ; 0xa1488
+ db $0, "I'm elated that", $4f
+ db "more people are", $51
+ db "taking part in my", $4f
+ db "PASSWORD show.", $51
+ db "But when PIKACHU", $4f
+ db "was the password,", $51
+ db "it was uh… whew…", $4f
+ db "overwhelming.", $51
+ db "FAN CLUB people", $4f
+ db "came in out in", $51
+ db "droves, shouting", $4f
+ db "'PIKACHU!' over", $51
+ db "and over. I mean,", $4f
+ db "they were loud.", $51
+ db "Anyone tuning in", $4f
+ db "around then must", $51
+ db "have been shocked", $4f
+ db "by the racket!", $51
+ db "Anyway, back to", $4f
+ db "work for me!", $51
+ db "Let's chat again!", $57
+; 0xa15de
+
+UnknownText_0xa15de: ; 0xa15de
+ db $0, "Guess what?", $4f
+ db "The RADIO TOWER's", $51
+ db "DIRECTOR is a big", $4f
+ db "fan of TV!", $51
+ db "A while ago, a", $4f
+ db "fashion show on TV", $51
+ db "said that black", $4f
+ db "suits were in.", $51
+ db "Now all he wears", $4f
+ db "are black suits.", $51
+ db "But it's a secret", $4f
+ db "that our DIRECTOR", $51
+ db "is a TV fan, so if", $4f
+ db "you see him, don't", $51
+ db "you dare mention", $4f
+ db "it!", $51
+ db "Oh! The DIRECTOR", $4f
+ db "will be here soon!", $51
+ db "Later! Tune into", $4f
+ db "my show!", $57
+; 0xa1717
+
+UnknownText_0xa1717: ; 0xa1717
+ db $0, $14, ", tell me.", $51
+ db "When do you relax", $4f
+ db "the most?", $51
+ db "For me, it has to", $4f
+ db "be in the studio", $51
+ db "right after my", $4f
+ db "show, enjoying a", $51
+ db "nice cup of tea.", $4f
+ db "It's so pleasant", $51
+ db "that it gradually", $4f
+ db "makes me drowsy…", $51
+ db $56, " ", $56, " ", $56, $51
+ db $56, " ", $56, " ", $56, "Zzz", $51
+ db "Oops, I drifted", $4f
+ db "off just thinking", $51
+ db "about it! How, uh…", $4f
+ db "embarrassing!", $51
+ db "Please forget this", $4f
+ db "happened! Later!", $57
+; 0xa183d
+
+UnknownText_0xa183d: ; 0xa183d
+ db $0, $14, ", what was", $4f
+ db "the first #MON", $55
+ db "you ever caught?", $51
+ db "…Oh, really?", $51
+ db "I've seen lots of", $4f
+ db "#MON around,", $51
+ db "but I've never", $4f
+ db "caught one.", $51
+ db "I should give it a", $4f
+ db "try sometime.", $51
+ db "Did you know that", $4f
+ db "the first #MON", $51
+ db "MARY caught was a", $4f
+ db "DROWZEE?", $51
+ db "Isn't that so out", $4f
+ db "of character?", $51
+ db "But MARY's DROWZEE", $4f
+ db "kept making her", $51
+ db "fall asleep on the", $4f
+ db "job, so she traded", $51
+ db "with a fan for a", $4f
+ db "MEOWTH.", $51
+ db "Let's chat about", $4f
+ db "#MON again!", $51
+ db "Bye-bye!", $57
+; 0xa19b1
+
+UnknownText_0xa19b1: ; 0xa19b1
+ db $0, "Guess what? All of", $4f
+ db "us from the RADIO", $51
+ db "TOWER are going on", $4f
+ db "a company vacation", $51
+ db "to the RADIO TOWER", $4f
+ db "in LAVENDER.", $51
+ db "We're wasting our", $4f
+ db "vacation on a trip", $51
+ db "to another RADIO", $4f
+ db "TOWER?", $51
+ db "I'd much rather go", $4f
+ db "to the beach!", $51
+ db $14, ", I hope", $4f
+ db "you have enough", $51
+ db "fun for both of us", $4f
+ db "on your journey!", $51
+ db "Bye-bye!", $57
+; 0xa1ac0
+
+UnknownText_0xa1ac0: ; 0xa1ac0
+ db $0, "Did you know…?", $51
+ db "BEN and FERN talk", $4f
+ db "on the phone for", $51
+ db "hours about what", $4f
+ db "#MON music they", $51
+ db "should play on", $4f
+ db "different days of", $55
+ db "the week.", $51
+ db "One time, FERN's", $4f
+ db "rapping style kind", $51
+ db "of rubbed off on", $4f
+ db "BEN weirdly.", $51
+ db "So we ended up", $4f
+ db "enduring BEN's", $51
+ db "silly, chilly, a", $4f
+ db "willy-nilly jive-", $55
+ db "talking shtick for", $55
+ db "a while.", $51
+ db "Let's chat again!", $57
+; 0xa1bed
+
+UnknownText_0xa1bed: ; 0xa1bed
+ db $0, "I'm going shopping", $4f
+ db "with MARY and LILY", $55
+ db "soon.", $51
+ db "It'll be great if", $4f
+ db "GOLDENROD DEPT.", $51
+ db "STORE has a sale", $4f
+ db "on when we go…", $51
+ db $14, ", maybe we", $4f
+ db "can hook up too!", $51
+ db "Catch you later!", $57
+; 0xa1c88
+
+UnknownText_0xa1c88: ; 0xa1c88
+ db $0, "I'm thinking of", $4f
+ db "going to the GAME", $51
+ db "CORNER tomorrow.", $4f
+ db "It's been a while.", $51
+ db "You see, I have my", $4f
+ db "favorite machine…", $51
+ db "It pays out a lot,", $4f
+ db "I kid you not!", $51
+ db "Huh? Nuh-uh, it's", $4f
+ db "my secret!", $51
+ db "You have to find", $4f
+ db "it yourself!", $51
+ db "Catch you later!", $57
+; 0xa1d5f
+
+UnknownText_0xa1d5f: ; 0xa1d5f
+ db $0, "Hey, ", $14, ". You", $4f
+ db "use your #GEAR", $51
+ db "to listen to the", $4f
+ db "radio, right?", $51
+ db "I heard that you", $4f
+ db "can even display", $51
+ db "town maps with", $4f
+ db "#GEAR.", $51
+ db "I have a bad sense", $4f
+ db "of direction, so", $51
+ db "#GEAR would be", $4f
+ db "handy…", $51
+ db "Anyway, thanks for", $4f
+ db "calling! Later!", $57
+; 0xa1e2f
+
+UnknownText_0xa1e2f: ; 0xa1e2f
+ db $0, "Is it sunny", $4f
+ db "outside today?", $51
+ db "When you're cooped", $4f
+ db "up in the RADIO", $51
+ db "TOWER as much as I", $4f
+ db "am, you lose touch", $51
+ db "with the outside.", $4f
+ db "It can be boring.", $51
+ db "Please call again!", $57
+; 0xa1eca
+
--- a/wram.asm
+++ b/wram.asm
@@ -1,3 +1,6 @@
+INCLUDE "includes.asm"
+
+
SECTION "tiles0",VRAM[$8000],BANK[0]
VTiles0:
SECTION "tiles1",VRAM[$8800],BANK[0]