Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature fifo ppu #51

Merged
merged 54 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cdbee8e
Starting to implement a fifo ppu
alloncm Jun 5, 2021
3c2c2bb
WIP in the middle of the fifo ppy
alloncm Jun 12, 2021
427df0e
The fifo supposed to support the bg layer
alloncm Jul 21, 2021
35b9946
Wrap the fifo code in order to start and test it
alloncm Jul 21, 2021
9587841
WIP adding the registers to the new ppu
alloncm Jul 22, 2021
683e2df
Remove uncessary function
alloncm Jul 23, 2021
67f49ba
Add support for the registers
alloncm Jul 23, 2021
601b75e
Add gfx device and sdl gfx device
alloncm Jul 23, 2021
3ce9e29
Fix the fetiching tile number stage in the new ppu
alloncm Jul 26, 2021
3a299f7
Fix the timing issue with the fifo ppu
alloncm Jul 26, 2021
58dc36f
FIx a vblank interrupt not fired
alloncm Jul 26, 2021
a43c095
Hope I fixed the stat interrupt trigger
alloncm Jul 26, 2021
e4ba52e
More fixes for the interrupt
alloncm Jul 26, 2021
f350e62
Move the fifo stuff to its own folder
alloncm Jul 27, 2021
9bfe553
Integrate the bg fetcher
alloncm Jul 27, 2021
391b362
Add the sprite fetcher
alloncm Jul 27, 2021
58e64e2
Integrate the sprite fetcher
alloncm Jul 27, 2021
dd28221
Still implementing the sprites
alloncm Jul 28, 2021
260414d
Fix bugs u8 overflow and rendering
alloncm Jul 28, 2021
9aff501
First sprites on the screen!
alloncm Jul 28, 2021
db57edf
Fix the stat interrupt and support for hiding bg
alloncm Jul 28, 2021
e361544
Adding propper support for the window
alloncm Jul 29, 2021
16daae8
Adapt to linux and amde error message clearer
alloncm Jul 30, 2021
00e7457
Fix the window rendering
alloncm Jul 30, 2021
ecd624d
Update the readme
alloncm Jul 30, 2021
894339d
Fix sprite fetcher
alloncm Jul 30, 2021
5f845a3
Seperate the pixel x pos from the bg x pos
alloncm Jul 31, 2021
c3d0a4f
The bg stops render when a sprite has been found
alloncm Jul 31, 2021
fb470cb
Fix sprite fetcher
alloncm Aug 1, 2021
ee58381
Add support for sprite flipping on Y axis
alloncm Aug 13, 2021
33a18e5
Update the fifo for the new sprite fetcher
alloncm Aug 13, 2021
205f1fa
Trying to add support for extended sprites
alloncm Aug 13, 2021
f2c4496
Implement the extended sprites correctly.
alloncm Aug 14, 2021
e6a3755
Fix the proprity in the fifo
alloncm Aug 14, 2021
21ed932
WIP try to impement the internal sprites priority
alloncm Aug 14, 2021
46eca23
WIP Try to impl the sprite priority
alloncm Aug 15, 2021
d959651
Fix the fifo obj rendering
alloncm Aug 20, 2021
69a3e94
Arrange the bg fetcher code.
alloncm Aug 20, 2021
1926087
Fix the bg rendering
alloncm Aug 20, 2021
dff63cb
FIx the bug with the missing vertical object lines
alloncm Sep 3, 2021
f52c16c
Arrange the gameboy main code
alloncm Sep 3, 2021
dcd3e63
Merge branch 'dev' into feature-fifo_ppu
alloncm Sep 3, 2021
b71436e
Code indentation and redundant code removal
alloncm Sep 3, 2021
15b1b6c
Refactor the fetchers
alloncm Sep 4, 2021
0b3b51d
Arrange the fifo code
alloncm Sep 6, 2021
fdc2624
Arrange and rename
alloncm Sep 6, 2021
a3513c1
Change FetchingStateData to a struct from union
alloncm Sep 6, 2021
6380c55
Remove unused files and modules
alloncm Sep 6, 2021
73dbb19
Change magic numbers into consts and fix casting
alloncm Sep 6, 2021
d2fe771
Implemented the fifo DS + some tests
alloncm Sep 6, 2021
cc472ce
Clean the create array util
alloncm Sep 8, 2021
4fec856
Fix this weird bug where the image is courupted
alloncm Sep 9, 2021
4142854
Fix the window rendering, passing the turtle tests
alloncm Sep 9, 2021
b4347cd
SCR
alloncm Sep 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Seperate the pixel x pos from the bg x pos
  • Loading branch information
