I think my brain just melted at the concept of "fractions of bits".

Started by deepthaw, May 31 2018 5:56 PM

36 replies to this topic

Posted Tue Jun 5, 2018 8:12 AM

I think my brain just melted at the concept of "fractions of bits".

Posted Tue Jun 5, 2018 9:47 AM

I think you meant *fractional byte variables*, like nybbles and bits?

Posted Tue Jun 5, 2018 9:54 AM

This reminds me of a technique I used on the NES. [...] I'm pretty sure I've explained it before.

http://www.biglist.c...5/msg00205.html

Nice

[edit

- Sheddy, gauauu and DirtyHairy like this

Posted Tue Jun 5, 2018 11:19 AM

Most of today's programmer would have that problem with fractions of words already.I think my brain just melted at the concept of "fractions of bits".

They wouldn't understand how you can fraction bytes and have no clue how to fraction bits. I suppose that would sound like fission to them.

**Edited by Thomas Jentzsch, Tue Jun 5, 2018 11:21 AM.**

Posted Tue Jun 5, 2018 11:40 AM

If we're desperate for memory, just ask the player to remember some values for us and input them later.

That's what the Keyboard Controllers are for.

Posted Tue Jun 5, 2018 2:10 PM

For fractional bits, do you load the value, subtract the offset for the sub-variable, and then perform a modulus to extract the actual value? In other words, you would split the 256 possible values into multiple groups of various sizes, and treat each group separately. Makes it take awhile to decide values, but saves precious RAM.

**Edited by JeremiahK, Tue Jun 5, 2018 2:12 PM.**

Posted Tue Jun 5, 2018 9:33 PM

For fractional bits, do you load the value, subtract the offset for the sub-variable, and then perform a modulus to extract the actual value? In other words, you would split the 256 possible values into multiple groups of various sizes, and treat each group separately. Makes it take awhile to decide values, but saves precious RAM.

Almost. Check out the biglist link in the post above.

Essentialy - consider the string of bits as a mixed-base number. Each digit has its own base.... could be base 21, or base 3.. whatever.

So, [base4][base35][base3][base7]

That's a 4 digit mixed-base number, with each digit written in its own base. To extract the lowest significant digit we need the remainder when divided by the base of that digit. In this example, base 7. That's effectively the original binary number MOD 7. Or in another way, keep subtracting 7 from the original number until you can't anymore. What you are left with is the low digit, in this case [base7]. That's how to extract the lowest. To extract the next one up, you need to divide by the base of the lowest. Just like 102/10 --> 10 (in integer arithmetic) now puts the 2nd base-10 digit in the low position (i.e,. units), by dividing our original number by base7's base (ie: 7) we drop that base7 digit "off" the mixed-base number. We'd now be left with [base4][base35][base3] having dropped the [base7] off the end. So now we use the same method to get the base3 number - that is, MOD 3 (or repeated subtractions of 3). What's left is the value stored in that 2nd grouping from the right (i.e., [base3]). Similarly we'd do the same for the remaining [base35] digit and the [base4] digit. In summary, think of a number as being entirely in the base of the least significant digit (and we're trying to extract the least significant digit). Perform an effective MOD of the base on the whole number, leaving just the digit. Then, shift off that low-digit in the base we were dealing with by dividing by the base.

- Sheddy, ZackAttack and JeremiahK like this

Posted Tue Jun 5, 2018 10:02 PM

Aha! I remember reading that awhile back, but had forgotten it.

Did anyone else notice this in your final reply on that biglist link?

*"And yes, in answer to the quesion... I DID need to use this technique on the **C64. I distinctly remember the days when we had to use the screen space to **hold code, and change the colours so that it would not be seen on the TV. **Space was often really really really tight."*

Deja vu, no?

**Edited by JeremiahK, Tue Jun 5, 2018 10:06 PM.**

Posted Thu Jun 7, 2018 2:22 AM

If we're desperate for memory, just ask the player to remember some values for us and input them later.

The difficulty and black & white switches could be used for 3 bits of memory storage input by the player.

Posted Sat Jun 9, 2018 10:57 PM

Hahah, if you're counting switches as memory you could count the joystick direction/buttons or other controller in port 2 as even more user controlled input memory storage! :-)

The difficulty and black & white switches could be used for 3 bits of memory storage input by the player.

Posted Sun Jun 10, 2018 2:41 AM

True...both A and B ports can be reconfigured as the user wants. 8 bits in each one. The stack pointer is another byte, and T1024T can be used as temporary storage of another byte if your program is quick about it.

None of it really matters, tho...since a cartridge can just include it's own Ram memory scheme - up to 2 kb without banking. Go into coprocessor territory, and it becomes pretty much unlimited.

0 members, 0 guests, 0 anonymous users