Added stack pointer accessors to system device

This commit is contained in:
neauoire 2023-08-19 07:34:14 -07:00
parent c6a628e6ae
commit 15d09cf15b
5 changed files with 25 additions and 6 deletions

View File

@ -120,7 +120,7 @@ screen_resize(Uint16 width, Uint16 height)
{
Uint8 *bg, *fg;
Uint32 *pixels = NULL;
if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400)
if(width < 0x8 || height < 0x8 || width >= 0x800 || height >= 0x800)
return;
if(uxn_screen.width == width && uxn_screen.height == height)
return;

View File

@ -116,6 +116,16 @@ system_init(Uxn *u, Uint8 *ram, char *rom)
/* IO */
Uint8
system_dei(Uxn *u, Uint8 addr)
{
switch(addr) {
case 0x4: return u->wst.ptr;
case 0x5: return u->rst.ptr;
default: return u->dev[addr];
}
}
void
system_deo(Uxn *u, Uint8 *d, Uint8 port)
{
@ -134,6 +144,12 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)];
}
break;
case 0x4:
u->wst.ptr = d[4];
break;
case 0x5:
u->rst.ptr = d[5];
break;
case 0xe:
system_inspect(u);
break;

View File

@ -9,9 +9,9 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#define SYSTEM_VERSION 1
#define SYSTEM_DEIMASK 0x0000
#define SYSTEM_DEOMASK 0xff08
#define SYSTEM_VERSION 2
#define SYSTEM_DEIMASK 0x0030
#define SYSTEM_DEOMASK 0xff38
#define RAM_PAGES 0x10
@ -24,4 +24,5 @@ int system_version(Uxn *u, 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);
void system_deo(Uxn *u, Uint8 *d, Uint8 port);

View File

@ -24,6 +24,7 @@ Uint8
emu_dei(Uxn *u, Uint8 addr)
{
switch(addr & 0xf0) {
case 0x00: return system_dei(u, addr);
case 0xc0: return datetime_dei(u, addr);
}
return u->dev[addr];
@ -73,7 +74,7 @@ main(int argc, char **argv)
system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version(&u, "Uxncli - Console Varvara Emulator", "17 Aug 2023");
return system_version(&u, "Uxncli - Console Varvara Emulator", "19 Aug 2023");
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

@ -96,6 +96,7 @@ emu_dei(Uxn *u, Uint8 addr)
{
Uint8 p = addr & 0x0f, d = addr & 0xf0;
switch(d) {
case 0x00: return system_dei(u, addr);
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);
@ -516,7 +517,7 @@ main(int argc, char **argv)
system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return system_version(&u, "Uxnemu - Graphical Varvara Emulator", "17 Aug 2023");
return system_version(&u, "Uxnemu - Graphical Varvara Emulator", "19 Aug 2023");
if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0', 0);
if(!emu_init())