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.1.1.1 by cebix, 2002-02-04T16:58:13Z vs.
Revision 1.11 by gbeauche, 2004-12-19T15:14:22Z

# 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-2004 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 35 | Line 35
35   #include "macos_util.h"
36   #include "user_strings.h"
37   #include "version.h"
38 + #include "thunks.h"
39  
40   #define DEBUG 0
41   #include "debug.h"
# Line 73 | 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 97 | 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 155 | 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
158        csSave->gammaTable = NULL;                      // No gamma table yet
159        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 <        csSave->vslServiceID = 0;
172 <        VSLNewInterruptService(csSave->regEntryID, FOURCC('v','b','l',' '), &(csSave->vslServiceID));
171 >        SheepVar32 theServiceID = 0;
172 >        VSLNewInterruptService(Host2MacAddr((uint8 *)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;
176  
# Line 180 | 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;
186 <        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 <                }
201 <                
202 <                gammaTable->gVersion = 0;                       // A version 0 style of the GammaTbl structure
203 <                gammaTable->gType = 0;                          // Frame buffer hardware invariant
204 <                gammaTable->gFormulaSize = 0;           // No formula data, just correction data
205 <                gammaTable->gChanCnt = 1;                       // Apply same correction to Red, Green, & Blue
206 <                gammaTable->gDataCnt = 256;                     // gDataCnt == 2^^gDataWidth
207 <                gammaTable->gDataWidth = 8;                     // 8 bits of significant data per entry
208 <
209 <                // Find the starting address of the correction data.  This can be computed by starting at
210 <                // the address of gFormula[0] and adding the gFormulaSize.
211 <                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
235 <
236 <                // Allocate new gamma table if existing gamma table is smaller than required.
237 <                if (tableSize > csSave->maxGammaTableSize) {
238 <                        delete[] csSave->gammaTable;
239 <                        csSave->gammaTable = (GammaTbl *)new uint8[tableSize];
240 <                        csSave->maxGammaTableSize = tableSize;
241 <                        gammaTable = csSave->gammaTable;
242 <                }
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;
246 <                
247 <                // Copy the formula data (if any)
248 <                uint8 *newData = (uint8 *)&gammaTable->gFormulaData[0];         // Point to newGamma's formula data
249 <                uint8 *clientData = (uint8 *)&clientGamma->gFormulaData[0];     // Point to clientGamma's formula data
250 <                for (int i=0; i<gammaTable->gFormulaSize; i++)
251 <                        *newData++ = *clientData++;
252 <
253 <                // Copy the correction data. Convientiently, after copying the formula data, the 'newData'
254 <                // pointer and the 'clientData' pointer are pointing to the their respective starting points
255 <                // of their correction data.
256 <                for (int i=0; i<gammaTable->gChanCnt; i++)
257 <                        for (int j=0; j<gammaTable->gDataCnt; j++)              
258 <                                *newData++ = *clientData++;
245 >                // Copy table
246 >                Mac2Mac_memcpy(csSave->gammaTable, gamma, size);
247          }
248          return noErr;
249   }
# Line 285 | 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 296 | 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 327 | 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 345 | 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;
383 <                                case APPLE_32_BIT:
384 <                                        pattern=0xffffffff;
385 <                                        for (int i=0;i<VModes[cur_mode].viYsize;i++) {
386 <                                                for (int j=0;j<VModes[cur_mode].viXsize;j++) {
387 <                                                        screen[j]=pattern;
388 <                                                        pattern = ~pattern;
389 <                                                }
390 <                                                screen = (uint32 *)((uint32)screen + row_bytes);
391 <                                        }
392 <                                        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 455 | 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 545 | Line 536 | static int16 VideoStatus(uint32 pb, VidL
536  
537                  case cscGetEntries: {                                           // GetEntries
538                          D(bug("GetEntries\n"));
539 <                        ColorSpec *d_pal = (ColorSpec *)Mac2HostAddr(ReadMacInt32(param + csTable));
540 <                        int16 start = ReadMacInt16(param + csStart);
541 <                        int16 count = ReadMacInt16(param + csCount);
539 >                        uint32 d_pal = ReadMacInt32(param + csTable);
540 >                        uint16 start = ReadMacInt16(param + csStart);
541 >                        uint16 count = ReadMacInt16(param + csCount);
542                          rgb_color *s_pal;
543                          if ((VModes[cur_mode].viAppleMode == APPLE_32_BIT)||
544                                  (VModes[cur_mode].viAppleMode == APPLE_16_BIT)) {
545                                  D(bug("ERROR: GetEntries in direct mode \n"));
546                                  return statusErr;
547                          }
548 <                        if (start >= 0) {       // indexed get
549 <                                s_pal = &(mac_pal[start]);
548 >
549 >                        if (start == 0xffff) {          // Indexed
550                                  for (uint16 i=0;i<count;i++) {
551 <                                        (*d_pal).red=(uint16)((*s_pal).red)*0x101;
552 <                                        (*d_pal).green=(uint16)((*s_pal).green)*0x101;
553 <                                        (*d_pal).blue=(uint16)((*s_pal).blue)*0x101;
554 <                                        d_pal++; s_pal++;
551 >                                        s_pal = mac_pal + (ReadMacInt16(d_pal + csValue) & 0xff);
552 >                                        uint8 red = (*s_pal).red;
553 >                                        uint8 green = (*s_pal).green;
554 >                                        uint8 blue = (*s_pal).blue;
555 >                                        WriteMacInt16(d_pal + csRed, red * 0x0101);
556 >                                        WriteMacInt16(d_pal + csGreen, green * 0x0101);
557 >                                        WriteMacInt16(d_pal + csBlue, blue * 0x0101);
558 >                                        d_pal += 8;
559                                  }
560 <                        } else {                                                                // selected set
560 >                        } else {                                        // Sequential
561 >                                if (start + count > 255)
562 >                                        return paramErr;
563 >                                s_pal = mac_pal + start;
564                                  for (uint16 i=0;i<count;i++) {
565 <                                        s_pal = &(mac_pal[(*d_pal).value]);
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++;
565 >                                        uint8 red = (*s_pal).red;
566 >                                        uint8 green = (*s_pal).green;
567 >                                        uint8 blue = (*s_pal).blue;
568 >                                        s_pal++;
569 >                                        WriteMacInt16(d_pal + csRed, red * 0x0101);
570 >                                        WriteMacInt16(d_pal + csGreen, green * 0x0101);
571 >                                        WriteMacInt16(d_pal + csBlue, blue * 0x0101);
572 >                                        d_pal += 8;
573                                  }
574                          };
575                          return noErr;
# Line 687 | Line 688 | static int16 VideoStatus(uint32 pb, VidL
688                                          WriteMacInt32(param + csVerticalLines, 768);
689                                          WriteMacInt32(param + csRefreshRate, 75<<16);
690                                          break;
691 +                                case APPLE_1152x768:
692 +                                        WriteMacInt32(param + csHorizontalPixels, 1152);
693 +                                        WriteMacInt32(param + csVerticalLines, 768);
694 +                                        WriteMacInt32(param + csRefreshRate, 75<<16);
695 +                                        break;
696                                  case APPLE_1152x900:
697                                          WriteMacInt32(param + csHorizontalPixels, 1152);
698                                          WriteMacInt32(param + csVerticalLines, 900);
# Line 805 | Line 811 | static int16 VideoStatus(uint32 pb, VidL
811                                                  case APPLE_1024x768:
812                                                          timing = timingVESA_1024x768_75hz;
813                                                          break;
814 +                                                case APPLE_1152x768:
815 +                                                        timing = timingApple_1152x870_75hz; // FIXME
816 +                                                        break;
817                                                  case APPLE_1152x900:
818                                                          timing = timingApple_1152x870_75hz;
819                                                          break;
# Line 865 | Line 874 | static int16 VideoClose(uint32 pb, VidLo
874   *  Native (PCI) driver entry
875   */
876  
877 < int16 VideoDoDriverIO(void *spaceID, void *commandID, void *commandContents, uint32 commandCode, uint32 commandKind)
877 > int16 VideoDoDriverIO(uint32 spaceID, uint32 commandID, uint32 commandContents, uint32 commandCode, uint32 commandKind)
878   {
879 < //      D(bug("VideoDoDriverIO space %p, command %p, contents %p, code %d, kind %d\n", spaceID, commandID, commandContents, commandCode, commandKind));
879 > //      D(bug("VideoDoDriverIO space %08x, command %08x, contents %08x, code %d, kind %d\n", spaceID, commandID, commandContents, commandCode, commandKind));
880          int16 err = noErr;
881  
882          switch (commandCode) {
883                  case kInitializeCommand:
884                  case kReplaceCommand:
885 <                        if (private_data != NULL)       // Might be left over from a reboot
886 <                                delete private_data->gammaTable;
885 >                        if (private_data != NULL) {     // Might be left over from a reboot
886 >                                if (private_data->gammaTable)
887 >                                        Mac_sysfree(private_data->gammaTable);
888 >                        }
889                          delete private_data;
890  
891 <                        iocic_tvect = (uint32)FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete");
891 >                        iocic_tvect = FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete");
892                          D(bug("IOCommandIsComplete TVECT at %08lx\n", iocic_tvect));
893                          if (iocic_tvect == 0) {
894                                  printf("FATAL: VideoDoDriverIO(): Can't find IOCommandIsComplete()\n");
895                                  err = -1;
896                                  break;
897                          }
898 <                        vslnewis_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\026VSLNewInterruptService");
898 >                        vslnewis_tvect = FindLibSymbol("\020VideoServicesLib", "\026VSLNewInterruptService");
899                          D(bug("VSLNewInterruptService TVECT at %08lx\n", vslnewis_tvect));
900                          if (vslnewis_tvect == 0) {
901                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLNewInterruptService()\n");
902                                  err = -1;
903                                  break;
904                          }
905 <                        vsldisposeis_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\032VSLDisposeInterruptService");
905 >                        vsldisposeis_tvect = FindLibSymbol("\020VideoServicesLib", "\032VSLDisposeInterruptService");
906                          D(bug("VSLDisposeInterruptService TVECT at %08lx\n", vsldisposeis_tvect));
907                          if (vsldisposeis_tvect == 0) {
908                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLDisposeInterruptService()\n");
909                                  err = -1;
910                                  break;
911                          }
912 <                        vsldois_tvect = (uint32)FindLibSymbol("\020VideoServicesLib", "\025VSLDoInterruptService");
912 >                        vsldois_tvect = FindLibSymbol("\020VideoServicesLib", "\025VSLDoInterruptService");
913                          D(bug("VSLDoInterruptService TVECT at %08lx\n", vsldois_tvect));
914                          if (vsldois_tvect == 0) {
915                                  printf("FATAL: VideoDoDriverIO(): Can't find VSLDoInterruptService()\n");
916                                  err = -1;
917                                  break;
918                          }
919 <                        nqdmisc_tvect = (uint32)FindLibSymbol("\014InterfaceLib", "\007NQDMisc");
919 >                        nqdmisc_tvect = FindLibSymbol("\014InterfaceLib", "\007NQDMisc");
920                          D(bug("NQDMisc TVECT at %08lx\n", nqdmisc_tvect));
921                          if (nqdmisc_tvect == 0) {
922                                  printf("FATAL: VideoDoDriverIO(): Can't find NQDMisc()\n");
# Line 914 | Line 925 | int16 VideoDoDriverIO(void *spaceID, voi
925                          }
926  
927                          private_data = new VidLocals;
928 <                        private_data->gammaTable = NULL;
929 <                        memcpy(private_data->regEntryID, (uint8 *)commandContents + 2, 16);     // DriverInitInfo.deviceEntry
928 >                        private_data->gammaTable = 0;
929 >                        Mac2Host_memcpy(&private_data->regEntryID, commandContents + 2, 16);    // DriverInitInfo.deviceEntry
930                          private_data->interruptsEnabled = false;        // Disable interrupts
931                          break;
932  
933                  case kFinalizeCommand:
934                  case kSupersededCommand:
935 <                        if (private_data != NULL)
936 <                                delete private_data->gammaTable;
935 >                        if (private_data != NULL && private_data->gammaTable)
936 >                                Mac_sysfree(private_data->gammaTable);
937                          delete private_data;
938                          private_data = NULL;
939                          break;
940  
941                  case kOpenCommand:
942 <                        err = VideoOpen((uint32)commandContents, private_data);
942 >                        err = VideoOpen(commandContents, private_data);
943                          break;
944  
945                  case kCloseCommand:
946 <                        err = VideoClose((uint32)commandContents, private_data);
946 >                        err = VideoClose(commandContents, private_data);
947                          break;
948  
949                  case kControlCommand:
950 <                        err = VideoControl((uint32)commandContents, private_data);
950 >                        err = VideoControl(commandContents, private_data);
951                          break;
952  
953                  case kStatusCommand:
954 <                        err = VideoStatus((uint32)commandContents, private_data);
954 >                        err = VideoStatus(commandContents, private_data);
955                          break;
956  
957                  case kReadCommand:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines