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
19babd32
Verified
Commit
19babd32
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fix half carry in sub
parent
1c99b69a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cpu.rs
+22
-10
22 additions, 10 deletions
src/cpu.rs
with
22 additions
and
10 deletions
src/cpu.rs
+
22
−
10
View file @
19babd32
...
...
@@ -538,6 +538,13 @@ impl Cpu {
println!
(
"GOING TO PLAY BOOT SOUND"
);
}
if
pc
==
0x008f
{
println!
(
"GOING TO PLAY BOOT 0x00e0"
);
}
// calls the current instruction and increments the number of
// cycles executed by the instruction time of the instruction
// that has just been executed
instruction_fn
(
self
);
self
.ticks
=
self
.ticks
.wrapping_add
(
*
instruction_time
as
u32
);
...
...
@@ -738,11 +745,12 @@ fn inc_b(cpu: &mut Cpu) {
}
fn
dec_b
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.b
.wrapping_sub
(
1
);
let
b
=
cpu
.b
;
let
value
=
b
.wrapping_sub
(
1
);
cpu
.set_sub
(
true
);
cpu
.set_zero
(
value
==
0
);
cpu
.set_half_carry
((
value
&
0xf
)
==
0xf
);
cpu
.set_half_carry
((
b
&
0xf
)
==
0xf
);
cpu
.b
=
value
;
}
...
...
@@ -785,11 +793,12 @@ fn inc_c(cpu: &mut Cpu) {
}
fn
dec_c
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.c
.wrapping_sub
(
1
);
let
c
=
cpu
.c
;
let
value
=
c
.wrapping_sub
(
1
);
cpu
.set_sub
(
true
);
cpu
.set_zero
(
value
==
0
);
cpu
.set_half_carry
((
value
&
0xf
)
==
0xf
);
cpu
.set_half_carry
((
c
&
0xf
)
==
0xf
);
cpu
.c
=
value
;
}
...
...
@@ -809,11 +818,12 @@ fn inc_de(cpu: &mut Cpu) {
}
fn
dec_d
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.d
.wrapping_sub
(
1
);
let
d
=
cpu
.d
;
let
value
=
d
.wrapping_sub
(
1
);
cpu
.set_sub
(
true
);
cpu
.set_zero
(
value
==
0
);
cpu
.set_half_carry
((
value
&
0xf
)
==
0xf
);
cpu
.set_half_carry
((
d
&
0xf
)
==
0xf
);
cpu
.d
=
value
;
}
...
...
@@ -841,11 +851,12 @@ fn ld_a_mde(cpu: &mut Cpu) {
}
fn
dec_e
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.e
.wrapping_sub
(
1
);
let
e
=
cpu
.e
;
let
value
=
e
.wrapping_sub
(
1
);
cpu
.set_sub
(
true
);
cpu
.set_zero
(
value
==
0
);
cpu
.set_half_carry
((
valu
e
&
0xf
)
==
0xf
);
cpu
.set_half_carry
((
e
&
0xf
)
==
0xf
);
cpu
.e
=
value
;
}
...
...
@@ -916,11 +927,12 @@ fn ld_mhld_a(cpu: &mut Cpu) {
}
fn
dec_a
(
cpu
:
&
mut
Cpu
)
{
let
value
=
cpu
.a
.wrapping_sub
(
1
);
let
a
=
cpu
.a
;
let
value
=
a
.wrapping_sub
(
1
);
cpu
.set_sub
(
true
);
cpu
.set_zero
(
value
==
0
);
cpu
.set_half_carry
((
value
&
0xf
)
==
0xf
);
cpu
.set_half_carry
((
a
&
0xf
)
==
0xf
);
cpu
.a
=
value
;
}
...
...
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