c128lib Framework
A Commodore 128 software framework for enabling high-level development of C128 programs.
Loading...
Searching...
No Matches
random-global.asm File Reference

Functions

macro c128lib_PseudoRandom ()
 Random number generator module.
 
macro c128lib_InitSid ()
 
macro c128lib_GetRandomNumberFromSid ()
 

Function Documentation

◆ c128lib_PseudoRandom()

macro c128lib_PseudoRandom ( )

Random number generator module.

This module contains a bunch of macros for random number generation. There are mainly two types of generetions: random and pseudo-random Pseudo-random generator creates random numbers inside a sequence based on alghorithm. Random generator try to create an unpredictable number sequence.

Random number generator must be initialized before use.

Date
2023

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.

Note
The generated pseudo-random number is stored in the accumulator (.A register).
Remarks
Register .A must contain seed and will contain pseudo random number generated. Flags N, Z and C will be affected.
Use c128lib_PseudoRandom in random-global.asm
Since
0.1.0

◆ c128lib_InitSid()

macro c128lib_InitSid ( )

Init random number generator based on the Sid chip. When used, voice 3 of Sid chip can't be used for playback sounds.

Remarks
Register .A will be changed. Flags N and Z will be affected.
See also
c128lib_GetRandomNumberFromSid
Since
0.1.0

◆ c128lib_GetRandomNumberFromSid()

macro c128lib_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().

Remarks
Register .A will be changed. Flags N and Z will be affected.
See also
c128lib_InitSid
Since
0.1.0