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
d233d07e
Verified
Commit
d233d07e
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: initial boot loading support
parent
fbecab72
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mmu.rs
+5
-11
5 additions, 11 deletions
src/mmu.rs
src/ppu.rs
+9
-4
9 additions, 4 deletions
src/ppu.rs
with
14 additions
and
15 deletions
src/mmu.rs
+
5
−
11
View file @
d233d07e
...
...
@@ -49,22 +49,16 @@ impl Mmu {
}
// ROM0 (12 KB/16 KB)
0x1000
|
0x2000
|
0x3000
=>
self
.rom
[
addr
as
usize
],
// ROM1 (
u
nbanked) (16 KB)
// ROM1 (
U
nbanked) (16 KB)
0x4000
|
0x5000
|
0x6000
|
0x7000
=>
self
.rom
[
addr
as
usize
],
// Graphics: VRAM (8 KB)
0x8000
|
0x9000
=>
{
self
.ppu.vram
[(
addr
&
0x1fff
)
as
usize
]
}
0x8000
|
0x9000
=>
self
.ppu.vram
[(
addr
&
0x1fff
)
as
usize
],
// External RAM (8 KB)
0xa000
|
0xb000
=>
{
self
.eram
[(
addr
&
0x1fff
)
as
usize
]
}
0xa000
|
0xb000
=>
self
.eram
[(
addr
&
0x1fff
)
as
usize
],
// Working RAM (8 KB)
0xc000
|
0xd000
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
// Working RAM Shadow
0xe000
=>
{
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
}
0xe000
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
// Working RAM Shadow, I/O, Zero-page RAM
0xf000
=>
match
addr
&
0x0f00
{
0x000
|
0x100
|
0x200
|
0x300
|
0x400
|
0x500
|
0x600
|
0x700
|
0x800
|
0x900
...
...
@@ -102,7 +96,7 @@ impl Mmu {
0x1000
|
0x2000
|
0x3000
=>
{
println!
(
"WRITING TO ROM 0"
);
}
// ROM1 (
u
nbanked) (16 KB)
// ROM1 (
U
nbanked) (16 KB)
0x4000
|
0x5000
|
0x6000
|
0x7000
=>
{
println!
(
"WRITING TO ROM 1"
);
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
9
−
4
View file @
d233d07e
...
...
@@ -218,11 +218,16 @@ impl Ppu {
}
fn
render_line
(
&
mut
self
)
{
// obtains the base address of the background map using the bg map flag
// that control which background map is going to be used
let
mut
map_offset
:
usize
=
if
self
.bg_map
{
0x1c00
}
else
{
0x1800
};
map_offset
+=
(((
self
.line
+
self
.scy
)
&
0xff
)
>>
3
)
as
usize
;
// increments the offset by the number of lines and the SCY (scroll Y)
// divided by 8 (as the tiles are 8x8 pixels)
map_offset
+=
((((
self
.line
+
self
.scy
)
&
0xff
)
>>
3
)
as
usize
)
*
32
;
// calculates the sprite line offset by using the SCX register
// shifted by 3 meaning
as
the tiles are 8x8
// shifted by 3 meaning
that
the tiles are 8x8
let
mut
line_offset
:
usize
=
(
self
.scx
>>
3
)
as
usize
;
// calculates both the current Y and X positions within the tiles
...
...
@@ -233,7 +238,7 @@ impl Ppu {
// if the tile data set in use is #1, the indices are
// signed, then calculates a real tile offset
let
mut
tile_index
=
self
.vram
[
map_offset
+
line_offset
]
as
usize
;
if
self
.bg_tile
&&
tile_index
<
128
{
if
!
self
.bg_tile
&&
tile_index
<
128
{
tile_index
+=
256
;
}
...
...
@@ -273,7 +278,7 @@ impl Ppu {
// calculates the tile index nad makes sure the value
// takes into consideration the bg tile value
tile_index
=
self
.vram
[
map_offset
+
line_offset
]
as
usize
;
if
self
.bg_tile
&&
tile_index
<
128
{
if
!
self
.bg_tile
&&
tile_index
<
128
{
tile_index
+=
256
;
}
}
...
...
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