Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
0ca783bc
Verified
Commit
0ca783bc
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: made frame buffer size a const
parent
49932ec9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gb.rs
+2
-2
2 additions, 2 deletions
src/gb.rs
src/ppu.rs
+4
-1
4 additions, 1 deletion
src/ppu.rs
with
6 additions
and
3 deletions
src/gb.rs
+
2
−
2
View file @
0ca783bc
use
crate
::{
cpu
::
Cpu
,
mmu
::
Mmu
,
ppu
::
Ppu
,
util
::
read_file
};
use
crate
::{
cpu
::
Cpu
,
mmu
::
Mmu
,
ppu
::
{
Ppu
,
FRAME_BUFFER_SIZE
},
util
::
read_file
};
pub
struct
GameBoy
{
pub
struct
GameBoy
{
cpu
:
Cpu
,
cpu
:
Cpu
,
...
@@ -38,7 +38,7 @@ impl GameBoy {
...
@@ -38,7 +38,7 @@ impl GameBoy {
self
.cpu
.ppu
()
self
.cpu
.ppu
()
}
}
pub
fn
frame_buffer
(
&
mut
self
)
->
&
Box
<
[
u8
;
73920
]
>
{
pub
fn
frame_buffer
(
&
mut
self
)
->
&
Box
<
[
u8
;
FRAME_BUFFER_SIZE
]
>
{
&
(
self
.ppu
()
.frame_buffer
)
&
(
self
.ppu
()
.frame_buffer
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
4
−
1
View file @
0ca783bc
...
@@ -13,6 +13,9 @@ pub const DISPLAY_WIDTH: usize = 160;
...
@@ -13,6 +13,9 @@ pub const DISPLAY_WIDTH: usize = 160;
/// The height of the Game Boy screen in pixels.
/// The height of the Game Boy screen in pixels.
pub
const
DISPLAY_HEIGHT
:
usize
=
154
;
pub
const
DISPLAY_HEIGHT
:
usize
=
154
;
// The size of the RGB frame buffer in bytes.
pub
const
FRAME_BUFFER_SIZE
:
usize
=
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
*
RGB_SIZE
;
/// Represents the Game Boy PPU (Pixel Processing Unit) and controls
/// Represents the Game Boy PPU (Pixel Processing Unit) and controls
/// all of the logic behind the graphics processing and presentation.
/// all of the logic behind the graphics processing and presentation.
/// Should store both the VRAM and HRAM together with the internal
/// Should store both the VRAM and HRAM together with the internal
...
@@ -27,7 +30,7 @@ pub const DISPLAY_HEIGHT: usize = 154;
...
@@ -27,7 +30,7 @@ pub const DISPLAY_HEIGHT: usize = 154;
pub
struct
Ppu
{
pub
struct
Ppu
{
/// The 8 bit based RGB frame buffer with the
/// The 8 bit based RGB frame buffer with the
/// processed set of pixels ready to be displayed on screen.
/// processed set of pixels ready to be displayed on screen.
pub
frame_buffer
:
Box
<
[
u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
*
RGB
_SIZE
]
>
,
pub
frame_buffer
:
Box
<
[
u8
;
FRAME_BUFFER
_SIZE
]
>
,
/// Video dedicated memory (VRAM) where both the tiles and
/// Video dedicated memory (VRAM) where both the tiles and
/// the sprites are going to be stored.
/// the sprites are going to be stored.
pub
vram
:
[
u8
;
VRAM_SIZE
],
pub
vram
:
[
u8
;
VRAM_SIZE
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment