Added code to get the consoles to be split into their own
Fixed issue where exiting a shell would not close the parent console properly Changed the way the consoles are linked to the processes by making it a pointer to the console Added all the console changes for the above Added a slow maze drawing program similar to the c64 version
This commit is contained in:
66
maze.c
Normal file
66
maze.c
Normal file
@ -0,0 +1,66 @@
|
||||
#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);
|
||||
}
|
||||
exit();
|
||||
}
|
Reference in New Issue
Block a user