this repo has no description
1/*
2 OSGLUAAA.h
3
4 Copyright (C) 2006 Philip Cummins, Richard F. Bannister,
5 Paul C. Pratt
6
7 You can redistribute this file and/or modify it under the terms
8 of version 2 of the GNU General Public License as published by
9 the Free Software Foundation. You should have received a copy
10 of the license along with this file; see the file COPYING.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 license for more details.
16*/
17
18/*
19 Operating System GLUe AAA
20
21 header file for operating system dependent code (OSGLUxxx).
22 the same header is used for all platforms.
23 (The "AAA" is just to put it alphabetically in front
24 of the OSGLUxxx files.)
25
26 This code is descended from Richard F. Bannister's Macintosh
27 port of vMac, by Philip Cummins.
28*/
29
30#ifdef OSGLUAAA_H
31#error "header already included"
32#else
33#define OSGLUAAA_H
34#endif
35
36
37#if WantAbnormalReports
38EXPORTOSGLUPROC WarnMsgAbnormalID(ui4r id);
39#endif
40
41#if NonDiskProtect
42EXPORTOSGLUPROC WarnMsgUnsupportedDisk(void);
43#endif
44
45#if dbglog_HAVE
46EXPORTOSGLUPROC dbglog_writeCStr(char *s);
47EXPORTOSGLUPROC dbglog_writeReturn(void);
48EXPORTOSGLUPROC dbglog_writeHex(uimr x);
49EXPORTOSGLUPROC dbglog_writeNum(uimr x);
50EXPORTOSGLUPROC dbglog_writeMacChar(ui3r x);
51EXPORTOSGLUPROC dbglog_writeln(char *s);
52EXPORTOSGLUPROC dbglog_writelnHex(char *s, uimr x);
53EXPORTOSGLUPROC dbglog_writelnNum(char *s, simr v);
54#endif
55
56#if dbglog_HAVE
57EXPORTOSGLUPROC MacMsgDebugAlert(char *s);
58#endif
59
60EXPORTOSGLUPROC ReserveAllocOneBlock(ui3p *p, uimr n, ui3r align,
61 blnr FillOnes);
62
63EXPORTOSGLUPROC MyMoveBytes(anyp srcPtr, anyp destPtr, si5b byteCount);
64
65
66EXPORTVAR(ui3p, ROM)
67
68/*
69 error codes returned by Mini vMac extensions
70 (passed back to the emulated 68k code).
71*/
72
73#define tMacErr ui4r
74
75#define mnvm_noErr ((tMacErr) 0x0000)
76 /* (ui4b) 0 - No Error */
77#define mnvm_miscErr ((tMacErr) 0xFFFF)
78 /* (ui4b) - 1 - Should probably replace these */
79#define mnvm_controlErr ((tMacErr) 0xFFEF)
80 /* (ui4b) - 17 - I/O System Errors */
81#define mnvm_statusErr ((tMacErr) 0xFFEE)
82 /* (ui4b) - 18 - Driver can't respond to Status call */
83#define mnvm_closErr ((tMacErr) 0xFFE8)
84 /* (ui4b) - 24 - I/O System Errors */
85#define mnvm_eofErr ((tMacErr) 0xFFD9)
86 /* (ui4b) - 39 - End of file */
87#define mnvm_tmfoErr ((tMacErr) 0xFFD6)
88 /* (ui4b) - 42 - too many files open */
89#define mnvm_fnfErr ((tMacErr) 0xFFD5)
90 /* (ui4b) - 43 - File not found */
91#define mnvm_wPrErr ((tMacErr) 0xFFD4)
92 /* (ui4b) - 44 - diskette is write protected */
93#define mnvm_vLckdErr ((tMacErr) 0xFFD2)
94 /* (ui4b) - 46 - volume is locked */
95#define mnvm_dupFNErr ((tMacErr) 0xFFD0)
96 /* (ui4b) - 48 - duplicate filename */
97#define mnvm_opWrErr ((tMacErr) 0xFFCF)
98 /* (ui4b) - 49 - file already open with with write permission */
99#define mnvm_paramErr ((tMacErr) 0xFFCE)
100 /* (ui4b) - 50 - error in parameter list */
101#define mnvm_permErr ((tMacErr) 0xFFCA)
102 /* (ui4b) - 54 - permissions error (on file open) */
103#define mnvm_nsDrvErr ((tMacErr) 0xFFC8)
104 /* (ui4b) - 56 - No Such Drive */
105#define mnvm_wrPermErr ((tMacErr) 0xFFC3)
106 /* (ui4b) - 61 - write permissions error */
107#define mnvm_offLinErr ((tMacErr) 0xFFBF)
108 /* (ui4b) - 65 - off-line drive */
109#define mnvm_dirNFErr ((tMacErr) 0xFF88)
110 /* (ui4b) - 120 - directory not found */
111#define mnvm_afpAccessDenied ((tMacErr) 0xEC78)
112 /* (ui4b) - 5000 - Insufficient access privileges for operation */
113
114#if IncludePbufs
115
116#define tPbuf ui4r
117
118#define NotAPbuf ((tPbuf)0xFFFF)
119
120EXPORTOSGLUFUNC tMacErr CheckPbuf(tPbuf Pbuf_No);
121EXPORTOSGLUFUNC tMacErr PbufGetSize(tPbuf Pbuf_No, ui5r *Count);
122
123EXPORTOSGLUFUNC tMacErr PbufNew(ui5b count, tPbuf *r);
124EXPORTOSGLUPROC PbufDispose(tPbuf i);
125EXPORTOSGLUPROC PbufTransfer(ui3p Buffer,
126 tPbuf i, ui5r offset, ui5r count, blnr IsWrite);
127
128#endif
129
130#define tDrive ui4r
131
132EXPORTVAR(ui5b, vSonyWritableMask)
133EXPORTVAR(ui5b, vSonyInsertedMask)
134
135#define vSonyIsInserted(Drive_No) \
136 ((vSonyInsertedMask & ((ui5b)1 << (Drive_No))) != 0)
137
138EXPORTOSGLUFUNC tMacErr vSonyTransfer(blnr IsWrite, ui3p Buffer,
139 tDrive Drive_No, ui5r Sony_Start, ui5r Sony_Count,
140 ui5r *Sony_ActCount);
141EXPORTOSGLUFUNC tMacErr vSonyEject(tDrive Drive_No);
142EXPORTOSGLUFUNC tMacErr vSonyGetSize(tDrive Drive_No, ui5r *Sony_Count);
143
144EXPORTOSGLUFUNC blnr AnyDiskInserted(void);
145EXPORTOSGLUPROC DiskRevokeWritable(tDrive Drive_No);
146
147#if IncludeSonyRawMode
148EXPORTVAR(blnr, vSonyRawMode)
149#endif
150
151#if IncludeSonyNew
152EXPORTVAR(blnr, vSonyNewDiskWanted)
153EXPORTVAR(ui5b, vSonyNewDiskSize)
154EXPORTOSGLUFUNC tMacErr vSonyEjectDelete(tDrive Drive_No);
155#endif
156
157#if IncludeSonyNameNew
158EXPORTVAR(tPbuf, vSonyNewDiskName)
159#endif
160
161#if IncludeSonyGetName
162EXPORTOSGLUFUNC tMacErr vSonyGetName(tDrive Drive_No, tPbuf *r);
163#endif
164
165#if IncludeHostTextClipExchange
166EXPORTOSGLUFUNC tMacErr HTCEexport(tPbuf i);
167EXPORTOSGLUFUNC tMacErr HTCEimport(tPbuf *r);
168#endif
169
170EXPORTVAR(ui5b, OnTrueTime)
171
172EXPORTVAR(ui5b, CurMacDateInSeconds)
173#if AutoLocation
174EXPORTVAR(ui5b, CurMacLatitude)
175EXPORTVAR(ui5b, CurMacLongitude)
176#endif
177#if AutoTimeZone
178EXPORTVAR(ui5b, CurMacDelta)
179 /* (dlsDelta << 24) | (gmtDelta & 0x00FFFFFF) */
180#endif
181
182
183#define vMacScreenNumPixels \
184 ((long)vMacScreenHeight * (long)vMacScreenWidth)
185#define vMacScreenNumBits (vMacScreenNumPixels << vMacScreenDepth)
186#define vMacScreenNumBytes (vMacScreenNumBits / 8)
187#define vMacScreenBitWidth ((long)vMacScreenWidth << vMacScreenDepth)
188#define vMacScreenByteWidth (vMacScreenBitWidth / 8)
189
190#define vMacScreenMonoNumBytes (vMacScreenNumPixels / 8)
191#define vMacScreenMonoByteWidth ((long)vMacScreenWidth / 8)
192
193#if 0 != vMacScreenDepth
194EXPORTVAR(blnr, UseColorMode)
195EXPORTVAR(blnr, ColorModeWorks)
196#endif
197
198#if 0 != vMacScreenDepth
199EXPORTVAR(blnr, ColorMappingChanged)
200#endif
201
202#if (0 != vMacScreenDepth) && (vMacScreenDepth < 4)
203#define CLUT_size (1 << (1 << vMacScreenDepth))
204
205EXPORTVAR(ui4r, CLUT_reds[CLUT_size])
206EXPORTVAR(ui4r, CLUT_greens[CLUT_size])
207EXPORTVAR(ui4r, CLUT_blues[CLUT_size])
208#endif
209
210EXPORTVAR(blnr, EmVideoDisable)
211EXPORTVAR(si3b, EmLagTime)
212
213EXPORTOSGLUPROC Screen_OutputFrame(ui3p screencurrentbuff);
214EXPORTOSGLUPROC DoneWithDrawingForTick(void);
215
216EXPORTVAR(blnr, ForceMacOff)
217
218EXPORTVAR(blnr, WantMacInterrupt)
219
220EXPORTVAR(blnr, WantMacReset)
221
222EXPORTOSGLUFUNC blnr ExtraTimeNotOver(void);
223
224EXPORTVAR(ui3b, SpeedValue)
225
226#if EnableAutoSlow
227EXPORTVAR(blnr, WantNotAutoSlow)
228#endif
229
230/* where emulated machine thinks mouse is */
231EXPORTVAR(ui4b, CurMouseV)
232EXPORTVAR(ui4b, CurMouseH)
233
234#if EnableAutoSlow
235EXPORTVAR(ui5r, QuietTime)
236EXPORTVAR(ui5r, QuietSubTicks)
237
238#define QuietEnds() \
239{ \
240 QuietTime = 0; \
241 QuietSubTicks = 0; \
242}
243#else
244#define QuietEnds()
245#endif
246
247#if 3 == kLn2SoundSampSz
248#define trSoundSamp ui3r
249#define tbSoundSamp ui3b
250#define tpSoundSamp ui3p
251#define kCenterSound 0x80
252#elif 4 == kLn2SoundSampSz
253#define trSoundSamp ui4r
254#define tbSoundSamp ui4b
255#define tpSoundSamp ui4p
256#define kCenterSound 0x8000
257#else
258#error "unsupported kLn2SoundSampSz"
259#endif
260
261#if MySoundEnabled
262
263EXPORTOSGLUFUNC tpSoundSamp MySound_BeginWrite(ui4r n, ui4r *actL);
264EXPORTOSGLUPROC MySound_EndWrite(ui4r actL);
265
266/* 370 samples per tick = 22,254.54 per second */
267#endif
268
269#if EmLocalTalk
270
271EXPORTVAR(ui3b, LT_NodeHint)
272
273#if LT_MayHaveEcho
274EXPORTVAR(blnr, CertainlyNotMyPacket)
275#endif
276
277#define LT_TxBfMxSz 1024
278EXPORTVAR(ui3p, LT_TxBuffer)
279EXPORTVAR(ui4r, LT_TxBuffSz)
280
281EXPORTOSGLUPROC LT_TransmitPacket(void);
282
283EXPORTVAR(ui3p, LT_RxBuffer)
284EXPORTVAR(ui5r, LT_RxBuffSz)
285
286EXPORTOSGLUPROC LT_ReceivePacket(void);
287
288#endif
289
290EXPORTOSGLUPROC WaitForNextTick(void);
291
292#define MyEvtQElKindKey 0
293#define MyEvtQElKindMouseButton 1
294#define MyEvtQElKindMousePos 2
295#define MyEvtQElKindMouseDelta 3
296
297struct MyEvtQEl {
298 /* expected size : 8 bytes */
299 ui3b kind;
300 ui3b pad[3];
301 union {
302 struct {
303 ui3b down;
304 ui3b key;
305 } press;
306 struct {
307 ui4b h;
308 ui4b v;
309 } pos;
310 } u;
311};
312typedef struct MyEvtQEl MyEvtQEl;
313
314EXPORTOSGLUFUNC MyEvtQEl * MyEvtQOutP(void);
315EXPORTOSGLUPROC MyEvtQOutDone(void);
316
317#define MKC_A 0x00
318#define MKC_B 0x0B
319#define MKC_C 0x08
320#define MKC_D 0x02
321#define MKC_E 0x0E
322#define MKC_F 0x03
323#define MKC_G 0x05
324#define MKC_H 0x04
325#define MKC_I 0x22
326#define MKC_J 0x26
327#define MKC_K 0x28
328#define MKC_L 0x25
329#define MKC_M 0x2E
330#define MKC_N 0x2D
331#define MKC_O 0x1F
332#define MKC_P 0x23
333#define MKC_Q 0x0C
334#define MKC_R 0x0F
335#define MKC_S 0x01
336#define MKC_T 0x11
337#define MKC_U 0x20
338#define MKC_V 0x09
339#define MKC_W 0x0D
340#define MKC_X 0x07
341#define MKC_Y 0x10
342#define MKC_Z 0x06
343
344#define MKC_1 0x12
345#define MKC_2 0x13
346#define MKC_3 0x14
347#define MKC_4 0x15
348#define MKC_5 0x17
349#define MKC_6 0x16
350#define MKC_7 0x1A
351#define MKC_8 0x1C
352#define MKC_9 0x19
353#define MKC_0 0x1D
354
355#define MKC_Command 0x37
356#define MKC_Shift 0x38
357#define MKC_CapsLock 0x39
358#define MKC_Option 0x3A
359
360#define MKC_Space 0x31
361#define MKC_Return 0x24
362#define MKC_BackSpace 0x33
363#define MKC_Tab 0x30
364
365#define MKC_Left /* 0x46 */ 0x7B
366#define MKC_Right /* 0x42 */ 0x7C
367#define MKC_Down /* 0x48 */ 0x7D
368#define MKC_Up /* 0x4D */ 0x7E
369
370#define MKC_Minus 0x1B
371#define MKC_Equal 0x18
372#define MKC_BackSlash 0x2A
373#define MKC_Comma 0x2B
374#define MKC_Period 0x2F
375#define MKC_Slash 0x2C
376#define MKC_SemiColon 0x29
377#define MKC_SingleQuote 0x27
378#define MKC_LeftBracket 0x21
379#define MKC_RightBracket 0x1E
380#define MKC_Grave 0x32
381#define MKC_Clear 0x47
382#define MKC_KPEqual 0x51
383#define MKC_KPDevide 0x4B
384#define MKC_KPMultiply 0x43
385#define MKC_KPSubtract 0x4E
386#define MKC_KPAdd 0x45
387#define MKC_Enter 0x4C
388
389#define MKC_KP1 0x53
390#define MKC_KP2 0x54
391#define MKC_KP3 0x55
392#define MKC_KP4 0x56
393#define MKC_KP5 0x57
394#define MKC_KP6 0x58
395#define MKC_KP7 0x59
396#define MKC_KP8 0x5B
397#define MKC_KP9 0x5C
398#define MKC_KP0 0x52
399#define MKC_Decimal 0x41
400
401/* these aren't on the Mac Plus keyboard */
402
403#define MKC_Control 0x3B
404#define MKC_Escape 0x35
405#define MKC_F1 0x7a
406#define MKC_F2 0x78
407#define MKC_F3 0x63
408#define MKC_F4 0x76
409#define MKC_F5 0x60
410#define MKC_F6 0x61
411#define MKC_F7 0x62
412#define MKC_F8 0x64
413#define MKC_F9 0x65
414#define MKC_F10 0x6d
415#define MKC_F11 0x67
416#define MKC_F12 0x6f
417
418#define MKC_Home 0x73
419#define MKC_End 0x77
420#define MKC_PageUp 0x74
421#define MKC_PageDown 0x79
422#define MKC_Help 0x72 /* = Insert */
423#define MKC_ForwardDel 0x75
424#define MKC_Print 0x69
425#define MKC_ScrollLock 0x6B
426#define MKC_Pause 0x71
427
428#define MKC_AngleBracket 0x0A /* found on german keyboard */
429
430/*
431 Additional codes found in Apple headers
432
433 #define MKC_RightShift 0x3C
434 #define MKC_RightOption 0x3D
435 #define MKC_RightControl 0x3E
436 #define MKC_Function 0x3F
437
438 #define MKC_VolumeUp 0x48
439 #define MKC_VolumeDown 0x49
440 #define MKC_Mute 0x4A
441
442 #define MKC_F16 0x6A
443 #define MKC_F17 0x40
444 #define MKC_F18 0x4F
445 #define MKC_F19 0x50
446 #define MKC_F20 0x5A
447
448 #define MKC_F13 MKC_Print
449 #define MKC_F14 MKC_ScrollLock
450 #define MKC_F15 MKC_Pause
451*/
452
453/* not Apple key codes, only for Mini vMac */
454
455#define MKC_CM 0x80
456#define MKC_real_CapsLock 0x81
457 /*
458 for use in platform specific code
459 when CapsLocks need special handling.
460 */
461#define MKC_None 0xFF