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
115cec98
Verified
Commit
115cec98
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: better display of information
parent
45b6f484
No related branches found
No related tags found
No related merge requests found
Pipeline
#949
passed
2 years ago
Stage: build
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/sdl/src/main.rs
+2
-1
2 additions, 1 deletion
examples/sdl/src/main.rs
src/gb.rs
+3
-0
3 additions, 0 deletions
src/gb.rs
src/ppu.rs
+1
-1
1 addition, 1 deletion
src/ppu.rs
src/rom.rs
+53
-5
53 additions, 5 deletions
src/rom.rs
with
59 additions
and
7 deletions
examples/sdl/src/main.rs
+
2
−
1
View file @
115cec98
...
@@ -87,9 +87,10 @@ fn main() {
...
@@ -87,9 +87,10 @@ fn main() {
//game_boy.load_rom_file("../../res/roms.prop/tetris.gb");
//game_boy.load_rom_file("../../res/roms.prop/tetris.gb");
//game_boy.load_rom_file("../../res/roms.prop/dr_mario.gb");
//game_boy.load_rom_file("../../res/roms.prop/dr_mario.gb");
//game_boy.load_rom_file("../../res/roms.prop/alleyway.gb");
//game_boy.load_rom_file("../../res/roms.prop/alleyway.gb");
game_boy
.load_rom_file
(
"../../res/roms.prop/super_mario.gb"
);
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
game_boy
.load_rom_file
(
"../../res/roms/opus5.gb"
);
//
game_boy.load_rom_file("../../res/roms/opus5.gb");
//game_boy.load_rom_file("../../res/roms/paradius/cpu/01-special.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/01-special.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb"); // PASSED
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
3
−
0
View file @
115cec98
...
@@ -4,6 +4,7 @@ use crate::{
...
@@ -4,6 +4,7 @@ use crate::{
mmu
::
Mmu
,
mmu
::
Mmu
,
pad
::{
Pad
,
PadKey
},
pad
::{
Pad
,
PadKey
},
ppu
::{
Ppu
,
Tile
,
FRAME_BUFFER_SIZE
},
ppu
::{
Ppu
,
Tile
,
FRAME_BUFFER_SIZE
},
rom
::
Rom
,
timer
::
Timer
,
timer
::
Timer
,
util
::
read_file
,
util
::
read_file
,
};
};
...
@@ -69,6 +70,8 @@ impl GameBoy {
...
@@ -69,6 +70,8 @@ impl GameBoy {
}
}
pub
fn
load_rom
(
&
mut
self
,
data
:
&
[
u8
])
{
pub
fn
load_rom
(
&
mut
self
,
data
:
&
[
u8
])
{
let
rom
=
Rom
::
from_data
(
data
);
println!
(
"{}"
,
rom
);
self
.cpu
.mmu
()
.write_rom
(
0x0000
,
data
);
self
.cpu
.mmu
()
.write_rom
(
0x0000
,
data
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
1
−
1
View file @
115cec98
...
@@ -113,7 +113,7 @@ impl Display for ObjectData {
...
@@ -113,7 +113,7 @@ impl Display for ObjectData {
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
write!
(
f
,
f
,
"Index => {}
X => {}
Y => {}
Tile => {}"
,
"Index => {}
\n
X => {}
\n
Y => {}
\n
Tile => {}"
,
self
.index
,
self
.x
,
self
.y
,
self
.tile
self
.index
,
self
.x
,
self
.y
,
self
.tile
)
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/rom.rs
+
53
−
5
View file @
115cec98
use
core
::
fmt
;
use
std
::
fmt
::{
Display
,
Formatter
};
pub
struct
Rom
{
pub
struct
Rom
{
data
:
Vec
<
u8
>
,
data
:
Vec
<
u8
>
,
}
}
pub
enum
RomType
{
pub
enum
RomType
{
RomOnly
=
0x00
,
RomOnly
=
0x00
,
Mbc1
=
0x01
,
Mbc1
=
0x01
,
...
@@ -12,12 +14,58 @@ pub enum RomType {
...
@@ -12,12 +14,58 @@ pub enum RomType {
Unknown
=
0xff
,
Unknown
=
0xff
,
}
}
pub
enum
RomSize
{
Size32K
=
32
,
Size64K
=
64
,
Size128K
=
128
,
SizeUnknown
=
0
,
}
impl
Rom
{
impl
Rom
{
pub
fn
title
()
->
&
'static
str
{
pub
fn
from_data
(
data
:
&
[
u8
])
->
Self
{
"asdas"
Self
{
data
:
data
.to_vec
(),
}
}
}
pub
fn
rom_type
()
->
RomType
{
pub
fn
data
(
&
self
)
->
&
Vec
<
u8
>
{
RomType
::
RomOnly
&
self
.data
}
pub
fn
title
(
&
self
)
->
&
str
{
std
::
str
::
from_utf8
(
&
self
.data
[
0x0134
..
0x0143
])
.unwrap
()
}
pub
fn
rom_type
(
&
self
)
->
RomType
{
match
self
.data
[
0x0147
]
{
0x00
=>
RomType
::
RomOnly
,
0x01
=>
RomType
::
Mbc1
,
0x02
=>
RomType
::
Mbc1Ram
,
0x03
=>
RomType
::
Mbc1RamBattery
,
0x05
=>
RomType
::
Mbc2
,
0x06
=>
RomType
::
Mbc2Battery
,
_
=>
RomType
::
Unknown
,
}
}
pub
fn
size
(
&
self
)
->
RomSize
{
match
self
.data
[
0x0148
]
{
0x00
=>
RomSize
::
Size32K
,
0x01
=>
RomSize
::
Size64K
,
0x02
=>
RomSize
::
Size128K
,
_
=>
RomSize
::
SizeUnknown
,
}
}
}
impl
Display
for
Rom
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"Name => {}
\n
Type => {}
\n
Size => {}"
,
self
.title
(),
self
.rom_type
()
as
u8
,
self
.size
()
as
u32
)
}
}
}
}
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