AGS performace tweaks and bugfixes

Bypass legacy 80 column card when in SHR rendering mode
Mask unused palette bits that were causing VGA PIO to fail
Fixed color calculation for AGS hardware
This commit is contained in:
David Kuder 2023-04-25 16:19:28 -04:00
parent 0fa9fe4538
commit 9727add223
4 changed files with 25 additions and 5 deletions

View File

@ -8,6 +8,7 @@
extern uint16_t lores_palette[16];
extern uint16_t text_fore, text_back, text_border;
extern uint8_t status_line[81];
extern bool mono_rendering;
extern void terminal_clear_screen();
@ -53,9 +54,9 @@ extern void vga_deinit();
#ifdef ANALOG_GS
#define _RGB(r, g, b) ( \
(((((uint)(r) * 256 / 18) + 256) / 256) << 8) | \
(((((uint)(g) * 256 / 18) + 256) / 256) << 4) | \
((((uint)(b) * 256 / 18) + 256) / 256) \
(((((uint)(r) * 256 / 18) + 255) / 256) << 8) | \
(((((uint)(g) * 256 / 18) + 255) / 256) << 4) | \
((((uint)(b) * 256 / 18) + 255) / 256) \
)
#define _RGBHALF 0x777
#else

View File

@ -9,7 +9,7 @@
static void render_shr_line(uint16_t line);
#ifdef ANALOG_GS
#define rgb444(a) (a)
#define rgb444(a) (a & 0xFFF)
#else
static inline uint16_t rgb444(uint16_t a) {
return ((a & 0xe00) >> 3) | ((a & 0xe0) >> 2) | ((a & 0xe) >> 1);
@ -27,7 +27,7 @@ void DELAYED_COPY_CODE(render_shr)() {
}
static void DELAYED_COPY_CODE(render_shr_line)(uint16_t line) {
struct vga_scanline *sl = vga_prepare_scanline();
struct vga_scanline *sl = vga_prepare_scanline_quick();
uint sl_pos = 0;
uint i;

View File

@ -249,6 +249,24 @@ struct vga_scanline * DELAYED_COPY_CODE(vga_prepare_scanline)() {
return scanline;
}
// Set up and return a new display scanline
struct vga_scanline * DELAYED_COPY_CODE(vga_prepare_scanline_quick)() {
struct vga_scanline *scanline = &scanline_queue[scanline_queue_head];
// Wait for the scanline buffer to become available again
while(scanline->_flags & FLAG_BUSY)
tight_loop_contents();
// Reinitialize the scanline struct for reuse
scanline->length = 0;
scanline->repeat_count = 0;
scanline->_flags = FLAG_BUSY;
scanline->_sync = (uint32_t)THEN_WAIT_HSYNC << 16;
scanline_queue_head = (scanline_queue_head + 1) & (NUM_SCANLINE_BUFFERS-1);
return scanline;
}
// Mark the scanline as ready so it can be displayed
void DELAYED_COPY_CODE(vga_submit_scanline)(struct vga_scanline *scanline) {
spin_lock_t *lock = spin_lock_instance(CONFIG_VGA_SPINLOCK_ID);

View File

@ -43,6 +43,7 @@ struct vga_scanline {
extern void vga_prepare_frame();
extern struct vga_scanline *vga_prepare_scanline();
extern struct vga_scanline *vga_prepare_scanline_quick();
extern void vga_submit_scanline(struct vga_scanline *scanline);
extern void vga_stop();