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

Feature fifo ppu #51

merged 54 commits into from
Sep 9, 2021

Conversation

alloncm
Copy link
Owner

@alloncm alloncm commented Jun 19, 2021

This new implementation should be more accurate and faster than the current one.

Closes #50
Closes #52

@alloncm
Copy link
Owner Author

alloncm commented Jul 23, 2021

Add this video to the resources - https://www.youtube.com/watch?v=HyzD8pNlpwI

alloncm added 22 commits July 24, 2021 00:46
and progressed with the fifo implementation
The bootrom npw displays the logo!
Not working as intended
Rendered the first tile twice in the bg
 to include the ultimate gb talk as one of the resources
Ordering the sprites after fetching them from oam ram
Both fifos cant operate at the same time.
the sprite fifo stops the bg fifo and the pixels to the lcd pusher.
The fifo is 8 pxiels length.
If it contains pixels from previous sprite the new sprite first
number of pixels in the fifo are discarded and not pushed to the fifo.
This way sprite whos ovelapping wont override each other
and the sprite with the lowest x value (higher priority) will be drawn.
The bug was a case when the x position is more advanced
than the start of the obj x pos. the pixels would still be
pushed and we will end up with more than 8 pixels in the fifo.
Solve it by checking the x pos too.
I think I know how to solve the problem with the x axis scroll animation
It has something to do with SCX mod 8 pixels wich are
discarded at the beginning of the stage 3 (push).
Allow the smooth moving animation on X axis
The bug would ocour only for objects drawn with odd scx register.
Since the state machine of the sprite fetcher worked in steps
of 2 t_cycles it would miss some lines.
Moved the state machine to work for every t_cycle and not
for the even ones.
@alloncm alloncm marked this pull request as ready for review September 3, 2021 17:19
lib_gb/src/machine/gameboy.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/sprite_fetcher.rs Outdated Show resolved Hide resolved
gb/src/sdl_gfx_device.rs Outdated Show resolved Hide resolved
lib_gb/src/machine/gameboy.rs Outdated Show resolved Hide resolved
lib_gb/src/machine/gameboy.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/bg_fetcher.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fifo_ppu.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fifo_ppu.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fifo_ppu.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/sprite_fetcher.rs Outdated Show resolved Hide resolved
@alloncm
Copy link
Owner Author

alloncm commented Sep 3, 2021

Remove all the regular PPU files and change the fifo ppu name to gb_ppu

This commit is a result of a SCR (self code review).
@alloncm
Copy link
Owner Author

alloncm commented Sep 4, 2021

Squash the WIP commit (42b2fdb) with the next one (7bee195)

lib_gb/src/ppu/fifo/bg_fetcher.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fetcher_state_machine.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fetching_state.rs Outdated Show resolved Hide resolved
lib_gb/src/mmu/io_components.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/bg_fetcher.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fifo_ppu.rs Outdated Show resolved Hide resolved
lib_gb/src/ppu/fifo/fifo_ppu.rs Outdated Show resolved Hide resolved
Now using a better state machine mechanism.
SCR - Arrange code and extract some to
functions, fix typos and made some fields private
Change BGFetcher to BackgroundFetcher
Move the to color code into the color mod
Made this more safe and less error prone
Replaced the scanline based ppu with the fifo
ppu and adpted the rest of the project to it
Added a lot of constants for the code to make it clearer
Add some tests (not fully coverage)

the code still dont works
In rust ! operator will bitwise not integers,
I forgot to add a proper pranthesis and this broke the ppu
Implement the window rendering correctly:
- handle the LY==WY case
- increment the internal window counter correctly
(only when LY is greater than WY)
- Some more fixes (reseting vars on vblank etc)
- New const
- Remove redundant field
- arrange code
@alloncm alloncm merged commit d9793c7 into dev Sep 9, 2021
@alloncm alloncm deleted the feature-fifo_ppu branch September 9, 2021 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better sync the ppu and the screen Implement a FIFO PPU
1 participant