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

Comparing BasiliskII/src/macos_util.cpp (file contents):
Revision 1.4 by cebix, 2000-04-10T18:52:24Z vs.
Revision 1.9 by cebix, 2002-01-15T14:58:32Z

# Line 1 | Line 1
1   /*
2   *  macos_util.cpp - MacOS definitions/utility functions
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2002 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 20 | Line 20
20  
21   #include "sysdeps.h"
22   #include "cpu_emulation.h"
23 + #include "adb.h"
24   #include "main.h"
25   #include "sony.h"
26   #include "disk.h"
# Line 86 | Line 87 | void MountVolume(void *fh)
87  
88  
89   /*
89 *  Test if basic MacOS initializations (of the ROM) are done
90 */
91
92 bool HasMacStarted(void)
93 {
94        return ReadMacInt32(0xcfc) == 'WLSC';   // Mac warm start flag
95 }
96
97
98 /*
90   *  Calculate disk image file layout given file size and first 256 data bytes
91   */
92  
# Line 111 | Line 102 | void FileDiskLayout(loff_t size, uint8 *
102                  real_size = size - start_byte;
103          }
104   }
105 +
106 +
107 + uint32 DebugUtil(uint32 Selector)
108 + {
109 +        switch (Selector) {
110 +                case duDebuggerGetMax:
111 +                        return 3;
112 +                case duDebuggerEnter:
113 +                        return 0;
114 +                case duDebuggerExit:
115 +                        return 0;
116 +                case duDebuggerPoll:
117 +                        ADBInterrupt();
118 +                        return 0;
119 +                default:
120 +                        return (uint32) paramErr;
121 +        }
122 + }
123 +
124 +
125 + /*
126 + *  Convert time_t value to MacOS time (seconds since 1.1.1904)
127 + */
128 +
129 + uint32 TimeToMacTime(time_t t)
130 + {
131 +        // This code is taken from glibc 2.2
132 +
133 +        // Convert to number of seconds elapsed since 1-Jan-1904
134 +        struct tm *local = localtime(&t);
135 +        const int TM_EPOCH_YEAR = 1900;
136 +        const int MAC_EPOCH_YEAR = 1904;
137 +        int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
138 +        int b4 = (MAC_EPOCH_YEAR >> 2) - !(MAC_EPOCH_YEAR & 3);
139 +        int a100 = a4 / 25 - (a4 % 25 < 0);
140 +        int b100 = b4 / 25 - (b4 % 25 < 0);
141 +        int a400 = a100 >> 2;
142 +        int b400 = b100 >> 2;
143 +        int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
144 +        uint32 days = local->tm_yday + 365 * (local->tm_year - 4) + intervening_leap_days;
145 +        return local->tm_sec + 60 * (local->tm_min + 60 * (local->tm_hour + 24 * days));
146 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines