(ref) Moved console_listen into main loop

This commit is contained in:
Devine Lu Linvega 2024-01-10 12:59:29 -08:00
parent 46d7ca5cd9
commit 526696d44b
1 changed files with 7 additions and 15 deletions

View File

@ -1,5 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
/* clang-format off */
@ -27,21 +26,10 @@ int
console_input(Uxn *u, char c, int type)
{
Uint8 *d = &u->dev[0x10];
d[0x2] = c;
d[0x7] = type;
d[0x2] = c, d[0x7] = type;
return uxn_eval(u, PEEK2(d));
}
void
console_listen(Uxn *u, int i, int argc, char **argv)
{
for(; i < argc; i++) {
char *p = argv[i];
while(*p) console_input(u, *p++, 0x2);
console_input(u, '\n', i == argc - 1 ? 0x4 : 0x3);
}
}
void
console_deo(Uint8 *d, Uint8 port)
{
@ -149,9 +137,9 @@ uxn_eval(Uxn *u, Uint16 pc)
int
main(int argc, char **argv)
{
FILE *f;
int i = 1;
Uxn u = {0};
FILE *f;
if(i == argc) {
fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]);
return 0;
@ -166,7 +154,11 @@ main(int argc, char **argv)
/* eval */
u.dev[0x17] = argc - i;
if(uxn_eval(&u, 0x0100)) {
console_listen(&u, i, argc, argv);
for(; i < argc; i++) {
char *p = argv[i];
while(*p) console_input(&u, *p++, 0x2);
console_input(&u, '\n', i == argc - 1 ? 0x4 : 0x3);
}
while(!u.dev[0x0f]) {
char c = fgetc(stdin);
if(c == EOF) {