Removing uxn core indirection in dei deo
This commit is contained in:
parent
20b41ab70d
commit
eff62461a4
|
@ -97,10 +97,10 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
case 0x34: /* LDA2 */ t=T2; SET(2, 0) N = ram[t++]; T = ram[t]; break;
|
case 0x34: /* LDA2 */ t=T2; SET(2, 0) N = ram[t++]; T = ram[t]; break;
|
||||||
case 0x15: /* STA */ t=T2;n=L; SET(3,-3) ram[t] = n; break;
|
case 0x15: /* STA */ t=T2;n=L; SET(3,-3) ram[t] = n; break;
|
||||||
case 0x35: /* STA2 */ t=T2;n=N2; SET(4,-4) ram[t++] = n >> 8; ram[t] = n; break;
|
case 0x35: /* STA2 */ t=T2;n=N2; SET(4,-4) ram[t++] = n >> 8; ram[t] = n; break;
|
||||||
case 0x16: /* DEI */ t=T; SET(1, 0) T = emu_dei(u, t); break;
|
case 0x16: /* DEI */ t=T; SET(1, 0) T = emu_dei(t); break;
|
||||||
case 0x36: /* DEI2 */ t=T; SET(1, 1) N = emu_dei(u, t++); T = emu_dei(u, t); break;
|
case 0x36: /* DEI2 */ t=T; SET(1, 1) N = emu_dei(t++); T = emu_dei(t); break;
|
||||||
case 0x17: /* DEO */ t=T;n=N; SET(2,-2) emu_deo(u, t, n); break;
|
case 0x17: /* DEO */ t=T;n=N; SET(2,-2) emu_deo(t, n); break;
|
||||||
case 0x37: /* DEO2 */ t=T;n=N;l=L; SET(3,-3) emu_deo(u, t++, l); emu_deo(u, t, n); break;
|
case 0x37: /* DEO2 */ t=T;n=N;l=L; SET(3,-3) emu_deo(t++, l); emu_deo(t, n); break;
|
||||||
case 0x18: /* ADD */ t=T;n=N; SET(2,-1) T = n + t; break;
|
case 0x18: /* ADD */ t=T;n=N; SET(2,-1) T = n + t; break;
|
||||||
case 0x38: /* ADD2 */ t=T2;n=N2; SET(4,-2) T2_(n + t) break;
|
case 0x38: /* ADD2 */ t=T2;n=N2; SET(4,-2) T2_(n + t) break;
|
||||||
case 0x19: /* SUB */ t=T;n=N; SET(2,-1) T = n - t; break;
|
case 0x19: /* SUB */ t=T;n=N; SET(2,-1) T = n - t; break;
|
||||||
|
|
|
@ -35,8 +35,8 @@ typedef struct Uxn {
|
||||||
|
|
||||||
/* required functions */
|
/* required functions */
|
||||||
|
|
||||||
extern Uint8 emu_dei(Uxn *u, Uint8 addr);
|
extern Uint8 emu_dei(Uint8 addr);
|
||||||
extern void emu_deo(Uxn *u, Uint8 addr, Uint8 value);
|
extern void emu_deo(Uint8 addr, Uint8 value);
|
||||||
extern Uxn uxn;
|
extern Uxn uxn;
|
||||||
|
|
||||||
/* built-ins */
|
/* built-ins */
|
||||||
|
|
32
src/uxn11.c
32
src/uxn11.c
|
@ -45,32 +45,32 @@ clamp(int val, int min, int max)
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
emu_dei(Uxn *u, Uint8 addr)
|
emu_dei(Uint8 addr)
|
||||||
{
|
{
|
||||||
switch(addr & 0xf0) {
|
switch(addr & 0xf0) {
|
||||||
case 0x00: return system_dei(u, addr);
|
case 0x00: return system_dei(&uxn, addr);
|
||||||
case 0x10: return console_dei(u, addr);
|
case 0x10: return console_dei(&uxn, addr);
|
||||||
case 0x20: return screen_dei(u, addr);
|
case 0x20: return screen_dei(&uxn, addr);
|
||||||
case 0xc0: return datetime_dei(u, addr);
|
case 0xc0: return datetime_dei(&uxn, addr);
|
||||||
}
|
}
|
||||||
return u->dev[addr];
|
return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
emu_deo(Uxn *u, Uint8 addr, Uint8 value)
|
emu_deo(Uint8 addr, Uint8 value)
|
||||||
{
|
{
|
||||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||||
u->dev[addr] = value;
|
uxn.dev[addr] = value;
|
||||||
switch(d) {
|
switch(d) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
system_deo(u, &u->dev[d], p);
|
system_deo(&uxn, &uxn.dev[d], p);
|
||||||
if(p > 0x7 && p < 0xe)
|
if(p > 0x7 && p < 0xe)
|
||||||
screen_palette(&u->dev[0x8]);
|
screen_palette(&uxn.dev[0x8]);
|
||||||
break;
|
break;
|
||||||
case 0x10: console_deo(u, &u->dev[d], p); break;
|
case 0x10: console_deo(&uxn, &uxn.dev[d], p); break;
|
||||||
case 0x20: screen_deo(u->ram, &u->dev[d], p); break;
|
case 0x20: screen_deo(uxn.ram, &uxn.dev[d], p); break;
|
||||||
case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break;
|
case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break;
|
||||||
case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break;
|
case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ main(int argc, char **argv)
|
||||||
int i = 1;
|
int i = 1;
|
||||||
char *rom;
|
char *rom;
|
||||||
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
|
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
|
||||||
fprintf(stdout, "Uxn11 - Varvara Emulator, 5 Jun 2024.\n");
|
fprintf(stdout, "Uxn11 - Varvara Emulator, 29 Jun 2024.\n");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
rom = i == argc ? "boot.rom" : argv[i++];
|
rom = i == argc ? "boot.rom" : argv[i++];
|
||||||
|
@ -285,7 +285,7 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Game Loop */
|
/* Game Loop */
|
||||||
u.dev[0x17] = argc - i;
|
uxn.dev[0x17] = argc - i;
|
||||||
if(uxn_eval(&uxn, PAGE_PROGRAM)) {
|
if(uxn_eval(&uxn, PAGE_PROGRAM)) {
|
||||||
console_listen(&uxn, i, argc, argv);
|
console_listen(&uxn, i, argc, argv);
|
||||||
emu_run(&uxn);
|
emu_run(&uxn);
|
||||||
|
|
24
src/uxncli.c
24
src/uxncli.c
|
@ -21,26 +21,26 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
Uxn uxn;
|
Uxn uxn;
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
emu_dei(Uxn *u, Uint8 addr)
|
emu_dei(Uint8 addr)
|
||||||
{
|
{
|
||||||
switch(addr & 0xf0) {
|
switch(addr & 0xf0) {
|
||||||
case 0x00: return system_dei(u, addr);
|
case 0x00: return system_dei(&uxn, addr);
|
||||||
case 0x10: return console_dei(u, addr);
|
case 0x10: return console_dei(&uxn, addr);
|
||||||
case 0xc0: return datetime_dei(u, addr);
|
case 0xc0: return datetime_dei(&uxn, addr);
|
||||||
}
|
}
|
||||||
return u->dev[addr];
|
return uxn.dev[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
emu_deo(Uxn *u, Uint8 addr, Uint8 value)
|
emu_deo(Uint8 addr, Uint8 value)
|
||||||
{
|
{
|
||||||
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
Uint8 p = addr & 0x0f, d = addr & 0xf0;
|
||||||
u->dev[addr] = value;
|
uxn.dev[addr] = value;
|
||||||
switch(d) {
|
switch(d) {
|
||||||
case 0x00: system_deo(u, &u->dev[d], p); break;
|
case 0x00: system_deo(&uxn, &uxn.dev[d], p); break;
|
||||||
case 0x10: console_deo(u, &u->dev[d], p); break;
|
case 0x10: console_deo(&uxn, &uxn.dev[d], p); break;
|
||||||
case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break;
|
case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break;
|
||||||
case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break;
|
case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ main(int argc, char **argv)
|
||||||
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
||||||
/* Read flags */
|
/* Read flags */
|
||||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
return system_version("Uxncli - Console Varvara Emulator", "18 Mar 2024");
|
return system_version("Uxncli - Console Varvara Emulator", "29 Jun 2024");
|
||||||
if(!system_boot(&uxn, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
if(!system_boot(&uxn, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
||||||
return system_error("Init", "Failed to initialize uxn.");
|
return system_error("Init", "Failed to initialize uxn.");
|
||||||
/* Game Loop */
|
/* Game Loop */
|
||||||
|
|
Loading…
Reference in New Issue