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

Comparing BasiliskII/src/AmigaOS/main_amiga.cpp (file contents):
Revision 1.3 by cebix, 1999-10-19T19:28:15Z vs.
Revision 1.10 by cebix, 2000-09-04T16:30:47Z

# Line 1 | Line 1
1   /*
2   *  main_amiga.cpp - Startup code for AmigaOS
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2000 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 56 | Line 56
56   #include "debug.h"
57  
58  
59 < // Our minimum stack requirement
60 < unsigned long __stack = 0x4000;
59 > // Options for libnix
60 > unsigned long __stack = 0x4000;         // Stack requirement
61 > int __nocommandline = 1;                        // Disable command line parsing
62  
63  
64   // Constants
# Line 90 | Line 91 | struct Library *GadToolsBase = NULL;
91   struct Library *IFFParseBase = NULL;
92   struct Library *AslBase = NULL;
93   struct Library *P96Base = NULL;
94 + struct Library *CyberGfxBase = NULL;
95   struct Library *TimerBase = NULL;
96   struct Library *AHIBase = NULL;
97   struct Library *DiskBase = NULL;
# Line 179 | Line 181 | int main(void)
181                  ErrorAlert(GetString(STR_NO_ASL_LIB_ERR));
182                  QuitEmulator();
183          }
184 +
185 +        // These two can fail (the respective gfx support won't be available, then)
186          P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2);
187 +        CyberGfxBase = OpenLibrary((UBYTE *)"cybergraphics.library", 2);
188  
189          // Read preferences
190          PrefsInit();
# Line 237 | Line 242 | int main(void)
242                  WarningAlert(GetString(STR_SMALL_RAM_WARN));
243                  RAMSize = 1024*1024;
244          }
245 <        RAMBaseHost = (uint8 *)AllocMem(RAMSize + 0x100000, MEMF_PUBLIC);
245 >        RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC);
246          if (RAMBaseHost == NULL) {
247 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
248 <                QuitEmulator();
247 >                uint32 newRAMSize = AvailMem(MEMF_LARGEST) - 0x100000;
248 >                char xText[120];
249 >
250 >                sprintf(xText, GetString(STR_NOT_ENOUGH_MEM_WARN), RAMSize, newRAMSize);
251 >
252 >                if (ChoiceAlert(xText, "Use", "Quit") != 1)
253 >                        QuitEmulator();
254 >
255 >                RAMSize = newRAMSize;
256 >                RAMBaseHost = (uint8 *)AllocVec(RAMSize + 0x100000, MEMF_PUBLIC);
257 >                if (RAMBaseHost == NULL) {
258 >                        ErrorAlert(GetString(STR_NO_MEM_ERR));
259 >                        QuitEmulator();
260 >                }
261          }
262          RAMBaseMac = (uint32)RAMBaseHost;
263          D(bug("Mac RAM starts at %08lx\n", RAMBaseHost));
# Line 308 | Line 325 | int main(void)
325          // Set task priority to -1 so we don't use all processing time
326          SetTaskPri(MainTask, -1);
327  
328 +        WriteMacInt32(0xbff, 0);        // MacsBugFlags
329 +
330          // Swap stack to Mac RAM area
331          stack_swap.stk_Lower = RAMBaseHost;
332          stack_swap.stk_Upper = (ULONG)RAMBaseHost + RAMSize;
# Line 342 | Line 361 | void __saveds quit_emulator(void)
361  
362   void QuitEmulator(void)
363   {
364 +        // Stop 60Hz thread
365 +        if (tick_proc) {
366 +                SetSignal(0, SIGF_SINGLE);
367 +                tick_proc_active = false;
368 +                Wait(SIGF_SINGLE);
369 +        }
370 +
371          // Restore stack
372          if (stack_swapped) {
373                  stack_swapped = false;
# Line 355 | Line 381 | void QuitEmulator(void)
381                  FreeSignal(IRQSig);
382          }
383  
358        // Stop 60Hz thread
359        if (tick_proc) {
360                SetSignal(0, SIGF_SINGLE);
361                tick_proc_active = false;
362                Wait(SIGF_SINGLE);
363        }
364
384          // Remove trap handler
385          MainTask->tc_TrapCode = OldTrapHandler;
386  
# Line 370 | Line 389 | void QuitEmulator(void)
389  
390          // Delete RAM/ROM area
391          if (RAMBaseHost)
392 <                FreeMem(RAMBaseHost, RAMSize + 0x100000);
392 >                FreeVec(RAMBaseHost);
393  
394          // Delete scratch memory area
395          if (ScratchMem)
# Line 397 | Line 416 | void QuitEmulator(void)
416          PrefsExit();
417  
418          // Close libraries
419 +        if (CyberGfxBase)
420 +                CloseLibrary(CyberGfxBase);
421          if (P96Base)
422                  CloseLibrary(P96Base);
423          if (AslBase)
# Line 446 | Line 467 | void TriggerInterrupt(void)
467          Signal(MainTask, IRQSigMask);
468   }
469  
470 + void TriggerNMI(void)
471 + {
472 +        AsmTriggerNMI();
473 + }
474 +
475  
476   /*
477   *  60Hz thread
# Line 488 | Line 514 | static __saveds void tick_func(void)
514                  if (++tick_counter > 60) {
515                          tick_counter = 0;
516                          WriteMacInt32(0x20c, TimerDateTime());
517 +                        SetInterruptFlag(INTFLAG_1HZ);
518 +                        TriggerInterrupt();
519                  }
520  
521                  // Trigger 60Hz interrupt
# Line 601 | Line 629 | void __saveds IllInstrHandler(trap_regs
629                  EmulatedSR |= 0x0700;
630  
631                  // Call opcode routine
632 <                EmulOp(*(uint16 *)(r->pc), (M68kRegisters *)r);
632 >                EmulOp(opcode, (M68kRegisters *)r);
633                  r->pc += 2;
634  
635                  // Restore interrupts

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines