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
3cb92ad8
Verified
Commit
3cb92ad8
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fix: issues related to WASM
parent
ce6c8df9
No related branches found
No related tags found
1 merge request
!3
Support for sprites/object drawing 💪
Pipeline
#928
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/sdl/src/main.rs
+19
-13
19 additions, 13 deletions
examples/sdl/src/main.rs
src/inst.rs
+0
-6
0 additions, 6 deletions
src/inst.rs
src/ppu.rs
+7
-4
7 additions, 4 deletions
src/ppu.rs
with
26 additions
and
23 deletions
examples/sdl/src/main.rs
+
19
−
13
View file @
3cb92ad8
...
@@ -118,12 +118,18 @@ fn main() {
...
@@ -118,12 +118,18 @@ fn main() {
Event
::
KeyDown
{
Event
::
KeyDown
{
keycode
:
Some
(
keycode
),
keycode
:
Some
(
keycode
),
..
..
}
=>
game_boy
.key_press
(
key_to_pad
(
keycode
)),
}
=>
match
key_to_pad
(
keycode
)
{
Some
(
key
)
=>
game_boy
.key_press
(
key
),
None
=>
(),
},
Event
::
KeyUp
{
Event
::
KeyUp
{
keycode
:
Some
(
keycode
),
keycode
:
Some
(
keycode
),
..
..
}
=>
game_boy
.key_lift
(
key_to_pad
(
keycode
)),
}
=>
match
key_to_pad
(
keycode
)
{
Some
(
key
)
=>
game_boy
.key_lift
(
key
),
None
=>
(),
},
_
=>
(),
_
=>
(),
}
}
...
@@ -160,17 +166,17 @@ fn main() {
...
@@ -160,17 +166,17 @@ fn main() {
}
}
}
}
fn
key_to_pad
(
keycode
:
Keycode
)
->
PadKey
{
fn
key_to_pad
(
keycode
:
Keycode
)
->
Option
<
PadKey
>
{
match
keycode
{
match
keycode
{
Keycode
::
Up
=>
PadKey
::
Up
,
Keycode
::
Up
=>
Some
(
PadKey
::
Up
)
,
Keycode
::
Down
=>
PadKey
::
Down
,
Keycode
::
Down
=>
Some
(
PadKey
::
Down
)
,
Keycode
::
Left
=>
PadKey
::
Left
,
Keycode
::
Left
=>
Some
(
PadKey
::
Left
)
,
Keycode
::
Right
=>
PadKey
::
Right
,
Keycode
::
Right
=>
Some
(
PadKey
::
Right
)
,
Keycode
::
Return
=>
PadKey
::
Start
,
Keycode
::
Return
=>
Some
(
PadKey
::
Start
)
,
Keycode
::
Return2
=>
PadKey
::
Start
,
Keycode
::
Return2
=>
Some
(
PadKey
::
Start
)
,
Keycode
::
Space
=>
PadKey
::
Select
,
Keycode
::
Space
=>
Some
(
PadKey
::
Select
)
,
Keycode
::
A
=>
PadKey
::
A
,
Keycode
::
A
=>
Some
(
PadKey
::
A
)
,
Keycode
::
S
=>
PadKey
::
B
,
Keycode
::
S
=>
Some
(
PadKey
::
B
)
,
_
=>
PadKey
::
A
,
//@todo this does not make sence, make it an Option
_
=>
None
,
}
}
}
}
This diff is collapsed.
Click to expand it.
src/inst.rs
+
0
−
6
View file @
3cb92ad8
...
@@ -555,12 +555,6 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [
...
@@ -555,12 +555,6 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [
fn
nop
(
_cpu
:
&
mut
Cpu
)
{}
fn
nop
(
_cpu
:
&
mut
Cpu
)
{}
fn
noimpl
(
_cpu
:
&
mut
Cpu
)
{
let
ten_millis
=
time
::
Duration
::
from_millis
(
10000
);
thread
::
sleep
(
ten_millis
);
// @todo remove this hack
todo!
(
"Instruction not implemented"
);
}
fn
illegal
(
_cpu
:
&
mut
Cpu
)
{
fn
illegal
(
_cpu
:
&
mut
Cpu
)
{
panic!
(
"Illegal instruction"
);
panic!
(
"Illegal instruction"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
7
−
4
View file @
3cb92ad8
...
@@ -58,15 +58,18 @@ impl Tile {
...
@@ -58,15 +58,18 @@ impl Tile {
self
.buffer
[
y
*
TILE_WIDTH
+
x
]
=
value
;
self
.buffer
[
y
*
TILE_WIDTH
+
x
]
=
value
;
}
}
pub
fn
get_row
(
&
self
,
y
:
usize
)
->
&
[
u8
]
{
&
self
.buffer
[
y
*
TILE_WIDTH
..
(
y
+
1
)
*
TILE_WIDTH
]
}
pub
fn
buffer
(
&
self
)
->
Vec
<
u8
>
{
pub
fn
buffer
(
&
self
)
->
Vec
<
u8
>
{
self
.buffer
.to_vec
()
self
.buffer
.to_vec
()
}
}
}
}
impl
Tile
{
pub
fn
get_row
(
&
self
,
y
:
usize
)
->
&
[
u8
]
{
&
self
.buffer
[
y
*
TILE_WIDTH
..
(
y
+
1
)
*
TILE_WIDTH
]
}
}
impl
Tile
{
impl
Tile
{
pub
fn
palette_buffer
(
&
self
,
palette
:
Palette
)
->
Vec
<
u8
>
{
pub
fn
palette_buffer
(
&
self
,
palette
:
Palette
)
->
Vec
<
u8
>
{
self
.buffer
self
.buffer
...
...
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