Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-01-02 11:29:02 -08:00
parent a4f4eb7460
commit 8c212fed3e
13 changed files with 27 additions and 56 deletions

View File

@ -12,8 +12,6 @@ WITH REGARD TO THIS SOFTWARE.
typedef signed int Sint32;
#define AUDIO_VERSION 1
#define AUDIO_DEIMASK 0x0014
#define AUDIO_DEOMASK 0x8000
#define AUDIO_BUFSIZE 256.0f
#define SAMPLE_FREQUENCY 44100.0f

View File

@ -10,8 +10,6 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define CONSOLE_VERSION 1
#define CONSOLE_DEIMASK 0x0000
#define CONSOLE_DEOMASK 0x0300
#define CONSOLE_STD 0x1
#define CONSOLE_ARG 0x2

View File

@ -10,8 +10,6 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define CONTROL_VERSION 1
#define CONTROL_DEIMASK 0x0000
#define CONTROL_DEOMASK 0x0000
void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
void controller_up(Uxn *u, Uint8 *d, Uint8 mask);

View File

@ -18,10 +18,8 @@ Uint8
datetime_dei(Uxn *u, Uint8 addr)
{
time_t seconds = time(NULL);
struct tm zt = {0};
struct tm *t = localtime(&seconds);
if(t == NULL)
t = &zt;
struct tm zt = {0}, *t = localtime(&seconds);
if(t == NULL) t = &zt;
switch(addr) {
case 0xc0: return (t->tm_year + 1900) >> 8;
case 0xc1: return (t->tm_year + 1900);

View File

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

View File

@ -10,8 +10,6 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define FILE_VERSION 1
#define FILE_DEIMASK 0x0000
#define FILE_DEOMASK 0xa260
#define POLYFILEY 2
#define DEV_FILE0 0xa

View File

@ -29,23 +29,16 @@ mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
void
mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
{
*(d + 2) = x >> 8;
*(d + 3) = x;
*(d + 4) = y >> 8;
*(d + 5) = y;
*(d + 2) = x >> 8, *(d + 3) = x;
*(d + 4) = y >> 8, *(d + 5) = y;
uxn_eval(u, PEEK2(d));
}
void
mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
{
*(d + 0xa) = x >> 8;
*(d + 0xb) = x;
*(d + 0xc) = -y >> 8;
*(d + 0xd) = -y;
*(d + 0xa) = x >> 8, *(d + 0xb) = x;
*(d + 0xc) = -y >> 8, *(d + 0xd) = -y;
uxn_eval(u, PEEK2(d));
*(d + 0xa) = 0;
*(d + 0xb) = 0;
*(d + 0xc) = 0;
*(d + 0xd) = 0;
*(d + 0xa) = *(d + 0xb) = *(d + 0xc) = *(d + 0xd) = 0;
}

View File

@ -10,8 +10,6 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define MOUSE_VERSION 1
#define MOUSE_DEIMASK 0x0000
#define MOUSE_DEOMASK 0x0000
void mouse_down(Uxn *u, Uint8 *d, Uint8 mask);
void mouse_up(Uxn *u, Uint8 *d, Uint8 mask);

View File

@ -216,36 +216,32 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
Uint8 *port_x, *port_y, *port_addr;
Uint16 x, y, dx, dy, dxy, dyx, addr, addr_incr;
switch(port) {
case 0x3: {
Uint8 *port_width = d + 0x2;
screen_resize(PEEK2(port_width), uxn_screen.height);
} break;
case 0x5: {
Uint8 *port_height = d + 0x4;
screen_resize(uxn_screen.width, PEEK2(port_height));
} break;
case 0x3: screen_resize(PEEK2(d + 2), uxn_screen.height); break;
case 0x5: screen_resize(uxn_screen.width, PEEK2(d + 4)); break;
case 0xe: {
Uint8 ctrl = d[0xe];
Uint8 color = ctrl & 0x3;
Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg;
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
port_x = d + 0x8, port_y = d + 0xa;
x = PEEK2(port_x);
y = PEEK2(port_y);
Uint16 x = PEEK2(port_x), y = PEEK2(port_y);
/* fill mode */
if(ctrl & 0x80) {
Uint16 x2 = uxn_screen.width, y2 = uxn_screen.height;
if(ctrl & 0x10) x2 = x, x = 0;
if(ctrl & 0x20) y2 = y, y = 0;
if(!x && !y && x2 == uxn_screen.width && y2 == uxn_screen.height)
screen_fill(layer, color);
Uint16 x2, y2;
if(ctrl & 0x10)
x2 = x, x = 0;
else
screen_rect(layer, x, y, x2, y2, color);
x2 = uxn_screen.width;
if(ctrl & 0x20)
y2 = y, y = 0;
else
y2 = uxn_screen.height;
screen_rect(layer, x, y, x2, y2, color);
screen_change(x, y, x2, y2);
}
/* pixel mode */
else {
Uint16 w = uxn_screen.width, h = uxn_screen.height;
if(x < w && y < h)
Uint16 w = uxn_screen.width;
if(x < w && y < uxn_screen.height)
layer[x + y * w] = color;
screen_change(x, y, x + 1, y + 1);
if(d[0x6] & 0x1) POKE2(port_x, x + 1);
@ -259,8 +255,8 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
Uint8 move = d[0x6];
Uint8 length = move >> 4;
Uint8 twobpp = !!(ctrl & 0x80);
Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg;
Uint8 color = ctrl & 0xf;
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
int flipx = (ctrl & 0x10), fx = flipx ? -1 : 1;
int flipy = (ctrl & 0x20), fy = flipy ? -1 : 1;
port_x = d + 0x8, port_y = d + 0xa;
@ -281,11 +277,11 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
}
screen_change(x, y, x + dyx * length + 8, y + dxy * length + 8);
if(move & 0x1) {
x = x + dx * fx;
x += dx * fx;
POKE2(port_x, x);
}
if(move & 0x2) {
y = y + dy * fy;
y += dy * fy;
POKE2(port_y, y);
}
if(move & 0x4) POKE2(port_addr, addr); /* auto addr+length */

View File

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

View File

@ -10,8 +10,6 @@ WITH REGARD TO THIS SOFTWARE.
*/
#define SYSTEM_VERSION 2
#define SYSTEM_DEIMASK 0x0030
#define SYSTEM_DEOMASK 0xff38
#define RAM_PAGES 0x10

View File

@ -72,7 +72,7 @@ main(int argc, char **argv)
return system_error("usage", "uxncli [-v] file.rom [args..]");
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version("Uxncli - Console Varvara Emulator", "11 Nov 2023");
return system_version("Uxncli - Console Varvara Emulator", "2 Jan 2024");
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn.");
/* Game Loop */

View File

@ -105,7 +105,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
if(p > 0x7 && p < 0xe) screen_palette(&u->dev[0x8]);
break;
case 0x10: console_deo(&u->dev[d], p); break;
case 0x20: screen_deo(u->ram, &u->dev[d], p); break;
case 0x20: screen_deo(u->ram, &u->dev[0x20], p); break;
case 0x30: audio_deo(0, &u->dev[d], p, u); break;
case 0x40: audio_deo(1, &u->dev[d], p, u); break;
case 0x50: audio_deo(2, &u->dev[d], p, u); break;