initial g
This commit is contained in:
parent
e051ac2c48
commit
8b022f1a27
Binary file not shown.
|
@ -10,10 +10,9 @@ copyright notice and this permission notice appear in all copies.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE.
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
TODO de-janking display code, support for greyscale displays
|
TODO proper support for greyscale displays
|
||||||
TODO rom loading
|
TODO rom loading
|
||||||
TODO other varvara devices
|
TODO other varvara devices
|
||||||
TODO hardware builds
|
|
||||||
TODO clean up
|
TODO clean up
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ const Uint8 hwrom[] = { /* hello world ROM */
|
||||||
0x21,
|
0x21,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Uint8 screenrom[] = { /* screen test ROM */
|
const Uint8 uxn_rom[] = { /* screen test ROM */
|
||||||
0x20, 0x01, 0x43, 0x80, 0x20, 0x37, 0x20, 0xf0,
|
0x20, 0x01, 0x43, 0x80, 0x20, 0x37, 0x20, 0xf0,
|
||||||
0x7f, 0x80, 0x08, 0x37, 0x20, 0xf0, 0xe0, 0x80,
|
0x7f, 0x80, 0x08, 0x37, 0x20, 0xf0, 0xe0, 0x80,
|
||||||
0x0a, 0x37, 0x20, 0xf0, 0xc0, 0x80, 0x0c, 0x37,
|
0x0a, 0x37, 0x20, 0xf0, 0xc0, 0x80, 0x0c, 0x37,
|
||||||
|
@ -136,7 +135,7 @@ const Uint8 screenrom[] = { /* screen test ROM */
|
||||||
0x80, 0x80,
|
0x80, 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Uint8 uxn_rom[] = { // screen vector test ROM
|
const Uint8 vector_rom[] = { // screen vector test ROM
|
||||||
0x20, 0x01, 0x19, 0x80, 0x20, 0x37, 0x20, 0x0f,
|
0x20, 0x01, 0x19, 0x80, 0x20, 0x37, 0x20, 0x0f,
|
||||||
0x7f, 0x80, 0x08, 0x37, 0x20, 0x0f, 0xe0, 0x80,
|
0x7f, 0x80, 0x08, 0x37, 0x20, 0x0f, 0xe0, 0x80,
|
||||||
0x0a, 0x37, 0x20, 0x0f, 0xc0, 0x80, 0x0c, 0x37,
|
0x0a, 0x37, 0x20, 0x0f, 0xc0, 0x80, 0x0c, 0x37,
|
||||||
|
@ -213,7 +212,7 @@ inspect(Stack *s, char *name)
|
||||||
static void
|
static void
|
||||||
set_palette(Uint8 *addr)
|
set_palette(Uint8 *addr)
|
||||||
{
|
{
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_HAS_COLOR
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 4; ++i) {
|
for(i = 0; i < 4; ++i) {
|
||||||
Uint8
|
Uint8
|
||||||
|
@ -222,11 +221,18 @@ set_palette(Uint8 *addr)
|
||||||
b = (*(addr + 4 + 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] = LCD_RGBPACK(r*8,g*8,b*8);
|
||||||
}
|
}
|
||||||
|
#elif LCD_DEPTH > 1 // greyscale
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < 4; ++i) {
|
||||||
|
Uint8 sum = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
|
sum += (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
|
sum += (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
|
palette[i] = sum;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 4; ++i) {
|
for(i = 0; i < 4; ++i) {
|
||||||
Uint8
|
Uint8 sum = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
sum = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
|
||||||
sum += (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
sum += (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
sum += (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
sum += (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
||||||
palette[i] = sum > 0x17;
|
palette[i] = sum > 0x17;
|
||||||
|
@ -323,14 +329,17 @@ nil_talk(Device *d, Uint8 b0, Uint8 w)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO optimise, make build on non-color devices
|
// TODO optimise, proper greyscale
|
||||||
static void redraw(void)
|
static void redraw(void)
|
||||||
{
|
{
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
Uint16 x, y;
|
Uint16 x, y;
|
||||||
for(y = 0; y < ppu.height; ++y)
|
for(y = 0; y < ppu.height; ++y)
|
||||||
for(x = 0; x < ppu.width; ++x) {
|
for(x = 0; x < ppu.width; ++x) {
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_HAS_COLOR
|
||||||
|
rb->lcd_set_foreground(palette[ppu_read(&ppu, x, y)]);
|
||||||
|
rb->lcd_drawpixel(x, y);
|
||||||
|
#elif LCD_DEPTH > 1
|
||||||
rb->lcd_set_foreground(palette[ppu_read(&ppu, x, y)]);
|
rb->lcd_set_foreground(palette[ppu_read(&ppu, x, y)]);
|
||||||
rb->lcd_drawpixel(x, y);
|
rb->lcd_drawpixel(x, y);
|
||||||
#else
|
#else
|
||||||
|
@ -356,10 +365,9 @@ static void run() {
|
||||||
uxn_eval(&u, devscreen->vector);
|
uxn_eval(&u, devscreen->vector);
|
||||||
if(ppu.reqdraw || devsystem->dat[0xe])
|
if(ppu.reqdraw || devsystem->dat[0xe])
|
||||||
redraw();
|
redraw();
|
||||||
switch(rb->button_get(false)) {
|
switch(rb->button_get(false)) { // TODO implement other buttons
|
||||||
case BUTTON_NONE: break;
|
case BUTTON_NONE: break;
|
||||||
default:
|
default: return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
rb->sleep(HZ/60);
|
rb->sleep(HZ/60);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue