Files
xv6-custom-os/maze.c
iDunnoDev c65c58a954 Added the drawtitle function to console
Added ability to pick a bg preset for the title bar
Added counting program
Added function to set the current consoles title name
Removed some of the debug code
2022-12-16 15:23:38 +00:00

67 lines
1.5 KiB
C

#include "types.h"
#include "user.h"
uint rngnumber(void)
{
// Take from http://stackoverflow.com/questions/1167253/implementation-of-rand
static unsigned int z1 = 12345, z2 = 12345, z3 = 12345, z4 = 12345;
unsigned int b;
b = ((z1 << 6) ^ z1) >> 13;
z1 = ((z1 & 4294967294U) << 18) ^ b;
b = ((z2 << 2) ^ z2) >> 27;
z2 = ((z2 & 4294967288U) << 2) ^ b;
b = ((z3 << 13) ^ z3) >> 21;
z3 = ((z3 & 4294967280U) << 7) ^ b;
b = ((z4 << 3) ^ z4) >> 12;
z4 = ((z4 & 4294967168U) << 13) ^ b;
return (z1 ^ z2 ^ z3 ^ z4) / 2;
}
int rngrange(int start, int end)
{
if (end < start)
{
int swtmp = start;
start = end;
end = swtmp;
}
int range = end - start + 1;
return rngnumber() % (range) + start;
}
int main(int argc, char *argv[]) {
int lines = 1000;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-l") == 0) {
lines = atoi(argv[i + 1]);
}
}
cls();
printf(1, "Start Maze\n");
for (int y = 0; y < lines; y++)
{
for (int x = 0; x < 79; x++)
{
int rndnum = rngrange(189, 197);
switch (rndnum)
{
case 189:
rndnum = 179;
break;
case 190:
rndnum = 180;
break;
}
printf(1, "%c", rndnum);
}
printf(1, "\n");
sleep(10);
}
printf(1, "Maze Ended\n");
exit();
}