shithub: pokecrystal

Download patch

ref: ffbf2c0f5d28c05c14f67a3cfb123d37157c2ef9
parent: 6b33a8d155b7d3d6d7738ad2bcaa33c7983b3fce
author: PikalaxALT <[email protected]>
date: Tue Dec 1 10:35:28 EST 2015

More animations including cutting grass

--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -270,8 +270,8 @@
 	const SPRITE_ANIM_INDEX_13
 	const SPRITE_ANIM_INDEX_14
 	const SPRITE_ANIM_INDEX_15
-	const SPRITE_ANIM_INDEX_16
-	const SPRITE_ANIM_INDEX_17
+	const SPRITE_ANIM_INDEX_LEAF
+	const SPRITE_ANIM_INDEX_CUT_TREE
 	const SPRITE_ANIM_INDEX_18
 	const SPRITE_ANIM_INDEX_19
 	const SPRITE_ANIM_INDEX_1A
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -24,7 +24,7 @@
 	const VAR_XCOORD           ; 12
 	const VAR_YCOORD           ; 13
 	const VAR_SPECIALPHONECALL ; 14
-	const VAR_15               ; 15
+	const VAR_BT_WIN_STREAK    ; 15
 	const VAR_KURT_APRICORNS   ; 16
 	const VAR_CALLERID         ; 17
 	const VAR_BLUECARDBALANCE  ; 18
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -347,3 +347,21 @@
 	const FACING_1D
 	const FACING_1E
 	const FACING_1F
+
+	const_def
+	const SPRITEANIMSTRUCT_INDEX
+	const SPRITEANIMSTRUCT_01
+	const SPRITEANIMSTRUCT_ANIM_SEQ_ID
+	const SPRITEANIMSTRUCT_TILE_ID
+	const SPRITEANIMSTRUCT_XCOORD
+	const SPRITEANIMSTRUCT_YCOORD
+	const SPRITEANIMSTRUCT_XOFFSET
+	const SPRITEANIMSTRUCT_YOFFSET
+	const SPRITEANIMSTRUCT_DURATION
+	const SPRITEANIMSTRUCT_09
+	const SPRITEANIMSTRUCT_FRAME
+	const SPRITEANIMSTRUCT_0B
+	const SPRITEANIMSTRUCT_0C
+	const SPRITEANIMSTRUCT_0D
+	const SPRITEANIMSTRUCT_0E
+	const SPRITEANIMSTRUCT_0F
--- a/engine/breeding/egg.asm
+++ b/engine/breeding/egg.asm
@@ -823,16 +823,16 @@
 	push bc
 	ld a, SPRITE_ANIM_INDEX_1C
 	call _InitSpriteAnimStruct
-	ld hl, SpriteAnim1TileID - SpriteAnim1
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
 	ld [hl], $0
 	pop de
 	ld a, e
-	ld hl, SpriteAnim1Sprite01 - SpriteAnim1
+	ld hl, SPRITEANIMSTRUCT_01
 	add hl, bc
 	add [hl]
 	ld [hl], a
-	ld hl, SpriteAnim1Sprite0b - SpriteAnim1
+	ld hl, SPRITEANIMSTRUCT_0B
 	add hl, bc
 	ld [hl], d
 	pop hl
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -76,7 +76,7 @@
 	add_predef PrintType
 	add_predef PrintMonTypes
 	add_predef GetUnownLetter
-	add_predef Functioncbcdd
+	add_predef LoadPoisonBGPals
 	add_predef Predef2F
 	add_predef Function9853 ; $30
 	add_predef Predef_LoadSGBLayout
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -25,7 +25,7 @@
 
 	ld a, $0
 	ld [wc3b5], a
-	call Function8cf7a
+	call DoNextFrameForAllSprites
 
 	pop af
 	pop bc
@@ -34,7 +34,7 @@
 	ret
 ; 8cf7a
 
-Function8cf7a: ; 8cf7a
+DoNextFrameForAllSprites: ; 8cf7a
 	ld hl, wSpriteAnimationStructs
 	ld e, 10 ; There are 10 structs here.
 
@@ -241,7 +241,7 @@
 	jr z, .done
 	cp -4
 	jr z, .almost
-	call Function8d1a2 ; read from a pointer table
+	call Function8d1a2 ; OAM?
 	ld a, [wc3ba]
 	add [hl]
 	ld [wc3ba], a
@@ -416,40 +416,40 @@
 
 Function8d132: ; 8d132
 .loop
-	ld hl, $8
+	ld hl, SPRITEANIMSTRUCT_DURATION
 	add hl, bc
 	ld a, [hl]
 	and a
-	jr z, .ok
+	jr z, .done ; finished the current sequence
 	dec [hl]
-	call Function8d189
+	call Function8d189 ; load pointer from Unknown_8d6e6
 	ld a, [hli]
 	push af
-	jr .skip
+	jr .okay
 
-.ok
-	ld hl, $a
+.done
+	ld hl, SPRITEANIMSTRUCT_FRAME
 	add hl, bc
 	inc [hl]
-	call Function8d189
+	call Function8d189 ; load pointer from Unknown_8d6e6
 	ld a, [hli]
 	cp $fe
 	jr z, .minus_2
 	cp $ff
 	jr z, .minus_1
+
 	push af
 	ld a, [hl]
 	push hl
 	and $3f
-	ld hl, $9
+	ld hl, SPRITEANIMSTRUCT_09
 	add hl, bc
 	add [hl]
-	ld hl, $8
+	ld hl, SPRITEANIMSTRUCT_DURATION
 	add hl, bc
 	ld [hl], a
 	pop hl
-
-.skip
+.okay
 	ld a, [hl]
 	and $c0
 	srl a
@@ -459,10 +459,11 @@
 
 .minus_1
 	xor a
-	ld hl, $8
+	ld hl, SPRITEANIMSTRUCT_DURATION
 	add hl, bc
 	ld [hl], a
-	ld hl, $a
+
+	ld hl, SPRITEANIMSTRUCT_FRAME
 	add hl, bc
 rept 2
 	dec [hl]
@@ -471,11 +472,12 @@
 
 .minus_2
 	xor a
-	ld hl, $8
+	ld hl, SPRITEANIMSTRUCT_DURATION
 	add hl, bc
 	ld [hl], a
+
 	dec a
-	ld hl, $a
+	ld hl, SPRITEANIMSTRUCT_FRAME
 	add hl, bc
 	ld [hl], a
 	jr .loop
@@ -482,9 +484,10 @@
 ; 8d189
 
 Function8d189: ; 8d189
-	; Get the [bc+10]th entry in the data table
-	; indexed at [bc+1] in Unknown_8d6e6
-	ld hl, $1
+	; Get the data for the current frame for the current animation sequence
+
+	; Unknown_8d6e6 + 2 * SpriteAnim[SPRITEANIMSTRUCT_01] + 3 * SpriteAnim[SPRITEANIMSTRUCT_FRAME]
+	ld hl, SPRITEANIMSTRUCT_01
 	add hl, bc
 	ld e, [hl]
 	ld d, 0
@@ -495,7 +498,7 @@
 	ld e, [hl]
 	inc hl
 	ld d, [hl]
-	ld hl, $a
+	ld hl, SPRITEANIMSTRUCT_FRAME
 	add hl, bc
 	ld l, [hl]
 	ld h, 0
@@ -1406,72 +1409,72 @@
 ; 8d6e6 (23:56e6)
 
 Unknown_8d6e6: ; 8d6e6
-	dw Unknown_8d76a
-	dw Unknown_8d76d
-	dw Unknown_8d772
-	dw Unknown_8d777
-	dw Unknown_8d77c
-	dw Unknown_8d781
-	dw Unknown_8d786
-	dw Unknown_8d7a6
-	dw Unknown_8d7ab
-	dw Unknown_8d7b0
-	dw Unknown_8d7b5
-	dw Unknown_8d7d4
-	dw Unknown_8d7d9
-	dw Unknown_8d7e2
-	dw Unknown_8d7eb
-	dw Unknown_8d7f4
-	dw Unknown_8d7ff
-	dw Unknown_8d78b
-	dw Unknown_8d802
-	dw Unknown_8d805
-	dw Unknown_8d808
-	dw Unknown_8d811
-	dw Unknown_8d818
-	dw Unknown_8d81d
-	dw Unknown_8d822
-	dw Unknown_8d825
-	dw Unknown_8d82c
-	dw Unknown_8d82f
-	dw Unknown_8d861
-	dw Unknown_8d864
-	dw Unknown_8d867
-	dw Unknown_8d874
-	dw Unknown_8d877
-	dw Unknown_8d87a
-	dw Unknown_8d87d
-	dw Unknown_8d880
-	dw Unknown_8d883
-	dw Unknown_8d890
-	dw Unknown_8d899
-	dw Unknown_8d89c
-	dw Unknown_8d89f
-	dw Unknown_8d8a2
-	dw Unknown_8d8a5
-	dw Unknown_8d8a8
-	dw Unknown_8d8ab
-	dw Unknown_8d794
-	dw Unknown_8d79d
-	dw Unknown_8d8ae
-	dw Unknown_8d8cd
-	dw Unknown_8d8ec
-	dw Unknown_8d8f1
-	dw Unknown_8d8f4
-	dw Unknown_8d8f7
-	dw Unknown_8d8fe
-	dw Unknown_8d907
-	dw Unknown_8d90c
-	dw Unknown_8d913
-	dw Unknown_8d916
-	dw Unknown_8d91d
-	dw Unknown_8d924
-	dw Unknown_8d92b
-	dw Unknown_8d932
-	dw Unknown_8d93d
-	dw Unknown_8d940
-	dw Unknown_8d943
-	dw Unknown_8d948
+	dw Unknown_8d76a ; 00
+	dw Unknown_8d76d ; 01
+	dw Unknown_8d772 ; 02
+	dw Unknown_8d777 ; 03
+	dw Unknown_8d77c ; 04
+	dw Unknown_8d781 ; 05
+	dw Unknown_8d786 ; 06
+	dw Unknown_8d7a6 ; 07
+	dw Unknown_8d7ab ; 08
+	dw Unknown_8d7b0 ; 09
+	dw Unknown_8d7b5 ; 0a
+	dw Unknown_8d7d4 ; 0b
+	dw Unknown_8d7d9 ; 0c
+	dw Unknown_8d7e2 ; 0d
+	dw Unknown_8d7eb ; 0e
+	dw Unknown_8d7f4 ; 0f
+	dw Unknown_8d7ff ; 10
+	dw Unknown_8d78b ; 11
+	dw Unknown_8d802 ; 12
+	dw Unknown_8d805 ; 13
+	dw Unknown_8d808 ; 14
+	dw Unknown_8d811 ; 15
+	dw Unknown_8d818 ; 16
+	dw Unknown_8d81d ; 17
+	dw Unknown_8d822 ; 18
+	dw Unknown_8d825 ; 19
+	dw Unknown_8d82c ; 1a
+	dw Unknown_8d82f ; 1b
+	dw Unknown_8d861 ; 1c
+	dw Unknown_8d864 ; 1d
+	dw Unknown_8d867 ; 1e
+	dw Unknown_8d874 ; 1f
+	dw Unknown_8d877 ; 20
+	dw Unknown_8d87a ; 21
+	dw Unknown_8d87d ; 22
+	dw Unknown_8d880 ; 23
+	dw Unknown_8d883 ; 24
+	dw Unknown_8d890 ; 25
+	dw Unknown_8d899 ; 26
+	dw Unknown_8d89c ; 27
+	dw Unknown_8d89f ; 28
+	dw Unknown_8d8a2 ; 29
+	dw Unknown_8d8a5 ; 2a
+	dw Unknown_8d8a8 ; 2b
+	dw Unknown_8d8ab ; 2c
+	dw Unknown_8d794 ; 2d
+	dw Unknown_8d79d ; 2e
+	dw Unknown_8d8ae ; 2f
+	dw Unknown_8d8cd ; 30
+	dw Unknown_8d8ec ; 31
+	dw Unknown_8d8f1 ; 32
+	dw Unknown_8d8f4 ; 33
+	dw Unknown_8d8f7 ; 34
+	dw Unknown_8d8fe ; 35
+	dw Unknown_8d907 ; 36
+	dw Unknown_8d90c ; 37
+	dw Unknown_8d913 ; 38
+	dw Unknown_8d916 ; 39
+	dw Unknown_8d91d ; 3a
+	dw Unknown_8d924 ; 3b
+	dw Unknown_8d92b ; 3c
+	dw Unknown_8d932 ; 3d
+	dw Unknown_8d93d ; 3e
+	dw Unknown_8d940 ; 3f
+	dw Unknown_8d943 ; 40
+	dw Unknown_8d948 ; 41
 ; 8d76a
 
 Unknown_8d76a: 	dw $2000
--- a/engine/time.asm
+++ b/engine/time.asm
@@ -118,7 +118,7 @@
 rept 4
 	ld [hli], a
 endr
-	ld hl, wdc58
+	ld hl, wKenjiBreakTimer
 	ld a, [hl]
 	and a
 	jr z, .RestartKenjiBreakCountdown
@@ -137,7 +137,7 @@
 	call Random
 	and 3
 	add 3
-	ld [wdc58], a
+	ld [wKenjiBreakTimer], a
 	ret
 ; 11490
 
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -38,34 +38,34 @@
 ; $00: copy [de] to StringBuffer2
 ; $40: return address in de
 ; $80: call function
-	dwb StringBuffer2,         RETVAR_STRBUF2
-	dwb PartyCount,            RETVAR_STRBUF2
-	dwb .BattleResult,         RETVAR_EXECUTE
-	dwb BattleType,            RETVAR_ADDR_DE
-	dwb TimeOfDay,             RETVAR_STRBUF2
-	dwb .CountCaughtMons,      RETVAR_EXECUTE
-	dwb .CountSeenMons,        RETVAR_EXECUTE
-	dwb .CountBadges,          RETVAR_EXECUTE
-	dwb PlayerState,           RETVAR_ADDR_DE
-	dwb .PlayerFacing,         RETVAR_EXECUTE
-	dwb hHours,                RETVAR_STRBUF2
-	dwb .DayOfWeek,            RETVAR_EXECUTE
-	dwb MapGroup,              RETVAR_STRBUF2
-	dwb MapNumber,             RETVAR_STRBUF2
-	dwb .UnownCaught,          RETVAR_EXECUTE
-	dwb wPermission,           RETVAR_STRBUF2
-	dwb .BoxFreeSpace,         RETVAR_EXECUTE
-	dwb wBugContestMinsRemaining,                 RETVAR_STRBUF2
-	dwb XCoord,                RETVAR_STRBUF2
-	dwb YCoord,                RETVAR_STRBUF2
-	dwb wSpecialPhoneCallID,   RETVAR_STRBUF2
-	dwb wcf64,                 RETVAR_STRBUF2
-	dwb wKurtApricornQuantity, RETVAR_STRBUF2
-	dwb wCurrentCaller,        RETVAR_ADDR_DE
-	dwb wBlueCardBalance,      RETVAR_ADDR_DE
-	dwb wBuenasPassword,       RETVAR_ADDR_DE
-	dwb wdc58,                 RETVAR_STRBUF2
-	dwb NULL,                  RETVAR_STRBUF2
+	dwb StringBuffer2,                  RETVAR_STRBUF2
+	dwb PartyCount,                     RETVAR_STRBUF2
+	dwb .BattleResult,                  RETVAR_EXECUTE
+	dwb BattleType,                     RETVAR_ADDR_DE
+	dwb TimeOfDay,                      RETVAR_STRBUF2
+	dwb .CountCaughtMons,               RETVAR_EXECUTE
+	dwb .CountSeenMons,                 RETVAR_EXECUTE
+	dwb .CountBadges,                   RETVAR_EXECUTE
+	dwb PlayerState,                    RETVAR_ADDR_DE
+	dwb .PlayerFacing,                  RETVAR_EXECUTE
+	dwb hHours,                         RETVAR_STRBUF2
+	dwb .DayOfWeek,                     RETVAR_EXECUTE
+	dwb MapGroup,                       RETVAR_STRBUF2
+	dwb MapNumber,                      RETVAR_STRBUF2
+	dwb .UnownCaught,                   RETVAR_EXECUTE
+	dwb wPermission,                    RETVAR_STRBUF2
+	dwb .BoxFreeSpace,                  RETVAR_EXECUTE
+	dwb wBugContestMinsRemaining,       RETVAR_STRBUF2
+	dwb XCoord,                         RETVAR_STRBUF2
+	dwb YCoord,                         RETVAR_STRBUF2
+	dwb wSpecialPhoneCallID,            RETVAR_STRBUF2
+	dwb wNrOfBeatenBattleTowerTrainers, RETVAR_STRBUF2
+	dwb wKurtApricornQuantity,          RETVAR_STRBUF2
+	dwb wCurrentCaller,                 RETVAR_ADDR_DE
+	dwb wBlueCardBalance,               RETVAR_ADDR_DE
+	dwb wBuenasPassword,                RETVAR_ADDR_DE
+	dwb wKenjiBreakTimer,               RETVAR_STRBUF2
+	dwb NULL,                           RETVAR_STRBUF2
 ; 806c5
 
 .CountCaughtMons: ; 806c5
--- a/event/celebi.asm
+++ b/event/celebi.asm
@@ -31,7 +31,7 @@
 	push de
 	ld a, $90
 	ld [wc3b5], a
-	callba Function8cf7a
+	callba DoNextFrameForAllSprites
 	call Function49935
 	ld c, 2
 	call DelayFrames
--- a/event/field_moves.asm
+++ b/event/field_moves.asm
@@ -29,7 +29,7 @@
 	ld hl, VTiles1 tile $04
 	lb bc, BANK(HeadbuttTreeGFX), 8
 	call Request2bpp
-	call Function8cad3
+	call Cut_Headbutt_GetPixelFacing
 	ld a, SPRITE_ANIM_INDEX_1B
 	call _InitSpriteAnimStruct
 	ld hl, $3
@@ -37,7 +37,7 @@
 	ld [hl], $84
 	ld a, $90
 	ld [wc3b5], a
-	callba Function8cf7a
+	callba DoNextFrameForAllSprites
 	call GetHeadbuttTreeRelativeLocation
 	ld a, $20
 	ld [wcf64], a
@@ -52,7 +52,7 @@
 	dec [hl]
 	ld a, $90
 	ld [wc3b5], a
-	callba Function8cf7a
+	callba DoNextFrameForAllSprites
 	call DelayFrame
 	jr .loop
 
@@ -62,8 +62,8 @@
 	xor a
 	ld [hBGMapMode], a
 	callba Function8cf53
-	ld hl, Sprites + $90
-	ld bc, $10
+	ld hl, Sprites + 36 * 4
+	ld bc, SpritesEnd - (Sprites + 36 * 4)
 	xor a
 	call ByteFill
 	ld de, Font
@@ -126,7 +126,7 @@
 	jr nz, .finish
 	ld a, $90
 	ld [wc3b5], a
