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

Comparing SheepShaver/src/video.cpp (file contents):
Revision 1.4 by gbeauche, 2003-12-04T17:26:35Z vs.
Revision 1.14 by gbeauche, 2005-03-27T13:44:45Z

# Line 1 | Line 1
1   /*
2   *  video.cpp - Video/graphics emulation
3   *
4 < *  SheepShaver (C) 1997-2002 Marc Hellwig and Christian Bauer
4 > *  SheepShaver (C) 1997-2005 Marc Hellwig and 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 74 | Line 74 | static long save_conf_mode = APPLE_8_BIT
74   // Function pointers of imported functions
75   typedef int16 (*iocic_ptr)(void *, int16);
76   static uint32 iocic_tvect = 0;
77 < static inline int16 IOCommandIsComplete(void *arg1, int16 arg2)
77 > static inline int16 IOCommandIsComplete(uintptr arg1, int16 arg2)
78   {
79 <        return (int16)CallMacOS2(iocic_ptr, iocic_tvect, arg1, arg2);
79 >        return (int16)CallMacOS2(iocic_ptr, iocic_tvect, (void *)arg1, arg2);
80   }
81   typedef int16 (*vslnewis_ptr)(void *, uint32, uint32 *);
82   static uint32 vslnewis_tvect = 0;
83 < static inline int16 VSLNewInterruptService(void *arg1, uint32 arg2, uint32 *arg3)
83 > static inline int16 VSLNewInterruptService(uintptr arg1, uint32 arg2, uintptr arg3)
84   {
85 <        return (int16)CallMacOS3(vslnewis_ptr, vslnewis_tvect, arg1, arg2, arg3);
85 >        return (int16)CallMacOS3(vslnewis_ptr, vslnewis_tvect, (void *)arg1, arg2, (uint32 *)arg3);
86   }
87   typedef int16 (*vsldisposeis_ptr)(uint32);
88   static uint32 vsldisposeis_tvect = 0;
# Line 98 | Line 98 | int16 VSLDoInterruptService(uint32 arg1)
98   }
99   typedef void (*nqdmisc_ptr)(uint32, void *);
100   static uint32 nqdmisc_tvect = 0;
101 < void NQDMisc(uint32 arg1, void *arg2)
101 > void NQDMisc(uint32 arg1, uintptr arg2)
102   {
103 <        CallMacOS2(nqdmisc_ptr, nqdmisc_tvect, arg1, arg2);
103 >        CallMacOS2(nqdmisc_ptr, nqdmisc_tvect, arg1, (void *)arg2);
104   }
105  
106  
# Line 156 | Line 156 | static int16 VideoOpen(uint32 pb, VidLoc
156          csSave->saveMode = VModes[cur_mode].viAppleMode;
157          csSave->savePage = 0;
158          csSave->saveVidParms = 0;                       // Add the right table
159        csSave->gammaTable = NULL;                      // No gamma table yet
160        csSave->maxGammaTableSize = 0;
159          csSave->luminanceMapping = false;
160          csSave->cursorX = 0;
161          csSave->cursorY = 0;
162          csSave->cursorVisible = 0;
163          csSave->cursorSet = 0;
164  
165 <        // Activate default gamma table
165 >        // Find and set default gamma table
166 >        csSave->gammaTable = 0;
167 >        csSave->maxGammaTableSize = 0;
168          set_gamma(csSave, 0);
169  
170          // Install and activate interrupt service
171          SheepVar32 theServiceID = 0;
172 <        VSLNewInterruptService(csSave->regEntryID, FOURCC('v','b','l',' '), (uint32 *)theServiceID.addr());
172 >        VSLNewInterruptService(csSave->regEntryID, FOURCC('v','b','l',' '), theServiceID.addr());
173          csSave->vslServiceID = theServiceID.value();
174          D(bug(" Interrupt ServiceID %08lx\n", csSave->vslServiceID));
175          csSave->interruptsEnabled = true;
# Line 182 | Line 182 | static int16 VideoOpen(uint32 pb, VidLoc
182   *  Video driver control routine
183   */
184  
185 + static bool allocate_gamma_table(VidLocals *csSave, uint32 size)
186 + {
187 +        if (size > csSave->maxGammaTableSize) {
188 +                if (csSave->gammaTable) {
189 +                        Mac_sysfree(csSave->gammaTable);
190 +                        csSave->gammaTable = 0;
191 +                        csSave->maxGammaTableSize = 0;
192 +                }
193 +                if ((csSave->gammaTable = Mac_sysalloc(size)) == 0)
194 +                        return false;
195 +                csSave->maxGammaTableSize = size;
196 +        }
197 +        return true;
198 + }
199 +
200   static int16 set_gamma(VidLocals *csSave, uint32 gamma)
201   {
202 <        GammaTbl *clientGamma = (GammaTbl *)gamma;
188 <        GammaTbl *gammaTable = csSave->gammaTable;
202 >        return paramErr;
203  
204 <        if (clientGamma == NULL) {
204 >        if (gamma == 0) { // Build linear ramp, 256 entries
205  
206 <                // No gamma table supplied, build linear ramp
207 <                uint32 linearRampSize = sizeof(GammaTbl) + 256 - 2;    
208 <                uint8 *correctionData;
209 <
210 <                // Allocate new gamma table if existing gamma table is smaller than required.
211 <                if (linearRampSize > csSave->maxGammaTableSize) {
212 <                        delete[] csSave->gammaTable;
213 <                        csSave->gammaTable = (GammaTbl *)new uint8[linearRampSize];
214 <                        csSave->maxGammaTableSize = linearRampSize;
215 <                        gammaTable = csSave->gammaTable;
216 <                }
203 <                
204 <                gammaTable->gVersion = 0;                       // A version 0 style of the GammaTbl structure
205 <                gammaTable->gType = 0;                          // Frame buffer hardware invariant
206 <                gammaTable->gFormulaSize = 0;           // No formula data, just correction data
207 <                gammaTable->gChanCnt = 1;                       // Apply same correction to Red, Green, & Blue
208 <                gammaTable->gDataCnt = 256;                     // gDataCnt == 2^^gDataWidth
209 <                gammaTable->gDataWidth = 8;                     // 8 bits of significant data per entry
210 <
211 <                // Find the starting address of the correction data.  This can be computed by starting at
212 <                // the address of gFormula[0] and adding the gFormulaSize.
213 <                correctionData = (uint8 *)((uint32)&gammaTable->gFormulaData[0] + gammaTable->gFormulaSize);
206 >                // Allocate new table, if necessary
207 >                if (!allocate_gamma_table(csSave, SIZEOF_GammaTbl + 256))
208 >                        return memFullErr;
209 >
210 >                // Initialize header
211 >                WriteMacInt16(csSave->gammaTable + gVersion, 0);                // A  version 0 style of the GammaTbl structure
212 >                WriteMacInt16(csSave->gammaTable + gType, 0);                   // Frame buffer hardware invariant
213 >                WriteMacInt16(csSave->gammaTable + gFormulaSize, 0);    // No formula data, just correction data
214 >                WriteMacInt16(csSave->gammaTable + gChanCnt, 1);                // Apply same correction to Red, Green, & Blue
215 >                WriteMacInt16(csSave->gammaTable + gDataCnt, 256);              // gDataCnt == 2^^gDataWidth
216 >                WriteMacInt16(csSave->gammaTable + gDataWidth, 8);              // 8 bits of significant data per entry
217  
218                  // Build the linear ramp
219 <                for (int i=0; i<gammaTable->gDataCnt; i++)
220 <                        *correctionData++ = i;          
219 >                uint32 p = csSave->gammaTable + gFormulaData;
220 >                for (int i=0; i<256; i++)
221 >                        WriteMacInt8(p + i, i);
222  
223 <        } else {
223 >        } else { // User-supplied gamma table
224  
225 <                // User supplied a gamma table, so make sure it is a valid one
226 <                if (clientGamma->gVersion != 0)
225 >                // Validate header
226 >                if (ReadMacInt16(gamma + gVersion) != 0)
227                          return paramErr;
228 <                if (clientGamma->gType != 0)
228 >                if (ReadMacInt16(gamma + gType) != 0)
229                          return paramErr;
230 <                if ((clientGamma->gChanCnt != 1) && (clientGamma->gChanCnt != 3))
230 >                int chan_cnt = ReadMacInt16(gamma + gChanCnt);
231 >                if (chan_cnt != 1 && chan_cnt != 3)
232                          return paramErr;
233 <                if (clientGamma->gDataWidth > 8)
233 >                int data_width = ReadMacInt16(gamma + gDataWidth);
234 >                if (data_width > 8)
235                          return paramErr;
236 <                if (clientGamma->gDataCnt != (1 << clientGamma->gDataWidth))
236 >                int data_cnt = ReadMacInt16(gamma + gDataWidth);
237 >                if (data_cnt != (1 << data_width))
238                          return paramErr;
239  
240 <                uint32 tableSize = sizeof(GammaTbl)                                             // fixed size header
241 <                                + clientGamma->gFormulaSize                                             // add formula size
242 <                                + clientGamma->gChanCnt * clientGamma->gDataCnt // assume 1 byte/entry
243 <                                - 2;                                                                                    // correct gFormulaData[0] counted twice
237 <
238 <                // Allocate new gamma table if existing gamma table is smaller than required.
239 <                if (tableSize > csSave->maxGammaTableSize) {
240 <                        delete[] csSave->gammaTable;
241 <                        csSave->gammaTable = (GammaTbl *)new uint8[tableSize];
242 <                        csSave->maxGammaTableSize = tableSize;
243 <                        gammaTable = csSave->gammaTable;
244 <                }
240 >                // Allocate new table, if necessary
241 >                int size = SIZEOF_GammaTbl + ReadMacInt16(gamma + gFormulaSize) + chan_cnt * data_cnt;
242 >                if (!allocate_gamma_table(csSave, size))
243 >                        return memFullErr;
244  
245 <                // Copy gamma table header              
246 <                *gammaTable = *clientGamma;
248 <                
249 <                // Copy the formula data (if any)
250 <                uint8 *newData = (uint8 *)&gammaTable->gFormulaData[0];         // Point to newGamma's formula data
251 <                uint8 *clientData = (uint8 *)&clientGamma->gFormulaData[0];     // Point to clientGamma's formula data
252 <                for (int i=0; i<gammaTable->gFormulaSize; i++)
253 <                        *newData++ = *clientData++;
254 <
255 <                // Copy the correction data. Convientiently, after copying the formula data, the 'newData'
256 <                // pointer and the 'clientData' pointer are pointing to the their respective starting points
257 <                // of their correction data.
258 <                for (int i=0; i<gammaTable->gChanCnt; i++)
259 <                        for (int j=0; j<gammaTable->gDataCnt; j++)              
260 <                                *newData++ = *clientData++;
245 >                // Copy table
246 >                Mac2Mac_memcpy(csSave->gammaTable, gamma, size);
247          }
248          return noErr;
249   }
# Line 287 | Line 273 | static int16 VideoControl(uint32 pb, Vid
273                  case cscSetEntries: {                                                   // SetEntries
274                          D(bug("SetEntries\n"));                                
275                          if (VModes[cur_mode].viAppleMode > APPLE_8_BIT) return controlErr;
276 <                        ColorSpec *s_pal = (ColorSpec *)Mac2HostAddr(ReadMacInt32(param + csTable));
277 <                        int16 start = ReadMacInt16(param + csStart);
278 <                        int16 count = ReadMacInt16(param + csCount);
279 <                        if (s_pal == NULL || count > 256) return controlErr;
276 >                        uint32 s_pal = ReadMacInt32(param + csTable);
277 >                        uint16 start = ReadMacInt16(param + csStart);
278 >                        uint16 count = ReadMacInt16(param + csCount);
279 >                        if (s_pal == 0 || count > 256) return controlErr;
280  
281                          // Preparations for gamma correction
282                          bool do_gamma = false;
# Line 298 | Line 284 | static int16 VideoControl(uint32 pb, Vid
284                          uint8 *green_gamma = NULL;
285                          uint8 *blue_gamma = NULL;
286                          int gamma_data_width = 0;
287 <                        if (display_type == DIS_SCREEN && csSave->gammaTable != NULL) { // Windows are gamma-corrected by BeOS
288 <                                do_gamma = true;
289 <                                GammaTbl *gamma = csSave->gammaTable;
290 <                                gamma_data_width = gamma->gDataWidth;
291 <                                red_gamma = (uint8 *)&gamma->gFormulaData + gamma->gFormulaSize;
292 <                                if (gamma->gChanCnt == 1) {
293 <                                        green_gamma = blue_gamma = red_gamma;
294 <                                } else {
295 <                                        green_gamma = red_gamma + gamma->gDataCnt;
296 <                                        blue_gamma = red_gamma + 2 * gamma->gDataCnt;
287 >                        if (csSave->gammaTable) {
288 > #ifdef __BEOS__
289 >                                // Windows are gamma-corrected by BeOS
290 >                                const bool can_do_gamma = (display_type == DIS_SCREEN);
291 > #else
292 >                                const bool can_do_gamma = true;
293 > #endif
294 >                                if (can_do_gamma) {
295 >                                        uint32 gamma_table = csSave->gammaTable;
296 >                                        red_gamma = Mac2HostAddr(gamma_table + gFormulaData + ReadMacInt16(gamma_table + gFormulaSize));
297 >                                        int chan_cnt = ReadMacInt16(gamma_table + gChanCnt);
298 >                                        if (chan_cnt == 1)
299 >                                                green_gamma = blue_gamma = red_gamma;
300 >                                        else {
301 >                                                int ofs = ReadMacInt16(gamma_table + gDataCnt);
302 >                                                green_gamma = red_gamma + ofs;
303 >                                                blue_gamma = green_gamma + ofs;
304 >                                        }
305 >                                        gamma_data_width = ReadMacInt16(gamma_table + gDataWidth);
306 >                                        do_gamma = true;
307                                  }
308                          }
309  
310                          // Set palette
311                          rgb_color *d_pal;
312 <                        if (start == -1) {                      // Indexed
312 >                        if (start == 0xffff) {                  // Indexed
313                                  for (int i=0; i<=count; i++) {
314 <                                        d_pal = &(mac_pal[(*s_pal).value]);
315 <                                        uint8 red = (*s_pal).red >> 8;
316 <                                        uint8 green = (*s_pal).green >> 8;
317 <                                        uint8 blue = (*s_pal).blue >> 8;
314 >                                        d_pal = mac_pal + (ReadMacInt16(s_pal + csValue) & 0xff);
315 >                                        uint8 red = (uint16)ReadMacInt16(s_pal + csRed) >> 8;
316 >                                        uint8 green = (uint16)ReadMacInt16(s_pal + csGreen) >> 8;
317 >                                        uint8 blue = (uint16)ReadMacInt16(s_pal + csBlue) >> 8;
318                                          if (csSave->luminanceMapping)
319                                                  red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16;
320                                          if (do_gamma) {
# Line 329 | Line 325 | static int16 VideoControl(uint32 pb, Vid
325                                          (*d_pal).red = red;
326                                          (*d_pal).green = green;
327                                          (*d_pal).blue = blue;
328 <                                        s_pal++;
328 >                                        s_pal += 8;
329                                  }
330 <                        } else {                                                                // Sequential
331 <                                d_pal = &(mac_pal[start]);
330 >                        } else {                                                // Sequential
331 >                                d_pal = mac_pal + start;
332                                  for (int i=0; i<=count; i++) {
333 <                                        uint8 red = (*s_pal).red >> 8;
334 <                                        uint8 green = (*s_pal).green >> 8;
335 <                                        uint8 blue = (*s_pal).blue >> 8;
333 >                                        uint8 red = (uint16)ReadMacInt16(s_pal + csRed) >> 8;
334 >                                        uint8 green = (uint16)ReadMacInt16(s_pal + csGreen) >> 8;
335 >                                        uint8 blue = (uint16)ReadMacInt16(s_pal + csBlue) >> 8;
336                                          if (csSave->luminanceMapping)
337                                                  red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16;
338                                          if (do_gamma) {
# Line 347 | Line 343 | static int16 VideoControl(uint32 pb, Vid
343                                          (*d_pal).red = red;
344                                          (*d_pal).green = green;
345                                          (*d_pal).blue = blue;
346 <                                        d_pal++; s_pal++;
346 >                                        d_pal++;
347 >                                        s_pal += 8;
348                                  }
349                          }
350                          video_set_palette();
351                          return noErr;
352                  }
353  
354 <                case cscSetGamma:                                                       // SetGamma
355 <                        D(bug("SetGamma\n"));
356 <                        return set_gamma(csSave, ReadMacInt32(param));
354 >                case cscSetGamma: {                                                     // SetGamma
355 >                        uint32 user_table = ReadMacInt32(param + csGTable);
356 >                        D(bug("SetGamma %08x\n", user_table));
357 >                        return set_gamma(csSave, ReadMacInt32(user_table));
358 >                }
359  
360                  case cscGrayPage: {                                                     // GrayPage
361 <                        D(bug("GrayPage\n"));
362 <                        uint32 *screen = (uint32 *)csSave->saveBaseAddr;
363 <                        uint32 pattern;
364 <                        uint32 row_bytes = VModes[cur_mode].viRowBytes;
365 <                        switch (VModes[cur_mode].viAppleMode) {
366 <                                case APPLE_8_BIT:
367 <                                        pattern=0xff00ff00;
368 <                                        for (int i=0;i<VModes[cur_mode].viYsize;i++) {
369 <                                                for (int j=0;j<(VModes[cur_mode].viXsize>>2);j++)
370 <                                                        screen[j] = pattern;
371 <                                                pattern = ~pattern;
372 <                                                screen = (uint32 *)((uint32)screen + row_bytes);
373 <                                        }
374 <                                        break;
375 <                                case APPLE_16_BIT:
376 <                                        pattern=0xffff0000;
377 <                                        for (int i=0;i<VModes[cur_mode].viYsize;i++) {
378 <                                                for (int j=0;j<(VModes[cur_mode].viXsize>>1);j++)
379 <                                                        screen[j]=pattern;
380 <                                                pattern = ~pattern;
381 <                                                screen = (uint32 *)((uint32)screen + row_bytes);
382 <                                        }
383 <                                        break;
385 <                                case APPLE_32_BIT:
386 <                                        pattern=0xffffffff;
387 <                                        for (int i=0;i<VModes[cur_mode].viYsize;i++) {
388 <                                                for (int j=0;j<VModes[cur_mode].viXsize;j++) {
389 <                                                        screen[j]=pattern;
390 <                                                        pattern = ~pattern;
391 <                                                }
392 <                                                screen = (uint32 *)((uint32)screen + row_bytes);
393 <                                        }
394 <                                        break;
361 >                        D(bug("GrayPage %d\n", ReadMacInt16(param + csPage)));
362 >                        if (ReadMacInt16(param + csPage))
363 >                                return paramErr;
364 >
365 >                        uint32 pattern[6] = {
366 >                                0xaaaaaaaa,             // 1 bpp
367 >                                0xcccccccc,             // 2 bpp
368 >                                0xf0f0f0f0,             // 4 bpp
369 >                                0xff00ff00,             // 8 bpp
370 >                                0xffff0000,             // 16 bpp
371 >                                0xffffffff              // 32 bpp
372 >                        };
373 >                        uint32 p = csSave->saveBaseAddr;
374 >                        uint32 pat = pattern[VModes[cur_mode].viAppleMode - APPLE_1_BIT];
375 >                        bool invert = (VModes[cur_mode].viAppleMode == APPLE_32_BIT);
376 >                        for (uint32 y=0; y<VModes[cur_mode].viYsize; y++) {
377 >                                for (uint32 x=0; x<VModes[cur_mode].viRowBytes; x+=4) {
378 >                                        WriteMacInt32(p + x, pat);
379 >                                        if (invert)
380 >                                                pat = ~pat;
381 >                                }
382 >                                p += VModes[cur_mode].viRowBytes;
383 >                                pat = ~pat;
384                          }
385                          return noErr;
386                  }
# Line 457 | Line 446 | static int16 VideoControl(uint32 pb, Vid
446                          MacCursor[3] = ReadMacInt8(0x887);
447  
448                          // Set new cursor image
449 <                        if (display_type == DIS_SCREEN)
449 >                        if (!video_can_change_cursor())
450                                  return controlErr;
451                          if (changed)
452                                  video_set_cursor();
# Line 528 | Line 517 | static uint32 max_depth(uint32 id)
517          return max;
518   }
519  
520 + // Get X/Y size of specified resolution
521 + static void get_size_of_resolution(int id, uint32 &x, uint32 &y)
522 + {
523 +        VideoInfo *p = VModes;
524 +        while (p->viType != DIS_INVALID) {
525 +                if (p->viAppleID == id) {
526 +                        x = p->viXsize;
527 +                        y = p->viYsize;
528 +                        return;
529 +                }
530 +                p++;
531 +        }
532 +        x = y = 0;
533 + }
534 +
535   static int16 VideoStatus(uint32 pb, VidLocals *csSave)
536   {
537          int16 code = ReadMacInt16(pb + csCode);
# Line 547 | Line 551 | static int16 VideoStatus(uint32 pb, VidL
551  
552                  case cscGetEntries: {                                           // GetEntries
553                          D(bug("GetEntries\n"));
554 <                        ColorSpec *d_pal = (ColorSpec *)Mac2HostAddr(ReadMacInt32(param + csTable));
555 <                        int16 start = ReadMacInt16(param + csStart);
556 <                        int16 count = ReadMacInt16(param + csCount);
554 >                        uint32 d_pal = ReadMacInt32(param + csTable);
555 >                        uint16 start = ReadMacInt16(param + csStart);
556 >                        uint16 count = ReadMacInt16(param + csCount);
557                          rgb_color *s_pal;
558                          if ((VModes[cur_mode].viAppleMode == APPLE_32_BIT)||
559                                  (VModes[cur_mode].viAppleMode == APPLE_16_BIT)) {
560                                  D(bug("ERROR: GetEntries in direct mode \n"));
561                                  return statusErr;
562                          }
563 <                        if (start >= 0) {       // indexed get
564 <                                s_pal = &(mac_pal[start]);
563 >
564 >                        if (start == 0xffff) {          // Indexed
565                                  for (uint16 i=0;i<count;i++) {
566 <                                        (*d_pal).red=(uint16)((*s_pal).red)*0x101;
567 <                                        (*d_pal).green=(uint16)((*s_pal).green)*0x101;
568 <                                        (*d_pal).blue=(uint16)((*s_pal).blue)*0x101;
569 <                                        d_pal++; s_pal++;
566 >                                        s_pal = mac_pal + (ReadMacInt16(d_pal + csValue) & 0xff);
567 >                                        uint8 red = (*s_pal).red;
568 >                                        uint8 green = (*s_pal).green;
569 >                                        uint8 blue = (*s_pal).blue;
570 >                                        WriteMacInt16(d_pal + csRed, red * 0x0101);
571 >                                        WriteMacInt16(d_pal + csGreen, green * 0x0101);
572 >                                        WriteMacInt16(d_pal + csBlue, blue * 0x0101);
573 >                                        d_pal += 8;
574                                  }
575 <                        } else {                                                                // selected set
575 >                        } else {                                        // Sequential
576 >                                if (start + count > 255)
577 >                                        return paramErr;
578 >                                s_pal = mac_pal + start;
579                                  for (uint16 i=0;i<count;i++) {
580 <                                        s_pal = &(mac_pal[(*d_pal).value]);
581 <                                        (*d_pal).red=(uint16)((*s_pal).red)*0x101;
582 <                                        (*d_pal).green=(uint16)((*s_pal).green)*0x101;
583 <                                        (*d_pal).blue=(uint16)((*s_pal).blue)*0x101;
584 <                                        d_pal++;
580 >                                        uint8 red = (*s_pal).red;
581 >                                        uint8 green = (*s_pal).green;
582 >                                        uint8 blue = (*s_pal).blue;
583 >                                        s_pal++;
584 >                                        WriteMacInt16(d_pal + csRed, red * 0x0101);
585 >                                        WriteMacInt16(d_pal + csGreen, green * 0x0101);
586 >                                        WriteMacInt16(d_pal + csBlue, blue * 0x0101);
587 >                                        d_pal += 8;
588                                  }
589                          };
590                          return noErr;
# Line 689 | Line 703 | static int16 VideoStatus(uint32 pb, VidL
703                                          WriteMacInt32(param + csVerticalLines, 768);
704                                          WriteMacInt32(param + csRefreshRate, 75<<16);
705                                          break;
706 +                                case APPLE_1152x768:
707 +                                        WriteMacInt32(param + csHorizontalPixels, 1152);
708 +                                        WriteMacInt32(param + csVerticalLines, 768);
709 +                                        WriteMacInt32(param + csRefreshRate, 75<<16);
710 +                                        break;
711                                  case APPLE_1152x900:
712                                          WriteMacInt32(param + csHorizontalPixels, 1152);
713                                          WriteMacInt32(param + csVerticalLines, 900);
# Line 704 | Line 723 | static int16 VideoStatus(uint32 pb, VidL
723                                          WriteMacInt32(param + csVerticalLines, 1200);
724                                          WriteMacInt32(param + csRefreshRate, 75<<16);
725                                          break;
726 +                                case APPLE_CUSTOM: {
727 +                                        uint32 x, y;
728 +                                        get_size_of_resolution(work_id, x, y);
729 +                                        WriteMacInt32(param + csHorizontalPixels, x);
730 +                                        WriteMacInt32(param + csVerticalLines, y);
731 +                                        WriteMacInt32(param + csRefreshRate, 75<<16);
732 +                                        break;
733 +                                }
734                          }
735                          return noErr;
736                  }
# Line 807 | Line 834 | static int16 VideoStatus(uint32 pb, VidL
834                                                  case APPLE_1024x768:
835                                                          timing = timingVESA_1024x768_75hz;
836                                                          break;
837 +                                                case APPLE_1152x768:
838 +                                                        timing = timingApple_1152x870_75hz; // FIXME
839 +                                                        break;
840                                                  case APPLE_1152x900:
841                                                          timing = timingApple_1152x870_75hz;
842                                                          break;
# Line 867 | Line 897 | static int16 VideoClose(uint32 pb, VidLo
897   *  Native (PCI) driver entry
898   */
899  
900 < int16 VideoDoDriverIO(void *spaceID, void *commandID, void *commandContents, uint32 commandCode, uint32 commandKind)
900 > int16 VideoDoDriverIO(uint32 spaceID, uint32 commandID, uint32 commandContents, uint32 commandCode, uint32 commandKind)
901   {
902 < //      D(bug("VideoDoDriverIO space %p, command %p, contents %p, code %d, kind %d\n", spaceID, commandID, commandContents, commandCode, commandKind));
902 > //      D(bug("VideoDoDriverIO space %08x, command %08x, contents %08x, code %d, kind %d\n", spaceID, commandID, commandContents, commandCode, commandKind));
903          int16 err = noErr;
904  
905          switch (commandCode) {
906                  case kInitializeCommand:
907                  case kReplaceCommand:
908 <                        if (private_data != NULL)       // Might be left over from a reboot
909 <                                delete private_data->gammaTable;
908 >                        if (private_data != NULL) {     // Might be left over from a reboot
909 >                                if (private_data->gammaTable)
910 >                                        Mac_sysfree(private_data->gammaTable);
911 >                                if (private_data->regEntryID)
912 >                                        Mac_sysfree(private_data->regEntryID);
913 >                        }
914                          delete private_data;
915  
916 <                        iocic_tvect = (uint32)FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete");
916 >                        iocic_tvect = FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete");
917                          D(bug("IOCommandIsComplete TVECT at %08lx\n", iocic_tvect));
918                          if (iocic_tvect == 0) {
919                                  printf("FATAL: VideoDoDriverIO(): Can't find IOCommandIsComplete()\n");
920                                  err = -1;
921                                  break;
922                          }
923 <                        vslnewis_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\026VSLNewInterruptService");
923 >                        vslnewis_tvect = FindLibSymbol("\020VideoServicesLib", "\026VSLNewInterruptService");
924                          D(bug("VSLNewInterruptService TVECT at %08lx\n", vslnewis_tvect));
925                          if (vslnewis_tvect == 0) {
926                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLNewInterruptService()\n");
927                                  err = -1;
928                                  break;
929                          }
930 <                        vsldisposeis_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\032VSLDisposeInterruptService");
930 >                        vsldisposeis_tvect = FindLibSymbol("\020VideoServicesLib", "\032VSLDisposeInterruptService");
931                          D(bug("VSLDisposeInterruptService TVECT at %08lx\n", vsldisposeis_tvect));
932                          if (vsldisposeis_tvect == 0) {
933                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLDisposeInterruptService()\n");
934                                  err = -1;
935                                  break;
936                          }
937 <                        vsldois_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\025VSLDoInterruptService");
937 >                        vsldois_tvect = FindLibSymbol("\020VideoServicesLib", "\025VSLDoInterruptService");
938                          D(bug("VSLDoInterruptService TVECT at %08lx\n", vsldois_tvect));
939                          if (vsldois_tvect == 0) {
940                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLDoInterruptService()\n");
941                                  err = -1;
942                                  break;
943                          }
944 <                        nqdmisc_tvect = (uint32)FindLibSymbol("\014InterfaceLib", "\007NQDMisc");
944 >                        nqdmisc_tvect = FindLibSymbol("\014InterfaceLib", "\007NQDMisc");
945                          D(bug("NQDMisc TVECT at %08lx\n", nqdmisc_tvect));
946                          if (nqdmisc_tvect == 0) {
947                                  printf("FATAL: VideoDoDriverIO(): Can't find NQDMisc()\n");
# Line 916 | Line 950 | int16 VideoDoDriverIO(void *spaceID, voi
950                          }
951  
952                          private_data = new VidLocals;
953 <                        private_data->gammaTable = NULL;
954 <                        memcpy(private_data->regEntryID, (uint8 *)commandContents + 2, 16);     // DriverInitInfo.deviceEntry
953 >                        private_data->gammaTable = 0;
954 >                        private_data->regEntryID = Mac_sysalloc(sizeof(RegEntryID));
955 >                        if (private_data->regEntryID == 0) {
956 >                                printf("FATAL: VideoDoDriverIO(): Can't allocate service owner\n");
957 >                                err = -1;
958 >                                break;
959 >                        }
960 >                        Mac2Mac_memcpy(private_data->regEntryID, commandContents + 2, 16);      // DriverInitInfo.deviceEntry
961                          private_data->interruptsEnabled = false;        // Disable interrupts
962                          break;
963  
964                  case kFinalizeCommand:
965                  case kSupersededCommand:
966 <                        if (private_data != NULL)
967 <                                delete private_data->gammaTable;
966 >                        if (private_data != NULL) {
967 >                                if (private_data->gammaTable)
968 >                                        Mac_sysfree(private_data->gammaTable);
969 >                                if (private_data->regEntryID)
970 >                                        Mac_sysfree(private_data->regEntryID);
971 >                        }
972                          delete private_data;
973                          private_data = NULL;
974                          break;
975  
976                  case kOpenCommand:
977 <                        err = VideoOpen((uint32)commandContents, private_data);
977 >                        err = VideoOpen(commandContents, private_data);
978                          break;
979  
980                  case kCloseCommand:
981 <                        err = VideoClose((uint32)commandContents, private_data);
981 >                        err = VideoClose(commandContents, private_data);
982                          break;
983  
984                  case kControlCommand:
985 <                        err = VideoControl((uint32)commandContents, private_data);
985 >                        err = VideoControl(commandContents, private_data);
986                          break;
987  
988                  case kStatusCommand:
989 <                        err = VideoStatus((uint32)commandContents, private_data);
989 >                        err = VideoStatus(commandContents, private_data);
990                          break;
991  
992                  case kReadCommand:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines