|
|
1.1 root 1: /*
1.1.1.5 root 2: Hatari - vdi.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6:
7: VDI (Virtual Device Interface) (Trap #2)
8:
1.1.1.5 root 9: To get higher resolutions on the Desktop, we intercept the VDI/Line-A calls
10: and set elements in their structures to the higher width/height/cel/planes.
11: We need to intercept the initial Line-A call (which we force into the TOS on
12: boot-up) and also the init calls to the VDI.
1.1 root 13: */
1.1.1.12 root 14: const char VDI_fileid[] = "Hatari vdi.c : " __DATE__ " " __TIME__;
1.1 root 15:
16: #include "main.h"
17: #include "file.h"
18: #include "gemdos.h"
19: #include "m68000.h"
20: #include "screen.h"
21: #include "stMemory.h"
22: #include "vdi.h"
23: #include "video.h"
1.1.1.9 root 24: #include "configuration.h"
1.1 root 25:
26:
1.1.1.7 root 27: Uint32 VDI_OldPC; /* When call Trap#2, store off PC */
1.1.1.2 root 28:
1.1.1.12 root 29: bool bUseVDIRes = false; /* Set to true (if want VDI), or false (ie for games) */
1.1.1.9 root 30: /* defaults */
31: int VDIRes = 0; /* 0,1 or 2 (low, medium, high) */
32: int VDIWidth = 640; /* 640x480, 800x600 or 1024x768 */
33: int VDIHeight = 480;
34: int VDIPlanes = 4;
35: static int VDIColors = 16;
36: static int VDICharHeight = 8;
37:
38: static Uint32 LineABase; /* Line-A structure */
39: static Uint32 FontBase; /* Font base, used for 16-pixel high font */
1.1 root 40:
1.1.1.8 root 41: static Uint32 Control;
42: static Uint32 Intin;
43: static Uint32 Ptsin;
44: static Uint32 Intout;
45: static Uint32 Ptsout;
1.1 root 46:
1.1.1.2 root 47:
48: /*-----------------------------------------------------------------------*/
49: /* Desktop TOS 1.04 and TOS 2.06 desktop configuration files */
1.1.1.8 root 50: static const Uint8 DesktopScript[504] =
1.1.1.3 root 51: {
1.1.1.9 root 52: 0x23,0x61,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x62,0x30,0x30,0x30,0x30,
53: 0x30,0x30,0x0D,0x0A,0x23,0x63,0x37,0x37,0x37,0x30,0x30,0x30,0x37,0x30,0x30,0x30,
54: 0x36,0x30,0x30,0x30,0x37,0x30,0x30,0x35,0x35,0x32,0x30,0x30,0x35,0x30,0x35,0x35,
55: 0x35,0x32,0x32,0x32,0x30,0x37,0x37,0x30,0x35,0x35,0x37,0x30,0x37,0x35,0x30,0x35,
56: 0x35,0x35,0x30,0x37,0x37,0x30,0x33,0x31,0x31,0x31,0x31,0x30,0x33,0x0D,0x0A,0x23,
57: 0x64,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
58: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
59: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,
60: 0x23,0x45,0x20,0x31,0x38,0x20,0x31,0x31,0x20,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,
61: 0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,
62: 0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
63: 0x32,0x20,0x30,0x42,0x20,0x32,0x36,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,
64: 0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x41,0x20,0x30,0x46,0x20,
65: 0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,
66: 0x30,0x20,0x30,0x30,0x20,0x30,0x45,0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,
67: 0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x31,0x20,0x30,0x30,0x20,
68: 0x30,0x30,0x20,0x46,0x46,0x20,0x43,0x20,0x48,0x41,0x52,0x44,0x20,0x44,0x49,0x53,
69: 0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
70: 0x30,0x30,0x20,0x46,0x46,0x20,0x41,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,
71: 0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,
72: 0x31,0x20,0x30,0x30,0x20,0x46,0x46,0x20,0x42,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,
73: 0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x54,0x20,0x30,0x30,
74: 0x20,0x30,0x33,0x20,0x30,0x32,0x20,0x46,0x46,0x20,0x20,0x20,0x54,0x52,0x41,0x53,
75: 0x48,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x46,0x20,0x46,0x46,0x20,0x30,0x34,0x20,
76: 0x20,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x0D,0x0A,0x23,0x44,0x20,0x46,0x46,
77: 0x20,0x30,0x31,0x20,0x20,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x0D,0x0A,0x23,
78: 0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x20,0x20,0x2A,0x2E,0x41,0x50,0x50,0x40,
79: 0x20,0x40,0x20,0x0D,0x0A,0x23,0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x20,0x20,
80: 0x2A,0x2E,0x50,0x52,0x47,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x50,0x20,0x30,0x33,
81: 0x20,0x46,0x46,0x20,0x20,0x20,0x2A,0x2E,0x54,0x54,0x50,0x40,0x20,0x40,0x20,0x0D,
82: 0x0A,0x23,0x46,0x20,0x30,0x33,0x20,0x30,0x34,0x20,0x20,0x20,0x2A,0x2E,0x54,0x4F,
83: 0x53,0x40,0x20,0x40,0x20,0x0D,0x0A,0x1A
1.1 root 84: };
85:
1.1.1.8 root 86: static const Uint8 NewDeskScript[786] =
1.1.1.3 root 87: {
1.1.1.9 root 88: 0x23,0x61,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x62,0x30,0x30,0x30,0x30,
89: 0x30,0x30,0x0D,0x0A,0x23,0x63,0x37,0x37,0x37,0x30,0x30,0x30,0x37,0x30,0x30,0x30,
90: 0x36,0x30,0x30,0x30,0x37,0x30,0x30,0x35,0x35,0x32,0x30,0x30,0x35,0x30,0x35,0x35,
91: 0x35,0x32,0x32,0x32,0x30,0x37,0x37,0x30,0x35,0x35,0x37,0x30,0x37,0x35,0x30,0x35,
92: 0x35,0x35,0x30,0x37,0x37,0x30,0x33,0x31,0x31,0x31,0x31,0x30,0x33,0x0D,0x0A,0x23,
93: 0x64,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
94: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
95: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,
96: 0x23,0x4B,0x20,0x34,0x46,0x20,0x35,0x33,0x20,0x34,0x43,0x20,0x30,0x30,0x20,0x34,
97: 0x36,0x20,0x34,0x32,0x20,0x34,0x33,0x20,0x35,0x37,0x20,0x34,0x35,0x20,0x35,0x38,
98: 0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
99: 0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
100: 0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x35,0x32,0x20,0x30,0x30,0x20,0x30,0x30,
101: 0x20,0x34,0x44,0x20,0x35,0x36,0x20,0x35,0x30,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,
102: 0x23,0x45,0x20,0x31,0x38,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x30,0x36,0x20,0x0D,
103: 0x0A,0x23,0x51,0x20,0x34,0x31,0x20,0x34,0x30,0x20,0x34,0x33,0x20,0x34,0x30,0x20,
104: 0x34,0x33,0x20,0x34,0x30,0x20,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,
105: 0x20,0x30,0x30,0x20,0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,0x30,0x30,0x20,
106: 0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x32,0x20,0x30,
107: 0x42,0x20,0x32,0x36,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,
108: 0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x41,0x20,0x30,0x46,0x20,0x31,0x41,0x20,
109: 0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,
110: 0x30,0x20,0x30,0x45,0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,
111: 0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x34,0x20,
112: 0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,
113: 0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x43,0x20,0x30,0x42,0x20,0x32,0x36,
114: 0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,
115: 0x30,0x30,0x20,0x30,0x38,0x20,0x30,0x46,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,
116: 0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x36,
117: 0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,
118: 0x23,0x4E,0x20,0x46,0x46,0x20,0x30,0x34,0x20,0x30,0x30,0x30,0x20,0x40,0x20,0x2A,
119: 0x2E,0x2A,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x44,0x20,0x46,0x46,0x20,0x30,0x31,
120: 0x20,0x30,0x30,0x30,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x40,0x20,0x0D,0x0A,
121: 0x23,0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x41,
122: 0x50,0x50,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x47,0x20,0x30,0x33,0x20,
123: 0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x50,0x52,0x47,0x40,0x20,0x40,0x20,
124: 0x40,0x20,0x0D,0x0A,0x23,0x59,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,
125: 0x20,0x2A,0x2E,0x47,0x54,0x50,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x50,
126: 0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x54,0x54,0x50,
127: 0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x46,0x20,0x30,0x33,0x20,0x30,0x34,
128: 0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x54,0x4F,0x53,0x40,0x20,0x40,0x20,0x40,0x20,
129: 0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x46,0x46,
130: 0x20,0x43,0x20,0x48,0x41,0x52,0x44,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,
131: 0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x46,0x46,
132: 0x20,0x41,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,
133: 0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
134: 0x46,0x46,0x20,0x42,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,
135: 0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x54,0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,
136: 0x32,0x20,0x46,0x46,0x20,0x20,0x20,0x54,0x52,0x41,0x53,0x48,0x40,0x20,0x40,0x20,
137: 0x0D,0x0A
1.1 root 138: };
139:
1.1.1.2 root 140:
141: /*-----------------------------------------------------------------------*/
1.1.1.9 root 142: /**
143: * Returns given value after constraining it within "min" and "max" values
144: * and making it evenly divisable by "align"
145: */
146: int VDI_Limit(int value, int align, int min, int max)
1.1 root 147: {
1.1.1.9 root 148: value = (value/align)*align;
149: if (value > max)
150: {
151: /* align down */
152: return (max/align)*align;
153: }
154: if (value < min)
155: {
156: /* align up */
157: min += align-1;
158: return (min/align)*align;
159: }
160: return value;
1.1 root 161: }
162:
1.1.1.2 root 163:
164: /*-----------------------------------------------------------------------*/
1.1.1.9 root 165: /**
166: * Set Width/Height/BitDepth according to passed GEMRES_640x480,
167: * GEMRES_800x600, GEMRES_OTHER. Align size when necessary.
168: */
169: void VDI_SetResolution(int GEMColor, int WidthRequest, int HeightRequest)
170: {
171: /* Color depth */
172: switch (GEMColor)
173: {
174: case GEMCOLOR_2:
175: VDIRes = 2;
176: VDIPlanes = 1;
177: VDIColors = 2;
178: VDICharHeight = 16;
179: break;
180: case GEMCOLOR_4:
181: VDIRes = 1;
182: VDIPlanes = 2;
183: VDIColors = 4;
184: VDICharHeight = 8;
185: break;
186: case GEMCOLOR_16:
187: VDIRes = 0;
188: VDIPlanes = 4;
189: VDIColors = 16;
190: VDICharHeight = 8;
191: break;
192: }
193:
194: /* width needs to be aligned to 16 bytes */
195: VDIWidth = VDI_Limit(WidthRequest, 128/VDIPlanes, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
196: /* height needs to be multiple of cell height */
197: VDIHeight = VDI_Limit(HeightRequest, VDICharHeight, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
198: printf("VDI screen: request = %dx%d@%d, aligned result = %dx%d@%d\n",
199: WidthRequest, HeightRequest, VDIPlanes, VDIWidth, VDIHeight, VDIPlanes);
200:
201: /* Write resolution to re-boot takes effect with correct bit-depth */
202: VDI_FixDesktopInf();
203: }
204:
1.1 root 205:
1.1.1.9 root 206: /*-----------------------------------------------------------------------*/
207: /**
1.1.1.12 root 208: * Check VDI call and see if we need to re-direct to our own routines.
209: * Return true if we've handled the exception, else return false.
1.1.1.9 root 210: *
1.1.1.12 root 211: * We enter here with Trap #2, so D1 is pointer to VDI vectors, i.e. Control,
212: * Intin, Ptsin etc...
1.1.1.9 root 213: */
1.1.1.10 root 214: bool VDI(void)
1.1 root 215: {
1.1.1.9 root 216: Uint32 TablePtr = Regs[REG_D1];
1.1.1.13! root 217: /* Uint16 OpCode;*/
1.1 root 218:
1.1.1.9 root 219: /* Read off table pointers */
220: Control = STMemory_ReadLong(TablePtr);
221: Intin = STMemory_ReadLong(TablePtr+4);
222: Ptsin = STMemory_ReadLong(TablePtr+8);
223: Intout = STMemory_ReadLong(TablePtr+12);
224: Ptsout = STMemory_ReadLong(TablePtr+16);
225:
226: /*
227: OpCode = STMemory_ReadWord(Control);
228: // Check OpCode
229: // 8 - Text Font
230: if (OpCode==9)
231: {
1.1.1.12 root 232: return true;
1.1.1.9 root 233: }
234: */
1.1 root 235:
1.1.1.9 root 236: /* Call as normal! */
1.1.1.12 root 237: return false;
1.1 root 238: }
239:
1.1.1.2 root 240:
241: /*-----------------------------------------------------------------------*/
1.1.1.9 root 242: /**
243: * Modify Line-A structure for our VDI resolutions
244: */
245: void VDI_LineA(Uint32 linea, Uint32 fontbase)
1.1 root 246: {
1.1.1.9 root 247: if (bUseVDIRes)
248: {
249: STMemory_WriteWord(linea-46, VDICharHeight); /* v_cel_ht */
250: STMemory_WriteWord(linea-44, (VDIWidth/8)-1); /* v_cel_mx (cols-1) */
251: STMemory_WriteWord(linea-42, (VDIHeight/VDICharHeight)-1); /* v_cel_my (rows-1) */
252: STMemory_WriteWord(linea-40, VDICharHeight*((VDIWidth*VDIPlanes)/8)); /* v_cel_wr */
253:
254: STMemory_WriteWord(linea-12, VDIWidth); /* v_rez_hz */
255: STMemory_WriteWord(linea-4, VDIHeight); /* v_rez_vt */
256: STMemory_WriteWord(linea-2, (VDIWidth*VDIPlanes)/8); /* bytes_lin */
257: STMemory_WriteWord(linea+0, VDIPlanes); /* planes */
258: STMemory_WriteWord(linea+2, (VDIWidth*VDIPlanes)/8); /* width */
259: }
260: LineABase = linea;
261: FontBase = fontbase;
1.1 root 262: }
263:
1.1.1.2 root 264:
1.1.1.13! root 265: #if ENABLE_TRACING
! 266: /*-----------------------------------------------------------------------*/
! 267: /**
! 268: * Map VDI call opcode/sub-opcode to a VDI function name
! 269: */
! 270: static const char* VDI_Opcode2Name(Uint16 opcode, Uint16 subcode)
! 271: {
! 272: static const char* names_0[] = {
! 273: "???",
! 274: "v_opnwk",
! 275: "v_clswk",
! 276: "v_clrwk",
! 277: "v_updwk",
! 278: "", /* 5: lots of sub opcodes */
! 279: "v_pline",
! 280: "v_pmarker",
! 281: "v_gtext",
! 282: "v_fillarea", /* sub-opcode 13: v_bez_fill with GDOS */
! 283: "v_cellarray",
! 284: "", /* 11: lots of sub opcodes */
! 285: "vst_height",
! 286: "vst_rotation",
! 287: "vs_color",
! 288: "vsl_type",
! 289: "vsl_width",
! 290: "vsl_color",
! 291: "vsm_type",
! 292: "vsm_height",
! 293: "vsm_color",
! 294: "vst_font",
! 295: "vst_color",
! 296: "vsf_interior",
! 297: "vsf_style",
! 298: "vsf_color",
! 299: "vq_color",
! 300: "vq_cellarray",
! 301: "vrq/sm_locator",
! 302: "vrq/sm_valuator",
! 303: "vrq/sm_choice",
! 304: "vrq/sm_string",
! 305: "vswr_mode",
! 306: "vsin_mode",
! 307: "???", /* 34 */
! 308: "vql_attributes",
! 309: "vqm_attributes",
! 310: "vqf_attributes",
! 311: "vqt_attributes",
! 312: "vst_alignment"
! 313: };
! 314: static const char* names_100[] = {
! 315: "v_opnvwk",
! 316: "v_clsvwk",
! 317: "vq_extnd",
! 318: "v_contourfill",
! 319: "vsf_perimeter",
! 320: "v_get_pixel",
! 321: "vst_effects",
! 322: "vst_point",
! 323: "vsl_ends",
! 324: "vro_cpyfm",
! 325: "vr_trnfm",
! 326: "vsc_form",
! 327: "vsf_udpat",
! 328: "vsl_udsty",
! 329: "vr_recfl",
! 330: "vqin_mode",
! 331: "vqt_extent",
! 332: "vqt_width",
! 333: "vex_timv",
! 334: "vst_load_fonts",
! 335: "vst_unload_fonts",
! 336: "vrt_cpyfm",
! 337: "v_show_c",
! 338: "v_hide_c",
! 339: "vq_mouse",
! 340: "vex_butv",
! 341: "vex_motv",
! 342: "vex_curv",
! 343: "vq_key_s",
! 344: "vs_clip",
! 345: "vqt_name",
! 346: "vqt_fontinfo"
! 347: /* 131-233: no known opcodes
! 348: * 234-255: (Speedo) GDOS opcodes
! 349: */
! 350: };
! 351: static const char* names_opcode5[] = {
! 352: "???",
! 353: "vq_chcells",
! 354: "v_exit_cur",
! 355: "v_enter_cur",
! 356: "v_curup",
! 357: "v_curdown",
! 358: "v_curright",
! 359: "v_curleft",
! 360: "v_curhome",
! 361: "v_eeos",
! 362: "v_eeol",
! 363: "vs_curaddress",
! 364: "v_curtext",
! 365: "v_rvon",
! 366: "v_rvoff",
! 367: "vq_curaddress",
! 368: "vq_tabstatus",
! 369: "v_hardcopy",
! 370: "v_dspcur",
! 371: "v_rmcur",
! 372: "v_form_adv",
! 373: "v_output_window",
! 374: "v_clear_disp_list",
! 375: "v_bit_image",
! 376: "vq_scan",
! 377: "v_alpha_text"
! 378: };
! 379: static const char* names_opcode5_98[] = {
! 380: "v_meta_extents",
! 381: "v_write_meta",
! 382: "vm_filename",
! 383: "???",
! 384: "v_fontinit"
! 385: };
! 386: static const char* names_opcode11[] = {
! 387: "???",
! 388: "v_bar",
! 389: "v_arc",
! 390: "v_pieslice",
! 391: "v_circle",
! 392: "v_ellipse",
! 393: "v_ellarc",
! 394: "v_ellpie",
! 395: "v_rbox",
! 396: "v_rfbox",
! 397: "v_justified"
! 398: };
! 399:
! 400: if (opcode == 5)
! 401: {
! 402: if (subcode < ARRAYSIZE(names_opcode5)) {
! 403: return names_opcode5[subcode];
! 404: }
! 405: if (subcode >= 98) {
! 406: subcode -= 98;
! 407: if (subcode < ARRAYSIZE(names_opcode5_98)) {
! 408: return names_opcode5_98[subcode];
! 409: }
! 410: }
! 411: }
! 412: else if (opcode == 11)
! 413: {
! 414: if (subcode < ARRAYSIZE(names_opcode11)) {
! 415: return names_opcode11[subcode];
! 416: }
! 417: }
! 418: else if (opcode < ARRAYSIZE(names_0))
! 419: {
! 420: return names_0[opcode];
! 421: }
! 422: else if (opcode >= 100)
! 423: {
! 424: opcode -= 100;
! 425: if (opcode < ARRAYSIZE(names_100))
! 426: {
! 427: return names_100[opcode];
! 428: }
! 429: }
! 430: return "GDOS call?";
! 431: }
! 432: #endif
! 433:
! 434:
1.1.1.2 root 435: /*-----------------------------------------------------------------------*/
1.1.1.9 root 436: /**
437: * This is called on completion of a VDI Trap, used to modify return structure for
438: */
1.1 root 439: void VDI_Complete(void)
440: {
1.1.1.10 root 441: Uint16 OpCode;
1.1 root 442:
1.1.1.9 root 443: OpCode = STMemory_ReadWord(Control);
444: /* Is 'Open Workstation', or 'Open Virtual Screen Workstation'? */
445: if ( (OpCode==1) || (OpCode==100) )
446: {
447: STMemory_WriteWord(Intout, VDIWidth-1); /* IntOut[0] Width-1 */
448: STMemory_WriteWord(Intout+1*2, VDIHeight-1); /* IntOut[1] Height-1 */
449: STMemory_WriteWord(Intout+13*2, VDIColors); /* IntOut[13] #colors */
450: STMemory_WriteWord(Intout+39*2, 512); /* IntOut[39] #available colors */
1.1 root 451:
1.1.1.9 root 452: STMemory_WriteWord(LineABase-0x15a*2, VDIWidth-1); /* WKXRez */
453: STMemory_WriteWord(LineABase-0x159*2, VDIHeight-1); /* WKYRez */
1.1 root 454:
1.1.1.9 root 455: VDI_LineA(LineABase, FontBase); /* And modify Line-A structure accordingly */
456: }
1.1.1.12 root 457:
1.1.1.13! root 458: #if ENABLE_TRACING
! 459: {
! 460: Uint16 SubCode = STMemory_ReadWord(Control+2*5);
! 461: LOG_TRACE(TRACE_OS_VDI, "VDI call %3hd/%3hd (%s)\n",
! 462: OpCode, SubCode, VDI_Opcode2Name(OpCode, SubCode));
! 463: }
! 464: #endif
1.1 root 465: }
466:
1.1.1.2 root 467:
468: /*-----------------------------------------------------------------------*/
1.1.1.9 root 469: /**
470: * Save desktop configuration file for VDI, eg desktop.inf(TOS 1.04) or newdesk.inf(TOS 2.06)
471: */
1.1.1.8 root 472: static void VDI_SaveDesktopInf(char *pszFileName, const Uint8 *Script, long ScriptSize)
1.1 root 473: {
1.1.1.9 root 474: /* Just save file */
1.1.1.12 root 475: File_Save(pszFileName, Script, ScriptSize, false);
1.1 root 476: }
477:
1.1.1.2 root 478:
479: /*-----------------------------------------------------------------------*/
1.1.1.9 root 480: /**
481: * Modify exisiting ST desktop configuration files to set resolution(keep user settings)
482: */
1.1.1.5 root 483: static void VDI_ModifyDesktopInf(char *pszFileName)
1.1 root 484: {
1.1.1.9 root 485: long InfSize;
486: Uint8 *pInfData;
487: int i;
488:
489: /* Load our '.inf' file */
490: pInfData = File_Read(pszFileName, &InfSize, NULL);
491: if (pInfData)
492: {
493: /* Scan file for '#E' */
494: i = 0;
495: while (i < (InfSize-8))
496: {
497: if ((pInfData[i]=='#') && (pInfData[i+1]=='E'))
498: {
499: /* Modify resolution */
500: pInfData[i+7] = '1'+VDIRes;
501: break;
502: }
503:
504: i++;
505: }
506:
507: /* And save */
1.1.1.12 root 508: File_Save(pszFileName, pInfData, InfSize, false);
1.1.1.9 root 509: /* Free */
510: free(pInfData);
511: }
1.1 root 512: }
513:
1.1.1.2 root 514:
515: /*-----------------------------------------------------------------------*/
1.1.1.9 root 516: /**
517: * Modify (or create) ST desktop configuration files so VDI boots up in
518: * correct color depth
519: */
1.1 root 520: void VDI_FixDesktopInf(void)
521: {
1.1.1.9 root 522: char *szDesktopFileName, *szNewDeskFileName;
1.1 root 523:
1.1.1.9 root 524: if (!GEMDOS_EMU_ON)
525: {
526: /* Can't modify DESKTOP.INF when not using GEMDOS hard disk emulation */
527: return;
528: }
529:
530: szDesktopFileName = malloc(2 * FILENAME_MAX);
531: if (!szDesktopFileName)
532: {
533: perror("VDI_FixDesktopInf");
534: return;
535: }
536: szNewDeskFileName = szDesktopFileName + FILENAME_MAX;
537:
538: /* Create filenames for hard-drive */
539: GemDOS_CreateHardDriveFileName(2, "\\DESKTOP.INF", szDesktopFileName, FILENAME_MAX);
540: GemDOS_CreateHardDriveFileName(2, "\\NEWDESK.INF", szNewDeskFileName, FILENAME_MAX);
541:
542: /* First, check if files exist(ie modify or replace) */
543: if (!File_Exists(szDesktopFileName))
544: VDI_SaveDesktopInf(szDesktopFileName,DesktopScript,sizeof(DesktopScript));
545: VDI_ModifyDesktopInf(szDesktopFileName);
546:
547: if (!File_Exists(szNewDeskFileName))
548: VDI_SaveDesktopInf(szNewDeskFileName,NewDeskScript,sizeof(NewDeskScript));
549: VDI_ModifyDesktopInf(szNewDeskFileName);
1.1.1.5 root 550:
1.1.1.9 root 551: free(szDesktopFileName);
1.1 root 552: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.