From e051ac2c48c523502c1ebcd200d05f6a5e0833eb Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Fri, 29 Oct 2021 09:03:45 +0100 Subject: [PATCH] add screen vector and first test program --- apps/plugins/varvara/tests/screen-vector.tal | 69 ++++++++++++++++++ apps/plugins/varvara/varvara.c | 74 +++++++++++++++++--- 2 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 apps/plugins/varvara/tests/screen-vector.tal diff --git a/apps/plugins/varvara/tests/screen-vector.tal b/apps/plugins/varvara/tests/screen-vector.tal new file mode 100644 index 0000000000..3f500f3557 --- /dev/null +++ b/apps/plugins/varvara/tests/screen-vector.tal @@ -0,0 +1,69 @@ +( dev/screen ) + +%RTN { JMP2r } +%2/ { #01 SFT } +%4/ { #02 SFT } + +( devices ) + +|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] + +( variables ) + +|0000 + +@count $2 +@center + &x $2 &y $2 + +( init ) + +|0100 ( -> ) + + ( vector ) + ;on-frame .Screen/vector DEO2 + + ( theme ) + #0f7f .System/r DEO2 + #0fe0 .System/g DEO2 + #0fc0 .System/b DEO2 + +BRK + +@on-frame ( -> ) + + .count LDZ2 INC2 [ DUP2 ] .count STZ2 + + #0000 .Screen/x DEO2 + #0000 .Screen/y DEO2 + + ( color ) #01 STH + + SWP + DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 + ( draw ) STHkr .Screen/sprite DEO + #0f AND [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 + .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + ( draw ) STHkr .Screen/sprite DEO + DUP #04 SFT [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 + .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + ( draw ) STHkr .Screen/sprite DEO + #0f AND [ #00 SWP ] #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 + .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + ( draw ) STHr .Screen/sprite DEO + +BRK + +@preview_icn + 0f38 675f dfbf bfbf 0007 1820 2344 4848 + +@font-hex + 007c 8282 8282 827c 0030 1010 1010 1010 + 007c 8202 7c80 80fe 007c 8202 1c02 827c + 000c 1424 4484 fe04 00fe 8080 7c02 827c + 007c 8280 fc82 827c 007c 8202 1e02 0202 + 007c 8282 7c82 827c 007c 8282 7e02 827c + 007c 8202 7e82 827e 00fc 8282 fc82 82fc + 007c 8280 8080 827c 00fc 8282 8282 82fc + 007c 8280 f080 827c 007c 8280 f080 8080 diff --git a/apps/plugins/varvara/varvara.c b/apps/plugins/varvara/varvara.c index 579700e9bb..51085a09c4 100644 --- a/apps/plugins/varvara/varvara.c +++ b/apps/plugins/varvara/varvara.c @@ -1,6 +1,7 @@ /* Varvara plugin for rockbox. I have no idea what I'm doing. -Functions taken from uxnemu.c and uxncli.c are copyright (c) 2021 Devine Lu Linvega. +copyright (c) 2021 Devine Lu Linvega +copyright (c) 2021 nihilazo Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -9,7 +10,8 @@ copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. -TODO screen vector, de-janking display code, support for greyscale displays +TODO de-janking display code, support for greyscale displays +TODO rom loading TODO other varvara devices TODO hardware builds TODO clean up @@ -25,14 +27,14 @@ TODO clean up -const uint8_t hwrom[] = { /* hello world ROM */ +const Uint8 hwrom[] = { /* hello world ROM */ 0x20, 0x01, 0x0e, 0x94, 0x80, 0x18, 0x17, 0x21, 0x94, 0x80, 0xf7, 0x0d, 0x22, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x55, 0x78, 0x6e, 0x21, 0x21, }; -const uint8_t uxn_rom[] = { /* screen test ROM */ +const Uint8 screenrom[] = { /* screen test ROM */ 0x20, 0x01, 0x43, 0x80, 0x20, 0x37, 0x20, 0xf0, 0x7f, 0x80, 0x08, 0x37, 0x20, 0xf0, 0xe0, 0x80, 0x0a, 0x37, 0x20, 0xf0, 0xc0, 0x80, 0x0c, 0x37, @@ -134,12 +136,54 @@ const uint8_t uxn_rom[] = { /* screen test ROM */ 0x80, 0x80, }; +const Uint8 uxn_rom[] = { // screen vector test ROM + 0x20, 0x01, 0x19, 0x80, 0x20, 0x37, 0x20, 0x0f, + 0x7f, 0x80, 0x08, 0x37, 0x20, 0x0f, 0xe0, 0x80, + 0x0a, 0x37, 0x20, 0x0f, 0xc0, 0x80, 0x0c, 0x37, + 0x00, 0x80, 0x00, 0x30, 0x21, 0x23, 0x80, 0x00, + 0x31, 0x20, 0x00, 0x00, 0x80, 0x28, 0x37, 0x20, + 0x00, 0x00, 0x80, 0x2a, 0x37, 0x80, 0x01, 0x0f, + 0x05, 0x03, 0x80, 0x04, 0x1f, 0x80, 0x00, 0x05, + 0x80, 0x30, 0x3f, 0x20, 0x01, 0xb2, 0x38, 0x80, + 0x2c, 0x37, 0xcf, 0x80, 0x2f, 0x17, 0x80, 0x0f, + 0x1c, 0x80, 0x00, 0x05, 0x80, 0x30, 0x3f, 0x20, + 0x01, 0xb2, 0x38, 0x80, 0x2c, 0x37, 0x80, 0x28, + 0x36, 0x20, 0x00, 0x08, 0x38, 0x80, 0x28, 0x37, + 0xcf, 0x80, 0x2f, 0x17, 0x03, 0x80, 0x04, 0x1f, + 0x80, 0x00, 0x05, 0x80, 0x30, 0x3f, 0x20, 0x01, + 0xb2, 0x38, 0x80, 0x2c, 0x37, 0x80, 0x28, 0x36, + 0x20, 0x00, 0x08, 0x38, 0x80, 0x28, 0x37, 0xcf, + 0x80, 0x2f, 0x17, 0x80, 0x0f, 0x1c, 0x80, 0x00, + 0x05, 0x80, 0x30, 0x3f, 0x20, 0x01, 0xb2, 0x38, + 0x80, 0x2c, 0x37, 0x80, 0x28, 0x36, 0x20, 0x00, + 0x08, 0x38, 0x80, 0x28, 0x37, 0x4f, 0x80, 0x2f, + 0x17, 0x00, 0x0f, 0x38, 0x67, 0x5f, 0xdf, 0xbf, + 0xbf, 0xbf, 0x00, 0x07, 0x18, 0x20, 0x23, 0x44, + 0x48, 0x48, 0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x7c, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x00, 0x7c, 0x82, 0x02, 0x7c, 0x80, + 0x80, 0xfe, 0x00, 0x7c, 0x82, 0x02, 0x1c, 0x02, + 0x82, 0x7c, 0x00, 0x0c, 0x14, 0x24, 0x44, 0x84, + 0xfe, 0x04, 0x00, 0xfe, 0x80, 0x80, 0x7c, 0x02, + 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xfc, 0x82, + 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x1e, 0x02, + 0x02, 0x02, 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, + 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x82, 0x7e, 0x02, + 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x02, 0x7e, 0x82, + 0x82, 0x7e, 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x82, + 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0x80, 0x80, + 0x82, 0x7c, 0x00, 0xfc, 0x82, 0x82, 0x82, 0x82, + 0x82, 0xfc, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, + 0x82, 0x7c, 0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, + 0x80, 0x80, 0x80, +}; + static Uxn u; static Ppu ppu; static Device *devsystem, *devconsole, *devscreen; unsigned int palette[3]; -static uint8_t framebuffer[LCD_HEIGHT * LCD_WIDTH * 4]; +static Uint8 framebuffer[LCD_HEIGHT * LCD_WIDTH * 4]; static void memzero8(void *src, uint64_t n) @@ -303,10 +347,24 @@ static void redraw(void) int uxn_halt(Uxn *u, Uint8 error, char *name, int id) { - DEBUGF("Halted"); + rb->splash(HZ, "Halted\n"); return 0; } +static void run() { + while(!devsystem->dat[0xf]) { + uxn_eval(&u, devscreen->vector); + if(ppu.reqdraw || devsystem->dat[0xe]) + redraw(); + switch(rb->button_get(false)) { + case BUTTON_NONE: break; + default: + return; + } + rb->sleep(HZ/60); + } +} + /* this is the plugin entry point */ enum plugin_status plugin_start(const void* parameter) @@ -342,9 +400,7 @@ enum plugin_status plugin_start(const void* parameter) /* empty */ uxn_port(&u, 0xf, nil_talk); DEBUGF("eval\n"); uxn_eval(&u, 0x0100); - redraw(); - - rb->button_get(true); + run(); return PLUGIN_OK; }