ppu work
This commit is contained in:
@ -255,6 +255,23 @@ void pipeline_fifo_reset() {
|
||||
ppu_get_context()->pfc.pixel_fifo.head = 0;
|
||||
}
|
||||
|
||||
//Rate at wich the screen interpolates between the old and new colors
|
||||
//Used to simulate the slow response time of the GB's LCD
|
||||
//A value of zero will always use the exiting screen color, while a 1 will always use the new color
|
||||
//any value in between will interpolate that percentage between the two
|
||||
#define INTERPOLATION_RATE 0.5
|
||||
|
||||
u32 interpolate(u32 first, u32 second) {
|
||||
u32 final = 0;
|
||||
for(int c = 0; c < 4; c++) {
|
||||
u8 c1 = (first >> (c*8)) & 0xFF;
|
||||
u8 c2 = (second >> (c*8)) & 0xFF;
|
||||
u8 cf = (u8)(((((float)c2/(float)0xFF) - ((float)c1/(float)0xFF)) * INTERPOLATION_RATE + ((float)c1/(float)0xFF)) * 0xFF);
|
||||
final |= cf << (c*8);
|
||||
}
|
||||
return final;
|
||||
}
|
||||
|
||||
void pipeline_push_pixel() {
|
||||
if (ppu_get_context()->pfc.pixel_fifo.size > 8) {
|
||||
u32 pixel_data = pixel_fifo_pop();
|
||||
@ -270,13 +287,15 @@ void pipeline_push_pixel() {
|
||||
}
|
||||
if(ppu_get_context()->rendering_window) {
|
||||
ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
|
||||
(lcd_get_context()->ly * XRES)] = pixel_data;
|
||||
(lcd_get_context()->ly * XRES)] = interpolate(ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
|
||||
(lcd_get_context()->ly * XRES)], pixel_data);
|
||||
|
||||
ppu_get_context()->pfc.pushed_x++;
|
||||
}else {
|
||||
if(ppu_get_context()->pfc.line_x >= (lcd_get_context()->scroll_x % 8)) {
|
||||
ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
|
||||
(lcd_get_context()->ly * XRES)] = pixel_data;
|
||||
(lcd_get_context()->ly * XRES)] = interpolate(ppu_get_context()->video_buffer[ppu_get_context()->pfc.pushed_x +
|
||||
(lcd_get_context()->ly * XRES)], pixel_data);
|
||||
|
||||
ppu_get_context()->pfc.pushed_x++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user