Skip to content

Commit

Permalink
display: fix a bug that hid the first scanline of the screen
Browse files Browse the repository at this point in the history
We shouldn't apply the scanline shifting logic in non-interlaced modes.
  • Loading branch information
rasky committed Dec 21, 2022
1 parent 46d4a66 commit 038e388
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void __write_dram_register( void const * const dram_val )
{
volatile uint32_t *reg_base = (uint32_t *)REGISTER_BASE;

reg_base[1] = (uint32_t)dram_val;
reg_base[1] = PhysicalAddr(dram_val);
MEMORY_BARRIER();
}

Expand Down Expand Up @@ -169,6 +169,7 @@ static void __display_callback()
/* Least significant bit of the current line register indicates
if the currently displayed field is odd or even. */
bool field = reg_base[4] & 1;
bool interlaced = reg_base[0] & (1<<6);

/* Check if the next buffer is ready to be displayed, otherwise just
leave up the current frame */
Expand All @@ -178,7 +179,7 @@ static void __display_callback()
ready_mask &= ~(1 << next);
}

__write_dram_register(__safe_buffer[now_showing] + (!field ? __width * __bitdepth : 0));
__write_dram_register(__safe_buffer[now_showing] + (interlaced && !field ? __width * __bitdepth : 0));
}

void display_init( resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma_t gamma, antialias_t aa )
Expand Down Expand Up @@ -327,7 +328,7 @@ void display_init( resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma
to avoid confusing the VI chip with in-frame modifications. */
if ( __is_vi_active() ) { __wait_for_vblank(); }

registers[1] = (uintptr_t) __safe_buffer[0];
registers[1] = PhysicalAddr(__safe_buffer[0]);
__write_registers( registers );

enable_interrupts();
Expand Down

0 comments on commit 038e388

Please sign in to comment.