Commit Graph

40 Commits

Author SHA1 Message Date
Aaron Culliney
80b880550f Fix shutdown codepaths
- Ensures various shutdown codepaths (interface, cpu/audio, main/video, ...) run on proper thread(s)
    - Actually now runs the CloseAL() code
    - Try to ensure all detached threads exit ... seems to help keep Valgrind happy =)
2015-05-31 13:43:51 -07:00
Aaron Culliney
dcd0207525 Fix ctor load priorities 2015-04-17 22:12:13 -07:00
Aaron Culliney
5f210bfcf3 HACK around lingering issues with speed adjustment on mobile 2015-03-22 19:14:35 -07:00
Aaron Culliney
af42dc36b2 Squashed commit of the following:
CPU speed animation touch-ups, and enable building for desktop
    Rename/shuffle animation declarations and code
    Refactor backend video system to be a dynamically initialized module
    Basic CPU speed texture animation works on desktop Linux and Android
    Use static pixel buffers to avoid malloc/free churn
    Improve CPU animations
    First cut at CPU speed message animation
    Refactor some of the classic interface functions to be potentially reusable elsewhere
2015-03-22 18:53:13 -07:00
Aaron Culliney
cec638b959 Get threaded tests unstuck and rename/shuffle some code 2015-02-16 08:46:29 -08:00
Aaron Culliney
50cd4ac6fe Synchronize timing functions
- Avoids resetting critical speaker variables when CPU thread is churning
    - Moves pthread_* variable ownership into timing.c
2015-02-07 14:34:23 -08:00
Aaron Culliney
851d22568b Use 32bit counters to avoid overflow
- Previously there were cases where we could overflow cpu65_cycles_to_execute when adding the cycles_speaker_feedback
2015-02-03 22:10:47 -08:00
Aaron Culliney
f234de116f Refactor speaker system to prevent audio glitches and to support CPU automatic speed switching
Squashed commit of the following:

    REFACTOR : fix comments, logging, and rename some variables
    REFACTOR : fix up some commentary, clean deadc0de
    REFACTOR : mostly fix all the audio glitches
        - amplitudes of samples are gradually shifted to zero when speaker has fallen silent
        - simplifies speaker state machine
        - fullspeed mode only enqueues quiet samples
    REFACTOR : fix up a number of other functions and comments
    REFACTOR : clean up code to submit normal speed wave buffer to OpenAL
    Move some initializations to the cpu_thread()
    REFACTOR : properly reset the speaker cycles access counter so we don't underflow and assert
    REFACTOR : should never get a split buffer from our soundcore implementation
    Fix warning from gcc ... static array size needs to be computed from integer values
    REFACTOR : gcc (but not clang) complains about these, so just make them preprocessor defines
    REFACTOR : use unsigned long long because we don't actually care that this counter is 64bit
    REFACTOR : remainder_buffer and miscellaneous tweaks
        - Adds implementation commentary to document remainder_buffer purpose
        - Also adds sample average for square wave boundary in case where remainder_buffer not used (whole-sample boundary)
        - Variable renaming and code shuffling
    REFACTOR : do not dynamically alloc remainder buffer
        - Never attribute to cache-coherancy bugs what is a simple thread race =P
    REFACTOR : comments and whitespace
    REFACTOR : rename public speaker API functions
    REFACTOR : clean up public speaker API
    REFACTOR : tabs to spaces
    REFACTOR : moar deadc0de clean up and renaming
    REFACTOR : remove deadc0de paths from soundcore
    REFACTOR : fully excise soundtype stuff now that we only support soundcard output
    Move a file static to function scope
    REFACTOR : rename more variables and remove deadc0de
    REFACTOR : samples_buffer naming and change to explict int16_t
    REFACTOR : removed deadc0de and shuffled code locations
    REFACTOR : remainder buffer naming and clarify type
    REFACTOR : move joystick timing to VM module and remove header visibility
    REFACTOR : clarify speaker variable name
    REFACTOR : clarify cycle counting codepaths
    REFACTOR : VBL/timing interfaces
        - eliminates passing around a common global
    REFACTOR : names and comments
    HACK around volume issue
    REFACTOR : rename speaker feedback variable
    REFACTOR : rename global total cycle count
    REFACTOR : rename a constant
    Fix test builds
    REFACTOR: rename to is_fullspeed
    REFACTOR : local variable naming changes
    REFACTOR : migrate cycle timing variables to correct location and remove header visibility
    Allow fullspeed codepath to update speaker
    REFACTOR : remove deadc0de paths in prep for cleanup
    REFACTOR : speaker now manages its own VM entry point
2015-01-31 13:57:10 -08:00
Aaron Culliney
191a1b7395 Fix Mac builds 2015-01-16 21:11:29 -08:00
Aaron Culliney
87a2d081d3 CPU_TRACING now emits machine cycles 2015-01-11 18:37:57 -08:00
Aaron Culliney
643a431386 first cut at auto fast-loading of disk images
- automatically adjusts cpu timing to fastest if drive motor accessed recently and no audio/video
    - TODO: audio output clipping issue when (un)pausing audio outpu
