How To

How to edit a single bit in memory

3

412lop 2023-08-07 19:43

How do you edit a single bit in memory?


nathanielbabiak 2023-08-07 21:43 (Edited)

https://en.m.wikipedia.org/wiki/Bit_manipulation

Read that, and any linked articles that look interesting, and then check out this fantasy console's manual for the implementation here. (...I'm sure others will be along shortly with specific examples...)


was8bit 2023-08-08 07:57

Check this out :)

https://lowresnx.inutilis.com/topic.php?id=3080


was8bit 2023-08-12 17:11 (Edited)

There is probably a way to do the edit directly with just math, but it would have to be precisely done... my approach breaks the math down into steps, making it easier for me to see what I am doing in each step

the memory is only accessible as an 8x8 batch of data bits, so you will need to isolate the one bit out of the 64 bits, and edit only that one bit without effecting the remaining 63 bits....

My approach reads the whole batch of 64 bits into an array, edit the array, then rewrite the array as a whole 64 bit batch


was8bit 2023-08-12 17:16 (Edited)

It is possible to use the graphic data as just data, allowing you to manually edit the data using the graphic designer...

For axample, each dot could represent a different item, like a block, a piece of gold, etc.. and you could use your finger in the graphic edit to edit a block of graphics to arrange a layout for a game level... I did this approach for one of my games... it limits you though to just 3 things in your layout ...


SP4CEBAR 2023-08-14 09:25 (Edited)

Call this function where $A000 is the address ($0000 to $FFFF), and 7 is the bit (0 to 7):

CALL SET_BIT( $A000, 7 )

And add this to your code:

SUB SET_BIT( ADDRESS, BIT )
  POKE ADDRESS, PEEK(ADDRESS) AND 2^BIT
END SUB


Log in to reply.