diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 17fa0b3..21fa11d 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(gb6 ../src/lcd.c ../src/rom.c emulator.c + lcd_sixel.c ) target_link_libraries(gb6 diff --git a/cli/lcd_sixel.c b/cli/lcd_sixel.c new file mode 100644 index 0000000..80aa95b --- /dev/null +++ b/cli/lcd_sixel.c @@ -0,0 +1,34 @@ +#include +#include +#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; +} \ No newline at end of file diff --git a/src/lcd.h b/src/lcd.h index 84735aa..60a2456 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -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 \ No newline at end of file