Working on ppu

This commit is contained in:
2025-02-18 22:39:56 -07:00
parent 89a1b4cec6
commit c8ec44fa39
7 changed files with 38 additions and 9 deletions

View File

@ -42,6 +42,9 @@ 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));
if(ppu_get_context()->rendering_window) {
sp_x = (ppu_get_context()->fetched_entries[i].x - 8);
}
if (sp_x + 8 < ppu_get_context()->pfc.fifo_x) {
//past this pixel already
@ -71,8 +74,8 @@ u32 fetch_sprite_pixels(int bit, u32 color, u8 bg_color) {
}
if(!bg_priority || bg_color == 0) {
color = (ppu_get_context()->fetched_entries[i].f_pn) ?
lcd_get_context()->sp2_colors[hi|lo] : lcd_get_context()->sp1_colors[hi|lo];
color = ((ppu_get_context()->fetched_entries[i].f_pn) ?
lcd_get_context()->sp2_colors[hi|lo] : lcd_get_context()->sp1_colors[hi|lo]);
if(hi | lo) {
break;
@ -101,7 +104,7 @@ bool pipeline_fifo_add() {
color = lcd_get_context()->bg_colors[0];
}
if(LCDC_OBJ_ENABLE) {
if(LCDC_OBJ_ENABLE && !ppu_get_context()->debug) {
color = fetch_sprite_pixels(bit, color, hi | lo);
}
@ -204,7 +207,7 @@ void pipeline_fetch() {
if(ppu_get_context()->rendering_window){
ppu_get_context()->pfc.bgw_fetch_data[1] = bus_read(LCDC_BGW_DATA_AREA +
(ppu_get_context()->pfc.bgw_fetch_data[0] * 16) +
(lcd_get_context()->ly % 8) * 2);
(ppu_get_context()->window_line % 8) * 2);
} else {
ppu_get_context()->pfc.bgw_fetch_data[1] = bus_read(LCDC_BGW_DATA_AREA +
(ppu_get_context()->pfc.bgw_fetch_data[0] * 16) +
@ -220,7 +223,7 @@ void pipeline_fetch() {
if(ppu_get_context()->rendering_window){
ppu_get_context()->pfc.bgw_fetch_data[2] = bus_read(LCDC_BGW_DATA_AREA +
(ppu_get_context()->pfc.bgw_fetch_data[0] * 16) + 1 +
(lcd_get_context()->ly % 8) * 2);
(ppu_get_context()->window_line % 8) * 2);
} else {
ppu_get_context()->pfc.bgw_fetch_data[2] = bus_read(LCDC_BGW_DATA_AREA +
(ppu_get_context()->pfc.bgw_fetch_data[0] * 16) +
@ -256,12 +259,13 @@ void pipeline_push_pixel() {
if (ppu_get_context()->pfc.pixel_fifo.size > 8) {
u32 pixel_data = pixel_fifo_pop();
if(ppu_get_context()->pfc.pushed_x+7 >= lcd_get_context()->win_x && lcd_get_context()->ly >= lcd_get_context()->win_y && !ppu_get_context()->rendering_window && window_visible()) {
if(ppu_get_context()->pfc.line_x+7 >= lcd_get_context()->win_x && lcd_get_context()->ly >= lcd_get_context()->win_y && !ppu_get_context()->rendering_window && window_visible()) {
ppu_get_context()->rendering_window = true;
pipeline_fifo_reset();
ppu_get_context()->pfc.cur_fetch_state = FS_TILE;
ppu_get_context()->pfc.fetch_x = 0;
ppu_get_context()->pfc.fifo_x = 0;
ppu_get_context()->pfc.fetch_x = ppu_get_context()->pfc.line_x;
ppu_get_context()->pfc.fifo_x = ppu_get_context()->pfc.line_x;
ppu_get_context()->pfc.pushed_x = ppu_get_context()->pfc.line_x;
return;
}
if(ppu_get_context()->rendering_window) {