Added per-device versions

This commit is contained in:
neauoire 2023-08-08 14:44:17 -07:00
parent 97d299261f
commit 2e1b56018b
12 changed files with 41 additions and 16 deletions

View File

@ -12,10 +12,9 @@ WITH REGARD TO THIS SOFTWARE.
typedef signed int Sint32; typedef signed int Sint32;
#define AUDIO_VERSION 1 #define AUDIO_VERSION 1
#define AUDIO_DEIMASK 0x0000 #define AUDIO_DEIMASK 0x0014
#define AUDIO_DEOMASK 0x0000 #define AUDIO_DEOMASK 0x8000
#define SAMPLE_FREQUENCY 44100 #define SAMPLE_FREQUENCY 44100
#define POLYPHONY 4 #define POLYPHONY 4

View File

@ -11,7 +11,7 @@ WITH REGARD TO THIS SOFTWARE.
#define CONSOLE_VERSION 1 #define CONSOLE_VERSION 1
#define CONSOLE_DEIMASK 0x0000 #define CONSOLE_DEIMASK 0x0000
#define CONSOLE_DEOMASK 0x0000 #define CONSOLE_DEOMASK 0x0300
#define CONSOLE_STD 0x1 #define CONSOLE_STD 0x1
#define CONSOLE_ARG 0x2 #define CONSOLE_ARG 0x2

View File

@ -10,7 +10,7 @@ WITH REGARD TO THIS SOFTWARE.
*/ */
#define DATETIME_VERSION 1 #define DATETIME_VERSION 1
#define DATETIME_DEIMASK 0x0000 #define DATETIME_DEIMASK 0x07ff
#define DATETIME_DEOMASK 0x0000 #define DATETIME_DEOMASK 0x0000
Uint8 datetime_dei(Uxn *u, Uint8 addr); Uint8 datetime_dei(Uxn *u, Uint8 addr);

View File

@ -11,7 +11,7 @@ WITH REGARD TO THIS SOFTWARE.
#define FILE_VERSION 1 #define FILE_VERSION 1
#define FILE_DEIMASK 0x0000 #define FILE_DEIMASK 0x0000
#define FILE_DEOMASK 0x0000 #define FILE_DEOMASK 0xa260
#define POLYFILEY 2 #define POLYFILEY 2
#define DEV_FILE0 0xa #define DEV_FILE0 0xa

View File

@ -9,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
#define MOUSE_VERSION 1 #define MOUSE_VERSION 1
#define MOUSE_DEIMASK 0x0000 #define MOUSE_DEIMASK 0x0000
#define MOUSE_DEOMASK 0x0000 #define MOUSE_DEOMASK 0x0000

View File

@ -11,8 +11,8 @@ WITH REGARD TO THIS SOFTWARE.
*/ */
#define SCREEN_VERSION 1 #define SCREEN_VERSION 1
#define SCREEN_DEIMASK 0x0000 #define SCREEN_DEIMASK 0x003c
#define SCREEN_DEOMASK 0x0000 #define SCREEN_DEOMASK 0xc028
typedef struct UxnScreen { typedef struct UxnScreen {
int width, height, x1, y1, x2, y2; int width, height, x1, y1, x2, y2;

View File

@ -74,6 +74,15 @@ system_inspect(Uxn *u)
system_print(&u->rst, "rst"); system_print(&u->rst, "rst");
} }
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;
}
/* IO */ /* IO */
void void

View File

@ -11,10 +11,11 @@ WITH REGARD TO THIS SOFTWARE.
#define SYSTEM_VERSION 1 #define SYSTEM_VERSION 1
#define SYSTEM_DEIMASK 0x0000 #define SYSTEM_DEIMASK 0x0000
#define SYSTEM_DEOMASK 0x0000 #define SYSTEM_DEOMASK 0xff28
#define RAM_PAGES 0x10 #define RAM_PAGES 0x10
void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
int system_load(Uxn *u, char *filename); int system_load(Uxn *u, char *filename);
void system_inspect(Uxn *u); void system_inspect(Uxn *u);
int system_error(char *msg, const char *err); int system_error(char *msg, const char *err);

View File

@ -95,4 +95,5 @@ uxn_boot(Uxn *u, Uint8 *ram)
cptr[i] = 0; cptr[i] = 0;
u->ram = ram; u->ram = ram;
return 1; return 1;
} }

View File

@ -42,8 +42,7 @@ typedef struct Uxn {
extern Uint8 emu_dei(Uxn *u, Uint8 addr); extern Uint8 emu_dei(Uxn *u, Uint8 addr);
extern void emu_deo(Uxn *u, Uint8 addr); extern void emu_deo(Uxn *u, Uint8 addr);
extern int emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr); extern int emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
extern Uint16 dei_mask[]; extern Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
extern Uint16 deo_mask[];
/* built-ins */ /* built-ins */

View File

@ -18,8 +18,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
Uint16 deo_mask[] = {0xc028, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000}; Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
Uint16 dei_mask[] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07ff, 0x0000, 0x0000, 0x0000};
Uint8 Uint8
emu_dei(Uxn *u, Uint8 addr) emu_dei(Uxn *u, Uint8 addr)
@ -53,6 +52,12 @@ main(int argc, char **argv)
return system_error("Boot", "Failed"); return system_error("Boot", "Failed");
if(!system_load(&u, argv[i++])) if(!system_load(&u, argv[i++]))
return system_error("Load", "Failed"); return system_error("Load", "Failed");
/* connect devices */
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);
u.dev[0x17] = argc - i; u.dev[0x17] = argc - i;
if(uxn_eval(&u, PAGE_PROGRAM)) { if(uxn_eval(&u, PAGE_PROGRAM)) {
for(; i < argc; i++) { for(; i < argc; i++) {

View File

@ -60,8 +60,7 @@ static Uint32 stdin_event, audio0_event, zoom = 1;
static Uint64 exec_deadline, deadline_interval, ms_interval; static Uint64 exec_deadline, deadline_interval, ms_interval;
static char *rom_path; static char *rom_path;
Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000}; Uint16 dev_vers[0x10], dei_mask[0x10], deo_mask[0x10];
Uint16 dei_mask[] = {0x0000, 0x0000, 0x003c, 0x0014, 0x0014, 0x0014, 0x0014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07ff, 0x0000, 0x0000, 0x0000};
static int static int
clamp(int v, int min, int max) clamp(int v, int min, int max)
@ -252,6 +251,19 @@ emu_init(void)
SDL_SetRenderDrawColor(emu_renderer, 0x00, 0x00, 0x00, 0xff); SDL_SetRenderDrawColor(emu_renderer, 0x00, 0x00, 0x00, 0xff);
ms_interval = SDL_GetPerformanceFrequency() / 1000; ms_interval = SDL_GetPerformanceFrequency() / 1000;
deadline_interval = ms_interval * TIMEOUT_MS; 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; return 1;
} }