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
b097b4e8
Verified
Commit
b097b4e8
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: renamed game boy mode
parent
9d55eb6c
No related branches found
No related tags found
1 merge request
!16
Support for Game Boy Color (CGB) 😎🖍️
Pipeline
#2558
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/sdl/src/main.rs
+2
-2
2 additions, 2 deletions
frontends/sdl/src/main.rs
src/gb.rs
+17
-14
17 additions, 14 deletions
src/gb.rs
with
19 additions
and
16 deletions
frontends/sdl/src/main.rs
+
2
−
2
View file @
b097b4e8
...
@@ -7,7 +7,7 @@ pub mod graphics;
...
@@ -7,7 +7,7 @@ pub mod graphics;
use
audio
::
Audio
;
use
audio
::
Audio
;
use
boytacean
::{
use
boytacean
::{
devices
::
printer
::
PrinterDevice
,
devices
::
printer
::
PrinterDevice
,
gb
::{
AudioProvider
,
G
B
Mode
,
GameBoy
},
gb
::{
AudioProvider
,
G
ameBoy
Mode
,
GameBoy
},
pad
::
PadKey
,
pad
::
PadKey
,
ppu
::{
PaletteInfo
,
PpuMode
,
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
},
ppu
::{
PaletteInfo
,
PpuMode
,
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
},
};
};
...
@@ -446,7 +446,7 @@ impl Emulator {
...
@@ -446,7 +446,7 @@ impl Emulator {
fn
main
()
{
fn
main
()
{
// creates a new Game Boy instance and loads both the boot ROM
// creates a new Game Boy instance and loads both the boot ROM
// and the initial game ROM to "start the engine"
// and the initial game ROM to "start the engine"
let
mut
game_boy
=
GameBoy
::
new
(
G
B
Mode
::
Cgb
);
let
mut
game_boy
=
GameBoy
::
new
(
G
ameBoy
Mode
::
Dmg
);
let
mut
printer
=
Box
::
<
PrinterDevice
>
::
default
();
let
mut
printer
=
Box
::
<
PrinterDevice
>
::
default
();
printer
.set_callback
(|
image_buffer
|
{
printer
.set_callback
(|
image_buffer
|
{
let
file_name
=
format!
(
"printer-{}.png"
,
Utc
::
now
()
.format
(
"%Y%m%d-%H%M%S"
));
let
file_name
=
format!
(
"printer-{}.png"
,
Utc
::
now
()
.format
(
"%Y%m%d-%H%M%S"
));
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
17
−
14
View file @
b097b4e8
...
@@ -32,9 +32,12 @@ use std::{
...
@@ -32,9 +32,12 @@ use std::{
/// Enumeration that describes the multiple running
/// Enumeration that describes the multiple running
// modes of the Game Boy emulator.
// modes of the Game Boy emulator.
// DMG = Original Game Boy
// CGB = Game Boy Color
// SGB = Super Game Boy
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen)]
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen)]
#[derive(Clone,
Copy,
PartialEq,
Eq)]
#[derive(Clone,
Copy,
PartialEq,
Eq)]
pub
enum
G
B
Mode
{
pub
enum
G
ameBoy
Mode
{
Dmg
=
1
,
Dmg
=
1
,
Cgb
=
2
,
Cgb
=
2
,
Sgb
=
3
,
Sgb
=
3
,
...
@@ -46,7 +49,7 @@ pub struct GameBoyConfig {
...
@@ -46,7 +49,7 @@ pub struct GameBoyConfig {
/// The current running mode of the emulator, this
/// The current running mode of the emulator, this
/// may affect many aspects of the emulation, like
/// may affect many aspects of the emulation, like
/// CPU frequency, PPU frequency, Boot rome size, etc.
/// CPU frequency, PPU frequency, Boot rome size, etc.
mode
:
G
B
Mode
,
mode
:
G
ameBoy
Mode
,
/// If the PPU is enabled, it will be clocked.
/// If the PPU is enabled, it will be clocked.
ppu_enabled
:
bool
,
ppu_enabled
:
bool
,
...
@@ -73,26 +76,26 @@ pub struct GameBoyConfig {
...
@@ -73,26 +76,26 @@ pub struct GameBoyConfig {
impl
GameBoyConfig
{
impl
GameBoyConfig
{
#[inline(always)]
#[inline(always)]
pub
fn
is_dmg
(
&
self
)
->
bool
{
pub
fn
is_dmg
(
&
self
)
->
bool
{
self
.mode
==
G
B
Mode
::
Dmg
self
.mode
==
G
ameBoy
Mode
::
Dmg
}
}
#[inline(always)]
#[inline(always)]
pub
fn
is_cgb
(
&
self
)
->
bool
{
pub
fn
is_cgb
(
&
self
)
->
bool
{
self
.mode
==
G
B
Mode
::
Cgb
self
.mode
==
G
ameBoy
Mode
::
Cgb
}
}
#[inline(always)]
#[inline(always)]
pub
fn
is_sgb
(
&
self
)
->
bool
{
pub
fn
is_sgb
(
&
self
)
->
bool
{
self
.mode
==
G
B
Mode
::
Sgb
self
.mode
==
G
ameBoy
Mode
::
Sgb
}
}
#[inline(always)]
#[inline(always)]
pub
fn
mode
(
&
self
)
->
G
B
Mode
{
pub
fn
mode
(
&
self
)
->
G
ameBoy
Mode
{
self
.mode
self
.mode
}
}
#[inline(always)]
#[inline(always)]
pub
fn
set_mode
(
&
mut
self
,
value
:
G
B
Mode
)
{
pub
fn
set_mode
(
&
mut
self
,
value
:
G
ameBoy
Mode
)
{
self
.mode
=
value
;
self
.mode
=
value
;
}
}
...
@@ -189,7 +192,7 @@ pub trait AudioProvider {
...
@@ -189,7 +192,7 @@ pub trait AudioProvider {
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen)]
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen)]
impl
GameBoy
{
impl
GameBoy
{
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen(constructor))]
#[cfg_attr(feature
=
"wasm"
,
wasm_bindgen(constructor))]
pub
fn
new
(
mode
:
G
B
Mode
)
->
Self
{
pub
fn
new
(
mode
:
G
ameBoy
Mode
)
->
Self
{
let
gbc
=
Rc
::
new
(
RefCell
::
new
(
GameBoyConfig
{
let
gbc
=
Rc
::
new
(
RefCell
::
new
(
GameBoyConfig
{
mode
,
mode
,
ppu_enabled
:
true
,
ppu_enabled
:
true
,
...
@@ -282,9 +285,9 @@ impl GameBoy {
...
@@ -282,9 +285,9 @@ impl GameBoy {
pub
fn
load
(
&
mut
self
,
boot
:
bool
)
{
pub
fn
load
(
&
mut
self
,
boot
:
bool
)
{
match
self
.mode
()
{
match
self
.mode
()
{
G
B
Mode
::
Dmg
=>
self
.load_dmg
(
boot
),
G
ameBoy
Mode
::
Dmg
=>
self
.load_dmg
(
boot
),
G
B
Mode
::
Cgb
=>
self
.load_cgb
(
boot
),
G
ameBoy
Mode
::
Cgb
=>
self
.load_cgb
(
boot
),
G
B
Mode
::
Sgb
=>
todo!
(),
G
ameBoy
Mode
::
Sgb
=>
todo!
(),
}
}
}
}
...
@@ -446,11 +449,11 @@ impl GameBoy {
...
@@ -446,11 +449,11 @@ impl GameBoy {
}
}
#[inline(always)]
#[inline(always)]
pub
fn
mode
(
&
self
)
->
G
B
Mode
{
pub
fn
mode
(
&
self
)
->
G
ameBoy
Mode
{
(
*
self
.gbc
)
.borrow
()
.mode
()
(
*
self
.gbc
)
.borrow
()
.mode
()
}
}
pub
fn
set_mode
(
&
mut
self
,
value
:
G
B
Mode
)
{
pub
fn
set_mode
(
&
mut
self
,
value
:
G
ameBoy
Mode
)
{
(
*
self
.gbc
)
.borrow_mut
()
.set_mode
(
value
);
(
*
self
.gbc
)
.borrow_mut
()
.set_mode
(
value
);
}
}
...
@@ -718,6 +721,6 @@ impl AudioProvider for GameBoy {
...
@@ -718,6 +721,6 @@ impl AudioProvider for GameBoy {
impl
Default
for
GameBoy
{
impl
Default
for
GameBoy
{
fn
default
()
->
Self
{
fn
default
()
->
Self
{
Self
::
new
(
G
B
Mode
::
Dmg
)
Self
::
new
(
G
ameBoy
Mode
::
Dmg
)
}
}
}
}
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