mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-10 06:31:13 +00:00
Refactor : move reinitialize() to timing module and make static (mostly)
This commit is contained in:
parent
f95a00df7b
commit
7d4b63e12d
@ -130,8 +130,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobje
|
||||
#if TESTING
|
||||
_run_tests();
|
||||
#else
|
||||
c_initialize_firsttime();
|
||||
pthread_create(&cpu_thread_id, NULL, (void *) &cpu_thread, (void *)NULL);
|
||||
timing_startCPU();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
// to [self openGLContext])
|
||||
[[self openGLContext] makeCurrentContext];
|
||||
|
||||
c_initialize_firsttime();
|
||||
pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL);
|
||||
timing_startCPU();
|
||||
|
||||
// Synchronize buffer swaps with vertical refresh rate
|
||||
GLint swapInt = 1;
|
||||
|
@ -1068,13 +1068,11 @@ void video_init(void) {
|
||||
memset(video__fb2,0,SCANWIDTH*SCANHEIGHT);
|
||||
|
||||
#if !HEADLESS
|
||||
#if !defined(__APPLE__)
|
||||
#if !defined(ANDROID)
|
||||
# if !defined(__APPLE__) && !defined(ANDROID)
|
||||
if (!is_headless) {
|
||||
video_backend->init((void*)0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
42
src/misc.c
42
src/misc.c
@ -566,43 +566,6 @@ void c_initialize_vm() {
|
||||
c_joystick_reset(); /* reset joystick */
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
void c_initialize_firsttime()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void reinitialize(void) {
|
||||
#if !TESTING
|
||||
assert(pthread_self() == cpu_thread_id);
|
||||
#endif
|
||||
|
||||
cycles_count_total = 0;
|
||||
|
||||
c_initialize_vm();
|
||||
|
||||
softswitches = SS_TEXT | SS_IOUDIS | SS_C3ROM | SS_LCWRT | SS_LCSEC;
|
||||
|
||||
video_setpage( 0 );
|
||||
|
||||
video_redraw();
|
||||
|
||||
cpu65_init();
|
||||
|
||||
timing_initialize();
|
||||
|
||||
#ifdef AUDIO_ENABLED
|
||||
MB_Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void c_initialize_firsttime(void) {
|
||||
|
||||
video_init();
|
||||
|
||||
#ifdef DEBUGGER
|
||||
c_debugger_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TESTING && !defined(__APPLE__) && !defined(ANDROID)
|
||||
extern void *cpu_thread(void *dummyptr);
|
||||
|
||||
@ -652,11 +615,8 @@ int main(int _argc, char **_argv) {
|
||||
#ifdef INTERFACE_CLASSIC
|
||||
c_keys_set_key(kF8); // show credits before emulation start
|
||||
#endif
|
||||
c_initialize_firsttime(); // one-time initializations
|
||||
|
||||
// spin off cpu thread
|
||||
pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL);
|
||||
|
||||
timing_startCPU();
|
||||
video_main_loop();
|
||||
|
||||
assert(emulator_shutting_down && "emulator is properly shutting down");
|
||||
|
@ -100,14 +100,12 @@ extern uint32_t softswitches;
|
||||
|
||||
extern bool emulator_shutting_down;
|
||||
|
||||
void c_initialize_firsttime();
|
||||
void c_initialize_sound_hooks();
|
||||
void c_disable_sound_hooks();
|
||||
void c_set_primary_char();
|
||||
void c_set_altchar();
|
||||
void c_initialize_font();
|
||||
void c_initialize_vm();
|
||||
void reinitialize();
|
||||
|
||||
/* vm hooks */
|
||||
|
||||
|
34
src/timing.c
34
src/timing.c
@ -160,6 +160,33 @@ static void _timing_initialize(double scale) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !TESTING
|
||||
static
|
||||
#endif
|
||||
void reinitialize(void) {
|
||||
#if !TESTING
|
||||
assert(pthread_self() == cpu_thread_id);
|
||||
#endif
|
||||
|
||||
cycles_count_total = 0;
|
||||
|
||||
c_initialize_vm();
|
||||
|
||||
softswitches = SS_TEXT | SS_IOUDIS | SS_C3ROM | SS_LCWRT | SS_LCSEC;
|
||||
|
||||
video_setpage( 0 );
|
||||
|
||||
video_redraw();
|
||||
|
||||
cpu65_init();
|
||||
|
||||
timing_initialize();
|
||||
|
||||
#ifdef AUDIO_ENABLED
|
||||
MB_Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void timing_initialize(void) {
|
||||
assert(cpu_isPaused() || (pthread_self() == cpu_thread_id));
|
||||
_timing_initialize(alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor);
|
||||
@ -234,7 +261,7 @@ bool timing_shouldAutoAdjustSpeed(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void *cpu_thread(void *dummyptr) {
|
||||
static void *cpu_thread(void *dummyptr) {
|
||||
|
||||
assert(pthread_self() == cpu_thread_id);
|
||||
|
||||
@ -525,6 +552,11 @@ void *cpu_thread(void *dummyptr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void timing_startCPU(void) {
|
||||
video_init();
|
||||
pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL);
|
||||
}
|
||||
|
||||
unsigned int CpuGetCyclesThisVideoFrame(void) {
|
||||
timing_checkpoint_cycles();
|
||||
return g_dwCyclesThisFrame + cycles_checkpoint_count;
|
||||
|
10
src/timing.h
10
src/timing.h
@ -69,6 +69,11 @@ extern READONLY pthread_t cpu_thread_id;
|
||||
*/
|
||||
struct timespec timespec_diff(struct timespec start, struct timespec end, bool *negative);
|
||||
|
||||
/*
|
||||
* Start CPU thread
|
||||
*/
|
||||
void timing_startCPU(void);
|
||||
|
||||
/*
|
||||
* toggles CPU speed between configured values
|
||||
*/
|
||||
@ -91,11 +96,6 @@ void timing_initialize(void);
|
||||
*/
|
||||
void timing_reinitializeAudio(void);
|
||||
|
||||
/*
|
||||
* timing/CPU thread entry point
|
||||
*/
|
||||
void *cpu_thread(void *ignored);
|
||||
|
||||
/*
|
||||
* Pause timing/CPU thread.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user