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
88f16b03
Verified
Commit
88f16b03
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: removed extra warnings
These are temporary fixes.
parent
e3317ab4
No related branches found
No related tags found
1 merge request
!19
Initial tentative audio support 🔉
Pipeline
#2273
passed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/apu.rs
+20
-14
20 additions, 14 deletions
src/apu.rs
src/gb.rs
+10
-2
10 additions, 2 deletions
src/gb.rs
with
30 additions
and
16 deletions
src/apu.rs
+
20
−
14
View file @
88f16b03
...
@@ -35,9 +35,10 @@ pub struct Apu {
...
@@ -35,9 +35,10 @@ pub struct Apu {
ch2_sound_length
:
bool
,
ch2_sound_length
:
bool
,
ch2_enabled
:
bool
,
ch2_enabled
:
bool
,
ch3_timer
:
u16
,
// @TODO start using this once we're ready for CH3
ch3_sequence
:
u8
,
//ch3_timer: u16,
ch3_output
:
u8
,
//ch3_sequence: u8,
//ch3_output: u8,
ch3_dac
:
bool
,
ch3_dac
:
bool
,
ch3_length_timer
:
u8
,
ch3_length_timer
:
u8
,
ch3_output_level
:
u8
,
ch3_output_level
:
u8
,
...
@@ -48,7 +49,7 @@ pub struct Apu {
...
@@ -48,7 +49,7 @@ pub struct Apu {
wave_ram
:
[
u8
;
16
],
wave_ram
:
[
u8
;
16
],
output_timer
:
u16
,
output_timer
:
u16
,
output
_buffer
:
Vec
<
u8
>
,
audio
_buffer
:
Vec
<
u8
>
,
}
}
impl
Apu
{
impl
Apu
{
...
@@ -81,9 +82,10 @@ impl Apu {
...
@@ -81,9 +82,10 @@ impl Apu {
ch2_sound_length
:
false
,
ch2_sound_length
:
false
,
ch2_enabled
:
false
,
ch2_enabled
:
false
,
ch3_timer
:
0
,
// @TODO start using this once we're ready for CH3
ch3_sequence
:
0
,
//ch3_timer: 0,
ch3_output
:
0
,
//ch3_sequence: 0,
//ch3_output: 0,
ch3_dac
:
false
,
ch3_dac
:
false
,
ch3_length_timer
:
0x0
,
ch3_length_timer
:
0x0
,
ch3_output_level
:
0x0
,
ch3_output_level
:
0x0
,
...
@@ -94,7 +96,7 @@ impl Apu {
...
@@ -94,7 +96,7 @@ impl Apu {
wave_ram
:
[
0u8
;
16
],
wave_ram
:
[
0u8
;
16
],
output_timer
:
0
,
output_timer
:
0
,
output
_buffer
:
Vec
::
new
(),
audio
_buffer
:
Vec
::
new
(),
}
}
}
}
...
@@ -167,7 +169,7 @@ impl Apu {
...
@@ -167,7 +169,7 @@ impl Apu {
if
value
&
0x80
==
0x80
{
if
value
&
0x80
==
0x80
{
//self.ch2_timer = 0;
//self.ch2_timer = 0;
//self.ch2_sequence = 0;
//self.ch2_sequence = 0;
//@TODO improve this reset operation
//
@TODO improve this reset operation
}
}
}
}
...
@@ -242,7 +244,7 @@ impl Apu {
...
@@ -242,7 +244,7 @@ impl Apu {
self
.output_timer
=
self
.output_timer
.saturating_sub
(
1
);
self
.output_timer
=
self
.output_timer
.saturating_sub
(
1
);
if
self
.output_timer
==
0
{
if
self
.output_timer
==
0
{
self
.
output
_buffer
.push
(
self
.output
());
self
.
audio
_buffer
.push
(
self
.output
());
// @TODO target sampling rate is hardcoded, need to softcode this
// @TODO target sampling rate is hardcoded, need to softcode this
self
.output_timer
=
(
4194304.0
/
44100.0
)
as
u16
;
self
.output_timer
=
(
4194304.0
/
44100.0
)
as
u16
;
}
}
...
@@ -252,12 +254,16 @@ impl Apu {
...
@@ -252,12 +254,16 @@ impl Apu {
self
.ch1_output
+
self
.ch2_output
self
.ch1_output
+
self
.ch2_output
}
}
pub
fn
output
_buffer
(
&
self
)
->
&
Vec
<
u8
>
{
pub
fn
audio
_buffer
(
&
self
)
->
&
Vec
<
u8
>
{
&
self
.
output
_buffer
&
self
.
audio
_buffer
}
}
pub
fn
clear_buffer
(
&
mut
self
)
{
pub
fn
audio_buffer_mut
(
&
mut
self
)
->
&
mut
Vec
<
u8
>
{
self
.output_buffer
.clear
();
&
mut
self
.audio_buffer
}
pub
fn
clear_audio_buffer
(
&
mut
self
)
{
self
.audio_buffer
.clear
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/gb.rs
+
10
−
2
View file @
88f16b03
...
@@ -164,6 +164,10 @@ impl GameBoy {
...
@@ -164,6 +164,10 @@ impl GameBoy {
self
.frame_buffer
()
.to_vec
()
self
.frame_buffer
()
.to_vec
()
}
}
pub
fn
audio_buffer_eager
(
&
mut
self
)
->
Vec
<
u8
>
{
self
.audio_buffer
()
.to_vec
()
}
pub
fn
cartridge_eager
(
&
mut
self
)
->
Cartridge
{
pub
fn
cartridge_eager
(
&
mut
self
)
->
Cartridge
{
self
.mmu
()
.rom
()
.clone
()
self
.mmu
()
.rom
()
.clone
()
}
}
...
@@ -279,6 +283,10 @@ impl GameBoy {
...
@@ -279,6 +283,10 @@ impl GameBoy {
&
(
self
.ppu
()
.frame_buffer
)
&
(
self
.ppu
()
.frame_buffer
)
}
}
pub
fn
audio_buffer
(
&
mut
self
)
->
&
Vec
<
u8
>
{
self
.apu
()
.audio_buffer
()
}
pub
fn
load_boot_path
(
&
mut
self
,
path
:
&
str
)
{
pub
fn
load_boot_path
(
&
mut
self
,
path
:
&
str
)
{
let
data
=
read_file
(
path
);
let
data
=
read_file
(
path
);
self
.load_boot
(
&
data
);
self
.load_boot
(
&
data
);
...
@@ -388,11 +396,11 @@ impl AudioProvider for GameBoy {
...
@@ -388,11 +396,11 @@ impl AudioProvider for GameBoy {
}
}
fn
audio_buffer
(
&
self
)
->
&
Vec
<
u8
>
{
fn
audio_buffer
(
&
self
)
->
&
Vec
<
u8
>
{
self
.apu_i
()
.
output
_buffer
()
self
.apu_i
()
.
audio
_buffer
()
}
}
fn
clear_audio_buffer
(
&
mut
self
)
{
fn
clear_audio_buffer
(
&
mut
self
)
{
self
.apu
()
.clear_buffer
()
self
.apu
()
.clear_
audio_
buffer
()
}
}
}
}
...
...
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