News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ervin

"dirty" flag using bitstreaming

Started by ervin, 08:17, 27 August 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ervin

Hi all.

I have a requirement that is very similar (though not the same conceptually) to a "dirty" flag being used to determine whether or not part of the screen should be updated.

I've got a 64-byte table, representing a row of bytes on a 64-byte wide screen.
I need to check for 0 or 1 in each of those bytes to determine whether something needs doing or not.

Naturally this lends itself well to using 8 bytes, and checking each of the 8 bits in each of the 8 bytes. But I need to check them sequentially.

Does anyone have a technique they would recommend for doing such a thing?

Thanks.

arnoldemu

First check if the byte is not 0. This indicates at least 1 bit has changed.

Then either shift each bit out into carry and do the result each time. Or potentially you could do some kind of AND to narrow it down furthur (e.g. nibbles) then drop to a look up table of each of the 16 possible combinations.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

ervin

Tremendous suggestion, thanks Kev!

ralferoo

Quote from: arnoldemu on 08:53, 27 August 13
First check if the byte is not 0. This indicates at least 1 bit has changed.
This is a really good idea.
Quote
Then either shift each bit out into carry and do the result each time. Or potentially you could do some kind of AND to narrow it down furthur (e.g. nibbles) then drop to a look up table of each of the 16 possible combinations.
Getting the high nibble is quite slow using shifts, it's far quicker (but wasteful of RAM) to use a lookup table instead. Or you could try RLD which might be quickest for some use cases.

TFM

Forget it, that's too much effort! You will loose too much time calculation which byte is "dirty" and which not.  8)




Use bigger blocks, for example four byte * 8 raster lines.


Then if it must be sequential, you can do something like


LD A,(dirty_flag)


RRCA:JR NC,next_bit1


clearn screen routine


next_bit RRCA:JR NC,next_bit2


and so on...




No loops, costs much time.



TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Powered by SMFPacks Menu Editor Mod