Skip to content

Commit

Permalink
PulseChannel fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
miochen1226 committed Oct 11, 2023
1 parent 60fa719 commit edca5ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions NES_EMU.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 82Q375NBS9;
ENABLE_PREVIEWS = YES;
GCC_OPTIMIZATION_LEVEL = 3;
Expand Down Expand Up @@ -791,7 +791,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 82Q375NBS9;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iOS/Info.plist;
Expand Down
Binary file not shown.
22 changes: 8 additions & 14 deletions Shared/NES/Apu/Channel/PulseChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,9 @@ class PulseChannel:BaseChannel {
lengthCounter.setHalt(l)
volumeEnvelope.setLoop(l)

if c {
volumeEnvelope.setConstantVolumeMode(true)
volumeEnvelope.setConstantVolume(UInt16(vvvv))
//print("volumeEnvelope c true->" + String(vvvv))
}
else {
volumeEnvelope.setConstantVolumeMode(false)
volumeEnvelope.setCounter(UInt16(vvvv))
volumeEnvelope.restart()
}
volumeEnvelope.setConstantVolumeMode(c)
volumeEnvelope.setConstantVolume(UInt16(vvvv))
volumeEnvelope.setCounter(UInt16(vvvv))
}

func handle40014005(cpuAddress:UInt16, value: UInt8) {
Expand All @@ -87,11 +80,11 @@ class PulseChannel:BaseChannel {
let SSS = readBits8( target:BITS([0,1,2]),value:value)
sweepUnit.setShiftCount(SSS)

//sweepUnit.restart()
// Side effect
sweepUnit.restart()
}

func handle40024006(cpuAddress:UInt16, value:UInt8)
{
func handle40024006(cpuAddress:UInt16, value:UInt8) {
//LLLL.LLLL
//LLLLLLLL
//timer 的低 8 位(一共 11 位,用于将 cpu 二分频后的时钟继续分频)
Expand All @@ -111,7 +104,8 @@ class PulseChannel:BaseChannel {
let LLLL = readBits8( target:BITS([3,4,5,6,7]),value:value) >> 3
lengthCounter.loadCounterFromLUT(LLLL)

//volumeEnvelope.restart()
// Side effects...
volumeEnvelope.restart()
pulseWaveGenerator.restart()
}

Expand Down
1 change: 1 addition & 0 deletions Shared/NES/Apu/Channel/TriangleChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class TriangleChannel: BaseChannel {
case 0x400B:
let period = readBits8(target: 0x7, value: value)
timer.setPeriodHigh3(UInt16(period))
// Side effect
linearCounter.restart()
lengthCounter.loadCounterFromLUT(value >> 3)
break
Expand Down

0 comments on commit edca5ba

Please sign in to comment.