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
cf6571ad
Verified
Commit
cf6571ad
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: initial loading of information
parent
c3f57505
No related branches found
No related tags found
No related merge requests found
Pipeline
#602
passed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/chip8_neo.rs
+33
-1
33 additions, 1 deletion
src/chip8_neo.rs
with
33 additions
and
1 deletion
src/chip8_neo.rs
+
33
−
1
View file @
cf6571ad
...
...
@@ -8,6 +8,25 @@ pub const REGISTERS_SIZE: usize = 16;
/// the initial PC position.
const
ROM_START
:
usize
=
0x200
;
static
FONT_SET
:
[
u8
;
80
]
=
[
0xf0
,
0x90
,
0x90
,
0x90
,
0xf0
,
// 0
0x20
,
0x60
,
0x20
,
0x20
,
0x70
,
// 1
0xf0
,
0x10
,
0xf0
,
0x80
,
0xf0
,
// 2
0xf0
,
0x10
,
0xf0
,
0x10
,
0xf0
,
// 3
0x90
,
0x90
,
0xf0
,
0x10
,
0x10
,
// 4
0xf0
,
0x80
,
0xf0
,
0x10
,
0xf0
,
// 5
0xf0
,
0x80
,
0xf0
,
0x90
,
0xf0
,
// 6
0xf0
,
0x10
,
0x20
,
0x40
,
0x40
,
// 7
0xf0
,
0x90
,
0xf0
,
0x90
,
0xf0
,
// 8
0xf0
,
0x90
,
0xf0
,
0x10
,
0xf0
,
// 9
0xf0
,
0x90
,
0xf0
,
0x90
,
0x90
,
// A
0xe0
,
0x90
,
0xe0
,
0x90
,
0xe0
,
// B
0xf0
,
0x80
,
0x80
,
0x80
,
0xf0
,
// C
0xe0
,
0x90
,
0x90
,
0x90
,
0xe0
,
// D
0xf0
,
0x80
,
0xf0
,
0x80
,
0xf0
,
// E
0xf0
,
0x80
,
0xf0
,
0x80
,
0x80
,
// F
];
pub
struct
Chip8Neo
{
ram
:
[
u8
;
RAM_SIZE
],
vram
:
[
u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
],
...
...
@@ -24,7 +43,7 @@ pub struct Chip8Neo {
impl
Chip8Neo
{
#[cfg_attr(feature
=
"web"
,
wasm_bindgen(constructor))]
pub
fn
new
()
->
Chip8Neo
{
let
chip8
=
Chip8Neo
{
let
mut
chip8
=
Chip8Neo
{
ram
:
[
0u8
;
RAM_SIZE
],
vram
:
[
0u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
],
stack
:
[
0u16
;
STACK_SIZE
],
...
...
@@ -35,10 +54,23 @@ impl Chip8Neo {
dt
:
0x0
,
st
:
0x0
,
};
chip8
.load_default_font
();
chip8
}
pub
fn
tick
(
&
mut
self
)
{
self
.pc
+=
0x2
;
}
pub
fn
load_rom
(
&
mut
self
,
rom
:
&
[
u8
])
{
self
.ram
[
ROM_START
..
ROM_START
+
rom
.len
()]
.clone_from_slice
(
&
rom
);
}
fn
load_font
(
&
mut
self
,
position
:
usize
,
font_set
:
&
[
u8
])
{
self
.ram
[
position
..
position
+
font_set
.len
()]
.clone_from_slice
(
&
font_set
);
}
fn
load_default_font
(
&
mut
self
)
{
self
.load_font
(
0
,
&
FONT_SET
);
}
}
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