Starting status bar

This commit is contained in:
neauoire 2023-12-13 20:14:51 -08:00
parent 5f543a97d4
commit ed415f9a00
4 changed files with 359 additions and 7 deletions

View File

@ -5,7 +5,7 @@ ASM=bin/uxnasm
.PHONY: all dest run install uninstall format clean
all: dest bin/uxnasm bin/porporo bin/menu.rom bin/wallpaper.rom bin/log.rom
all: dest bin/uxnasm bin/porporo bin/menu.rom bin/potato.rom bin/wallpaper.rom bin/log.rom
dest:
@ mkdir -p bin
@ -27,6 +27,8 @@ bin/porporo: ${SRC} src/porporo.c
bin/menu.rom: src/utils/menu.tal src/utils/menu.assets.tal
@ ${ASM} src/utils/menu.tal bin/menu.rom
bin/potato.rom: src/utils/potato.tal src/utils/potato.assets.tal
@ ${ASM} src/utils/potato.tal bin/potato.rom
bin/wallpaper.rom: src/utils/wallpaper.tal
@ ${ASM} src/utils/wallpaper.tal bin/wallpaper.rom
bin/log.rom: src/utils/log.tal src/utils/log.assets.tal

View File

@ -34,7 +34,7 @@ static enum Action action;
static Uint8 *ram, cursor_icn[] = {0xff, 0xfe, 0xfc, 0xf8, 0xfc, 0xee, 0xc7, 0x82};
static Uint32 *pixels, palette[] = {0xeeeeee, 0x000000, 0x72DEC2, 0xffb545};
static int WIDTH, HEIGHT, reqdraw, olen;
static Varvara varvaras[RAM_PAGES], *order[RAM_PAGES], *menu, *wallpaper, *focused;
static Varvara varvaras[RAM_PAGES], *order[RAM_PAGES], *wallpaper, *menu, *focused, *potato;
static Point2d camera, drag, cursor;
static SDL_DisplayMode DM;
static SDL_Window *gWindow = NULL;
@ -295,6 +295,15 @@ por_close(Varvara *v)
por_pop(v);
}
static void
por_setaction(enum Action a)
{
Uint16 vector = PEEK2(&potato->u.ram[0x0000]);
action = a, reqdraw |= 1;
potato->u.ram[0x0002] = a;
uxn_eval(&potato->u, vector);
}
static void
por_menu(int x, int y)
{
@ -302,7 +311,8 @@ por_menu(int x, int y)
por_pop(menu);
menu->u.dev[0x0f] = 0;
uxn_eval(&menu->u, PAGE_PROGRAM);
action = NORMAL, drag.mode = 0;
por_setaction(NORMAL);
drag.mode = 0;
por_push(menu, x, y, 0);
}
@ -503,9 +513,9 @@ on_controller_special(char c, Uint8 fkey)
}
}
switch(c) {
case 0x1b: action = NORMAL, reqdraw |= 1; return;
case 'd': action = action == DRAW ? NORMAL : DRAW, reqdraw |= 1; return;
case 'm': action = action == MOVE ? NORMAL : MOVE, reqdraw |= 1; return;
case 0x1b: por_setaction(NORMAL); return;
case 'd': por_setaction(action == DRAW ? NORMAL : DRAW); return;
case 'm': por_setaction(action == MOVE ? NORMAL : MOVE); return;
}
}
@ -644,9 +654,10 @@ main(int argc, char **argv)
load_theme();
menu = por_spawn(0, "bin/menu.rom", 0);
wallpaper = por_push(por_spawn(1, "bin/wallpaper.rom", 1), 0, 0, 1);
potato = por_push(por_spawn(2, "bin/potato.rom", 1), 0x10, 0x10, 1);
/* load from arguments */
for(i = 1; i < argc; i++) {
Varvara *a = por_push(por_spawn(i + 1, argv[i], 1), anchor + 0x10, 0x10, 0);
Varvara *a = por_push(por_spawn(i + 2, argv[i], 1), anchor + 0x10, 0x10, 0);
anchor += a->screen.w + 0x10;
}
/* event loop */

208
src/utils/potato.assets.tal Normal file
View File

@ -0,0 +1,208 @@
@font-uf2 [
0405 0509 0709 0903 0505 0807 0407 0307
0808 0808 0808 0808 0808 0304 0607 0608
0a09 0908 0807 0708 0806 0708 070b 0a08
0808 0808 0809 090b 0707 0706 0706 0408
0108 0807 0707 0607 0704 0606 040b 0707
0807 0607 0608 070a 0707 0705 0405 0801
0908 0807 0908 0908 0808 0808 0807 0707
0707 0505 0505 0707 0707 0707 0808 0808
&glyphs
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1010 1010 2020 2000 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0050 5050 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0001 0a3f 147e 2420 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0008 3854 5030 1028 24a4 7820 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3e51 9264 0816 2949 8600 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0018 2424 2830 508a 848a 7100 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0040 4040 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0008 1020 2040 4040 4040 2020 1000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 1008 0808 0808 0810 1020 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 4428 fe28 4402 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1010 7c10 1000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 2020 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 7e00 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0004 0408 0810 1020 2040 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0018 2442 4282 8282 8244 3800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0808 0808 0808 1010 1000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c42 0204 1820 4080 fc00 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c22 0418 0402 8284 7800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2022 4244 84fe 0408 0808 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3e40 8070 0804 0484 7800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0010 2040 409c a2c2 8244 3800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7e82 0404 0808 1010 1000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0018 2444 4830 4884 8484 7800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 7884 8282 423e 0404 0810 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0020 0000 0000 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0010 1000 0000 2020 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0408 1020 2010 0800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 7c00 7c00 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 4020 1008 0810 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3c42 0204 0810 2000 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 001f 204e 5253 4c21 1e00 0000 0000
0000 0000 8080 8000 0000 0000 0000 0000
0001 0305 0912 1227 fa42 8280 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0e11 1122 2621 4141 829c 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c22 4480 8080 8044 3800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0010 7824 2242 4242 8284 f800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c20 4040 7880 8080 7800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c20 4040 7880 8080 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0c30 4080 8c92 8244 3800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2222 2242 7c44 8488 8800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0808 1010 1010 2020 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0e34 0404 0448 8888 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1126 2830 2050 4844 4200 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1010 2020 2040 4040 3c00 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0008 1818 292a 4a4c 4881 8100 0000 0000
0000 40c0 4040 4080 8000 0000 0000 0000
0000 1010 2829 2945 4542 4200 0000 0000
0000 8080 8000 0000 0000 0000 0000 0000
0000 3844 8282 8284 8448 3000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c22 4242 8498 8080 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1824 4242 8284 9448 3400 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3844 8488 f0a0 9088 8402 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1c22 2018 0442 8284 7800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0004 7e08 0810 1010 2020 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2121 4142 8282 8244 3800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 4142 4244 2428 2810 1000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 8080 8888 4955 5522 2200 0000 0000
0000 4040 8080 0000 0000 0000 0000 0000
0004 4428 2810 1028 4844 8400 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 8444 2828 1010 1020 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3cc4 0810 1020 408c f000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0018 2020 2020 4040 4040 4030 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 2020 1010 1010 0808 0808 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0018 0404 0408 0808 1010 1060 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2050 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 ff00 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1e22 4284 848c 7400 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 2040 5864 4242 8284 b800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 3844 8880 8088 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0002 0204 043c 4484 8888 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 3844 84f8 8088 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
000c 1020 2078 2020 4040 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1824 4444 8c94 6808 9060 0000
0000 0000 0000 0000 0000 0000 0000 0000
0020 4040 98a4 c4c4 8888 9000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1000 2020 2020 4040 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0400 0404 0408 0808 1010 9060 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2020 4048 5060 a090 8800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 2020 2040 4040 8080 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 5867 4444 8888 8800 0000 0000
0000 0000 0080 4040 4080 8000 0000 0000
0000 0000 5864 4484 8488 8800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1824 4484 8488 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 2834 2222 2244 5840 8080 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 344c 4484 8c94 6808 1010 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 5c60 4040 8080 8000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1824 4038 0488 7000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 1010 f820 2020 4040 4000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 2242 4484 8c94 6400 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0002 8484 8848 5020 2000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0091 91aa aa44 4400 0000 0000
0000 0000 8000 0000 0000 0000 0000 0000
0000 0000 4448 2810 2848 4480 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 8484 8850 5020 2040 4080 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 7c88 1020 4084 f800 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1820 2040 4040 8040 4040 4040 3000 0000
0000 0000 0000 0000 0000 0000 0000 0000
1010 1010 2020 2020 2020 4040 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
2010 1010 1008 1010 1010 2020 4000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 3946 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 1c3e 7e7e 7c38 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 ]
@mem &filepath $80 &dir $800
&folders $200
&roms $200
&misc $200

