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
40f2e2cc
Verified
Commit
40f2e2cc
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: initial palette update operation
parent
33e8e59c
No related branches found
No related tags found
No related merge requests found
Pipeline
#1536
passed
2 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/web/index.ts
+14
-7
14 additions, 7 deletions
examples/web/index.ts
examples/web/react/app.tsx
+3
-1
3 additions, 1 deletion
examples/web/react/app.tsx
with
17 additions
and
8 deletions
examples/web/index.ts
+
14
−
7
View file @
40f2e2cc
...
...
@@ -33,6 +33,11 @@ const BACKGROUNDS = [
"
3a5a40
"
];
const
PALETTES
=
[
[
"
ffffff
"
,
"
c0c0c0
"
,
"
606060
"
,
"
000000
"
],
[
"
b6a571
"
,
"
8b7e56
"
,
"
554d35
"
,
"
201d13
"
]
];
const
KEYS_NAME
:
Record
<
string
,
number
>
=
{
ArrowUp
:
PadKey
.
Up
,
ArrowDown
:
PadKey
.
Down
,
...
...
@@ -73,6 +78,7 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
private
fps
:
number
=
0
;
private
frameStart
:
number
=
new
Date
().
getTime
();
private
frameCount
:
number
=
0
;
private
paletteIndex
:
number
=
0
;
private
romName
:
string
|
null
=
null
;
private
romData
:
Uint8Array
|
null
=
null
;
...
...
@@ -286,13 +292,8 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
break
;
}
// @TODO replace this with something more flexible
this
.
gameBoy
.
set_palette_colors_ws
([
"
b6a571
"
,
"
8b7e56
"
,
"
554d35
"
,
"
201d13
"
]);
// runs the initial palette update operation
this
.
updatePalette
();
// resets the Game Boy engine to restore it into
// a valid state ready to be used
...
...
@@ -464,6 +465,12 @@ class GameboyEmulator extends EmulatorBase implements Emulator {
this
.
gameBoy
?.
key_lift
(
keyCode
);
}
updatePalette
()
{
this
.
gameBoy
?.
set_palette_colors_ws
(
PALETTES
[
this
.
paletteIndex
]);
this
.
paletteIndex
+=
1
;
this
.
paletteIndex
%=
PALETTES
.
length
;
}
benchmark
(
count
=
50000000
)
{
let
cycles
=
0
;
this
.
pause
();
...
...
This diff is collapsed.
Click to expand it.
examples/web/react/app.tsx
+
3
−
1
View file @
40f2e2cc
...
...
@@ -222,6 +222,8 @@ export interface Emulator extends ObservableI {
keyLift
(
key
:
string
):
void
;
updatePalette
():
void
;
/**
* Runs a benchmark operation in the emulator, effectively
* measuring the performance of it.
...
...
@@ -483,7 +485,7 @@ export const App: FC<AppProps> = ({
setBackgroundIndex
((
backgroundIndex
+
1
)
%
backgrounds
.
length
);
};
const
onPaletteClick
=
()
=>
{
console
.
info
(
"
p
alette
"
);
emulator
.
updateP
alette
(
);
};
const
onUploadFile
=
async
(
file
:
File
)
=>
{
const
arrayBuffer
=
await
file
.
arrayBuffer
();
...
...
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