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
d2b66e9c
Verified
Commit
d2b66e9c
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: initial instruction processing
parent
4b80e173
No related branches found
No related tags found
No related merge requests found
Pipeline
#607
passed
2 years ago
Stage: build
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/chip8_neo.rs
+25
-0
25 additions, 0 deletions
src/chip8_neo.rs
with
25 additions
and
0 deletions
src/chip8_neo.rs
+
25
−
0
View file @
d2b66e9c
...
...
@@ -59,7 +59,28 @@ impl Chip8Neo {
}
pub
fn
tick
(
&
mut
self
)
{
// fetches the current instruction and increments
// the PC (program counter) accordingly
let
instruction
=
(
self
.ram
[
self
.pc
as
usize
]
as
u16
)
<<
8
|
self
.ram
[
self
.pc
as
usize
+
1
]
as
u16
;
self
.pc
+=
0x2
;
let
opcode
=
instruction
&
0xf000
;
let
address
=
instruction
&
0x0fff
;
let
nibble
=
((
instruction
&
0x0f00
)
>>
8
)
as
u8
;
let
byte
=
(
instruction
&
0x00ff
)
as
u8
;
match
opcode
{
0x0000
=>
match
byte
{
0xe0
=>
self
.clear_screen
(),
_
=>
println!
(
"unimplemented instruction"
),
},
0x1000
=>
self
.pc
=
address
,
0x6000
=>
{
self
.registers
[
nibble
as
usize
]
=
byte
;
}
_
=>
println!
(
"unimplemented instruction"
),
}
}
pub
fn
load_rom
(
&
mut
self
,
rom
:
&
[
u8
])
{
...
...
@@ -73,4 +94,8 @@ impl Chip8Neo {
fn
load_default_font
(
&
mut
self
)
{
self
.load_font
(
0
,
&
FONT_SET
);
}
fn
clear_screen
(
&
mut
self
)
{
self
.vram
=
[
0u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
];
}
}
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