-	callab Function8cf7a
+	callab DoNextFrameForAllSprites
 	call OWCutJumptable
 	call DelayFrame
 	jr .loop
@@ -172,21 +172,22 @@
 
 
 .jumptable: ; 8ca1b (23:4a1b)
-	dw Function8ca23
-	dw Function8ca3c
-	dw Function8ca5c
-	dw Function8ca64
+	dw Cut_SpawnAnimateTree
+	dw Cut_SpawnAnimateLeaves
+	dw Cut_StartWaiting
+	dw Cut_WaitAnimSFX
 
 
-Function8ca23: ; 8ca23 (23:4a23)
-	call Function8cad3
-	ld a, SPRITE_ANIM_INDEX_17 ; leaf
+Cut_SpawnAnimateTree: ; 8ca23 (23:4a23)
+	call Cut_Headbutt_GetPixelFacing
+	ld a, SPRITE_ANIM_INDEX_CUT_TREE ; cut tree
 	call _InitSpriteAnimStruct
-	ld hl, $3
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
 	ld [hl], $84
-	ld a, $20
+	ld a, 32
 	ld [wcf64], a
+; Cut_StartWaiting
 	ld hl, wJumptableIndex
 rept 2
 	inc [hl]
@@ -193,75 +194,78 @@
 endr
 	ret
 
-Function8ca3c: ; 8ca3c (23:4a3c)
-	call Function8ca8e
+Cut_SpawnAnimateLeaves: ; 8ca3c (23:4a3c)
+	call Cut_GetLeafSpawnCoords
 	xor a
-	call Function8ca73
+	call Cut_SpawnLeaf
 	ld a, $10
-	call Function8ca73
+	call Cut_SpawnLeaf
 	ld a, $20
-	call Function8ca73
+	call Cut_SpawnLeaf
 	ld a, $30
-	call Function8ca73
-	ld a, $20
+	call Cut_SpawnLeaf
+	ld a, 32 ; frames
 	ld [wcf64], a
+; Cut_StartWaiting
 	ld hl, wJumptableIndex
 	inc [hl]
 	ret
 
-Function8ca5c: ; 8ca5c (23:4a5c)
+Cut_StartWaiting: ; 8ca5c (23:4a5c)
 	ld a, $1
 	ld [hBGMapMode], a
+; Cut_WaitAnimSFX
 	ld hl, wJumptableIndex
 	inc [hl]
 
-Function8ca64: ; 8ca64 (23:4a64)
+Cut_WaitAnimSFX: ; 8ca64 (23:4a64)
 	ld hl, wcf64
 	ld a, [hl]
 	and a
-	jr z, .asm_8ca6d
+	jr z, .finished
 	dec [hl]
 	ret
-.asm_8ca6d
+
+.finished
 	ld hl, wJumptableIndex
 	set 7, [hl]
 	ret
 
-Function8ca73: ; 8ca73 (23:4a73)
+Cut_SpawnLeaf: ; 8ca73 (23:4a73)
 	push de
 	push af
-	ld a, SPRITE_ANIM_INDEX_16 ; fly takeoff
+	ld a, SPRITE_ANIM_INDEX_LEAF ; leaf
 	call _InitSpriteAnimStruct
-	ld hl, $3
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
 	ld [hl], $80
-	ld hl, $e
+	ld hl, SPRITEANIMSTRUCT_0E
 	add hl, bc
 	ld [hl], $4
 	pop af
-	ld hl, $c
+	ld hl, SPRITEANIMSTRUCT_0C
 	add hl, bc
 	ld [hl], a
 	pop de
 	ret
 
-Function8ca8e: ; 8ca8e (23:4a8e)
+Cut_GetLeafSpawnCoords: ; 8ca8e (23:4a8e)
 	ld de, 0
-	ld a, [wd197]
+	ld a, [wMetatileStandingX]
 	bit 0, a
-	jr z, .asm_8ca9a
+	jr z, .left_side
 	set 0, e
-.asm_8ca9a
-	ld a, [wd196]
+.left_side
+	ld a, [wMetatileStandingY]
 	bit 0, a
-	jr z, .asm_8caa3
+	jr z, .top_side
 	set 1, e
-.asm_8caa3
+.top_side
 	ld a, [PlayerDirection]
-	and $c
+	and %00001100
 	add e
 	ld e, a
-	ld hl, Unknown_8cab3
+	ld hl, .Coords
 rept 2
 	add hl, de
 endr
@@ -271,32 +275,35 @@
 	ret
 ; 8cab3 (23:4ab3)
 
