More work interpreting the sprite engine

This commit is contained in:
PikalaxALT
2015-12-02 13:24:18 -05:00
parent 92a8c491c3
commit be082943ed
17 changed files with 1165 additions and 1023 deletions

View File

@@ -191,30 +191,30 @@ DoEggStep:: ; 16f3e
OverworldHatchEgg:: ; 16f5e
call ResetWindow
call LoadStandardMenuDataHeader
call Function16f70
call HatchEggs
call ExitAllMenus
call RestartMapMusic
jp CloseText
; 16f70
Function16f70: ; 16f70 (5:6f70)
HatchEggs: ; 16f70 (5:6f70)
ld de, PartySpecies
ld hl, PartyMon1Happiness
xor a
ld [CurPartyMon], a
Function16f7a: ; 16f7a (5:6f7a)
.loop: ; 16f7a (5:6f7a)
ld a, [de]
inc de
cp -1
jp z, Function1708a
jp z, .done
push de
push hl
cp EGG
jp nz, Function1707d
jp nz, .next
ld a, [hl]
and a
jp nz, Function1707d
jp nz, .next
ld [hl], $78
push de
@@ -304,7 +304,7 @@ Function16f7a: ; 16f7a (5:6f7a)
ld e, l
ld hl, PlayerName
call CopyBytes
ld hl, UnknownText_0x1708b
ld hl, .Text_HatchEgg
call PrintText
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
@@ -313,11 +313,12 @@ Function16f7a: ; 16f7a (5:6f7a)
ld d, h
ld e, l
push de
ld hl, UnknownText_0x170ba
ld hl, .Text_NicknameHatchling
call PrintText
call YesNoBox
pop de
jr c, .nonickname
ld a, $1
ld [wd26b], a
xor a
@@ -328,32 +329,30 @@ Function16f7a: ; 16f7a (5:6f7a)
pop hl
ld de, StringBuffer1
call InitName
jr Function1707d
jr .next
.nonickname
ld hl, StringBuffer1
ld bc, PKMN_NAME_LENGTH
call CopyBytes
Function1707d: ; 1707d (5:707d)
.next: ; 1707d (5:707d)
ld hl, CurPartyMon
inc [hl]
pop hl
ld de, PARTYMON_STRUCT_LENGTH
add hl, de
pop de
jp Function16f7a
jp .loop
Function1708a: ; 1708a (5:708a)
.done: ; 1708a (5:708a)
ret
; 1708b (5:708b)
UnknownText_0x1708b: ; 0x1708b
.Text_HatchEgg: ; 0x1708b
; Huh? @ @
text_jump UnknownText_0x1c0db0
start_asm
; 0x17090
Function17090: ; 17090
ld hl, VramState
res 0, [hl]
push hl
@@ -361,38 +360,38 @@ Function17090: ; 17090
push bc
ld a, [CurPartySpecies]
push af
call Function1728f
ld hl, UnknownText_0x170b0
call EggHatch_AnimationSequence
ld hl, .ClearTextbox
call PrintText
pop af
ld [CurPartySpecies], a
pop bc
pop de
pop hl
ld hl, UnknownText_0x170b5
ld hl, .CameOutOfItsEgg
ret
; 170b0 (5:70b0)
UnknownText_0x170b0: ; 0x170b0
.ClearTextbox: ; 0x170b0
;
text_jump UnknownText_0x1c0db8
db "@"
; 0x170b5
UnknownText_0x170b5: ; 0x170b5
.CameOutOfItsEgg: ; 0x170b5
; came out of its EGG!@ @
text_jump UnknownText_0x1c0dba
db "@"
; 0x170ba
UnknownText_0x170ba: ; 0x170ba
.Text_NicknameHatchling: ; 0x170ba
; Give a nickname to @ ?
text_jump UnknownText_0x1c0dd8
db "@"
; 0x170bf
Function170bf: ; 170bf
call Function17197
InitEggMoves: ; 170bf
call GetHeritableMoves
ld d, h
ld e, l
ld b, NUM_MOVES
@@ -409,9 +408,9 @@ Function170bf: ; 170bf
inc hl
dec c
jr nz, .next
call Function170e4
call GetEggMove
jr nc, .skip
call Function17169
call LoadEggMove
.skip
inc de
@@ -422,7 +421,7 @@ Function170bf: ; 170bf
ret
; 170e4
Function170e4: ; 170e4
GetEggMove: ; 170e4
GLOBAL EggMoves
push bc
@@ -440,7 +439,7 @@ endr
ld a, BANK(EggMoves)
call GetFarByte
cp -1
jr z, .found_mon
jr z, .reached_end
ld b, a
ld a, [de]
cp b
@@ -448,7 +447,7 @@ endr
inc hl
jr .loop
.found_mon
.reached_end
call Function1720b
ld b, NUM_MOVES
.loop2
@@ -504,7 +503,7 @@ endr
ld a, [de]
cp b
jr nz, .loop5
ld [wd262], a
ld [wPutativeTMHMMove], a
predef CanLearnTMHMMove
ld a, c
and a
@@ -521,7 +520,7 @@ endr
ret
; 17169
Function17169: ; 17169
LoadEggMove: ; 17169
push de
push bc
ld a, [de]
@@ -556,7 +555,7 @@ Function17169: ; 17169
ret
; 17197
Function17197: ; 17197
GetHeritableMoves: ; 17197
ld hl, wBreedMon2Moves
ld a, [wBreedMon1Species]
cp DITTO
@@ -579,7 +578,7 @@ Function17197: ; 17197
ld [TempMonDVs], a
ld a, [wBreedMon2DVs + 1]
ld [TempMonDVs + 1], a
ld a, $3
ld a, BREEDMON
ld [MonType], a
predef GetGender
jr c, .inherit_mon2_moves
@@ -595,7 +594,7 @@ Function17197: ; 17197
ld [TempMonDVs], a
ld a, [wBreedMon1DVs + 1]
ld [TempMonDVs + 1], a
ld a, $3
ld a, BREEDMON
ld [MonType], a
predef GetGender
jr c, .inherit_mon1_moves
@@ -674,7 +673,7 @@ Function17254: ; 17254 (5:7254)
call SetPalettes
jp WaitBGMap
Function1727f: ; 1727f (5:727f)
EggHatch_DoAnimFrame: ; 1727f (5:727f)
push hl
push de
push bc
@@ -685,7 +684,7 @@ Function1727f: ; 1727f (5:727f)
pop hl
ret
Function1728f: ; 1728f (5:728f)
EggHatch_AnimationSequence: ; 1728f (5:728f)
ld a, [wd265]
ld [wJumptableIndex], a
ld a, [CurSpecies]
@@ -710,45 +709,47 @@ Function1728f: ; 1728f (5:728f)
call PlayMusic
call EnableLCD
hlcoord 7, 4
ld b, $98
ld c, $31
ld b, (VBGMap0 + 1 * $20 + 17) / $100
ld c, (VBGMap0 + 1 * $20 + 17) % $100
ld a, EGG
call Function17254
ld c, $50
ld c, 80
call DelayFrames
xor a
ld [wcf64], a
ld a, [hSCX]
ld b, a
.asm_172ee
.outerloop
ld hl, wcf64
ld a, [hl]
inc [hl]
cp $8
jr nc, .asm_17327
cp 8
jr nc, .done
ld e, [hl]
.asm_172f8
ld a, $2
.loop
; wobble e times
ld a, 2
ld [hSCX], a
ld a, $fe
ld a, -2
ld [wc3c0], a
call Function1727f
ld c, $2
call EggHatch_DoAnimFrame
ld c, 2
call DelayFrames
ld a, $fe
ld a, -2
ld [hSCX], a
ld a, $2
ld a, 2
ld [wc3c0], a
call Function1727f
ld c, $2
call EggHatch_DoAnimFrame
ld c, 2
call DelayFrames
dec e
jr nz, .asm_172f8
ld c, $10
jr nz, .loop
ld c, 16
call DelayFrames
call Function1736d
jr .asm_172ee
.asm_17327
call EggHatch_CrackShell
jr .outerloop
.done
ld de, SFX_EGG_HATCH
call PlaySFX
xor a
@@ -757,8 +758,8 @@ Function1728f: ; 1728f (5:728f)
call ClearSprites
call Function173b3
hlcoord 6, 3
ld b, $98
ld c, $0
ld b, VBGMap0 / $100
ld c, VBGMap0 % $100
ld a, [wJumptableIndex]
call Function17254
call Function17418
@@ -779,7 +780,7 @@ Function17363: ; 17363 (5:7363)
ld c, $0
jp GetSGBLayout
Function1736d: ; 1736d (5:736d)
EggHatch_CrackShell: ; 1736d (5:736d)
ld a, [wcf64]
dec a
and $7
@@ -794,7 +795,7 @@ Function1736d: ; 1736d (5:736d)
ld e, 11 * 8
ld a, SPRITE_ANIM_INDEX_19
call _InitSpriteAnimStruct
ld hl, $3
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $0
ld de, SFX_EGG_CRACK
@@ -840,7 +841,7 @@ Function173b3: ; 173b3 (5:73b3)
.done
ld de, SFX_EGG_HATCH
call PlaySFX
call Function1727f
call EggHatch_DoAnimFrame
ret
; 173ef (5:73ef)
@@ -862,7 +863,7 @@ Function173b3: ; 173b3 (5:73b3)
Function17418: ; 17418 (5:7418)
ld c, $81
.asm_1741a
call Function1727f
call EggHatch_DoAnimFrame
dec c
jr nz, .asm_1741a
ret

