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
0fa80392
Verified
Commit
0fa80392
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: more changes
parent
d5725652
No related branches found
No related tags found
1 merge request
!8
Support for react.js components
Pipeline
#1051
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+2
-0
2 additions, 0 deletions
README.md
src/gb.rs
+3
-3
3 additions, 3 deletions
src/gb.rs
src/rom.rs
+51
-28
51 additions, 28 deletions
src/rom.rs
with
56 additions
and
31 deletions
README.md
+
2
−
0
View file @
0fa80392
...
...
@@ -2,6 +2,8 @@
A Game Boy emulator that is written in Rust 🦀.
**This emulator has been written for educational purposes and shouldn't be taken to seriously.**
But yeahh it plays games... 🎮
## Build
### WASM for Node.js
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
3
−
3
View file @
0fa80392
...
...
@@ -205,11 +205,11 @@ impl GameBoy {
#[wasm_bindgen]
extern
"C"
{
#[wasm_bindgen(js_namespace
=
window)]
fn
panic
(
s
:
&
str
);
fn
panic
(
message
:
&
str
);
}
#[cfg(feature
=
"wasm"
)]
pub
fn
hook_impl
(
info
:
&
PanicInfo
)
{
let
m
sg
=
info
.to_string
();
panic
(
m
sg
.as_str
());
let
m
essage
=
info
.to_string
();
panic
(
m
essage
.as_str
());
}
This diff is collapsed.
Click to expand it.
src/rom.rs
+
51
−
28
View file @
0fa80392
...
...
@@ -45,9 +45,9 @@ pub enum RomType {
Unknown
=
0xef
,
}
impl
Display
for
RomType
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
let
str
=
match
self
{
impl
RomType
{
pub
fn
description
(
&
self
)
->
&
'static
str
{
match
self
{
RomType
::
RomOnly
=>
"ROM Only"
,
RomType
::
Mbc1
=>
"MBC1"
,
RomType
::
Mbc1Ram
=>
"MBC1 + RAM"
,
...
...
@@ -77,8 +77,13 @@ impl Display for RomType {
RomType
::
HuC3
=>
"HuC3"
,
RomType
::
HuC1RamBattery
=>
"HuC1 + RAM + BATTERY"
,
RomType
::
Unknown
=>
"Unknown"
,
};
write!
(
f
,
"{}"
,
str
)
}
}
}
impl
Display
for
RomType
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"{}"
,
self
.description
())
}
}
...
...
@@ -97,6 +102,21 @@ pub enum RomSize {
}
impl
RomSize
{
pub
fn
description
(
&
self
)
->
&
'static
str
{
match
self
{
RomSize
::
Size32K
=>
"32 KB"
,
RomSize
::
Size64K
=>
"64 KB"
,
RomSize
::
Size128K
=>
"128 KB"
,
RomSize
::
Size256K
=>
"256 KB"
,
RomSize
::
Size512K
=>
"512 KB"
,
RomSize
::
Size1M
=>
"1 MB"
,
RomSize
::
Size2M
=>
"2 MB"
,
RomSize
::
Size4M
=>
"4 MB"
,
RomSize
::
Size8M
=>
"8 MB"
,
RomSize
::
SizeUnknown
=>
"Unknown"
,
}
}
pub
fn
rom_banks
(
&
self
)
->
u16
{
match
self
{
RomSize
::
Size32K
=>
2
,
...
...
@@ -115,19 +135,7 @@ impl RomSize {
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
::
Size256K
=>
"256 KB"
,
RomSize
::
Size512K
=>
"512 KB"
,
RomSize
::
Size1M
=>
"1 MB"
,
RomSize
::
Size2M
=>
"2 MB"
,
RomSize
::
Size4M
=>
"4 MB"
,
RomSize
::
Size8M
=>
"8 MB"
,
RomSize
::
SizeUnknown
=>
"Unknown"
,
};
write!
(
f
,
"{}"
,
str
)
write!
(
f
,
"{}"
,
self
.description
())
}
}
...
...
@@ -143,6 +151,18 @@ pub enum RamSize {
}
impl
RamSize
{
pub
fn
description
(
&
self
)
->
&
'static
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"
,
}
}
pub
fn
ram_banks
(
&
self
)
->
u16
{
match
self
{
RamSize
::
NoRam
=>
0
,
...
...
@@ -158,16 +178,7 @@ impl RamSize {
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
)
write!
(
f
,
"{}"
,
self
.description
())
}
}
...
...
@@ -376,6 +387,18 @@ impl Cartridge {
_
=>
RamSize
::
SizeUnknown
,
}
}
pub
fn
rom_type_s
(
&
self
)
->
String
{
String
::
from
(
self
.rom_type
()
.description
())
}
pub
fn
rom_size_s
(
&
self
)
->
String
{
String
::
from
(
self
.rom_size
()
.description
())
}
pub
fn
ram_size_s
(
&
self
)
->
String
{
String
::
from
(
self
.ram_size
()
.description
())
}
}
impl
Display
for
Cartridge
{
...
...
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