Jump to content
IGNORED

Selecting a bit?


Trip2018

Recommended Posts

So I was wondering if there is a simple way to read and select a bit with a variable.

 

Like a possible implementation of a{6} = b{x}

 

I know course it throws an error for that specifically, but are there any alternatives? I'm trying to setup a 4 way platformer map where the bits are read across the x axis.

Link to comment
Share on other sites

here's one way

setbyte is the kernel table for selecting bits (for eg setting playfield pixels)

 

the exact form of setbyte depends on the kernel but you could do your own table if neccesary

  if setbyte[x] & b then a{6} = 1 else a{6} = 0

 

Edited by bogax
Link to comment
Share on other sites

6 hours ago, Trip2018 said:

Oh, that was a lot simpler than I was anticipating! Does the setbyte table loop once the variable is over 7 or would I need to reset the variable before I read? Very much appreciated, thanks!

the setbyte table is for a row of playfield pixels

some bytes in the playfield are reversed but which ones depends on kernel/kernel options

you'd have to limit x

Link to comment
Share on other sites

2 hours ago, KevKelley said:

So could something like this also be used to count the bits turned on or off on the screen instead of selecting, like 


  if setbyte[x] & b then c=c+1

yes you could do that if eg you're going to access bits randomly

if you're doing a byte at a time a table would be better

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...