fixed zelda line weirdness

This commit is contained in:
Samuel Walker 2025-02-21 12:36:25 -07:00
parent 97bf116c89
commit 4da737135d
Signed by: piwalker
GPG Key ID: 616B1928705EA4C9
3 changed files with 6 additions and 4 deletions

View File

@ -40,6 +40,7 @@ typedef struct {
u8 map_x;
u8 tile_y;
u8 fifo_x;
u8 lo_scroll_x;
} pixel_fifo_context;
typedef struct {

View File

@ -41,7 +41,7 @@ u32 pixel_fifo_pop() {
u32 fetch_sprite_pixels(int bit, u32 color, u8 bg_color) {
for (int i = 0; i < ppu_get_context()->fetched_entry_count; i++) {
int sp_x = (ppu_get_context()->fetched_entries[i].x - 8) +
((lcd_get_context()->scroll_x % 8));
((ppu_get_context()->pfc.lo_scroll_x));
if(ppu_get_context()->rendering_window) {
sp_x = (ppu_get_context()->fetched_entries[i].x - 8);
}
@ -92,7 +92,7 @@ bool pipeline_fifo_add() {
return false;
}
int x = ppu_get_context()->pfc.fetch_x - (8 - lcd_get_context()->scroll_x % 8);
int x = ppu_get_context()->pfc.fetch_x - (8 - ppu_get_context()->pfc.lo_scroll_x);
for (int i=0; i<8; i++) {
int bit = 7 - i;
@ -121,7 +121,7 @@ void pipeline_load_sprite_tile() {
oam_line_entry *le = ppu_get_context()->line_sprites;
while(le) {
int sp_x = (le->entry.x - 8) + (lcd_get_context()->scroll_x % 8);
int sp_x = (le->entry.x - 8) + (ppu_get_context()->pfc.lo_scroll_x);
if ((sp_x >= ppu_get_context()->pfc.fetch_x && sp_x < ppu_get_context()->pfc.fetch_x + 8) ||
((sp_x + 8) >= ppu_get_context()->pfc.fetch_x && (sp_x + 8) < ppu_get_context()->pfc.fetch_x + 8)) {
@ -292,7 +292,7 @@ void pipeline_push_pixel() {
ppu_get_context()->pfc.pushed_x++;
}else {
if(ppu_get_context()->pfc.line_x >= (lcd_get_context()->scroll_x % 8)) {
if(ppu_get_context()->pfc.line_x >= (ppu_get_context()->pfc.lo_scroll_x)) {
ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
(lcd_get_context()->ly * XRES)] = interpolate(ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
(lcd_get_context()->ly * XRES)], pixel_data);

View File

@ -94,6 +94,7 @@ void ppu_mode_oam() {
}
if(ppu_get_context()->line_ticks == 1) {
ppu_get_context()->pfc.lo_scroll_x = lcd_get_context()->scroll_x & 0b111;
//read oam on the first tick only...
ppu_get_context()->line_sprites = 0;
ppu_get_context()->line_sprite_count = 0;