Move collision attributes routines into engine/pinball_game/stage_collision_attributes.asm

This commit is contained in:
Marcus Huderle 2017-06-30 16:29:37 -07:00
parent 5bf01e71c4
commit 15e6fda643
2 changed files with 150 additions and 150 deletions

View File

@ -0,0 +1,149 @@
LoadStageCollisionAttributes: ; 0xe578
ld a, [wCurrentStage]
sla a
ld c, a
ld b, $0
ld hl, StageCollisionAttributesPointers
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hli]
and a
jr z, .asm_e598
ld a, [wStageCollisionState]
sla a
ld c, a
sla a
add c
ld c, a
ld b, $0 ; bc = 6 * [wStageCollisionState]
add hl, bc
.asm_e598
ld de, wStageCollisionMapPointer
ld b, $6
.asm_e59d
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .asm_e59d
call LoadCollisionAttributes
ret
StageCollisionAttributesPointers: ; 0xe5a7
dw StageRedFieldTopCollisionAttributesPointers
dw StageRedFieldBottomCollisionAttributesPointers
dw StageUnusedCollisionAttributesPointers
dw StageUnused2CollisionAttributesPointers
dw StageBlueFieldTopCollisionAttributesPointers
dw StageBlueFieldBottomCollisionAttributesPointers
dw StageGengarBonusCollisionAttributesPointers
dw StageGengarBonusCollisionAttributesPointers
dw StageMewtwoBonusCollisionAttributesPointers
dw StageMewtwoBonusCollisionAttributesPointers
dw StageMeowthBonusCollisionAttributesPointers
dw StageMeowthBonusCollisionAttributesPointers
dw StageDiglettBonusCollisionAttributesPointers
dw StageDiglettBonusCollisionAttributesPointers
dw StageSeelBonusCollisionAttributesPointers
dw StageSeelBonusCollisionAttributesPointers
StageRedFieldTopCollisionAttributesPointers: ; 0xe5c7
db $01 ; multiple pair entries
dwb StageRedFieldTopCollisionAttributes0, Bank(StageRedFieldTopCollisionAttributes0)
dwb StageRedFieldTopCollisionMasks0, Bank(StageRedFieldTopCollisionMasks0)
dwb StageRedFieldTopCollisionAttributes1, Bank(StageRedFieldTopCollisionAttributes1)
dwb StageRedFieldTopCollisionMasks0, Bank(StageRedFieldTopCollisionMasks0)
dwb StageRedFieldTopCollisionAttributes2, Bank(StageRedFieldTopCollisionAttributes2)
dwb StageRedFieldTopCollisionMasks1, Bank(StageRedFieldTopCollisionMasks1)
dwb StageRedFieldTopCollisionAttributes3, Bank(StageRedFieldTopCollisionAttributes3)
dwb StageRedFieldTopCollisionMasks1, Bank(StageRedFieldTopCollisionMasks1)
dwb StageRedFieldTopCollisionAttributes4, Bank(StageRedFieldTopCollisionAttributes4)
dwb StageRedFieldTopCollisionMasks2, Bank(StageRedFieldTopCollisionMasks2)
dwb StageRedFieldTopCollisionAttributes5, Bank(StageRedFieldTopCollisionAttributes5)
dwb StageRedFieldTopCollisionMasks2, Bank(StageRedFieldTopCollisionMasks2)
dwb StageRedFieldTopCollisionAttributes6, Bank(StageRedFieldTopCollisionAttributes6)
dwb StageRedFieldTopCollisionMasks3, Bank(StageRedFieldTopCollisionMasks3)
dwb StageRedFieldTopCollisionAttributes7, Bank(StageRedFieldTopCollisionAttributes7)
dwb StageRedFieldTopCollisionMasks3, Bank(StageRedFieldTopCollisionMasks3)
StageRedFieldBottomCollisionAttributesPointers: ; 0xe5f8
db $00 ; single pair entry
dwb StageRedFieldBottomCollisionAttributes, Bank(StageRedFieldBottomCollisionAttributes)
dwb StageRedFieldBottomCollisionMasks, Bank(StageRedFieldBottomCollisionMasks)
StageUnusedCollisionAttributesPointers: ; 0xe5ff
; This entry is never used
db $00
StageUnused2CollisionAttributesPointers: ; 0xe600
; This entry is never used
db $00
StageBlueFieldTopCollisionAttributesPointers: ; 0xe601
db $01 ; multiple pair entries
dwb StageBlueFieldTopCollisionAttributesBallEntrance, Bank(StageBlueFieldTopCollisionAttributesBallEntrance)
dwb StageBlueFieldTopCollisionMasks, Bank(StageBlueFieldTopCollisionMasks)
dwb StageBlueFieldTopCollisionAttributes, Bank(StageBlueFieldTopCollisionAttributes)
dwb StageBlueFieldTopCollisionMasks, Bank(StageBlueFieldTopCollisionMasks)
StageBlueFieldBottomCollisionAttributesPointers: ; 0xe60e
db $00 ; single pair entry
dwb StageBlueFieldBottomCollisionAttributes, Bank(StageBlueFieldBottomCollisionAttributes)
dwb StageBlueFieldBottomCollisionMasks, Bank(StageBlueFieldBottomCollisionMasks)
StageGengarBonusCollisionAttributesPointers: ; 0xe615
db $01 ; multiple pair entries
dwb StageGengarBonusCollisionAttributesBallEntrance, Bank(StageGengarBonusCollisionAttributesBallEntrance)
dwb StageGengarBonusCollisionMasks, Bank(StageGengarBonusCollisionMasks)
dwb StageGengarBonusCollisionAttributes, Bank(StageGengarBonusCollisionAttributes)
dwb StageGengarBonusCollisionMasks, Bank(StageGengarBonusCollisionMasks)
StageMewtwoBonusCollisionAttributesPointers: ; 0xe622
db $01 ; multiple pair entries
dwb StageMewtwoBonusCollisionAttributesBallEntrance, Bank(StageMewtwoBonusCollisionAttributesBallEntrance)
dwb StageMewtwoBonusCollisionMasks, Bank(StageMewtwoBonusCollisionMasks)
dwb StageMewtwoBonusCollisionAttributes, Bank(StageMewtwoBonusCollisionAttributes)
dwb StageMewtwoBonusCollisionMasks, Bank(StageMewtwoBonusCollisionMasks)
StageMeowthBonusCollisionAttributesPointers: ; 0xe62f
db $01 ; multiple pair entries
dwb StageMeowthBonusCollisionAttributesBallEntrance, Bank(StageMeowthBonusCollisionAttributesBallEntrance)
dwb StageMeowthBonusCollisionMasks, Bank(StageMeowthBonusCollisionMasks)
dwb StageMeowthBonusCollisionAttributes, Bank(StageMeowthBonusCollisionAttributes)
dwb StageMeowthBonusCollisionMasks, Bank(StageMeowthBonusCollisionMasks)
StageDiglettBonusCollisionAttributesPointers: ; 0xe63c
db $01 ; multiple pair entries
dwb StageDiglettBonusCollisionAttributesBallEntrance, Bank(StageDiglettBonusCollisionAttributesBallEntrance)
dwb StageDiglettBonusCollisionMasks, Bank(StageDiglettBonusCollisionMasks)
dwb StageDiglettBonusCollisionAttributes, Bank(StageDiglettBonusCollisionAttributes)
dwb StageDiglettBonusCollisionMasks, Bank(StageDiglettBonusCollisionMasks)
StageSeelBonusCollisionAttributesPointers: ; 0xe649
db $01 ; multiple pair entries
dwb StageSeelBonusCollisionAttributesBallEntrance, Bank(StageSeelBonusCollisionAttributesBallEntrance)
dwb StageSeelBonusCollisionMasks, Bank(StageSeelBonusCollisionMasks)
dwb StageSeelBonusCollisionAttributes, Bank(StageSeelBonusCollisionAttributes)
dwb StageSeelBonusCollisionMasks, Bank(StageSeelBonusCollisionMasks)
LoadCollisionAttributes: ; 0xe656
; Loads the stage's collision attributes into RAM
; Input: [wStageCollisionMapPointer] = pointer to collision attributes map
; [wStageCollisionMapBank] = ROM bank of collision attributes map
ld hl, wStageCollisionMapPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wStageCollisionMapBank]
ld de, wStageCollisionMap
ld bc, $0300
call FarCopyData
ld hl, wStageCollisionMapPointer
ld [hl], (wStageCollisionMap & $ff)
inc hl
ld [hl], (wStageCollisionMap >> 8)
inc hl
ld [hl], $0 ; Bank 0, because the data is in WRAM, so it doesn't matter which bank is saved
ret

151
main.asm
View File

@ -1897,156 +1897,7 @@ INCLUDE "engine/pinball_game/ball_loss/ball_loss_meowth_bonus.asm"
INCLUDE "engine/pinball_game/ball_loss/ball_loss_diglett_bonus.asm"
INCLUDE "engine/pinball_game/ball_loss/ball_loss_seel_bonus.asm"
INCLUDE "engine/pinball_game/flippers.asm"
LoadStageCollisionAttributes: ; 0xe578
ld a, [wCurrentStage]
sla a
ld c, a
ld b, $0
ld hl, StageCollisionAttributesPointers
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hli]
and a
jr z, .asm_e598
ld a, [wStageCollisionState]
sla a
ld c, a
sla a
add c
ld c, a
ld b, $0 ; bc = 6 * [wStageCollisionState]
add hl, bc
.asm_e598
ld de, wStageCollisionMapPointer
ld b, $6
.asm_e59d
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .asm_e59d
call LoadCollisionAttributes
ret
StageCollisionAttributesPointers: ; 0xe5a7
dw StageRedFieldTopCollisionAttributesPointers
dw StageRedFieldBottomCollisionAttributesPointers
dw StageUnusedCollisionAttributesPointers
dw StageUnused2CollisionAttributesPointers
dw StageBlueFieldTopCollisionAttributesPointers
dw StageBlueFieldBottomCollisionAttributesPointers
dw StageGengarBonusCollisionAttributesPointers
dw StageGengarBonusCollisionAttributesPointers
dw StageMewtwoBonusCollisionAttributesPointers
dw StageMewtwoBonusCollisionAttributesPointers
dw StageMeowthBonusCollisionAttributesPointers
dw StageMeowthBonusCollisionAttributesPointers
dw StageDiglettBonusCollisionAttributesPointers
dw StageDiglettBonusCollisionAttributesPointers
dw StageSeelBonusCollisionAttributesPointers
dw StageSeelBonusCollisionAttributesPointers
StageRedFieldTopCollisionAttributesPointers: ; 0xe5c7
db $01 ; multiple pair entries
dwb StageRedFieldTopCollisionAttributes0, Bank(StageRedFieldTopCollisionAttributes0)
dwb StageRedFieldTopCollisionMasks0, Bank(StageRedFieldTopCollisionMasks0)
dwb StageRedFieldTopCollisionAttributes1, Bank(StageRedFieldTopCollisionAttributes1)
dwb StageRedFieldTopCollisionMasks0, Bank(StageRedFieldTopCollisionMasks0)
dwb StageRedFieldTopCollisionAttributes2, Bank(StageRedFieldTopCollisionAttributes2)
dwb StageRedFieldTopCollisionMasks1, Bank(StageRedFieldTopCollisionMasks1)
dwb StageRedFieldTopCollisionAttributes3, Bank(StageRedFieldTopCollisionAttributes3)
dwb StageRedFieldTopCollisionMasks1, Bank(StageRedFieldTopCollisionMasks1)
dwb StageRedFieldTopCollisionAttributes4, Bank(StageRedFieldTopCollisionAttributes4)
dwb StageRedFieldTopCollisionMasks2, Bank(StageRedFieldTopCollisionMasks2)
dwb StageRedFieldTopCollisionAttributes5, Bank(StageRedFieldTopCollisionAttributes5)
dwb StageRedFieldTopCollisionMasks2, Bank(StageRedFieldTopCollisionMasks2)
dwb StageRedFieldTopCollisionAttributes6, Bank(StageRedFieldTopCollisionAttributes6)
dwb StageRedFieldTopCollisionMasks3, Bank(StageRedFieldTopCollisionMasks3)
dwb StageRedFieldTopCollisionAttributes7, Bank(StageRedFieldTopCollisionAttributes7)
dwb StageRedFieldTopCollisionMasks3, Bank(StageRedFieldTopCollisionMasks3)
StageRedFieldBottomCollisionAttributesPointers: ; 0xe5f8
db $00 ; single pair entry
dwb StageRedFieldBottomCollisionAttributes, Bank(StageRedFieldBottomCollisionAttributes)
dwb StageRedFieldBottomCollisionMasks, Bank(StageRedFieldBottomCollisionMasks)
StageUnusedCollisionAttributesPointers: ; 0xe5ff
; This entry is never used
db $00
StageUnused2CollisionAttributesPointers: ; 0xe600
; This entry is never used
db $00
StageBlueFieldTopCollisionAttributesPointers: ; 0xe601
db $01 ; multiple pair entries
dwb StageBlueFieldTopCollisionAttributesBallEntrance, Bank(StageBlueFieldTopCollisionAttributesBallEntrance)
dwb StageBlueFieldTopCollisionMasks, Bank(StageBlueFieldTopCollisionMasks)
dwb StageBlueFieldTopCollisionAttributes, Bank(StageBlueFieldTopCollisionAttributes)
dwb StageBlueFieldTopCollisionMasks, Bank(StageBlueFieldTopCollisionMasks)
StageBlueFieldBottomCollisionAttributesPointers: ; 0xe60e
db $00 ; single pair entry
dwb StageBlueFieldBottomCollisionAttributes, Bank(StageBlueFieldBottomCollisionAttributes)
dwb StageBlueFieldBottomCollisionMasks, Bank(StageBlueFieldBottomCollisionMasks)
StageGengarBonusCollisionAttributesPointers: ; 0xe615
db $01 ; multiple pair entries
dwb StageGengarBonusCollisionAttributesBallEntrance, Bank(StageGengarBonusCollisionAttributesBallEntrance)
dwb StageGengarBonusCollisionMasks, Bank(StageGengarBonusCollisionMasks)
dwb StageGengarBonusCollisionAttributes, Bank(StageGengarBonusCollisionAttributes)
dwb StageGengarBonusCollisionMasks, Bank(StageGengarBonusCollisionMasks)
StageMewtwoBonusCollisionAttributesPointers: ; 0xe622
db $01 ; multiple pair entries
dwb StageMewtwoBonusCollisionAttributesBallEntrance, Bank(StageMewtwoBonusCollisionAttributesBallEntrance)
dwb StageMewtwoBonusCollisionMasks, Bank(StageMewtwoBonusCollisionMasks)
dwb StageMewtwoBonusCollisionAttributes, Bank(StageMewtwoBonusCollisionAttributes)
dwb StageMewtwoBonusCollisionMasks, Bank(StageMewtwoBonusCollisionMasks)
StageMeowthBonusCollisionAttributesPointers: ; 0xe62f
db $01 ; multiple pair entries
dwb StageMeowthBonusCollisionAttributesBallEntrance, Bank(StageMeowthBonusCollisionAttributesBallEntrance)
dwb StageMeowthBonusCollisionMasks, Bank(StageMeowthBonusCollisionMasks)
dwb StageMeowthBonusCollisionAttributes, Bank(StageMeowthBonusCollisionAttributes)
dwb StageMeowthBonusCollisionMasks, Bank(StageMeowthBonusCollisionMasks)
StageDiglettBonusCollisionAttributesPointers: ; 0xe63c
db $01 ; multiple pair entries
dwb StageDiglettBonusCollisionAttributesBallEntrance, Bank(StageDiglettBonusCollisionAttributesBallEntrance)
dwb StageDiglettBonusCollisionMasks, Bank(StageDiglettBonusCollisionMasks)
dwb StageDiglettBonusCollisionAttributes, Bank(StageDiglettBonusCollisionAttributes)
dwb StageDiglettBonusCollisionMasks, Bank(StageDiglettBonusCollisionMasks)
StageSeelBonusCollisionAttributesPointers: ; 0xe649
db $01 ; multiple pair entries
dwb StageSeelBonusCollisionAttributesBallEntrance, Bank(StageSeelBonusCollisionAttributesBallEntrance)
dwb StageSeelBonusCollisionMasks, Bank(StageSeelBonusCollisionMasks)
dwb StageSeelBonusCollisionAttributes, Bank(StageSeelBonusCollisionAttributes)
dwb StageSeelBonusCollisionMasks, Bank(StageSeelBonusCollisionMasks)
LoadCollisionAttributes: ; 0xe656
; Loads the stage's collision attributes into RAM
; Input: [wStageCollisionMapPointer] = pointer to collision attributes map
; [wStageCollisionMapBank] = ROM bank of collision attributes map
ld hl, wStageCollisionMapPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wStageCollisionMapBank]
ld de, wStageCollisionMap
ld bc, $0300
call FarCopyData
ld hl, wStageCollisionMapPointer
ld [hl], (wStageCollisionMap & $ff)
inc hl
ld [hl], (wStageCollisionMap >> 8)
inc hl
ld [hl], $0 ; Bank 0, because the data is in WRAM, so it doesn't matter which bank is saved
ret
INCLUDE "engine/pinball_game/stage_collision_attributes.asm"
FieldVerticalTransition: ; 0xe674
push af