alloncm committed Jul 31, 2021
commit 5f845a31a2d720694dc7a53740a89324e4feb877
2 changes: 1 addition & 1 deletion lib_gb/src/ppu/fifo/bg_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::{mmu::vram::VRam, utils::{bit_masks::*, vec2::Vec2}};
use super::fetching_state::FethcingState;

pub struct BGFetcher{
alloncm marked this conversation as resolved.
Show resolved Hide resolved
pub current_x_pos:u8,
pub fifo:Vec<u8>,
pub window_line_counter:u8,

current_x_pos:u8,
rendered_window:bool,
rendering_window:bool,
current_fetching_state:FethcingState,
Expand Down
12 changes: 9 additions & 3 deletions lib_gb/src/ppu/fifo/fifo_ppu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct FifoPpu<GFX: GfxDevice>{
screen_buffer: [u32; 160*144],
push_lcd_buffer:Vec<Color>,
screen_buffer_index:usize,
pixel_x_pos:u8,

//interrupts
pub v_blank_interrupt_request:bool,
Expand Down Expand Up @@ -74,6 +75,7 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
bg_fetcher:BGFetcher::new(),
sprite_fetcher:SpriteFetcher::new(),
push_lcd_buffer:Vec::<Color>::new(),
pixel_x_pos:0,
}
}

Expand All @@ -90,6 +92,7 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
self.trigger_stat_interrupt = false;
self.bg_fetcher.reset();
self.sprite_fetcher.reset();
self.pixel_x_pos = 0;
}

pub fn turn_on(&mut self){
Expand Down Expand Up @@ -186,6 +189,7 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
self.trigger_stat_interrupt = true;
}
}
self.pixel_x_pos = 0;
self.t_cycles_passed = 0;
self.ly_register += 1;
}
Expand All @@ -196,6 +200,7 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
if self.oam_search_interrupt_request{
self.trigger_stat_interrupt = true;
}
self.pixel_x_pos = 0;
self.t_cycles_passed = 0;
self.ly_register = 0;
}
Expand All @@ -206,18 +211,18 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
self.t_cycles_passed += 2;
}
PpuState::PixelTransfer=>{
if self.bg_fetcher.current_x_pos < 160{
if self.pixel_x_pos < 160{
self.bg_fetcher.fetch_pixels(&self.vram, self.lcd_control, self.ly_register, &self.window_pos, &self.bg_pos);
if self.lcd_control & BIT_1_MASK != 0{
self.sprite_fetcher.fetch_pixels(&self.vram, self.ly_register, self.bg_fetcher.current_x_pos);
self.sprite_fetcher.fetch_pixels(&self.vram, self.ly_register, self.pixel_x_pos);
}
}

for _ in 0..2{
self.try_push_to_lcd();
}

if self.bg_fetcher.current_x_pos == 160 && self.bg_fetcher.fifo.is_empty(){
if self.pixel_x_pos == 160 {
self.state = PpuState::Hblank;
if self.h_blank_interrupt_request{
self.trigger_stat_interrupt = true;
Expand Down Expand Up @@ -263,6 +268,7 @@ impl<GFX:GfxDevice> FifoPpu<GFX>{
};

self.push_lcd_buffer.push(pixel);
self.pixel_x_pos += 1;
}
}

Expand Down