mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add UVM32_SYSCALL_RAND to get a "true" random number from the host, as I want to play zigtris and not have it be the same every time.
This commit is contained in:
parent
3d83844d5c
commit
d780c4e69d
6 changed files with 18 additions and 1 deletions
|
|
@ -241,6 +241,8 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
srand(clock());
|
||||
|
||||
uvm32_init(vmst);
|
||||
|
||||
if (!uvm32_load(vmst, rom, romlen)) {
|
||||
|
|
@ -374,6 +376,9 @@ int main(int argc, char *argv[]) {
|
|||
case UVM32_SYSCALL_MILLIS: {
|
||||
uvm32_arg_setval(vmst, &evt, RET, SDL_GetTicks());
|
||||
} break;
|
||||
case UVM32_SYSCALL_RAND:
|
||||
uvm32_arg_setval(&vmst, &evt, RET, rand());
|
||||
break;
|
||||
case UVM32_SYSCALL_GETC: {
|
||||
uvm32_arg_setval(vmst, &evt, RET, 0xFFFFFFFF);
|
||||
} break;
|
||||
|
|
|
|||
|
|
@ -190,6 +190,8 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
srand(clock());
|
||||
|
||||
uvm32_init(&vmst);
|
||||
|
||||
if (!uvm32_load(&vmst, rom, romlen)) {
|
||||
|
|
@ -264,6 +266,9 @@ int main(int argc, char *argv[]) {
|
|||
case UVM32_SYSCALL_PRINTHEX:
|
||||
printf("%08x", uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
break;
|
||||
case UVM32_SYSCALL_RAND:
|
||||
uvm32_arg_setval(&vmst, &evt, RET, rand());
|
||||
break;
|
||||
case UVM32_SYSCALL_MILLIS: {
|
||||
clock_t now = clock() / (CLOCKS_PER_SEC / 1000);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, now - start_time);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue