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.13 by cebix, 2001-01-04T19:50:22Z vs.
Revision 1.14 by cebix, 2001-01-25T22:24:36Z

# Line 108 | Line 108 | static struct timerequest *timereq = NUL
108   static struct MsgPort *ahi_port = NULL;                 // Port for AHI
109   static struct AHIRequest *ahi_io = NULL;                // IORequest for AHI
110  
111 + static struct Process *xpram_proc = NULL;               // XPRAM watchdog
112 + static volatile bool xpram_proc_active = true;  // Flag for quitting the XPRAM watchdog
113 +
114   static struct Process *tick_proc = NULL;                // 60Hz process
115   static volatile bool tick_proc_active = true;   // Flag for quitting the 60Hz process
116  
# Line 120 | Line 123 | struct trap_regs;
123   extern "C" void AtomicAnd(uint32 *p, uint32 val);
124   extern "C" void AtomicOr(uint32 *p, uint32 val);
125   extern "C" void MoveVBR(void);
126 + extern "C" void DisableSuperBypass(void);
127   extern "C" void TrapHandlerAsm(void);
128   extern "C" void ExceptionHandlerAsm(void);
129   extern "C" void IllInstrHandler(trap_regs *regs);
# Line 131 | Line 135 | uint16 EmulatedSR;                                     // Emulated SR (s
135  
136   // Prototypes
137   static void jump_to_rom(void);
138 + static void xpram_func(void);
139   static void tick_func(void);
140  
141  
# Line 303 | Line 308 | int main(int argc, char **argv)
308          // Move VBR away from 0 if neccessary
309          MoveVBR();
310  
311 +        // On 68060, disable Super Bypass mode because of a CPU bug that is triggered by MacOS 8
312 +        if (CPUIs68060)
313 +                DisableSuperBypass();
314 +
315          // Install trap handler
316          EmulatedSR = 0x2700;
317          OldTrapHandler = MainTask->tc_TrapCode;
# Line 315 | Line 324 | int main(int argc, char **argv)
324          MainTask->tc_ExceptCode = (APTR)ExceptionHandlerAsm;
325          SetExcept(SIGBREAKF_CTRL_C | IRQSigMask, SIGBREAKF_CTRL_C | IRQSigMask);
326  
327 +        // Start XPRAM watchdog process
328 +        xpram_proc = CreateNewProcTags(
329 +                NP_Entry, (ULONG)xpram_func,
330 +                NP_Name, (ULONG)"Basilisk II XPRAM Watchdog",
331 +                NP_Priority, 0,
332 +                TAG_END
333 +        );
334 +
335          // Start 60Hz process
336          tick_proc = CreateNewProcTags(
337                  NP_Entry, (ULONG)tick_func,
# Line 362 | Line 379 | void __saveds quit_emulator(void)
379  
380   void QuitEmulator(void)
381   {
382 <        // Stop 60Hz thread
382 >        // Stop 60Hz process
383          if (tick_proc) {
384                  SetSignal(0, SIGF_SINGLE);
385                  tick_proc_active = false;
386                  Wait(SIGF_SINGLE);
387          }
388  
389 +        // Stop XPRAM watchdog process
390 +        if (xpram_proc) {
391 +                SetSignal(0, SIGF_SINGLE);
392 +                xpram_proc_active = false;
393 +                Wait(SIGF_SINGLE);
394 +        }
395 +
396          // Restore stack
397          if (stack_swapped) {
398                  stack_swapped = false;
# Line 475 | Line 499 | void TriggerNMI(void)
499  
500  
501   /*
502 < *  60Hz thread
502 > *  60Hz thread (really 60.15Hz)
503   */
504  
505   static __saveds void tick_func(void)
# Line 537 | Line 561 | static __saveds void tick_func(void)
561  
562          // Main task asked for termination, send signal
563          Forbid();
564 +        Signal(MainTask, SIGF_SINGLE);
565 + }
566 +
567 +
568 + /*
569 + *  XPRAM watchdog thread (saves XPRAM every minute)
570 + */
571 +
572 + static __saveds void xpram_func(void)
573 + {
574 +        uint8 last_xpram[256];
575 +        memcpy(last_xpram, XPRAM, 256);
576 +
577 +        while (xpram_proc_active) {
578 +                for (int i=0; i<60 && xpram_proc_active; i++)
579 +                        Delay(50);              // Only wait 1 second so we quit promptly when xpram_proc_active becomes false
580 +                if (memcmp(last_xpram, XPRAM, 256)) {
581 +                        memcpy(last_xpram, XPRAM, 256);
582 +                        SaveXPRAM();
583 +                }
584 +        }
585 +
586 +        // Main task asked for termination, send signal
587 +        Forbid();
588          Signal(MainTask, SIGF_SINGLE);
589   }
590  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines