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
397a4d53
Verified
Commit
397a4d53
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fet: new ram structure
parent
33996d5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/web/gb.ts
+14
-0
14 additions, 0 deletions
examples/web/gb.ts
with
14 additions
and
0 deletions
examples/web/gb.ts
+
14
−
0
View file @
397a4d53
...
@@ -199,11 +199,21 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
...
@@ -199,11 +199,21 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
this
.
gameBoy
?.
ppu_mode
()
===
PpuMode
.
VBlank
&&
this
.
gameBoy
?.
ppu_mode
()
===
PpuMode
.
VBlank
&&
this
.
gameBoy
?.
ppu_frame
()
!==
lastFrame
this
.
gameBoy
?.
ppu_frame
()
!==
lastFrame
)
{
)
{
// updates the reference to the last frame index
// to be used for comparison in the next tick
lastFrame
=
this
.
gameBoy
?.
ppu_frame
();
lastFrame
=
this
.
gameBoy
?.
ppu_frame
();
// triggers the frame event indicating that
// triggers the frame event indicating that
// a new frame is now available for drawing
// a new frame is now available for drawing
this
.
trigger
(
"
frame
"
);
this
.
trigger
(
"
frame
"
);
// @todo this has to be structureed in a better way
if
(
this
.
cartridge
&&
this
.
cartridge
.
has_battery
())
{
const
ramData
=
this
.
cartridge
.
ram_data_eager
();
const
decoder
=
new
TextDecoder
(
"
utf8
"
);
const
ramDataB64
=
btoa
(
decoder
.
decode
(
ramData
));
localStorage
.
setItem
(
this
.
cartridge
.
title
(),
ramDataB64
)
}
}
}
}
}
...
@@ -289,6 +299,10 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
...
@@ -289,6 +299,10 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
this
.
gameBoy
.
load_boot_default
();
this
.
gameBoy
.
load_boot_default
();
const
cartridge
=
this
.
gameBoy
.
load_rom_ws
(
romData
!
);
const
cartridge
=
this
.
gameBoy
.
load_rom_ws
(
romData
!
);
// in case there's a battery involved tries to obtain
if
(
cartridge
.
has_battery
())
{
}
// updates the ROM name in case there's extra information
// updates the ROM name in case there's extra information
// coming from the cartridge
// coming from the cartridge
romName
=
cartridge
.
title
()
?
cartridge
.
title
()
:
romName
;
romName
=
cartridge
.
title
()
?
cartridge
.
title
()
:
romName
;
...
...
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