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
1096c7e5
Verified
Commit
1096c7e5
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: better printing support for specs
Will allow much better debug.
parent
71a51c80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!16
Support for Game Boy Color (CGB) 😎🖍️
Pipeline
#2591
failed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontends/sdl/src/main.rs
+3
-10
3 additions, 10 deletions
frontends/sdl/src/main.rs
src/gb.rs
+38
-2
38 additions, 2 deletions
src/gb.rs
src/rom.rs
+21
-9
21 additions, 9 deletions
src/rom.rs
with
62 additions
and
21 deletions
frontends/sdl/src/main.rs
+
3
−
10
View file @
1096c7e5
...
...
@@ -8,7 +8,6 @@ use audio::Audio;
use
boytacean
::{
devices
::
printer
::
PrinterDevice
,
gb
::{
AudioProvider
,
GameBoy
,
GameBoyMode
},
gen
::
VERSION
,
pad
::
PadKey
,
ppu
::{
PaletteInfo
,
PpuMode
,
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
},
};
...
...
@@ -472,15 +471,6 @@ fn main() {
let
args
=
Args
::
parse
();
let
mode
=
GameBoyMode
::
from_str
(
&
args
.mode
);
// prints the current version of the emulator (informational message)
println!
(
"========= Boytacean ========="
);
println!
(
"Version {}"
,
VERSION
);
println!
(
"Mode {}"
,
mode
);
println!
(
"CPU Freq. 4.34 Mhz"
);
println!
(
"RAM Size 32 KB"
);
println!
(
"ROM Size 32 KB"
);
println!
(
"VRAM Size 32 KB"
);
// creates a new Game Boy instance and loads both the boot ROM
// and the initial game ROM to "start the engine"
let
mut
game_boy
=
GameBoy
::
new
(
mode
);
...
...
@@ -499,6 +489,9 @@ fn main() {
game_boy
.attach_serial
(
printer
);
game_boy
.load
(
true
);
// prints the current version of the emulator (informational message)
println!
(
"========= Boytacean =========
\n
{}"
,
game_boy
);
// creates a new generic emulator structure then starts
// both the video and audio sub-systems, loads default
// ROM file and starts running it
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
38
−
2
View file @
1096c7e5
...
...
@@ -3,11 +3,11 @@ use crate::{
cpu
::
Cpu
,
data
::{
BootRom
,
CGB_BOOT
,
DMG_BOOT
,
DMG_BOOTIX
,
MGB_BOOTIX
,
SGB_BOOT
},
devices
::{
printer
::
PrinterDevice
,
stdout
::
StdoutDevice
},
gen
::{
COMPILATION_DATE
,
COMPILATION_TIME
,
COMPILER
,
COMPILER_VERSION
},
gen
::{
COMPILATION_DATE
,
COMPILATION_TIME
,
COMPILER
,
COMPILER_
VERSION
,
VERSION
},
mmu
::
Mmu
,
pad
::{
Pad
,
PadKey
},
ppu
::{
Ppu
,
PpuMode
,
Tile
,
FRAME_BUFFER_SIZE
},
rom
::
Cartridge
,
rom
::
{
Cartridge
,
RamSize
},
serial
::{
NullDevice
,
Serial
,
SerialDevice
},
timer
::
Timer
,
util
::
read_file
,
...
...
@@ -591,6 +591,36 @@ impl GameBoy {
pub
fn
attach_printer_serial
(
&
mut
self
)
{
self
.attach_serial
(
Box
::
<
PrinterDevice
>
::
default
());
}
pub
fn
ram_size
(
&
self
)
->
RamSize
{
match
self
.mode
{
GameBoyMode
::
Dmg
=>
RamSize
::
Size8K
,
GameBoyMode
::
Cgb
=>
RamSize
::
Size32K
,
GameBoyMode
::
Sgb
=>
RamSize
::
Size8K
,
}
}
pub
fn
vram_size
(
&
self
)
->
RamSize
{
match
self
.mode
{
GameBoyMode
::
Dmg
=>
RamSize
::
Size8K
,
GameBoyMode
::
Cgb
=>
RamSize
::
Size16K
,
GameBoyMode
::
Sgb
=>
RamSize
::
Size8K
,
}
}
pub
fn
description
(
&
self
,
column_length
:
usize
)
->
String
{
format!
(
"{} {}
\n
{} {}
\n
{} {}
\n
{} {}"
,
format!
(
"{:width$}"
,
"Version"
,
width
=
column_length
),
VERSION
,
format!
(
"{:width$}"
,
"Mode"
,
width
=
column_length
),
self
.mode
(),
format!
(
"{:width$}"
,
"RAM Size"
,
width
=
column_length
),
self
.ram_size
(),
format!
(
"{:width$}"
,
"VRAM Size"
,
width
=
column_length
),
self
.vram_size
(),
)
}
}
/// Gameboy implementations that are meant with performance
...
...
@@ -801,3 +831,9 @@ impl Default for GameBoy {
Self
::
new
(
GameBoyMode
::
Dmg
)
}
}
impl
Display
for
GameBoy
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"{}"
,
self
.description
(
9
))
}
}
This diff is collapsed.
Click to expand it.
src/rom.rs
+
21
−
9
View file @
1096c7e5
use
core
::
fmt
;
use
std
::{
any
::
Any
,
cmp
::
max
,
fmt
::{
Display
,
Formatter
},
};
...
...
@@ -144,6 +145,7 @@ pub enum RamSize {
NoRam
,
Unused
,
Size8K
,
Size16K
,
Size32K
,
Size64K
,
Size128K
,
...
...
@@ -156,6 +158,7 @@ impl RamSize {
RamSize
::
NoRam
=>
"No RAM"
,
RamSize
::
Unused
=>
"Unused"
,
RamSize
::
Size8K
=>
"8 KB"
,
RamSize
::
Size16K
=>
"16 KB"
,
RamSize
::
Size32K
=>
"32 KB"
,
RamSize
::
Size128K
=>
"128 KB"
,
RamSize
::
Size64K
=>
"64 KB"
,
...
...
@@ -168,6 +171,7 @@ impl RamSize {
RamSize
::
NoRam
=>
0
,
RamSize
::
Unused
=>
0
,
RamSize
::
Size8K
=>
1
,
RamSize
::
Size16K
=>
2
,
RamSize
::
Size32K
=>
4
,
RamSize
::
Size64K
=>
8
,
RamSize
::
Size128K
=>
16
,
...
...
@@ -498,6 +502,22 @@ impl Cartridge {
pub
fn
set_ram_data
(
&
mut
self
,
ram_data
:
Vec
<
u8
>
)
{
self
.ram_data
=
ram_data
;
}
pub
fn
description
(
&
self
,
column_length
:
usize
)
->
String
{
format!
(
"{} {}
\n
{} {}
\n
{} {}
\n
{} {}
\n
{} {}"
,
format!
(
"{:width$}"
,
"Name"
,
width
=
column_length
),
self
.title
(),
format!
(
"{:width$}"
,
"Type"
,
width
=
column_length
),
self
.rom_type
(),
format!
(
"{:width$}"
,
"ROM Size"
,
width
=
column_length
),
self
.rom_size
(),
format!
(
"{:width$}"
,
"RAM Size"
,
width
=
column_length
),
self
.ram_size
(),
format!
(
"{:width$}"
,
"CGB Mode"
,
width
=
column_length
),
self
.cgb_flag
()
)
}
}
impl
Default
for
Cartridge
{
...
...
@@ -508,15 +528,7 @@ impl Default for Cartridge {
impl
Display
for
Cartridge
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"Name {}
\n
Type {}
\n
ROM Size {}
\n
RAM Size {}
\n
CGB Mode {}"
,
self
.title
(),
self
.rom_type
(),
self
.rom_size
(),
self
.ram_size
(),
self
.cgb_flag
()
)
write!
(
f
,
"{}"
,
self
.description
(
9
))
}
}
...
...
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