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
99790dcc
Verified
Commit
99790dcc
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: improved fetch rom
parent
cb791c34
No related branches found
No related tags found
2 merge requests
!12
Version 0.4.1
,
!11
Support for remote ROM loading
Pipeline
#1450
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/web/index.ts
+9
-4
9 additions, 4 deletions
examples/web/index.ts
with
9 additions
and
4 deletions
examples/web/index.ts
+
9
−
4
View file @
99790dcc
...
...
@@ -292,7 +292,7 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
// in case a remote ROM loading operation has been
// requested then loads it from the remote origin
if
(
loadRom
)
{
[
romName
,
romData
]
=
await
this
.
fetchRom
(
romPath
);
({
name
:
romName
,
data
:
romData
}
=
await
this
.
fetchRom
(
romPath
)
)
;
}
else
if
(
romName
===
null
||
romData
===
null
)
{
[
romName
,
romData
]
=
[
this
.
romName
,
this
.
romData
];
}
...
...
@@ -509,7 +509,9 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
}
}
private
async
fetchRom
(
romPath
:
string
):
Promise
<
[
string
,
Uint8Array
]
>
{
private
async
fetchRom
(
romPath
:
string
):
Promise
<
{
name
:
string
;
data
:
Uint8Array
}
>
{
// extracts the name of the ROM from the provided
// path by splitting its structure
const
romPathS
=
romPath
.
split
(
/
\/
/g
);
...
...
@@ -519,14 +521,17 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
// loads the ROM data and converts it into the
// target byte array buffer (to be used by WASM)
const
response
=
await
fetch
(
ROM_PATH
);
const
response
=
await
fetch
(
romPath
);
const
blob
=
await
response
.
blob
();
const
arrayBuffer
=
await
blob
.
arrayBuffer
();
const
romData
=
new
Uint8Array
(
arrayBuffer
);
// returns both the name of the ROM and the data
// contents as a byte array
return
[
romName
,
romData
];
return
{
name
:
romName
,
data
:
romData
};
}
}
...
...
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