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
9137a109
Verified
Commit
9137a109
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
fix: initial support for tetris tile screen
parent
ef26d544
No related branches found
No related tags found
No related merge requests found
Pipeline
#905
failed
2 years ago
Stage: build
Stage: deploy
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
examples/web/index.ts
+1
-1
1 addition, 1 deletion
examples/web/index.ts
src/cpu.rs
+2
-2
2 additions, 2 deletions
src/cpu.rs
src/mmu.rs
+13
-9
13 additions, 9 deletions
src/mmu.rs
src/pad.rs
+12
-12
12 additions, 12 deletions
src/pad.rs
src/ppu.rs
+5
-0
5 additions, 0 deletions
src/ppu.rs
with
33 additions
and
24 deletions
examples/web/index.ts
+
1
−
1
View file @
9137a109
...
@@ -49,7 +49,7 @@ const KEYS: Record<string, number> = {
...
@@ -49,7 +49,7 @@ const KEYS: Record<string, number> = {
};
};
// @ts-ignore: ts(2580)
// @ts-ignore: ts(2580)
const
ROM_PATH
=
require
(
"
../../res/roms
/firstwhite
.gb
"
);
const
ROM_PATH
=
require
(
"
../../res/roms
.prop/tetris
.gb
"
);
// Enumeration that describes the multiple pixel
// Enumeration that describes the multiple pixel
// formats and the associated byte size.
// formats and the associated byte size.
...
...
This diff is collapsed.
Click to expand it.
src/cpu.rs
+
2
−
2
View file @
9137a109
...
@@ -113,8 +113,8 @@ impl Cpu {
...
@@ -113,8 +113,8 @@ impl Cpu {
if
self
.ime
{
if
self
.ime
{
// @todo aggregate all of this interrupts in the MMU
// @todo aggregate all of this interrupts in the MMU
if
self
.mmu
.ppu
()
.int_vblank
()
{
if
(
self
.mmu.ie
&
0x01
==
0x01
)
&&
self
.mmu
.ppu
()
.int_vblank
()
{
println!
(
"
VAI FAZER HANDLING VBLANK
"
);
println!
(
"
Going to run V-Blank interrupt handler
"
);
let
pc
=
self
.pc
;
let
pc
=
self
.pc
;
self
.disable_int
();
self
.disable_int
();
self
.push_word
(
pc
);
self
.push_word
(
pc
);
...
...
This diff is collapsed.
Click to expand it.
src/mmu.rs
+
13
−
9
View file @
9137a109
...
@@ -13,6 +13,10 @@ pub struct Mmu {
...
@@ -13,6 +13,10 @@ pub struct Mmu {
rom
:
[
u8
;
ROM_SIZE
],
rom
:
[
u8
;
ROM_SIZE
],
ram
:
[
u8
;
RAM_SIZE
],
ram
:
[
u8
;
RAM_SIZE
],
eram
:
[
u8
;
RAM_SIZE
],
eram
:
[
u8
;
RAM_SIZE
],
/// Registers that controls the interrupts that are considered
/// to be enabled and should be triggered.
pub
ie
:
u8
,
}
}
impl
Mmu
{
impl
Mmu
{
...
@@ -25,6 +29,7 @@ impl Mmu {
...
@@ -25,6 +29,7 @@ impl Mmu {
rom
:
[
0u8
;
ROM_SIZE
],
rom
:
[
0u8
;
ROM_SIZE
],
ram
:
[
0u8
;
RAM_SIZE
],
ram
:
[
0u8
;
RAM_SIZE
],
eram
:
[
0u8
;
ERAM_SIZE
],
eram
:
[
0u8
;
ERAM_SIZE
],
ie
:
0x0
,
}
}
}
}
...
@@ -77,12 +82,11 @@ impl Mmu {
...
@@ -77,12 +82,11 @@ impl Mmu {
0xf000
=>
match
addr
&
0x0f00
{
0xf000
=>
match
addr
&
0x0f00
{
0x000
|
0x100
|
0x200
|
0x300
|
0x400
|
0x500
|
0x600
|
0x700
|
0x800
|
0x900
0x000
|
0x100
|
0x200
|
0x300
|
0x400
|
0x500
|
0x600
|
0x700
|
0x800
|
0x900
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
self
.ram
[(
addr
&
0x1fff
)
as
usize
],
0xe00
=>
{
0xe00
=>
self
.ppu.oam
[(
addr
&
0x009f
)
as
usize
],
println!
(
"Reading from PPU OAM - NOT IMPLEMENTED"
);
0x00
}
0xf00
=>
{
0xf00
=>
{
if
addr
>=
0xff80
{
if
addr
==
0xffff
{
self
.ie
}
else
if
addr
>=
0xff80
{
self
.ppu.hram
[(
addr
&
0x007f
)
as
usize
]
self
.ppu.hram
[(
addr
&
0x007f
)
as
usize
]
}
else
{
}
else
{
match
addr
&
0x00f0
{
match
addr
&
0x00f0
{
...
@@ -147,11 +151,11 @@ impl Mmu {
...
@@ -147,11 +151,11 @@ impl Mmu {
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
{
|
0xa00
|
0xb00
|
0xc00
|
0xd00
=>
{
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
=
value
;
self
.ram
[(
addr
&
0x1fff
)
as
usize
]
=
value
;
}
}
0xe00
=>
{
0xe00
=>
self
.ppu.oam
[(
addr
&
0x009f
)
as
usize
]
=
value
,
println!
(
"Writing to PPU OAM at 0x{:04x}"
,
addr
);
}
0xf00
=>
{
0xf00
=>
{
if
addr
>=
0xff80
{
if
addr
==
0xffff
{
self
.ie
=
value
;
}
else
if
addr
>=
0xff80
{
self
.ppu.hram
[(
addr
&
0x007f
)
as
usize
]
=
value
;
self
.ppu.hram
[(
addr
&
0x007f
)
as
usize
]
=
value
;
}
else
{
}
else
{
match
addr
&
0x00f0
{
match
addr
&
0x00f0
{
...
...
This diff is collapsed.
Click to expand it.
src/pad.rs
+
12
−
12
View file @
9137a109
...
@@ -37,26 +37,26 @@ impl Pad {
...
@@ -37,26 +37,26 @@ impl Pad {
let
mut
value
;
let
mut
value
;
match
self
.selection
{
match
self
.selection
{
PadSelection
::
Action
=>
{
PadSelection
::
Action
=>
{
value
=
if
self
.a
{
0x0
1
}
else
{
0x0
0
}
value
=
if
self
.a
{
0x0
0
}
else
{
0x0
1
}
|
if
self
.b
{
0x0
2
}
else
{
0x0
0
}
|
if
self
.b
{
0x0
0
}
else
{
0x0
2
}
|
if
self
.select
{
0x0
4
}
else
{
0x0
0
}
|
if
self
.select
{
0x0
0
}
else
{
0x0
4
}
|
if
self
.start
{
0x0
8
}
else
{
0x0
0
}
|
if
self
.start
{
0x0
0
}
else
{
0x0
8
}
}
}
PadSelection
::
Direction
=>
{
PadSelection
::
Direction
=>
{
value
=
if
self
.right
{
0x0
1
}
else
{
0x0
0
}
value
=
if
self
.right
{
0x0
0
}
else
{
0x0
1
}
|
if
self
.left
{
0x0
2
}
else
{
0x0
0
}
|
if
self
.left
{
0x0
0
}
else
{
0x0
2
}
|
if
self
.up
{
0x0
4
}
else
{
0x0
0
}
|
if
self
.up
{
0x0
0
}
else
{
0x0
4
}
|
if
self
.down
{
0x0
8
}
else
{
0x0
0
}
|
if
self
.down
{
0x0
0
}
else
{
0x0
8
}
}
}
}
}
value
|
=
if
self
.selection
==
PadSelection
::
Direction
{
value
|
=
if
self
.selection
==
PadSelection
::
Direction
{
0x00
}
else
{
0x10
0x10
}
|
if
self
.selection
==
PadSelection
::
Action
{
0x00
}
else
{
}
else
{
0x00
}
|
if
self
.selection
==
PadSelection
::
Action
{
0x20
0x20
}
else
{
0x00
};
};
value
value
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ppu.rs
+
5
−
0
View file @
9137a109
...
@@ -9,6 +9,7 @@ use wasm_bindgen::prelude::*;
...
@@ -9,6 +9,7 @@ use wasm_bindgen::prelude::*;
pub
const
VRAM_SIZE
:
usize
=
8192
;
pub
const
VRAM_SIZE
:
usize
=
8192
;
pub
const
HRAM_SIZE
:
usize
=
128
;
pub
const
HRAM_SIZE
:
usize
=
128
;
pub
const
OAM_SIZE
:
usize
=
260
;
pub
const
PALETTE_SIZE
:
usize
=
4
;
pub
const
PALETTE_SIZE
:
usize
=
4
;
pub
const
RGB_SIZE
:
usize
=
3
;
pub
const
RGB_SIZE
:
usize
=
3
;
...
@@ -99,6 +100,9 @@ pub struct Ppu {
...
@@ -99,6 +100,9 @@ pub struct Ppu {
/// High RAM memory that should provide extra speed for regular
/// High RAM memory that should provide extra speed for regular
/// operations.
/// operations.
pub
hram
:
[
u8
;
HRAM_SIZE
],
pub
hram
:
[
u8
;
HRAM_SIZE
],
/// OAM RAM (Sprite Attribute Table ) used for the storage of the
/// sprite attributes for each of the 40 sprites of the Game Boy.
pub
oam
:
[
u8
;
OAM_SIZE
],
/// The current set of processed tiles that are store in the
/// The current set of processed tiles that are store in the
/// PPU related structures.
/// PPU related structures.
tiles
:
[
Tile
;
TILE_COUNT
],
tiles
:
[
Tile
;
TILE_COUNT
],
...
@@ -172,6 +176,7 @@ impl Ppu {
...
@@ -172,6 +176,7 @@ impl Ppu {
frame_buffer
:
Box
::
new
([
0u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
*
RGB_SIZE
]),
frame_buffer
:
Box
::
new
([
0u8
;
DISPLAY_WIDTH
*
DISPLAY_HEIGHT
*
RGB_SIZE
]),
vram
:
[
0u8
;
VRAM_SIZE
],
vram
:
[
0u8
;
VRAM_SIZE
],
hram
:
[
0u8
;
HRAM_SIZE
],
hram
:
[
0u8
;
HRAM_SIZE
],
oam
:
[
0u8
;
OAM_SIZE
],
tiles
:
[
Tile
{
buffer
:
[
0u8
;
64
]
};
TILE_COUNT
],
tiles
:
[
Tile
{
buffer
:
[
0u8
;
64
]
};
TILE_COUNT
],
palette
:
[[
0u8
;
RGB_SIZE
];
PALETTE_SIZE
],
palette
:
[[
0u8
;
RGB_SIZE
];
PALETTE_SIZE
],
palette_obj_0
:
[[
0u8
;
RGB_SIZE
];
PALETTE_SIZE
],
palette_obj_0
:
[[
0u8
;
RGB_SIZE
];
PALETTE_SIZE
],
...
...
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