sixel graphics for test purposes

This commit is contained in:
Matthew Laux 2022-06-28 21:49:10 -05:00
parent ec9226e144
commit ab630f2e38
3 changed files with 37 additions and 0 deletions

View File

@ -13,6 +13,7 @@ add_executable(gb6
../src/lcd.c
../src/rom.c
emulator.c
lcd_sixel.c
)
target_link_libraries(gb6

34
cli/lcd_sixel.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <string.h>
#include "../src/lcd.h"
void lcd_draw(struct lcd *lcd)
{
int x, y, yy;
puts("\033[2J\033[H"); // clear screen and move cursor to 0, 0
puts("\033Pq"); // enter sixel graphics mode
for (y = 0; y < LCD_HEIGHT; y += 6) {
for (x = 0; x < LCD_WIDTH; x++) {
int val = 63;
for (yy = 0; yy < 6; yy++) {
val += !lcd->pixels[(y + yy) * LCD_WIDTH + x] << yy;
}
putchar(val);
}
putchar('-');
}
// puts("#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0");
// puts("#1~~@@vv@@~~@@~~$");
// puts("#2??}}GG}}??}}??-");
// puts("#1!14@");
puts("\033\\"); // leave graphics mode
}
int test_main(int argc, char *argv[])
{
struct lcd lcd;
lcd_new(&lcd);
lcd_draw(&lcd);
return 0;
}

View File

@ -40,4 +40,6 @@ void lcd_put_pixel(struct lcd *lcd, u8 x, u8 y, u8 value);
// i feel like i'm going to need to call this every cycle and update regs
void lcd_step(struct lcd *lcd);
void lcd_draw(struct lcd *lcd);
#endif