use as a viewer

This commit is contained in:
Nico 2021-11-07 19:54:35 +00:00
parent 2ca7b61c84
commit 4f5319db11
3 changed files with 27 additions and 14 deletions

View File

@ -189,4 +189,4 @@ wormlet,games
xobox,games
xworld,games
zxbox,viewers
varvara,apps
varvara,viewers

View File

@ -10,7 +10,7 @@ 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 proper support for greyscale displays
TODO optimise support for greyscale/1-bit displays
TODO rom loading
TODO other varvara devices
TODO clean up
@ -544,18 +544,31 @@ static void run() {
enum plugin_status plugin_start(const void* parameter)
{
(void)parameter;
DEBUGF("Setting PPU size\n");
ppu_init(&ppu, LCD_WIDTH, LCD_HEIGHT, framebuffer);
DEBUGF("UXN init\n");
// Clear RAM and copy rom to VM.
DEBUGF("zeroing\n");
if(!parameter) {
rb->splash(HZ, "Please open a .rom file using this plugin!");
return PLUGIN_ERROR;
}
DEBUGF("zeroing\n");
memzero8(&u, sizeof(Uxn));
DEBUGF("copying ROM\n");
memcpy(u.ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom));
DEBUGF("registering ports\n");
DEBUGF("loading ROM\n");
char* filename = (char*) parameter;
int fd = rb->open(filename, O_RDONLY);
if (fd < 0) {
rb->splash(HZ, "File Error");
return PLUGIN_ERROR;
}
int numread = rb->read(fd, u.ram.dat + PAGE_PROGRAM, 65536-PAGE_PROGRAM);
if (numread==-1) {
rb->splash(HZ, "I/O Error");
return PLUGIN_ERROR;
}
rb->close(fd);
ppu_init(&ppu, LCD_WIDTH, LCD_HEIGHT, framebuffer);
// Register ports
/* system */ devsystem = uxn_port(&u, 0x0, system_talk);
/* console */ devconsole = uxn_port(&u, 0x1, console_talk);
@ -573,7 +586,6 @@ enum plugin_status plugin_start(const void* parameter)
/* empty */ uxn_port(&u, 0xd, nil_talk);
/* empty */ uxn_port(&u, 0xe, nil_talk);
/* empty */ uxn_port(&u, 0xf, nil_talk);
DEBUGF("eval\n");
uxn_eval(&u, 0x0100);
run();
return PLUGIN_OK;

View File

@ -103,3 +103,4 @@ z7,viewers/frotz,-
z8,viewers/frotz,-
shopper,viewers/shopper,1
lnk,viewers/windows_lnk,-
rom,viewers/varvara,-