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

Comparing BasiliskII/src/Unix/main_unix.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.8 by cebix, 1999-10-31T23:18:36Z

# Line 27 | Line 27
27  
28   #include "cpu_emulation.h"
29   #include "sys.h"
30 + #include "rom_patches.h"
31   #include "xpram.h"
32   #include "timer.h"
32 #include "sony.h"
33 #include "disk.h"
34 #include "cdrom.h"
35 #include "scsi.h"
36 #include "audio.h"
33   #include "video.h"
38 #include "serial.h"
39 #include "ether.h"
40 #include "clip.h"
41 #include "rom_patches.h"
34   #include "prefs.h"
35   #include "prefs_editor.h"
36   #include "macos_util.h"
# Line 46 | Line 38
38   #include "version.h"
39   #include "main.h"
40  
41 < #define DEBUG 1
41 > #define DEBUG 0
42   #include "debug.h"
43  
44  
# Line 56 | Line 48
48   #include <gtk/gtk.h>
49   #endif
50  
51 < #if ENABLE_DGA
51 > #if ENABLE_XF86_DGA
52   #include <X11/Xlib.h>
53   #include <X11/Xutil.h>
54   #include <X11/extensions/xf86dga.h>
55   #endif
56  
57 + #if ENABLE_MON
58 + #include "mon.h"
59 + #endif
60 +
61  
62   // Constants
63   const char ROM_FILE_NAME[] = "ROM";
# Line 95 | Line 91 | static struct sigaction timer_sa;                                      //
91   static timer_t timer;                                                           // 60Hz timer
92   #endif
93  
94 + #if ENABLE_MON
95 + static struct sigaction sigint_sa;                                      // sigaction for SIGINT handler
96 + static void sigint_handler(...);
97 + #endif
98 +
99  
100   // Prototypes
101   static void *xpram_func(void *arg);
# Line 140 | Line 141 | int main(int argc, char **argv)
141          for (int i=1; i<argc; i++) {
142                  if (strcmp(argv[i], "-display") == 0 && ++i < argc)
143                          x_display_name = argv[i];
144 +                else if (strcmp(argv[i], "-break") == 0 && ++i < argc)
145 +                        ROMBreakpoint = strtol(argv[i], NULL, 0);
146 +                else if (strcmp(argv[i], "-rominfo") == 0)
147 +                        PrintROMInfo = true;
148          }
149  
150          // Open display
# Line 151 | Line 156 | int main(int argc, char **argv)
156                  QuitEmulator();
157          }
158  
159 < #if ENABLE_DGA
159 > #if ENABLE_XF86_DGA && !ENABLE_MON
160          // Fork out, so we can return from fullscreen mode when things get ugly
161 <        XF86DGAForkApp(XDefaultScreen(x_display));
161 >        XF86DGAForkApp(DefaultScreen(x_display));
162   #endif
163  
164   #if ENABLE_GTK
# Line 207 | Line 212 | int main(int argc, char **argv)
212                  QuitEmulator();
213          }
214  
215 <        // Check ROM version
216 <        if (!CheckROM()) {
212 <                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
215 >        // Initialize everything
216 >        if (!InitAll())
217                  QuitEmulator();
214        }
215
216        // Set CPU and FPU type (UAE emulation)
217        switch (ROMVersion) {
218                case ROM_VERSION_64K:
219                case ROM_VERSION_PLUS:
220                case ROM_VERSION_CLASSIC:
221                        CPUType = 0;
222                        FPUType = 0;
223                        TwentyFourBitAddressing = true;
224                        break;
225                case ROM_VERSION_II:
226                        CPUType = 2;
227                        FPUType = PrefsFindBool("fpu") ? 1 : 0;
228                        TwentyFourBitAddressing = true;
229                        break;
230                case ROM_VERSION_32:
231                        CPUType = 3;
232                        FPUType = PrefsFindBool("fpu") ? 1 : 0;
233                        TwentyFourBitAddressing = false;
234                        break;
235        }
236        CPUIs68060 = false;
237
238        // Load XPRAM
239        XPRAMInit();
240
241        // Set boot volume
242        int16 i16 = PrefsFindInt16("bootdrive");
243        XPRAM[0x78] = i16 >> 8;
244        XPRAM[0x79] = i16 & 0xff;
245        i16 = PrefsFindInt16("bootdriver");
246        XPRAM[0x7a] = i16 >> 8;
247        XPRAM[0x7b] = i16 & 0xff;
218  
219          // Start XPRAM watchdog thread
220          xpram_thread_active = (pthread_create(&xpram_thread, NULL, xpram_func, NULL) == 0);
221  
252        // Init drivers
253        SonyInit();
254        DiskInit();
255        CDROMInit();
256        SCSIInit();
257
258        // Init serial ports
259        SerialInit();
260
261        // Init network
262        EtherInit();
263
264        // Init Time Manager
265        TimerInit();
266
267        // Init clipboard
268        ClipInit();
269
270        // Init audio
271        AudioInit();
272
273        // Init video
274        if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC))
275                QuitEmulator();
276
277        // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM())
278        if (!Init680x0())
279                QuitEmulator();
280
281        // Install ROM patches
282        if (!PatchROM()) {
283                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
284                QuitEmulator();
285        }
286
222   #if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS)
223          // Start 60Hz timer
224          sigemptyset(&timer_sa.sa_mask);
# Line 330 | Line 265 | int main(int argc, char **argv)
265          }
266   #endif
267  
268 + #if ENABLE_MON
269 +        // Setup SIGINT handler to enter mon
270 +        sigemptyset(&sigint_sa.sa_mask);
271 +        sigint_sa.sa_flags = 0;
272 +        sigint_sa.sa_handler = sigint_handler;
273 +        sigaction(SIGINT, &sigint_sa, NULL);
274 + #endif
275 +
276          // Start 68k and jump to ROM boot routine
277          Start680x0();
278  
# Line 370 | Line 313 | void QuitEmulator(void)
313                  pthread_join(xpram_thread, NULL);
314          }
315  
316 <        // Save XPRAM
317 <        XPRAMExit();
375 <
376 <        // Exit video
377 <        VideoExit();
378 <
379 <        // Exit audio
380 <        AudioExit();
381 <
382 <        // Exit clipboard
383 <        ClipExit();
384 <
385 <        // Exit Time Manager
386 <        TimerExit();
387 <
388 <        // Exit serial ports
389 <        SerialExit();
390 <
391 <        // Exit network
392 <        EtherExit();
393 <
394 <        // Exit drivers
395 <        SCSIExit();
396 <        CDROMExit();
397 <        DiskExit();
398 <        SonyExit();
316 >        // Deinitialize everything
317 >        ExitAll();
318  
319          // Delete ROM area
320          delete[] ROMBaseHost;
# Line 428 | Line 347 | void FlushCodeCache(void *start, uint32
347   }
348   #endif
349  
350 +
351 + /*
352 + *  SIGINT handler, enters mon
353 + */
354 +
355 + #if ENABLE_MON
356 + extern void m68k_dumpstate(uaecptr *nextpc);
357 + static void sigint_handler(...)
358 + {
359 +        uaecptr nextpc;
360 +        m68k_dumpstate(&nextpc);
361 +        char *arg[2] = {"rmon", NULL};
362 +        mon(1, arg);
363 +        QuitEmulator();
364 + }
365 + #endif
366 +
367  
368   /*
369   *  Interrupt flags (must be handled atomically!)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines