commit dae025af20596a02a4fac6931f315d55bf488cd3
parent abd7ab403e6453b64a4bb799c1b6de081e9f19db
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Wed, 1 Mar 2023 11:28:14 -0800
Date and Screen devices DEI do no need device ptr
Diffstat:
6 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/src/devices/datetime.c b/src/devices/datetime.c
@@ -15,25 +15,25 @@ WITH REGARD TO THIS SOFTWARE.
*/
Uint8
-datetime_dei(Uint8 *d, Uint8 port)
+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;
- switch(port) {
- case 0x0: return (t->tm_year + 1900) >> 8;
- case 0x1: return (t->tm_year + 1900);
- case 0x2: return t->tm_mon;
- case 0x3: return t->tm_mday;
- case 0x4: return t->tm_hour;
- case 0x5: return t->tm_min;
- case 0x6: return t->tm_sec;
- case 0x7: return t->tm_wday;
- case 0x8: return t->tm_yday >> 8;
- case 0x9: return t->tm_yday;
- case 0xa: return t->tm_isdst;
- default: return d[port];
+ switch(addr) {
+ case 0xc0: return (t->tm_year + 1900) >> 8;
+ case 0xc1: return (t->tm_year + 1900);
+ case 0xc2: return t->tm_mon;
+ case 0xc3: return t->tm_mday;
+ case 0xc4: return t->tm_hour;
+ case 0xc5: return t->tm_min;
+ case 0xc6: return t->tm_sec;
+ case 0xc7: return t->tm_wday;
+ case 0xc8: return t->tm_yday >> 8;
+ case 0xc9: return t->tm_yday;
+ case 0xca: return t->tm_isdst;
+ default: return u->dev[addr];
}
}
diff --git a/src/devices/datetime.h b/src/devices/datetime.h
@@ -9,4 +9,4 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
-Uint8 datetime_dei(Uint8 *d, Uint8 port);
+Uint8 datetime_dei(Uxn *u, Uint8 addr);
diff --git a/src/devices/screen.c b/src/devices/screen.c
@@ -139,14 +139,14 @@ screen_mono(UxnScreen *p, Uint32 *pixels)
/* IO */
Uint8
-screen_dei(Uint8 *d, Uint8 port)
+screen_dei(Uxn *u, Uint8 addr)
{
- switch(port) {
- case 0x2: return uxn_screen.width >> 8;
- case 0x3: return uxn_screen.width;
- case 0x4: return uxn_screen.height >> 8;
- case 0x5: return uxn_screen.height;
- default: return d[port];
+ switch(addr) {
+ case 0x22: return uxn_screen.width >> 8;
+ case 0x23: return uxn_screen.width;
+ case 0x24: return uxn_screen.height >> 8;
+ case 0x25: return uxn_screen.height;
+ default: return u->dev[addr];
}
}
@@ -155,14 +155,12 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
{
switch(port) {
case 0x3:
- if(!FIXED_SIZE) {
+ if(!FIXED_SIZE)
screen_resize(&uxn_screen, clamp(PEEK16(d + 2), 1, 1024), uxn_screen.height);
- }
break;
case 0x5:
- if(!FIXED_SIZE) {
+ if(!FIXED_SIZE)
screen_resize(&uxn_screen, uxn_screen.width, clamp(PEEK16(d + 4), 1, 1024));
- }
break;
case 0xe: {
Uint16 x = PEEK16(d + 0x8), y = PEEK16(d + 0xa);
diff --git a/src/devices/screen.h b/src/devices/screen.h
@@ -31,6 +31,6 @@ void screen_clear(UxnScreen *p, Layer *layer);
void screen_redraw(UxnScreen *p, Uint32 *pixels);
void screen_mono(UxnScreen *p, Uint32 *pixels);
-Uint8 screen_dei(Uint8 *d, Uint8 port);
+Uint8 screen_dei(Uxn *u, Uint8 addr);
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
int clamp(int val, int min, int max);
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -52,7 +52,7 @@ emu_dei(Uxn *u, Uint8 addr)
switch(d) {
case 0xa0: return file_dei(0, &u->dev[d], p);
case 0xb0: return file_dei(1, &u->dev[d], p);
- case 0xc0: return datetime_dei(&u->dev[d], p);
+ case 0xc0: return datetime_dei(u, addr);
}
return u->dev[addr];
}
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -109,14 +109,14 @@ emu_dei(Uxn *u, Uint8 addr)
{
Uint8 p = addr & 0x0f, d = addr & 0xf0;
switch(d) {
- case 0x20: return screen_dei(&u->dev[d], p);
+ case 0x20: return screen_dei(u, addr);
case 0x30: return audio_dei(0, &u->dev[d], p);
case 0x40: return audio_dei(1, &u->dev[d], p);
case 0x50: return audio_dei(2, &u->dev[d], p);
case 0x60: return audio_dei(3, &u->dev[d], p);
case 0xa0: return file_dei(0, &u->dev[d], p);
case 0xb0: return file_dei(1, &u->dev[d], p);
- case 0xc0: return datetime_dei(&u->dev[d], p);
+ case 0xc0: return datetime_dei(u, addr);
}
return u->dev[addr];
}