View File

@@ -828,7 +828,7 @@ Function81df4: ; 81df4
ld [wd265], a
predef GetTMHMMove
ld a, [wd265]
ld [wd262], a
ld [wPutativeTMHMMove], a
call GetMoveName
hlcoord 10, 12
call PlaceString

View File

@@ -485,7 +485,7 @@ endr
.learn
ld a, d
ld [wd262], a
ld [wPutativeTMHMMove], a
ld [wd265], a
call GetMoveName
call CopyName1

View File

@@ -57,7 +57,7 @@ LearnMove: ; 6508
pop hl
.learn
ld a, [wd262]
ld a, [wPutativeTMHMMove]
ld [hl], a
ld bc, MON_PP - MON_MOVES
add hl, bc

View File

@@ -100,7 +100,7 @@ Function927af: ; 927af (24:67af)
call Function92844
call Function92b0f
xor a
ld [wc3b5], a
ld [wOAMRetentionSize], a
callab DoNextFrameForFirst16Sprites
call Function927f8
call Function927d3

View File

@@ -23,8 +23,8 @@ PlaySpriteAnimations: ; 8cf69
push bc
push af
ld a, $0
ld [wc3b5], a
ld a, 0 * 4
ld [wOAMRetentionSize], a
call DoNextFrameForAllSprites
pop af
@@ -58,11 +58,11 @@ DoNextFrameForAllSprites: ; 8cf7a
dec e
jr nz, .loop
ld a, [wc3b5]
ld a, [wOAMRetentionSize]
ld l, a
ld h, Sprites / $0100
.loop2 ; Clear (Sprites + [wc3b5] --> SpritesEnd)
.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> SpritesEnd)
ld a, l
cp SpritesEnd % $100
jr nc, .done
@@ -98,11 +98,11 @@ DoNextFrameForFirst16Sprites: ; 8cfa8 (23:4fa8)
dec e
jr nz, .loop
ld a, [wc3b5]
ld a, [wOAMRetentionSize]
ld l, a
ld h, (Sprites + $40) / $100
.loop2 ; Clear (Sprites + [wc3b5] --> Sprites + $40)
.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> Sprites + $40)
ld a, l
cp (Sprites + 16 * 4) % $100
jr nc, .done
@@ -213,7 +213,7 @@ endr
Function8d036: ; 8d036
; Clear the index field of the struct in bc.
ld hl, 0
ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
ld [hl], $0
ret
@@ -240,25 +240,29 @@ Function8d04c: ; 8d04c
cp -3
jr z, .done
cp -4
jr z, .almost
jr z, .delete
call Function8d1a2 ; OAM?
ld a, [wc3ba]
; add byte to [wCurrAnimVTile]
ld a, [wCurrAnimVTile]
add [hl]
ld [wc3ba], a
ld [wCurrAnimVTile], a
inc hl
; load pointer into hl
ld a, [hli]
ld h, [hl]
ld l, a
push bc
ld a, [wc3b5]
ld a, [wOAMRetentionSize]
ld e, a
ld d, Sprites / $100
ld a, [hli]
ld c, a
ld c, a ; number of objects
.loop
ld a, [wc3bc]
; first byte: y (px)
; [de] = [wCurrAnimYCoord] + [wCurrAnimYOffset] + [wc3bf] + Function8d0be([hl])
ld a, [wCurrAnimYCoord]
ld b, a
ld a, [wc3be]
ld a, [wCurrAnimYOffset]
add b
ld b, a
ld a, [wc3bf]
@@ -269,9 +273,11 @@ Function8d04c: ; 8d04c
ld [de], a
inc hl
inc de
ld a, [wc3bb]
; second byte: x (px)
; [de] = [wCurrAnimXCoord] + [wCurrAnimXOffset] + [wc3c0] + Function8d0ce([hl])
ld a, [wCurrAnimXCoord]
ld b, a
ld a, [wc3bd]
ld a, [wCurrAnimXOffset]
add b
ld b, a
ld a, [wc3c0]
@@ -282,32 +288,36 @@ Function8d04c: ; 8d04c
ld [de], a
inc hl
inc de
ld a, [wc3ba]
; third byte: vtile
; [de] = [wCurrAnimVTile] + [hl]
ld a, [wCurrAnimVTile]
add [hl]
ld [de], a
inc hl
inc de
; fourth byte: attributes
; [de] = Function8d0de([hl])
call Function8d0de
ld [de], a
inc hl
inc de
ld a, e
ld [wc3b5], a
ld [wOAMRetentionSize], a
cp SpritesEnd % $100
jr nc, .outofroom
jr nc, .reached_the_end
dec c
jr nz, .loop
pop bc
jr .done
.almost
.delete
call Function8d036
.done
and a
ret
.outofroom
.reached_the_end
pop bc
scf
ret
@@ -359,18 +369,18 @@ Function8d0de: ; 8d0de
Function8d0ec: ; 8d0ec
xor a
ld [wc3b8], a
ld hl, $3
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld a, [hli]
ld [wc3ba], a
ld [wCurrAnimVTile], a
ld a, [hli]
ld [wc3bb], a
ld [wCurrAnimXCoord], a
ld a, [hli]
ld [wc3bc], a
ld [wCurrAnimYCoord], a
ld a, [hli]
ld [wc3bd], a
ld [wCurrAnimXOffset], a
ld a, [hli]
ld [wc3be], a
ld [wCurrAnimYOffset], a
ret
; 8d109
@@ -420,22 +430,22 @@ Function8d132: ; 8d132
add hl, bc
ld a, [hl]
and a
jr z, .done ; finished the current sequence
jr z, .next_frame ; finished the current sequence
dec [hl]
call Function8d189 ; load pointer from Unknown_8d6e6
ld a, [hli]
push af
jr .okay
.done
.next_frame
ld hl, SPRITEANIMSTRUCT_FRAME
add hl, bc
inc [hl]
call Function8d189 ; load pointer from Unknown_8d6e6
ld a, [hli]
cp $fe
cp -2
jr z, .minus_2
cp $ff
cp -1
jr z, .minus_1
push af
@@ -486,7 +496,7 @@ endr
Function8d189: ; 8d189
; Get the data for the current frame for the current animation sequence
; Unknown_8d6e6 + 2 * SpriteAnim[SPRITEANIMSTRUCT_01] + 3 * SpriteAnim[SPRITEANIMSTRUCT_FRAME]
; Unknown_8d6e6[SpriteAnim[SPRITEANIMSTRUCT_01]][SpriteAnim[SPRITEANIMSTRUCT_FRAME]]
ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld e, [hl]
@@ -508,6 +518,7 @@ endr
; 8d1a2
Function8d1a2: ; 8d1a2
; Load OAM data pointer
ld e, a
ld d, 0
ld hl, Unknown_8d94d

View File

@@ -5,7 +5,7 @@ CanLearnTMHMMove: ; 11639
ld hl, BaseTMHM
push hl
ld a, [wd262]
ld a, [wPutativeTMHMMove]
ld b, a
ld c, 0
ld hl, TMHMMoves