Jump to content
IGNORED

pfread for the multisprite kernel


bogax

Recommended Posts

pfread for the multisprite kernel

as bB functions

 

The first (mostly) in bB

The second in asm

 

Both take column and row as

parameters and return 0 or 255

 

0, 0 is bottom left

 

Both use temp1 and temp2 but

no other variables.

 

function msk_pf_rd()
temp1 = temp1 + $08
if temp1{4} then skip_PF1_and 

asm
lda (PF1pointer),y
sta temp2
end
goto skip_PF2_and

skip_PF1_and
asm
lda (PF2pointer),y
sta temp2
end

skip_PF2_and
temp1 = temp1 & $0F
if bit_masks[temp1] & temp2 then temp2 = $FF
return

data bit_masks
1,2,4,8,$10,$20,$40,$80
$80,$40,$20,$10,8,4,2,1
end

 

 

 

function msk_pf_rd()
asm
clc
adc #$08
and #$1F
cmp #$10
and #$0F
tax
lda bit_masks,x
bcc skip_PF2_and
and (PF2pointer),y
bcs skip_PF1_and
skip_PF2_and
and (PF1pointer),y
skip_PF1_and
beq skip_ldFF
lda #$FF
skip_ldFF
end

return

data bit_masks
1,2,4,8,$10,$20,$40,$80
$80,$40,$20,$10,8,4,2,1
end

  • Like 2
Link to comment
Share on other sites

One more

 

Here it is purely as asm

 

This can be put in an include file

or put in the bB program as asm

(not as a function)

 

Then it can be used directly in an

if statement (or used in an assignment)

 

One odd thing, the sense of the

if statement is backwards.

(whats up with that?

 

So you'd need to use it like this

 

if pfread (column, row) then goto pfpixel_off else goto pfpixel_on

 

 

pfread
clc
adc #$08
and #$1F
cmp #$10
and #$0F
tax
lda bit_masks,x
bcc skip_PF2_and
and (PF2pointer),y
bcs skip_PF1_and
skip_PF2_and
and (PF1pointer),y
skip_PF1_and
beq skip_ldFF
lda #$FF
skip_ldFF
return

bit_masks
.byte $01, $02, $04, $08, $10, $20, $40, $80
.byte $80, $40, $20, $10, $08, $04, $02, $01

Edited by bogax
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...