Motion code, this should $@%@#$% work, why doesn't it?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Table is two nibbles RLDU 0000 (Delay value not used currently.) | |
| DIRECTION_TABLE: | |
| .byte $80,$80,$90,$90,$10,$10,$50,$50,$40,$40,$60,$60,$20,$20,$A0,$A0 | |
| ;; | |
| ;; Change ball directions into velocities | |
| ;; | |
| Dir2Veloc: | |
| ldx #$00 | |
| Dir2Veloc1: | |
| lda B0Direction,x | |
| and #$0F | |
| tay | |
| lda DIRECTION_TABLE,y | |
| sta B0Velocity,x | |
| Dir2VelocNext: | |
| inx | |
| cpx #$03 | |
| bne Dir2Veloc1 | |
| ;; | |
| ;; Check ball and missles for collisions and PONG if necessary. | |
| ;; | |
| ldx #$02 ; change back to 0 when working. for now, just ball. | |
| BallCol: | |
| lda CXM0FB,x ; Check collision register. | |
| bmi Coll1 ; If collided, go to coll1 | |
| lda #$00 ; otherwise, clear the collision count. | |
| sta B0CollisionCnt,x ; | |
| jmp NextBallCol ; And go to the next missile/ball to check. | |
| Coll1: lda B0CollisionCnt,x ; get collision count. | |
| cmp #$00 ; is it first collision from none? | |
| bne Coll2 ; no? go to stage 2. | |
| lda B0Direction,x ; otherwise, save the old bearing. | |
| sta B0DirectionS,x ; | |
| eor #$FF ; flip it to reverse it. | |
| sta B0Direction,x ; store it, and | |
| inc B0Direction,x ; increment it to do 2s compliment negative. | |
| lda B0Direction,x ; load bearing, and check | |
| and #$03 ; if it isn't diagonal. | |
| bne IncBallCol ; if it isn't, go to next player. | |
| inc B0Direction,x ; if it is, turn it left 45 degrees. | |
| jmp IncBallCol ; increment the collision counter, and go to next player. | |
| Coll2: cmp #$01 ; is this two collisions in a row? | |
| beq Rv180 ; yes, go to rv180 | |
| cmp #$03 ; is this three or more collisions in a row? | |
| bcc IncBallCol ; | |
| bne IncBallCol ; | |
| lda B0DirectionS,x ; 3 or more, recall saved bearing | |
| jmp Bm180 ; and go 180* opposite direction. | |
| Rv180: lda B0Direction,x ; get current bearing | |
| Bm180: clc ; | |
| adc #$08 ; add 180 degrees to it. | |
| sta B0Direction,x ; and store it in direction. | |
| IncBallCol: | |
| inc B0CollisionCnt,x ; increment the consecutive collision counter | |
| NextBallCol: | |
| inx ; increment object to scan for collision | |
| cpx #$03 ; are we done? | |
| bne BallCol ; no? loop back around. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment