Jump to content
IGNORED

Software maze wall detection


Karl G

Recommended Posts

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...