ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/macos_util.cpp
Revision: 1.6
Committed: 2000-08-20T14:08:39Z (24 years, 2 months ago) by jlachmann
Branch: MAIN
Changes since 1.5: +21 -0 lines
Log Message:
added MacsBug Support -jl-

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * macos_util.cpp - MacOS definitions/utility functions
3     *
4 cebix 1.4 * Basilisk II (C) 1997-2000 Christian Bauer
5 cebix 1.1 *
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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "sysdeps.h"
22     #include "cpu_emulation.h"
23 jlachmann 1.6 #include "adb.h"
24 cebix 1.1 #include "main.h"
25     #include "sony.h"
26     #include "disk.h"
27     #include "cdrom.h"
28     #include "macos_util.h"
29    
30     #define DEBUG 0
31     #include "debug.h"
32    
33    
34     /*
35     * Enqueue QElem to list
36     */
37    
38 cebix 1.3 void EnqueueMac(uint32 elem, uint32 list)
39 cebix 1.1 {
40     WriteMacInt32(elem + qLink, 0);
41     if (!ReadMacInt32(list + qTail)) {
42     WriteMacInt32(list + qHead, elem);
43     WriteMacInt32(list + qTail, elem);
44     } else {
45     WriteMacInt32(ReadMacInt32(list + qTail) + qLink, elem);
46     WriteMacInt32(list + qTail, elem);
47     }
48     }
49    
50    
51     /*
52     * Find first free drive number, starting at num
53     */
54    
55     static bool is_drive_number_free(int num)
56     {
57     uint32 e = ReadMacInt32(0x308 + qHead);
58     while (e) {
59     uint32 d = e - dsQLink;
60 cebix 1.2 if ((int)ReadMacInt16(d + dsQDrive) == num)
61 cebix 1.1 return false;
62     e = ReadMacInt32(e + qLink);
63     }
64     return true;
65     }
66    
67     int FindFreeDriveNumber(int num)
68     {
69     while (!is_drive_number_free(num))
70     num++;
71     return num;
72     }
73    
74    
75     /*
76     * Mount volume with given file handle (call this function when you are unable to
77     * do automatic media change detection and the user has to press a special key
78     * or something to mount a volume; this function will check if there's really a
79     * volume in the drive with SysIsDiskInserted(); volumes which are present on startup
80     * are automatically mounted)
81     */
82    
83     void MountVolume(void *fh)
84     {
85     SonyMountVolume(fh) || DiskMountVolume(fh) || CDROMMountVolume(fh);
86     }
87    
88    
89     /*
90     * Calculate disk image file layout given file size and first 256 data bytes
91     */
92    
93     void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size)
94     {
95     if (size == 419284 || size == 838484) {
96     // 400K/800K DiskCopy image, 84 byte header
97     start_byte = 84;
98     real_size = (size - 84) & ~0x1ff;
99     } else {
100     // 0..511 byte header
101     start_byte = size & 0x1ff;
102     real_size = size - start_byte;
103     }
104     }
105 jlachmann 1.6
106    
107     uint32 DebugUtil(uint32 Selector)
108     {
109     switch (Selector)
110     {
111     case duDebuggerGetMax:
112     return 3;
113     case duDebuggerEnter:
114     return 0;
115     case duDebuggerExit:
116     return 0;
117     case duDebuggerPoll:
118     ADBInterrupt();
119     return 0;
120     default:
121     return (uint32) paramErr;
122     }
123     }
124