It's okay, I think that I've guessed a solution, as follows:
Code: Select all
int main();
void ramdomiser();
unsigned char random;
unsigned char stringBuffer;
/**
* Random number generator based on
* how long the user interacts with the
* program - prints random numbers
* between 0 and 15
* DONKEYSOFT MMXVII
*/
int main()
{
unsigned char i, r;
for(i = 0; i < 20; i++)
{
randomiser();
r = srand(random) % 16;
printf("%d", r);
gets(stringBuffer);
}
}
/**
* Sets the unsigned char random to
* the current low byte value of $401e
* If this routine causes issues with
* your program then push hl and a
* to the stack and restore them, or
* exchange for the shadow registers
*/
void randomiser()
{
__asm
ld hl, ($401e)
ld a, l
ld (_random), a
__endasm;
}
When writing to 'globals' in your assembly listing, you need to put an underscore before the variable name (_random is where we are storing the value passed to a, so each time randomiser() is called, it will update the value in random).
Enjoy!
Shaun