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
2519d732
Verified
Commit
2519d732
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: clippy changes
parent
3192d273
No related branches found
No related tags found
No related merge requests found
Pipeline
#1504
passed
2 years ago
Stage: build
Stage: deploy
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/gb.rs
+1
-1
1 addition, 1 deletion
src/gb.rs
src/inst.rs
+2
-2
2 additions, 2 deletions
src/inst.rs
src/mmu.rs
+3
-4
3 additions, 4 deletions
src/mmu.rs
src/ppu.rs
+9
-11
9 additions, 11 deletions
src/ppu.rs
src/rom.rs
+3
-3
3 additions, 3 deletions
src/rom.rs
with
18 additions
and
21 deletions
src/gb.rs
+
1
−
1
View file @
2519d732
...
...
@@ -51,7 +51,7 @@ impl GameBoy {
let
timer
=
Timer
::
new
();
let
mmu
=
Mmu
::
new
(
ppu
,
pad
,
timer
);
let
cpu
=
Cpu
::
new
(
mmu
);
Self
{
cpu
:
cpu
}
Self
{
cpu
}
}
pub
fn
reset
(
&
mut
self
)
{
...
...
This diff is collapsed.
Click to expand it.
src/inst.rs
+
2
−
2
View file @
2519d732
use
crate
::
cpu
::
Cpu
;
pub
const
INSTRUCTIONS
:
[(
fn
(
&
mut
Cpu
),
u8
,
&
'static
str
);
256
]
=
[
pub
const
INSTRUCTIONS
:
[(
fn
(
&
mut
Cpu
),
u8
,
&
str
);
256
]
=
[
// 0x0 opcodes
(
nop
,
4
,
"NOP"
),
(
ld_bc_u16
,
12
,
"LD BC, u16"
),
...
...
@@ -275,7 +275,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(
rst_38h
,
16
,
"RST 38h"
),
];
pub
const
EXTENDED
:
[(
fn
(
&
mut
Cpu
),
u8
,
&
'static
str
);
256
]
=
[
pub
const
EXTENDED
:
[(
fn
(
&
mut
Cpu
),
u8
,
&
str
);
256
]
=
[
// 0x0 opcodes
(
rlc_b
,
8
,
"RLC B"
),
(
rlc_c
,
8
,
"RLC C"
),
...
...
This diff is collapsed.
Click to expand it.
src/mmu.rs
+
3
−
4
View file @
2519d732
...
...
@@ -119,11 +119,10 @@ impl Mmu {
0xe00
=>
self
.ppu.oam
[(
addr
&
0x009f
)
as
usize
],
0xf00
=>
match
addr
&
0x00ff
{
0x0f
=>
{
let
value
=
if
self
.ppu
.int_vblank
()
{
0x01
}
else
{
0x00
}
(
if
self
.ppu
.int_vblank
()
{
0x01
}
else
{
0x00
}
|
if
self
.ppu
.int_stat
()
{
0x02
}
else
{
0x00
}
|
if
self
.timer
.int_tima
()
{
0x04
}
else
{
0x00
}
|
if
self
.pad
.int_pad
()
{
0x10
}
else
{
0x00
};
value
|
if
self
.pad
.int_pad
()
{
0x10
}
else
{
0x00
})
}
0x80
..=
0xfe
=>
self
.ppu.hram
[(
addr
&
0x007f
)
as
usize
],
0xff
=>
self
.ie
,
...
...
@@ -245,7 +244,7 @@ impl Mmu {
data
.push
(
byte
);
}
return
data
;
data
}
pub
fn
write_boot
(
&
mut
self
,
addr
:
u16
,
buffer
:
&
[
u8
])
{
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
9
−
11
View file @
2519d732
...
...
@@ -93,7 +93,7 @@ impl Display for Tile {
for
x
in
0
..
8
{
buffer
.push_str
(
format!
(
"{}"
,
self
.get
(
x
,
y
))
.as_str
());
}
buffer
.push
_str
(
"
\n
"
);
buffer
.push
(
'
\n
'
);
}
write!
(
f
,
"{}"
,
buffer
)
}
...
...
@@ -434,24 +434,22 @@ impl Ppu {
pub
fn
read
(
&
mut
self
,
addr
:
u16
)
->
u8
{
match
addr
&
0x00ff
{
0x0040
=>
{
let
value
=
if
self
.switch_bg
{
0x01
}
else
{
0x00
}
(
if
self
.switch_bg
{
0x01
}
else
{
0x00
}
|
if
self
.switch_obj
{
0x02
}
else
{
0x00
}
|
if
self
.obj_size
{
0x04
}
else
{
0x00
}
|
if
self
.bg_map
{
0x08
}
else
{
0x00
}
|
if
self
.bg_tile
{
0x10
}
else
{
0x00
}
|
if
self
.switch_window
{
0x20
}
else
{
0x00
}
|
if
self
.window_map
{
0x40
}
else
{
0x00
}
|
if
self
.switch_lcd
{
0x80
}
else
{
0x00
};
value
|
if
self
.switch_lcd
{
0x80
}
else
{
0x00
})
}
0x0041
=>
{
let
value
=
if
self
.stat_hblank
{
0x08
}
else
{
0x00
}
(
if
self
.stat_hblank
{
0x08
}
else
{
0x00
}
|
if
self
.stat_vblank
{
0x10
}
else
{
0x00
}
|
if
self
.stat_oam
{
0x20
}
else
{
0x00
}
|
if
self
.stat_lyc
{
0x40
}
else
{
0x00
}
|
if
self
.lyc
==
self
.ly
{
0x04
}
else
{
0x00
}
|
(
self
.mode
as
u8
&
0x03
);
value
|
(
self
.mode
as
u8
&
0x03
))
}
0x0042
=>
self
.scy
,
0x0043
=>
self
.scx
,
...
...
@@ -673,9 +671,9 @@ impl Ppu {
0x02
=>
obj
.tile
=
value
,
0x03
=>
{
obj
.palette
=
if
value
&
0x10
==
0x10
{
1
}
else
{
0
};
obj
.xflip
=
if
value
&
0x20
==
0x20
{
true
}
else
{
false
}
;
obj
.yflip
=
if
value
&
0x40
==
0x40
{
true
}
else
{
false
}
;
obj
.priority
=
if
value
&
0x80
=
=
0x80
{
false
}
else
{
true
}
;
obj
.xflip
=
value
&
0x20
==
0x20
;
obj
.yflip
=
value
&
0x40
==
0x40
;
obj
.priority
=
value
&
0x80
!
=
0x80
;
obj
.index
=
obj_index
as
u8
;
}
_
=>
(),
...
...
@@ -866,7 +864,7 @@ impl Ppu {
tile
=
&
self
.tiles
[
obj
.tile
as
usize
&
0xfe
];
}
else
{
tile
=
&
self
.tiles
[
obj
.tile
as
usize
|
0x01
];
tile_offset
=
tile_offset
-
8
;
tile_offset
-
=
8
;
}
}
// otherwise we're facing a 8x8 sprite and we should grab
...
...
This diff is collapsed.
Click to expand it.
src/rom.rs
+
3
−
3
View file @
2519d732
...
...
@@ -475,7 +475,7 @@ pub static MBC1: Mbc = Mbc {
// ROM bank selection 5 lower bits
0x2000
|
0x3000
=>
{
let
mut
rom_bank
=
value
&
0x1f
;
rom_bank
=
rom_bank
&
(
rom
.rom_bank_count
*
2
-
1
)
as
u8
;
rom_bank
&
=
(
rom
.rom_bank_count
*
2
-
1
)
as
u8
;
if
rom_bank
==
0
{
rom_bank
=
1
;
}
...
...
@@ -537,7 +537,7 @@ pub static MBC3: Mbc = Mbc {
// ROM bank selection
0x2000
|
0x3000
=>
{
let
mut
rom_bank
=
value
&
0x7f
;
rom_bank
=
rom_bank
&
(
rom
.rom_bank_count
*
2
-
1
)
as
u8
;
rom_bank
&
=
(
rom
.rom_bank_count
*
2
-
1
)
as
u8
;
if
rom_bank
==
0
{
rom_bank
=
1
;
}
...
...
@@ -592,7 +592,7 @@ pub static MBC5: Mbc = Mbc {
}
// ROM bank selection
0x2000
=>
{
let
rom_bank
=
value
&
0xff
;
let
rom_bank
=
value
;
rom
.set_rom_bank
(
rom_bank
);
}
// RAM bank selection
...
...
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