Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
chip-ahoyto
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
chip-ahoyto
Commits
01958072
Verified
Commit
01958072
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fix: key press issue
parent
09109d08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Working version of the neo implementation 🥳
Pipeline
#620
passed
2 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/sdl/src/main.rs
+1
-1
1 addition, 1 deletion
examples/sdl/src/main.rs
src/chip8_neo.rs
+15
-8
15 additions, 8 deletions
src/chip8_neo.rs
with
16 additions
and
9 deletions
examples/sdl/src/main.rs
+
1
−
1
View file @
01958072
...
...
@@ -252,7 +252,7 @@ fn main() {
}
=>
{
state
.pixel_color_index
=
(
state
.pixel_color_index
+
1
)
%
COLORS
.len
()
as
u32
;
state
.pixel_color
=
COLORS
[
state
.pixel_color_index
as
usize
];
let
diag_color_index
=
(
state
.pixel_color_index
+
2
)
%
COLORS
.len
()
as
u32
;
let
diag_color_index
=
(
state
.pixel_color_index
+
1
)
%
COLORS
.len
()
as
u32
;
state
.diag_color
=
COLORS
[
diag_color_index
as
usize
];
None
}
...
...
This diff is collapsed.
Click to expand it.
src/chip8_neo.rs
+
15
−
8
View file @
01958072
...
...
@@ -2,10 +2,11 @@ use crate::util::random;
pub
const
DISPLAY_WIDTH
:
usize
=
64
;
pub
const
DISPLAY_HEIGHT
:
usize
=
32
;
pub
const
RAM_SIZE
:
usize
=
4096
;
pub
const
STACK_SIZE
:
usize
=
16
;
pub
const
REGISTERS_SIZE
:
usize
=
16
;
pub
const
KEYS_SIZE
:
usize
=
16
;
const
RAM_SIZE
:
usize
=
4096
;
const
STACK_SIZE
:
usize
=
16
;
const
REGISTERS_SIZE
:
usize
=
16
;
const
KEYS_SIZE
:
usize
=
16
;
/// The starting address for the ROM loading, should be
/// the initial PC position for execution.
...
...
@@ -137,7 +138,7 @@ impl Chip8Neo {
self
.regs
[
0xf
]
=
overflow
as
u8
;
}
0x5
=>
{
self
.regs
[
0xf
]
=
(
self
.regs
[
x
]
>
=
self
.regs
[
y
])
as
u8
;
self
.regs
[
0xf
]
=
(
self
.regs
[
x
]
>
self
.regs
[
y
])
as
u8
;
self
.regs
[
x
]
=
self
.regs
[
x
]
.wrapping_sub
(
self
.regs
[
y
]);
}
0x6
=>
{
...
...
@@ -145,7 +146,7 @@ impl Chip8Neo {
self
.regs
[
x
]
>>=
1
;
}
0x7
=>
{
self
.regs
[
0xf
]
=
(
self
.regs
[
y
]
>
=
self
.regs
[
x
])
as
u8
;
self
.regs
[
0xf
]
=
(
self
.regs
[
y
]
>
self
.regs
[
x
])
as
u8
;
self
.regs
[
x
]
=
self
.regs
[
y
]
.wrapping_sub
(
self
.regs
[
x
]);
}
0xe
=>
{
...
...
@@ -166,8 +167,14 @@ impl Chip8Neo {
);
}
0xe000
=>
match
byte
{
0x9e
=>
self
.pc
+=
if
self
.keys
[
x
]
{
2
}
else
{
0
},
0xa1
=>
self
.pc
+=
if
!
self
.keys
[
x
]
{
2
}
else
{
0
},
0x9e
=>
{
let
key
=
self
.regs
[
x
]
as
usize
;
self
.pc
+=
if
self
.keys
[
key
]
{
2
}
else
{
0
}
}
0xa1
=>
{
let
key
=
self
.regs
[
x
]
as
usize
;
self
.pc
+=
if
!
self
.keys
[
key
]
{
2
}
else
{
0
}
}
_
=>
println!
(
"unimplemented instruction 0xe000, instruction 0x{:04x}"
,
instruction
...
...
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