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

Comparing BasiliskII/src/BeOS/main_beos.cpp (file contents):
Revision 1.1.1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.16 by asvitkine, 2009-09-21T03:33:20Z

# Line 1 | Line 1
1   /*
2   *  main_beos.cpp - Startup code for BeOS
3   *
4 < *  Basilisk II (C) 1997-1999 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 34 | Line 34
34   #include "cpu_emulation.h"
35   #include "xpram.h"
36   #include "timer.h"
37 #include "sony.h"
38 #include "disk.h"
39 #include "cdrom.h"
40 #include "scsi.h"
41 #include "audio.h"
37   #include "video.h"
43 #include "serial.h"
44 #include "ether.h"
45 #include "clip.h"
38   #include "rom_patches.h"
39   #include "prefs.h"
40   #include "prefs_editor.h"
# Line 184 | Line 176 | void BasiliskII::ReadyToRun(void)
176                  delete_area(old_rom_area);
177  
178          // Read preferences
179 <        PrefsInit();
179 >        int argc = 0;
180 >        char **argv = NULL;
181 >        PrefsInit(argc, argv);
182  
183          // Init system routines
184          SysInit();
# Line 222 | Line 216 | void BasiliskII::StartEmulator(void)
216          char str[256];
217  
218   #if REAL_ADDRESSING
219 <        // Open memory mess driver and remap low memory
219 >        // Open sheep driver and remap low memory
220          sheep_fd = open("/dev/sheep", 0);
221          if (sheep_fd < 0) {
222                  sprintf(str, GetString(STR_NO_SHEEP_DRIVER_ERR), strerror(sheep_fd), sheep_fd);
# Line 249 | Line 243 | void BasiliskII::StartEmulator(void)
243          RAMBaseHost = (uint8 *)0x10000000;
244          ram_area = create_area(RAM_AREA_NAME, (void **)&RAMBaseHost, B_BASE_ADDRESS, RAMSize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
245          if (ram_area < 0) {
246 <                ErrorAlert(GetString(STR_NO_RAM_AREA_ERR));
246 >                ErrorAlert(STR_NO_RAM_AREA_ERR);
247                  PostMessage(B_QUIT_REQUESTED);
248                  return;
249          }
# Line 259 | Line 253 | void BasiliskII::StartEmulator(void)
253          try {
254                  init_rom();
255          } catch (area_error) {
256 <                ErrorAlert(GetString(STR_NO_ROM_AREA_ERR));
256 >                ErrorAlert(STR_NO_ROM_AREA_ERR);
257                  PostMessage(B_QUIT_REQUESTED);
258                  return;
259          } catch (file_open_error) {
260 <                ErrorAlert(GetString(STR_NO_ROM_FILE_ERR));
260 >                ErrorAlert(STR_NO_ROM_FILE_ERR);
261                  PostMessage(B_QUIT_REQUESTED);
262                  return;
263          } catch (file_read_error) {
264 <                ErrorAlert(GetString(STR_ROM_FILE_READ_ERR));
264 >                ErrorAlert(STR_ROM_FILE_READ_ERR);
265                  PostMessage(B_QUIT_REQUESTED);
266                  return;
267          } catch (rom_size_error) {
268 <                ErrorAlert(GetString(STR_ROM_SIZE_ERR));
268 >                ErrorAlert(STR_ROM_SIZE_ERR);
269                  PostMessage(B_QUIT_REQUESTED);
270                  return;
271          }
272  
273 <        // Check ROM version
274 <        if (!CheckROM()) {
281 <                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
282 <                PostMessage(B_QUIT_REQUESTED);
283 <                return;
284 <        }
285 <
286 <        // Set CPU and FPU type (UAE emulation)
287 <        switch (ROMVersion) {
288 <                case ROM_VERSION_64K:
289 <                case ROM_VERSION_PLUS:
290 <                case ROM_VERSION_CLASSIC:
291 <                        CPUType = 0;
292 <                        FPUType = 0;
293 <                        TwentyFourBitAddressing = true;
294 <                        break;
295 <                case ROM_VERSION_II:
296 <                        CPUType = 2;
297 <                        FPUType = PrefsFindBool("fpu") ? 1 : 0;
298 <                        TwentyFourBitAddressing = true;
299 <                        break;
300 <                case ROM_VERSION_32:
301 <                        CPUType = 3;
302 <                        FPUType = PrefsFindBool("fpu") ? 1 : 0;
303 <                        TwentyFourBitAddressing = false;
304 <                        break;
305 <        }
306 <        CPUIs68060 = false;
307 <
308 <        // Load XPRAM
309 <        XPRAMInit();
310 <
311 <        // Set boot volume
312 <        int16 i16 = PrefsFindInt16("bootdrive");
313 <        XPRAM[0x78] = i16 >> 8;
314 <        XPRAM[0x79] = i16 & 0xff;
315 <        i16 = PrefsFindInt16("bootdriver");
316 <        XPRAM[0x7a] = i16 >> 8;
317 <        XPRAM[0x7b] = i16 & 0xff;
318 <
319 <        // Start XPRAM watchdog thread
320 <        xpram_thread = spawn_thread(xpram_func, "XPRAM Watchdog", B_LOW_PRIORITY, this);
321 <        resume_thread(xpram_thread);
322 <
323 <        // Init drivers
324 <        SonyInit();
325 <        DiskInit();
326 <        CDROMInit();
327 <        SCSIInit();
328 <
329 <        // Init network
330 <        EtherInit();
331 <
332 <        // Init serial ports
333 <        SerialInit();
334 <
335 <        // Init Time Manager
336 <        TimerInit();
337 <
338 <        // Init clipboard
339 <        ClipInit();
340 <
341 <        // Init audio
342 <        AudioInit();
343 <
344 <        // Init video
345 <        if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC)) {
346 <                PostMessage(B_QUIT_REQUESTED);
347 <                return;
348 <        }
349 <
350 <        // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM())
351 <        if (!Init680x0()) {
352 <                PostMessage(B_QUIT_REQUESTED);
353 <                return;
354 <        }
355 <
356 <        // Install ROM patches
357 <        if (!PatchROM()) {
358 <                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
273 >        // Initialize everything
274 >        if (!InitAll(NULL)) {
275                  PostMessage(B_QUIT_REQUESTED);
276                  return;
277          }
# Line 366 | Line 282 | void BasiliskII::StartEmulator(void)
282          // Disallow quitting with Alt-Q from now on
283          AllowQuitting = false;
284  
285 +        // Start XPRAM watchdog thread
286 +        xpram_thread = spawn_thread(xpram_func, "XPRAM Watchdog", B_LOW_PRIORITY, this);
287 +        resume_thread(xpram_thread);
288 +
289          // Start 60Hz interrupt
290          tick_thread = spawn_thread(tick_func, "60Hz", B_REAL_TIME_PRIORITY, this);
291          resume_thread(tick_thread);
# Line 421 | Line 341 | void BasiliskII::Quit(void)
341                  wait_for_thread(xpram_thread, &l);
342          }
343  
344 <        // Save XPRAM
345 <        XPRAMExit();
426 <
427 <        // Exit video
428 <        VideoExit();
429 <
430 <        // Exit audio
431 <        AudioExit();
432 <
433 <        // Exit clipboard
434 <        ClipExit();
435 <
436 <        // Exit Time Manager
437 <        TimerExit();
438 <
439 <        // Exit serial ports
440 <        SerialExit();
441 <
442 <        // Exit network
443 <        EtherExit();
444 <
445 <        // Exit drivers
446 <        SCSIExit();
447 <        CDROMExit();
448 <        DiskExit();
449 <        SonyExit();
344 >        // Deinitialize everything
345 >        ExitAll();
346  
347          // Delete ROM area
348          if (rom_area >= 0)
# Line 573 | Line 469 | void FlushCodeCache(void *start, uint32
469  
470  
471   /*
472 + *  Mutexes
473 + */
474 +
475 + struct B2_mutex {
476 +        int dummy;      //!!
477 + };
478 +
479 + B2_mutex *B2_create_mutex(void)
480 + {
481 +        return new B2_mutex;
482 + }
483 +
484 + void B2_lock_mutex(B2_mutex *mutex)
485 + {
486 + }
487 +
488 + void B2_unlock_mutex(B2_mutex *mutex)
489 + {
490 + }
491 +
492 + void B2_delete_mutex(B2_mutex *mutex)
493 + {
494 +        delete mutex;
495 + }
496 +
497 +
498 + /*
499   *  Interrupt flags (must be handled atomically!)
500   */
501  
# Line 609 | Line 532 | status_t BasiliskII::tick_func(void *arg
532                  if (++tick_counter > 60) {
533                          tick_counter = 0;
534                          WriteMacInt32(0x20c, TimerDateTime());
535 +                        SetInterruptFlag(INTFLAG_1HZ);
536 +                        TriggerInterrupt();
537                  }
538  
539                  // Trigger 60Hz interrupt
# Line 625 | Line 550 | status_t BasiliskII::tick_func(void *arg
550  
551   status_t BasiliskII::xpram_func(void *arg)
552   {
553 <        uint8 last_xpram[256];
554 <        memcpy(last_xpram, XPRAM, 256);
553 >        uint8 last_xpram[XPRAM_SIZE];
554 >        memcpy(last_xpram, XPRAM, XPRAM_SIZE);
555  
556          while (((BasiliskII *)arg)->xpram_thread_active) {
557                  snooze(60*1000000);
558 <                if (memcmp(last_xpram, XPRAM, 256)) {
559 <                        memcpy(last_xpram, XPRAM, 256);
558 >                if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) {
559 >                        memcpy(last_xpram, XPRAM, XPRAM_SIZE);
560                          SaveXPRAM();
561                  }
562          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines