Skip to content

Commit

Permalink
vga-nextgen
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Feb 14, 2024
1 parent 3999f6a commit 518c40a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions drivers/vga-nextgen/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void __time_critical_func() dma_handler_VGA() {
case VGA_320x200x256x4:
case GRAPHICSMODE_DEFAULT:
line_number = screen_line / 2;
if (screen_line % 2) return;
y = screen_line - graphics_buffer_shift_y;
if (screen_line % 3) return;
y = screen_line / 3 - graphics_buffer_shift_y;
break;

case TEXTMODE_160x100:
Expand Down Expand Up @@ -185,7 +185,7 @@ void __time_critical_func() dma_handler_VGA() {
dma_channel_set_read_addr(dma_chan_ctrl, &lines_pattern[0], false); // TODO: ensue it is required
return;
}
if (false&& y >= graphics_buffer_height) {
if (y >= graphics_buffer_height) {
// заполнение линии цветом фона
if (y == graphics_buffer_height | y == graphics_buffer_height + 1 |
y == graphics_buffer_height + 2) {
Expand Down
24 changes: 18 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ uint16_t stream[AUDIO_BUFFER_SIZE_BYTES];
((((color565 >> 5) & 0x3F) * 255 / 63) >> 6) << 2 | \
((color565 & 0x1F) * 255 / 31) >> 6)

#define convertRGB565toRGB222(rgb565) ((((rgb565) & 0xF800) << 8) | (((rgb565) & 0x07E0) << 5) | (((rgb565) & 0x001F) << 3))
#define convertRGB565toRGB222(rgb565) (rgb565)
//((((rgb565) & 0xF800) << 8) | (((rgb565) & 0x07E0) << 5) | (((rgb565) & 0x001F) << 3))
//((((rgb565) & 0xF800) << 8) | (((rgb565) & 0x07E0) << 5) | (((rgb565) & 0x001F) << 3))

typedef uint32_t palette222_t[3][4];
Expand Down Expand Up @@ -202,7 +203,7 @@ void __time_critical_func(render_core)() {
graphics_set_buffer(buffer, LCD_WIDTH, LCD_HEIGHT);
graphics_set_textbuffer(buffer);
graphics_set_bgcolor(0x000000);
graphics_set_offset(160, 240-144);
graphics_set_offset(0, 0);
graphics_set_flashmode(false, false);
graphics_set_mode(GRAPHICSMODE_DEFAULT);
// clrScr(1);
Expand Down Expand Up @@ -244,10 +245,10 @@ void __time_critical_func(render_core)() {
* Draws scanline into framebuffer.
*/
void __always_inline lcd_draw_line(struct gb_s* gb, const uint8_t pixels[160], const uint_fast8_t y) {
memcpy((uint32_t *)SCREEN[y], (uint32_t *)pixels, 160);
// memcpy((uint32_t *)SCREEN[y], (uint32_t *)pixels, 160);
// screen[y][x] = palette[(pixels[x] & LCD_PALETTE_ALL) >> 4][pixels[x] & 3];
// for (unsigned int x = 0; x < LCD_WIDTH; x++)
// SCREEN[y][x] = palette[(pixels[x] & LCD_PALETTE_ALL) >> 4][pixels[x] & 3];
for (unsigned int x = 0; x < LCD_WIDTH; x++)
SCREEN[y][x] = palette[(pixels[x] & LCD_PALETTE_ALL) >> 4][pixels[x] & 3];
}


Expand Down Expand Up @@ -792,6 +793,17 @@ int menu() {
}
draw_text(result, x, y, color, bg_color);
}
sleep_ms(100);
}
if (manual_palette_selected > 0) {
manual_assign_palette(palette16, manual_palette_selected);

for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++) {
graphics_set_palette(i * 4 + j, convertRGB565toRGB222(palette16[i][j]));
palette[i][j] = i * 4 + j;
}

}

graphics_set_mode(GRAPHICSMODE_DEFAULT);
Expand Down Expand Up @@ -865,7 +877,7 @@ int main() {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++) {
graphics_set_palette(i * 4 + j, convertRGB565toRGB222(palette16[i][j]));
// palette[i][j] = i * 4 + j;
palette[i][j] = i * 4 + j;
}
//palette[i][j] = convertRGB565toRGB222(palette16[i][j]);

Expand Down

0 comments on commit 518c40a

Please sign in to comment.