Jump to content
IGNORED

Superchip Playfield Variables


KevKelley

Recommended Posts

I know in the regular standard kernel I can play around with playfield Variables to turn things on or off by using their variables like var30=%11010001 and then use some bitwise operations to turn them on or off. 

 

I was looking to do something similar with Superchip playfield but was a little confused on how I'd do it. Would I check them the same but use Superchip variables like w/r087, etc.?

Link to comment
Share on other sites

25 minutes ago, Karl G said:

Yeah, that's how it would work. You can use the read variables to get playfield information, and the write variables to change the playfield on the fly. 

Thanks. I assumed but when I was looking at it this morning I couldn't figure it out. Hopefully I can get whatever I am looking to get done to work.

Link to comment
Share on other sites

1 hour ago, Karl G said:

Yeah, that's how it would work. You can use the read variables to get playfield information, and the write variables to change the playfield on the fly. 

Would you happen to know if there is a relatively simple way to compare how many bits are different between a variable?

 

For example, if a playfield variable is checked, if bits are off then they are flipped on, and then count how many bits are flipped?

Link to comment
Share on other sites

Here's a way to do it assuming that I'm understanding you correctly. Let's say the new value was $FF because you are turning all 8 pixels on, and let's say that the playfield block in question is 100.

 

    temp1 = r100^$FF. ; Exclusive or will set only the bits that differ to 1, and the rest are 0
    w100 = $FF ; Actually change the variable after checking what bits differ
; Next we count the number of bits that are set to 1 in temp1, which will be the number of bits that were changed
; temp2 will be equal to the number of bits changed.
    temp2 = 0
BitCountLoop
    if temp1{0} then temp2 = temp2 + 1 ; check rightmost bit for a 1, and increment temp2 if so
    temp1 = temp1 / 2 ; shift all bytes to the right by 1
    if temp1 then goto BitCountLoop ; Repeat again if any remaining bits are still 1

 

  • Like 1
Link to comment
Share on other sites

21 minutes ago, Karl G said:

Here's a way to do it assuming that I'm understanding you correctly. Let's say the new value was $FF because you are turning all 8 pixels on, and let's say that the playfield block in question is 100.

 


    temp1 = r100^$FF. ; Exclusive or will set only the bits that differ to 1, and the rest are 0
    w100 = $FF ; Actually change the variable after checking what bits differ
; Next we count the number of bits that are set to 1 in temp1, which will be the number of bits that were changed
; temp2 will be equal to the number of bits changed.
    temp2 = 0
BitCountLoop
    if temp1{0} then temp2 = temp2 + 1 ; check rightmost bit for a 1, and increment temp2 if so
    temp1 = temp1 / 2 ; shift all bytes to the right by 1
    if temp1 then goto BitCountLoop ; Repeat again if any remaining bits are still 1

 

I think this was kind of what I was going for. 

 

I will have to post what I went with when I get home and test to see if it works. 

 

Thanks!

 

Link to comment
Share on other sites

So originally I was trying to kind of systematically go through each playfield variable, flip any bit that is off turning them on, and then turn off the same amount of bits but I was trying to make the bits that turn off either to the left or the right of the ones turned on.

 

I think I was approaching my goal the wrong way (although I was interested in applicability of doing things like counting bits or comparing bits but this is the solution I came up with that pretty much achieved the desired effects and was much simpler:

 

 r=rand16&63
WINDLITTER
 if r>50 || player1y<40 then goto SKIP_WINDLITTER ; determines the frequency of when the playfield pixel is checked 
 if var1>24 then var1=9 ; determines the row
 if var2>20 then var2=9 ; determines the column
 var3=var1+1: if var3>24 then var3=9 ; determines relocated pixel location
 if pfread(var1,var2) then goto SKIP_GRASSCHECK ; if the playfield is on then skip the repositioning 
 pfpixel var1 var2 on: w004=r004-1:var4=1 ; turns on the playfield, w004 keeps track of pixels turned off or on
 if var4=1 &&  pfread(var3,var2) then pfpixel var3 var2 off:w004=r004+1:var4=0:var2=var2+1:var1=var1+1 ; turns off the pixel in new location
 goto SKIP_WINDLITTER
SKIP_GRASSCHECK
 var1=var1+1:var2=var2+1 ; changes next playfield pixel location to check
SKIP_WINDLITTER

 

So far from testing it seems to work how I intended.

Edited by KevKelley
  • Like 1
Link to comment
Share on other sites

Cool that you found a simpler solution for what you were trying to do, but I have a small nitpick for your code:

 

29 minutes ago, KevKelley said:

 r=rand16&63

That's not how rand16 is supposed to be used. You dim rand16 to one of your variables to improve the randomization routine by allowing it to use 16 bits. You still use rand for setting variables, however.

 

30 minutes ago, KevKelley said:

 r=rand&63

 

Link to comment
Share on other sites

8 minutes ago, Karl G said:

Cool that you found a simpler solution for what you were trying to do, but I have a small nitpick for your code:

 

That's not how rand16 is supposed to be used. You dim rand16 to one of your variables to improve the randomization routine by allowing it to use 16 bits. You still use rand for setting variables, however.

 

 

Oh! I didn't know that. I had thought it replaced rand. 

 

 

Link to comment
Share on other sites

On 5/9/2022 at 12:05 PM, KevKelley said:

Oh! I didn't know that. I had thought it replaced rand. 

 

I just updated the bB page to be more clear:

 

https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#rand_rand16

Quote

Do not use “rand16” in your code; use rand as you normally would. The only place “rand16” is used is when you set it up with “dim rand16 = <var>”.

 

  • Like 1
  • Thanks 1
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...