The file device cannot write on the supervisor

This commit is contained in:
neauoire 2022-01-08 10:03:21 -08:00
parent 78f38e80e5
commit 5004ee1339
5 changed files with 26 additions and 17 deletions

View File

@ -67,7 +67,7 @@ BRK
@on-button ( -> )
.Controller/func DEI
.Controller/func DEI DUP DEBUG
DUP #02 ! ,&no-f2 JCN
;toggle-debugger JSR2
&no-f2
@ -124,7 +124,8 @@ BRK
@toggle-debugger ( -- )
( toggle debug ) #fd0e STH2k LDA #00 = STH2r STA
( toggle debug )
( #fd0e STH2k LDA #00 = STH2r STA )
RTN
@ -133,6 +134,9 @@ RTN
( clear devices/stacks )
#fd00 #0300 ;mclr JSR2
( load rom )
RTN
&boot-path "boot.rom $1

View File

@ -149,7 +149,7 @@ file_deo(Device *d, Uint8 port)
case 0x5:
DEVPEEK16(a, 0x4);
DEVPEEK16(b, 0xa);
res = file_stat(&d->mem[a], b);
res = file_stat(&memory[a], b);
DEVPOKE16(0x2, res);
break;
case 0x6:
@ -158,19 +158,19 @@ file_deo(Device *d, Uint8 port)
break;
case 0x9:
DEVPEEK16(a, 0x8);
res = file_init(&d->mem[a]);
res = file_init(&memory[a]);
DEVPOKE16(0x2, res);
break;
case 0xd:
DEVPEEK16(a, 0xc);
DEVPEEK16(b, 0xa);
res = file_read(&d->mem[a], b);
res = file_read(&memory[a], b);
DEVPOKE16(0x2, res);
break;
case 0xf:
DEVPEEK16(a, 0xe);
DEVPEEK16(b, 0xa);
res = file_write(&d->mem[a], b, d->dat[0x7]);
res = file_write(&memory[a], b, d->dat[0x7]);
DEVPOKE16(0x2, res);
break;
}

View File

@ -11,3 +11,5 @@ WITH REGARD TO THIS SOFTWARE.
*/
void file_deo(Device *d, Uint8 port);
extern Uint8 *memory;

View File

@ -4,6 +4,9 @@
#include <time.h>
#include "uxn.h"
Uint8 *supervisor_memory, *memory;
#include "devices/system.h"
#include "devices/file.h"
#include "devices/datetime.h"
@ -110,17 +113,15 @@ load(Uxn *u, char *filepath)
return 1;
}
static Uint8 *shadow, *memory;
int
main(int argc, char **argv)
{
Uxn u;
int i, loaded = 0;
shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
if(!uxn_boot(&u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST)))
return error("Boot", "Failed");
/* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo);

View File

@ -1,8 +1,11 @@
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include "uxn.h"
Uint8 *supervisor_memory, *memory;
#pragma GCC diagnostic push
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
@ -246,17 +249,15 @@ load(Uxn *u, char *rom)
return 1;
}
static Uint8 *shadow, *memory;
static int
start(Uxn *u, char *rom)
{
memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8));
supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8));
if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST)))
if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST)))
return error("Boot", "Failed to start uxn.");
if(!uxn_boot(u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST)))
if(!uxn_boot(u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST)))
return error("Boot", "Failed to start uxn.");
if(!load(&supervisor, "supervisor.rom"))
error("Supervisor", "No debugger found.");
@ -458,10 +459,11 @@ run(Uxn *u)
controller_key(devctrl, get_key(&event));
else if(get_button(&event))
controller_down(devctrl, get_button(&event));
/* else if(get_fkey(&event))
controller_special(&supervisor.dev[0x8], get_fkey(&event)); */
else
do_shortcut(u, &event);
/* function keys are sent to supervisor */
if(get_fkey(&event))
controller_special(&supervisor.dev[0x8], get_fkey(&event));
ksym = event.key.keysym.sym;
if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym)
break;