ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/main_windows.cpp
(Generate patch)

Comparing BasiliskII/src/Windows/main_windows.cpp (file contents):
Revision 1.4 by gbeauche, 2004-12-05T16:54:14Z vs.
Revision 1.13 by gbeauche, 2008-01-01T09:40:33Z

# Line 1 | Line 1
1   /*
2   *  main_windows.cpp - Startup code for Windows
3   *
4 < *  Basilisk II (C) 1997-2004 Christian Bauer
4 > *  Basilisk II (C) 1997-2008 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 48 | Line 48 | using std::string;
48   #include "main.h"
49   #include "vm_alloc.h"
50   #include "sigsegv.h"
51 + #include "util_windows.h"
52   #include "kernel_windows.h"
53  
54   #if USE_JIT
55 < extern void flush_icache_range(uint32 start, uint32 size); // from compemu_support.cpp
55 > extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp
56   #endif
57  
58   #ifdef ENABLE_MON
# Line 72 | Line 73 | int CPUType;
73   bool CPUIs68060;
74   int FPUType;
75   bool TwentyFourBitAddressing;
75 bool ThirtyThreeBitAddressing = false;
76  
77  
78   // Global variables
79 < static uint8 last_xpram[XPRAM_SIZE];                            // Buffer for monitoring XPRAM changes
79 > HANDLE emul_thread = NULL;                                                      // Handle of MacOS emulation thread (main thread)
80  
81 + static uint8 last_xpram[XPRAM_SIZE];                            // Buffer for monitoring XPRAM changes
82   static bool xpram_thread_active = false;                        // Flag: XPRAM watchdog installed
83   static volatile bool xpram_thread_cancel = false;       // Flag: Cancel XPRAM thread
84   static SDL_Thread *xpram_thread = NULL;                         // XPRAM watchdog
# Line 132 | Line 133 | char *strdup(const char *s)
133  
134   void *vm_acquire_mac(size_t size)
135   {
136 <        void *m = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_33BIT);
136 <        if (m == NULL) {
137 <                ThirtyThreeBitAddressing = false;
138 <                m = vm_acquire(size);
139 <        }
140 <        return m;
136 >        return vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT);
137   }
138  
139  
# Line 145 | Line 141 | void *vm_acquire_mac(size_t size)
141   *  SIGSEGV handler
142   */
143  
144 < static sigsegv_return_t sigsegv_handler(sigsegv_address_t fault_address, sigsegv_address_t fault_instruction)
144 > static sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip)
145   {
146 +        const uintptr fault_address = (uintptr)sigsegv_get_fault_address(sip);
147   #if ENABLE_VOSF
148          // Handle screen fault
149 <        extern bool Screen_fault_handler(sigsegv_address_t, sigsegv_address_t);
150 <        if (Screen_fault_handler(fault_address, fault_instruction))
149 >        extern bool Screen_fault_handler(sigsegv_info_t *sip);
150 >        if (Screen_fault_handler(sip))
151                  return SIGSEGV_RETURN_SUCCESS;
152   #endif
153  
# Line 171 | Line 168 | static sigsegv_return_t sigsegv_handler(
168   *  Dump state when everything went wrong after a SEGV
169   */
170  
171 < static void sigsegv_dump_state(sigsegv_address_t fault_address, sigsegv_address_t fault_instruction)
171 > static void sigsegv_dump_state(sigsegv_info_t *sip)
172   {
173 +        const sigsegv_address_t fault_address = sigsegv_get_fault_address(sip);
174 +        const sigsegv_address_t fault_instruction = sigsegv_get_fault_instruction_address(sip);
175          fprintf(stderr, "Caught SIGSEGV at address %p", fault_address);
176 <        if (fault_instruction != SIGSEGV_INVALID_PC)
176 >        if (fault_instruction != SIGSEGV_INVALID_ADDRESS)
177                  fprintf(stderr, " [IP=%p]", fault_instruction);
178          fprintf(stderr, "\n");
179          uaecptr nextpc;
# Line 297 | Line 296 | int main(int argc, char **argv)
296                  QuitEmulator();
297          }
298  
299 +        // Check that drivers are installed
300 +        if (!check_drivers())
301 +                QuitEmulator();
302 +
303          // Load win32 libraries
304          KernelInit();
305  
306 +        // FIXME: default to DIB driver
307 +        if (getenv("SDL_VIDEODRIVER") == NULL)
308 +            putenv("SDL_VIDEODRIVER=windib");
309 +
310          // Initialize SDL system
311          int sdl_flags = 0;
312   #ifdef USE_SDL_VIDEO
# Line 346 | Line 353 | int main(int argc, char **argv)
353          vm_init();
354  
355          // Create areas for Mac RAM and ROM
349 #ifdef USE_33BIT_ADDRESSING
350        // Speculatively enables 33-bit addressing
351        ThirtyThreeBitAddressing = true;
352 #endif
356          RAMBaseHost = (uint8 *)vm_acquire_mac(RAMSize);
357          ROMBaseHost = (uint8 *)vm_acquire_mac(0x100000);
358          if (RAMBaseHost == VM_MAP_FAILED || ROMBaseHost == VM_MAP_FAILED) {
# Line 412 | Line 415 | int main(int argc, char **argv)
415                  QuitEmulator();
416          D(bug("Initialization complete\n"));
417  
418 +        // Get handle of main thread
419 +        emul_thread = GetCurrentThread();
420 +
421          // SDL threads available, start 60Hz thread
422          tick_thread_active = ((tick_thread = SDL_CreateThread(tick_func, NULL)) != NULL);
423          if (!tick_thread_active) {
# Line 504 | Line 510 | void FlushCodeCache(void *start, uint32
510   {
511   #if USE_JIT
512      if (UseJIT)
513 <                flush_icache_range((uintptr)start, size);
513 >                flush_icache_range((uint8 *)start, size);
514   #endif
515   }
516  
# Line 641 | Line 647 | static int tick_func(void *arg)
647  
648   #ifdef USE_SDL_VIDEO
649   #include <SDL_syswm.h>
650 < static HWND GetMainWindowHandle(void)
650 > HWND GetMainWindowHandle(void)
651   {
652          SDL_SysWMinfo wmInfo;
653 <        wmInfo.version.major = SDL_MAJOR_VERSION;
648 <        wmInfo.version.minor = SDL_MINOR_VERSION;
649 <        wmInfo.version.patch = SDL_PATCHLEVEL;
653 >        SDL_VERSION(&wmInfo.version);
654          return SDL_GetWMInfo(&wmInfo) ? wmInfo.window : NULL;
655   }
656   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines