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
0f188280
Verified
Commit
0f188280
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: rudimentary CH1 sound support
There's still a lot of work needed.
parent
1b85628a
No related branches found
No related tags found
1 merge request
!19
Initial tentative audio support 🔉
Pipeline
#2265
failed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/apu.rs
+20
-2
20 additions, 2 deletions
src/apu.rs
with
20 additions
and
2 deletions
src/apu.rs
+
20
−
2
View file @
0f188280
...
...
@@ -146,9 +146,27 @@ impl Apu {
#[inline(always)]
pub
fn
cycle
(
&
mut
self
,
freq
:
u32
)
{
self
.ch1_timer
=
self
.ch1_timer
.saturating_sub
(
1
);
if
self
.ch1_timer
==
0
{
let
target_freq
=
1048576.0
/
(
2048.0
-
self
.ch1_wave_length
as
f32
);
self
.ch1_timer
=
(
freq
as
f32
/
target_freq
)
as
u16
;
self
.ch1_sequence
=
(
self
.ch1_sequence
+
1
)
&
7
;
if
self
.ch1_enabled
{
self
.ch1_output
=
if
DUTY_TABLE
[
self
.ch1_wave_duty
as
usize
][
self
.ch1_sequence
as
usize
]
==
1
{
self
.ch1_volume
}
else
{
0
};
}
else
{
self
.ch1_output
=
0
;
}
}
self
.ch2_timer
=
self
.ch2_timer
.saturating_sub
(
1
);
if
self
.ch2_timer
==
0
{
let
target_freq
=
1048576.0
/
(
2048.0
-
self
.ch
1
_wave_length
as
f32
);
let
target_freq
=
1048576.0
/
(
2048.0
-
self
.ch
2
_wave_length
as
f32
);
self
.ch2_timer
=
(
freq
as
f32
/
target_freq
)
as
u16
;
self
.ch2_sequence
=
(
self
.ch2_sequence
+
1
)
&
7
;
...
...
@@ -166,6 +184,6 @@ impl Apu {
}
pub
fn
output
(
&
self
)
->
u8
{
self
.ch2_output
self
.ch1_output
+
self
.ch2_output
}
}
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