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
3c4f52aa
Verified
Commit
3c4f52aa
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: new instructions
parent
c7564b65
No related branches found
No related tags found
No related merge requests found
Pipeline
#865
passed
2 years ago
Stage: build
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/sdl/src/main.rs
+3
-1
3 additions, 1 deletion
examples/sdl/src/main.rs
src/cpu.rs
+7
-0
7 additions, 0 deletions
src/cpu.rs
src/inst.rs
+11
-2
11 additions, 2 deletions
src/inst.rs
src/mmu.rs
+7
-7
7 additions, 7 deletions
src/mmu.rs
with
28 additions
and
10 deletions
examples/sdl/src/main.rs
+
3
−
1
View file @
3c4f52aa
...
...
@@ -80,10 +80,12 @@ fn main() {
let
mut
game_boy
=
GameBoy
::
new
();
game_boy
.load_boot_dmg
();
game_boy
.load_rom_file
(
"../../res/roms.prop/tetris.gb"
);
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
//game_boy.load_rom_file("../../res/roms/opus5.gb");
//game_boy.load_rom_file("../../res/roms/ld_r_r.gb");
game_boy
.load_rom_file
(
"../../res/roms/special.gb"
);
//game_boy.load_rom_file("../../res/roms/special.gb");
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
let
mut
counter
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/cpu.rs
+
7
−
0
View file @
3c4f52aa
use
core
::
panic
;
use
crate
::{
inst
::{
EXTENDED
,
INSTRUCTIONS
},
mmu
::
Mmu
,
...
...
@@ -303,6 +305,11 @@ impl Cpu {
self
.halted
=
true
;
}
#[inline(always)]
pub
fn
stop
(
&
mut
self
)
{
panic!
(
"STOP is not implemented"
);
}
#[inline(always)]
pub
fn
enable_int
(
&
mut
self
)
{
// @todo implement this one
...
...
This diff is collapsed.
Click to expand it.
src/inst.rs
+
11
−
2
View file @
3c4f52aa
...
...
@@ -19,7 +19,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
ld_c_u8
,
8
,
"LD C, u8"
),
(
noimpl
,
4
,
"! UNIMP !"
),
// 0x1 opcodes
(
noimpl
,
4
,
"! UNIMP !
"
),
(
stop
,
4
,
"STOP
"
),
(
ld_de_u16
,
12
,
"LD DE, u16"
),
(
ld_mde_a
,
8
,
"LD [DE], A"
),
(
inc_de
,
8
,
"INC DE"
),
...
...
@@ -62,7 +62,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
ld_mhl_u8
,
12
,
"LD [HL], u8 "
),
(
scf
,
4
,
"SCF"
),
(
jr_c_i8
,
8
,
"JR C, i8"
),
(
noimpl
,
4
,
"
! UNIMP !
"
),
(
add_hl_sp
,
8
,
"
ADD HL, SP
"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
inc_a
,
4
,
"INC A"
),
...
...
@@ -656,6 +656,10 @@ fn ld_c_u8(cpu: &mut Cpu) {
cpu
.c
=
byte
;
}
fn
stop
(
cpu
:
&
mut
Cpu
)
{
cpu
.stop
();
}
fn
ld_de_u16
(
cpu
:
&
mut
Cpu
)
{
let
word
=
cpu
.read_u16
();
cpu
.set_de
(
word
);
...
...
@@ -923,6 +927,11 @@ fn jr_c_i8(cpu: &mut Cpu) {
cpu
.ticks
=
cpu
.ticks
.wrapping_add
(
4
);
}
fn
add_hl_sp
(
cpu
:
&
mut
Cpu
)
{
let
value
=
add_u16_u16
(
cpu
,
cpu
.hl
(),
cpu
.sp
());
cpu
.set_hl
(
value
);
}
fn
inc_a
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.a
.wrapping_add
(
1
);
...
...
This diff is collapsed.
Click to expand it.
src/mmu.rs
+
7
−
7
View file @
3c4f52aa
...
...
@@ -51,9 +51,9 @@ impl Mmu {
}
self
.rom
[
addr
as
usize
]
}
// ROM0 (12 KB/16 KB)
// ROM
0 (12 KB/16 KB)
0x1000
|
0x2000
|
0x3000
=>
self
.rom
[
addr
as
usize
],
// ROM1 (Unbanked) (16 KB)
// ROM
1 (Unbanked) (16 KB)
0x4000
|
0x5000
|
0x6000
|
0x7000
=>
self
.rom
[
addr
as
usize
],
// Graphics: VRAM (8 KB)
0x8000
|
0x9000
=>
self
.ppu.vram
[(
addr
&
0x1fff
)
as
usize
],
...
...
@@ -99,15 +99,15 @@ impl Mmu {
// BOOT (256 B) + ROM0 (4 KB/16 KB)
0x0000
=>
{
self
.rom
[
addr
as
usize
]
=
value
;
p
rintln
!
(
"Writing to BOOT at 0x{:04x}"
,
addr
)
p
anic
!
(
"Writing to BOOT at 0x{:04x}"
,
addr
)
}
// ROM0 (12 KB/16 KB)
// ROM
0 (12 KB/16 KB)
0x1000
|
0x2000
|
0x3000
=>
{
p
rintln
!
(
"Writing to ROM 0 at 0x{:04x}"
,
addr
);
p
anic
!
(
"Writing to ROM 0 at 0x{:04x}"
,
addr
);
}
// ROM1 (Unbanked) (16 KB)
// ROM
1 (Unbanked) (16 KB)
0x4000
|
0x5000
|
0x6000
|
0x7000
=>
{
p
rintln
!
(
"Writing to ROM 1 at 0x{:04x}"
,
addr
);
p
anic
!
(
"Writing to ROM 1 at 0x{:04x}"
,
addr
);
}
// Graphics: VRAM (8 KB)
0x8000
|
0x9000
=>
{
...
...
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