R Register Update

Page 2/2
1 |

By realpeterjack

Champion (417)

realpeterjack's picture

28-09-2005, 16:23

Just a quick addition: the R register can be used as a random generator, if the number of instructions executed between the readings varies. But it will be only in the range 0-127, since Z80 preserves the value of the most significant bit as set by the programmer. If you load the R register with &b00000000, it will start incrementing it and will reset it after &b01111111. If you load it with &b1xxxxxxx, after the count reaches &b11111111, it will reset to &b10000000. It only increments the 7 least significant bits.

By ro

Scribe (4473)

ro's picture

28-09-2005, 16:44

@ro

R register usage as a random number is a poor solution. If used in sequence you get numbers in sequence too (with few jumps).

If you use the R register to determine a angle of some enemies movement, each successive enemy will have angles in sequence, always bigger than the last.

Hence the quotes around the word random Wink

By marison

Expert (104)

marison's picture

28-09-2005, 17:00

The quotes didn't was processed by my own Z0.8 CPU. It was totally discarded...

I should do an autoupgrade...

Page 2/2
1 |