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
7c8baf80
Verified
Commit
7c8baf80
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: initial channel4 implementation code
parent
929bd08d
No related branches found
No related tags found
1 merge request
!21
Initial working version of Audio CH4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/apu.rs
+31
-1
31 additions, 1 deletion
src/apu.rs
with
31 additions
and
1 deletion
src/apu.rs
+
31
−
1
View file @
7c8baf80
...
@@ -62,6 +62,9 @@ pub struct Apu {
...
@@ -62,6 +62,9 @@ pub struct Apu {
ch4_timer
:
i16
,
ch4_timer
:
i16
,
ch4_output
:
u8
,
ch4_output
:
u8
,
ch4_length_timer
:
u8
,
ch4_length_timer
:
u8
,
ch4_pace
:
u8
,
ch4_direction
:
u8
,
ch4_volume
:
u8
,
ch4_output_level
:
u8
,
ch4_output_level
:
u8
,
ch4_wave_length
:
u16
,
ch4_wave_length
:
u16
,
ch4_length_stop
:
bool
,
ch4_length_stop
:
bool
,
...
@@ -128,6 +131,9 @@ impl Apu {
...
@@ -128,6 +131,9 @@ impl Apu {
ch4_timer
:
0
,
ch4_timer
:
0
,
ch4_output
:
0
,
ch4_output
:
0
,
ch4_length_timer
:
0x0
,
ch4_length_timer
:
0x0
,
ch4_pace
:
0x0
,
ch4_direction
:
0x0
,
ch4_volume
:
0x0
,
ch4_output_level
:
0x0
,
ch4_output_level
:
0x0
,
ch4_wave_length
:
0x0
,
ch4_wave_length
:
0x0
,
ch4_length_stop
:
false
,
ch4_length_stop
:
false
,
...
@@ -140,6 +146,10 @@ impl Apu {
...
@@ -140,6 +146,10 @@ impl Apu {
/// to be used in channel 3 audio
/// to be used in channel 3 audio
wave_ram
:
[
0u8
;
16
],
wave_ram
:
[
0u8
;
16
],
/// The rate at which audio samples are going to be
/// taken, ideally this value should be aligned with
/// the sampling rate of the output device. A typical
/// sampling rate would be of 44.1kHz.
sampling_rate
,
sampling_rate
,
/// Internal sequencer counter that runs at 512Hz
/// Internal sequencer counter that runs at 512Hz
...
@@ -361,6 +371,26 @@ impl Apu {
...
@@ -361,6 +371,26 @@ impl Apu {
self
.ch3_enabled
|
=
value
&
0x80
==
0x80
;
self
.ch3_enabled
|
=
value
&
0x80
==
0x80
;
}
}
// 0xFF20 — NR41: Channel 4 length timer
0xff20
=>
{
self
.ch4_length_timer
=
value
&
0x3f
;
}
// 0xFF21 — NR42: Channel 4 volume & envelope
0xff21
=>
{
self
.ch4_pace
=
value
&
0x07
;
self
.ch4_direction
=
(
value
&
0x08
)
>>
3
;
self
.ch4_volume
=
(
value
&
0xf0
)
>>
4
;
}
// 0xFF22 — NR43: Channel 4 frequency & randomness
0xff22
=>
{
//@TODO need to implement this one!
}
// 0xFF23 — NR44: Channel 4 control
0xff23
=>
{
self
.ch4_length_stop
|
=
value
&
0x40
==
0x40
;
self
.ch4_enabled
|
=
value
&
0x80
==
0x80
;
}
// 0xFF30-0xFF3F — Wave pattern RAM
// 0xFF30-0xFF3F — Wave pattern RAM
0xff30
..=
0xff3f
=>
{
0xff30
..=
0xff3f
=>
{
self
.wave_ram
[
addr
as
usize
&
0x000f
]
=
value
;
self
.wave_ram
[
addr
as
usize
&
0x000f
]
=
value
;
...
@@ -371,7 +401,7 @@ impl Apu {
...
@@ -371,7 +401,7 @@ impl Apu {
}
}
pub
fn
output
(
&
self
)
->
u8
{
pub
fn
output
(
&
self
)
->
u8
{
self
.ch1_output
+
self
.ch2_output
+
self
.ch3_output
self
.ch1_output
+
self
.ch2_output
+
self
.ch3_output
+
self
.ch4_output
}
}
pub
fn
audio_buffer
(
&
self
)
->
&
VecDeque
<
u8
>
{
pub
fn
audio_buffer
(
&
self
)
->
&
VecDeque
<
u8
>
{
...
...
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