2015-01-11 18:35:51 -08:00
Aaron Culliney
cce2bbb0cc timing code cleanup 2015-01-11 12:24:43 -08:00
Aaron Culliney
381d97c485 Preliminary VBL support sourced from AppleWin 2015-01-10 16:17:18 -08:00
Aaron Culliney
551cc00781 Silence a number of clang compiler warnings on Linux 2014-10-25 08:44:21 -07:00
Aaron Culliney
1b8387d214 cput_thread() now has correct pthread function prototype 2014-09-16 20:39:08 -07:00
Aaron Culliney
6e4b390b0d HACK until audio system refactored 2014-06-21 14:55:30 -07:00
Aaron Culliney
cecc78e824 Silence clang warnings 2014-06-21 14:51:25 -07:00
Aaron Culliney
a9d094c112 Misc tweaks to get OS X target building 2014-06-21 14:28:50 -07:00
Aaron Culliney
5b46978233 Allow "complete" reboots to occur when debug-stepping
* This allows reboot to work if RAMRD switch is set to auxmem (as it is in a few VM tests)
2014-04-28 11:40:51 -07:00
Aaron Culliney
baf9315d01 better pthread signaling between ui and cpu threads 2014-03-30 11:17:12 -07:00
Aaron Culliney
52b087f805 sanity-check for cpu thread 2014-03-30 11:10:24 -07:00
Aaron Culliney
e57f332ff6 moar ifdefs for various macro conditional codepaths
* INTERFACE_CLASSIC : specifies the "classic" (current) menuing system
    * AUDIO_ENABLED : specifies whether audio code is enabled
2014-03-23 14:25:28 -07:00
Aaron Culliney
a95354d87c cycles_adjust is too small to be worth calculating 2014-03-22 16:39:07 -07:00
Aaron Culliney
f34eff338b 65c02 Debugger fixen
* Threading fixes to allow CPU thread to iterate while under control of interface/video thread
2014-03-22 13:57:51 -07:00
asc
3abd2e87aa Refactor to use GNU build tools
* Added configure.ac and non-recursive Makefile.am
    * Modularized source into subdirectories
    * Simplified header inclusion
2014-01-22 20:51:50 -08:00
Aaron Culliney
e104ad9cb3 Some timing debugging tweaks 2013-12-29 11:39:34 -08:00
Aaron Culliney
b50d2c89cf Fix potential NULL-dereference 2013-12-29 11:37:05 -08:00
Aaron Culliney
d0ea2d654e Fix the game controller routines to use proper timers
* Add proper timers according to spec mentioned in _Understanding the Apple IIe_
    * This will allow us to refactor/eliminate all the hackish joystick adjustment routines
2013-12-21 13:55:40 -08:00
Aaron Culliney
bbf3205415 more timing statistics 2013-11-17 15:01:23 -08:00
Aaron Culliney
766d278601 First cut at supporting mockingboard.
* Now using OpenAL as the main backend, ALSA has been deprecated...

    * soundcore-openal.[hc] - OpenAL sound output for emulator

    * alhelpers.[hc] - OpenAL suport files

    * mockingboard.[hc] , AY8910.[hc] , SSI263Phonemes.h - Mockingboard support ported from AppleWin ...
2013-11-12 23:43:16 -08:00
Aaron Culliney
c39bea9580 Partial fix debugger for multithreaded environment
* Fixes crashing observed when trying to use debugger

    * Various refactoring whitespace fixes
2013-10-06 21:01:00 -07:00
Aaron Culliney
527c04e41f Support for new timing model
This is part 2 of 2

    * Handles UI changes to support new delay model, added ability to toggle to
      alternate speed scale

    * Code cleanups
2013-10-06 01:31:58 -07:00
Aaron Culliney
41a1f3d598 Timing model back to nanosleep for sound fidelity
This is part 1 of 2

    * Proper emulator timing is critical for emulating the Apple2 speaker with a
      square wave on a modern soundcard.  The AppleWin sources provided
      reference, inspiration, and source for both timing and speaker emulation
      code.

    * cpu.S, cpu.h, timing.c : OK so I flip-flopped quite a bit here on how best
      to do proper emulator timing, but the previous spinloop implementation was
      not one of my more enlightened decisions :P ... cpu/power consumption
      nightmare ...

    * ds-shim.h, win-shim.h -- Shims for Windows-isms and DirectSound-isms.  I
      assume these will eventually be refactored away...

    * soundcore.[hc], speaker.[hc] -- Directly ported from a recent version of
      AppleWin.  Everything I've added should be braced with #ifdef APPLE2IX.

    * soundcore-alsa.[hc] -- An ALSA backend using mmap'ed soundcard access.
2013-10-05 23:33:18 -07:00
Aaron Culliney
1f9a1778b9 spinloop timing that seeks to directly match apple speed 2013-07-25 22:58:31 -07:00
Aaron Culliney
980bcc627d WIP : dynamically adjustable spinloop 2013-07-23 00:33:29 -07:00
Aaron Culliney
96d083a2c3 WIP: changes to cpu throttling/timing
WARN: this is still a WIP and untested.  Instead of nanosleep() the cpu thread
now uses an adaptive spinloop.  This better emulates the actual apple //e speed
in preparation to do near-realtime audio.  The drawback is that the cpu thread
is pegged at 100% usage.
2013-07-21 17:20:03 -07:00
Aaron Culliney
d599a2174a refactoring for clarity and adding cycle timing 2013-07-07 20:52:30 -07:00
Aaron Culliney
e919718b73 an uncrustify pass and uncrustify config file 2013-07-05 21:37:13 -07:00
Aaron Culliney
18c3f5f698 we no longer use timers with setitimer and SIGVTALRM, that's so nineties...
instead spin off a cpu_thread and have it ping the main render thread as needed
2013-07-02 01:10:57 -07:00
Aaron Culliney
8bd46f494f new cpu throttling routine 2013-06-27 23:36:25 -07:00