mirror of
https://github.com/pret/pokeyellow.git
synced 2026-05-09 04:11:32 -05:00
Revert "Revert "data/facing.asm, titlescreen functions, oam/sprite related functions, other misc functions""
This reverts commit c8ddbe7566.
This commit is contained in:
parent
2b7cb8a1d8
commit
2ea331ebb3
184
data/facing.asm
184
data/facing.asm
|
|
@ -1,57 +1,133 @@
|
|||
SpriteFacingAndAnimationTable: ; 4000 (1:4000)
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; facing down, walk animation frame 0
|
||||
dw SpriteFacingDownAndWalking, SpriteOAMParameters ; facing down, walk animation frame 1
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; facing down, walk animation frame 2
|
||||
dw SpriteFacingDownAndWalking, SpriteOAMParametersFlipped ; facing down, walk animation frame 3
|
||||
dw SpriteFacingUpAndStanding, SpriteOAMParameters ; facing up, walk animation frame 0
|
||||
dw SpriteFacingUpAndWalking, SpriteOAMParameters ; facing up, walk animation frame 1
|
||||
dw SpriteFacingUpAndStanding, SpriteOAMParameters ; facing up, walk animation frame 2
|
||||
dw SpriteFacingUpAndWalking, SpriteOAMParametersFlipped ; facing up, walk animation frame 3
|
||||
dw SpriteFacingLeftAndStanding, SpriteOAMParameters ; facing left, walk animation frame 0
|
||||
dw SpriteFacingLeftAndWalking, SpriteOAMParameters ; facing left, walk animation frame 1
|
||||
dw SpriteFacingLeftAndStanding, SpriteOAMParameters ; facing left, walk animation frame 2
|
||||
dw SpriteFacingLeftAndWalking, SpriteOAMParameters ; facing left, walk animation frame 3
|
||||
dw SpriteFacingLeftAndStanding, SpriteOAMParametersFlipped ; facing right, walk animation frame 0
|
||||
dw SpriteFacingLeftAndWalking, SpriteOAMParametersFlipped ; facing right, walk animation frame 1
|
||||
dw SpriteFacingLeftAndStanding, SpriteOAMParametersFlipped ; facing right, walk animation frame 2
|
||||
dw SpriteFacingLeftAndWalking, SpriteOAMParametersFlipped ; facing right, walk animation frame 3
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; ---
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; This table is used for sprites $a and $b.
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; All orientation and animation parameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; lead to the same result. Used for immobile
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; sprites like items on the ground
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters ; ---
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding, SpriteOAMParameters
|
||||
dw SpriteFacingDownAndStanding ; facing down, walk animation frame 0
|
||||
dw SpriteFacingDownAndWalking ; facing down, walk animation frame 1
|
||||
dw SpriteFacingDownAndStanding ; facing down, walk animation frame 2
|
||||
dw SpriteFacingDownAndWalking2 ; facing down, walk animation frame 3
|
||||
|
||||
SpriteFacingDownAndStanding: ; 4080 (1:4080)
|
||||
db $00,$01,$02,$03
|
||||
SpriteFacingDownAndWalking: ; 4084 (1:4084)
|
||||
db $80,$81,$82,$83
|
||||
SpriteFacingUpAndStanding: ; 4088 (1:4088)
|
||||
db $04,$05,$06,$07
|
||||
SpriteFacingUpAndWalking: ; 408c (1:408c)
|
||||
db $84,$85,$86,$87
|
||||
SpriteFacingLeftAndStanding: ; 4090 (1:4090)
|
||||
db $08,$09,$0a,$0b
|
||||
SpriteFacingLeftAndWalking: ; 4094 (1:4094)
|
||||
db $88,$89,$8a,$8b
|
||||
dw SpriteFacingUpAndStanding ; facing up, walk animation frame 0
|
||||
dw SpriteFacingUpAndWalking ; facing up, walk animation frame 1
|
||||
dw SpriteFacingUpAndStanding ; facing up, walk animation frame 2
|
||||
dw SpriteFacingUpAndWalking2 ; facing up, walk animation frame 3
|
||||
|
||||
SpriteOAMParameters: ; 4098 (1:4098)
|
||||
db $00,$00, $00 ; top left
|
||||
db $00,$08, $00 ; top right
|
||||
db $08,$00, OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08, OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
SpriteOAMParametersFlipped: ; 40a4 (1:40a4)
|
||||
db $00,$08, OAMFLAG_VFLIPPED
|
||||
db $00,$00, OAMFLAG_VFLIPPED
|
||||
db $08,$08, OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED
|
||||
db $08,$00, OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA
|
||||
dw SpriteFacingLeftAndStanding ; facing left, walk animation frame 0
|
||||
dw SpriteFacingLeftAndWalking ; facing left, walk animation frame 1
|
||||
dw SpriteFacingLeftAndStanding ; facing left, walk animation frame 2
|
||||
dw SpriteFacingLeftAndWalking ; facing left, walk animation frame 3
|
||||
|
||||
dw SpriteFacingRightAndStanding ; facing right, walk animation frame 0
|
||||
dw SpriteFacingRightAndWalking ; facing right, walk animation frame 1
|
||||
dw SpriteFacingRightAndStanding ; facing right, walk animation frame 2
|
||||
dw SpriteFacingRightAndWalking ; facing right, walk animation frame 3
|
||||
|
||||
dw SpriteFacingDownAndStanding ; ---
|
||||
dw SpriteFacingDownAndStanding ; This table is used for sprites $a and $b.
|
||||
dw SpriteFacingDownAndStanding ; All orientation and animation parameters
|
||||
dw SpriteFacingDownAndStanding ; lead to the same result. Used for immobile
|
||||
dw SpriteFacingDownAndStanding ; sprites like items on the ground
|
||||
dw SpriteFacingDownAndStanding ; ---
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
dw SpriteFacingDownAndStanding
|
||||
; special case
|
||||
dw SpriteSpecialCase ; pikachu maybe?
|
||||
|
||||
SpriteFacingDownAndStanding: ; 4042 (1:4042)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$00,$00 ; top left
|
||||
db $00,$08,$01,$00 ; top right
|
||||
db $08,$00,$02,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$03,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingDownAndWalking: ; 4053 (1:4053)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$80,$00 ; top left
|
||||
db $00,$08,$81,$00 ; top right
|
||||
db $08,$00,$82,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$83,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingDownAndWalking2: ; 4064 (1:4064)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$08,$80,OAMFLAG_VFLIPPED ; top left
|
||||
db $00,$00,$81,OAMFLAG_VFLIPPED ; top right
|
||||
db $08,$08,$82,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$00,$83,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingUpAndStanding: ; 4075 (1:4075)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$04,$00 ; top left
|
||||
db $00,$08,$05,$00 ; top right
|
||||
db $08,$00,$06,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$07,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingUpAndWalking: ; 4086 (1:4086)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$84,$00 ; top left
|
||||
db $00,$08,$85,$00 ; top right
|
||||
db $08,$00,$86,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$87,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingUpAndWalking2: ; 4097 (1:4097)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$08,$84,OAMFLAG_VFLIPPED ; top left
|
||||
db $00,$00,$85,OAMFLAG_VFLIPPED ; top right
|
||||
db $08,$08,$86,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$00,$87,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingLeftAndStanding: ; 40a8 (1:40a8)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$08,$00 ; top left
|
||||
db $00,$08,$09,$00 ; top right
|
||||
db $08,$00,$0a,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$0b,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingLeftAndWalking: ; 40b9 (1:40b9)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$00,$88,$00 ; top left
|
||||
db $00,$08,$89,$00 ; top right
|
||||
db $08,$00,$8a,OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$08,$8b,OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingRightAndStanding: ; 40ca (1:40ca)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$08,$08,OAMFLAG_VFLIPPED ; top left
|
||||
db $00,$00,$09,OAMFLAG_VFLIPPED ; top right
|
||||
db $08,$08,$0a,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$00,$0b,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteFacingRightAndWalking: ; 40db (1:40db)
|
||||
db $04
|
||||
; Sprite OAM Parameters
|
||||
db $00,$08,$88,OAMFLAG_VFLIPPED ; top left
|
||||
db $00,$00,$89,OAMFLAG_VFLIPPED ; top right
|
||||
db $08,$08,$8a,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED ; bottom left
|
||||
db $08,$00,$8b,OAMFLAG_VFLIPPED | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
|
||||
|
||||
SpriteSpecialCase ; 40ec (1:40ec)
|
||||
db $09
|
||||
; Sprite OAM Parameters
|
||||
db -$4,-$4,$00,$00
|
||||
db -$4,$04,$01,$00
|
||||
db -$4,$0c,$00,OAMFLAG_VFLIPPED
|
||||
db $04,-$4,$01,$00
|
||||
db $04,$04,$02,$00
|
||||
db $04,$0c,$01,$00
|
||||
db $0c,-$4,$00,OAM_VFLIP | OAMFLAG_CANBEMASKED
|
||||
db $0c,$04,$01,OAMFLAG_CANBEMASKED
|
||||
db $0c,$0c,$00,OAM_VFLIP | OAM_HFLIP | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
ItemPrices: ; 4608 (1:4608)
|
||||
ItemPrices: ; 4494 (1:4494)
|
||||
money 0 ; MASTER_BALL
|
||||
money 1200 ; ULTRA_BALL
|
||||
money 600 ; GREAT_BALL
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Func_f0000:: ; f0000 (3c:4000)
|
||||
PlayPikachuSoundClip:: ; f0000 (3c:4000)
|
||||
ld a, e
|
||||
ld e, a
|
||||
ld d, $0
|
||||
|
|
@ -53,7 +53,7 @@ Func_f0000:: ; f0000 (3c:4000)
|
|||
ld [rNR34], a
|
||||
pop hl
|
||||
pop bc
|
||||
call Func_150
|
||||
call PlayPikachuPCM
|
||||
xor a
|
||||
ld [wc0f3], a
|
||||
ld [wc0f4], a
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ PrintBeginningBattleText: ; f4000 (3d:4000)
|
|||
jr c,.asm_f4026
|
||||
ld e,$a
|
||||
.asm_f4026
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
jr .continue
|
||||
.notnewbattletype
|
||||
ld a, [wEnemyMonSpecies2]
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ HoFDisplayAndRecordMonInfo: ; 7030e (1c:430e)
|
|||
callab IsThisPartymonOurPikachu ; 3f:4e18
|
||||
jr nc, .asm_70336
|
||||
ld e, $22
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
jr .asm_7033c
|
||||
.asm_70336
|
||||
ld a,[wHoFMonSpecies]
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@ ItemUseEvoStone: ; d7d0 (3:57d0)
|
|||
callab IsThisPartymonOurPikachu
|
||||
jr nc, .notPlayerPikachu
|
||||
ld e, $1b
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
ld a, [wWhichPokemon]
|
||||
ld hl, wPartyMonNicks
|
||||
call GetPartyMonName
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ BillsPCDeposit: ; 2156d (8:556d)
|
|||
callab IsThisPartymonOurPikachu
|
||||
jr nc, .asm_215c9
|
||||
ld e, $1b
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
jr .asm_215cf
|
||||
.asm_215c9
|
||||
ld a, [wcf91]
|
||||
|
|
@ -304,7 +304,7 @@ BillsPCWithdraw: ; 21613 (8:5613)
|
|||
callab Func_fce0d
|
||||
jr nc, .asm_21660
|
||||
ld e, $22
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
jr .asm_21666
|
||||
.asm_21660
|
||||
ld a, [wcf91]
|
||||
|
|
@ -355,7 +355,7 @@ BillsPCRelease: ; 21690 (8:5690)
|
|||
ld hl, wBoxMonNicks
|
||||
call GetPartyMonName
|
||||
ld e, $27
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
ld hl, PikachuUnhappyText
|
||||
call PrintText
|
||||
jp BillsPCMenu
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
PrepareOAMData:
|
||||
PrepareOAMData: ; 499b (1:499b)
|
||||
; Determine OAM data for currently visible
|
||||
; sprites and write it to wOAMBuffer.
|
||||
; Yellow code has been changed to use registers more efficiently
|
||||
; as well as tweaking the code to show gbc palettes
|
||||
|
||||
ld a, [wUpdateSpritesEnabled]
|
||||
dec a
|
||||
jr z, .updateEnabled
|
||||
|
||||
cp 0 - 1
|
||||
cp $ff
|
||||
ret nz
|
||||
ld [wUpdateSpritesEnabled], a
|
||||
jp HideSprites
|
||||
|
|
@ -17,10 +19,10 @@ PrepareOAMData:
|
|||
|
||||
.spriteLoop
|
||||
ld [hSpriteOffset2], a
|
||||
|
||||
ld d, wSpriteStateData1 / $100
|
||||
ld a, [hSpriteOffset2]
|
||||
|
||||
ld e, a
|
||||
ld d, wSpriteStateData1 / $100
|
||||
|
||||
ld a, [de] ; c1x0
|
||||
and a
|
||||
jp z, .nextSprite
|
||||
|
|
@ -40,16 +42,22 @@ PrepareOAMData:
|
|||
jr c, .usefacing
|
||||
|
||||
; unchanging
|
||||
and $f
|
||||
add $10 ; skip to the second half of the table which doesn't account for facing direction
|
||||
ld a, $0
|
||||
jr .next
|
||||
|
||||
.usefacing
|
||||
and $f
|
||||
|
||||
.next
|
||||
; read the entry from the table
|
||||
ld c, a
|
||||
ld b, 0
|
||||
ld hl, SpriteFacingAndAnimationTable
|
||||
add hl, bc
|
||||
add hl, bc
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
|
||||
; get sprite priority
|
||||
push de
|
||||
inc d
|
||||
|
|
@ -61,65 +69,46 @@ PrepareOAMData:
|
|||
ld [hSpritePriority], a ; temp store sprite priority
|
||||
pop de
|
||||
|
||||
; read the entry from the table
|
||||
ld h, 0
|
||||
ld bc, SpriteFacingAndAnimationTable
|
||||
add hl, hl
|
||||
add hl, hl
|
||||
add hl, bc
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
ld a, [hli]
|
||||
ld b, a
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
|
||||
call GetSpriteScreenXY
|
||||
|
||||
ld a, [hOAMBufferOffset]
|
||||
add [hl]
|
||||
cp $a0
|
||||
jr z, .hidden
|
||||
jr nc, .asm_4a41
|
||||
.hidden
|
||||
call Func_4a7b
|
||||
ld [wd5cd], a
|
||||
ld a, [hOAMBufferOffset]
|
||||
|
||||
ld e, a
|
||||
ld d, wOAMBuffer / $100
|
||||
|
||||
.tileLoop
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
.loop
|
||||
ld a, [hSpriteScreenY] ; temp for sprite Y position
|
||||
add $10 ; Y=16 is top of screen (Y=0 is invisible)
|
||||
add [hl] ; add Y offset from table
|
||||
ld [de], a ; write new sprite OAM Y position
|
||||
inc hl
|
||||
inc e
|
||||
ld a, [hSpriteScreenX] ; temp for sprite X position
|
||||
add $8 ; X=8 is left of screen (X=0 is invisible)
|
||||
add [hl] ; add X offset from table
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc e
|
||||
ld [de], a ; write new sprite OAM X position
|
||||
inc e
|
||||
ld a, [bc] ; read pattern number offset (accommodates orientation (offset 0,4 or 8) and animation (offset 0 or $80))
|
||||
inc bc
|
||||
push bc
|
||||
ld a, [wd5cd]
|
||||
add [hl]
|
||||
cp $80
|
||||
jr c, .asm_4a1c
|
||||
ld b, a
|
||||
|
||||
ld a, [wd5cd] ; temp copy of c1x2
|
||||
swap a ; high nybble determines sprite used (0 is always player sprite, next are some npcs)
|
||||
and $f
|
||||
|
||||
; Sprites $a and $b have one face (and therefore 4 tiles instead of 12).
|
||||
; As a result, sprite $b's tile offset is less than normal.
|
||||
cp $b
|
||||
jr nz, .notFourTileSprite
|
||||
ld a, $a * 12 + 4
|
||||
jr .next2
|
||||
|
||||
.notFourTileSprite
|
||||
; a *= 12
|
||||
sla a
|
||||
sla a
|
||||
ld c, a
|
||||
sla a
|
||||
add c
|
||||
|
||||
.next2
|
||||
add b ; add the tile offset from the table (based on frame and facing direction)
|
||||
pop bc
|
||||
ld a, [$fffc]
|
||||
add b
|
||||
.asm_4a1c
|
||||
ld [de], a ; tile id
|
||||
inc hl
|
||||
inc e
|
||||
|
|
@ -129,15 +118,19 @@ PrepareOAMData:
|
|||
ld a, [hSpritePriority]
|
||||
or [hl]
|
||||
.skipPriority
|
||||
inc hl
|
||||
and $f0
|
||||
bit 4, a ; OBP0 or OBP1
|
||||
jr z, .spriteusesOBP0
|
||||
or %100 ; palettes 4-7 are OBP1
|
||||
.spriteusesOBP0
|
||||
ld [de], a
|
||||
inc hl
|
||||
inc e
|
||||
bit 0, a ; OAMFLAG_ENDOFDATA
|
||||
jr z, .tileLoop
|
||||
dec c
|
||||
jr nz, .loop
|
||||
|
||||
ld a, e
|
||||
ld [hOAMBufferOffset], a
|
||||
|
||||
.nextSprite
|
||||
ld a, [hSpriteOffset2]
|
||||
add $10
|
||||
|
|
@ -145,28 +138,33 @@ PrepareOAMData:
|
|||
jp nz, .spriteLoop
|
||||
|
||||
; Clear unused OAM.
|
||||
ld a, [hOAMBufferOffset]
|
||||
ld l, a
|
||||
ld h, wOAMBuffer / $100
|
||||
ld de, $4
|
||||
ld b, $a0
|
||||
.asm_4a41
|
||||
ld a, [wd736]
|
||||
bit 6, a ; jumping down ledge or fishing animation?
|
||||
ld a, $a0
|
||||
ld c, $a0
|
||||
jr z, .clear
|
||||
|
||||
; Don't clear the last 4 entries because they are used for the shadow in the
|
||||
; jumping down ledge animation and the rod in the fishing animation.
|
||||
ld a, $90
|
||||
ld c, $90
|
||||
|
||||
.clear
|
||||
cp l
|
||||
ret z
|
||||
ld a, [hOAMBufferOffset]
|
||||
cp c
|
||||
ret nc
|
||||
ld l, a
|
||||
ld h, wOAMBuffer / $100
|
||||
ld a, c
|
||||
ld de, $4 ; entry size
|
||||
ld b, $a0
|
||||
.clearLoop
|
||||
ld [hl], b
|
||||
add hl, de
|
||||
jr .clear
|
||||
cp l
|
||||
jr nz, .clearLoop
|
||||
ret
|
||||
|
||||
GetSpriteScreenXY: ; 4bd1 (1:4bd1)
|
||||
GetSpriteScreenXY: ; 4a5f (1:4a5f)
|
||||
inc e
|
||||
inc e
|
||||
ld a, [de] ; c1x4
|
||||
|
|
@ -188,6 +186,32 @@ GetSpriteScreenXY: ; 4bd1 (1:4bd1)
|
|||
ld [de], a ; c1xb (x)
|
||||
ret
|
||||
|
||||
Func_4a7b: ; 4a7b (1:4a7b)
|
||||
push bc
|
||||
ld a, [wd5cd] ; temp copy of c1x2
|
||||
swap a ; high nybble determines sprite used (0 is always player sprite, next are some npcs)
|
||||
and $f
|
||||
|
||||
; Sprites $a and $b have one face (and therefore 4 tiles instead of 12).
|
||||
; As a result, sprite $b's tile offset is less than normal.
|
||||
cp $b
|
||||
jr nz, .notFourTileSprite
|
||||
ld a, $a * 12 + 4 ; $7c
|
||||
jr .done
|
||||
|
||||
.notFourTileSprite
|
||||
; a *= 12
|
||||
add a
|
||||
add a
|
||||
ld c, a
|
||||
add a
|
||||
add c
|
||||
.done
|
||||
pop bc
|
||||
ret
|
||||
|
||||
INCLUDE "engine/oam_dma.asm"
|
||||
|
||||
_IsTilePassable:: ; 4aaa (1:4aaa)
|
||||
ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles
|
||||
ld a,[hli]
|
||||
|
|
@ -198,8 +222,11 @@ _IsTilePassable:: ; 4aaa (1:4aaa)
|
|||
cp a,$ff
|
||||
jr z,.tileNotPassable
|
||||
cp c
|
||||
ret z
|
||||
jr .loop
|
||||
jr nz,.loop
|
||||
xor a
|
||||
ret
|
||||
.tileNotPassable
|
||||
scf
|
||||
ret
|
||||
ret
|
||||
|
||||
INCLUDE "data/collision.asm" ; probably
|
||||
|
|
@ -1,9 +1,4 @@
|
|||
; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
|
||||
CopyFixedLengthText: ; 42b1 (1:42b1)
|
||||
ld bc, NAME_LENGTH
|
||||
jp CopyData
|
||||
|
||||
SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
|
||||
SetDefaultNamesBeforeTitlescreen: ; 414b (1:414b)
|
||||
ld hl, NintenText
|
||||
ld de, wPlayerName
|
||||
call CopyFixedLengthText
|
||||
|
|
@ -21,7 +16,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
|
|||
ld [wAudioROMBank], a
|
||||
ld [wAudioSavedROMBank], a
|
||||
|
||||
DisplayTitleScreen: ; 42dd (1:42dd)
|
||||
DisplayTitleScreen: ; 4171 (1:4171)
|
||||
call GBPalWhiteOut
|
||||
ld a, $1
|
||||
ld [H_AUTOBGTRANSFERENABLED], a
|
||||
|
|
@ -35,93 +30,35 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
call ClearScreen
|
||||
call DisableLCD
|
||||
call LoadFontTilePatterns
|
||||
ld hl, NintendoCopyrightLogoGraphics
|
||||
ld de, vTitleLogo2 + $100
|
||||
; todo: fix hl pointers
|
||||
ld hl, NintendoCopyrightLogoGraphics ; 4:4c48
|
||||
ld de, vTitleLogo + $600
|
||||
ld bc, $50
|
||||
ld a, BANK(NintendoCopyrightLogoGraphics)
|
||||
call FarCopyData2
|
||||
ld hl, GamefreakLogoGraphics
|
||||
ld de, vTitleLogo2 + $100 + $50
|
||||
call FarCopyData
|
||||
ld hl, NineTile ; 4:4e08
|
||||
ld de, vTitleLogo + $6e0
|
||||
ld bc, $10
|
||||
ld a, BANK(NineTile)
|
||||
call FarCopyData
|
||||
ld hl, GamefreakLogoGraphics ; 4:4d78
|
||||
ld de, vTitleLogo + $650
|
||||
ld bc, $90
|
||||
ld a, BANK(GamefreakLogoGraphics)
|
||||
call FarCopyData2
|
||||
ld hl, PokemonLogoGraphics
|
||||
ld de, vTitleLogo
|
||||
ld bc, $600
|
||||
ld a, BANK(PokemonLogoGraphics)
|
||||
call FarCopyData2 ; first chunk
|
||||
ld hl, PokemonLogoGraphics+$600
|
||||
ld de, vTitleLogo2
|
||||
ld bc, $100
|
||||
ld a, BANK(PokemonLogoGraphics)
|
||||
call FarCopyData2 ; second chunk
|
||||
ld hl, Version_GFX ; $402f
|
||||
ld de,vChars2 + $600
|
||||
ld bc, Version_GFXEnd - Version_GFX
|
||||
ld a, BANK(Version_GFX)
|
||||
call FarCopyDataDouble
|
||||
call ClearBothBGMaps
|
||||
|
||||
; place tiles for pokemon logo (except for the last row)
|
||||
coord hl, 2, 1
|
||||
ld a, $80
|
||||
ld de, SCREEN_WIDTH
|
||||
ld c, 6
|
||||
.pokemonLogoTileLoop
|
||||
ld b, $10
|
||||
push hl
|
||||
.pokemonLogoTileRowLoop ; place tiles for one row
|
||||
ld [hli], a
|
||||
inc a
|
||||
dec b
|
||||
jr nz, .pokemonLogoTileRowLoop
|
||||
pop hl
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .pokemonLogoTileLoop
|
||||
|
||||
; place tiles for the last row of the pokemon logo
|
||||
coord hl, 2, 7
|
||||
ld a, $31
|
||||
ld b, $10
|
||||
.pokemonLogoLastTileRowLoop
|
||||
ld [hli], a
|
||||
inc a
|
||||
dec b
|
||||
jr nz, .pokemonLogoLastTileRowLoop
|
||||
|
||||
call DrawPlayerCharacter
|
||||
|
||||
; put a pokeball in the player's hand
|
||||
ld hl, wOAMBuffer + $28
|
||||
ld a, $74
|
||||
ld [hl], a
|
||||
|
||||
; place tiles for title screen copyright
|
||||
coord hl, 2, 17
|
||||
ld de, .tileScreenCopyrightTiles
|
||||
ld b, $10
|
||||
.tileScreenCopyrightTilesLoop
|
||||
ld a, [de]
|
||||
ld [hli], a
|
||||
inc de
|
||||
dec b
|
||||
jr nz, .tileScreenCopyrightTilesLoop
|
||||
|
||||
jr .next
|
||||
|
||||
.tileScreenCopyrightTiles ; 437f (1:437f)
|
||||
db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
|
||||
|
||||
.next
|
||||
call FarCopyData
|
||||
callab Func_f453f
|
||||
ld hl, vBGMap0
|
||||
ld bc, (vBGMap1 + $400) - vBGMap0
|
||||
ld a, " "
|
||||
call FillMemory
|
||||
callab Func_f4578
|
||||
call Func_4418
|
||||
call .WriteCopyrightTiles
|
||||
call SaveScreenTilesToBuffer2
|
||||
call LoadScreenTilesFromBuffer2
|
||||
call EnableLCD
|
||||
ld a,CHARMANDER ; which Pokemon to show first on the title screen
|
||||
|
||||
ld [wTitleMonSpecies], a
|
||||
call LoadTitleMonSprite
|
||||
ld a, (vBGMap0 + $300) / $100
|
||||
callab Func_f459a
|
||||
ld a, $9b
|
||||
call TitleScreenCopyTileMapToVRAM
|
||||
call SaveScreenTilesToBuffer1
|
||||
ld a, $40
|
||||
|
|
@ -132,8 +69,9 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
ld b, SET_PAL_TITLE_SCREEN
|
||||
call RunPaletteCommand
|
||||
call GBPalNormal
|
||||
ld a, %11100100
|
||||
ld a, %11100000
|
||||
ld [rOBP0], a
|
||||
call UpdateGBCPal_OBP0
|
||||
|
||||
; make pokemon logo bounce up and down
|
||||
ld bc, hSCY ; background scroll Y
|
||||
|
|
@ -153,7 +91,7 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
call .ScrollTitleScreenPokemonLogo
|
||||
jr .bouncePokemonLogoLoop
|
||||
|
||||
.TitleScreenPokemonLogoYScrolls: ; 43db (1:43db)
|
||||
.TitleScreenPokemonLogoYScrolls ; 4228 (1:4228)
|
||||
; Controls the bouncing effect of the Pokemon logo on the title screen
|
||||
db -4,16 ; y scroll amount, number of times to scroll
|
||||
db 3,4
|
||||
|
|
@ -164,7 +102,7 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
db -1,2
|
||||
db 0 ; terminate list with 0
|
||||
|
||||
.ScrollTitleScreenPokemonLogo
|
||||
.ScrollTitleScreenPokemonLogo ; 4237 (1:4237)
|
||||
; Scrolls the Pokemon logo on the title screen to create the bouncing effect
|
||||
; Scrolls d pixels e times
|
||||
call DelayFrame
|
||||
|
|
@ -175,7 +113,22 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
jr nz, .ScrollTitleScreenPokemonLogo
|
||||
ret
|
||||
|
||||
.finishedBouncingPokemonLogo
|
||||
; place tiles for title screen copyright
|
||||
.WriteCopyrightTiles ; 4241 (1:4241)
|
||||
coord hl, 2, 17
|
||||
ld de, .tileScreenCopyrightTiles
|
||||
.titleScreenCopyrightTilesLoop
|
||||
ld a, [de]
|
||||
inc de
|
||||
cp $ff
|
||||
ret z
|
||||
ld [hli], a
|
||||
jr .titleScreenCopyrightTilesLoop
|
||||
|
||||
.tileScreenCopyrightTiles ; 424f (1:424f)
|
||||
db $e0,$e1,$e2,$e3,$e1,$e2,$ee,$e5,$e6,$e7,$e8,$e9,$ea,$eb,$ec,$ed,$ff ; ©1995-1999 GAME FREAK inc.
|
||||
|
||||
.finishedBouncingPokemonLogo ; 4260 (1:4260)
|
||||
call LoadScreenTilesFromBuffer1
|
||||
ld c, 36
|
||||
call DelayFrames
|
||||
|
|
@ -183,52 +136,41 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
call PlaySound
|
||||
|
||||
; scroll game version in from the right
|
||||
call PrintGameVersionOnTitleScreen
|
||||
callab Func_f4585
|
||||
ld a, SCREEN_HEIGHT_PIXELS
|
||||
ld [hWY], a
|
||||
ld d, 144
|
||||
.scrollTitleScreenGameVersionLoop
|
||||
ld h, d
|
||||
ld l, 64
|
||||
call ScrollTitleScreenGameVersion
|
||||
ld h, 0
|
||||
ld l, 80
|
||||
call ScrollTitleScreenGameVersion
|
||||
ld a, d
|
||||
add 4
|
||||
ld d, a
|
||||
and a
|
||||
jr nz, .scrollTitleScreenGameVersionLoop
|
||||
|
||||
ld a, vBGMap1 / $100
|
||||
call TitleScreenCopyTileMapToVRAM
|
||||
call LoadScreenTilesFromBuffer2
|
||||
call PrintGameVersionOnTitleScreen
|
||||
call Delay3
|
||||
ld e, 0
|
||||
call TitleScreen_PlayPikachuPCM
|
||||
call WaitForSoundToFinish
|
||||
call StopAllMusic
|
||||
ld a, MUSIC_TITLE_SCREEN
|
||||
ld [wNewSoundID], a
|
||||
call PlaySound
|
||||
.asm_428f
|
||||
xor a
|
||||
ld [wUnusedCC5B], a
|
||||
|
||||
; Keep scrolling in new mons indefinitely until the user performs input.
|
||||
.awaitUserInterruptionLoop
|
||||
ld c, 200
|
||||
call CheckForUserInterruption
|
||||
jr c, .finishedWaiting
|
||||
call TitleScreenScrollInMon
|
||||
ld c, 1
|
||||
call CheckForUserInterruption
|
||||
jr c, .finishedWaiting
|
||||
callba TitleScreenAnimateBallIfStarterOut
|
||||
call TitleScreenPickNewMon
|
||||
jr .awaitUserInterruptionLoop
|
||||
|
||||
.finishedWaiting
|
||||
ld a, [wTitleMonSpecies]
|
||||
call PlayCry
|
||||
call WaitForSoundToFinish
|
||||
ld [wTitleMonSpecies], a
|
||||
ld [wTitleMonSpecies+1], a
|
||||
ld [wTitleMonSpecies+2], a
|
||||
ld [wTitleMonSpecies+3], a
|
||||
ld a, $f
|
||||
ld [wTitleMonSpecies+4], a
|
||||
.titleScreenLoop
|
||||
call IncrementResetCounter
|
||||
jp c, .doTitlescreenReset
|
||||
call DelayFrame
|
||||
call JoypadLowSensitivity
|
||||
ld a, [hJoyHeld]
|
||||
cp D_UP | SELECT | B_BUTTON
|
||||
jr z, .asm_42bf
|
||||
and A_BUTTON | START
|
||||
jr nz, .asm_42bf
|
||||
call Func_4390
|
||||
jr .titleScreenLoop
|
||||
.asm_42bf
|
||||
ld e, $a
|
||||
call TitleScreen_PlayPikachuPCM
|
||||
call GBPalWhiteOutWithDelay3
|
||||
call ClearSprites
|
||||
xor a
|
||||
|
|
@ -248,143 +190,172 @@ DisplayTitleScreen: ; 42dd (1:42dd)
|
|||
cp D_UP | SELECT | B_BUTTON
|
||||
jp z, .doClearSaveDialogue
|
||||
jp MainMenu
|
||||
.asm_42f0 ; 42f0 (1:42f0)
|
||||
callab Func_e8e79
|
||||
jp .asm_428f
|
||||
|
||||
.doClearSaveDialogue
|
||||
.asm_42fb ; 42fb (1:42fb)
|
||||
ld a, [wTitleMonSpecies+4]
|
||||
inc a
|
||||
cp $2a
|
||||
jr c, .asm_4305
|
||||
ld a, $f
|
||||
.asm_4305
|
||||
ld [wTitleMonSpecies+4], a
|
||||
ld e, a
|
||||
callab PlayPikachuSoundClip
|
||||
xor a
|
||||
ld [wTitleMonSpecies+2], a
|
||||
ld [wTitleMonSpecies+3], a
|
||||
jp .titleScreenLoop
|
||||
.doTitlescreenReset ; 431b (1:431b)
|
||||
ld [wAudioFadeOutControl], a
|
||||
call StopAllMusic
|
||||
.audioFadeLoop
|
||||
ld a, [wAudioFadeOutControl]
|
||||
and a
|
||||
jr nz, .audioFadeLoop
|
||||
jp Init
|
||||
|
||||
.doClearSaveDialogue ; 432a (1:432a)
|
||||
jpba DoClearSaveDialogue
|
||||
|
||||
TitleScreenPickNewMon: ; 4496 (1:4496)
|
||||
ld a, vBGMap0 / $100
|
||||
call TitleScreenCopyTileMapToVRAM
|
||||
|
||||
.loop
|
||||
; Keep looping until a mon different from the current one is picked.
|
||||
call Random
|
||||
and $f
|
||||
ld c, a
|
||||
ld b, 0
|
||||
ld hl, TitleMons
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld hl, wTitleMonSpecies
|
||||
|
||||
; Can't be the same as before.
|
||||
cp [hl]
|
||||
jr z, .loop
|
||||
|
||||
ld [hl], a
|
||||
call LoadTitleMonSprite
|
||||
|
||||
ld a, $90
|
||||
ld [hWY], a
|
||||
ld d, 1 ; scroll out
|
||||
callba TitleScroll
|
||||
ret
|
||||
|
||||
TitleScreenScrollInMon: ; 44c1 (1:44c1)
|
||||
ld d, 0 ; scroll in
|
||||
callba TitleScroll
|
||||
xor a
|
||||
ld [hWY], a
|
||||
ret
|
||||
|
||||
ScrollTitleScreenGameVersion: ; 44cf (1:44cf)
|
||||
.wait
|
||||
ld a, [rLY]
|
||||
cp l
|
||||
jr nz, .wait
|
||||
|
||||
ld a, h
|
||||
ld [rSCX], a
|
||||
|
||||
.wait2
|
||||
ld a, [rLY]
|
||||
cp h
|
||||
jr z, .wait2
|
||||
ret
|
||||
|
||||
DrawPlayerCharacter: ; 44dd (1:44dd)
|
||||
ld hl, PlayerCharacterTitleGraphics
|
||||
ld de, vSprites
|
||||
ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
|
||||
ld a, BANK(PlayerCharacterTitleGraphics)
|
||||
call FarCopyData2
|
||||
call ClearSprites
|
||||
xor a
|
||||
ld [wPlayerCharacterOAMTile], a
|
||||
ld hl, wOAMBuffer
|
||||
ld de, $605a
|
||||
ld b, 7
|
||||
.loop
|
||||
push de
|
||||
ld c, 5
|
||||
.innerLoop
|
||||
ld a, d
|
||||
ld [hli], a ; Y
|
||||
ld a, e
|
||||
ld [hli], a ; X
|
||||
add 8
|
||||
ld e, a
|
||||
ld a, [wPlayerCharacterOAMTile]
|
||||
ld [hli], a ; tile
|
||||
inc a
|
||||
ld [wPlayerCharacterOAMTile], a
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .innerLoop
|
||||
pop de
|
||||
ld a, 8
|
||||
add d
|
||||
ld d, a
|
||||
dec b
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
ClearBothBGMaps: ; 4519 (1:4519)
|
||||
ld hl, vBGMap0
|
||||
ld bc, $400 * 2
|
||||
ld a, " "
|
||||
jp FillMemory
|
||||
|
||||
LoadTitleMonSprite: ; 4524 (1:4524)
|
||||
ld [wcf91], a
|
||||
ld [wd0b5], a
|
||||
coord hl, 5, 10
|
||||
call GetMonHeader
|
||||
jp LoadFrontSpriteByMonIndex
|
||||
|
||||
TitleScreenCopyTileMapToVRAM: ; 4533 (1:4533)
|
||||
TitleScreenCopyTileMapToVRAM: ; 4332 (1:4332)
|
||||
ld [H_AUTOBGTRANSFERDEST + 1], a
|
||||
jp Delay3
|
||||
|
||||
LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538)
|
||||
LoadCopyrightAndTextBoxTiles: ; 4337 (1:4337)
|
||||
xor a
|
||||
ld [hWY], a
|
||||
call ClearScreen
|
||||
call LoadTextBoxTilePatterns
|
||||
|
||||
LoadCopyrightTiles: ; 4541 (1:4541)
|
||||
LoadCopyrightTiles: ; 4340 (1:4340)
|
||||
ld de, NintendoCopyrightLogoGraphics
|
||||
ld hl, vChars2 + $600
|
||||
lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
|
||||
lb bc, BANK(NintendoCopyrightLogoGraphics), (TextBoxGraphics + $10 - NintendoCopyrightLogoGraphics) / $10 ; bug: overflows into text box graphics and copies the "A" tile
|
||||
call CopyVideoData
|
||||
coord hl, 2, 7
|
||||
ld de, CopyrightTextString
|
||||
jp PlaceString
|
||||
|
||||
CopyrightTextString: ; 4556 (1:4556)
|
||||
db $60,$61,$62,$61,$63,$61,$64,$7F,$65,$66,$67,$68,$69,$6A ; ©'95.'96.'98 Nintendo
|
||||
next $60,$61,$62,$61,$63,$61,$64,$7F,$6B,$6C,$6D,$6E,$6F,$70,$71,$72 ; ©'95.'96.'98 Creatures inc.
|
||||
next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc.
|
||||
CopyrightTextString: ; 4355 (1:4355)
|
||||
db $60,$61,$62,$63,$61,$62,$7c,$7f,$65,$66,$67,$68,$69,$6a ; ©1995-1999 Nintendo
|
||||
next $60,$61,$62,$63,$61,$62,$7c,$7f,$6b,$6c,$6d,$6e,$6f,$70,$71,$72 ; ©1995-1999 Creatures inc.
|
||||
next $60,$61,$62,$63,$61,$62,$7c,$7f,$73,$74,$75,$76,$77,$78,$79,$7a,$7b ; ©1995-1999 GAME FREAK inc.
|
||||
db "@"
|
||||
|
||||
INCLUDE "data/title_mons.asm"
|
||||
TitleScreen_PlayPikachuPCM: ; 4387 (1:4387)
|
||||
callab PlayPikachuSoundClip
|
||||
ret
|
||||
|
||||
Func_4390: ; 4390 (1:4390)
|
||||
call Func_43de
|
||||
ld a, [wTitleMonSpecies]
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, PointerTable_43a2
|
||||
add hl, de
|
||||
add hl, de
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
jp hl
|
||||
|
||||
PointerTable_43a2: ; 43a2 (1:43a2)
|
||||
dw Func_43be
|
||||
dw Func_43c3
|
||||
dw Func_43d9
|
||||
dw Func_43d9
|
||||
dw Func_43c7
|
||||
dw Func_43d9
|
||||
dw Func_43d9
|
||||
dw Func_43c3
|
||||
dw Func_43d9
|
||||
dw Func_43d9
|
||||
dw Func_43bf
|
||||
dw Func_43ba
|
||||
|
||||
Func_43ba: ; 43ba (1:43ba)
|
||||
xor a
|
||||
ld [wTitleMonSpecies], a
|
||||
Func_43be
|
||||
ret
|
||||
|
||||
Func_43bf: ; 43bf (1:43bf)
|
||||
ld e, 0
|
||||
jr asm_43c9
|
||||
Func_43c3: ; 43c3 (1:43c3)
|
||||
ld e, 4
|
||||
jr asm_43c9
|
||||
Func_43c7: ; 43c7 (1:43c7)
|
||||
ld e, 8
|
||||
asm_43c9: ; 43c9 (1:43c9)
|
||||
ld hl, wOAMBuffer + 2
|
||||
ld c, 8
|
||||
.loop
|
||||
ld a, [hl]
|
||||
and $f3
|
||||
or e
|
||||
ld [hli], a
|
||||
inc hl
|
||||
inc hl
|
||||
inc hl
|
||||
dec c
|
||||
jr nz, .loop
|
||||
Func_43d9: ; 43d9 (1:43d9)
|
||||
ld hl, wTitleMonSpecies
|
||||
inc [hl]
|
||||
ret
|
||||
|
||||
Func_43de: ; 43de (1:43de)
|
||||
ld hl, wTitleMonSpecies + 1
|
||||
ld a, [hl]
|
||||
inc [hl]
|
||||
and a
|
||||
jr z, .asm_43ed
|
||||
cp $80
|
||||
jr z, .asm_43ed
|
||||
cp $90
|
||||
ret nz
|
||||
.asm_43ed
|
||||
ld a, $1
|
||||
ld [wTitleMonSpecies], a
|
||||
ret
|
||||
|
||||
; prints version text (red, blue)
|
||||
PrintGameVersionOnTitleScreen: ; 4598 (1:4598)
|
||||
coord hl, 7, 8
|
||||
ld de, VersionOnTitleScreenText
|
||||
jp PlaceString
|
||||
; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
|
||||
CopyFixedLengthText: ; 43f3 (1:43f3)
|
||||
ld bc, NAME_LENGTH
|
||||
jp CopyData
|
||||
|
||||
NintenText: db "NINTEN@"
|
||||
SonyText: db "SONY@"
|
||||
|
||||
; these point to special tiles specifically loaded for that purpose and are not usual text
|
||||
VersionOnTitleScreenText: ; 45a1 (1:45a1)
|
||||
db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version"
|
||||
IncrementResetCounter: ; 4405 (1:4405)
|
||||
ld hl, wTitleMonSpecies + 2
|
||||
ld e, [hl]
|
||||
inc hl
|
||||
ld d, [hl]
|
||||
inc de
|
||||
ld a, d
|
||||
cp $c
|
||||
jr z, .doReset
|
||||
ld [hl], d
|
||||
dec hl
|
||||
ld [hl], e
|
||||
and a
|
||||
ret
|
||||
.doReset
|
||||
scf
|
||||
ret
|
||||
|
||||
Func_4418: ; 4418 (1:4418)
|
||||
xor a
|
||||
call SwitchSRAMBankAndLatchClockData
|
||||
ld hl, $a000
|
||||
ld bc, $20
|
||||
ld a, $aa
|
||||
call FillMemory
|
||||
call PrepareRTCDataAndDisableSRAM
|
||||
ret
|
||||
|
|
@ -108,7 +108,7 @@ DisplayTownMap: ; 70eb7 (1c:4eb7)
|
|||
ld a,[hJoy5]
|
||||
and D_DOWN | D_UP
|
||||
ret z
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
ret
|
||||
|
||||
INCLUDE "data/town_map_order.asm"
|
||||
|
|
|
|||
32
home.asm
32
home.asm
|
|
@ -32,7 +32,7 @@ SECTION "joypad", ROM0 [$60]
|
|||
|
||||
SECTION "Home", ROM0
|
||||
|
||||
DisableLCD::
|
||||
DisableLCD:: ; 0061 (0:0061)
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld a, [rIE]
|
||||
|
|
@ -52,13 +52,13 @@ DisableLCD::
|
|||
ld [rIE], a
|
||||
ret
|
||||
|
||||
EnableLCD::
|
||||
EnableLCD:: ; 007b (0:007b)
|
||||
ld a, [rLCDC]
|
||||
set rLCDC_ENABLE, a
|
||||
ld [rLCDC], a
|
||||
ret
|
||||
|
||||
ClearSprites::
|
||||
ClearSprites:: ; 0082 (0:0082)
|
||||
xor a
|
||||
ld hl, wOAMBuffer
|
||||
ld b, 40 * 4
|
||||
|
|
@ -68,7 +68,7 @@ ClearSprites::
|
|||
jr nz, .loop
|
||||
ret
|
||||
|
||||
HideSprites::
|
||||
HideSprites:: ; 008d (0:008d)
|
||||
ld a, 160
|
||||
ld hl, wOAMBuffer
|
||||
ld de, 4
|
||||
|
|
@ -101,7 +101,7 @@ SECTION "Header", ROM0 [$104]
|
|||
|
||||
SECTION "Main", ROM0
|
||||
|
||||
Func_150:: ; 0150 (0:0150)
|
||||
PlayPikachuPCM:: ; 0150 (0:0150)
|
||||
ld a,[H_LOADEDROMBANK]
|
||||
push af
|
||||
ld a,b
|
||||
|
|
@ -114,16 +114,16 @@ Func_150:: ; 0150 (0:0150)
|
|||
ld a,[hli]
|
||||
ld d,a
|
||||
ld a,$3
|
||||
.unknownloop
|
||||
.playSingleSample
|
||||
dec a
|
||||
jr nz,.unknownloop
|
||||
jr nz,.playSingleSample
|
||||
|
||||
rept 7
|
||||
call Func_199
|
||||
call Func_1a5
|
||||
call LoadNextSoundClipSample
|
||||
call PlaySoundClipSample
|
||||
endr
|
||||
|
||||
call Func_199
|
||||
call LoadNextSoundClipSample
|
||||
dec bc
|
||||
ld a,c
|
||||
or b
|
||||
|
|
@ -132,7 +132,7 @@ Func_150:: ; 0150 (0:0150)
|
|||
call BankswitchCommon
|
||||
ret
|
||||
|
||||
Func_199:: ; 0199 (0:0199)
|
||||
LoadNextSoundClipSample:: ; 0199 (0:0199)
|
||||
ld a,d
|
||||
and $80
|
||||
srl a
|
||||
|
|
@ -141,14 +141,14 @@ Func_199:: ; 0199 (0:0199)
|
|||
sla d
|
||||
ret
|
||||
|
||||
Func_1a5:: ; 01a5 (0:01a5)
|
||||
PlaySoundClipSample:: ; 01a5 (0:01a5)
|
||||
ld a,$3
|
||||
.unknownloop2
|
||||
.loop
|
||||
dec a
|
||||
jr nz,.unknownloop2
|
||||
jr nz,.loop
|
||||
ret
|
||||
|
||||
Start::
|
||||
Start:: ; 01ab (0:01ab)
|
||||
cp GBC
|
||||
jr z, .gbc
|
||||
xor a
|
||||
|
|
@ -159,7 +159,7 @@ Start::
|
|||
ld [hGBC], a
|
||||
jp Init
|
||||
|
||||
Joypad:: ; 01b9
|
||||
Joypad:: ; 01b9 (0:01b9)
|
||||
homecall_jump _Joypad
|
||||
|
||||
ReadJoypad:: ; 01c8 (0:01c8)
|
||||
|
|
|
|||
2
main.asm
2
main.asm
|
|
@ -2540,7 +2540,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de)
|
|||
callab IsThisPartymonOurPikachu
|
||||
jr nc, .curMonNotPlayerPikachu
|
||||
ld e, $3
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
callab_ModifyPikachuHappiness_ld_d PIKAHAPPY_PSNFNT
|
||||
.curMonNotPlayerPikachu
|
||||
pop de
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
ItemNames: ; 472b (1:472b)
|
||||
ItemNames: ; 45b7 (1:45b7)
|
||||
db "MASTER BALL@"
|
||||
db "ULTRA BALL@"
|
||||
db "GREAT BALL@"
|
||||
|
|
|
|||
547
yellow/main.asm
547
yellow/main.asm
|
|
@ -18,31 +18,529 @@ SECTION "home",ROM0
|
|||
INCLUDE "home.asm"
|
||||
SECTION "bank01",ROMX,BANK[$01]
|
||||
|
||||
;INCLUDE "data/facing.asm"
|
||||
dr $4000,$4111
|
||||
INCLUDE "data/facing.asm"
|
||||
INCLUDE "engine/battle/safari_zone.asm"
|
||||
SetDefaultNamesBeforeTitlescreen: ; 414b (1:414b)
|
||||
dr $414b,$442b
|
||||
INCLUDE "engine/titlescreen.asm"
|
||||
|
||||
LoadMonData_: ; 442b (1:442b)
|
||||
dr $442b,$4494
|
||||
ItemPrices: ; 4494 (1:4494)
|
||||
dr $4494,$45b7
|
||||
ItemNames: ; 45b7 (1:45b7)
|
||||
dr $45b7,$491e
|
||||
; Load monster [wWhichPokemon] from list [wMonDataLocation]:
|
||||
; 0: partymon
|
||||
; 1: enemymon
|
||||
; 2: boxmon
|
||||
; 3: daycaremon
|
||||
; Return monster id at wcf91 and its data at wLoadedMon.
|
||||
; Also load base stats at W_MONHEADER for convenience.
|
||||
|
||||
ld a, [wDayCareMonSpecies]
|
||||
ld [wcf91], a
|
||||
ld a, [wMonDataLocation]
|
||||
cp DAYCARE_DATA
|
||||
jr z, .GetMonHeader
|
||||
|
||||
ld a, [wWhichPokemon]
|
||||
ld e, a
|
||||
call GetMonSpecies
|
||||
|
||||
.GetMonHeader
|
||||
ld a, [wcf91]
|
||||
ld [wd0b5], a ; input for GetMonHeader
|
||||
call GetMonHeader
|
||||
|
||||
ld hl, wPartyMons
|
||||
ld bc, wPartyMon2 - wPartyMon1
|
||||
ld a, [wMonDataLocation]
|
||||
cp ENEMY_PARTY_DATA
|
||||
jr c, .getMonEntry
|
||||
|
||||
ld hl, wEnemyMons
|
||||
jr z, .getMonEntry
|
||||
|
||||
cp 2
|
||||
ld hl, wBoxMons
|
||||
ld bc, wBoxMon2 - wBoxMon1
|
||||
jr z, .getMonEntry
|
||||
|
||||
ld hl, wDayCareMon
|
||||
jr .copyMonData
|
||||
|
||||
.getMonEntry
|
||||
ld a, [wWhichPokemon]
|
||||
call AddNTimes
|
||||
|
||||
.copyMonData
|
||||
ld de, wLoadedMon
|
||||
ld bc, wPartyMon2 - wPartyMon1
|
||||
jp CopyData
|
||||
|
||||
; get species of mon e in list [wMonDataLocation] for LoadMonData
|
||||
GetMonSpecies: ; 4478 (1:4478)
|
||||
ld hl, wPartySpecies
|
||||
ld a, [wMonDataLocation]
|
||||
and a
|
||||
jr z, .getSpecies
|
||||
dec a
|
||||
jr z, .enemyParty
|
||||
ld hl, wBoxSpecies
|
||||
jr .getSpecies
|
||||
.enemyParty
|
||||
ld hl, wEnemyPartyMons
|
||||
.getSpecies
|
||||
ld d, 0
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
ld [wcf91], a
|
||||
ret
|
||||
|
||||
INCLUDE "data/item_prices.asm"
|
||||
INCLUDE "text/item_names.asm"
|
||||
|
||||
UnusedNames: ; 491e (1:491e)
|
||||
dr $491e,$499b
|
||||
PrepareOAMData: ; 499b (1:499b)
|
||||
dr $499b,$4a92
|
||||
WriteDMACodeToHRAM: ; 4a92 (1:4a92)
|
||||
dr $4a92,$4aaa
|
||||
_IsTilePassable: ; 4aaa (1:4aaa)
|
||||
dr $4aaa,$4b89
|
||||
db "かみなりバッヂ@"
|
||||
db "かいがらバッヂ@"
|
||||
db "おじぞうバッヂ@"
|
||||
db "はやぶさバッヂ@"
|
||||
db "ひんやりバッヂ@"
|
||||
db "なかよしバッヂ@"
|
||||
db "バラバッヂ@"
|
||||
db "ひのたまバッヂ@"
|
||||
db "ゴールドバッヂ@"
|
||||
db "たまご@"
|
||||
db "ひよこ@"
|
||||
db "ブロンズ@"
|
||||
db "シルバー@"
|
||||
db "ゴールド@"
|
||||
db "プチキャプテン@"
|
||||
db "キャプテン@"
|
||||
db "プチマスター@"
|
||||
db "マスター@"
|
||||
db "エクセレント"
|
||||
|
||||
INCLUDE "engine/overworld/oam.asm"
|
||||
|
||||
PrintWaitingText: ; 4b89 (1:4b89)
|
||||
dr $4b89,$4bb7
|
||||
coord hl, 3, 10
|
||||
lb bc, 1, 11
|
||||
ld a, [W_ISINBATTLE]
|
||||
and a
|
||||
jr z, .asm_4b9a
|
||||
call TextBoxBorder
|
||||
jr .asm_4b9d
|
||||
.asm_4b9a
|
||||
call CableClub_TextBoxBorder
|
||||
.asm_4b9d
|
||||
coord hl, 4, 11
|
||||
ld de, WaitingText
|
||||
call PlaceString
|
||||
ld c, 50
|
||||
jp DelayFrames
|
||||
|
||||
WaitingText: ; 4bab (1:4bab)
|
||||
db "Waiting...!@"
|
||||
|
||||
_UpdateSprites: ; 4bb7 (1:4bb7)
|
||||
dr $4bb7,$5012
|
||||
ld h, wSpriteStateData1 / $100
|
||||
inc h
|
||||
ld a, $e ; (wSpriteStateData2 + $0e) & $ff
|
||||
.spriteLoop
|
||||
ld l, a
|
||||
sub $e
|
||||
ld c, a
|
||||
ld [H_CURRENTSPRITEOFFSET], a
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .skipSprite ; tests $c2Xe
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
call .updateCurrentSprite
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
.skipSprite
|
||||
ld a, l
|
||||
add $10 ; move to next sprite
|
||||
cp $e ; test for overflow (back at $0e)
|
||||
jr nz, .spriteLoop
|
||||
ret
|
||||
.updateCurrentSprite ; 4bd7 (1:4bd7)
|
||||
ld a, [H_CURRENTSPRITEOFFSET]
|
||||
and a
|
||||
jp z, UpdatePlayerSprite
|
||||
cp $f0 ; pikachu
|
||||
jp z, Func_1552
|
||||
ld a, [hl]
|
||||
|
||||
UpdateNonPlayerSprite: ; 4be3 (1:4be3)
|
||||
dec a
|
||||
swap a
|
||||
ld [$ff93], a ; $10 * sprite#
|
||||
ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset?
|
||||
ld b, a
|
||||
ld a, [H_CURRENTSPRITEOFFSET]
|
||||
cp b
|
||||
jr nz, .unequal
|
||||
jp DoScriptedNPCMovement
|
||||
.unequal
|
||||
jp UpdateNPCSprite
|
||||
|
||||
; This detects if the current sprite (whose offset is at H_CURRENTSPRITEOFFSET)
|
||||
; is going to collide with another sprite by looping over the other sprites.
|
||||
; The current sprite's offset will be labelled with i (e.g. $c1i0).
|
||||
; The loop sprite's offset will labelled with j (e.g. $c1j0).
|
||||
;
|
||||
; Note that the Y coordinate of the sprite (in [$c1k4]) is one of the following
|
||||
; 9 values when the sprite is aligned with the grid: $fc, $0c, $1c, $2c, ..., $7c.
|
||||
; The reason that 4 is added below to the coordinate is to make it align with a
|
||||
; multiple of $10 to make comparisons easier.
|
||||
DetectCollisionBetweenSprites: ; 4bf7 (1:4bf7)
|
||||
; nop
|
||||
|
||||
ld h, wSpriteStateData1 / $100
|
||||
ld a, [H_CURRENTSPRITEOFFSET]
|
||||
ld l, a
|
||||
|
||||
ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused)
|
||||
and a ; is this sprite slot slot used?
|
||||
ret z ; return if not used
|
||||
|
||||
ld a, l
|
||||
add 3
|
||||
ld l, a
|
||||
|
||||
ld a, [hli] ; a = [$c1i3] (delta Y) (-1, 0, or 1)
|
||||
call SetSpriteCollisionValues
|
||||
|
||||
ld a, [hli] ; a = [$C1i4] (Y screen coordinate)
|
||||
add 4 ; align with multiple of $10
|
||||
|
||||
; The effect of the following 3 lines is to
|
||||
; add 7 to a if moving south or
|
||||
; subtract 7 from a if moving north.
|
||||
add b
|
||||
and $f0
|
||||
or c
|
||||
|
||||
ld [$ff90], a ; store Y coordinate adjusted for direction of movement
|
||||
|
||||
ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1)
|
||||
call SetSpriteCollisionValues
|
||||
ld a, [hl] ; a = [$C1i6] (X screen coordinate)
|
||||
|
||||
; The effect of the following 3 lines is to
|
||||
; add 7 to a if moving east or
|
||||
; subtract 7 from a if moving west.
|
||||
add b
|
||||
and $f0
|
||||
or c
|
||||
|
||||
ld [$ff91], a ; store X coordinate adjusted for direction of movement
|
||||
|
||||
ld a, l
|
||||
add 7
|
||||
ld l, a
|
||||
|
||||
xor a
|
||||
ld [hld], a ; zero [$c1id] XXX what's [$c1id] for?
|
||||
ld [hld], a ; zero [$c1ic] (directions in which collisions occurred)
|
||||
|
||||
ld a, [$ff91]
|
||||
ld [hld], a ; [$c1ib] = adjusted X coordinate
|
||||
ld a, [$ff90]
|
||||
ld [hl], a ; [$c1ia] = adjusted Y coordinate
|
||||
|
||||
xor a ; zero the loop counter
|
||||
|
||||
.loop
|
||||
ld [$ff8f], a ; store loop counter
|
||||
swap a
|
||||
ld e, a
|
||||
ld a, [H_CURRENTSPRITEOFFSET]
|
||||
cp e ; does the loop sprite match the current sprite?
|
||||
jp z, .next ; go to the next sprite if they match
|
||||
|
||||
ld d, h
|
||||
ld a, [de] ; a = [$c1j0] (picture) (0 if slot is unused)
|
||||
and a ; is this sprite slot slot used?
|
||||
jp z, .next ; go the next sprite if not used
|
||||
|
||||
inc e
|
||||
inc e
|
||||
ld a, [de] ; a = [$c1j2] ($ff means the sprite is offscreen)
|
||||
inc a
|
||||
jp z, .next ; go the next sprite if offscreen
|
||||
|
||||
ld a, [H_CURRENTSPRITEOFFSET]
|
||||
add 10
|
||||
ld l, a
|
||||
|
||||
inc e
|
||||
ld a, [de] ; a = [$c1j3] (delta Y)
|
||||
call SetSpriteCollisionValues
|
||||
|
||||
inc e
|
||||
ld a, [de] ; a = [$C1j4] (Y screen coordinate)
|
||||
add 4 ; align with multiple of $10
|
||||
|
||||
; The effect of the following 3 lines is to
|
||||
; add 7 to a if moving south or
|
||||
; subtract 7 from a if moving north.
|
||||
add b
|
||||
and $f0
|
||||
or c
|
||||
|
||||
sub [hl] ; subtract the adjusted Y coordinate of sprite i ([$c1ia]) from that of sprite j
|
||||
|
||||
; calculate the absolute value of the difference to get the distance
|
||||
jr nc, .noCarry1
|
||||
cpl
|
||||
inc a
|
||||
.noCarry1
|
||||
ld [$ff90], a ; store the distance between the two sprites' adjusted Y values
|
||||
|
||||
; Use the carry flag set by the above subtraction to determine which sprite's
|
||||
; Y coordinate is larger. This information is used later to set [$c1ic],
|
||||
; which stores which direction the collision occurred in.
|
||||
; The following 5 lines set the lowest 2 bits of c, which are later shifted left by 2.
|
||||
; If sprite i's Y is larger, set lowest 2 bits of c to 10.
|
||||
; If sprite j's Y is larger or both are equal, set lowest 2 bits of c to 01.
|
||||
push af
|
||||
rl c
|
||||
pop af
|
||||
ccf
|
||||
rl c
|
||||
|
||||
; If sprite i's delta Y is 0, then b = 7, else b = 9.
|
||||
ld b, 7
|
||||
ld a, [hl] ; a = [$c1ia] (adjusted Y coordinate)
|
||||
and $f
|
||||
jr z, .next1
|
||||
ld b, 9
|
||||
|
||||
.next1
|
||||
ld a, [$ff90] ; a = distance between adjusted Y coordinates
|
||||
sub b
|
||||
ld [$ff92], a ; store distance adjusted using sprite i's direction
|
||||
ld a, b
|
||||
ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y
|
||||
jr c, .checkXDistance
|
||||
|
||||
; If sprite j's delta Y is 0, then b = 7, else b = 9.
|
||||
ld b, 7
|
||||
dec e
|
||||
ld a, [de] ; a = [$c1j3] (delta Y)
|
||||
inc e
|
||||
and a
|
||||
jr z, .next2
|
||||
ld b, 9
|
||||
|
||||
.next2
|
||||
ld a, [$ff92] ; a = distance adjusted using sprite i's direction
|
||||
sub b ; adjust distance using sprite j's direction
|
||||
jr z, .checkXDistance
|
||||
jr nc, .next ; go to next sprite if distance is still positive after both adjustments
|
||||
|
||||
.checkXDistance
|
||||
inc e
|
||||
inc l
|
||||
ld a, [de] ; a = [$c1j5] (delta X)
|
||||
|
||||
push bc
|
||||
|
||||
call SetSpriteCollisionValues
|
||||
inc e
|
||||
ld a, [de] ; a = [$c1j6] (X screen coordinate)
|
||||
|
||||
; The effect of the following 3 lines is to
|
||||
; add 7 to a if moving east or
|
||||
; subtract 7 from a if moving west.
|
||||
add b
|
||||
and $f0
|
||||
or c
|
||||
|
||||
pop bc
|
||||
|
||||
sub [hl] ; subtract the adjusted X coordinate of sprite i ([$c1ib]) from that of sprite j
|
||||
|
||||
; calculate the absolute value of the difference to get the distance
|
||||
jr nc, .noCarry2
|
||||
cpl
|
||||
inc a
|
||||
.noCarry2
|
||||
ld [$ff91], a ; store the distance between the two sprites' adjusted X values
|
||||
|
||||
; Use the carry flag set by the above subtraction to determine which sprite's
|
||||
; X coordinate is larger. This information is used later to set [$c1ic],
|
||||
; which stores which direction the collision occurred in.
|
||||
; The following 5 lines set the lowest 2 bits of c.
|
||||
; If sprite i's X is larger, set lowest 2 bits of c to 10.
|
||||
; If sprite j's X is larger or both are equal, set lowest 2 bits of c to 01.
|
||||
push af
|
||||
rl c
|
||||
pop af
|
||||
ccf
|
||||
rl c
|
||||
|
||||
; If sprite i's delta X is 0, then b = 7, else b = 9.
|
||||
ld b, 7
|
||||
ld a, [hl] ; a = [$c1ib] (adjusted X coordinate)
|
||||
and $f
|
||||
jr z, .next3
|
||||
ld b, 9
|
||||
|
||||
.next3
|
||||
ld a, [$ff91] ; a = distance between adjusted X coordinates
|
||||
sub b
|
||||
ld [$ff92], a ; store distance adjusted using sprite i's direction
|
||||
ld a, b
|
||||
ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X
|
||||
jr c, .collision
|
||||
|
||||
; If sprite j's delta X is 0, then b = 7, else b = 9.
|
||||
ld b, 7
|
||||
dec e
|
||||
ld a, [de] ; a = [$c1j5] (delta X)
|
||||
inc e
|
||||
and a
|
||||
jr z, .next4
|
||||
ld b, 9
|
||||
|
||||
.next4
|
||||
ld a, [$ff92] ; a = distance adjusted using sprite i's direction
|
||||
sub b ; adjust distance using sprite j's direction
|
||||
jr z, .collision
|
||||
jr nc, .next ; go to next sprite if distance is still positive after both adjustments
|
||||
|
||||
.collision
|
||||
ld a, l
|
||||
and $f0 ; collision with pikachu?
|
||||
jr nz, .asm_4cd9
|
||||
xor a
|
||||
ld [wd434], a
|
||||
ld a, [$ff8f]
|
||||
cp $f
|
||||
jr nz, .asm_4cd9
|
||||
call Func_4d0a
|
||||
jr .asm_4cef
|
||||
.asm_4cd9
|
||||
ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X
|
||||
ld b, a
|
||||
ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y
|
||||
inc l
|
||||
|
||||
; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100.
|
||||
; (note that normally if delta X isn't 0, then delta Y must be 0 and vice versa)
|
||||
cp b
|
||||
jr c, .next5
|
||||
ld b, %1100
|
||||
jr .next6
|
||||
.next5
|
||||
ld b, %0011
|
||||
|
||||
.next6
|
||||
ld a, c ; c has 2 bits set (one of bits 0-1 is set for the X axis and one of bits 2-3 for the Y axis)
|
||||
and b ; we select either the bit in bits 0-1 or bits 2-3 based on the calculation immediately above
|
||||
or [hl] ; or with existing collision direction bits in [$c1ic]
|
||||
ld [hl], a ; store new value
|
||||
ld a, c ; useless code because a is overwritten before being used again
|
||||
|
||||
; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with
|
||||
inc l
|
||||
inc l
|
||||
.asm_4cef
|
||||
ld a, [$ff8f] ; a = loop counter
|
||||
ld de, SpriteCollisionBitTable
|
||||
add a
|
||||
add e
|
||||
ld e, a
|
||||
jr nc, .noCarry3
|
||||
inc d
|
||||
.noCarry3
|
||||
ld a, [de]
|
||||
or [hl]
|
||||
ld [hli], a
|
||||
inc de
|
||||
ld a, [de]
|
||||
or [hl]
|
||||
ld [hl], a
|
||||
|
||||
.next
|
||||
ld a, [$ff8f] ; a = loop counter
|
||||
inc a
|
||||
cp $10
|
||||
jp nz, .loop
|
||||
ret
|
||||
|
||||
; takes delta X or delta Y in a
|
||||
; b = delta X/Y
|
||||
; c = 0 if delta X/Y is 0
|
||||
; c = 7 if delta X/Y is 1
|
||||
; c = 9 if delta X/Y is -1
|
||||
Func_4d0a: ; 4d0a (1:4d0a)
|
||||
ld a, [$ff91]
|
||||
ld b, a
|
||||
ld a, [$ff90]
|
||||
inc l
|
||||
cp b
|
||||
jr c, .asm_4d17
|
||||
ld b, %1100
|
||||
jr .asm_4d19
|
||||
.asm_4d17
|
||||
ld b, %11
|
||||
.asm_4d19
|
||||
ld a, c
|
||||
and b
|
||||
ld [wd434], a
|
||||
ld a, c
|
||||
inc l
|
||||
inc l
|
||||
ret
|
||||
|
||||
SetSpriteCollisionValues: ; 4d22 (1:4d22)
|
||||
and a
|
||||
ld b, 0
|
||||
ld c, 0
|
||||
jr z, .done
|
||||
ld c, 9
|
||||
cp -1
|
||||
jr z, .ok
|
||||
ld c, 7
|
||||
ld a, 0
|
||||
.ok
|
||||
ld b, a
|
||||
.done
|
||||
ret
|
||||
|
||||
SpriteCollisionBitTable: ; 4d35 (1:4d35)
|
||||
db %00000000,%00000001
|
||||
db %00000000,%00000010
|
||||
db %00000000,%00000100
|
||||
db %00000000,%00001000
|
||||
db %00000000,%00010000
|
||||
db %00000000,%00100000
|
||||
db %00000000,%01000000
|
||||
db %00000000,%10000000
|
||||
db %00000001,%00000000
|
||||
db %00000010,%00000000
|
||||
db %00000100,%00000000
|
||||
db %00001000,%00000000
|
||||
db %00010000,%00000000
|
||||
db %00100000,%00000000
|
||||
db %01000000,%00000000
|
||||
db %10000000,%00000000
|
||||
|
||||
dr $4d55,$4da5
|
||||
UpdatePlayerSprite: ; 4da5 (1:4da5)
|
||||
dr $4da5,$4e3e
|
||||
UpdateNPCSprite: ; 4e3e (1:4e3e)
|
||||
dr $4e3e,$5012
|
||||
Func_5012: ; 5012 (1:5012)
|
||||
dr $5012,$5ce4
|
||||
dr $5012,$5199
|
||||
DoScriptedNPCMovement: ; 5199 (1:5199)
|
||||
dr $5199,$5b67
|
||||
CableClub_TextBoxBorder: ; 5b67 (1:5b67)
|
||||
dr $5b67,$5ba6
|
||||
MainMenu: ; 5ba6 (1:5ba6)
|
||||
dr $5ba6,$5ce4
|
||||
Func_5ce4: ; 5ce4 (1:5ce4)
|
||||
dr $5ce4,$5d58
|
||||
PrintSaveScreenText: ; 5d58 (1:5d58)
|
||||
|
|
@ -622,7 +1120,7 @@ ApplyOutOfBattlePoisonDamage: ; c3de (3:43de)
|
|||
callab IsThisPartymonOurPikachu
|
||||
jr nc, .curMonNotPlayerPikachu
|
||||
ld e, $3
|
||||
callab Func_f0000
|
||||
callab PlayPikachuSoundClip
|
||||
calladb_ModifyPikachuHappiness PIKAHAPPY_PSNFNT
|
||||
.curMonNotPlayerPikachu
|
||||
pop de
|
||||
|
|
@ -2381,6 +2879,7 @@ BattleHudTiles2: INCBIN "gfx/battle_hud2.1bpp"
|
|||
BattleHudTiles3: INCBIN "gfx/battle_hud3.1bpp"
|
||||
NintendoCopyrightLogoGraphics: INCBIN "gfx/copyright.2bpp"
|
||||
GamefreakLogoGraphics: INCBIN "gfx/gamefreak.2bpp"
|
||||
GamefreakLogoGraphicsEnd:
|
||||
NineTile: INCBIN "gfx/9_tile.2bpp"
|
||||
TextBoxGraphics: INCBIN "gfx/text_box.2bpp"
|
||||
TextBoxGraphicsEnd:
|
||||
|
|
@ -2527,7 +3026,9 @@ HandleLedges: ; 1a7f4 (6:67f4)
|
|||
|
||||
SECTION "bank07",ROMX,BANK[$07]
|
||||
|
||||
dr $1c000,$1e321
|
||||
dr $1c000,$1c21e
|
||||
DoClearSaveDialogue: ; 1c21e (7:421e)
|
||||
dr $1c21e,$1e321
|
||||
SafariZoneCheck: ; 1e321 (7:6e21)
|
||||
dr $1e321,$1e330
|
||||
SafariZoneCheckSteps: ; 1e330 (7:6330)
|
||||
|
|
@ -3492,7 +3993,9 @@ MonsterNames: ; e8000 (3a:4000)
|
|||
Func_e8a5e: ; e8a5e (3a:4a5e)
|
||||
dr $e8a5e,$e8d35
|
||||
Func_e8d35:: ; e8d35 (3a:4d35)
|
||||
dr $e8d35,$e928a
|
||||
dr $e8d35,$e8e79
|
||||
Func_e8e79: ; e8e79 (3a:4e79)
|
||||
dr $e8e79,$e928a
|
||||
SurfingPikachu2Graphics: INCBIN "gfx/surfing_pikachu_2.2bpp"
|
||||
dr $e988a,$e9bfa
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user