started drag example
This commit is contained in:
parent
1beb714ce1
commit
36bfb2a417
|
@ -140,6 +140,8 @@ makevariable(char *id, Uint16 *addr, FILE *f)
|
||||||
char wv[64];
|
char wv[64];
|
||||||
Uint8 origin;
|
Uint8 origin;
|
||||||
fscanf(f, "%s", wv);
|
fscanf(f, "%s", wv);
|
||||||
|
if(!sihx(wv))
|
||||||
|
return error("Variable value is invalid", wv);
|
||||||
origin = *addr;
|
origin = *addr;
|
||||||
*addr += shex(wv);
|
*addr += shex(wv);
|
||||||
return makelabel(id, origin, shex(wv));
|
return makelabel(id, origin, shex(wv));
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -19,5 +19,5 @@ rm -f ./bin/emulator
|
||||||
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator
|
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler examples/controller.usm bin/boot.rom
|
./bin/assembler examples/drag.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -252,8 +252,10 @@ screenw(Device *d, Memory *m, Uint8 b)
|
||||||
(d->mem[2] << 8) + d->mem[3],
|
(d->mem[2] << 8) + d->mem[3],
|
||||||
(d->mem[0] << 8) + d->mem[1],
|
(d->mem[0] << 8) + d->mem[1],
|
||||||
d->mem[4]);
|
d->mem[4]);
|
||||||
if(d->mem[5])
|
if(d->mem[5] == 1)
|
||||||
REQDRAW = 1;
|
REQDRAW = 1;
|
||||||
|
if(d->mem[5] == 2)
|
||||||
|
clear(pixels);
|
||||||
d->ptr = 0;
|
d->ptr = 0;
|
||||||
}
|
}
|
||||||
(void)m;
|
(void)m;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
( comment )
|
( controller )
|
||||||
|
|
||||||
:dev/r fff8 ( const read port )
|
:dev/r fff8 ( const read port )
|
||||||
:dev/w fff9 ( const write port )
|
:dev/w fff9 ( const write port )
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
( drag )
|
||||||
|
|
||||||
|
:dev/r fff8 ( std read port )
|
||||||
|
:dev/w fff9 ( std write port )
|
||||||
|
|
||||||
|
;drawx 2 ;drawy 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
|
||||||
|
|
||||||
|
|0100 @RESET
|
||||||
|
|
||||||
|
#05 =dev/r ( set dev/read mouse )
|
||||||
|
#01 =dev/w ( set dev/write to screen )
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
|c000 @FRAME
|
||||||
|
|
||||||
|
( get touch )
|
||||||
|
#04 IOR #01 NEQ ,frame-end ROT JMP? POP2
|
||||||
|
|
||||||
|
( clear )
|
||||||
|
#00 =color
|
||||||
|
~x ~y #0060 #0040 ,fillrect JSR
|
||||||
|
|
||||||
|
( fill rect x y w h )
|
||||||
|
#01 =color
|
||||||
|
#00 IOR2 ( get mouse-x ) =x
|
||||||
|
#02 IOR2 ( get mouse-y ) =y
|
||||||
|
~x ~y #0060 #0040 ,fillrect JSR
|
||||||
|
|
||||||
|
,redraw JSR
|
||||||
|
|
||||||
|
@frame-end
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@fillrect
|
||||||
|
=h =w =y =x ( store values in variables )
|
||||||
|
~x =drawx ~y =drawy ( store draw pos in variables )
|
||||||
|
@fillrectrow
|
||||||
|
~x =drawx
|
||||||
|
@fillrectcol
|
||||||
|
( draw ) ~drawx ~drawy IOW2 IOW2 ~color IOW #00 IOW
|
||||||
|
~drawx #0001 ADD2 =drawx
|
||||||
|
~drawx ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2
|
||||||
|
~drawy #0001 ADD2 =drawy
|
||||||
|
~drawy ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@getmouse
|
||||||
|
#00 IOR2 ( get mouse x )
|
||||||
|
#02 IOR2 ( get mouse y )
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@redraw
|
||||||
|
#0000 IOW2
|
||||||
|
#0000 IOW2
|
||||||
|
#00 IOW
|
||||||
|
#01 IOW
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@clear
|
||||||
|
#0000 IOW2
|
||||||
|
#0000 IOW2
|
||||||
|
#00 IOW
|
||||||
|
#02 IOW
|
||||||
|
RTS
|
||||||
|
|
||||||
|
|d000 @ERROR BRK
|
||||||
|
|FFFA .RESET .FRAME .ERROR
|
|
@ -1,4 +1,4 @@
|
||||||
( comment )
|
( hello world )
|
||||||
|
|
||||||
:dev/w fff9 ( const write port )
|
:dev/w fff9 ( const write port )
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ BRK
|
||||||
|
|
||||||
@displaygui
|
@displaygui
|
||||||
#02 =dev/w ( set dev/write to sprite )
|
#02 =dev/w ( set dev/write to sprite )
|
||||||
@displayguiloop
|
@guiloop
|
||||||
DUP2 LDR ,printchar JSR
|
DUP2 LDR ,printchar JSR
|
||||||
#0001 ADD2
|
#0001 ADD2
|
||||||
~x #0008 ADD2 =x
|
~x #0008 ADD2 =x
|
||||||
DUP2 LDR #00 NEQ ,displayguiloop ROT JMP? POP2
|
DUP2 LDR #00 NEQ ,guiloop ROT JMP? POP2
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@printchar
|
@printchar
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
( my default test file )
|
( pixels )
|
||||||
|
|
||||||
:dev/r fff8 ( std read port )
|
:dev/r fff8 ( std read port )
|
||||||
:dev/w fff9 ( std write port )
|
:dev/w fff9 ( std write port )
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
( comment )
|
( sprite )
|
||||||
|
|
||||||
:dev/w fff9 ( const write port )
|
:dev/w fff9 ( const write port )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue