mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-02-07 04:31:50 +00:00
Revert "Fix non-deterministic ctor load issues and use singleton for video_backend module access"
This reverts commit af95212a199fbf4360de89409067861b6248a5b5. TODO : make ctor loads deterministic
This commit is contained in:
parent
e2272132c2
commit
2bc846d1fe
@ -90,19 +90,19 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobje
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsChanged(JNIEnv *env, jobject obj, jint width, jint height) {
|
||||
LOG("%s", "native graphicsChanged...");
|
||||
video_backendInstance()->reshape(width, height);
|
||||
video_backend->reshape(width, height);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsInitialized(JNIEnv *env, jobject obj, jint width, jint height) {
|
||||
LOG("native graphicsInitialized width:%d height:%d", width, height);
|
||||
static bool graphicsPreviouslyInitialized = false;
|
||||
if (graphicsPreviouslyInitialized) {
|
||||
video_backendInstance()->shutdown();
|
||||
video_backend->shutdown();
|
||||
}
|
||||
graphicsPreviouslyInitialized = true;
|
||||
|
||||
video_backendInstance()->reshape(width, height);
|
||||
video_backendInstance()->init((void *)0);
|
||||
video_backend->reshape(width, height);
|
||||
video_backend->init((void *)0);
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnResume(JNIEnv *env, jobject obj) {
|
||||
@ -149,7 +149,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeRender(JNIEnv *env, jobject
|
||||
if (!nativePaused) {
|
||||
_vid_dirty = true;// HACK HACK HACK FIXME TODO : efficiency and battery life gains if we can fix this ...
|
||||
}
|
||||
video_backendInstance()->render();
|
||||
video_backend->render();
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeReboot(JNIEnv *env, jobject obj) {
|
||||
@ -220,8 +220,8 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeIncreaseCPUSpeed(JNIEnv *en
|
||||
|
||||
LOG("native set emulation percentage to %f", cpu_scale_factor);
|
||||
|
||||
if (video_backendInstance()->video_animation_show_cpuspeed) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed();
|
||||
if (video_backend->video_animation_show_cpuspeed) {
|
||||
video_backend->video_animation_show_cpuspeed();
|
||||
}
|
||||
|
||||
#warning HACK TODO FIXME ... refactor timing stuff
|
||||
@ -253,8 +253,8 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeDecreaseCPUSpeed(JNIEnv *en
|
||||
|
||||
LOG("native set emulation percentage to %f", cpu_scale_factor);
|
||||
|
||||
if (video_backendInstance()->video_animation_show_cpuspeed) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed();
|
||||
if (video_backend->video_animation_show_cpuspeed) {
|
||||
video_backend->video_animation_show_cpuspeed();
|
||||
}
|
||||
|
||||
#warning HACK TODO FIXME ... refactor timing stuff
|
||||
|
@ -196,10 +196,10 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
// Init our renderer. Use 0 for the defaultFBO which is appropriate for
|
||||
// OSX (but not iOS since iOS apps must create their own FBO)
|
||||
#if TARGET_OS_MAC
|
||||
video_backendInstance()->init(0);
|
||||
video_backend->init(0);
|
||||
#elif TARGET_OS_IPHONE
|
||||
# error "FBO FIXME TODO"
|
||||
video_backendInstance()->init(otherFBO);
|
||||
video_backend->init(otherFBO);
|
||||
#else
|
||||
# error "unknown/unsupported Apple platform
|
||||
#endif
|
||||
@ -246,7 +246,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
#endif // !SUPPORT_RETINA_RESOLUTION
|
||||
|
||||
// Set the new dimensions in our renderer
|
||||
video_backendInstance()->reshape((int)viewRectPixels.size.width, (int)viewRectPixels.size.height);
|
||||
video_backend->reshape((int)viewRectPixels.size.width, (int)viewRectPixels.size.height);
|
||||
|
||||
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
||||
}
|
||||
@ -276,7 +276,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
- (void)drawView
|
||||
{
|
||||
CGLLockContext([[self openGLContext] CGLContextObj]);
|
||||
video_backendInstance()->render();
|
||||
video_backend->render();
|
||||
CGLFlushDrawable([[self openGLContext] CGLContextObj]);
|
||||
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:(NSString *)kDrawTimerNotification object:nil];
|
||||
@ -296,7 +296,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
#endif
|
||||
|
||||
// shut down common OpenGL stuff AFTER display link has been released
|
||||
video_backendInstance()->shutdown();
|
||||
video_backend->shutdown();
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -16,12 +16,6 @@
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#define spin_lock_t OSSpinLock
|
||||
#define spin_lock_lock OSSpinLockLock
|
||||
#define spin_lock_unlock OSSpinLockUnlock
|
||||
|
||||
#define CLOCK_MONOTONIC 1
|
||||
|
||||
int clock_gettime(int, struct timespec *);
|
||||
|
@ -25,6 +25,7 @@ static uint8_t vga_mem_page_0[SCANWIDTH*SCANHEIGHT];
|
||||
static uint8_t vga_mem_page_1[SCANWIDTH*SCANHEIGHT];
|
||||
|
||||
A2Color_s colormap[256] = { { 0 } };
|
||||
video_backend_s *video_backend = NULL;
|
||||
|
||||
static uint8_t video__wider_font[0x8000];
|
||||
static uint8_t video__font[0x4000];
|
||||
@ -490,7 +491,7 @@ void video_loadfont(int first, int quantity, const uint8_t *data, int mode) {
|
||||
}
|
||||
}
|
||||
|
||||
static void video_loadfont_interface(int first, int quantity, const uint8_t *data) {
|
||||
static void video_loadfont_int(int first, int quantity, const uint8_t *data) {
|
||||
unsigned int i = quantity * 8;
|
||||
while (i--) {
|
||||
unsigned int j = 8;
|
||||
@ -720,15 +721,15 @@ GLUE_C_WRITE(video__write_2e_text1_mixed)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Classic interface and printing HUD messages
|
||||
|
||||
void video_loadfonts_interface(void) {
|
||||
video_loadfont_interface(0x00,0x40,ucase_glyphs);
|
||||
video_loadfont_interface(0x40,0x20,ucase_glyphs);
|
||||
video_loadfont_interface(0x60,0x20,lcase_glyphs);
|
||||
video_loadfont_interface(0x80,0x40,ucase_glyphs);
|
||||
video_loadfont_interface(0xC0,0x20,ucase_glyphs);
|
||||
video_loadfont_interface(0xE0,0x20,lcase_glyphs);
|
||||
video_loadfont_interface(0x80,11,interface_glyphs);
|
||||
video_loadfont_interface(MOUSETEXT_BEGIN,0x20,mousetext_glyphs);
|
||||
static void _load_interface_fonts(void) {
|
||||
video_loadfont_int(0x00,0x40,ucase_glyphs);
|
||||
video_loadfont_int(0x40,0x20,ucase_glyphs);
|
||||
video_loadfont_int(0x60,0x20,lcase_glyphs);
|
||||
video_loadfont_int(0x80,0x40,ucase_glyphs);
|
||||
video_loadfont_int(0xC0,0x20,ucase_glyphs);
|
||||
video_loadfont_int(0xE0,0x20,lcase_glyphs);
|
||||
video_loadfont_int(0x80,11,interface_glyphs);
|
||||
video_loadfont_int(MOUSETEXT_BEGIN,0x20,mousetext_glyphs);
|
||||
}
|
||||
|
||||
void interface_plotChar(uint8_t *fb, int fb_pix_width, int col, int row, interface_colorscheme_t cs, uint8_t c) {
|
||||
@ -1057,7 +1058,7 @@ void video_init(void) {
|
||||
#if !defined(__APPLE__)
|
||||
#if !defined(ANDROID)
|
||||
if (!is_headless) {
|
||||
video_backendInstance()->init((void*)0);
|
||||
video_backend->init((void*)0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1067,7 +1068,7 @@ void video_init(void) {
|
||||
void video_shutdown(void) {
|
||||
#if !HEADLESS
|
||||
if (!is_headless) {
|
||||
video_backendInstance()->shutdown();
|
||||
video_backend->shutdown();
|
||||
}
|
||||
#if !defined(__APPLE__)
|
||||
exit(0);
|
||||
@ -1077,7 +1078,7 @@ void video_shutdown(void) {
|
||||
|
||||
void video_main_loop(void) {
|
||||
#if !HEADLESS
|
||||
video_backendInstance()->main_loop();
|
||||
video_backend->main_loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1271,3 +1272,10 @@ uint8_t floating_bus_hibit(const bool hibit) {
|
||||
uint8_t b = apple_ii_64k[0][scanner_addr];
|
||||
return (b & ~0x80) | (hibit ? 0x80 : 0);
|
||||
}
|
||||
|
||||
__attribute__((constructor))
|
||||
static void _init_interface(void) {
|
||||
LOG("display subsystem startup");
|
||||
_load_interface_fonts();
|
||||
}
|
||||
|
||||
|
12
src/keys.c
12
src/keys.c
@ -253,8 +253,8 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
|
||||
if (current_key == kF9)
|
||||
{
|
||||
timing_toggle_cpu_speed();
|
||||
if (video_backendInstance()->video_animation_show_cpuspeed) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed();
|
||||
if (video_backend->video_animation_show_cpuspeed) {
|
||||
video_backend->video_animation_show_cpuspeed();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -284,8 +284,8 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
|
||||
cpu_scale_factor = scale;
|
||||
}
|
||||
|
||||
if (video_backendInstance()->video_animation_show_cpuspeed) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed();
|
||||
if (video_backend->video_animation_show_cpuspeed) {
|
||||
video_backend->video_animation_show_cpuspeed();
|
||||
}
|
||||
#warning HACK TODO FIXME ... refactor timing stuff
|
||||
timing_toggle_cpu_speed();
|
||||
@ -313,8 +313,8 @@ void c_keys_handle_input(int scancode, int pressed, int is_cooked)
|
||||
cpu_scale_factor = scale;
|
||||
}
|
||||
|
||||
if (video_backendInstance()->video_animation_show_cpuspeed) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed();
|
||||
if (video_backend->video_animation_show_cpuspeed) {
|
||||
video_backend->video_animation_show_cpuspeed();
|
||||
}
|
||||
#warning HACK TODO FIXME ... refactor timing stuff
|
||||
timing_toggle_cpu_speed();
|
||||
|
@ -31,7 +31,7 @@ color_mode_t color_mode = COLOR;
|
||||
const char *data_dir = NULL;
|
||||
|
||||
__attribute__((constructor))
|
||||
static void _init_common(void) {
|
||||
static void _init_common() {
|
||||
error_log = stderr;
|
||||
#if defined(CONFIG_DATADIR)
|
||||
data_dir = strdup(CONFIG_DATADIR "/" PACKAGE_NAME);
|
||||
@ -599,8 +599,6 @@ void c_initialize_firsttime(void) {
|
||||
#ifdef DEBUGGER
|
||||
c_debugger_init();
|
||||
#endif
|
||||
|
||||
video_loadfonts_interface();
|
||||
}
|
||||
|
||||
#if !TESTING && !defined(__APPLE__) && !defined(ANDROID)
|
||||
|
@ -161,7 +161,8 @@ static bool cpuanim_onTouchEvent(interface_touch_event_t action, int pointer_cou
|
||||
|
||||
__attribute__((constructor))
|
||||
static void _init_glcpuanim(void) {
|
||||
video_backendInstance()->video_animation_show_cpuspeed = &cpuanim_show;
|
||||
LOG("Registering CPU speed animations");
|
||||
video_backend->video_animation_show_cpuspeed = &cpuanim_show;
|
||||
glnode_registerNode(RENDER_MIDDLE, (GLNode){
|
||||
.setup = &cpuanim_init,
|
||||
.shutdown = &cpuanim_shutdown,
|
||||
|
@ -47,6 +47,8 @@ static GLuint texcoordBufferName = UNINITIALIZED_GL;
|
||||
static GLuint elementBufferName = UNINITIALIZED_GL;
|
||||
static GLModel *crtModel = NULL;
|
||||
|
||||
static video_backend_s glvideo_backend = { 0 };
|
||||
|
||||
#if USE_GLUT
|
||||
static int glutWindow = -1;
|
||||
#endif
|
||||
@ -849,19 +851,16 @@ static void gldriver_main_loop(void) {
|
||||
// fall through if not GLUT
|
||||
}
|
||||
|
||||
video_backend_s *video_backendInstance(void) {
|
||||
static video_backend_s *glvideo_backend = NULL;
|
||||
spin_lock_t lock = 0L;
|
||||
spin_lock_lock(&lock);
|
||||
if (glvideo_backend == NULL) {
|
||||
glvideo_backend = malloc(sizeof(video_backend_s));
|
||||
glvideo_backend->init = &gldriver_init;
|
||||
glvideo_backend->main_loop = &gldriver_main_loop;
|
||||
glvideo_backend->reshape = &gldriver_reshape;
|
||||
glvideo_backend->render = &gldriver_render;
|
||||
glvideo_backend->shutdown = &gldriver_shutdown;
|
||||
}
|
||||
spin_lock_unlock(&lock);
|
||||
return glvideo_backend;
|
||||
__attribute__((constructor))
|
||||
static void _init_glvideo(void) {
|
||||
LOG("Initializing OpenGL renderer");
|
||||
|
||||
glvideo_backend.init = &gldriver_init;
|
||||
glvideo_backend.main_loop = &gldriver_main_loop;
|
||||
glvideo_backend.reshape = &gldriver_reshape;
|
||||
glvideo_backend.render = &gldriver_render;
|
||||
glvideo_backend.shutdown = &gldriver_shutdown;
|
||||
|
||||
video_backend = &glvideo_backend;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ typedef struct video_backend_s {
|
||||
/*
|
||||
* The registered video backend (renderer).
|
||||
*/
|
||||
extern video_backend_s *video_backendInstance(void);
|
||||
extern video_backend_s *video_backend;
|
||||
|
||||
/*
|
||||
* Color structure
|
||||
@ -103,11 +103,6 @@ void video_set(int flags);
|
||||
*/
|
||||
void video_loadfont(int first, int qty, const uint8_t *data, int mode);
|
||||
|
||||
/*
|
||||
* Load interface fonts.
|
||||
*/
|
||||
void video_loadfonts_interface(void);
|
||||
|
||||
/*
|
||||
* Redraw the display. This is called after exiting an interface display,
|
||||
* when changes have been made to the Apple's emulated framebuffer that
|
||||
|
@ -60,6 +60,7 @@ static int xshmeventtype;
|
||||
// pad pixels to uint32_t boundaries
|
||||
static int bitmap_pad = sizeof(uint32_t);
|
||||
|
||||
static video_backend_s xvideo_backend = { 0 };
|
||||
static bool request_set_mode = false;
|
||||
static int request_mode = 0;
|
||||
|
||||
@ -937,19 +938,16 @@ static void xdriver_render(void) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
video_backend_s *video_backendInstance(void) {
|
||||
static video_backend_s *xvideo_backend = NULL;
|
||||
spin_lock_t lock = 0L;
|
||||
spin_lock_lock(&lock);
|
||||
if (xvideo_backend == NULL) {
|
||||
xvideo_backend = malloc(sizeof(video_backend_s));
|
||||
xvideo_backend->init = &xdriver_init;
|
||||
xvideo_backend->main_loop = &xdriver_main_loop;
|
||||
xvideo_backend->reshape = &xdriver_reshape;
|
||||
xvideo_backend->render = &xdriver_render;
|
||||
xvideo_backend->shutdown = &xdriver_shutdown;
|
||||
}
|
||||
spin_lock_unlock(&lock);
|
||||
return xvideo_backend;
|
||||
__attribute__((constructor))
|
||||
static void _init_xvideo(void) {
|
||||
LOG("Initializing X11 renderer");
|
||||
|
||||
xvideo_backend.init = &xdriver_init;
|
||||
xvideo_backend.main_loop = &xdriver_main_loop;
|
||||
xvideo_backend.reshape = &xdriver_reshape;
|
||||
xvideo_backend.render = &xdriver_render;
|
||||
xvideo_backend.shutdown = &xdriver_shutdown;
|
||||
|
||||
video_backend = &xvideo_backend;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user