Implemented file vectors in nasu/noodle
This commit is contained in:
parent
56a3a993f4
commit
f3e58adc03
2
build.sh
2
build.sh
|
@ -32,7 +32,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Assembling.."
|
echo "Assembling.."
|
||||||
./bin/assembler projects/examples/dev.file.usm bin/boot.rom
|
./bin/assembler projects/software/noodle.usm bin/boot.rom
|
||||||
|
|
||||||
echo "Running.."
|
echo "Running.."
|
||||||
if [ "${2}" = '--cli' ];
|
if [ "${2}" = '--cli' ];
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|
||||||
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|
||||||
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
|
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
|
||||||
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 }
|
||||||
|
|
||||||
( program )
|
( program )
|
||||||
|
|
||||||
|
@ -16,22 +16,29 @@
|
||||||
|
|
||||||
( theme ) #ac52 =System.r #a362 =System.g #b253 =System.b
|
( theme ) #ac52 =System.r #a362 =System.g #b253 =System.b
|
||||||
( vectors ) ,on-mouse =Mouse.vector
|
( vectors ) ,on-mouse =Mouse.vector
|
||||||
|
( vectors ) ,on-transfer =File.vector
|
||||||
|
|
||||||
( load )
|
( load )
|
||||||
|
|
||||||
#0000 #0000 #0100 #0100 #2c ,pict_large ,draw-picture JSR2
|
#0000 #0000 #0100 #0100 #2c ,pict_large ,draw-picture JSR2
|
||||||
|
|
||||||
( load ) ,filepath =File.name #4000 =File.length ,img =File.load
|
|
||||||
( draw ) #0080 #0020 #0100 #0100 #41 ,img ,draw-chr JSR2
|
|
||||||
|
|
||||||
#0128 #0010 #0080 #0080 #2e ,pict_medium ,draw-picture JSR2
|
#0128 #0010 #0080 #0080 #2e ,pict_medium ,draw-picture JSR2
|
||||||
#0020 #00d0 #0020 #0020 #25 ,pict_small ,draw-picture JSR2
|
#0020 #00d0 #0020 #0020 #25 ,pict_small ,draw-picture JSR2
|
||||||
|
|
||||||
#0010 #0010 #0020 #0010 #25 ,dvd_icn ,draw-picture JSR2
|
#0010 #0010 #0020 #0010 #25 ,dvd_icn ,draw-picture JSR2
|
||||||
|
|
||||||
|
( load ) ,filepath =File.name #4000 =File.length ,img =File.load
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse
|
@on-transfer ( -> )
|
||||||
|
|
||||||
|
( draw ) #0080 #0020 #0100 #0100 #41 ,img ,draw-chr JSR2
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@on-mouse ( -> )
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
,clear_icn =Screen.addr
|
,clear_icn =Screen.addr
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
( theme ) #e0fc =System.r #30cc =System.g #30ac =System.b
|
( theme ) #e0fc =System.r #30cc =System.g #30ac =System.b
|
||||||
( vectors ) ,on-button =Controller.vector
|
( vectors ) ,on-button =Controller.vector
|
||||||
( vectors ) ,on-mouse =Mouse.vector
|
( vectors ) ,on-mouse =Mouse.vector
|
||||||
|
( vectors ) ,on-transfer =File.vector
|
||||||
|
|
||||||
~Screen.width 2/ #008a SUB2 =bankview.x
|
~Screen.width 2/ #008a SUB2 =bankview.x
|
||||||
~Screen.height 2/ #003f SUB2 =bankview.y
|
~Screen.height 2/ #003f SUB2 =bankview.y
|
||||||
|
@ -61,7 +62,13 @@
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-button
|
@on-transfer ( -> )
|
||||||
|
|
||||||
|
,redraw JSR2
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@on-button ( -> )
|
||||||
|
|
||||||
~Controller.button
|
~Controller.button
|
||||||
DUP #10 EQU ^$no-ctrl-up JNZ
|
DUP #10 EQU ^$no-ctrl-up JNZ
|
||||||
|
@ -83,7 +90,7 @@ BRK
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse
|
@on-mouse ( -> )
|
||||||
|
|
||||||
~Mouse.state #00 EQU ,$click-end JNZ2
|
~Mouse.state #00 EQU ,$click-end JNZ2
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
( vectors ) ,on-screen =Screen.vector
|
( vectors ) ,on-screen =Screen.vector
|
||||||
( vectors ) ,on-button =Controller.vector
|
( vectors ) ,on-button =Controller.vector
|
||||||
( vectors ) ,on-mouse =Mouse.vector
|
( vectors ) ,on-mouse =Mouse.vector
|
||||||
|
( vectors ) ,on-transfer =File.vector
|
||||||
|
|
||||||
~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
|
~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
|
||||||
|
|
||||||
|
@ -79,7 +80,6 @@
|
||||||
|
|
||||||
( load file )
|
( load file )
|
||||||
,untitled_txt ,path.name ,strcpy JSR2
|
,untitled_txt ,path.name ,strcpy JSR2
|
||||||
,path.name ,load-file JSR2
|
|
||||||
|
|
||||||
( setup panes )
|
( setup panes )
|
||||||
#0010 =toolpane.x1 #0010 =toolpane.y1 ~toolpane.x1 #0028 ADD2 =toolpane.x2 ~toolpane.y1 #0008 ADD2 =toolpane.y2
|
#0010 =toolpane.x1 #0010 =toolpane.y1 ~toolpane.x1 #0028 ADD2 =toolpane.x2 ~toolpane.y1 #0008 ADD2 =toolpane.y2
|
||||||
|
@ -91,9 +91,19 @@
|
||||||
,center JSR2
|
,center JSR2
|
||||||
,clear JSR2
|
,clear JSR2
|
||||||
|
|
||||||
|
( load default file )
|
||||||
|
,path.name ,load-file JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-screen ( -- )
|
@on-transfer ( -> )
|
||||||
|
|
||||||
|
,draw-canvas JSR2
|
||||||
|
( release ) #00 =Mouse.state
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@on-screen ( -> )
|
||||||
|
|
||||||
~document.edit #01 NEQ ^$no-edit JNZ
|
~document.edit #01 NEQ ^$no-edit JNZ
|
||||||
#0008 =Screen.x
|
#0008 =Screen.x
|
||||||
|
@ -108,7 +118,7 @@ BRK
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@on-mouse
|
@on-mouse ( -> )
|
||||||
|
|
||||||
,draw-cursor JSR2
|
,draw-cursor JSR2
|
||||||
|
|
||||||
|
|
|
@ -218,15 +218,15 @@ file_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
{
|
{
|
||||||
Uint8 *m = u->ram.dat;
|
Uint8 *m = u->ram.dat;
|
||||||
char *name = (char *)&m[(m[ptr + 8] << 8) + m[ptr + 8 + 1]];
|
char *name = (char *)&m[(m[ptr + 8] << 8) + m[ptr + 8 + 1]];
|
||||||
Uint16 length = (m[ptr + 8 + 2] << 8) + m[ptr + 8 + 3];
|
Uint16 length = mempeek16(u, ptr + 8 + 2);
|
||||||
Uint16 offset = (m[ptr + 2] << 8) + m[ptr + 3];
|
Uint16 offset = mempeek16(u, ptr + 2);
|
||||||
if(b0 == 0x0d) {
|
if(b0 == 0x0d) {
|
||||||
Uint16 addr = (m[ptr + 8 + 4] << 8) + b1;
|
Uint16 addr = (m[ptr + 8 + 4] << 8) + b1;
|
||||||
FILE *f = fopen(name, "r");
|
FILE *f = fopen(name, "r");
|
||||||
if(f && fseek(f, offset, SEEK_SET) != -1 && fread(&m[addr], length, 1, f)) {
|
if(f && fseek(f, offset, SEEK_SET) != -1 && fread(&m[addr], length, 1, f)) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
printf("Loaded %d bytes, at %04x from %s\n", length, addr, name);
|
printf("Loaded %d bytes, at %04x from %s\n", length, addr, name);
|
||||||
evaluxn(u, devfile->vector);
|
evaluxn(u, mempeek16(u, devfile->addr));
|
||||||
}
|
}
|
||||||
} else if(b0 == 0x0f) {
|
} else if(b0 == 0x0f) {
|
||||||
Uint16 addr = (m[ptr + 8 + 6] << 8) + b1;
|
Uint16 addr = (m[ptr + 8 + 6] << 8) + b1;
|
||||||
|
@ -234,7 +234,7 @@ file_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
if(f && fseek(f, offset, SEEK_SET) != -1 && fwrite(&m[addr], length, 1, f)) {
|
if(f && fseek(f, offset, SEEK_SET) != -1 && fwrite(&m[addr], length, 1, f)) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
printf("Saved %d bytes, at %04x from %s\n", length, addr, name);
|
printf("Saved %d bytes, at %04x from %s\n", length, addr, name);
|
||||||
evaluxn(u, devfile->vector);
|
evaluxn(u, mempeek16(u, devfile->addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b1;
|
return b1;
|
||||||
|
@ -293,9 +293,8 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
Uint8
|
Uint8
|
||||||
system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
{
|
{
|
||||||
Uint8 *m = u->ram.dat;
|
u->ram.dat[ptr + b0] = b1;
|
||||||
m[PAGE_DEVICE + b0] = b1;
|
getcolors(&ppu, &u->ram.dat[ptr + 0x0008]);
|
||||||
getcolors(&ppu, &m[PAGE_DEVICE + 0x0008]);
|
|
||||||
reqdraw = 1;
|
reqdraw = 1;
|
||||||
(void)ptr;
|
(void)ptr;
|
||||||
return b1;
|
return b1;
|
||||||
|
@ -315,7 +314,7 @@ ppnil(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
|
||||||
int
|
int
|
||||||
start(Uxn *u)
|
start(Uxn *u)
|
||||||
{
|
{
|
||||||
inituxn(u, 0x0200);
|
evaluxn(u, 0x0200);
|
||||||
redraw(ppu.output, u);
|
redraw(ppu.output, u);
|
||||||
while(1) {
|
while(1) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -333,14 +332,14 @@ start(Uxn *u)
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
doctrl(u, &event, event.type == SDL_KEYDOWN);
|
doctrl(u, &event, event.type == SDL_KEYDOWN);
|
||||||
evaluxn(u, devctrl->vector);
|
evaluxn(u, mempeek16(u, devctrl->addr));
|
||||||
u->ram.dat[devctrl->addr + 3] = 0;
|
u->ram.dat[devctrl->addr + 3] = 0;
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
domouse(u, &event);
|
domouse(u, &event);
|
||||||
evaluxn(u, devmouse->vector);
|
evaluxn(u, mempeek16(u, devmouse->addr));
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if(event.window.event == SDL_WINDOWEVENT_EXPOSED)
|
if(event.window.event == SDL_WINDOWEVENT_EXPOSED)
|
||||||
|
@ -348,7 +347,7 @@ start(Uxn *u)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
evaluxn(u, devscreen->vector);
|
evaluxn(u, mempeek16(u, devscreen->addr));
|
||||||
SDL_UnlockAudioDevice(audio_id);
|
SDL_UnlockAudioDevice(audio_id);
|
||||||
if(reqdraw)
|
if(reqdraw)
|
||||||
redraw(ppu.output, u);
|
redraw(ppu.output, u);
|
||||||
|
|
11
src/uxn.c
11
src/uxn.c
|
@ -151,17 +151,6 @@ evaluxn(Uxn *u, Uint16 vec)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
inituxn(Uxn *u, Uint16 vec)
|
|
||||||
{
|
|
||||||
Uint8 i = 0;
|
|
||||||
if(!evaluxn(u, vec))
|
|
||||||
return 0;
|
|
||||||
for(i = 0; i < 0x10; ++i)
|
|
||||||
u->dev[i].vector = mempeek16(u, u->dev[i].addr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
bootuxn(Uxn *u)
|
bootuxn(Uxn *u)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef struct {
|
||||||
struct Uxn;
|
struct Uxn;
|
||||||
|
|
||||||
typedef struct Device {
|
typedef struct Device {
|
||||||
Uint16 addr, vector;
|
Uint16 addr;
|
||||||
Uint8 (*poke)(struct Uxn *, Uint16, Uint8, Uint8);
|
Uint8 (*poke)(struct Uxn *, Uint16, Uint8, Uint8);
|
||||||
} Device;
|
} Device;
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ typedef struct Uxn {
|
||||||
|
|
||||||
int loaduxn(Uxn *c, char *filepath);
|
int loaduxn(Uxn *c, char *filepath);
|
||||||
int bootuxn(Uxn *c);
|
int bootuxn(Uxn *c);
|
||||||
int inituxn(Uxn *u, Uint16 vec);
|
|
||||||
int evaluxn(Uxn *u, Uint16 vec);
|
int evaluxn(Uxn *u, Uint16 vec);
|
||||||
void mempoke16(Uxn *u, Uint16 a, Uint16 b);
|
void mempoke16(Uxn *u, Uint16 a, Uint16 b);
|
||||||
Uint16 mempeek16(Uxn *u, Uint16 a);
|
Uint16 mempeek16(Uxn *u, Uint16 a);
|
||||||
|
|
Loading…
Reference in New Issue