-Unknown_8cab3: ; 8cab3
-	db $58, $60
-	db $48, $60
-	db $58, $70
-	db $48, $70
-	db $58, $40
-	db $48, $40
-	db $58, $50
-	db $48, $50
-	db $38, $60
-	db $48, $60
-	db $38, $50
-	db $48, $50
-	db $58, $60
-	db $68, $60
-	db $58, $50
-	db $68, $50
+.Coords: ; 8cab3
+	dbpixel 11, 12 ; facing down,  top left
+	dbpixel  9, 12 ; facing down,  top right
+	dbpixel 11, 14 ; facing down,  bottom left
+	dbpixel  9, 14 ; facing down,  bottom right
+
+	dbpixel 11,  8 ; facing up,    top left
+	dbpixel  9,  8 ; facing up,    top right
+	dbpixel 11, 10 ; facing up,    bottom left
+	dbpixel  9, 10 ; facing up,    bottom right
+
+	dbpixel  7, 12 ; facing left,  top left
+	dbpixel  9, 12 ; facing left,  top right
+	dbpixel  7, 10 ; facing left,  bottom left
+	dbpixel  9, 10 ; facing left,  bottom right
+
+	dbpixel 11, 12 ; facing right, top left
+	dbpixel 13, 12 ; facing right, top right
+	dbpixel 11, 10 ; facing right, bottom left
+	dbpixel 13, 10 ; facing right, bottom right
 ; 8cad3
 
-Function8cad3: ; 8cad3 (23:4ad3)
+Cut_Headbutt_GetPixelFacing: ; 8cad3 (23:4ad3)
 	ld a, [PlayerDirection]
-	and $c
+	and %00001100
 	srl a
 	ld e, a
 	ld d, 0
-	ld hl, Unknown_8cae5
+	ld hl, .Coords
 	add hl, de
 	ld e, [hl]
 	inc hl
@@ -304,9 +311,159 @@
 	ret
 ; 8cae5 (23:4ae5)
 
-Unknown_8cae5: ; 8cae5
-	db $50, $68
-	db $50, $48
-	db $40, $58
-	db $60, $58
+.Coords: ; 8cae5
+	dbpixel 10, 13
+	dbpixel 10,  9
+	dbpixel  8, 11
+	dbpixel 12, 11
 ; 8caed
+
+
+FlyFromAnim: ; 8caed
+	call DelayFrame
+	ld a, [VramState]
+	push af
+	xor a
+	ld [VramState], a
+	call Function8cb9b
+	depixel 10, 10, 4, 0
+	ld a, SPRITE_ANIM_INDEX_0A
+	call _InitSpriteAnimStruct
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
+	add hl, bc
+	ld [hl], $84
+	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+	add hl, bc
+	ld [hl], $16
+	ld a, $80
+	ld [wcf64], a
+.loop
+	ld a, [wJumptableIndex]
+	bit 7, a
+	jr nz, .exit
+	ld a, $0
+	ld [wc3b5], a
+	callab DoNextFrameForAllSprites
+	call Function8cbc8
+	call DelayFrame
+	jr .loop
+
+.exit
+	pop af
+	ld [VramState], a
+	ret
+; 8cb33
+
+FlyToAnim: ; 8cb33
+	call DelayFrame
+	ld a, [VramState]
+	push af
+	xor a
+	ld [VramState], a
+	call Function8cb9b
+	depixel 31, 10, 4, 0
+	ld a, SPRITE_ANIM_INDEX_0A
+	call _InitSpriteAnimStruct
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
+	add hl, bc
+	ld [hl], $84
+	ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+	add hl, bc
+	ld [hl], $18
+	ld hl, SPRITEANIMSTRUCT_0F
+	add hl, bc
+	ld [hl], $58
+	ld a, $40
+	ld [wcf64], a
+.loop
+	ld a, [wJumptableIndex]
+	bit 7, a
+	jr nz, .exit
+	ld a, $0
+	ld [wc3b5], a
+	callab DoNextFrameForAllSprites
+	call Function8cbc8
+	call DelayFrame
+	jr .loop
+
+.exit
+	pop af
+	ld [VramState], a
+	call Function8cb82
+	ret
+
+Function8cb82: ; 8cb82 (23:4b82)
+	ld hl, Sprites + 2 ; Tile ID
+	xor a
+	ld c, $4
+.loop
+	ld [hli], a
+rept 3
+	inc hl
+endr
+	inc a
+	dec c
+	jr nz, .loop
+	ld hl, Sprites + 4 * 4
+	ld bc, SpritesEnd - (Sprites + 4 * 4)
+	xor a
+	call ByteFill
+	ret
+
+Function8cb9b: ; 8cb9b (23:4b9b)
+	callab Function8cf53
+	ld de, CutGrassGFX
+	ld hl, VTiles1 tile $00
+	lb bc, BANK(CutGrassGFX), 4
+	call Request2bpp
+	ld a, [CurPartyMon]
+	ld hl, PartySpecies
+	ld e, a
+	ld d, 0
+	add hl, de
+	ld a, [hl]
+	ld [wd265], a
+	ld e, $84
+	callba Function8e9bc
+	xor a
+	ld [wJumptableIndex], a
+	ret
+
+Function8cbc8: ; 8cbc8 (23:4bc8)
+	call Function8cbe6
+	ld hl, wcf64
+	ld a, [hl]
+	and a
+	jr z, .exit
+	dec [hl]
+	cp $40
+	ret c
+	and $7
+	ret nz
+	ld de, SFX_FLY
+	call PlaySFX
+	ret
+
+.exit
+	ld hl, wJumptableIndex
+	set 7, [hl]
+	ret
+
+Function8cbe6: ; 8cbe6 (23:4be6)
+	ld hl, wcf65
+	ld a, [hl]
+	inc [hl]
+	and $7
+	ret nz
+	ld a, [hl]
+	and $18
+	sla a
+	add $40
+	ld d, a
+	ld e, $0
+	ld a, SPRITE_ANIM_INDEX_18 ; fly land
+	call _InitSpriteAnimStruct
+	ld hl, SPRITEANIMSTRUCT_TILE_ID
+	add hl, bc
+	ld [hl], $80
+	ret
--- a/event/poisonstep.asm
+++ b/event/poisonstep.asm
@@ -104,7 +104,7 @@
 	ld de, SFX_POISON
 	call PlaySFX
 	ld b, $2
