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
62b4fc96
Verified
Commit
62b4fc96
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: removed more dead code and allowed
engine switching
parent
7da32e19
No related branches found
No related tags found
1 merge request
!9
Version 0.4.0 🍾
Pipeline
#1400
passed
2 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/web/index.html
+1
-58
1 addition, 58 deletions
examples/web/index.html
examples/web/index.ts
+0
-23
0 additions, 23 deletions
examples/web/index.ts
examples/web/react/app.tsx
+37
-24
37 additions, 24 deletions
examples/web/react/app.tsx
with
38 additions
and
105 deletions
examples/web/index.html
+
1
−
58
View file @
62b4fc96
...
@@ -18,70 +18,13 @@
...
@@ -18,70 +18,13 @@
<div
class=
"side-left"
>
<div
class=
"side-left"
>
</div>
</div>
<div
class=
"side-right"
>
<div
class=
"side-right"
>
<div
class=
"separator"
></div>
<div
id=
"separator-narrative"
class=
"separator"
></div>
<div
id=
"section-narrative"
class=
"section"
>
<p>
This is a
<a
href=
"https://en.wikipedia.org/wiki/Game_Boy"
target=
"_blank"
>
Game Boy
</a>
emulator built using
the
<a
href=
"https://www.rust-lang.org"
target=
"_blank"
>
Rust Programming Language
</a>
and is running
inside this browser with the help of
<a
href=
"https://webassembly.org/"
target=
"_blank"
>
WebAssembly
</a>
.
</p>
<p>
You can check the source code of it at
<a
href=
"https://gitlab.stage.hive.pt/joamag/boytacean"
target=
"_blank"
>
GitLab
</a>
.
</p>
<p>
TIP: Drag and Drop ROM files to the Browser to load the ROM.
</p>
</div>
<div
id=
"separator-narrative"
class=
"separator"
></div>
<div
id=
"section-keyboard"
class=
"section"
style=
"display: none;"
>
<div
id=
"keyboard"
class=
"keyboard"
>
<div
class=
"keyboard-line"
>
<span
class=
"key"
>
1
</span>
<span
class=
"key"
>
2
</span>
<span
class=
"key"
>
3
</span>
<span
class=
"key"
>
4
</span>
</div>
<div
class=
"keyboard-line"
>
<span
class=
"key"
>
Q
</span>
<span
class=
"key"
>
W
</span>
<span
class=
"key"
>
E
</span>
<span
class=
"key"
>
R
</span>
</div>
<div
class=
"keyboard-line"
>
<span
class=
"key"
>
A
</span>
<span
class=
"key"
>
S
</span>
<span
class=
"key"
>
D
</span>
<span
class=
"key"
>
F
</span>
</div>
<div
class=
"keyboard-line"
>
<span
class=
"key"
>
Z
</span>
<span
class=
"key"
>
X
</span>
<span
class=
"key"
>
C
</span>
<span
class=
"key"
>
V
</span>
</div>
</div>
</div>
<div
id=
"separator-keyboard"
class=
"separator"
style=
"display: none;"
></div>
<div
id=
"section-debug"
class=
"section"
style=
"display: none;"
>
<div
id=
"section-debug"
class=
"section"
style=
"display: none;"
>
<div
id=
"debug"
class=
"debug"
>
<div
id=
"debug"
class=
"debug"
>
<canvas
id=
"canvas-tiles"
class=
"canvas-tiles"
width=
"128"
height=
"192"
></canvas>
<canvas
id=
"canvas-tiles"
class=
"canvas-tiles"
width=
"128"
height=
"192"
></canvas>
</div>
</div>
</div>
</div>
<div
id=
"separator-debug"
class=
"separator"
style=
"display: none;"
></div>
<div
id=
"separator-debug"
class=
"separator"
style=
"display: none;"
></div>
<div
id=
"section-diag"
class=
"section"
>
<dl
class=
"diag"
>
<dt>
Engine
</dt>
<dd
id=
"engine"
class=
"button simple"
>
-
</dd>
<dt>
ROM
</dt>
<dd
id=
"rom-name"
>
-
</dd>
<dt>
ROM Size
</dt>
<dd><span
id=
"rom-size"
>
-
</span>
bytes
</dd>
<dt>
CPU Frequency
</dt>
<dd>
<span
id=
"logic-frequency-minus"
class=
"button simple"
>
-
</span>
<span
id=
"logic-frequency"
>
-
</span>
Hz
<span
id=
"logic-frequency-plus"
class=
"button simple"
>
+
</span></dd>
<dt>
Framerate
</dt>
<dd><span
id=
"fps-count"
>
-
</span>
fps
</dd>
</dl>
</div>
<div
id=
"separator-diag"
class=
"separator"
></div>
<div
class=
"section"
>
<div
class=
"section"
>
<div
class=
"button-area"
>
<div
class=
"button-area"
>
<span
id=
"button-pause"
class=
"button simple border padded"
>
<span
id=
"button-pause"
class=
"button simple border padded"
>
...
...
This diff is collapsed.
Click to expand it.
examples/web/index.ts
+
0
−
23
View file @
62b4fc96
...
@@ -422,29 +422,6 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -422,29 +422,6 @@ class GameboyEmulator extends Observable implements Emulator {
}
}
registerButtons
()
{
registerButtons
()
{
const
engine
=
document
.
getElementById
(
"
engine
"
)
!
;
engine
.
addEventListener
(
"
click
"
,
()
=>
{
const
name
=
this
.
engine
===
"
neo
"
?
"
classic
"
:
"
neo
"
;
this
.
boot
({
engine
:
name
});
this
.
trigger
(
"
message
"
,
{
text
:
`Game Boy running in engine "
${
name
.
toUpperCase
()}
" from now on!`
});
});
const
logicFrequencyPlus
=
document
.
getElementById
(
"
logic-frequency-plus
"
)
!
;
logicFrequencyPlus
.
addEventListener
(
"
click
"
,
()
=>
{
this
.
logicFrequency
=
this
.
logicFrequency
+
FREQUENCY_DELTA
;
});
const
logicFrequencyMinus
=
document
.
getElementById
(
"
logic-frequency-minus
"
)
!
;
logicFrequencyMinus
.
addEventListener
(
"
click
"
,
()
=>
{
this
.
logicFrequency
=
this
.
logicFrequency
-
FREQUENCY_DELTA
;
});
const
buttonPause
=
document
.
getElementById
(
"
button-pause
"
)
!
;
const
buttonPause
=
document
.
getElementById
(
"
button-pause
"
)
!
;
buttonPause
.
addEventListener
(
"
click
"
,
()
=>
{
buttonPause
.
addEventListener
(
"
click
"
,
()
=>
{
this
.
toggleRunning
();
this
.
toggleRunning
();
...
...
This diff is collapsed.
Click to expand it.
examples/web/react/app.tsx
+
37
−
24
View file @
62b4fc96
...
@@ -146,6 +146,15 @@ export interface Emulator extends ObservableI {
...
@@ -146,6 +146,15 @@ export interface Emulator extends ObservableI {
* re-loads the ROM that is currently set in the emulator.
* re-loads the ROM that is currently set in the emulator.
*/
*/
reset
():
void
;
reset
():
void
;
/**
* Boot (or reboots) the emulator according to the provided
* set of options.
*
* @param options The options that are going to be used for
* the booting operation of the emulator.
*/
boot
(
options
:
any
):
void
;
}
}
/**
/**
...
@@ -299,6 +308,10 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
...
@@ -299,6 +308,10 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
const
onThemeClick
=
()
=>
{
const
onThemeClick
=
()
=>
{
setBackgroundIndex
((
backgroundIndex
+
1
)
%
backgrounds
.
length
);
setBackgroundIndex
((
backgroundIndex
+
1
)
%
backgrounds
.
length
);
};
};
const
onEngineChange
=
(
engine
:
string
)
=>
{
emulator
.
boot
({
engine
:
engine
.
toLowerCase
()
});
showToast
(
`Game Boy running in engine "
${
engine
}
" from now on!`
);
};
const
onMinimize
=
()
=>
{
const
onMinimize
=
()
=>
{
setFullscreen
(
!
fullscreen
);
setFullscreen
(
!
fullscreen
);
};
};
...
@@ -438,6 +451,30 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
...
@@ -438,6 +451,30 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
/>
/>
</
ButtonContainer
>
</
ButtonContainer
>
<
Info
>
<
Info
>
<
Pair
key
=
"button-engine"
name
=
{
"
Engine
"
}
valueNode
=
{
<
ButtonSwitch
options
=
{
[
"
NEO
"
,
"
CLASSIC
"
]
}
size
=
{
"
large
"
}
style
=
{
[
"
simple
"
]
}
onChange
=
{
onEngineChange
}
/>
}
/>
<
Pair
key
=
"button-frequency"
name
=
{
"
CPU Frequency
"
}
valueNode
=
{
<
ButtonIncrement
value
=
{
200
}
delta
=
{
100
}
min
=
{
0
}
suffix
=
{
"
Hz
"
}
/>
}
/>
<
Pair
<
Pair
key
=
"rom"
key
=
"rom"
name
=
{
"
ROM
"
}
name
=
{
"
ROM
"
}
...
@@ -462,30 +499,6 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
...
@@ -462,30 +499,6 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
name
=
{
"
Framerate
"
}
name
=
{
"
Framerate
"
}
value
=
{
`
${
framerate
}
fps`
}
value
=
{
`
${
framerate
}
fps`
}
/>
/>
<
Pair
key
=
"button-tobias"
name
=
{
"
Button Increment
"
}
valueNode
=
{
<
ButtonIncrement
value
=
{
200
}
delta
=
{
100
}
min
=
{
0
}
suffix
=
{
"
Hz
"
}
/>
}
/>
<
Pair
key
=
"button-cpu"
name
=
{
"
Button Switch
"
}
valueNode
=
{
<
ButtonSwitch
options
=
{
[
"
NEO
"
,
"
CLASSIC
"
]
}
size
=
{
"
large
"
}
style
=
{
[
"
simple
"
]
}
onChange
=
{
(
v
)
=>
alert
(
v
)
}
/>
}
/>
</
Info
>
</
Info
>
</
Section
>
</
Section
>
</
PanelSplit
>
</
PanelSplit
>
...
...
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