//==========================================================================␊ |
//␊ |
␊ |
void ␊ |
printVBEModeInfo()␊ |
void printVBEModeInfo()␊ |
{␊ |
␉VBEInfoBlock vbeInfo;␊ |
␉unsigned short * modePtr;␊ |
|
// Return the VESA mode that matches the properties specified.␊ |
// If a mode is not found, then return the "best" available mode.␊ |
␊ |
static unsigned short␊ |
getVESAModeWithProperties( unsigned short␉width,␊ |
static unsigned short getVESAModeWithProperties( unsigned short␉width,␊ |
unsigned short␉height,␊ |
unsigned char␉bitsPerPixel,␊ |
unsigned short␉attributesSet,␊ |
|
␊ |
␉// Loop through the mode list, and find the matching mode.␊ |
␊ |
␉for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr );␊ |
␉␉*modePtr != modeEndOfList; modePtr++ )␊ |
␉for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr ); *modePtr != modeEndOfList; modePtr++ )␊ |
␉{␊ |
␉␉// Get mode information.␊ |
␊ |
|
␊ |
#if DEBUG␊ |
␉␉printf("Mode %x: %dx%dx%d mm:%d attr:%x\n",␊ |
*modePtr, modeInfo.XResolution, modeInfo.YResolution,␊ |
modeInfo.BitsPerPixel, modeInfo.MemoryModel,␊ |
modeInfo.ModeAttributes);␊ |
␉␉␉*modePtr, modeInfo.XResolution, modeInfo.YResolution,␊ |
␉␉␉modeInfo.BitsPerPixel, modeInfo.MemoryModel,␊ |
␉␉␉modeInfo.ModeAttributes);␊ |
#endif␊ |
␊ |
␉␉// Filter out unwanted modes based on mode attributes.␊ |
␊ |
␉␉if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet )␊ |
|| ( ( modeInfo.ModeAttributes & attributesClear ) != 0 ) )␊ |
␉␉if (((modeInfo.ModeAttributes & attributesSet) != attributesSet) || ((modeInfo.ModeAttributes & attributesClear) != 0))␊ |
␉␉{␊ |
␉␉␉continue;␊ |
␉␉}␊ |
|
␊ |
␉␉modeBitsPerPixel = modeInfo.BitsPerPixel;␊ |
␊ |
␉␉if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) )␊ |
␉␉if ((modeBitsPerPixel == 4) && (modeInfo.MemoryModel == 0))␊ |
␉␉{␊ |
␉␉␉// Text mode, 16 colors.␊ |
␉␉}␊ |
␉␉else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) )␊ |
␉␉␉else if ((modeBitsPerPixel == 8) && (modeInfo.MemoryModel == 4))␊ |
␉␉{␊ |
␉␉␉// Packed pixel, 256 colors.␊ |
␉␉}␊ |
␉␉else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) )␊ |
␉␉␉&& ( modeInfo.MemoryModel == 6 )␊ |
␉␉␉&& ( modeInfo.RedMaskSize == 5 )␊ |
␉␉␉&& ( modeInfo.GreenMaskSize == 5 )␊ |
␉␉␉&& ( modeInfo.BlueMaskSize == 5 ) )␊ |
␉␉else if (((modeBitsPerPixel == 16) || (modeBitsPerPixel == 15)) && (modeInfo.MemoryModel == 6) && (modeInfo.RedMaskSize == 5) &&␊ |
␉␉␉(modeInfo.GreenMaskSize == 5) && (modeInfo.BlueMaskSize == 5))␊ |
␉␉{␊ |
␉␉␉// Direct color, 16 bpp (1:5:5:5).␊ |
␉␉␉modeInfo.BitsPerPixel = modeBitsPerPixel = 16;␊ |
␉␉}␊ |
␉␉else if ( ( modeBitsPerPixel == 32 )␊ |
␉␉␉&& ( modeInfo.MemoryModel == 6 )␊ |
␉␉␉&& ( modeInfo.RedMaskSize == 8 )␊ |
␉␉␉&& ( modeInfo.GreenMaskSize == 8 )␊ |
␉␉␉&& ( modeInfo.BlueMaskSize == 8 ) )␊ |
␉␉else if ((modeBitsPerPixel == 32) && (modeInfo.MemoryModel == 6) && (modeInfo.RedMaskSize == 8) &&␊ |
␉␉␉(modeInfo.GreenMaskSize == 8) && (modeInfo.BlueMaskSize == 8))␊ |
␉␉{␊ |
␉␉␉// Direct color, 32 bpp (8:8:8:8).␊ |
␉␉}␊ |
␉␉else␊ |
␉␉{␊ |
␉␉␉continue; // Not a supported mode.␊ |
␉␉␉continue;␉// Not a supported mode.␊ |
␉␉}␊ |
␊ |
␉␉// Modes larger than the specified dimensions are skipped.␊ |
␊ |
␉␉if ( ( modeInfo.XResolution > width ) ||␊ |
␉␉␉( modeInfo.YResolution > height ) )␊ |
␉␉if ((modeInfo.XResolution > width) || (modeInfo.YResolution > height))␊ |
␉␉{␊ |
␉␉␉continue;␊ |
␉␉}␊ |
␊ |
␉␉// Perfect match, we're done looking.␊ |
␊ |
␉␉if ( ( modeInfo.XResolution == width ) &&␊ |
␉␉␉( modeInfo.YResolution == height ) &&␊ |
␉␉␉( modeBitsPerPixel == bitsPerPixel ) )␊ |
␉␉if (modeInfo.XResolution == width && modeInfo.YResolution == height && modeBitsPerPixel == bitsPerPixel)␊ |
␉␉{␊ |
␉␉␉matchedMode = *modePtr;␊ |
␉␉␉bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) );␊ |
␉␉␉bcopy(&modeInfo, outModeInfo, sizeof(modeInfo));␊ |
␉␉␉break;␊ |
␉␉}␊ |
␊ |
␉␉// Save the next "best" mode in case a perfect match is not found.␊ |
␊ |
␉␉if ( modeInfo.XResolution == outModeInfo->XResolution &&␊ |
␉␉␉modeInfo.YResolution == outModeInfo->YResolution &&␊ |
␉␉␉modeBitsPerPixel <= outModeInfo->BitsPerPixel )␊ |
␉␉if (modeInfo.XResolution == outModeInfo->XResolution && modeInfo.YResolution == outModeInfo->YResolution &&␊ |
␉␉␉modeBitsPerPixel <= outModeInfo->BitsPerPixel)␊ |
␉␉{␊ |
␉␉␉continue; // Saved mode has more depth.␊ |
␉␉␉continue;␉// Saved mode has more depth.␊ |
␉␉}␊ |
␊ |
␉␉if ( modeInfo.XResolution < outModeInfo->XResolution ||␊ |
␉␉␉modeInfo.YResolution < outModeInfo->YResolution ||␊ |
␉␉␉modeBitsPerPixel < outModeInfo->BitsPerPixel )␊ |
␉␉if (modeInfo.XResolution < outModeInfo->XResolution || modeInfo.YResolution < outModeInfo->YResolution ||␊ |
␉␉␉modeBitsPerPixel < outModeInfo->BitsPerPixel)␊ |
␉␉{␊ |
␉␉␉continue; // Saved mode has more resolution.␊ |
␉␉␉continue;␉// Saved mode has more resolution.␊ |
␉␉}␊ |
␊ |
␉␉matchedMode = *modePtr;␊ |
␉␉bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) );␊ |
␉␉bcopy(&modeInfo, outModeInfo, sizeof(modeInfo));␊ |
␉}␊ |
␊ |
␉return matchedMode;␊ |
|
//==========================================================================␊ |
// setupPalette␊ |
␊ |
static void setupPalette( VBEPalette * p, const unsigned char * g )␊ |
static void setupPalette( VBEPalette *p, const unsigned char *g )␊ |
{␊ |
int i;␊ |
unsigned char * source = (unsigned char *) g;␊ |
|
//==========================================================================␊ |
// setVESAGraphicsMode␊ |
␊ |
static int␊ |
setVESAGraphicsMode( unsigned short width,␊ |
unsigned short height,␊ |
unsigned char bitsPerPixel,␊ |
unsigned short refreshRate )␊ |
static int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel, unsigned short refreshRate )␊ |
{␊ |
␉VBEModeInfoBlock minfo;␊ |
␉unsigned short mode;␊ |
|
␊ |
// Set the mode with default refresh rate.␊ |
␊ |
err = setVBEMode(mode | kLinearFrameBufferBit, NULL);␊ |
␉␉err = setVBEMode(mode | kLinearFrameBufferBit, NULL);␊ |
␊ |
if (err != errSuccess)␊ |
{␊ |
break;␊ |
}␊ |
␉␉if (err != errSuccess)␊ |
␉␉{␊ |
␉␉␉break;␊ |
␉␉}␊ |
␊ |
// Set 8-bit color palette.␊ |
␊ |
|
}␊ |
}␊ |
␊ |
// Is this required for buggy Video BIOS implementations?␊ |
// On which adapter?␊ |
␉␉// Is this required for buggy Video BIOS implementations?␊ |
␉␉// On which adapter?␊ |
␊ |
if ( minfo.BytesPerScanline == 0 )␊ |
minfo.BytesPerScanline = ( minfo.XResolution *␊ |
minfo.BitsPerPixel ) >> 3;␊ |
␉␉if ( minfo.BytesPerScanline == 0 )␊ |
␉␉{␊ |
␉ minfo.BytesPerScanline = ( minfo.XResolution * minfo.BitsPerPixel ) >> 3;␊ |
␉␉}␊ |
␊ |
// Update KernBootStruct using info provided by the selected␊ |
// VESA mode.␊ |
␉␉// Update KernBootStruct using info provided by the selected␊ |
␉␉// VESA mode.␊ |
␊ |
bootArgs->Video.v_display = GRAPHICS_MODE;␊ |
bootArgs->Video.v_width = minfo.XResolution;␊ |
bootArgs->Video.v_height = minfo.YResolution;␊ |
bootArgs->Video.v_depth = minfo.BitsPerPixel;␊ |
bootArgs->Video.v_rowBytes = minfo.BytesPerScanline;␊ |
bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr);␊ |
␉␉bootArgs->Video.v_display␉= GRAPHICS_MODE;␊ |
␉␉bootArgs->Video.v_width␉␉= minfo.XResolution;␉␉/* 1920 or 1600 */␊ |
␉␉bootArgs->Video.v_height␉= minfo.YResolution;␉␉/* 1200 or 900 */␊ |
␉␉bootArgs->Video.v_depth␉␉= minfo.BitsPerPixel;␉␉/* 32 */␊ |
␉␉bootArgs->Video.v_rowBytes␉= minfo.BytesPerScanline;␉/* 7680 or 6400 */␊ |
␉␉bootArgs->Video.v_baseAddr␉= VBEMakeUInt32(minfo.PhysBasePtr);␊ |
␊ |
␉} while ( 0 );␊ |
␊ |
return err;␊ |
␉return err;␊ |
}␊ |
␊ |
//==============================================================================␊ |
|
␊ |
//==============================================================================␊ |
␊ |
int loadPngImage(const char *filename, uint16_t *width, uint16_t *height,␊ |
uint8_t **imageData)␊ |
int loadPngImage(const char *filename, uint16_t *width, uint16_t *height, uint8_t **imageData)␊ |
{␊ |
uint8_t *pngData = NULL;␊ |
int pngFile = 0, pngSize;␊ |
|
␊ |
//==============================================================================␊ |
␊ |
int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData) {␊ |
int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData)␊ |
{␊ |
PNG_info_t *info;␊ |
int error = 0;␊ |
␉␊ |
|
␊ |
//==============================================================================␊ |
␊ |
void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height,␊ |
uint8_t *data)␊ |
void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data)␊ |
{␊ |
uint16_t drawWidth;␊ |
uint8_t *vram = (uint8_t *) VIDEO(baseAddr) + VIDEO(rowBytes) * y + 4 * x;␊ |
|
//==========================================================================␊ |
// drawDataRectangle␊ |
␊ |
void drawDataRectangle( unsigned short x,␊ |
unsigned short y,␊ |
unsigned short width,␊ |
unsigned short height,␊ |
unsigned char *data )␊ |
void drawDataRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *data )␊ |
{␊ |
␉unsigned short drawWidth;␊ |
␊ |
|
␊ |
DECLARE_IOHIBERNATEPROGRESSALPHA␊ |
␊ |
void drawPreview(void *src, uint8_t * saveunder)␊ |
void drawPreview(void *src, uint8_t *saveunder)␊ |
{␊ |
␉uint8_t *screen;␊ |
␉uint32_t rowBytes, pixelShift;␊ |
|
␊ |
//==============================================================================␊ |
␊ |
void updateProgressBar(uint8_t * saveunder, int32_t firstBlob, int32_t select)␊ |
void updateProgressBar(uint8_t *saveunder, int32_t firstBlob, int32_t select)␊ |
{␊ |
␉uint8_t␉␉*screen;␊ |
␉uint32_t␉rowBytes, pixelShift;␊ |
|
//==========================================================================␊ |
// getNumberArrayFromProperty␊ |
␊ |
static int getNumberArrayFromProperty( const char * propKey,␊ |
static int getNumberArrayFromProperty( const char *propKey,␊ |
unsigned long numbers[],␊ |
unsigned long maxArrayCount )␊ |
{␊ |