Replace file_i_deo and file_i_dei.

This commit is contained in:
neauoire 2022-03-28 10:22:23 -07:00
parent 387f3c7e21
commit 2074c2cbd6
4 changed files with 22 additions and 35 deletions

View File

@ -151,12 +151,18 @@ file_delete(UxnFile *c)
return unlink(c->current_filename); return unlink(c->current_filename);
} }
static UxnFile *
file_instance(Device *d)
{
return &uxn_file[d - &d->u->dev[DEV_FILE0]];
}
/* IO */ /* IO */
void void
file_i_deo(int instance, Device *d, Uint8 port) file_deo(Device *d, Uint8 port)
{ {
UxnFile *c = &uxn_file[instance]; UxnFile *c = file_instance(d);
Uint16 addr, len, res; Uint16 addr, len, res;
switch(port) { switch(port) {
case 0x5: case 0x5:
@ -196,9 +202,9 @@ file_i_deo(int instance, Device *d, Uint8 port)
} }
Uint8 Uint8
file_i_dei(int instance, Device *d, Uint8 port) file_dei(Device *d, Uint8 port)
{ {
UxnFile *c = &uxn_file[instance]; UxnFile *c = file_instance(d);
Uint16 res; Uint16 res;
switch(port) { switch(port) {
case 0xc: case 0xc:

View File

@ -11,6 +11,7 @@ WITH REGARD TO THIS SOFTWARE.
*/ */
#define POLYFILEY 2 #define POLYFILEY 2
#define DEV_FILE0 0xa
void file_i_deo(int instance, Device *d, Uint8 port); void file_deo(Device *d, Uint8 port);
Uint8 file_i_dei(int instance, Device *d, Uint8 port); Uint8 file_dei(Device *d, Uint8 port);

View File

@ -19,7 +19,7 @@ static Display *display;
static Visual *visual; static Visual *visual;
static Window window; static Window window;
static Device *devscreen, *devctrl, *devmouse, *devfile0; static Device *devscreen, *devctrl, *devmouse;
#define WIDTH 64 * 8 #define WIDTH 64 * 8
#define HEIGHT 40 * 8 #define HEIGHT 40 * 8
@ -38,18 +38,6 @@ system_deo_special(Device *d, Uint8 port)
screen_palette(&uxn_screen, &d->dat[0x8]); screen_palette(&uxn_screen, &d->dat[0x8]);
} }
static void
file_deo(Device *d, Uint8 port)
{
file_i_deo(d - devfile0, d, port);
}
static Uint8
file_dei(Device *d, Uint8 port)
{
return file_i_dei(d - devfile0, d, port);
}
static int static int
console_input(Uxn *u, char c) console_input(Uxn *u, char c)
{ {
@ -207,7 +195,7 @@ start(Uxn *u, char *rom)
/* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo);
/* control */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo); /* control */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo);
/* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo); /* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo);
/* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); /* file0 */ uxn_port(u, 0xa, file_dei, file_deo);
/* file1 */ uxn_port(u, 0xb, file_dei, file_deo); /* file1 */ uxn_port(u, 0xb, file_dei, file_deo);
/* empty */ uxn_port(u, 0xc, datetime_dei, nil_deo); /* empty */ uxn_port(u, 0xc, datetime_dei, nil_deo);
/* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo);

View File

@ -17,8 +17,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
static Device *devfile0;
static int static int
error(char *msg, const char *err) error(char *msg, const char *err)
{ {
@ -44,18 +42,6 @@ console_deo(Device *d, Uint8 port)
} }
} }
static void
file_deo(Device *d, Uint8 port)
{
file_i_deo(d - devfile0, d, port);
}
static Uint8
file_dei(Device *d, Uint8 port)
{
return file_i_dei(d - devfile0, d, port);
}
static Uint8 static Uint8
nil_dei(Device *d, Uint8 port) nil_dei(Device *d, Uint8 port)
{ {
@ -101,6 +87,12 @@ load(Uxn *u, char *filepath)
return 1; return 1;
} }
int
uxn_interrupt(void)
{
return 1;
}
static int static int
start(Uxn *u) start(Uxn *u)
{ {
@ -116,7 +108,7 @@ start(Uxn *u)
/* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x8, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x8, nil_dei, nil_deo);
/* empty */ uxn_port(u, 0x9, nil_dei, nil_deo); /* empty */ uxn_port(u, 0x9, nil_dei, nil_deo);
/* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); /* file0 */ uxn_port(u, 0xa, file_dei, file_deo);
/* file1 */ uxn_port(u, 0xb, file_dei, file_deo); /* file1 */ uxn_port(u, 0xb, file_dei, file_deo);
/* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); /* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo);
/* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo);