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

Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-01-02 19:20:16 -08:00
parent 78526d56e3
commit 02f7add4ac
5 changed files with 29 additions and 41 deletions

View file

@ -49,6 +49,17 @@ system_print(Stack *s, char *name)
fprintf(stderr, "\n");
}
static void
system_zero(Uxn *u, int soft)
{
int i;
for(i = PAGE_PROGRAM * soft; i < 0x10000; i++)
u->ram[i] = 0;
for(i = 0x0; i < 0x100; i++)
u->dev[i] = 0;
u->wst.ptr = u->rst.ptr = 0;
}
void
system_inspect(Uxn *u)
{
@ -64,24 +75,6 @@ system_error(char *msg, const char *err)
return 0;
}
int
system_version(char *name, char *date)
{
printf("%s, %s.\n", name, date);
return 0;
}
void
system_zero(Uxn *u, int soft)
{
int i;
for(i = PAGE_PROGRAM * soft; i < 0x10000; i++)
u->ram[i] = 0;
for(i = 0x0; i < 0x100; i++)
u->dev[i] = 0;
u->wst.ptr = u->rst.ptr = 0;
}
void
system_reboot(Uxn *u, char *rom, int soft)
{

View file

@ -15,10 +15,9 @@ WITH REGARD TO THIS SOFTWARE.
extern char *boot_rom;
int system_error(char *msg, const char *err);
void system_reboot(Uxn *u, char *rom, int soft);
void system_inspect(Uxn *u);
int system_version(char *emulator, char *date);
int system_error(char *msg, const char *err);
int system_init(Uxn *u, Uint8 *ram, char *rom);
Uint8 system_dei(Uxn *u, Uint8 addr);

View file

@ -35,7 +35,6 @@ typedef struct Uxn {
/* required functions */
extern Uxn u;
extern Uint8 emu_dei(Uxn *u, Uint8 addr);
extern void emu_deo(Uxn *u, Uint8 addr, Uint8 value);

View file

@ -18,8 +18,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
Uxn u;
Uint8
emu_dei(Uxn *u, Uint8 addr)
{
@ -47,12 +45,13 @@ int
main(int argc, char **argv)
{
int i = 1;
Uxn u = {0};
Uint8 dev[0x100] = {0};
u.dev = (Uint8 *)&dev;
if(i == argc)
return system_error("usage", "uxncli [-v] file.rom [args..]");
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxncli - Console Varvara Emulator", "2 Jan 2024");
return system_error("Uxncli - Varvara Emulator(CLI)", "2 Jan 2024.");
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn.");
/* eval */

View file

@ -46,8 +46,6 @@ WITH REGARD TO THIS SOFTWARE.
#define HEIGHT 40 * 8
#define TIMEOUT_MS 334
Uxn u;
static SDL_Window *emu_window;
static SDL_Texture *emu_texture;
static SDL_Renderer *emu_renderer;
@ -490,34 +488,34 @@ main(int argc, char **argv)
{
Uint8 *ram;
char *rom;
Uxn u = {0};
Uint8 dev[0x100] = {0};
Uxn u_audio = {0};
u.dev = (Uint8 *)&dev;
u_audio.dev = (Uint8 *)&dev;
int i = 1;
if(i == argc)
return system_error("usage", "uxnemu [-v] | uxnemu [-f | -2x | -3x | --] file.rom [args...]");
/* Read flag. Right now, there can be only one. */
if(argv[i][0] == '-') {
if(argv[i][1] == 'v')
return system_version("Uxnemu - Graphical Varvara Emulator", "2 Jan 2024");
if(argv[i][1] == '-')
i++;
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0', 0);
if(strcmp(argv[i], "-f") == 0) {
i++;
/* flags */
if(argc > 1 && argv[i][0] == '-') {
if(!strcmp(argv[i], "-v"))
return system_error("Uxnemu - Varvara Emulator(GUI)", "2 Jan 2024.");
else if(!strcmp(argv[i], "-2x"))
set_zoom(2, 0);
else if(!strcmp(argv[i], "-3x"))
set_zoom(3, 0);
else if(strcmp(argv[i], "-f") == 0)
set_fullscreen(1, 0);
}
i++;
}
/* Start system. */
if(i == argc)
return system_error("usage", "uxnemu [-v | -f | -2x | -3x] file.rom [args...]");
/* start */
ram = (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8));
rom = argv[i++];
if(!system_init(&u, ram, rom) || !system_init(&u_audio, ram, rom))
return system_error("Init", "Failed to initialize uxn.");
if(!emu_init(&u_audio))
return system_error("Init", "Failed to initialize varvara.");
/* Game Loop */
/* loop */
u.dev[0x17] = argc - i;
if(uxn_eval(&u, PAGE_PROGRAM)) {
console_listen(&u, i, argc, argv);