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
fbecab72
Verified
Commit
fbecab72
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: support for draw tile to stdout
parent
07f5ff07
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cpu.rs
+0
-8
0 additions, 8 deletions
src/cpu.rs
src/mmu.rs
+5
-10
5 additions, 10 deletions
src/mmu.rs
src/ppu.rs
+24
-1
24 additions, 1 deletion
src/ppu.rs
with
29 additions
and
19 deletions
src/cpu.rs
+
0
−
8
View file @
fbecab72
...
...
@@ -73,14 +73,6 @@ impl Cpu {
);
}
if
pc
==
0x0080
{
println!
(
"GOING TO PLAY BOOT SOUND"
);
}
if
pc
==
0x00e9
{
println!
(
"GOING TO PLAY BOOT 0x00ef"
);
}
// calls the current instruction and increments the number of
// cycles executed by the instruction time of the instruction
// that has just been executed
...
...
This diff is collapsed.
Click to expand it.
src/mmu.rs
+
5
−
10
View file @
fbecab72
...
...
@@ -53,22 +53,19 @@ impl Mmu {
0x4000
|
0x5000
|
0x6000
|
0x7000
=>
self
.rom
[
addr
as
usize
],
// Graphics: VRAM (8 KB)
0x8000
|
0x9000
=>
{
println!
(
"READING FROM VRAM"
);
self
.ppu.vram
[(
addr
&
0x1fff
)
as
usize
]
}
// External RAM (8 KB)
0xa000
|
0xb000
=>
{
println!
(
"READING FROM ERAM"
);
self
.eram
[(
addr
&
0x1fff
)
as
usize
]
}
// Working RAM (8 KB)
0xc000
|
0xd000
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
// Working RAM
s
hadow
// Working RAM
S
hadow
0xe000
=>
{
println!
(
"READING FROM RAM Shadow"
);
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
}
// Working RAM
s
hadow, I/O, Zero-page RAM
// Working RAM
S
hadow, I/O, Zero-page RAM
0xf000
=>
match
addr
&
0x0f00
{
0x000
|
0x100
|
0x200
|
0x300
|
0x400
|
0x500
|
0x600
|
0x700
|
0x800
|
0x900
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
...
...
@@ -118,19 +115,17 @@ impl Mmu {
}
// External RAM (8 KB)
0xa000
|
0xb000
=>
{
println!
(
"WRITING TO ERAM"
)
;
self
.eram
[(
addr
&
0x1fff
)
as
usize
]
=
value
;
}
// Working RAM (8 KB)
0xc000
|
0xd000
=>
{
println!
(
"WRITING TO RAM"
);
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
=
value
;
}
// Working RAM
s
hadow
// Working RAM
S
hadow
0xe000
=>
{
println!
(
"WRITING TO RAM Shadow"
);
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
=
value
;
}
// Working RAM
s
hadow, I/O, Zero-page RAM
// Working RAM
S
hadow, I/O, Zero-page RAM
0xf000
=>
match
addr
&
0x0f00
{
0x000
|
0x100
|
0x200
|
0x300
|
0x400
|
0x500
|
0x600
|
0x700
|
0x800
|
0x900
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
24
−
1
View file @
fbecab72
...
...
@@ -52,9 +52,18 @@ pub struct Ppu {
/// range between 0 (0x00) and 153 (0x99), representing
/// the 154 lines plus 10 extra v-blank lines.
line
:
u8
,
/// Controls if the background is going to be drawn to screen.
switch_bg
:
bool
,
/// Controls if the sprites are going to be drawn to screen.
switch_sprites
:
bool
,
/// Controls the map that is going to be drawn to screen, the
/// offset in VRAM will be adjusted according to this.
bg_map
:
bool
,
/// If the background tile set is active meaning that the
/// negative based indexes are going to be used.
bg_tile
:
bool
,
/// Flag that controls if the LCD screen is ON and displaying
/// content.
switch_lcd
:
bool
,
/// The current execution mode of the PPU, should change
/// between states over the drawing of a frame.
...
...
@@ -83,6 +92,7 @@ impl Ppu {
scx
:
0x0
,
line
:
0x0
,
switch_bg
:
false
,
switch_sprites
:
false
,
bg_map
:
false
,
bg_tile
:
false
,
switch_lcd
:
false
,
...
...
@@ -147,6 +157,7 @@ impl Ppu {
match
addr
&
0x00ff
{
0x0040
=>
{
let
value
=
if
self
.switch_bg
{
0x01
}
else
{
0x00
}
|
if
self
.switch_sprites
{
0x02
}
else
{
0x00
}
|
if
self
.bg_map
{
0x08
}
else
{
0x00
}
|
if
self
.bg_tile
{
0x10
}
else
{
0x00
}
|
if
self
.switch_lcd
{
0x80
}
else
{
0x00
};
...
...
@@ -163,7 +174,8 @@ impl Ppu {
match
addr
&
0x00ff
{
0x0040
=>
{
self
.switch_bg
=
value
&
0x01
==
0x01
;
self
.bg_map
=
value
&
0x08
==
0x08
;
// @todo o buf pode estar aqui
self
.switch_sprites
=
value
&
0x02
==
0x02
;
self
.bg_map
=
value
&
0x08
==
0x08
;
self
.bg_tile
=
value
&
0x10
==
0x10
;
self
.switch_lcd
=
value
&
0x80
==
0x80
;
}
...
...
@@ -267,4 +279,15 @@ impl Ppu {
}
}
}
/// Prints the tile data information to the stdout, this is
/// useful for debugging purposes.
pub
fn
draw_tile_stdout
(
&
self
,
tile_index
:
usize
)
{
for
y
in
0
..
8
{
for
x
in
0
..
8
{
print!
(
"{}"
,
self
.tiles
[
tile_index
][
y
as
usize
][
x
as
usize
]);
}
print!
(
"
\n
"
);
}
}
}
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