1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | *␊ |
24 | * Copyright 1993 NeXT, Inc. All rights reserved.␊ |
25 | *␊ |
26 | */␊ |
27 | ␊ |
28 | #include "boot.h"␊ |
29 | #include "vbe.h"␊ |
30 | #include "appleClut8.h"␊ |
31 | #include "gui.h"␊ |
32 | #include "IOHibernatePrivate.h"␊ |
33 | #include "../modules/Resolution/include/edid.h"␊ |
34 | ␊ |
35 | #if DEBUG␊ |
36 | #define DBG(x...)␉printf(x)␊ |
37 | #else␊ |
38 | #define DBG(x...)␉msglog(x)␊ |
39 | #endif␊ |
40 | ␊ |
41 | /*␊ |
42 | * for spinning disk␊ |
43 | */␊ |
44 | static int currentIndicator = 0;␊ |
45 | ␊ |
46 | int previewTotalSectors = 0;␊ |
47 | int previewLoadedSectors = 0;␊ |
48 | uint8_t *previewSaveunder = 0;␊ |
49 | ␊ |
50 | static uint16_t GraphicsModeCurrent = 0;␊ |
51 | ␊ |
52 | #define VIDEO(x) (bootArgs->Video.v_ ## x)␊ |
53 | ␊ |
54 | //==========================================================================␊ |
55 | // getVBEVideoRam␊ |
56 | ␊ |
57 | uint32_t getVBEVideoRam()␊ |
58 | {␊ |
59 | ␉VBEInfoBlock vbeInfo;␊ |
60 | ␉int err /*, small */;␊ |
61 | ␊ |
62 | ␉bzero( &vbeInfo, sizeof(vbeInfo) );␊ |
63 | ␉strcpy( (char*)&vbeInfo, "VBE2" );␊ |
64 | ␉err = getVBEInfo( &vbeInfo );␊ |
65 | ␉if (err != errSuccess)␊ |
66 | ␉␉return 0;␊ |
67 | ␊ |
68 | ␉if ( strncmp( (char *)vbeInfo.VESASignature, "VESA", 4 ) )␊ |
69 | ␉␉return 0;␊ |
70 | ␊ |
71 | ␉// small = (vbeInfo.TotalMemory < 16);␊ |
72 | ␊ |
73 | ␉return vbeInfo.TotalMemory * 64 * 1024;␊ |
74 | }␊ |
75 | ␊ |
76 | //==========================================================================␊ |
77 | // getVBEInfoString␊ |
78 | ␊ |
79 | char *getVBEInfoString()␊ |
80 | {␊ |
81 | ␉VBEInfoBlock vbeInfo;␊ |
82 | ␉int err, small;␊ |
83 | ␉char* buff = NULL;␊ |
84 | ␊ |
85 | ␉bzero( &vbeInfo, sizeof(vbeInfo) );␊ |
86 | ␉strcpy( (char*)&vbeInfo, "VBE2" );␊ |
87 | ␉err = getVBEInfo( &vbeInfo );␊ |
88 | ␉if (err != errSuccess)␊ |
89 | ␉{␊ |
90 | ␉␉return 0;␊ |
91 | ␉}␊ |
92 | ␊ |
93 | ␉if ( strncmp( (char *)vbeInfo.VESASignature, "VESA", 4 ) )␊ |
94 | ␉{␊ |
95 | ␉␉return 0;␊ |
96 | ␉}␊ |
97 | ␊ |
98 | ␉buff = malloc(sizeof(char) * 256);␊ |
99 | ␉if (!buff)␊ |
100 | ␉{␊ |
101 | ␉␉return 0;␊ |
102 | ␉}␊ |
103 | ␊ |
104 | ␉small = (vbeInfo.TotalMemory < 16);␊ |
105 | ␊ |
106 | ␉snprintf(buff, 256,␊ |
107 | ␉␉"VESA v%d.%d %d%s (%s)\n",␊ |
108 | ␉␉vbeInfo.VESAVersion >> 8,␊ |
109 | ␉␉vbeInfo.VESAVersion & 0xf,␊ |
110 | ␉␉small ? (vbeInfo.TotalMemory * 64) : (vbeInfo.TotalMemory / 16),␊ |
111 | ␉␉small ? "KB" : "MB",␊ |
112 | ␉␉VBEDecodeFP(const char *, vbeInfo.OEMStringPtr) );␊ |
113 | ␊ |
114 | ␉return buff;␊ |
115 | }␊ |
116 | ␊ |
117 | //==========================================================================␊ |
118 | //␊ |
119 | ␊ |
120 | void ␊ |
121 | printVBEModeInfo()␊ |
122 | {␊ |
123 | ␉VBEInfoBlock vbeInfo;␊ |
124 | ␉unsigned short * modePtr;␊ |
125 | ␉VBEModeInfoBlock modeInfo;␊ |
126 | ␉int err;␊ |
127 | ␉int line;␊ |
128 | ␉char* vbeInfoString = NULL;␊ |
129 | ␊ |
130 | ␉bzero( &vbeInfo, sizeof(vbeInfo) );␊ |
131 | ␉strcpy( (char*)&vbeInfo, "VBE2" );␊ |
132 | ␉err = getVBEInfo( &vbeInfo );␊ |
133 | ␉if ( err != errSuccess ) {␊ |
134 | ␉␉return;␊ |
135 | ␉}␊ |
136 | ␊ |
137 | ␉line = 0;␊ |
138 | ␊ |
139 | ␉// Activate and clear page 1␊ |
140 | ␉setActiveDisplayPage(1);␊ |
141 | ␉clearScreenRows(0, 24);␊ |
142 | ␉setCursorPosition( 0, 0, 1 );␊ |
143 | ␊ |
144 | ␉vbeInfoString = getVBEInfoString();␊ |
145 | ␉if (!vbeInfoString) {␊ |
146 | ␉␉error("[printVBEModeInfo] Error: getVBEInfoString failed\n");␊ |
147 | ␉␉return;␊ |
148 | ␉}␊ |
149 | ␉verbose("vbeInfoString: %s", vbeInfoString);␊ |
150 | ␉free(vbeInfoString);␊ |
151 | ␉vbeInfoString = NULL;␊ |
152 | ␊ |
153 | ␉verbose("Video modes supported:\n", VBEDecodeFP(const char *, vbeInfo.OEMStringPtr));␊ |
154 | ␊ |
155 | ␉// Loop through the mode list, and find the matching mode.␊ |
156 | ␊ |
157 | ␉for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr );␊ |
158 | *modePtr != modeEndOfList; modePtr++ )␊ |
159 | ␉{␊ |
160 | ␉␉// Get mode information.␊ |
161 | ␊ |
162 | ␉␉bzero( &modeInfo, sizeof(modeInfo) );␊ |
163 | ␉␉err = getVBEModeInfo( *modePtr, &modeInfo );␊ |
164 | ␉␉if ( err != errSuccess )␊ |
165 | ␉␉{␊ |
166 | ␉␉␉continue;␊ |
167 | ␉␉}␊ |
168 | ␊ |
169 | ␉␉verbose("Mode %x: %dx%dx%d mm:%d attr:%x\n",␊ |
170 | ␉␉␉*modePtr, modeInfo.XResolution, modeInfo.YResolution,␊ |
171 | ␉␉␉modeInfo.BitsPerPixel, modeInfo.MemoryModel,␊ |
172 | ␉␉␉modeInfo.ModeAttributes);␊ |
173 | ␊ |
174 | ␉␉if (line++ >= 20)␊ |
175 | ␉␉{␊ |
176 | #if DEBUG␊ |
177 | pause("\n[DEBUG_GFX] ");␊ |
178 | #endif␊ |
179 | ␉␉␉line = 0;␊ |
180 | ␉␉␉clearScreenRows(0, 24);␊ |
181 | ␉␉␉setCursorPosition( 0, 0, 1 );␊ |
182 | ␉␉}␊ |
183 | ␉}␊ |
184 | ␊ |
185 | ␉if (line != 0)␊ |
186 | ␉{␊ |
187 | #if DEBUG␊ |
188 | pause("\n[DEBUG_GFX] ");␊ |
189 | #endif␊ |
190 | ␉}␊ |
191 | ␊ |
192 | ␉setActiveDisplayPage(0);␊ |
193 | }␊ |
194 | ␊ |
195 | //==============================================================================␊ |
196 | ␊ |
197 | char *getVBEModeInfoString()␊ |
198 | {␊ |
199 | ␉VBEInfoBlock vbeInfo;␊ |
200 | ␉unsigned short * modePtr;␊ |
201 | ␉VBEModeInfoBlock modeInfo;␊ |
202 | ␉int err;␊ |
203 | ␊ |
204 | ␉bzero( &vbeInfo, sizeof(vbeInfo) );␊ |
205 | ␉strcpy( (char*)&vbeInfo, "VBE2" );␊ |
206 | ␉err = getVBEInfo( &vbeInfo );␊ |
207 | ␉if ( err != errSuccess )␊ |
208 | ␉{␊ |
209 | ␉␉return 0;␊ |
210 | ␉}␊ |
211 | ␊ |
212 | ␉char *buff=malloc(sizeof(char)*3072);␊ |
213 | ␉if(!buff)␊ |
214 | ␉{␊ |
215 | ␉␉return 0;␊ |
216 | ␉}␊ |
217 | ␊ |
218 | ␉int bufflen = 0;␊ |
219 | ␊ |
220 | ␉// Loop through the mode list, and find the matching mode.␊ |
221 | ␉for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr );␊ |
222 | ␉␉(*modePtr != modeEndOfList) && (bufflen < 3072); /* prevent buffer overrun */␊ |
223 | ␉␉modePtr++ )␊ |
224 | ␉{␊ |
225 | ␉␉// Get mode information.␊ |
226 | ␊ |
227 | ␉␉bzero( &modeInfo, sizeof(modeInfo) );␊ |
228 | ␉␉err = getVBEModeInfo( *modePtr, &modeInfo );␊ |
229 | ␉␉if ( err != errSuccess )␊ |
230 | ␉␉{␊ |
231 | ␉␉␉continue;␊ |
232 | ␉␉}␊ |
233 | ␊ |
234 | ␉␉bufflen += ␊ |
235 | ␉␉␉snprintf(buff+bufflen, 3072-bufflen, "Mode %x: %dx%dx%d mm:%d attr:%x\n",␊ |
236 | ␉␉␉*modePtr, modeInfo.XResolution, modeInfo.YResolution,␊ |
237 | ␉␉␉modeInfo.BitsPerPixel, modeInfo.MemoryModel,␊ |
238 | ␉␉␉modeInfo.ModeAttributes);␊ |
239 | ␉}␊ |
240 | ␉return buff;␊ |
241 | }␊ |
242 | ␊ |
243 | //==========================================================================␊ |
244 | // getVESAModeWithProperties␊ |
245 | //␊ |
246 | // Return the VESA mode that matches the properties specified.␊ |
247 | // If a mode is not found, then return the "best" available mode.␊ |
248 | ␊ |
249 | static unsigned short␊ |
250 | getVESAModeWithProperties( unsigned short␉width,␊ |
251 | unsigned short␉height,␊ |
252 | unsigned char␉bitsPerPixel,␊ |
253 | unsigned short␉attributesSet,␊ |
254 | unsigned short␉attributesClear,␊ |
255 | VBEModeInfoBlock␉*outModeInfo,␊ |
256 | unsigned short␉*vesaVersion␊ |
257 | ␉␉␉)␊ |
258 | {␊ |
259 | ␉VBEInfoBlock vbeInfo;␊ |
260 | ␉unsigned short * modePtr;␊ |
261 | ␉VBEModeInfoBlock modeInfo;␊ |
262 | ␉unsigned char modeBitsPerPixel;␊ |
263 | ␉unsigned short matchedMode = modeEndOfList;␊ |
264 | ␉int err;␊ |
265 | ␊ |
266 | ␉// Clear output mode info.␊ |
267 | ␊ |
268 | ␉bzero( outModeInfo, sizeof(*outModeInfo) );␊ |
269 | ␊ |
270 | ␉// Get VBE controller info containing the list of supported modes.␊ |
271 | ␊ |
272 | ␉bzero( &vbeInfo, sizeof(vbeInfo) );␊ |
273 | ␉strcpy( (char*)&vbeInfo, "VBE2" );␊ |
274 | ␉err = getVBEInfo( &vbeInfo );␊ |
275 | ␉if ( err != errSuccess )␊ |
276 | ␉{␊ |
277 | ␉␉return modeEndOfList;␊ |
278 | ␉}␊ |
279 | ␊ |
280 | ␉// Report the VESA major/minor version number.␊ |
281 | ␊ |
282 | ␉if (vesaVersion)␊ |
283 | ␉{␊ |
284 | ␉␉*vesaVersion = vbeInfo.VESAVersion;␊ |
285 | ␉}␊ |
286 | ␊ |
287 | ␉// Loop through the mode list, and find the matching mode.␊ |
288 | ␊ |
289 | //#if DEBUG␊ |
290 | ␉verbose("\nGraphics Modes [VESA %d.%d %dMB mode=0x%04X]:\n", vbeInfo.VESAVersion >> 8, vbeInfo.VESAVersion & 0xf, (vbeInfo.TotalMemory * 64)/1024, getCurrentGraphicsMode());␊ |
291 | //#endif␊ |
292 | ␊ |
293 | ␉for ( modePtr = VBEDecodeFP(unsigned short *, vbeInfo.VideoModePtr); *modePtr != modeEndOfList; modePtr++ )␊ |
294 | ␉{␊ |
295 | ␉␉// Get mode information.␊ |
296 | ␊ |
297 | ␉␉bzero( &modeInfo, sizeof(modeInfo) );␊ |
298 | ␊ |
299 | ␉␉err = getVBEModeInfo( *modePtr, &modeInfo );␊ |
300 | ␉␉if ( err != errSuccess )␊ |
301 | ␉␉{␊ |
302 | ␉␉␉verbose("\t%x: mode not suported. [ERROR: %d]\n", *modePtr, err);␊ |
303 | ␉␉␉continue;␊ |
304 | ␉␉}␊ |
305 | ␊ |
306 | //#if DEBUG␊ |
307 | ␉␉verbose("\t0x%04X: res=%dx%dx%d, mm=%d, attr=0x%04X %s\n",␊ |
308 | *modePtr, modeInfo.XResolution, modeInfo.YResolution,␊ |
309 | modeInfo.BitsPerPixel, modeInfo.MemoryModel,␊ |
310 | modeInfo.ModeAttributes, (*modePtr == GraphicsModeCurrent)? "<-":"");␊ |
311 | //#endif␊ |
312 | ␊ |
313 | ␉␉// Filter out unwanted modes based on mode attributes.␊ |
314 | ␊ |
315 | ␉␉if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet )␊ |
316 | || ( ( modeInfo.ModeAttributes & attributesClear ) != 0 ) )␊ |
317 | ␉␉{␊ |
318 | ␉␉␉continue;␊ |
319 | ␉␉}␊ |
320 | ␊ |
321 | ␉␉// Pixel depth in bits.␊ |
322 | ␊ |
323 | ␉␉modeBitsPerPixel = modeInfo.BitsPerPixel;␊ |
324 | ␊ |
325 | ␉␉if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) )␊ |
326 | ␉␉{␊ |
327 | ␉␉␉// Text mode, 16 colors.␊ |
328 | ␉␉}␊ |
329 | ␉␉else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) )␊ |
330 | ␉␉{␊ |
331 | ␉␉␉// Packed pixel, 256 colors.␊ |
332 | ␉␉}␊ |
333 | ␉␉else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) )␊ |
334 | ␉␉␉&& ( modeInfo.MemoryModel == 6 )␊ |
335 | ␉␉␉&& ( modeInfo.RedMaskSize == 5 )␊ |
336 | ␉␉␉&& ( modeInfo.GreenMaskSize == 5 )␊ |
337 | ␉␉␉&& ( modeInfo.BlueMaskSize == 5 ) )␊ |
338 | ␉␉{␊ |
339 | ␉␉␉// Direct color, 16 bpp (1:5:5:5).␊ |
340 | ␉␉␉modeInfo.BitsPerPixel = modeBitsPerPixel = 16;␊ |
341 | ␉␉}␊ |
342 | ␉␉else if ( ( modeBitsPerPixel == 32 )␊ |
343 | ␉␉␉&& ( modeInfo.MemoryModel == 6 )␊ |
344 | ␉␉␉&& ( modeInfo.RedMaskSize == 8 )␊ |
345 | ␉␉␉&& ( modeInfo.GreenMaskSize == 8 )␊ |
346 | ␉␉␉&& ( modeInfo.BlueMaskSize == 8 ) )␊ |
347 | ␉␉{␊ |
348 | ␉␉␉// Direct color, 32 bpp (8:8:8:8).␊ |
349 | ␉␉}␊ |
350 | ␉␉else␊ |
351 | ␉␉{␊ |
352 | ␉␉␉continue; // Not a supported mode.␊ |
353 | ␉␉}␊ |
354 | ␊ |
355 | ␉␉// Modes larger than the specified dimensions are skipped.␊ |
356 | ␊ |
357 | ␉␉if ( ( modeInfo.XResolution > width ) ||␊ |
358 | ␉␉␉( modeInfo.YResolution > height ) )␊ |
359 | ␉␉{␊ |
360 | ␉␉␉continue;␊ |
361 | ␉␉}␊ |
362 | ␊ |
363 | ␉␉// Perfect match, we're done looking.␊ |
364 | ␊ |
365 | ␉␉if ( ( modeInfo.XResolution == width ) &&␊ |
366 | ␉␉␉( modeInfo.YResolution == height ) &&␊ |
367 | ␉␉␉( modeBitsPerPixel == bitsPerPixel ) )␊ |
368 | ␉␉{␊ |
369 | ␉␉␉matchedMode = *modePtr;␊ |
370 | ␉␉␉bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) );␊ |
371 | ␉␉␉break;␊ |
372 | ␉␉}␊ |
373 | ␊ |
374 | ␉␉// Save the next "best" mode in case a perfect match is not found.␊ |
375 | ␊ |
376 | ␉␉if ( modeInfo.XResolution == outModeInfo->XResolution &&␊ |
377 | ␉␉␉modeInfo.YResolution == outModeInfo->YResolution &&␊ |
378 | ␉␉␉modeBitsPerPixel <= outModeInfo->BitsPerPixel )␊ |
379 | ␉␉{␊ |
380 | ␉␉␉continue; // Saved mode has more depth.␊ |
381 | ␉␉}␊ |
382 | ␊ |
383 | ␉␉if ( modeInfo.XResolution < outModeInfo->XResolution ||␊ |
384 | ␉␉␉modeInfo.YResolution < outModeInfo->YResolution ||␊ |
385 | ␉␉␉modeBitsPerPixel < outModeInfo->BitsPerPixel )␊ |
386 | ␉␉{␊ |
387 | ␉␉␉continue; // Saved mode has more resolution.␊ |
388 | ␉␉}␊ |
389 | ␊ |
390 | ␉␉matchedMode = *modePtr;␊ |
391 | ␉␉bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) );␊ |
392 | ␉}␊ |
393 | ␊ |
394 | ␉return matchedMode;␊ |
395 | }␊ |
396 | ␊ |
397 | //==========================================================================␊ |
398 | // setupPalette␊ |
399 | ␊ |
400 | static void setupPalette( VBEPalette * p, const unsigned char * g )␊ |
401 | {␊ |
402 | int i;␊ |
403 | unsigned char * source = (unsigned char *) g;␊ |
404 | ␊ |
405 | for (i = 0; i < 256; i++)␊ |
406 | {␊ |
407 | (*p)[i] = 0;␊ |
408 | (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 16; // Red␊ |
409 | (*p)[i] |= ((unsigned long)((*source++) >> 2)) << 8; // Green␊ |
410 | (*p)[i] |= ((unsigned long)((*source++) >> 2)); // Blue␊ |
411 | }␊ |
412 | }␊ |
413 | ␊ |
414 | //==========================================================================␊ |
415 | // Simple decompressor for boot images encoded in RLE format.␊ |
416 | ␊ |
417 | char * decodeRLE( const void * rleData, int rleBlocks, int outBytes )␊ |
418 | {␊ |
419 | char *out, *cp;␊ |
420 | ␊ |
421 | struct RLEBlock {␊ |
422 | unsigned char count;␊ |
423 | unsigned char value;␊ |
424 | } * bp = (struct RLEBlock *) rleData;␊ |
425 | ␊ |
426 | out = cp = malloc( outBytes );␊ |
427 | if ( out == NULL ) return NULL;␊ |
428 | ␊ |
429 | while ( rleBlocks-- )␊ |
430 | {␊ |
431 | memset( cp, bp->value, bp->count );␊ |
432 | cp += bp->count;␊ |
433 | bp++;␊ |
434 | }␊ |
435 | ␊ |
436 | return out;␊ |
437 | }␊ |
438 | ␊ |
439 | //==========================================================================␊ |
440 | // getCurrentGraphicsMode␊ |
441 | ␊ |
442 | uint16_t getCurrentGraphicsMode()␊ |
443 | {␊ |
444 | ␉if (getVBECurrentMode(&GraphicsModeCurrent) != errSuccess)␊ |
445 | ␉␉GraphicsModeCurrent = 0;␊ |
446 | ␉GraphicsModeCurrent &= 0x3FFF;␊ |
447 | ␉return GraphicsModeCurrent;␊ |
448 | }␊ |
449 | ␊ |
450 | //==========================================================================␊ |
451 | // getCurrentEDID␊ |
452 | ␊ |
453 | int getCurrentEDID()␊ |
454 | {␊ |
455 | ␉struct EDID edid;␊ |
456 | ␉//edid_mode mode;␊ |
457 | ␊ |
458 | ␉uint8_t status = getVBEEDID(&edid);␊ |
459 | ␊ |
460 | ␉if (status == errSuccess)␊ |
461 | ␉{␊ |
462 | /*␊ |
463 | if (fb_parse_edid(&edid, &mode)) {␊ |
464 | DBG("EDID first timing block info:\n");␊ |
465 | DBG("\tx_res=%d(native)\n", mode.h_active);␊ |
466 | DBG("\ty_res=%d(native)\n", mode.v_active);␊ |
467 | DBG("\tx_sync_offset=%d\n", mode.h_sync_offset);␊ |
468 | DBG("\tx_sync_width=%d\n", mode.h_sync_width);␊ |
469 | DBG("\ty_sync_offset=%d\n", mode.v_sync_offset);␊ |
470 | DBG("\ty_sync_width=%d\n", mode.v_sync_width);␊ |
471 | DBG("\tx_blanking=%d\n", mode.h_blanking);␊ |
472 | DBG("\ty_blanking=%d\n", mode.v_blanking);␊ |
473 | DBG("\tpixel_clock=%d\n", mode.pixel_clock);␊ |
474 | } else {␊ |
475 | DBG("[ERROR: 0x%02X] Failed to parse EDID!\n", status);␊ |
476 | }␊ |
477 | DBG("EDID read!\n", status);␊ |
478 | */␊ |
479 | ␉}␊ |
480 | ␉else␊ |
481 | ␉{␊ |
482 | ␉␉verbose("Failed to get EDID! [ERROR: 0x%02X]\n", status);␊ |
483 | ␉}␊ |
484 | ␊ |
485 | ␉return status;␊ |
486 | ␊ |
487 | }␊ |
488 | //==========================================================================␊ |
489 | // setVESAGraphicsMode␊ |
490 | ␊ |
491 | static int␊ |
492 | setVESAGraphicsMode( unsigned short width,␊ |
493 | unsigned short height,␊ |
494 | unsigned char bitsPerPixel,␊ |
495 | unsigned short refreshRate )␊ |
496 | {␊ |
497 | ␉VBEModeInfoBlock minfo;␊ |
498 | ␉unsigned short modeOld, mode;␊ |
499 | ␉unsigned short vesaVersion;␊ |
500 | ␉int err = errFuncNotSupported;␊ |
501 | ␊ |
502 | ␉modeOld = getCurrentGraphicsMode();␊ |
503 | ␉do {␊ |
504 | ␉␉mode = getVESAModeWithProperties( width, height, bitsPerPixel,␊ |
505 | maColorModeBit |␊ |
506 | maModeIsSupportedBit |␊ |
507 | maGraphicsModeBit |␊ |
508 | maLinearFrameBufferAvailBit,␊ |
509 | 0,␊ |
510 | &minfo, &vesaVersion );␊ |
511 | ␉␉if ( mode == modeEndOfList )␊ |
512 | ␉␉{␊ |
513 | ␉␉␉break;␊ |
514 | ␉␉}␊ |
515 | ␊ |
516 | //␊ |
517 | // FIXME : generateCRTCTiming() causes crash.␊ |
518 | //␊ |
519 | ␊ |
520 | // if ( (vesaVersion >> 8) >= 3 && refreshRate >= 60 &&␊ |
521 | // (gBootMode & kBootModeSafe) == 0 )␊ |
522 | // {␊ |
523 | // VBECRTCInfoBlock timing;␊ |
524 | // ␊ |
525 | // // Generate CRTC timing for given refresh rate.␊ |
526 | // ␊ |
527 | // generateCRTCTiming( minfo.XResolution, minfo.YResolution,␊ |
528 | // refreshRate, kCRTCParamRefreshRate,␊ |
529 | // &timing );␊ |
530 | // ␊ |
531 | // // Find the actual pixel clock supported by the hardware.␊ |
532 | // ␊ |
533 | // getVBEPixelClock( mode, &timing.PixelClock );␊ |
534 | // ␊ |
535 | // // Re-compute CRTC timing based on actual pixel clock.␊ |
536 | // ␊ |
537 | // generateCRTCTiming( minfo.XResolution, minfo.YResolution,␊ |
538 | // timing.PixelClock, kCRTCParamPixelClock,␊ |
539 | // &timing );␊ |
540 | // ␊ |
541 | // // Set the video mode and use specified CRTC timing.␊ |
542 | // ␊ |
543 | // err = setVBEMode( mode | kLinearFrameBufferBit |␊ |
544 | // kCustomRefreshRateBit, &timing );␊ |
545 | // }␊ |
546 | // else␊ |
547 | // {␊ |
548 | // // Set the mode with default refresh rate.␊ |
549 | // ␊ |
550 | // err = setVBEMode( mode | kLinearFrameBufferBit, NULL );␊ |
551 | // }␊ |
552 | ␊ |
553 | // Set the mode with default refresh rate.␊ |
554 | ␊ |
555 | err = setVBEMode(mode | kLinearFrameBufferBit, NULL);␊ |
556 | ␊ |
557 | if (err != errSuccess)␊ |
558 | {␊ |
559 | break;␊ |
560 | }␊ |
561 | ␊ |
562 | verbose("Succesfuly set mode: 0x%04X (old mode: 0x%04X)\n", getCurrentGraphicsMode(), modeOld);␊ |
563 | ␊ |
564 | // Set 8-bit color palette.␊ |
565 | ␊ |
566 | if ( minfo.BitsPerPixel == 8 )␊ |
567 | {␊ |
568 | VBEPalette palette;␊ |
569 | setupPalette( &palette, appleClut8 );␊ |
570 | if ((err = setVBEPalette(palette)) != errSuccess)␊ |
571 | {␊ |
572 | break;␊ |
573 | }␊ |
574 | }␊ |
575 | ␊ |
576 | // Is this required for buggy Video BIOS implementations?␊ |
577 | // On which adapter?␊ |
578 | ␊ |
579 | if ( minfo.BytesPerScanline == 0 )␊ |
580 | minfo.BytesPerScanline = ( minfo.XResolution *␊ |
581 | minfo.BitsPerPixel ) >> 3;␊ |
582 | ␊ |
583 | // Update KernBootStruct using info provided by the selected␊ |
584 | // VESA mode.␊ |
585 | ␊ |
586 | bootArgs->Video.v_display = GRAPHICS_MODE;␊ |
587 | bootArgs->Video.v_width = minfo.XResolution;␊ |
588 | bootArgs->Video.v_height = minfo.YResolution;␊ |
589 | bootArgs->Video.v_depth = minfo.BitsPerPixel;␊ |
590 | bootArgs->Video.v_rowBytes = minfo.BytesPerScanline;␊ |
591 | bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);␊ |
592 | ␊ |
593 | ␉} while ( 0 );␊ |
594 | ␊ |
595 | return err;␊ |
596 | }␊ |
597 | ␊ |
598 | //==============================================================================␊ |
599 | ␊ |
600 | int convertImage( unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData )␊ |
601 | {␊ |
602 | int cnt;␊ |
603 | unsigned char *img = 0;␊ |
604 | unsigned short *img16;␊ |
605 | unsigned long *img32;␊ |
606 | ␊ |
607 | switch ( VIDEO(depth) ) {␊ |
608 | case 16 :␊ |
609 | img16 = malloc(width * height * 2);␊ |
610 | if ( !img16 ) break;␊ |
611 | for (cnt = 0; cnt < (width * height); cnt++)␊ |
612 | img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16);␊ |
613 | img = (unsigned char *)img16;␊ |
614 | break;␊ |
615 | ␊ |
616 | case 32 :␊ |
617 | img32 = malloc(width * height * 4);␊ |
618 | if ( !img32 ) break;␊ |
619 | for (cnt = 0; cnt < (width * height); cnt++)␊ |
620 | img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32);␊ |
621 | img = (unsigned char *)img32;␊ |
622 | break;␊ |
623 | ␊ |
624 | default :␊ |
625 | img = malloc(width * height);␊ |
626 | bcopy(imageData, img, width * height);␊ |
627 | break;␊ |
628 | }␊ |
629 | *newImageData = img;␊ |
630 | return 0;␊ |
631 | }␊ |
632 | ␊ |
633 | //==============================================================================␊ |
634 | ␊ |
635 | int loadPngImage(const char *filename, uint16_t *width, uint16_t *height,␊ |
636 | uint8_t **imageData)␊ |
637 | {␊ |
638 | uint8_t *pngData = NULL;␊ |
639 | int pngFile = 0, pngSize;␊ |
640 | PNG_info_t *info;␊ |
641 | int error = 0;␊ |
642 | ␊ |
643 | pngFile = open_bvdev("bt(0,0)", filename, 0);␊ |
644 | if (pngFile == -1) {␊ |
645 | error = -1;␊ |
646 | goto failed;␊ |
647 | }␊ |
648 | pngSize = file_size(pngFile);␊ |
649 | if (!pngSize) {␊ |
650 | error = -1;␊ |
651 | goto failed;␊ |
652 | }␊ |
653 | pngData = malloc(pngSize);␊ |
654 | if (read(pngFile, (char *) pngData, pngSize) != pngSize) {␊ |
655 | error = -1;␊ |
656 | goto failed;␊ |
657 | }␊ |
658 | ␊ |
659 | PNG_error = -1;␊ |
660 | info = PNG_decode(pngData, pngSize);␊ |
661 | if (PNG_error != 0) {␊ |
662 | error = PNG_error;␊ |
663 | goto failed;␊ |
664 | } else if ((info->width > 0xffff) || (info->height > 0xffff)) {␊ |
665 | error = -1;␊ |
666 | goto failed;␊ |
667 | } else if ((info->width * info->height * 4) != info->image->size) {␊ |
668 | error = -1;␊ |
669 | goto failed;␊ |
670 | }␊ |
671 | ␉uint8_t *result = malloc(info->width*4*info->height);␊ |
672 | *width = info->width;␊ |
673 | *height = info->height;␊ |
674 | ␉memcpy(result, info->image->data, info->width*4*info->height);␊ |
675 | ␉*imageData = result;␊ |
676 | ␊ |
677 | failed:␊ |
678 | ␉png_alloc_free_all();␊ |
679 | if (pngData)␊ |
680 | free(pngData);␊ |
681 | if (pngFile != -1)␊ |
682 | close(pngFile);␊ |
683 | ␊ |
684 | return error;␊ |
685 | }␊ |
686 | ␊ |
687 | //==============================================================================␊ |
688 | ␊ |
689 | int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData) {␊ |
690 | PNG_info_t *info;␊ |
691 | int error = 0;␊ |
692 | ␉␊ |
693 | PNG_error = -1;␊ |
694 | info = PNG_decode(pngData, pngSize);␊ |
695 | ␉if (PNG_error != 0) {␊ |
696 | error = PNG_error;␊ |
697 | goto failed;␊ |
698 | } else if ((info->width > 0xffff) || (info->height > 0xffff)) {␊ |
699 | error = -1;␊ |
700 | goto failed;␊ |
701 | } else if ((info->width * info->height * 4) != info->image->size) {␊ |
702 | error = -1;␊ |
703 | goto failed;␊ |
704 | }␊ |
705 | ␉uint8_t *result = malloc(info->width*4*info->height);␊ |
706 | ␉*width = info->width;␊ |
707 | *height = info->height;␊ |
708 | ␉memcpy(result, info->image->data, info->width*4*info->height);␊ |
709 | ␉*imageData = result;␊ |
710 | ␊ |
711 | failed:␊ |
712 | ␉png_alloc_free_all();␊ |
713 | ␊ |
714 | return error;␊ |
715 | }␊ |
716 | ␊ |
717 | //==============================================================================␊ |
718 | ␊ |
719 | void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height,␊ |
720 | uint8_t *data)␊ |
721 | {␊ |
722 | uint16_t drawWidth;␊ |
723 | uint8_t *vram = (uint8_t *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + 4 * x;␊ |
724 | ␊ |
725 | drawWidth = MIN(width, VIDEO(width) - x);␊ |
726 | height = MIN(height, VIDEO(height) - y);␊ |
727 | while (height--) {␊ |
728 | ␉␉switch (VIDEO (depth))␊ |
729 | ␉␉{␊ |
730 | ␉␉␉case 32: /* Optimized version*/␊ |
731 | ␉␉␉{␊ |
732 | ␉␉␉␉uint32_t s; uint32_t* d; // Source (img) and destination (bkgd) pixels␊ |
733 | ␉␉␉␉uint32_t a; // Alpha␊ |
734 | ␉␉␉␉uint32_t dstrb, dstg, srcrb, srcg, drb, dg, rb, g, tempB; // Intermediate variables␊ |
735 | ␉␉␉␉uint16_t pos;␊ |
736 | ␊ |
737 | ␉␉␉␉for (pos = 0; pos < drawWidth * 4; pos += 4) {␊ |
738 | ␉␉␉␉␉// Fast pseudo-vector alpha blending, adapted from: http://www.stereopsis.com/doubleblend.html␊ |
739 | ␉␉␉␉␉s = *((uint32_t*) (data + pos));␊ |
740 | ␉␉␉␉␉d = (uint32_t*) (vram + pos);␊ |
741 | ␊ |
742 | ␉␉␉␉␉// Flip B and R in source␊ |
743 | ␉␉␉␉␉// TODO: use XCHG and inline assembly to do this in a faster, saner way␊ |
744 | ␉␉␉␉␉tempB = (s & 0xFF0000); // save B␊ |
745 | ␉␉␉␉␉s = (s & 0xFF00FFFF) | ((s & 0xFF) << 16); // put R in B␊ |
746 | ␉␉␉␉␉s = (s & 0xFFFFFF00) | (tempB >> 16); // put B in R␊ |
747 | ␊ |
748 | ␉␉␉␉␉a = (s >> 24) + 1;␊ |
749 | ␊ |
750 | ␉␉␉␉␉dstrb = *d & 0xFF00FF; dstg = *d & 0xFF00;␊ |
751 | ␉␉␉␉␉srcrb = s & 0xFF00FF; srcg = s & 0xFF00;␊ |
752 | ␊ |
753 | ␉␉␉␉␉drb = srcrb - dstrb;␊ |
754 | ␉␉␉␉␉dg = srcg - dstg;␊ |
755 | ␉␉␉␉␉drb *= a; dg *= a;␊ |
756 | ␉␉␉␉␉drb >>= 8; dg >>= 8;␊ |
757 | ␊ |
758 | ␉␉␉␉␉rb = (drb + dstrb) & 0xFF00FF;␊ |
759 | ␉␉␉␉␉g = (dg + dstg) & 0xFF00;␊ |
760 | ␊ |
761 | ␉␉␉␉␉*d = rb | g;␊ |
762 | ␉␉␉␉}␊ |
763 | ␉␉␉}␊ |
764 | ␉␉␉break;␊ |
765 | ␊ |
766 | ␉␉␉default: /*Universal version*/␊ |
767 | ␉␉␉{␊ |
768 | ␉␉␉␉uint32_t s; ␊ |
769 | ␉␉␉␉uint32_t a; // Alpha␊ |
770 | ␉␉␉␉uint32_t dr, dg, db, sr, sg, sb; // Intermediate variables␊ |
771 | ␉␉␉␉uint16_t pos;␊ |
772 | ␉␉␉␉int bpp = (VIDEO (depth) + 7)/8;␊ |
773 | ␊ |
774 | ␉␉␉␉for (pos = 0; pos < drawWidth; pos ++) {␊ |
775 | ␉␉␉␉␉// Fast pseudo-vector alpha blending, adapted from: http://www.stereopsis.com/doubleblend.html␊ |
776 | ␉␉␉␉␉s = *((uint32_t*) (data + 4*pos));␊ |
777 | ␉␉␉␉␉␊ |
778 | ␉␉␉␉␉sb = (s & 0xFF0000) >> 16;␊ |
779 | ␉␉␉␉␉sg = (s & 0xFF00) >> 8;␊ |
780 | ␉␉␉␉␉sr = (s & 0xFF);␊ |
781 | ␉␉␉␉␉␊ |
782 | ␉␉␉␉␉a = (s >> 24) + 1;␊ |
783 | ␊ |
784 | ␉␉␉␉␉switch (VIDEO (depth))␊ |
785 | ␉␉␉␉␉{␊ |
786 | ␉␉␉␉␉␉case 24:␊ |
787 | ␉␉␉␉␉␉␉db = ((*(uint32_t *)(vram + bpp*pos))&0xff);␊ |
788 | ␉␉␉␉␉␉␉dg = ((*(uint32_t *)(vram + bpp*pos))&0xff00)>>8;␊ |
789 | ␉␉␉␉␉␉␉dr = ((*(uint32_t *)(vram + bpp*pos))&0xff0000)>>16;␊ |
790 | ␉␉␉␉␉␉␉break;␊ |
791 | ␉␉␉␉␉␉case 16://16-bit seems to be 15-bit␊ |
792 | /*␉␉␉␉␉␉␉db = ((*(uint16_t *)(vram + bpp*pos))&0x1f)<<3;␊ |
793 | ␉␉␉␉␉␉␉dg = ((*(uint16_t *)(vram + bpp*pos))&0x07e0)>>3;␊ |
794 | ␉␉␉␉␉␉␉dr = ((*(uint16_t *)(vram + bpp*pos))&0xf800)>>8;␊ |
795 | ␉␉␉␉␉␉␉break;␉␉␉␉␉␉␉*/␊ |
796 | ␉␉␉␉␉␉case 15:␊ |
797 | ␉␉␉␉␉␉␉db = ((*(uint16_t *)(vram + bpp*pos))&0x1f)<<3;␊ |
798 | ␉␉␉␉␉␉␉dg = ((*(uint16_t *)(vram + bpp*pos))&0x03e0)>>2;␊ |
799 | ␉␉␉␉␉␉␉dr = ((*(uint16_t *)(vram + bpp*pos))&0x7c00)>>7;␊ |
800 | ␉␉␉␉␉␉␉break;␊ |
801 | ␉␉␉␉␉␉default:␊ |
802 | ␉␉␉␉␉␉␉return;␊ |
803 | ␉␉␉␉␉}␊ |
804 | ␊ |
805 | ␉␉␉␉␉dr = (((sr - dr) * a) >> 8) + dr;␊ |
806 | ␉␉␉␉␉dg = (((sg - dg) * a) >> 8) + dg;␊ |
807 | ␉␉␉␉␉db = (((sb - db) * a) >> 8) + db;␊ |
808 | ␉␉␉␉␉switch (VIDEO (depth))␊ |
809 | ␉␉␉␉␉{␊ |
810 | ␉␉␉␉␉␉case 24:␊ |
811 | ␉␉␉␉␉␉␉*(uint32_t *)(vram + bpp*pos) = (*(uint32_t *)(vram + bpp*pos) &0xff000000)␊ |
812 | ␉␉␉␉␉␉␉| (db&0xff) | ((dg&0xff)<<8) | ((dr&0xff)<<16);␊ |
813 | ␉␉␉␉␉␉␉break;␊ |
814 | ␉␉␉␉␉␉case 16:␊ |
815 | //␉␉␉␉␉␉␉*(uint16_t *)(vram + bpp*pos) = ((db&0xf8)>>3) | ((dg&0xfc)<<3) | ((dr&0xf8)<<8);␊ |
816 | //␉␉␉␉␉␉␉break;␉␉␉␉␉␉␉␊ |
817 | ␉␉␉␉␉␉case 15:␊ |
818 | ␉␉␉␉␉␉␉*(uint16_t *)(vram + bpp*pos) = ((db&0xf8)>>3) | ((dg&0xf8)<<2) | ((dr&0xf8)<<7);␊ |
819 | ␉␉␉␉␉␉␉break;␉␉␉␉␉␉␉␉␉␉␉␉␉␉␊ |
820 | ␉␉␉␉␉}␊ |
821 | ␊ |
822 | ␉␉␉␉}␊ |
823 | ␉␉␉}␊ |
824 | ␉␉␉break;␊ |
825 | }␊ |
826 | vram += VIDEO(rowBytes);␊ |
827 | data += width * 4;␊ |
828 | }␊ |
829 | }␊ |
830 | ␊ |
831 | //==============================================================================␊ |
832 | ␊ |
833 | void drawCheckerBoard()␊ |
834 | {␊ |
835 | uint32_t *vram = (uint32_t *) VIDEO(baseAddr);␊ |
836 | uint16_t x, y;␊ |
837 | uint8_t color;␊ |
838 | ␊ |
839 | for (y = 0; y < VIDEO(height); y++, vram += VIDEO(width)) {␊ |
840 | for (x = 0; x < VIDEO(width); x++) {␊ |
841 | color = 204 + 51 * (((x / 8) % 2) == ((y / 8) % 2));␊ |
842 | vram[x] = (color << 16) | (color << 8) | color;␊ |
843 | }␊ |
844 | }␊ |
845 | }␊ |
846 | ␊ |
847 | //==========================================================================␊ |
848 | // LookUpCLUTIndex␊ |
849 | ␊ |
850 | unsigned long lookUpCLUTIndex( unsigned char index, unsigned char depth )␊ |
851 | {␊ |
852 | long result, red, green, blue;␊ |
853 | ␊ |
854 | red = appleClut8[index * 3 + 0];␊ |
855 | green = appleClut8[index * 3 + 1];␊ |
856 | blue = appleClut8[index * 3 + 2];␊ |
857 | ␊ |
858 | switch (depth) {␊ |
859 | case 16 :␊ |
860 | result = ((red & 0xF8) << 7) | ␊ |
861 | ((green & 0xF8) << 2) |␊ |
862 | ((blue & 0xF8) >> 3);␊ |
863 | result |= (result << 16);␊ |
864 | break;␊ |
865 | ␊ |
866 | case 32 :␊ |
867 | result = (red << 16) | (green << 8) | blue;␊ |
868 | break;␊ |
869 | ␊ |
870 | default :␊ |
871 | result = index | (index << 8);␊ |
872 | result |= (result << 16);␊ |
873 | break;␊ |
874 | }␊ |
875 | ␊ |
876 | return result;␊ |
877 | }␊ |
878 | ␊ |
879 | //==========================================================================␊ |
880 | // drawColorRectangle␊ |
881 | ␊ |
882 | void * stosl(void * dst, long val, long len)␊ |
883 | {␊ |
884 | ␉asm volatile ( "rep; stosl"␊ |
885 | ␉␉␉␉ : "=c" (len), "=D" (dst)␊ |
886 | ␉␉␉␉ : "0" (len), "1" (dst), "a" (val)␊ |
887 | ␉␉␉␉ : "memory" );␊ |
888 | ␊ |
889 | ␉return dst;␊ |
890 | }␊ |
891 | ␊ |
892 | //==============================================================================␊ |
893 | ␊ |
894 | void drawColorRectangle( unsigned short x,␊ |
895 | unsigned short y,␊ |
896 | unsigned short width,␊ |
897 | unsigned short height,␊ |
898 | unsigned char colorIndex )␊ |
899 | {␊ |
900 | ␉long pixelBytes;␊ |
901 | ␉long color = lookUpCLUTIndex( colorIndex, VIDEO(depth) );␊ |
902 | ␉char * vram;␊ |
903 | ␊ |
904 | ␉pixelBytes = VIDEO(depth) / 8;␊ |
905 | ␉vram = (char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x;␊ |
906 | ␊ |
907 | ␉width = MIN(width, VIDEO(width) - x);␊ |
908 | ␉height = MIN(height, VIDEO(height) - y);␊ |
909 | ␊ |
910 | ␉while ( height-- )␊ |
911 | ␉{␊ |
912 | ␉␉int rem = ( pixelBytes * width ) % 4;␊ |
913 | ␉␉if ( rem )␊ |
914 | ␉␉{␊ |
915 | ␉␉␉bcopy( &color, vram, rem );␊ |
916 | ␉␉}␊ |
917 | ␊ |
918 | ␉␉stosl( vram + rem, color, pixelBytes * width / 4 );␊ |
919 | ␉␉vram += VIDEO(rowBytes);␊ |
920 | ␉}␊ |
921 | }␊ |
922 | ␊ |
923 | //==========================================================================␊ |
924 | // drawDataRectangle␊ |
925 | ␊ |
926 | void drawDataRectangle( unsigned short x,␊ |
927 | unsigned short y,␊ |
928 | unsigned short width,␊ |
929 | unsigned short height,␊ |
930 | unsigned char * data )␊ |
931 | {␊ |
932 | ␉unsigned short drawWidth;␊ |
933 | ␉long pixelBytes = VIDEO(depth) / 8;␊ |
934 | ␉unsigned char * vram = (unsigned char *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + pixelBytes * x;␊ |
935 | ␊ |
936 | ␉drawWidth = MIN(width, VIDEO(width) - x);␊ |
937 | ␉height = MIN(height, VIDEO(height) - y);␊ |
938 | ␉while ( height-- )␊ |
939 | ␉{␊ |
940 | ␉␉bcopy( data, vram, drawWidth * pixelBytes );␊ |
941 | ␉␉vram += VIDEO(rowBytes);␊ |
942 | ␉␉data += width * pixelBytes;␊ |
943 | ␉}␊ |
944 | }␊ |
945 | ␊ |
946 | //==============================================================================␊ |
947 | ␊ |
948 | void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or)␊ |
949 | {␊ |
950 | ␉int x,y, off;␊ |
951 | ␉int red=0x7f, green=0x7f, blue=0x7f;␊ |
952 | ␉for (x=0;x<ow;x++)␊ |
953 | ␉␉for (y=0;y<oh;y++)␊ |
954 | ␉␉{␊ |
955 | ␉␉␉off=(x*iw)/ow+((y*ih)/oh)*iw;␊ |
956 | ␉␉␉switch (ip)␊ |
957 | ␉␉␉{␊ |
958 | ␉␉␉␉case 16:␊ |
959 | ␉␉␉␉{␊ |
960 | ␉␉␉␉␉uint16_t val;␊ |
961 | ␉␉␉␉␉val=((uint16_t *)input)[off];␊ |
962 | ␉␉␉␉␉red=(val>>7)&0xf8;␊ |
963 | ␉␉␉␉␉green=(val>>2)&0xf8;␊ |
964 | ␉␉␉␉␉blue=(val<<3)&0xf8;␊ |
965 | ␉␉␉␉␉break;␊ |
966 | ␉␉␉␉}␊ |
967 | ␉␉␉␉case 32:␊ |
968 | ␉␉␉␉{␊ |
969 | ␉␉␉␉␉uint32_t val;␊ |
970 | ␉␉␉␉␉val=((uint32_t *)input)[off];␊ |
971 | ␉␉␉␉␉red=(val>>16)&0xff;␊ |
972 | ␉␉␉␉␉green=(val>>8)&0xff;␊ |
973 | ␉␉␉␉␉blue=(val)&0xff;␊ |
974 | ␉␉␉␉␉break;␊ |
975 | ␉␉␉␉}␊ |
976 | ␉␉␉}␊ |
977 | ␉␉␉char *ptr=(char *)output+x*(op/8)+y*or;␊ |
978 | ␉␉␉switch (op)␊ |
979 | ␉␉␉{␊ |
980 | ␉␉␉␉case 16:␊ |
981 | ␉␉␉␉␉*((uint16_t *)ptr) = ((red & 0xF8) << 7) | ␊ |
982 | ␉␉␉␉␉((green & 0xF8) << 2) |␊ |
983 | ␉␉␉␉␉((blue & 0xF8) >> 3);␊ |
984 | ␉␉␉␉␉break;␊ |
985 | ␉␉␉␉case 32 :␊ |
986 | ␉␉␉␉␉*((uint32_t *)ptr) = (red << 16) | (green << 8) | blue;␊ |
987 | ␉␉␉␉␉break;␊ |
988 | ␉␉␉}␊ |
989 | ␉␉}␊ |
990 | }␊ |
991 | ␊ |
992 | //==============================================================================␊ |
993 | ␊ |
994 | DECLARE_IOHIBERNATEPROGRESSALPHA␊ |
995 | ␊ |
996 | void drawPreview(void *src, uint8_t * saveunder)␊ |
997 | {␊ |
998 | ␉uint8_t * screen;␊ |
999 | ␉uint32_t rowBytes, pixelShift;␊ |
1000 | ␉uint32_t x, y;␊ |
1001 | ␉int32_t blob;␊ |
1002 | ␉uint32_t alpha, in, color, result;␊ |
1003 | ␉uint8_t * out;␊ |
1004 | ␉void *uncomp;␊ |
1005 | ␉int origwidth, origheight, origbpx;␊ |
1006 | ␉uint32_t saveindex[kIOHibernateProgressCount] = { 0 };␊ |
1007 | ␊ |
1008 | ␉if (src && (uncomp=DecompressData(src, &origwidth, &origheight, &origbpx)))␊ |
1009 | ␉{␊ |
1010 | ␉␉if (!setVESAGraphicsMode(origwidth, origheight, origbpx, 0))␊ |
1011 | ␉␉␉if (initGraphicsMode () != errSuccess)␊ |
1012 | ␉␉␉{␊ |
1013 | ␉␉␉␉return;␊ |
1014 | ␉␉␉}␊ |
1015 | ␊ |
1016 | ␉␉screen = (uint8_t *) VIDEO (baseAddr);␊ |
1017 | ␉␉rowBytes = VIDEO (rowBytes);␊ |
1018 | ␉␉loadImageScale (uncomp, origwidth, origheight, origbpx, screen, VIDEO(width), VIDEO(height), VIDEO(depth), VIDEO (rowBytes));␊ |
1019 | ␉}␊ |
1020 | ␉else␊ |
1021 | ␉{␊ |
1022 | ␉␉if (initGraphicsMode () != errSuccess)␊ |
1023 | ␉␉{␊ |
1024 | ␉␉␉return;␊ |
1025 | ␉␉}␊ |
1026 | ␊ |
1027 | ␉␉screen = (uint8_t *) VIDEO (baseAddr);␊ |
1028 | ␉␉rowBytes = VIDEO (rowBytes);␊ |
1029 | ␉␉// Set the screen to 75% grey.␊ |
1030 | ␉␉drawColorRectangle(0, 0, VIDEO(width), VIDEO(height), 0x01 /* color index */);␊ |
1031 | ␉}␊ |
1032 | ␊ |
1033 | ␉pixelShift = VIDEO (depth) >> 4;␊ |
1034 | ␉if (pixelShift < 1)␊ |
1035 | ␉{␊ |
1036 | ␉␉return;␊ |
1037 | ␉}␊ |
1038 | ␊ |
1039 | ␉screen += ((VIDEO (width) ␊ |
1040 | ␉␉␉␉- kIOHibernateProgressCount * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << (pixelShift - 1))␊ |
1041 | ␉+ (VIDEO (height) - kIOHibernateProgressOriginY - kIOHibernateProgressHeight) * rowBytes;␊ |
1042 | ␊ |
1043 | ␉for (y = 0; y < kIOHibernateProgressHeight; y++)␊ |
1044 | ␉{␊ |
1045 | ␉␉out = screen + y * rowBytes;␊ |
1046 | ␉␉for (blob = 0; blob < kIOHibernateProgressCount; blob++)␊ |
1047 | ␉␉{␊ |
1048 | ␉␉␉color = blob ? kIOHibernateProgressDarkGray : kIOHibernateProgressMidGray;␊ |
1049 | ␉␉␉for (x = 0; x < kIOHibernateProgressWidth; x++)␊ |
1050 | ␉␉␉{␊ |
1051 | ␉␉␉␉alpha = gIOHibernateProgressAlpha[y][x];␊ |
1052 | ␉␉␉␉result = color;␊ |
1053 | ␉␉␉␉if (alpha)␊ |
1054 | ␉␉␉␉{␊ |
1055 | ␉␉␉␉␉if (0xff != alpha)␊ |
1056 | ␉␉␉␉␉{␊ |
1057 | ␉␉␉␉␉␉if (1 == pixelShift)␊ |
1058 | ␉␉␉␉␉␉{␊ |
1059 | ␉␉␉␉␉␉␉in = *((uint16_t *)out) & 0x1f;␉// 16␊ |
1060 | ␉␉␉␉␉␉␉in = (in << 3) | (in >> 2);␊ |
1061 | ␉␉␉␉␉␉}␊ |
1062 | ␉␉␉␉␉␉else␊ |
1063 | ␉␉␉␉␉␉{␊ |
1064 | ␉␉␉␉␉␉␉in = *((uint32_t *)out) & 0xff;␉// 32␊ |
1065 | ␉␉␉␉␉␉}␊ |
1066 | ␊ |
1067 | ␉␉␉␉␉␉saveunder[blob * kIOHibernateProgressSaveUnderSize + saveindex[blob]++] = in;␊ |
1068 | ␉␉␉␉␉␉result = ((255 - alpha) * in + alpha * result + 0xff) >> 8;␊ |
1069 | ␉␉␉␉␉}␊ |
1070 | ␉␉␉␉␉if (1 == pixelShift)␊ |
1071 | ␉␉␉␉␉{␊ |
1072 | ␉␉␉␉␉␉result >>= 3;␊ |
1073 | ␉␉␉␉␉␉*((uint16_t *)out) = (result << 10) | (result << 5) | result;␉// 16␊ |
1074 | ␉␉␉␉␉}␊ |
1075 | ␉␉␉␉␉else␊ |
1076 | ␉␉␉␉␉{␊ |
1077 | ␉␉␉␉␉␉*((uint32_t *)out) = (result << 16) | (result << 8) | result;␉// 32␊ |
1078 | ␉␉␉␉␉}␊ |
1079 | ␊ |
1080 | ␉␉␉␉}␊ |
1081 | ␉␉␉␉out += (1 << pixelShift);␊ |
1082 | ␉␉␉}␊ |
1083 | ␉␉␉out += (kIOHibernateProgressSpacing << pixelShift);␊ |
1084 | ␉␉}␊ |
1085 | ␉}␊ |
1086 | }␊ |
1087 | ␊ |
1088 | //==============================================================================␊ |
1089 | ␊ |
1090 | void updateProgressBar(uint8_t * saveunder, int32_t firstBlob, int32_t select)␊ |
1091 | {␊ |
1092 | ␉uint8_t * screen;␊ |
1093 | ␉uint32_t rowBytes, pixelShift;␊ |
1094 | ␉uint32_t x, y;␊ |
1095 | ␉int32_t blob, lastBlob;␊ |
1096 | ␉uint32_t alpha, in, color, result;␊ |
1097 | ␉uint8_t * out;␊ |
1098 | ␉uint32_t saveindex[kIOHibernateProgressCount] = { 0 };␊ |
1099 | ␊ |
1100 | ␉pixelShift = VIDEO(depth) >> 4;␊ |
1101 | ␉if (pixelShift < 1) return;␊ |
1102 | ␉screen = (uint8_t *) VIDEO (baseAddr);␊ |
1103 | ␉rowBytes = VIDEO (rowBytes);␊ |
1104 | ␊ |
1105 | ␉screen += ((VIDEO (width) ␊ |
1106 | ␉␉␉␉- kIOHibernateProgressCount * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << (pixelShift - 1))␊ |
1107 | ␉+ (VIDEO (height) - kIOHibernateProgressOriginY - kIOHibernateProgressHeight) * rowBytes;␊ |
1108 | ␊ |
1109 | ␉lastBlob = (select < kIOHibernateProgressCount) ? select : (kIOHibernateProgressCount - 1);␊ |
1110 | ␊ |
1111 | ␉screen += (firstBlob * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << pixelShift;␊ |
1112 | ␊ |
1113 | ␉for (y = 0; y < kIOHibernateProgressHeight; y++)␊ |
1114 | ␉{␊ |
1115 | ␉␉out = screen + y * rowBytes;␊ |
1116 | ␉␉for (blob = firstBlob; blob <= lastBlob; blob++)␊ |
1117 | ␉␉{␊ |
1118 | ␉␉␉color = (blob < select) ? kIOHibernateProgressLightGray : kIOHibernateProgressMidGray;␊ |
1119 | ␉␉␉for (x = 0; x < kIOHibernateProgressWidth; x++)␊ |
1120 | ␉␉␉{␊ |
1121 | ␉␉␉␉alpha = gIOHibernateProgressAlpha[y][x];␊ |
1122 | ␉␉␉␉result = color;␊ |
1123 | ␉␉␉␉if (alpha)␊ |
1124 | ␉␉␉␉{␊ |
1125 | ␉␉␉␉␉if (0xff != alpha)␊ |
1126 | ␉␉␉␉␉{␊ |
1127 | ␉␉␉␉␉␉in = saveunder[blob * kIOHibernateProgressSaveUnderSize + saveindex[blob]++];␊ |
1128 | ␉␉␉␉␉␉result = ((255 - alpha) * in + alpha * result + 0xff) / 255;␊ |
1129 | ␉␉␉␉␉}␊ |
1130 | ␊ |
1131 | ␉␉␉␉␉if (1 == pixelShift)␊ |
1132 | ␉␉␉␉␉{␊ |
1133 | ␉␉␉␉␉␉result >>= 3;␊ |
1134 | ␉␉␉␉␉␉*((uint16_t *)out) = (result << 10) | (result << 5) | result;␉// 16␊ |
1135 | ␉␉␉␉␉}␊ |
1136 | ␉␉␉␉␉else␊ |
1137 | ␉␉␉␉␉{␊ |
1138 | ␉␉␉␉␉␉*((uint32_t *)out) = (result << 16) | (result << 8) | result;␉// 32␊ |
1139 | ␉␉␉␉␉}␊ |
1140 | ␉␉␉␉}␊ |
1141 | ␉␉␉␉out += (1 << pixelShift);␊ |
1142 | ␉␉␉}␊ |
1143 | ␉␉␉out += (kIOHibernateProgressSpacing << pixelShift);␊ |
1144 | ␉␉}␊ |
1145 | ␉}␊ |
1146 | }␊ |
1147 | ␊ |
1148 | //==========================================================================␊ |
1149 | // setVESATextMode␊ |
1150 | ␊ |
1151 | static int setVESATextMode( unsigned short cols, unsigned short rows, unsigned char bitsPerPixel )␊ |
1152 | {␊ |
1153 | ␉VBEModeInfoBlock minfo;␊ |
1154 | ␉unsigned short mode = modeEndOfList;␊ |
1155 | ␊ |
1156 | ␉if ( (cols != 80) || (rows != 25) ) // not 80x25 mode␊ |
1157 | ␉{␊ |
1158 | ␉␉mode = getVESAModeWithProperties( cols, rows, bitsPerPixel,␊ |
1159 | maColorModeBit |␊ |
1160 | maModeIsSupportedBit,␊ |
1161 | maGraphicsModeBit,␊ |
1162 | &minfo, NULL );␊ |
1163 | ␉}␊ |
1164 | ␊ |
1165 | ␉if ( ( mode == modeEndOfList ) || ( setVBEMode(mode, NULL) != errSuccess ) )␊ |
1166 | ␉{␊ |
1167 | ␉␉video_mode( 2 ); // VGA BIOS, 80x25 text mode.␊ |
1168 | ␉␉minfo.XResolution = 80;␊ |
1169 | ␉␉minfo.YResolution = 25;␊ |
1170 | ␉}␊ |
1171 | ␊ |
1172 | ␉// Update KernBootStruct using info provided by the selected␊ |
1173 | ␉// VESA mode.␊ |
1174 | ␊ |
1175 | ␉bootArgs->Video.v_display = VGA_TEXT_MODE;␊ |
1176 | ␉bootArgs->Video.v_baseAddr = 0xb8000;␊ |
1177 | ␉bootArgs->Video.v_width = minfo.XResolution;␊ |
1178 | ␉bootArgs->Video.v_height = minfo.YResolution;␊ |
1179 | ␉bootArgs->Video.v_depth = 8;␊ |
1180 | ␉bootArgs->Video.v_rowBytes = 0x8000;␊ |
1181 | ␊ |
1182 | ␉return errSuccess; // always return success␊ |
1183 | }␊ |
1184 | ␊ |
1185 | //==========================================================================␊ |
1186 | // getNumberArrayFromProperty␊ |
1187 | ␊ |
1188 | static int getNumberArrayFromProperty( const char * propKey,␊ |
1189 | unsigned long numbers[],␊ |
1190 | unsigned long maxArrayCount )␊ |
1191 | {␊ |
1192 | ␉char *propStr;␊ |
1193 | ␉unsigned long count = 0;␊ |
1194 | ␊ |
1195 | ␉propStr = newStringForKey((char *)propKey , &bootInfo->chameleonConfig);␊ |
1196 | ␊ |
1197 | ␉if (propStr)␊ |
1198 | ␉{␊ |
1199 | ␉␉char *delimiter = propStr;␊ |
1200 | ␉␉char *p = propStr;␊ |
1201 | ␊ |
1202 | ␉␉while ((count < maxArrayCount) && (*p != '\0'))␊ |
1203 | ␉␉{␊ |
1204 | ␉␉␉unsigned long val = strtoul(p, &delimiter, 10);␊ |
1205 | ␉␉␉if (p != delimiter)␊ |
1206 | ␉␉␉{␊ |
1207 | ␉␉␉␉numbers[count++] = val;␊ |
1208 | ␉␉␉␉p = delimiter;␊ |
1209 | ␉␉␉}␊ |
1210 | ␉␉␉while ((*p != '\0') && !isdigit(*p))␊ |
1211 | ␉␉␉␉p++;␊ |
1212 | ␉␉}␊ |
1213 | ␊ |
1214 | ␉␉free(propStr);␊ |
1215 | ␉}␊ |
1216 | ␊ |
1217 | ␉return count;␊ |
1218 | }␊ |
1219 | ␊ |
1220 | //==============================================================================␊ |
1221 | ␊ |
1222 | int initGraphicsMode ()␊ |
1223 | {␊ |
1224 | ␉unsigned long params[4];␊ |
1225 | ␉int count;␊ |
1226 | ␊ |
1227 | ␉params[3] = 0;␊ |
1228 | ␉count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 );␊ |
1229 | ␊ |
1230 | ␉// Try to find a resolution if "Graphics Mode" setting is not available.␊ |
1231 | ␉if ( count < 3 )␊ |
1232 | ␉{␊ |
1233 | ␉␉// Use the default resolution if we don't have an initialized GUI.␊ |
1234 | ␉␉if (gui.screen.width == 0 || gui.screen.height == 0)␊ |
1235 | ␉␉{␊ |
1236 | ␉␉␉gui.screen.width = DEFAULT_SCREEN_WIDTH;␊ |
1237 | ␉␉␉gui.screen.height = DEFAULT_SCREEN_HEIGHT;␊ |
1238 | ␉␉}␊ |
1239 | ␊ |
1240 | ␉␉params[0] = gui.screen.width;␊ |
1241 | ␉␉params[1] = gui.screen.height;␊ |
1242 | ␉␉params[2] = 32;␊ |
1243 | ␉}␊ |
1244 | ␊ |
1245 | ␉// Map from pixel format to bits per pixel.␊ |
1246 | ␊ |
1247 | ␉if ( params[2] == 256 )␊ |
1248 | ␉␉params[2] = 8;␊ |
1249 | ␊ |
1250 | ␉if ( params[2] == 555 )␊ |
1251 | ␉␉params[2] = 16;␊ |
1252 | ␊ |
1253 | ␉if ( params[2] == 888 )␊ |
1254 | ␉␉params[2] = 32;␊ |
1255 | ␊ |
1256 | ␉return setVESAGraphicsMode( params[0], params[1], params[2], params[3] );␊ |
1257 | }␊ |
1258 | ␊ |
1259 | //==========================================================================␊ |
1260 | // setVideoMode␊ |
1261 | //␊ |
1262 | // Set the video mode to VGA_TEXT_MODE or GRAPHICS_MODE.␊ |
1263 | ␊ |
1264 | void setVideoMode( int mode, int drawgraphics)␊ |
1265 | {␊ |
1266 | ␉unsigned long params[4];␊ |
1267 | ␉int count;␊ |
1268 | ␉int err = errSuccess;␊ |
1269 | ␊ |
1270 | ␉if ( mode == GRAPHICS_MODE )␊ |
1271 | ␉{␊ |
1272 | ␉␉if ( (err = initGraphicsMode()) == errSuccess )␊ |
1273 | ␉␉{␊ |
1274 | ␉␉␉if (gVerboseMode)␊ |
1275 | ␉␉␉{␊ |
1276 | ␉␉␉␉// Tell the kernel to use text mode on a linear frame buffer display␊ |
1277 | ␉␉␉␉bootArgs->Video.v_display = FB_TEXT_MODE;␊ |
1278 | ␉␉␉}␊ |
1279 | ␉␉␉else␊ |
1280 | ␉␉␉{␊ |
1281 | ␉␉␉␉bootArgs->Video.v_display = GRAPHICS_MODE;␊ |
1282 | ␉␉␉}␊ |
1283 | ␉␉}␊ |
1284 | ␉}␊ |
1285 | ␊ |
1286 | ␉if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) )␊ |
1287 | ␉{␊ |
1288 | ␉␉count = getNumberArrayFromProperty(kTextModeKey, params, 2);␊ |
1289 | ␉␉if ( count < 2 )␊ |
1290 | ␉␉{␊ |
1291 | ␉␉␉params[0] = 80; // Default text mode is 80x25.␊ |
1292 | ␉␉␉params[1] = 25;␊ |
1293 | ␉␉}␊ |
1294 | ␊ |
1295 | ␉␉setVESATextMode(params[0], params[1], 4);␊ |
1296 | ␉␉bootArgs->Video.v_display = VGA_TEXT_MODE;␊ |
1297 | ␉}␊ |
1298 | ␊ |
1299 | ␉currentIndicator = 0;␊ |
1300 | }␊ |
1301 | ␊ |
1302 | //==============================================================================␊ |
1303 | void getGraphicModeParams(unsigned long params[])␊ |
1304 | {␊ |
1305 | ␉params[3] = 0;␊ |
1306 | ␊ |
1307 | ␉VBEModeInfoBlock minfo;␊ |
1308 | ␊ |
1309 | ␉unsigned short vesaVersion;␊ |
1310 | ␉unsigned short mode = modeEndOfList;␊ |
1311 | ␊ |
1312 | ␉getNumberArrayFromProperty(kGraphicsModeKey, params, 4);␊ |
1313 | ␊ |
1314 | ␉mode = getVESAModeWithProperties(params[0], params[1], params[2],␊ |
1315 | ␉␉␉␉␉␉␉␉␉ maColorModeBit |␊ |
1316 | ␉␉␉␉␉␉␉␉␉ maModeIsSupportedBit |␊ |
1317 | ␉␉␉␉␉␉␉␉␉ maGraphicsModeBit |␊ |
1318 | ␉␉␉␉␉␉␉␉␉ maLinearFrameBufferAvailBit,␊ |
1319 | ␉␉␉␉␉␉␉␉␉ 0,␊ |
1320 | ␉␉␉␉␉␉␉␉␉ &minfo, &vesaVersion);␊ |
1321 | ␊ |
1322 | ␉params[0] = minfo.XResolution;␊ |
1323 | ␉params[1] = minfo.YResolution;␊ |
1324 | ␉params[2] = 32;␊ |
1325 | }␊ |
1326 | ␉␊ |
1327 | //==========================================================================␊ |
1328 | // Return the current video mode, VGA_TEXT_MODE or GRAPHICS_MODE.␊ |
1329 | ␊ |
1330 | int getVideoMode(void)␊ |
1331 | {␊ |
1332 | return bootArgs->Video.v_display;␊ |
1333 | }␊ |
1334 | ␊ |
1335 | //==========================================================================␊ |
1336 | // Display and clear the activity indicator.␊ |
1337 | ␊ |
1338 | // BASIC Indicator␊ |
1339 | static char indicator[] = {'-', '\\', '|', '/', '-', '\\', '|', '/', '\0'};␊ |
1340 | ␊ |
1341 | // To prevent a ridiculously fast-spinning indicator,␊ |
1342 | // ensure a minimum of 1/9 sec between animation frames.␊ |
1343 | #define MIN_TICKS 2␊ |
1344 | ␊ |
1345 | //==============================================================================␊ |
1346 | ␊ |
1347 | void spinActivityIndicator(int sectors)␊ |
1348 | {␊ |
1349 | static unsigned long lastTickTime = 0, currentTickTime;␊ |
1350 | ␊ |
1351 | ␉if (previewTotalSectors && previewSaveunder)␊ |
1352 | ␉{␊ |
1353 | ␉␉int blob, lastBlob;␊ |
1354 | ␊ |
1355 | ␉␉lastBlob = (previewLoadedSectors * kIOHibernateProgressCount) / previewTotalSectors;␊ |
1356 | ␉␉previewLoadedSectors+=sectors;␊ |
1357 | ␉␉blob = (previewLoadedSectors * kIOHibernateProgressCount) / previewTotalSectors;␊ |
1358 | ␉␉␊ |
1359 | ␉␉if (blob!=lastBlob)␊ |
1360 | ␉␉{␊ |
1361 | ␉␉␉updateProgressBar (previewSaveunder, lastBlob, blob);␊ |
1362 | ␉␉}␊ |
1363 | ␉␉return;␊ |
1364 | ␉}␊ |
1365 | ␊ |
1366 | ␉currentTickTime = time18(); // late binding␊ |
1367 | ␉if (currentTickTime < lastTickTime + MIN_TICKS)␊ |
1368 | ␉{␊ |
1369 | ␉␉return;␊ |
1370 | ␉}␊ |
1371 | ␉else␊ |
1372 | ␉{␊ |
1373 | ␉␉lastTickTime = currentTickTime;␊ |
1374 | ␉}␊ |
1375 | ␊ |
1376 | ␉if (getVideoMode() == VGA_TEXT_MODE)␊ |
1377 | ␉{␊ |
1378 | ␉␉if (currentIndicator >= sizeof(indicator))␊ |
1379 | ␉␉{␊ |
1380 | ␉␉␉currentIndicator = 0;␊ |
1381 | ␉␉}␊ |
1382 | ␉␉putchar(indicator[currentIndicator++]);␊ |
1383 | ␉␉putchar('\b');␊ |
1384 | ␉}␊ |
1385 | }␊ |
1386 | ␊ |
1387 | //==============================================================================␊ |
1388 | ␊ |
1389 | void clearActivityIndicator( void )␊ |
1390 | {␊ |
1391 | ␉if ( getVideoMode() == VGA_TEXT_MODE )␊ |
1392 | ␉{␊ |
1393 | ␉␉putchar(' ');␊ |
1394 | ␉␉putchar('\b');␊ |
1395 | ␉}␊ |
1396 | }␊ |
1397 | ␊ |
1398 | //==============================================================================␊ |
1399 | |