From 9c25f801d052fe8cade6953ebc150d76ffa1ca6a Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 8 Aug 2023 15:31:48 -0700 Subject: [PATCH] Print system versions for uxncli with -v flag --- README.md | 2 +- src/devices/audio.h | 3 +-- src/devices/console.h | 2 +- src/devices/screen.h | 3 +-- src/devices/system.c | 13 ++++++++++++- src/devices/system.h | 1 + src/uxn.h | 4 ++-- src/uxncli.c | 17 +++++++++++------ 8 files changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b097045..ae71c8b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler If you wish to build the emulator without graphics mode: ```sh -cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli +cc src/devices/datetime.c src/devices/system.c src/devices/console.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli ``` ### Plan 9 diff --git a/src/devices/audio.h b/src/devices/audio.h index 299307f..099cdbe 100644 --- a/src/devices/audio.h +++ b/src/devices/audio.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick +Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/console.h b/src/devices/console.h index 85d659b..aaaef23 100644 --- a/src/devices/console.h +++ b/src/devices/console.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/screen.h b/src/devices/screen.h index d1e0dbc..320cc33 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick +Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/system.c b/src/devices/system.c index 28aef3d..466490b 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -77,12 +77,23 @@ system_inspect(Uxn *u) void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo) { - /* printf("%02x -> v%d %04x %04x\n", device, ver, dei, deo); */ dev_vers[device] = ver; dei_mask[device] = dei; deo_mask[device] = deo; } +int +system_version(void) +{ + int i; + printf("Varvara Emulator 1.0\n"); + printf("Device Version Dei Deo\n", i, dev_vers[i], dei_mask[i], deo_mask[i]); + for(i = 0; i < 0x10; i++) + if(dev_vers[i]) + printf("%6x %7d %04x %04x\n", i, dev_vers[i], dei_mask[i], deo_mask[i]); + return 0; +} + /* IO */ void diff --git a/src/devices/system.h b/src/devices/system.h index 6526b19..0679e20 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -16,6 +16,7 @@ WITH REGARD TO THIS SOFTWARE. #define RAM_PAGES 0x10 void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo); +int system_version(void); int system_load(Uxn *u, char *filename); void system_inspect(Uxn *u); int system_error(char *msg, const char *err); diff --git a/src/uxn.h b/src/uxn.h index fda0086..8cab5f1 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -9,8 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define PAGE_PROGRAM 0x0100 - /* clang-format off */ #define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); } @@ -20,6 +18,8 @@ WITH REGARD TO THIS SOFTWARE. /* clang-format on */ +#define PAGE_PROGRAM 0x0100 + typedef unsigned char Uint8; typedef signed char Sint8; typedef unsigned short Uint16; diff --git a/src/uxncli.c b/src/uxncli.c index 3e3f68b..0cbbfe2 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -47,17 +47,22 @@ main(int argc, char **argv) Uxn u; int i = 1; if(i == argc) - return system_error("usage", "uxncli file.rom [args..]"); - if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)))) - return system_error("Boot", "Failed"); - if(!system_load(&u, argv[i++])) - return system_error("Load", "Failed"); - /* connect devices */ + return system_error("usage", "uxncli [-v] file.rom [args..]"); + /* Boot Varvara */ system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK); system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK); system_connect(0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK); system_connect(0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK); system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); + if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)))) + return system_error("Boot", "Failed"); + /* Read flags */ + if(argv[i][0] == '-' && argv[i][1] == 'v') + return system_version(); + /* Load rom */ + if(!system_load(&u, argv[i++])) + return system_error("Load", "Failed"); + /* Game Loop */ u.dev[0x17] = argc - i; if(uxn_eval(&u, PAGE_PROGRAM)) { for(; i < argc; i++) {