+Karl G Posted February 15, 2021 Share Posted February 15, 2021 Does anyone have any good sample code for software playfield collision detection? I'm still trying to debug mine, and I'm wondering if there's a better way than what I am doing. Here's what I have so far to convert object screen coordinates for a 2-line kernel to a 40 wide by 22 tall playfield (symmetric, mirrored): ; X Value in A, Y value in Y. Zero set if no playfield block. PFWall sty Temp2 lsr lsr cmp #20 bcc ____skip_adjust_x_pixel sta Temp1 lda #39 sec sbc Temp1 ____skip_adjust_x_pixel sta Temp1 cmp #4 bcs ____skip_pf0 ldy #0 jmp ____done_pfx ____skip_pf0 cmp #12 bcs ____skip_pf1 ldy #2 jmp ____done_pfx ____skip_pf1 ldy #4 ____done_pfx lda PF0Ptr,y sta TempPtr lda PF0Ptr+1,y sta TempPtr+1 lda Temp2 lsr lsr tay lda (TempPtr),y ldy Temp1 and pfpixel_mask,y rts ; End PFWall pfpixel_mask .byte bit4, bit5, bit6, bit7 .byte bit7, bit6, bit5, bit4, bit3, bit2, bit1, bit0 .byte bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7 DataPF0: .byte $F0,$10,$10,$90,$90,$90,$90,$00 .byte $00,$90,$10,$10,$90,$00,$00,$90 .byte $10,$10,$F0,$10,$10,$F0 DataPF1: .byte $E7,$00,$00,$E4,$04,$04,$E4,$07 .byte $04,$E4,$00,$00,$FC,$04,$04,$FC .byte $04,$04,$E4,$00,$00,$E7 DataPF2: .byte $FF,$09,$09,$C1,$41,$08,$08,$7F .byte $00,$00,$4F,$48,$C8,$09,$09,$49 .byte $01,$01,$4F,$00,$00,$FF Any samples or tips would be appreciated! Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted February 15, 2021 Share Posted February 15, 2021 Looks about right to me. You could swap out some of the branch logic and have a lookup table for which PF byte to use (y value used in the LDA PF0Ptr,y instructions). That would save cycle time and take about the same amount of space. 1 Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted February 16, 2021 Share Posted February 16, 2021 I took a stab at it. Might not be exactly what you are looking for but could give you some ideas. SoftwarePfCollision.zip 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted February 16, 2021 Author Share Posted February 16, 2021 5 hours ago, Omegamatrix said: I took a stab at it. Might not be exactly what you are looking for but could give you some ideas. SoftwarePfCollision.zip 8.28 kB · 4 downloads Thank you! This is indeed useful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.