diff --git a/ref/makefile b/ref/makefile index 1ec0e48..80da709 100644 --- a/ref/makefile +++ b/ref/makefile @@ -1,16 +1,25 @@ .PHONY: all run test format clean -all: bin/uxn +all: bin/uxnmin bin/opctest run: all - @ wc -c bin/uxn - @ cat console.tal | bin/uxn drifloon.bin > bin/console.rom - @ bin/uxn test.bin "String sent through stdin" + @ bin/uxnmin + @ bin/uxnmin missing.rom + @ bin/uxnmin bin/opctest.rom + @ cat console.tal | bin/uxnmin drifloon.bin > bin/console.rom + @ bin/uxnmin bin/console.rom "String sent through stdin" format: - @ clang-format -i uxn.c + @ clang-format -i uxnmin.c clean: - @ rm -r -f bin + @ rm -fr bin +install: all + @ cp bin/uxnmin ~/bin +archive: all + cp uxnmin.c ~/Git/oscean/etc/uxnmin.c.txt -bin/uxn: uxn.c +bin/opctest: ../cli/opctest/opctest.tal + @ uxnasm ../cli/opctest/opctest.tal bin/opctest.rom +bin/uxnmin: uxnmin.c @ mkdir -p bin/ - @ cc -std=c89 -Os -DNDEBUG -g0 -s -Wno-unknown-pragmas uxn.c -o bin/uxn + @ cc -std=c89 -Os -DNDEBUG -g0 -s -Wno-unknown-pragmas uxnmin.c -o bin/uxnmin + @ wc -c bin/uxnmin diff --git a/ref/uxn.c b/ref/uxnmin.c similarity index 95% rename from ref/uxn.c rename to ref/uxnmin.c index 105a44f..2e4fc62 100644 --- a/ref/uxn.c +++ b/ref/uxnmin.c @@ -15,14 +15,6 @@ typedef struct Uxn { int uxn_eval(Uxn *u, Uint16 pc); -int -console_input(Uxn *u, char c, int type) -{ - Uint16 vector = u->dev[0x10] << 8 | u->dev[0x11]; - u->dev[0x12] = c, u->dev[0x17] = type; - return uxn_eval(u, vector); -} - Uint8 emu_dei(Uxn *u, Uint8 addr) { @@ -108,24 +100,30 @@ uxn_eval(Uxn *u, Uint16 pc) } } +void +console_input(Uxn *u, char c, int type) +{ + u->dev[0x12] = c, u->dev[0x17] = type; + uxn_eval(u, u->dev[0x10] << 8 | u->dev[0x11]); +} + int main(int argc, char **argv) { FILE *f; int i = 1; Uxn u = {0}; - if(i == argc) { + if(argc < 2) { fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]); return 0; } f = fopen(argv[i++], "rb"); if(!f) { - fprintf(stderr, "Failed to initialize %s\n", argv[1]); + fprintf(stderr, "uxnmin: Error %s\n", argv[1]); return 0; } - fread(&u.ram[0x0100], 0xff00, 1, f); - fclose(f); u.dev[0x17] = argc - i; + fread(&u.ram[0x0100], 0xff00, 1, f), fclose(f); if(uxn_eval(&u, 0x0100) && (u.dev[0x10] << 8 | u.dev[0x11])) { for(; i < argc; i++) { char *p = argv[i];