diff --git a/A2Mac.xcodeproj/project.pbxproj b/A2Mac.xcodeproj/project.pbxproj index a9a15fd..d5758e9 100644 --- a/A2Mac.xcodeproj/project.pbxproj +++ b/A2Mac.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 32089E4924556DBD0036E667 /* PRNumber3.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 32089E4724556DBD0036E667 /* PRNumber3.ttf */; }; + 320B3FC424AD88B0005EA133 /* power.png in Resources */ = {isa = PBXBuildFile; fileRef = 320B3FC324AD88B0005EA133 /* power.png */; }; 3213936624079C30007F5C4A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; }; 323D042E248980600086A901 /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 323D042D248980600086A901 /* Preferences.storyboard */; }; 323D043024898AB70086A901 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 323D042F24898AB70086A901 /* PreferencesViewController.swift */; }; @@ -18,6 +19,7 @@ 323E2DD1245531E600156805 /* Apple2e.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; }; 32440B85247E27D7000F9DA1 /* 6502.c in Sources */ = {isa = PBXBuildFile; fileRef = 32439F7422ECD8AD0077AAE0 /* 6502.c */; }; 32440BA32480D5C0000F9DA1 /* LoRes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32440BA22480D5C0000F9DA1 /* LoRes.swift */; }; + 324D15D324ADAC71008AAFB0 /* floppy.png in Resources */ = {isa = PBXBuildFile; fileRef = 324D15D224ADAC71008AAFB0 /* floppy.png */; }; 325DC40E24AC5ABC00EB8858 /* doc.on.doc.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC40D24AC5ABC00EB8858 /* doc.on.doc.png */; }; 325DC41024AC691B00EB8858 /* rgb_color.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC40F24AC691B00EB8858 /* rgb_color.png */; }; 325DC41324AC692D00EB8858 /* rgb_mono.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 325DC41124AC692D00EB8858 /* rgb_mono.png */; }; @@ -54,6 +56,9 @@ 325EB6A82401118300C6B4A4 /* ProDOS_402_System.woz in Resources */ = {isa = PBXBuildFile; fileRef = 325EB6992401118200C6B4A4 /* ProDOS_402_System.woz */; }; 325EB6AA2401118300C6B4A4 /* Sneakers.woz in Resources */ = {isa = PBXBuildFile; fileRef = 325EB69A2401118300C6B4A4 /* Sneakers.woz */; }; 325EB6AC2401118300C6B4A4 /* Xonix.woz in Resources */ = {isa = PBXBuildFile; fileRef = 325EB69B2401118300C6B4A4 /* Xonix.woz */; }; + 326B56E524AD8E89009BA0AC /* gobackward.png in Resources */ = {isa = PBXBuildFile; fileRef = 326B56E424AD8E89009BA0AC /* gobackward.png */; }; + 326B56E724AD906D009BA0AC /* doc.text.viewfinder.png in Resources */ = {isa = PBXBuildFile; fileRef = 326B56E624AD906D009BA0AC /* doc.text.viewfinder.png */; }; + 32877F8D24ADA6AF003A940D /* joystick.png in Resources */ = {isa = PBXBuildFile; fileRef = 32877F8C24ADA6AF003A940D /* joystick.png */; }; 3296223224A6622C002DEB78 /* apple_original_logo_design.png in Resources */ = {isa = PBXBuildFile; fileRef = 3296223124A6622C002DEB78 /* apple_original_logo_design.png */; }; 3296223424A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx in Resources */ = {isa = PBXBuildFile; fileRef = 3296223324A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx */; }; 3296223524A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx in Resources */ = {isa = PBXBuildFile; fileRef = 3296223324A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx */; }; @@ -63,6 +68,7 @@ 3296223A24A710E5002DEB78 /* disk_ii_io_error.sfx in Copy SFX Files */ = {isa = PBXBuildFile; fileRef = 3296223724A710CD002DEB78 /* disk_ii_io_error.sfx */; }; 32A9F74A2467B60B004902A1 /* speaker.c in Sources */ = {isa = PBXBuildFile; fileRef = 32A9F7492467B60B004902A1 /* speaker.c */; }; 32A9F74B2467B60B004902A1 /* speaker.c in Sources */ = {isa = PBXBuildFile; fileRef = 32A9F7492467B60B004902A1 /* speaker.c */; }; + 32AF7C9724AD85E8002D82BF /* select_all.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 32AF7C9624AD85E8002D82BF /* select_all.png */; }; 32BFFB5B22EACC630003B53F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BFFB5A22EACC630003B53F /* AppDelegate.swift */; }; 32BFFB5D22EACC630003B53F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BFFB5C22EACC630003B53F /* ViewController.swift */; }; 32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB5E22EACC660003B53F /* Assets.xcassets */; }; @@ -262,6 +268,7 @@ dstPath = ""; dstSubfolderSpec = 7; files = ( + 32AF7C9724AD85E8002D82BF /* select_all.png in Copy Image Files */, 325DC41024AC691B00EB8858 /* rgb_color.png in Copy Image Files */, 325DC41324AC692D00EB8858 /* rgb_mono.png in Copy Image Files */, 325DC41424AC692D00EB8858 /* mono.png in Copy Image Files */, @@ -278,6 +285,7 @@ /* Begin PBXFileReference section */ 32089E4724556DBD0036E667 /* PRNumber3.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = PRNumber3.ttf; sourceTree = ""; }; + 320B3FC324AD88B0005EA133 /* power.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = power.png; sourceTree = ""; }; 323D042D248980600086A901 /* Preferences.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Preferences.storyboard; sourceTree = ""; }; 323D042F24898AB70086A901 /* PreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = ""; }; 323D04312489BFD80086A901 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = ""; }; @@ -335,6 +343,7 @@ 32440B9C247F9DC7000F9DA1 /* blank.woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = blank.woz; sourceTree = ""; }; 32440BA0247F9F99000F9DA1 /* LOCKSMITH_V7_REV_B.woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = LOCKSMITH_V7_REV_B.woz; sourceTree = ""; }; 32440BA22480D5C0000F9DA1 /* LoRes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoRes.swift; sourceTree = ""; }; + 324D15D224ADAC71008AAFB0 /* floppy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = floppy.png; sourceTree = ""; }; 325DC40D24AC5ABC00EB8858 /* doc.on.doc.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = doc.on.doc.png; sourceTree = ""; }; 325DC40F24AC691B00EB8858 /* rgb_color.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rgb_color.png; sourceTree = ""; }; 325DC41124AC692D00EB8858 /* rgb_mono.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rgb_mono.png; sourceTree = ""; }; @@ -377,12 +386,16 @@ 3264261023284F6F008B615F /* Apple2_mmio_8bit_ioaddr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Apple2_mmio_8bit_ioaddr.h; sourceTree = ""; }; 326426112328ADF4008B615F /* Apple_II_ROM.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = Apple_II_ROM.s; sourceTree = ""; }; 3268E68E2474E24900047474 /* paddle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = paddle.h; sourceTree = ""; }; + 326B56E424AD8E89009BA0AC /* gobackward.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gobackward.png; sourceTree = ""; }; + 326B56E624AD906D009BA0AC /* doc.text.viewfinder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = doc.text.viewfinder.png; sourceTree = ""; }; 326ED2EE232D7A0000A41337 /* 6502_functional_test.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = 6502_functional_test.bin; sourceTree = SOURCE_ROOT; }; + 32877F8C24ADA6AF003A940D /* joystick.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = joystick.png; sourceTree = ""; }; 3296223124A6622C002DEB78 /* apple_original_logo_design.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = apple_original_logo_design.png; sourceTree = ""; }; 3296223324A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx */ = {isa = PBXFileReference; lastKnownFileType = file; path = disk_ii_motor_w_floppy.sfx; sourceTree = ""; }; 3296223724A710CD002DEB78 /* disk_ii_io_error.sfx */ = {isa = PBXFileReference; lastKnownFileType = file; path = disk_ii_io_error.sfx; sourceTree = ""; }; 32A9F7482467B60B004902A1 /* speaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speaker.h; sourceTree = ""; }; 32A9F7492467B60B004902A1 /* speaker.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = speaker.c; sourceTree = ""; }; + 32AF7C9624AD85E8002D82BF /* select_all.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = select_all.png; sourceTree = ""; }; 32B18435233F10BC00DBB4AB /* Shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; }; 32B18438233FAB3900DBB4AB /* verticies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = verticies.swift; sourceTree = ""; }; 32BFFB5722EACC630003B53F /* Steve ][.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Steve ][.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -792,13 +805,19 @@ 32F8A8B124A3AE1600EE6735 /* img */ = { isa = PBXGroup; children = ( + 324D15D224ADAC71008AAFB0 /* floppy.png */, + 32877F8C24ADA6AF003A940D /* joystick.png */, 3296223124A6622C002DEB78 /* apple_original_logo_design.png */, 32E21BE62491BF8B006C0C72 /* apple-rainbow.png */, 323D04432490B3930086A901 /* dotmatrix_effect.png */, 323D04452490BA1E0086A901 /* scanlines.png */, 325DC40D24AC5ABC00EB8858 /* doc.on.doc.png */, 32E3127224AC0AC400E61891 /* doc.on.clipboard.png */, + 326B56E624AD906D009BA0AC /* doc.text.viewfinder.png */, + 32AF7C9624AD85E8002D82BF /* select_all.png */, + 320B3FC324AD88B0005EA133 /* power.png */, 325DC41224AC692D00EB8858 /* mono.png */, + 326B56E424AD8E89009BA0AC /* gobackward.png */, 325DC41124AC692D00EB8858 /* rgb_mono.png */, 325DC40F24AC691B00EB8858 /* rgb_color.png */, ); @@ -1065,10 +1084,15 @@ buildActionMask = 2147483647; files = ( 3296223424A709CE002DEB78 /* disk_ii_motor_w_floppy.sfx in Resources */, + 320B3FC424AD88B0005EA133 /* power.png in Resources */, + 32877F8D24ADA6AF003A940D /* joystick.png in Resources */, 3296223224A6622C002DEB78 /* apple_original_logo_design.png in Resources */, 3213936624079C30007F5C4A /* Main.storyboard in Resources */, + 326B56E724AD906D009BA0AC /* doc.text.viewfinder.png in Resources */, 32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */, + 324D15D324ADAC71008AAFB0 /* floppy.png in Resources */, 323D042E248980600086A901 /* Preferences.storyboard in Resources */, + 326B56E524AD8E89009BA0AC /* gobackward.png in Resources */, 32E3126524A7193700E61891 /* disk_ii_arm.sfx in Resources */, 3296223824A710CD002DEB78 /* disk_ii_io_error.sfx in Resources */, ); diff --git a/A2Mac/Base.lproj/Main.storyboard b/A2Mac/Base.lproj/Main.storyboard index c9f31a0..89aac01 100644 --- a/A2Mac/Base.lproj/Main.storyboard +++ b/A2Mac/Base.lproj/Main.storyboard @@ -1242,14 +1242,14 @@ - + - - - @@ -1290,20 +1287,20 @@ - + - + @@ -1322,6 +1319,22 @@ + + + + + + + + + @@ -1354,23 +1367,23 @@ - + - - + - + @@ -1383,23 +1396,23 @@ - + - + - - + @@ -1418,6 +1431,38 @@ + + + + + + + + + + + + + + + + + + @@ -1456,12 +1501,14 @@ - + + + @@ -1639,19 +1686,18 @@ - + - + - - - + + @@ -1668,6 +1714,10 @@ + + + + @@ -1955,19 +2005,22 @@ - - + + + + + diff --git a/A2Mac/ToolBarController.swift b/A2Mac/ToolBarController.swift index 8cb5a2e..80d2b73 100644 --- a/A2Mac/ToolBarController.swift +++ b/A2Mac/ToolBarController.swift @@ -13,17 +13,23 @@ import AVFoundation class ToolBarController: NSWindowController { @IBAction func PowerOn(_ sender: Any) { - ViewController.current?.PowerOn(sender) - } - - @IBAction func PowerOff(_ sender: Any) { - ViewController.current?.PowerOff(sender) + switch cpuState { + case cpuState_inited, cpuState_unknown: + ViewController.current?.PowerOn(sender) + + default: + ViewController.current?.PowerOff(sender) + } } @IBAction func Pause(_ sender: Any) { ViewController.current?.Pause(sender) } + @IBAction func Reset(_ sender: Any) { + ViewController.current?.Reset(sender) + } + @IBAction func Copy(_ sender: Any) { } @@ -81,4 +87,15 @@ class ToolBarController: NSWindowController { ViewController.current?.setSimulationMode( mode: sender.selectedItem?.title ?? "Normal" ) } + @IBAction func Mute(_ sender: Any) { + spkr_mute() + } + + @IBAction func VolDn(_ sender: Any) { + spkr_vol_dn() + } + + @IBAction func VolUp(_ sender: Any) { + spkr_vol_up() + } } diff --git a/Resources/img/doc.text.viewfinder.png b/Resources/img/doc.text.viewfinder.png new file mode 100644 index 0000000..b41f604 Binary files /dev/null and b/Resources/img/doc.text.viewfinder.png differ diff --git a/Resources/img/floppy.png b/Resources/img/floppy.png new file mode 100644 index 0000000..550831d Binary files /dev/null and b/Resources/img/floppy.png differ diff --git a/Resources/img/gobackward.png b/Resources/img/gobackward.png new file mode 100644 index 0000000..0ee2b41 Binary files /dev/null and b/Resources/img/gobackward.png differ diff --git a/Resources/img/joystick.png b/Resources/img/joystick.png new file mode 100644 index 0000000..f9a9621 Binary files /dev/null and b/Resources/img/joystick.png differ diff --git a/Resources/img/power.png b/Resources/img/power.png new file mode 100644 index 0000000..57c1b7c Binary files /dev/null and b/Resources/img/power.png differ diff --git a/Resources/img/select_all.png b/Resources/img/select_all.png new file mode 100644 index 0000000..05b96cb Binary files /dev/null and b/Resources/img/select_all.png differ diff --git a/src/dev/audio/speaker.c b/src/dev/audio/speaker.c index e4dc202..c5a0886 100644 --- a/src/dev/audio/speaker.c +++ b/src/dev/audio/speaker.c @@ -53,6 +53,7 @@ ALCdevice *dev = NULL; ALCcontext *ctx = NULL; +#define SPKR_MIN_VOL 0.0001 // OpenAL cannot change volume to 0.0 for some reason, so we just turn volume really low int spkr_level = SPKR_LEVEL_ZERO; @@ -68,6 +69,9 @@ ALuint spkr_disk_arm_buf = 0; ALuint spkr_disk_ioerr_buf = 0; +float spkr_vol = 0.5; + + const unsigned spkr_fps = DEFAULT_FPS; unsigned spkr_fps_divider = 1; unsigned spkr_frame_cntr = 0; @@ -174,6 +178,13 @@ void spkr_init() { alGenSources(SOURCES_COUNT, spkr_src); al_check_error(); + alListener3f(AL_POSITION, 0.0, 0.0, 0.0); + al_check_error(); + alListenerf(AL_GAIN, spkr_vol); + al_check_error(); +// alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0); +// al_check_error(); + alSourcei(spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_RELATIVE, AL_TRUE); al_check_error(); alSourcei(spkr_src[SPKR_SRC_GAME_SFX], AL_LOOPING, AL_FALSE); @@ -182,10 +193,6 @@ void spkr_init() { al_check_error(); alSource3f(spkr_src[SPKR_SRC_GAME_SFX], AL_POSITION, 0.0, 8.0, 0.0); al_check_error(); - alListener3f(AL_POSITION, 0.0, 0.0, 0.0); - al_check_error(); -// alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0); -// al_check_error(); // Set-up disk motor sound source and play buffer @@ -197,10 +204,6 @@ void spkr_init() { al_check_error(); alSource3f(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_POSITION, 0.0, 8.0, 0.0); al_check_error(); - alListener3f(AL_POSITION, 0.0, 0.0, 0.0); - al_check_error(); -// alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0); -// al_check_error(); // Set-up disk arm sound source and play buffer @@ -212,10 +215,6 @@ void spkr_init() { al_check_error(); alSource3f(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_POSITION, 0.0, 8.0, 0.0); al_check_error(); - alListener3f(AL_POSITION, 0.0, 0.0, 0.0); - al_check_error(); -// alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0); -// al_check_error(); // Set-up disk io error sound source and play buffer @@ -227,10 +226,6 @@ void spkr_init() { al_check_error(); alSource3f(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_POSITION, 0.0, 8.0, 0.0); al_check_error(); - alListener3f(AL_POSITION, 0.0, 0.0, 0.0); - al_check_error(); -// alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0); -// al_check_error(); // start from the beginning @@ -241,6 +236,41 @@ void spkr_init() { } +void spkr_vol_up() { + spkr_vol += 0.1; + if ( spkr_vol > 1 ) { + spkr_vol = 1; + } + alListenerf(AL_GAIN, spkr_vol); + al_check_error(); +} + +void spkr_vol_dn() { + spkr_vol -= 0.1; + if ( spkr_vol < 0.1 ) { + // use mute to make it completely silent + spkr_vol = 0.1; + } + alListenerf(AL_GAIN, spkr_vol); + al_check_error(); +} + +void spkr_mute() { + ALfloat vol = 0; + alGetListenerf(AL_GAIN, &vol); + al_check_error(); + + if ( vol > SPKR_MIN_VOL ) { + alListenerf(AL_GAIN, SPKR_MIN_VOL); + al_check_error(); + } + else { + alListenerf(AL_GAIN, spkr_vol); + al_check_error(); + } +} + + int spkr_unqueue( ALuint src ) { ALint processed = 0; diff --git a/src/dev/audio/speaker.h b/src/dev/audio/speaker.h index 67a2f93..a6da4dc 100644 --- a/src/dev/audio/speaker.h +++ b/src/dev/audio/speaker.h @@ -58,6 +58,11 @@ extern int spkr_extra_buf; extern unsigned spkr_play_timeout; extern unsigned spkr_play_time; +extern float spkr_vol; + +extern void spkr_vol_up(void); +extern void spkr_vol_dn(void); +extern void spkr_mute(void); extern void spkr_init(void); extern void spkr_exit(void);