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
368bd1cd
Verified
Commit
368bd1cd
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: new instructions
parent
2473aa8f
No related branches found
No related tags found
No related merge requests found
Pipeline
#856
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
-3
3 additions, 3 deletions
examples/sdl/src/main.rs
src/data.rs
+1
-1
1 addition, 1 deletion
src/data.rs
src/gb.rs
+6
-2
6 additions, 2 deletions
src/gb.rs
src/inst.rs
+36
-7
36 additions, 7 deletions
src/inst.rs
with
46 additions
and
13 deletions
examples/sdl/src/main.rs
+
3
−
3
View file @
368bd1cd
...
@@ -79,9 +79,9 @@ fn main() {
...
@@ -79,9 +79,9 @@ fn main() {
.unwrap
();
.unwrap
();
let
mut
game_boy
=
GameBoy
::
new
();
let
mut
game_boy
=
GameBoy
::
new
();
game_boy
.load_boot_
static
();
game_boy
.load_boot_
dmg
();
game_boy
.load_rom_file
(
"../../res/roms/firstwhite.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/opus5.gb"
);
let
mut
counter
=
0
;
let
mut
counter
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/data.rs
+
1
−
1
View file @
368bd1cd
/// Static data corresponding to the DMG boot ROM
/// Static data corresponding to the DMG boot ROM
/// allows freely using the emulator without external dependency.
/// allows freely using the emulator without external dependency.
pub
const
DM
B
_BOOT
:
[
u8
;
256
]
=
[
pub
const
DM
G
_BOOT
:
[
u8
;
256
]
=
[
49
,
254
,
255
,
175
,
33
,
255
,
159
,
50
,
203
,
124
,
32
,
251
,
33
,
38
,
255
,
14
,
17
,
62
,
128
,
50
,
226
,
49
,
254
,
255
,
175
,
33
,
255
,
159
,
50
,
203
,
124
,
32
,
251
,
33
,
38
,
255
,
14
,
17
,
62
,
128
,
50
,
226
,
12
,
62
,
243
,
226
,
50
,
62
,
119
,
119
,
62
,
252
,
224
,
71
,
17
,
4
,
1
,
33
,
16
,
128
,
26
,
205
,
149
,
0
,
12
,
62
,
243
,
226
,
50
,
62
,
119
,
119
,
62
,
252
,
224
,
71
,
17
,
4
,
1
,
33
,
16
,
128
,
26
,
205
,
149
,
0
,
205
,
150
,
0
,
19
,
123
,
254
,
52
,
32
,
243
,
17
,
216
,
0
,
6
,
8
,
26
,
19
,
34
,
35
,
5
,
32
,
249
,
62
,
25
,
205
,
150
,
0
,
19
,
123
,
254
,
52
,
32
,
243
,
17
,
216
,
0
,
6
,
8
,
26
,
19
,
34
,
35
,
5
,
32
,
249
,
62
,
25
,
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
6
−
2
View file @
368bd1cd
use
crate
::{
use
crate
::{
cpu
::
Cpu
,
cpu
::
Cpu
,
data
::
SGB_BOOT
,
data
::
{
SGB_BOOT
,
DMG_BOOT
},
mmu
::
Mmu
,
mmu
::
Mmu
,
ppu
::{
Ppu
,
FRAME_BUFFER_SIZE
},
ppu
::{
Ppu
,
FRAME_BUFFER_SIZE
},
util
::
read_file
,
util
::
read_file
,
...
@@ -68,7 +68,11 @@ impl GameBoy {
...
@@ -68,7 +68,11 @@ impl GameBoy {
self
.load_boot_file
(
"./res/boot/dmg_boot.bin"
);
self
.load_boot_file
(
"./res/boot/dmg_boot.bin"
);
}
}
pub
fn
load_boot_static
(
&
mut
self
)
{
pub
fn
load_boot_dmg
(
&
mut
self
)
{
self
.load_boot
(
&
DMG_BOOT
);
}
pub
fn
load_boot_sgb
(
&
mut
self
)
{
self
.load_boot
(
&
SGB_BOOT
);
self
.load_boot
(
&
SGB_BOOT
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/inst.rs
+
36
−
7
View file @
368bd1cd
...
@@ -12,7 +12,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
...
@@ -12,7 +12,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
rlca
,
4
,
"RLCA"
),
(
rlca
,
4
,
"RLCA"
),
(
ld_mu16_sp
,
20
,
"LD [u16], SP"
),
(
ld_mu16_sp
,
20
,
"LD [u16], SP"
),
(
add_hl_bc
,
8
,
"ADD HL, BC"
),
(
add_hl_bc
,
8
,
"ADD HL, BC"
),
(
noimpl
,
4
,
"
! UNIMP !
"
),
(
ld_a_mbc
,
8
,
"
LD A, [BC]
"
),
(
dec_bc
,
8
,
"DEC BC"
),
(
dec_bc
,
8
,
"DEC BC"
),
(
inc_c
,
4
,
"INC C"
),
(
inc_c
,
4
,
"INC C"
),
(
dec_c
,
4
,
"DEC C"
),
(
dec_c
,
4
,
"DEC C"
),
...
@@ -78,12 +78,12 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
...
@@ -78,12 +78,12 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
noimpl
,
4
,
"! UNIMP !"
),
(
noimpl
,
4
,
"! UNIMP !"
),
(
ld_b_mhl
,
8
,
"LD B, [HL]"
),
(
ld_b_mhl
,
8
,
"LD B, [HL]"
),
(
ld_b_a
,
4
,
"LD B, A"
),
(
ld_b_a
,
4
,
"LD B, A"
),
(
noimpl
,
4
,
"! UNIMP !
"
),
(
ld_c_b
,
4
,
"LD C, B
"
),
(
noimpl
,
4
,
"! UNIMP !
"
),
(
ld_c_c
,
4
,
"LD C, C
"
),
(
noimpl
,
4
,
"! UNIMP !
"
),
(
ld_c_d
,
4
,
"LD C, D
"
),
(
noimpl
,
4
,
"! UNIMP !
"
),
(
ld_c_e
,
4
,
"LD C, E
"
),
(
noimpl
,
4
,
"! UNIMP !
"
),
(
ld_c_h
,
4
,
"LD C, H
"
),
(
noimp
l
,
4
,
"
! UNIMP !
"
),
(
ld_c_
l
,
4
,
"
LD C, L
"
),
(
ld_c_mhl
,
8
,
"LD C, [HL]"
),
(
ld_c_mhl
,
8
,
"LD C, [HL]"
),
(
ld_c_a
,
4
,
"LD C, A"
),
(
ld_c_a
,
4
,
"LD C, A"
),
// 0x5 opcodes
// 0x5 opcodes
...
@@ -617,6 +617,11 @@ fn add_hl_bc(cpu: &mut Cpu) {
...
@@ -617,6 +617,11 @@ fn add_hl_bc(cpu: &mut Cpu) {
cpu
.set_hl
(
value
);
cpu
.set_hl
(
value
);
}
}
fn
ld_a_mbc
(
cpu
:
&
mut
Cpu
)
{
let
byte
=
cpu
.mmu
.read
(
cpu
.bc
());
cpu
.a
=
byte
;
}
fn
dec_bc
(
cpu
:
&
mut
Cpu
)
{
fn
dec_bc
(
cpu
:
&
mut
Cpu
)
{
cpu
.set_bc
(
cpu
.bc
()
.wrapping_sub
(
1
));
cpu
.set_bc
(
cpu
.bc
()
.wrapping_sub
(
1
));
}
}
...
@@ -948,6 +953,30 @@ fn ld_b_a(cpu: &mut Cpu) {
...
@@ -948,6 +953,30 @@ fn ld_b_a(cpu: &mut Cpu) {
cpu
.b
=
cpu
.a
;
cpu
.b
=
cpu
.a
;
}
}
fn
ld_c_b
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.b
;
}
fn
ld_c_c
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.c
;
}
fn
ld_c_d
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.d
;
}
fn
ld_c_e
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.e
;
}
fn
ld_c_h
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.h
;
}
fn
ld_c_l
(
cpu
:
&
mut
Cpu
)
{
cpu
.c
=
cpu
.l
;
}
fn
ld_c_mhl
(
cpu
:
&
mut
Cpu
)
{
fn
ld_c_mhl
(
cpu
:
&
mut
Cpu
)
{
let
byte
=
cpu
.mmu
.read
(
cpu
.hl
());
let
byte
=
cpu
.mmu
.read
(
cpu
.hl
());
cpu
.c
=
byte
;
cpu
.c
=
byte
;
...
...
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