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.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.3 by cebix, 1999-10-19T19:28:15Z

# Line 56 | Line 56
56   #include "debug.h"
57  
58  
59 + // Our minimum stack requirement
60 + unsigned long __stack = 0x4000;
61 +
62 +
63   // Constants
64   static const char ROM_FILE_NAME[] = "ROM";
65 < static const char __ver[] = "$VER: " VERSION_STRING " " __AMIGADATE__;
65 > static const char __ver[] = "$VER: " VERSION_STRING " " __DATE__;
66   static const int SCRATCH_MEM_SIZE = 65536;
67  
68  
# Line 80 | Line 84 | bool TwentyFourBitAddressing;
84  
85   // Global variables
86   extern ExecBase *SysBase;
87 + struct Library *GfxBase = NULL;
88 + struct IntuitionBase *IntuitionBase = NULL;
89   struct Library *GadToolsBase = NULL;
90 + struct Library *IFFParseBase = NULL;
91   struct Library *AslBase = NULL;
92   struct Library *P96Base = NULL;
93   struct Library *TimerBase = NULL;
# Line 106 | Line 113 | static bool stack_swapped = false;                             //
113   static StackSwapStruct stack_swap;
114  
115  
109 // Prototypes
110 static void jump_to_rom(void);
111 static void tick_func(void);
112
113
116   // Assembly functions
117   struct trap_regs;
118   extern "C" void AtomicAnd(uint32 *p, uint32 val);
# Line 120 | Line 122 | extern "C" void TrapHandlerAsm(void);
122   extern "C" void ExceptionHandlerAsm(void);
123   extern "C" void IllInstrHandler(trap_regs *regs);
124   extern "C" void PrivViolHandler(trap_regs *regs);
125 + extern "C" void quit_emulator(void);
126   uint16 EmulatedSR;                                      // Emulated SR (supervisor bit and interrupt mask)
127  
128  
129 + // Prototypes
130 + static void jump_to_rom(void);
131 + static void tick_func(void);
132 +
133 +
134   /*
135   *  Main program
136   */
# Line 141 | Line 149 | int main(void)
149          printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
150          printf(" %s\n", GetString(STR_ABOUT_TEXT2));
151  
144        // Read preferences
145        PrefsInit();
146
152          // Open libraries
153 +        GfxBase = OpenLibrary((UBYTE *)"graphics.library", 39);
154 +        if (GfxBase == NULL) {
155 +                printf("Cannot open graphics.library V39.\n");
156 +                exit(1);
157 +        }
158 +        IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library", 39);
159 +        if (IntuitionBase == NULL) {
160 +                printf("Cannot open intuition.library V39.\n");
161 +                CloseLibrary(GfxBase);
162 +                exit(1);
163 +        }
164          DiskBase = (struct Library *)OpenResource((UBYTE *)"disk.resource");
165          if (DiskBase == NULL)
166                  QuitEmulator();
# Line 153 | Line 169 | int main(void)
169                  ErrorAlert(GetString(STR_NO_GADTOOLS_LIB_ERR));
170                  QuitEmulator();
171          }
172 +        IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library", 39);
173 +        if (IFFParseBase == NULL) {
174 +                ErrorAlert(GetString(STR_NO_IFFPARSE_LIB_ERR));
175 +                QuitEmulator();
176 +        }
177          AslBase = OpenLibrary((UBYTE *)"asl.library", 36);
178          if (AslBase == NULL) {
179                  ErrorAlert(GetString(STR_NO_ASL_LIB_ERR));
# Line 160 | Line 181 | int main(void)
181          }
182          P96Base = OpenLibrary((UBYTE *)"Picasso96API.library", 2);
183  
184 +        // Read preferences
185 +        PrefsInit();
186 +
187          // Open AHI
188          ahi_port = CreateMsgPort();
189          if (ahi_port) {
# Line 228 | Line 252 | int main(void)
252          const char *rom_path = PrefsFindString("rom");
253  
254          // Load Mac ROM
255 <        BPTR rom_fh = Open(rom_path ? (char *)rom_path : ROM_FILE_NAME, MODE_OLDFILE);
255 >        BPTR rom_fh = Open(rom_path ? (char *)rom_path : (char *)ROM_FILE_NAME, MODE_OLDFILE);
256          if (rom_fh == NULL) {
257                  ErrorAlert(GetString(STR_NO_ROM_FILE_ERR));
258                  QuitEmulator();
# Line 248 | Line 272 | int main(void)
272                  QuitEmulator();
273          }
274  
251        // Check ROM version
252        if (!CheckROM()) {
253                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
254                QuitEmulator();
255        }
256
275          // Set CPU and FPU type
276          UWORD attn = SysBase->AttnFlags;
277          CPUType = attn & AFF_68040 ? 4 : (attn & AFF_68030 ? 3 : 2);
278          CPUIs68060 = attn & AFF_68060;
279          FPUType = attn & AFF_68881 ? 1 : 0;
280  
281 <        // Load XPRAM
282 <        XPRAMInit();
265 <
266 <        // Set boot volume
267 <        int16 i16 = PrefsFindInt16("bootdrive");
268 <        XPRAM[0x78] = i16 >> 8;
269 <        XPRAM[0x79] = i16 & 0xff;
270 <        i16 = PrefsFindInt16("bootdriver");
271 <        XPRAM[0x7a] = i16 >> 8;
272 <        XPRAM[0x7b] = i16 & 0xff;
273 <
274 <        // Init drivers
275 <        SonyInit();
276 <        DiskInit();
277 <        CDROMInit();
278 <        SCSIInit();
279 <
280 <        // Init network
281 <        EtherInit();
282 <
283 <        // Init serial ports
284 <        SerialInit();
285 <
286 <        // Init Time Manager
287 <        TimerInit();
288 <
289 <        // Init clipboard
290 <        ClipInit();
291 <
292 <        // Init audio
293 <        AudioInit();
294 <
295 <        // Init video
296 <        if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC))
281 >        // Initialize everything
282 >        if (!InitAll())
283                  QuitEmulator();
284  
299        // Install ROM patches
300        if (!PatchROM()) {
301                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
302                QuitEmulator();
303        }
304
285          // Move VBR away from 0 if neccessary
286          MoveVBR();
287  
# Line 319 | Line 299 | int main(void)
299  
300          // Start 60Hz process
301          tick_proc = CreateNewProcTags(
302 <                NP_Entry, tick_func,
303 <                NP_Name, "Basilisk II 60Hz",
302 >                NP_Entry, (ULONG)tick_func,
303 >                NP_Name, (ULONG)"Basilisk II 60Hz",
304                  NP_Priority, 5,
305                  TAG_END
306          );
# Line 354 | Line 334 | void Start680x0(void)
334   *  Quit emulator (__saveds because it might be called from an exception)
335   */
336  
337 < void __saveds QuitEmulator(void)
337 > // Assembly entry point
338 > void __saveds quit_emulator(void)
339 > {
340 >        QuitEmulator();
341 > }
342 >
343 > void QuitEmulator(void)
344   {
345          // Restore stack
346          if (stack_swapped) {
# Line 379 | Line 365 | void __saveds QuitEmulator(void)
365          // Remove trap handler
366          MainTask->tc_TrapCode = OldTrapHandler;
367  
368 <        // Save XPRAM
369 <        XPRAMExit();
384 <
385 <        // Exit video
386 <        VideoExit();
387 <
388 <        // Exit audio
389 <        AudioExit();
390 <
391 <        // Exit clipboard
392 <        ClipExit();
393 <
394 <        // Exit Time Manager
395 <        TimerExit();
396 <
397 <        // Exit serial ports
398 <        SerialExit();
399 <
400 <        // Exit network
401 <        EtherExit();
402 <
403 <        // Exit drivers
404 <        SCSIExit();
405 <        CDROMExit();
406 <        DiskExit();
407 <        SonyExit();
368 >        // Deinitialize everything
369 >        ExitAll();
370  
371          // Delete RAM/ROM area
372          if (RAMBaseHost)
# Line 439 | Line 401 | void __saveds QuitEmulator(void)
401                  CloseLibrary(P96Base);
402          if (AslBase)
403                  CloseLibrary(AslBase);
404 +        if (IFFParseBase)
405 +                CloseLibrary(IFFParseBase);
406          if (GadToolsBase)
407                  CloseLibrary(GadToolsBase);
408 +        if (IntuitionBase)
409 +                CloseLibrary((struct Library *)IntuitionBase);
410 +        if (GfxBase)
411 +                CloseLibrary(GfxBase);
412  
413          exit(0);
414   }
# Line 560 | Line 528 | void ErrorAlert(const char *text)
528          req.es_Title = (UBYTE *)GetString(STR_ERROR_ALERT_TITLE);
529          req.es_TextFormat = (UBYTE *)GetString(STR_GUI_ERROR_PREFIX);
530          req.es_GadgetFormat = (UBYTE *)GetString(STR_QUIT_BUTTON);
531 <        EasyRequest(NULL, &req, NULL, text);
531 >        EasyRequest(NULL, &req, NULL, (ULONG)text);
532   }
533  
534  
# Line 580 | Line 548 | void WarningAlert(const char *text)
548          req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE);
549          req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX);
550          req.es_GadgetFormat = (UBYTE *)GetString(STR_OK_BUTTON);
551 <        EasyRequest(NULL, &req, NULL, text);
551 >        EasyRequest(NULL, &req, NULL, (ULONG)text);
552   }
553  
554  
# Line 598 | Line 566 | bool ChoiceAlert(const char *text, const
566          req.es_Title = (UBYTE *)GetString(STR_WARNING_ALERT_TITLE);
567          req.es_TextFormat = (UBYTE *)GetString(STR_GUI_WARNING_PREFIX);
568          req.es_GadgetFormat = (UBYTE *)str;
569 <        return EasyRequest(NULL, &req, NULL, text);
569 >        return EasyRequest(NULL, &req, NULL, (ULONG)text);
570   }
571  
572  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines