Trip2018 Posted May 16, 2022 Share Posted May 16, 2022 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. Quote Link to comment Share on other sites More sharing options...
bogax Posted May 17, 2022 Share Posted May 17, 2022 (edited) 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 May 17, 2022 by bogax Quote Link to comment Share on other sites More sharing options...
Trip2018 Posted May 17, 2022 Author Share Posted May 17, 2022 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! Quote Link to comment Share on other sites More sharing options...
KevKelley Posted May 17, 2022 Share Posted May 17, 2022 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 Quote Link to comment Share on other sites More sharing options...
ZippyRedPlumber Posted May 17, 2022 Share Posted May 17, 2022 Bit variables can be activated by putting a 1 ex. _Bit1{1} = 1. Deactivating them is simple, change the 1 into a 0 ex. _Bit1{1} = 0 See also: https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 17, 2022 Share Posted May 17, 2022 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 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 17, 2022 Share Posted May 17, 2022 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 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.