keymap changes and new framebuffer

This commit is contained in:
Nico 2021-11-07 18:09:52 +00:00
parent 74ea93a708
commit ee32942ebb
2 changed files with 15 additions and 22 deletions

View File

@ -263,7 +263,7 @@
#define VARVARA_A BUTTON_VOL_UP
#define VARVARA_B BUTTON_VOL_DOWN
#define VARVARA_START BUTTON_SELECT
#define VARVARA_SELECTBUTTON_PLAYPAUSE
#define VARVARA_SELECT BUTTON_PLAYPAUSE
#define VARVARA_MENU BUTTON_BACK
#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD

View File

@ -24,9 +24,6 @@ TODO clean up
#include <stdint.h>
#include <time.h>
const Uint8 hwrom[] = { /* hello world ROM */
0x20, 0x01, 0x0e, 0x94, 0x80, 0x18, 0x17, 0x21,
0x94, 0x80, 0xf7, 0x0d, 0x22, 0x00, 0x48, 0x65,
@ -34,7 +31,7 @@ const Uint8 hwrom[] = { /* hello world ROM */
0x21,
};
const Uint8 screen_rom[] = { /* screen test ROM */
const Uint8 uxn_rom[] = { /* 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,
@ -178,7 +175,7 @@ const Uint8 vector_rom[] = { // screen vector test ROM
0x80, 0x80, 0x80,
};
const Uint8 uxn_rom[] = { /* controller test ROM */
const Uint8 controller_rom[] = { /* controller test ROM */
0x20, 0x0f, 0xf7, 0x80, 0x08, 0x37, 0x20, 0x0f,
0x07, 0x80, 0x0a, 0x37, 0x20, 0x0f, 0x07, 0x80,
0x0c, 0x37, 0x80, 0x22, 0x36, 0x80, 0x01, 0x3f,
@ -307,6 +304,7 @@ static Ppu ppu;
static Device *devctrl, *devsystem, *devconsole, *devscreen;
unsigned int palette[3];
static Uint8 framebuffer[LCD_HEIGHT * LCD_WIDTH * 4];
static fb_data *lcd_fb = NULL;
static void
memzero8(void *src, uint64_t n)
@ -343,7 +341,7 @@ set_palette(Uint8 *addr)
r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f,
g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f,
b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
palette[i] = LCD_RGBPACK(r*8,g*8,b*8);
palette[i] = FB_RGBPACK(r*8,g*8,b*8);
}
#else
int i;
@ -445,22 +443,17 @@ nil_talk(Device *d, Uint8 b0, Uint8 w)
return 1;
}
// TODO optimise, proper greyscale
// TODO mono, greyscale
static void redraw(void)
{
rb->lcd_clear_display();
Uint16 x, y;
for(y = 0; y < ppu.height; ++y)
for(x = 0; x < ppu.width; ++x) {
#if LCD_DEPTH > 4
rb->lcd_set_foreground(palette[ppu_read(&ppu, x, y)]);
rb->lcd_drawpixel(x, y);
#else
if(palette[ppu_read(&ppu, x, y)]) {
rb->lcd_drawpixel(x, y);
}
#endif
}
if (!lcd_fb)
{
struct viewport *vp_main = rb->lcd_set_viewport(NULL);
lcd_fb = vp_main->buffer->fb_ptr;
}
for(int y = 0 ; y < LCD_WIDTH*LCD_HEIGHT; y++ ) {
lcd_fb[y] = palette[ppu_read(&ppu, y%LCD_WIDTH, y/LCD_HEIGHT)];
}
rb->lcd_update();
ppu.reqdraw = 0;
@ -473,6 +466,7 @@ uxn_halt(Uxn *u, Uint8 error, char *name, int id)
return 0;
}
// TODO fix timing
static void run() {
while(!devsystem->dat[0xf]) {
uxn_eval(&u, devscreen->vector);
@ -519,7 +513,6 @@ static void run() {
uxn_eval(&u, peek16(devctrl->dat, 0));
}
rb->sleep(HZ/60);
}
}