Jump to content
IGNORED

New untitled game


atari2600land

Recommended Posts

Here's a little game I'm working on, and I need a little help.

Say I want to have an even number out of a random one. So, I'd go a=rand/8 (I want the number to be less than 32.) Say the number it picks is 15.

Then, I go a=a/2. The remainder would be 1/2. My question is, where does that 1/2 go? If it does go to temp1, then why doesn't this work?

if temp1>0 then a=a+1

Any other suggestions, ideas, or comments welcome (and yes, that little sprite is supposed to be an alligator. If anyone wants to design a sprite, for this game it *must* be 8 pixels long.)

zzyzzyx.bas

zzyzzyx.bas.bin

Edited by atari2600land
Link to comment
Share on other sites

The remainder would be 1/2. My question is, where does that 1/2 go?

 

Hello Atari2600land,

 

 

I believe BB would use a logical shift right (otherwise called LSR) to divide by 2. When you do a right shift the far right bit gets pushed into the carry. I believe in this case the carry would probably be disregarded after the shift, but I don't know what BB is doing. This is how I think it would sort of go:

 

1 / 2 = 0

2 / 2 = 1

3 / 2 = 1

4 / 2 = 2

5 / 2 = 2

6 / 2 = 3

 

 

Hope that helps.

Edited by Omegamatrix
Link to comment
Share on other sites

Bitwise AND the result with $FE (8 bits) or $FFFE (16 bits) as appropriate to make a number even.

What does that mean? :?

That is a way to make numbers even using a simple assembly instruction. A byte is made of 8 bits, and each bit can be one or zero. That is simple enough, no?

 

 

If the farthest right bit is a one, then the number is odd. To make it an even number we want to make that far right bit a zero.

 

11111111 < all the bits including the far right bit are 1's, this is an odd number as the far right bit is a "1"

 

11111110 < here the far right bit is a zero, so this number is even.

 

 

 

 

So if the goal is to make an odd number even all we got to do is change the one far right bit. An "AND" instruction can do that. AND can keep a bit as it is, or clear it.

Link to comment
Share on other sites

I changed the theme of the game from an alligator to a mouse. The title screen says "Cheesed Off!" but I might change the name to "Atomic Cheese." Anyway, I have no knowledge of assembly. What i need is a way to figure out how to find out if a number is odd and change it if it is, in bB language. I understand what Omegamatrix is trying to say about binary numbers, but I don't understand how to go about doing that in bB.

zzyzzyx.bas.bin

zzyzzyx.bas

post-9475-1235451382.png

Link to comment
Share on other sites

I'm glad that it worked. I see that you are using a && instead of & in this case. These are quite different things in C, but I'm not sure about BB.

 

 

In C the "&&" means if both expressions are true, return a one. The Bitwise operator is just a single "&" in C. Maybe just double check that "&&". It seems to me it should just be a single "&" in this case...

Link to comment
Share on other sites

I'm glad that it worked. I see that you are using a && instead of & in this case. These are quite different things in C, but I'm not sure about BB.

 

 

In C the "&&" means if both expressions are true, return a one. The Bitwise operator is just a single "&" in C. Maybe just double check that "&&". It seems to me it should just be a single "&" in this case...

In bB, && is used in if-then statements:

 

http://www.randomterrain.com/atari-2600-me...ds.html#boolean

 

http://www.randomterrain.com/atari-2600-me...mands.html#math

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