mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-27 08:13:01 +00:00
Rewrote the image routine
This commit is contained in:
parent
bf00513944
commit
e05290f235
5 changed files with 90 additions and 115 deletions
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler examples/devchord.usm bin/boot.rom
|
./bin/assembler examples/images.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -196,7 +196,7 @@ drawdebugger(Uint32 *dst, Uxn *u)
|
||||||
Uint8 x = (i % 8) * 3 + 3, y = i / 8 + 3, b = u->ram.dat[i];
|
Uint8 x = (i % 8) * 3 + 3, y = i / 8 + 3, b = u->ram.dat[i];
|
||||||
drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1, 0);
|
drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1, 0);
|
||||||
drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1, 0);
|
drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1, 0);
|
||||||
y = VER - i / 8, b = u->wst.dat[i];
|
y = VER - 1 + i / 8, b = u->wst.dat[i];
|
||||||
drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1 + (u->wst.ptr == i), 0);
|
drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1 + (u->wst.ptr == i), 0);
|
||||||
drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1 + (u->wst.ptr == i), 0);
|
drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1 + (u->wst.ptr == i), 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
( drag )
|
|
||||||
|
|
||||||
:dev/r fff8 ( std read port )
|
|
||||||
:dev/w fff9 ( std write port )
|
|
||||||
|
|
||||||
;dragx 2 ;dragy 2
|
|
||||||
;mousex 2 ;mousey 2
|
|
||||||
;lastx 2 ;lasty 2
|
|
||||||
;originx 2 ;originy 2
|
|
||||||
;down 1 ;state 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|
||||||
|
|
||||||
#05 =dev/r ( set dev/read mouse )
|
|
||||||
#02 =dev/w ( set dev/write to sprite )
|
|
||||||
,draw-picture JSR
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
|c000 @FRAME
|
|
||||||
|
|
||||||
( clear last cursor )
|
|
||||||
#10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR
|
|
||||||
( record mouse values )
|
|
||||||
#00 IOR2 =mousex #02 IOR2 =mousey
|
|
||||||
#04 IOR #11 ADD =state
|
|
||||||
( draw mouse )
|
|
||||||
~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR
|
|
||||||
( update last pos )
|
|
||||||
~mousex =lastx ~mousey =lasty
|
|
||||||
|
|
||||||
( get touch )
|
|
||||||
#05 IOR #01 EQU ,on-touch ROT JMP? POP2
|
|
||||||
#05 IOR #10 EQU ,on-release ROT JMP? POP2
|
|
||||||
#01 ~down EQU ,on-drag ROT JMP? POP2
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@on-touch
|
|
||||||
#01 =down
|
|
||||||
#00 IOR2 =originx #02 IOR2 =originy
|
|
||||||
,update JSR
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@on-release
|
|
||||||
#00 =down
|
|
||||||
,update JSR
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@on-drag
|
|
||||||
#00 IOR2 ~originx SUBS2 ~dragx ADDS2 =dragx
|
|
||||||
#02 IOR2 ~originy SUBS2 ~dragy ADDS2 =dragy
|
|
||||||
#00 IOR2 =originx #02 IOR2 =originy
|
|
||||||
,update JSR
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@update
|
|
||||||
,draw-picture JSR
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@draw-picture
|
|
||||||
#01 ,graphic #0040 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0008 ADD2 #0048 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0010 ADD2 #0050 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0018 ADD2 #0058 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0020 ADD2 #0040 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0028 ADD2 #0048 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0030 ADD2 #0050 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0038 ADD2 #0058 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0040 ADD2 #0040 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0048 ADD2 #0048 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0050 ADD2 #0050 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0058 ADD2 #0058 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0060 ADD2 #0040 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0068 ADD2 #0048 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0070 ADD2 #0050 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
#01 ,graphic #0078 ADD2 #0058 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@draw-sprite
|
|
||||||
IOW2 ( y byte )
|
|
||||||
IOW2 ( x byte )
|
|
||||||
IOW2 ( sprite address )
|
|
||||||
IOW ( layer-color )
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@clear_icn [ 0000 0000 0000 0000 ]
|
|
||||||
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
|
|
||||||
|
|
||||||
@graphic [
|
|
||||||
ff80 8080 8080 8088
|
|
||||||
ffff fffc f8f9 f1f4
|
|
||||||
ffff 0010 c721 2120
|
|
||||||
ffff 3f0f 0717 c343
|
|
||||||
8888 8080 8080 8080
|
|
||||||
f0f1 f2f5 f2f1 f0f4
|
|
||||||
1208 804c 9212 4c00
|
|
||||||
7303 0343 1b1b fbfb
|
|
||||||
8080 8f83 8383 8393
|
|
||||||
f0f3 f1f0 e4c0 80ff
|
|
||||||
00c7 c7c6 4606 00ff
|
|
||||||
c3d3 c307 870f 3fff
|
|
||||||
8f83 8383 8383 83ff
|
|
||||||
fff7 fdff c0e2 f1ff
|
|
||||||
7fef bfff 07af 5fff
|
|
||||||
ffff ffff ffff ffff
|
|
||||||
]
|
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|
||||||
|FFF0 [ f0ac f0bb f053 ] ( palette )
|
|
||||||
|FFFA .RESET .FRAME .ERROR ( vectors )
|
|
87
examples/images.usm
Normal file
87
examples/images.usm
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
( drag )
|
||||||
|
|
||||||
|
:dev/r fff8 ( std read port )
|
||||||
|
:dev/w fff9 ( std write port )
|
||||||
|
|
||||||
|
&Point { x 1 y 1 }
|
||||||
|
|
||||||
|
&Point2d { x 2 y 2 }
|
||||||
|
&Picture2d { x 2 y 2 width 1 height 1 color 1 addr 2 }
|
||||||
|
|
||||||
|
;pict Picture2d ;pictpt Point
|
||||||
|
|
||||||
|
|0100 @RESET
|
||||||
|
|
||||||
|
#05 =dev/r ( set dev/read mouse )
|
||||||
|
#02 =dev/w ( set dev/write to sprite )
|
||||||
|
|
||||||
|
#0030 #0042 #04 #04 #01 ,graphic ,draw-picture JSR
|
||||||
|
#0040 #0052 #04 #04 #02 ,graphic ,draw-picture JSR
|
||||||
|
#0050 #0062 #04 #04 #03 ,graphic ,draw-picture JSR
|
||||||
|
|
||||||
|
#0058 #0042 #04 #04 #05 ,graphic ,draw-picture JSR
|
||||||
|
#0068 #0052 #04 #04 #06 ,graphic ,draw-picture JSR
|
||||||
|
#0078 #0062 #04 #04 #07 ,graphic ,draw-picture JSR
|
||||||
|
|
||||||
|
#0080 #0042 #04 #04 #0a ,graphic ,draw-picture JSR
|
||||||
|
#0090 #0052 #04 #04 #0c ,graphic ,draw-picture JSR
|
||||||
|
#00a0 #0062 #04 #04 #0e ,graphic ,draw-picture JSR
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@draw-picture ( x y width height addr -> picture )
|
||||||
|
|
||||||
|
=pict.addr =pict.color =pict.height =pict.width =pict.y =pict.x
|
||||||
|
#00 =pictpt.y
|
||||||
|
@draw-picture-row
|
||||||
|
#00 =pictpt.x
|
||||||
|
@draw-picture-col
|
||||||
|
( draw )
|
||||||
|
~pict.color
|
||||||
|
~pict.addr
|
||||||
|
#0008 #00 ~pictpt.x MUL2 ADD2 ( x )
|
||||||
|
#0008 #00 ~pictpt.y ~pict.width MUL MUL2 ADD2 ( y * width )
|
||||||
|
~pict.x #0008 #00 ~pictpt.x MUL2 ADD2
|
||||||
|
~pict.y #0008 #00 ~pictpt.y MUL2 ADD2
|
||||||
|
,draw-sprite JSR
|
||||||
|
( draw - end )
|
||||||
|
( incr x ) ~pictpt.x #01 ADD =pictpt.x
|
||||||
|
~pictpt.x ~pict.width LTH ,draw-picture-col ROT JMP? POP2
|
||||||
|
( incr y ) ~pictpt.y #01 ADD =pictpt.y
|
||||||
|
~pictpt.y ~pict.height LTH ,draw-picture-row ROT JMP? POP2
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@draw-sprite
|
||||||
|
IOW2 ( y byte )
|
||||||
|
IOW2 ( x byte )
|
||||||
|
IOW2 ( sprite address )
|
||||||
|
IOW ( layer-color )
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@clear_icn [ 0000 0000 0000 0000 ]
|
||||||
|
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
|
||||||
|
|
||||||
|
@graphic [
|
||||||
|
ff80 8080 8080 8088
|
||||||
|
ffff fffc f8f9 f1f4
|
||||||
|
ffff 0010 c721 2120
|
||||||
|
ffff 3f0f 0717 c343
|
||||||
|
8888 8080 8080 8080
|
||||||
|
f0f1 f2f5 f2f1 f0f4
|
||||||
|
1208 804c 9212 4c00
|
||||||
|
7303 0343 1b1b fbfb
|
||||||
|
8080 8f83 8383 8393
|
||||||
|
f0f3 f1f0 e4c0 80ff
|
||||||
|
00c7 c7c6 4606 00ff
|
||||||
|
c3d3 c307 870f 3fff
|
||||||
|
8f83 8383 8383 83ff
|
||||||
|
fff7 fdff c0e2 f1ff
|
||||||
|
7fef bfff 07af 5fff
|
||||||
|
ffff ffff ffff ffff
|
||||||
|
]
|
||||||
|
|
||||||
|
|c000 @FRAME BRK
|
||||||
|
|d000 @ERROR BRK
|
||||||
|
|FFF0 [ f0ac f0bb f053 ] ( palette )
|
||||||
|
|FFFA .RESET .FRAME .ERROR ( vectors )
|
2
uxn.c
2
uxn.c
|
@ -108,7 +108,7 @@ Uint8 opr[][2] = {
|
||||||
{1,0}, {1,2}, {2,2}, {2,3}, {3,3}, {1,0}, {0,1}, {2,1},
|
{1,0}, {1,2}, {2,2}, {2,3}, {3,3}, {1,0}, {0,1}, {2,1},
|
||||||
{2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1},
|
{2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1},
|
||||||
/* 16-bit */
|
/* 16-bit */
|
||||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, /* TODO */
|
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {2,2}, {4,0}, /* TODO */
|
||||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, /* TODO */
|
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, /* TODO */
|
||||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {1,0}, {0,1}, {0,0}, /* TODO */
|
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {1,0}, {0,1}, {0,0}, /* TODO */
|
||||||
{4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}
|
{4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}, {4,2}
|
||||||
|
|
Loading…
Reference in a new issue