void display_putchar(char c) { if (c == '\n') { cursor_x = 0; cursor_y += 8; if (cursor_y >= 64) display_scroll(); display_refresh(); return; } else if (c == '\r') { cursor_x = 0; display_refresh(); return; } if (c < 32 || c > 127) return; for (uint8_t row = 0; row < 8; row++) { uint8_t line = font8x8_basic[c - 32][row]; for (uint8_t col = 0; col < 8; col += 2) { uint8_t px1 = (line & (1 << (7 - col))) ? 0xF : 0x0; uint8_t px2 = (line & (1 << (6 - col))) ? 0xF : 0x0; uint8_t packed = (px1 << 4) | px2; uint16_t offset = ((cursor_y + row) * SCREEN_WIDTH + cursor_x + col) / 2; if (offset < FRAMEBUFFER_SIZE) framebuffer[offset] = packed; } } cursor_x += 8; if (cursor_x >= 132) { cursor_x = 0; cursor_y += 8; if (cursor_y >= 64) { cursor_y = 0; // Wrap around } } display_refresh(); }