Use window on LCD

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2022-03-28 19:43:53 +01:00
parent 4379ef9f47
commit dfc88605c4
2 changed files with 64 additions and 25 deletions
+52 -11
View File
@@ -148,7 +148,7 @@ void core1_lcd_draw_line(const uint_fast8_t line)
[pixels_buffer[x] & 3]; [pixels_buffer[x] & 3];
} }
mk_ili9225_set_address(line + 15, 0xDB - 30); //mk_ili9225_set_address(line + 15, 0xDB - 30);
//mk_ili9225_set_x(line + 15); //mk_ili9225_set_x(line + 15);
#if USE_DMA #if USE_DMA
mk_ili9225_write_pixels_start(); mk_ili9225_write_pixels_start();
@@ -194,7 +194,8 @@ void main_core1(void)
#endif #endif
/* Set LCD window to DMG size. */ /* Set LCD window to DMG size. */
//mk_ili9225_set_window(15, LCD_HEIGHT+15, 29, LCD_WIDTH+29); mk_ili9225_set_window(15, LCD_HEIGHT + 15 - 1,
30, LCD_WIDTH + 30 - 1);
while(1) while(1)
{ {
@@ -232,8 +233,8 @@ void lcd_draw_line(struct gb_s *gb, const uint8_t pixels[LCD_WIDTH],
cmd.data = line; cmd.data = line;
//__atomic_store_n(&lcd_line_busy, 1, __ATOMIC_SEQ_CST); //__atomic_store_n(&lcd_line_busy, 1, __ATOMIC_SEQ_CST);
//__aeabi_memcpy4(pixels_buffer, pixels, LCD_WIDTH / 4); __aeabi_memcpy4(pixels_buffer, pixels, LCD_WIDTH / 4);
memcpy(pixels_buffer, pixels, LCD_WIDTH); //memcpy(pixels_buffer, pixels, LCD_WIDTH);
multicore_fifo_push_blocking(cmd.full); multicore_fifo_push_blocking(cmd.full);
} }
@@ -314,6 +315,9 @@ int main(void)
} while(HEDLEY_LIKELY(gb.gb_frame == 0)); } while(HEDLEY_LIKELY(gb.gb_frame == 0));
frames++; frames++;
/* Required since we do not know whether a button remains
* pressed over a serial connection. */
gb.direct.joypad = 0xFF; gb.direct.joypad = 0xFF;
input = getchar_timeout_us(0); input = getchar_timeout_us(0);
if(input == PICO_ERROR_TIMEOUT) if(input == PICO_ERROR_TIMEOUT)
@@ -341,29 +345,35 @@ int main(void)
#endif #endif
case 'c': case 'c':
{ {
static ili9225_color_mode_e mode = ILI9225_COLOR_MODE_FULL;
union core_cmd cmd; union core_cmd cmd;
mode = !mode;
cmd.cmd = CORE_CMD_IDLE_SET; cmd.cmd = CORE_CMD_IDLE_SET;
cmd.data = ILI9225_COLOR_MODE_FULL; cmd.data = mode;
multicore_fifo_push_blocking(cmd.full); multicore_fifo_push_blocking(cmd.full);
break; break;
} }
case 'i': case 'i':
{ {
union core_cmd cmd; gb.direct.interlace = !gb.direct.interlace;
cmd.cmd = CORE_CMD_IDLE_SET;
cmd.data = ILI9225_COLOR_MODE_8COLOR;
multicore_fifo_push_blocking(cmd.full);
break; break;
} }
case 'b': case 'b':
{ {
uint64_t end_time; uint64_t end_time;
uint32_t diff;
uint32_t fps;
end_time = time_us_64(); end_time = time_us_64();
diff = end_time-start_time;
fps = frames/diff;
printf("Frames: %u\n" printf("Frames: %u\n"
"Time: %llu us\n", "Time: %lu us\n"
frames, end_time-start_time); "FPS: %lu\n",
frames, diff, fps);
stdio_flush(); stdio_flush();
frames = 0; frames = 0;
start_time = time_us_64(); start_time = time_us_64();
@@ -371,11 +381,42 @@ int main(void)
} }
case '\n': case '\n':
case '\r':
{ {
gb.direct.joypad_bits.start = 0; gb.direct.joypad_bits.start = 0;
break; break;
} }
case '\b':
{
gb.direct.joypad_bits.select = 0;
break;
}
case '8':
{
gb.direct.joypad_bits.up = 0;
break;
}
case '2':
{
gb.direct.joypad_bits.down = 0;
break;
}
case '4':
{
gb.direct.joypad_bits.left= 0;
break;
}
case '6':
{
gb.direct.joypad_bits.right = 0;
break;
}
case 'z': case 'z':
{ {
gb.direct.joypad_bits.a = 0; gb.direct.joypad_bits.a = 0;
+3 -5
View File
@@ -387,11 +387,9 @@ unsigned mk_ili9225_init(void)
{ MK_ILI9225_REG_DRIVER_OUTPUT_CTRL, 0x011C }, { MK_ILI9225_REG_DRIVER_OUTPUT_CTRL, 0x011C },
/* Set LCD inversion to disabled. */ /* Set LCD inversion to disabled. */
{ MK_ILI9225_REG_LCD_AC_DRIVING_CTRL, 0x0100 }, { MK_ILI9225_REG_LCD_AC_DRIVING_CTRL, 0x0100 },
/* Use BGR mode (swap blue with red). /* Increment vertical and horizontal address.
* Increment vertical and horizontal address. * Use vertical image. */
* Use vertical image. { MK_ILI9225_REG_ENTRY_MODE, 0x0018 },
* FIXME: Why is BGR enabled? */
{ MK_ILI9225_REG_ENTRY_MODE, 0x0008 },
/* Turn off all display outputs. */ /* Turn off all display outputs. */
{ MK_ILI9225_REG_DISPLAY_CTRL, 0x0000 }, { MK_ILI9225_REG_DISPLAY_CTRL, 0x0000 },
/* Set porches to 8 lines. */ /* Set porches to 8 lines. */