0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-22 22:05:11 +00:00

Added version flag to uxnemu

This commit is contained in:
neauoire 2023-08-08 15:56:40 -07:00
parent 9c25f801d0
commit 2e25f6c27e
5 changed files with 41 additions and 25 deletions

View file

@ -94,6 +94,16 @@ fi
if [ $norun = 1 ]; then exit; fi
# Test usage
./bin/uxncli
./bin/uxnemu
# Test version
./bin/uxncli -v
./bin/uxnemu -v
./bin/uxnasm projects/software/piano.tal bin/piano.rom
./bin/uxnemu -2x bin/piano.rom

View file

@ -83,11 +83,11 @@ system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo)
}
int
system_version(void)
system_version(char *name, char *date)
{
int i;
printf("Varvara Emulator 1.0\n");
printf("Device Version Dei Deo\n", i, dev_vers[i], dei_mask[i], deo_mask[i]);
printf("%s, %s.\n", name, date);
printf("Device Version Dei Deo\n");
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]);

View file

@ -16,7 +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_version(char *emulator, char *date);
int system_load(Uxn *u, char *filename);
void system_inspect(Uxn *u);
int system_error(char *msg, const char *err);

View file

@ -48,17 +48,18 @@ main(int argc, char **argv)
int i = 1;
if(i == argc)
return system_error("usage", "uxncli [-v] file.rom [args..]");
/* Boot Varvara */
/* Connect 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();
return system_version("Uxncli - Console Varvara Emulator", "8 Aug 2023");
/* Continue.. */
if(!uxn_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8))))
return system_error("Boot", "Failed");
/* Load rom */
if(!system_load(&u, argv[i++]))
return system_error("Load", "Failed");

View file

@ -251,19 +251,6 @@ emu_init(void)
SDL_SetRenderDrawColor(emu_renderer, 0x00, 0x00, 0x00, 0xff);
ms_interval = SDL_GetPerformanceFrequency() / 1000;
deadline_interval = ms_interval * TIMEOUT_MS;
/* connect devices */
system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
system_connect(0x2, SCREEN_VERSION, SCREEN_DEIMASK, SCREEN_DEOMASK);
system_connect(0x3, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x4, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x5, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x6, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x8, CONTROL_VERSION, CONTROL_DEIMASK, CONTROL_DEOMASK);
system_connect(0x9, MOUSE_VERSION, MOUSE_DEIMASK, MOUSE_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);
return 1;
}
@ -517,13 +504,31 @@ main(int argc, char **argv)
{
Uxn u = {0};
int i = 1;
if(i == argc)
return system_error("usage", "uxnemu [-v][-2x][-3x] file.rom [args...]");
/* Connect Varvara */
system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
system_connect(0x2, SCREEN_VERSION, SCREEN_DEIMASK, SCREEN_DEOMASK);
system_connect(0x3, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x4, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x5, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x6, AUDIO_VERSION, AUDIO_DEIMASK, AUDIO_DEOMASK);
system_connect(0x8, CONTROL_VERSION, CONTROL_DEIMASK, CONTROL_DEOMASK);
system_connect(0x9, MOUSE_VERSION, MOUSE_DEIMASK, MOUSE_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);
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxnemu - Graphical Varvara Emulator", "8 Aug 2023");
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0', 0);
/* Continue.. */
if(!emu_init())
return system_error("Init", "Failed to initialize emulator.");
/* default zoom */
if(argc < 2)
return system_error("usage", "uxnemu [-2x][-3x] file.rom [args...]");
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0', 0);
/* load rom */
rom_path = argv[i++];
if(!emu_start(&u, rom_path, argc - i))