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
fc175307
Verified
Commit
fc175307
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: more verbose information printing
parent
115cec98
No related branches found
No related tags found
No related merge requests found
Pipeline
#950
passed
2 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/rom.rs
+73
-8
73 additions, 8 deletions
src/rom.rs
with
73 additions
and
8 deletions
src/rom.rs
+
73
−
8
View file @
fc175307
...
...
@@ -14,11 +14,63 @@ pub enum RomType {
Unknown
=
0xff
,
}
impl
Display
for
RomType
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
let
str
=
match
self
{
RomType
::
RomOnly
=>
"ROM Only"
,
RomType
::
Mbc1
=>
"MBC 1"
,
RomType
::
Mbc1Ram
=>
"MBC 1 + RAM"
,
RomType
::
Mbc1RamBattery
=>
"MBC 1 + RAM + Battery"
,
RomType
::
Mbc2
=>
"MBC 2"
,
RomType
::
Mbc2Battery
=>
"MBC 2 + RAM"
,
RomType
::
Unknown
=>
"Unknown"
,
};
write!
(
f
,
"{}"
,
str
)
}
}
pub
enum
RomSize
{
Size32K
=
32
,
Size64K
=
64
,
Size128K
=
128
,
SizeUnknown
=
0
,
Size32K
,
Size64K
,
Size128K
,
SizeUnknown
,
}
impl
Display
for
RomSize
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
let
str
=
match
self
{
RomSize
::
Size32K
=>
"32 KB"
,
RomSize
::
Size64K
=>
"64 KB"
,
RomSize
::
Size128K
=>
"128 KB"
,
RomSize
::
SizeUnknown
=>
"Unknown"
,
};
write!
(
f
,
"{}"
,
str
)
}
}
pub
enum
RamSize
{
NoRam
,
Unused
,
Size8K
,
Size32K
,
Size64K
,
Size128K
,
SizeUnknown
,
}
impl
Display
for
RamSize
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
let
str
=
match
self
{
RamSize
::
NoRam
=>
"No RAM"
,
RamSize
::
Unused
=>
"Unused"
,
RamSize
::
Size8K
=>
"8 KB"
,
RamSize
::
Size32K
=>
"32 KB"
,
RamSize
::
Size128K
=>
"128 KB"
,
RamSize
::
Size64K
=>
"64 KB"
,
RamSize
::
SizeUnknown
=>
"Unknown"
,
};
write!
(
f
,
"{}"
,
str
)
}
}
impl
Rom
{
...
...
@@ -48,7 +100,7 @@ impl Rom {
}
}
pub
fn
size
(
&
self
)
->
RomSize
{
pub
fn
rom_
size
(
&
self
)
->
RomSize
{
match
self
.data
[
0x0148
]
{
0x00
=>
RomSize
::
Size32K
,
0x01
=>
RomSize
::
Size64K
,
...
...
@@ -56,16 +108,29 @@ impl Rom {
_
=>
RomSize
::
SizeUnknown
,
}
}
pub
fn
ram_size
(
&
self
)
->
RamSize
{
match
self
.data
[
0x0148
]
{
0x00
=>
RamSize
::
NoRam
,
0x01
=>
RamSize
::
Unused
,
0x02
=>
RamSize
::
Size8K
,
0x03
=>
RamSize
::
Size32K
,
0x04
=>
RamSize
::
Size128K
,
0x05
=>
RamSize
::
Size64K
,
_
=>
RamSize
::
SizeUnknown
,
}
}
}
impl
Display
for
Rom
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"Name => {}
\n
Type => {}
\n
Size => {}"
,
"Name => {}
\n
Type => {}
\n
ROM Size => {}
\n
RAM
Size => {}"
,
self
.title
(),
self
.rom_type
()
as
u8
,
self
.size
()
as
u32
self
.rom_type
(),
self
.rom_size
(),
self
.ram_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