-	predef Functioncbcdd
+	predef LoadPoisonBGPals
 	call DelayFrame
 	ret
 ; 50669
--- a/macros.asm
+++ b/macros.asm
@@ -218,9 +218,17 @@
 else
 	lb \1, \2 * 8, \3 * 8
 endc
-	endm
+endm
 
 depixel EQUS "ldpixel de,"
+
+dbpixel: MACRO
+if _NARG == 4
+	db \1 * 8 + \3, \2 * 8 + \4
+else
+	db \1 * 8, \2 * 8
+endc
+endm
 
 bgcoord: MACRO
 IF _NARG == 4
--- a/main.asm
+++ b/main.asm
@@ -3440,13 +3440,13 @@
 	reloadmappart
 	callasm HideSprites
 	special UpdateTimePals
-	callasm Function8caed
+	callasm FlyFromAnim
 	farscall Script_AbortBugContest
 	special WarpToSpawnPoint
 	callasm DelayLoadingNewSprites
 	writecode VAR_MOVEMENT, PLAYER_NORMAL
 	newloadmap MAPSETUP_FLY
-	callasm Function8cb33
+	callasm FlyToAnim
 	special WaitSFX
 	callasm .ReturnFromFly
 	end
@@ -21429,153 +21429,6 @@
 ; 8c7d4
 
 INCLUDE "event/field_moves.asm"
-
-Function8caed: ; 8caed
-	call DelayFrame
-	ld a, [VramState]
-	push af
-	xor a
-	ld [VramState], a
-	call Function8cb9b
-	depixel 10, 10, 4, 0
-	ld a, SPRITE_ANIM_INDEX_0A
-	call _InitSpriteAnimStruct
-	ld hl, $3
-	add hl, bc
-	ld [hl], $84
-	ld hl, $2
-	add hl, bc
-	ld [hl], $16
-	ld a, $80
-	ld [wcf64], a
-.asm_8cb14
-	ld a, [wJumptableIndex]
-	bit 7, a
-	jr nz, .asm_8cb2e
-	ld a, $0
-	ld [wc3b5], a
-	callab Function8cf7a
-	call Function8cbc8
-	call DelayFrame
-	jr .asm_8cb14
-.asm_8cb2e
-	pop af
-	ld [VramState], a
-	ret
-; 8cb33
-
-Function8cb33: ; 8cb33
-	call DelayFrame
-	ld a, [VramState]
-	push af
-	xor a
-	ld [VramState], a
-	call Function8cb9b
-	depixel 31, 10, 4, 0
-	ld a, SPRITE_ANIM_INDEX_0A
-	call _InitSpriteAnimStruct
-	ld hl, $3
-	add hl, bc
-	ld [hl], $84
-	ld hl, $2
-	add hl, bc
-	ld [hl], $18
-	ld hl, $f
-	add hl, bc
-	ld [hl], $58
-	ld a, $40
-	ld [wcf64], a
-.asm_8cb60
-	ld a, [wJumptableIndex]
-	bit 7, a
-	jr nz, .asm_8cb7a
-	ld a, $0
-	ld [wc3b5], a
-	callab Function8cf7a
-	call Function8cbc8
-	call DelayFrame
-	jr .asm_8cb60
-.asm_8cb7a
-	pop af
-	ld [VramState], a
-	call Function8cb82
-	ret
-
-Function8cb82: ; 8cb82 (23:4b82)
-	ld hl, Sprites + 2
-	xor a
-	ld c, $4
-.asm_8cb88
-	ld [hli], a
-rept 3
-	inc hl
-endr
-	inc a
-	dec c
-	jr nz, .asm_8cb88
-	ld hl, Sprites + $10
-	ld bc, $90
-	xor a
-	call ByteFill
-	ret
-
-Function8cb9b: ; 8cb9b (23:4b9b)
-	callab Function8cf53
-	ld de, CutGrassGFX
-	ld hl, VTiles1 tile $00
-	lb bc, BANK(CutGrassGFX), 4
-	call Request2bpp
-	ld a, [CurPartyMon]
-	ld hl, PartySpecies
-	ld e, a
-	ld d, 0
-	add hl, de
-	ld a, [hl]
-	ld [wd265], a
-	ld e, $84
-	callba Function8e9bc
-	xor a
-	ld [wJumptableIndex], a
-	ret
-
-Function8cbc8: ; 8cbc8 (23:4bc8)
-	call Function8cbe6
-	ld hl, wcf64
-	ld a, [hl]
-	and a
-	jr z, .asm_8cbe0
-	dec [hl]
-	cp $40
-	ret c
-	and $7
-	ret nz
-	ld de, SFX_FLY
-	call PlaySFX
-	ret
-.asm_8cbe0
-	ld hl, wJumptableIndex
-	set 7, [hl]
-	ret
-
-Function8cbe6: ; 8cbe6 (23:4be6)
-	ld hl, wcf65
-	ld a, [hl]
-	inc [hl]
-	and $7
-	ret nz
-	ld a, [hl]
-	and $18
-	sla a
-	add $40
-	ld d, a
-	ld e, $0
-	ld a, SPRITE_ANIM_INDEX_18 ; fly land
-	call _InitSpriteAnimStruct
-	ld hl, $3
-	add hl, bc
-	ld [hl], $80
-	ret
-
 INCLUDE "event/magnet_train.asm"
 
 Function8cf4f: ; 8cf4f
@@ -21694,8 +21547,8 @@
 
 INCLUDE "battle/anims.asm"
 
-Functioncbcdd: ; cbcdd
-	call Functioncbce5
+LoadPoisonBGPals: ; cbcdd
+	call .LoadPals
 	ld a, [hCGB]
 	and a
 	ret nz
@@ -21702,18 +21555,18 @@
 	ret
 ; cbce5
 
-Functioncbce5: ; cbce5
+.LoadPals: ; cbce5
 	ld a, [hCGB]
 	and a
-	jr nz, .asm_cbd06
+	jr nz, .cgb
 	ld a, [TimeOfDayPal]
 	and $3
 	cp $3
 	ld a, $0
-	jr z, .asm_cbcf7
+	jr z, .convert_pals
 	ld a, $aa
 
-.asm_cbcf7
+.convert_pals
 	call DmgToCgbBGPals
 	ld c, 4
 	call DelayFrames
@@ -21720,7 +21573,7 @@
 	callba _UpdateTimePals
 	ret
 
-.asm_cbd06
+.cgb
 	ld a, [rSVBK]
 	push af
 	ld a, $5
@@ -21727,14 +21580,14 @@
 	ld [rSVBK], a
 	ld hl, BGPals
 	ld c, $20
-.asm_cbd12
+.loop
 ; RGB 31, 21, 28
-	ld a, $bc
+	ld a, (palred 31 + palgreen 21 + palblue 28) % $100
 	ld [hli], a
-	ld a, $7e
+	ld a, (palred 31 + palgreen 21 + palblue 28) / $100
 	ld [hli], a
 	dec c
-	jr nz, .asm_cbd12
+	jr nz, .loop
 	pop af
 	ld [rSVBK], a
 	ld a, $1
@@ -21939,6 +21792,7 @@
 SECTION "bank38", ROMX, BANK[$38]
 
 Functione0000: ; e0000
+; something to do with Unown printer
 	push de
 	xor a
 	call GetSRAMBank
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -5886,7 +5886,7 @@
 	call Function11ad6e
 	ld a, $78
 	ld [wc3b5], a
-	callba Function8cf7a
+	callba DoNextFrameForAllSprites
 	callba ReloadMapPart
 	jr .asm_11ac82
 
--- a/wram.asm
+++ b/wram.asm
@@ -1885,7 +1885,9 @@
 wd192:: ds 1
 wd193:: ds 1
 wd194:: dw
+wMetatileStandingY::
 wd196:: ds 1
+wMetatileStandingX::
 wd197:: ds 1
 wSecondMapHeaderBank:: ds 1
 wTileset:: ds 1
@@ -2772,7 +2774,7 @@
 wDailyRematchFlags:: ds 4
 wDailyPhoneItemFlags:: ds 4
 wDailyPhoneTimeOfDayFlags:: ds 4
-wdc58:: ds 2
+wKenjiBreakTimer:: ds 2 ; Kenji
 wdc5a:: ds 1
 wdc5b:: ds 1
 wdc5c:: ds 3