I'm working on an Arkanoid clone for NES all in ASM 6052 just for fun, currently, in my game, the ball collide fine with the walls, with the paddle player and I'm really happy for this. But, when I try to compute the collision with the bricks, somethings goes wrong.
Code: Select all
;=====================================
; Ball Collision Detection With Bricks
;=====================================
CheckCollisionOnAllBricks:
LDX #$00
CheckCollisionOnAllBricksLoop:
LDA brick_sprites, x
;Y MIN
CMP BALL_POS_Y
BCS PerformBallNotHitBrick
;Y MAX
CLC
ADC #$08
CMP BALL_POS_Y
BCC PerformBallNotHitBrick
;X MIN
INX
INX
INX
LDA brick_sprites, x
DEX
DEX
DEX
CMP BALL_POS_X
BCS PerformBallNotHitBrick
;X MAX
CLC
ADC #$18
CMP BALL_POS_X
BCC PerformBallNotHitBrick
; Collisione
PerformBallCollisionWithBrick:
LDA #$01
STA $0212
JMP CCCOABContinueLoop
PerformBallNotHitBrick:
LDA #$00
STA $0212
JMP CCCOABContinueLoop
CCCOABContinueLoop:
INX
INX
INX
INX
INX
INX
INX
INX
INX
INX
INX
INX
CPX #$18
BNE CheckCollisionOnAllBricksLoop
Code: Select all
brick_sprites:
;yPos tile attr xPos
.db $3A, $04, $0A, $70 ;sprite 0
.db $3A, $05, $0A, $78 ;sprite 1
.db $3A, $06, $0A, $7F ;sprite 2
.db $22, $04, $0A, $87 ;sprite 0
.db $22, $05, $0A, $8F ;sprite 1
.db $22, $06, $0A, $97 ;sprite 2
The strange things is that if I use only one brick and finish the check by CPX #$0C, everythings works great, BUT if i put two bricks as in the example code and i finish the cicle by compater CPX #$18 for some reason it get just the second brick, the first brick is ignored. I really can't understand where I'm wrong. Anyone can help me?
Thanks a lot and sorry for my English!