c128lib Framework
A Commodore 128 software framework for enabling high-level development of C128 programs.
|
Namespaces | |
namespace | Random |
Random number generator module. | |
Functions | |
macro | PseudoRandom () |
This macro generates a pseudo-random number. | |
macro | InitSid () |
macro | GetRandomNumberFromSid () |
macro PseudoRandom | ( | ) |
This macro generates a pseudo-random number.
The macro uses the Linear Feedback Shift Register (LFSR) method to generate a pseudo-random number. It is guaranteed to create a sequence touching every element from 0 to $ff just once. Seed must be provided in accumulator and can be from 0 to $ff. Output number will be available in the accumulator. It performs an arithmetic shift left (ASL) on the accumulator. If the result is zero or if the carry flag is set, it skips the exclusive OR (EOR) operation. Otherwise, it performs the EOR operation with the hexadecimal value 0x1D.
macro InitSid | ( | ) |
Init random number generator based on the Sid chip. When used, voice 3 of Sid chip can't be used for playback sounds.
macro GetRandomNumberFromSid | ( | ) |
Get a new random number from the Sid chip and puts it into the .A register. Random numbers are continuously generated so each call gives a new random number. Generetor must be initialized with InitSid().