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
96c36113
Verified
Commit
96c36113
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: renamed start method
parent
8ae6949b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!9
Version 0.4.0 🍾
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/web/index.ts
+14
-11
14 additions, 11 deletions
examples/web/index.ts
examples/web/react/app.tsx
+1
-1
1 addition, 1 deletion
examples/web/react/app.tsx
with
15 additions
and
12 deletions
examples/web/index.ts
+
14
−
11
View file @
96c36113
...
@@ -100,9 +100,9 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -100,9 +100,9 @@ class GameboyEmulator extends Observable implements Emulator {
await
this
.
init
();
await
this
.
init
();
await
this
.
register
();
await
this
.
register
();
//
start
the emulator subsystem with the initial
//
boots
the emulator subsystem with the initial
// ROM retrieved from a remote data source
// ROM retrieved from a remote data source
await
this
.
star
t
({
loadRom
:
true
});
await
this
.
boo
t
({
loadRom
:
true
});
// the counter that controls the overflowing cycles
// the counter that controls the overflowing cycles
// from tick to tick operation
// from tick to tick operation
...
@@ -157,7 +157,7 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -157,7 +157,7 @@ class GameboyEmulator extends Observable implements Emulator {
// also sets the default color on screen to indicate the issue
// also sets the default color on screen to indicate the issue
if
(
isPanic
)
{
if
(
isPanic
)
{
await
wasm
();
await
wasm
();
await
this
.
star
t
({
restore
:
false
});
await
this
.
boo
t
({
restore
:
false
});
this
.
trigger
(
"
error
"
);
this
.
trigger
(
"
error
"
);
}
}
...
@@ -251,11 +251,14 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -251,11 +251,14 @@ class GameboyEmulator extends Observable implements Emulator {
/**
/**
* Starts the current machine, setting the internal structure in
* Starts the current machine, setting the internal structure in
* a proper state to start drawing and receiving input.
* a proper state to start drawing and receiving input.
*
* This method can also be used to load a new ROM into the machine.
*
*
* @param options The options that are going to be used in the
* @param options The options that are going to be used in the
* starting of the machine.
* starting of the machine, includes information on the ROM and
* the emulator engine to use.
*/
*/
async
star
t
({
async
boo
t
({
engine
=
"
neo
"
,
engine
=
"
neo
"
,
restore
=
true
,
restore
=
true
,
loadRom
=
false
,
loadRom
=
false
,
...
@@ -317,9 +320,9 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -317,9 +320,9 @@ class GameboyEmulator extends Observable implements Emulator {
// then resumes the machine execution
// then resumes the machine execution
if
(
restore
)
this
.
resume
();
if
(
restore
)
this
.
resume
();
// triggers the
load
ed event indicating that the
// triggers the
boot
ed event indicating that the
// emulator has finished the loading process
// emulator has finished the loading process
this
.
trigger
(
"
load
ed
"
);
this
.
trigger
(
"
boot
ed
"
);
}
}
// @todo remove this method, or at least most of it
// @todo remove this method, or at least most of it
...
@@ -366,7 +369,7 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -366,7 +369,7 @@ class GameboyEmulator extends Observable implements Emulator {
const
arrayBuffer
=
await
file
.
arrayBuffer
();
const
arrayBuffer
=
await
file
.
arrayBuffer
();
const
romData
=
new
Uint8Array
(
arrayBuffer
);
const
romData
=
new
Uint8Array
(
arrayBuffer
);
this
.
star
t
({
engine
:
null
,
romName
:
file
.
name
,
romData
:
romData
});
this
.
boo
t
({
engine
:
null
,
romName
:
file
.
name
,
romData
:
romData
});
this
.
showToast
(
`Loaded
${
file
.
name
}
ROM successfully!`
);
this
.
showToast
(
`Loaded
${
file
.
name
}
ROM successfully!`
);
});
});
...
@@ -429,7 +432,7 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -429,7 +432,7 @@ class GameboyEmulator extends Observable implements Emulator {
const
engine
=
document
.
getElementById
(
"
engine
"
)
!
;
const
engine
=
document
.
getElementById
(
"
engine
"
)
!
;
engine
.
addEventListener
(
"
click
"
,
()
=>
{
engine
.
addEventListener
(
"
click
"
,
()
=>
{
const
name
=
this
.
engine
==
"
neo
"
?
"
classic
"
:
"
neo
"
;
const
name
=
this
.
engine
==
"
neo
"
?
"
classic
"
:
"
neo
"
;
this
.
star
t
({
engine
:
name
});
this
.
boo
t
({
engine
:
name
});
this
.
showToast
(
this
.
showToast
(
`Game Boy running in engine "
${
name
.
toUpperCase
()}
" from now on!`
`Game Boy running in engine "
${
name
.
toUpperCase
()}
" from now on!`
);
);
...
@@ -651,7 +654,7 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -651,7 +654,7 @@ class GameboyEmulator extends Observable implements Emulator {
buttonUploadFile
.
value
=
""
;
buttonUploadFile
.
value
=
""
;
this
.
star
t
({
engine
:
null
,
romName
:
file
.
name
,
romData
:
romData
});
this
.
boo
t
({
engine
:
null
,
romName
:
file
.
name
,
romData
:
romData
});
this
.
showToast
(
`Loaded
${
file
.
name
}
ROM successfully!`
);
this
.
showToast
(
`Loaded
${
file
.
name
}
ROM successfully!`
);
});
});
...
@@ -882,7 +885,7 @@ class GameboyEmulator extends Observable implements Emulator {
...
@@ -882,7 +885,7 @@ class GameboyEmulator extends Observable implements Emulator {
* the ROM that is currently set in the emulator.
* the ROM that is currently set in the emulator.
*/
*/
reset
()
{
reset
()
{
this
.
star
t
({
engine
:
null
});
this
.
boo
t
({
engine
:
null
});
}
}
async
fetchRom
(
romPath
:
string
):
Promise
<
[
string
,
Uint8Array
]
>
{
async
fetchRom
(
romPath
:
string
):
Promise
<
[
string
,
Uint8Array
]
>
{
...
...
This diff is collapsed.
Click to expand it.
examples/web/react/app.tsx
+
1
−
1
View file @
96c36113
...
@@ -151,7 +151,7 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
...
@@ -151,7 +151,7 @@ export const App: FC<AppProps> = ({ emulator, backgrounds = ["264653"] }) => {
event
.
preventDefault
();
event
.
preventDefault
();
}
}
});
});
emulator
.
bind
(
"
load
ed
"
,
()
=>
{
emulator
.
bind
(
"
boot
ed
"
,
()
=>
{
const
romInfo
=
emulator
.
getRomInfo
();
const
romInfo
=
emulator
.
getRomInfo
();
setRomInfo
(
romInfo
);
setRomInfo
(
romInfo
);
});
});
...
...
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