131
src/utils/potato.tal Normal file
View File

@ -0,0 +1,131 @@
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@action &vector $2 &value $1
|0100
@on-reset ( -> )
;meta #06 DEO2
#f17a .System/r DEO2
#f1da .System/g DEO2
#f1ba .System/b DEO2
<load-theme>
.Screen/width DEI2 #0020 SUB2 .Screen/width DEO2
#0018 .Screen/height DEO2
;on-mouse .Mouse/vector DEO2
;on-control .Controller/vector DEO2
<redraw>
( | register routines )
;on-action .action/vector STZ2
( #010e DEO ) BRK
@meta $1
( name ) "Potato(Porporo) 0a
( desc ) "Menu 20 "Bar 0a
( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
( date ) "13 20 "Dec 20 "2023 $1
( exts ) 00
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn <update-cursor>
BRK
@on-control ( -> )
BRK
(
@|remote )
@on-action ( -> )
<redraw>
LIT "a #18 DEO
BRK
(
@|core )
(
@|drawing )
@<redraw> ( -- )
#0006 .Screen/x DEO2
#0006 .Screen/y DEO2
#80 .Screen/pixel DEO
#0006 .Screen/x DEO2
#0006 .Screen/y DEO2
[ LIT2 00 -action/value ] LDZ DUP ADD ;actions-lut ADD2 LDA2 #01 <draw-uf2>
JMP2r
@test "Hello $1
@<draw-uf2> ( addr* color -- )
,&color STR
#15 .Screen/auto DEO
&w ( -- )
LDAk #1f GTH ?{ POP2 JMP2r }
LDAk #20 SUB #00 SWP
( ) DUP2 #50 SFT2 ;font-uf2/glyphs ADD2 .Screen/addr DEO2
( ) ;font-uf2 ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
( ) [ LIT &color 05 ] .Screen/sprite DEOk DEO
.Screen/x DEO2
INC2 !&w
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
#40 <draw-cursor>
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
.Screen/addr DEO2
@<draw-cursor> ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
(
@|stdlib )
@<pstr> ( str* -- )
&w ( -- )
LDAk #18 DEO
INC2 & LDAk ?&w
POP2 JMP2r
(
@|theme )
@<load-theme> ( -- )
;&path .File/name DEO2
#0002 .File/length DEO2
[ LIT2 -System/debug -System/r ]
&l ( -- )
;&buf .File/read DEO2
.File/success DEI2 #0000 EQU2 ?{
STHk [ LIT2 &buf $2 ] STHr DEO2
INC INC NEQk ?&l }
POP2 JMP2r
&path ".theme $1
(
@|assets )
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@fill-icn [ ffff ffff ffff ffff ]
@dict &default "Default $1
&move "Move $1
&draw "Draw $1
@actions-lut [ =dict/default =dict/move =dict/draw ]
~src/utils/potato.assets.tal