Looping over large chunk of memory

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Looping over large chunk of memory

Post by Oziphantom »

nesrocks wrote:Is what I said totally a bad idea? Or doesn't it apply? The advantage is that the list of objects can be any size. The disadvantage is that it can't have one specific byte value (or bit) at a certain point in the data array. You do need to check for that #FF byte on every item, but when using a counter you need to check against it, so I guess it's the same on that aspect, optimization-wise.
And in the OP case, I imagine it's one big object of 500 bytes? In that case you could reserve #FF to be the end of the data.
You can also say expect FF FF or FF FF FF or FF FF FF FF each getting more unlikely than the next, or you scan all of you data and find a magic combo that is not used at all. But FF seems to be used by a lot of things as an end marker ;)

Or you make an escape byte

FE FE = FE
FE FF = FF
FF XX = End
Post Reply