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
4185b9d3
Commit
4185b9d3
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Plain Diff
Merge branch 'joamag/audio-ch4' into 'master'
Improved trigger of audio chanels See merge request
!22
parents
2bba9622
ce6f5adb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Improved trigger of audio chanels
Pipeline
#2456
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
src/apu.rs
+37
-3
37 additions, 3 deletions
src/apu.rs
with
39 additions
and
4 deletions
CHANGELOG.md
+
2
−
1
View file @
4185b9d3
...
...
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
*
Support for audio channel 4 (noise) 🔈
*
Better trigger support for audio channels 🔈
### Changed
...
...
@@ -17,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
*
Envelope support for both channel 2 and 4
*
Envelope support for both channel 2 and 4
🔈
## [0.7.3] - 2023-04-02
...
...
This diff is collapsed.
Click to expand it.
src/apu.rs
+
37
−
3
View file @
4185b9d3
...
...
@@ -350,6 +350,9 @@ impl Apu {
(
self
.ch1_wave_length
&
0x00ff
)
|
(((
value
&
0x07
)
as
u16
)
<<
8
);
self
.ch1_length_stop
|
=
value
&
0x40
==
0x40
;
self
.ch1_enabled
|
=
value
&
0x80
==
0x80
;
if
value
&
0x80
==
0x80
{
self
.trigger_ch1
();
}
}
// 0xFF16 — NR21: Channel 2 length timer & duty cycle
...
...
@@ -373,6 +376,9 @@ impl Apu {
(
self
.ch2_wave_length
&
0x00ff
)
|
(((
value
&
0x07
)
as
u16
)
<<
8
);
self
.ch2_length_stop
|
=
value
&
0x40
==
0x40
;
self
.ch2_enabled
|
=
value
&
0x80
==
0x80
;
if
value
&
0x80
==
0x80
{
self
.trigger_ch2
();
}
}
// 0xFF1A — NR30: Channel 3 DAC enable
...
...
@@ -397,6 +403,9 @@ impl Apu {
(
self
.ch3_wave_length
&
0x00ff
)
|
(((
value
&
0x07
)
as
u16
)
<<
8
);
self
.ch3_length_stop
|
=
value
&
0x40
==
0x40
;
self
.ch3_enabled
|
=
value
&
0x80
==
0x80
;
if
value
&
0x80
==
0x80
{
self
.trigger_ch3
();
}
}
// 0xFF20 — NR41: Channel 4 length timer
...
...
@@ -422,9 +431,7 @@ impl Apu {
self
.ch4_length_stop
|
=
value
&
0x40
==
0x40
;
self
.ch4_enabled
|
=
value
&
0x80
==
0x80
;
if
value
&
0x80
==
0x80
{
self
.ch4_timer
=
((
CH4_DIVISORS
[
self
.ch4_divisor
as
usize
]
as
u16
)
<<
self
.ch4_clock_shift
)
as
i16
;
self
.ch4_lfsr
=
0x7ff1
;
self
.trigger_ch4
();
}
}
...
...
@@ -727,6 +734,33 @@ impl Apu {
self
.ch4_timer
+=
((
CH4_DIVISORS
[
self
.ch4_divisor
as
usize
]
as
u16
)
<<
self
.ch4_clock_shift
)
as
i16
;
}
#[inline(always)]
fn
trigger_ch1
(
&
mut
self
)
{
self
.ch1_timer
=
((
2048
-
self
.ch1_wave_length
)
<<
2
)
as
i16
;
self
.ch1_envelope_sequence
=
0
;
self
.ch1_sweep_sequence
=
0
;
}
#[inline(always)]
fn
trigger_ch2
(
&
mut
self
)
{
self
.ch2_timer
=
((
2048
-
self
.ch2_wave_length
)
<<
2
)
as
i16
;
self
.ch2_envelope_sequence
=
0
;
}
#[inline(always)]
fn
trigger_ch3
(
&
mut
self
)
{
self
.ch3_timer
=
3
;
self
.ch3_position
=
0
;
}
#[inline(always)]
fn
trigger_ch4
(
&
mut
self
)
{
self
.ch4_timer
=
((
CH4_DIVISORS
[
self
.ch4_divisor
as
usize
]
as
u16
)
<<
self
.ch4_clock_shift
)
as
i16
;
self
.ch4_lfsr
=
0x7ff1
;
self
.ch4_envelope_sequence
=
0
;
}
}
impl
Default
for
Apu
{
...
...
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