static int vlc_FromHR(audio_output_t *aout, HRESULT hr) { /* Select the default device (and restart) on unplug */ if (unlikely(hr == AUDCLNT_E_DEVICE_INVALIDATED || hr == AUDCLNT_E_RESOURCES_INVALIDATED)) DeviceSelect(aout, NULL); return SUCCEEDED(hr) ? 0 : -1; }
/********************************************************************* * Function: void SetReg(BYTE index, BYTE value) * * PreCondition: none * * Input: index - register number * value - value to be set * * Output: none * * Side Effects: none * * Overview: sets graphics controller register * * Note: none * ********************************************************************/ void SetReg(BYTE index, BYTE value) { DeviceSelect(); DeviceSetCommand(); DeviceWrite(index); DeviceSetData(); DeviceWrite(value); DeviceDeselect(); }
/********************************************************************* * Function: void ClearDevice(void) * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: clears screen with current color * * Note: none * ********************************************************************/ void ClearDevice(void) { DWORD counter; DeviceSelect(); SetAddress(0, 0); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++) { DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); } DeviceDeselect(); }
/********************************************************************* * Function: WORD GetPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: pixel color * * Side Effects: none * * Overview: return pixel color at x,y position * * Note: none * ********************************************************************/ WORD GetPixel(SHORT x, SHORT y) { WORD_VAL result; DeviceSelect(); SetAddress(x, y); DeviceSetCommand(); DeviceWrite(CMD_READ); DeviceSetData(); result.v[0] = DeviceRead(); result.v[1] = DeviceRead(); DeviceDeselect(); return (result.Val); }
/********************************************************************* * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) * * PreCondition: none * * Input: left,top - top left corner coordinates, * right,bottom - bottom right corner coordinates * * Output: For NON-Blocking configuration: * - Returns 0 when device is busy and the shape is not yet completely drawn. * - Returns 1 when the shape is completely drawn. * For Blocking configuration: * - Always return 1. * * Side Effects: none * * Overview: draws rectangle filled with current color * * Note: none * ********************************************************************/ WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom) { SHORT x, y; #ifndef USE_NONBLOCKING_CONFIG while(IsDeviceBusy() != 0); /* Ready */ #else if(IsDeviceBusy() != 0) return (0); #endif if(_clipRgn) { if(left < _clipLeft) left = _clipLeft; if(right > _clipRight) right = _clipRight; if(top < _clipTop) top = _clipTop; if(bottom > _clipBottom) bottom = _clipBottom; } DeviceSelect(); for(y = top; y < bottom + 1; y++) { SetAddress(left, top); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); for(x = left; x < right + 1; x++) { DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); } } DeviceDeselect(); return (1); }
/********************************************************************* * Function: void SetReg(BYTE index, WORD value) * * PreCondition: none * * Input: index - register number * value - value to be set * * Output: none * * Side Effects: none * * Overview: sets graphics controller register * * Note: none * ********************************************************************/ void SetReg(WORD index, WORD value) { DeviceSelect(); DeviceSetCommand(); #ifdef USE_16BIT_PMP DeviceWrite(index); #else DeviceWrite(((WORD_VAL)index).v[1]); DeviceWrite(((WORD_VAL)index).v[0]); #endif DeviceSetData(); #ifdef USE_16BIT_PMP DeviceWrite(value); #else DeviceWrite(((WORD_VAL)value).v[1]); DeviceWrite(((WORD_VAL)value).v[0]); #endif DeviceDeselect(); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize device DeviceInit(); // Enable LCD DeviceSelect(); // Setup display DeviceSetCommand() DeviceWrite(CMD_DISPON); DeviceWrite(CMD_MODE); DeviceSetData(); DeviceWrite(0x74); DeviceSetCommand(); DeviceWrite(CMD_SRTLINE); DeviceSetData(); DeviceWrite(128); // Disable LCD DeviceDeselect(); }
/********************************************************************* * Function: void PutPixel(SHORT x, SHORT y) * * PreCondition: none * * Input: x,y - pixel coordinates * * Output: none * * Side Effects: none * * Overview: puts pixel * * Note: none * ********************************************************************/ void PutPixel(SHORT x, SHORT y) { if(_clipRgn) { if(x < _clipLeft) return; if(x > _clipRight) return; if(y < _clipTop) return; if(y > _clipBottom) return; } DeviceSelect(); SetAddress(x, y); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); DeviceDeselect(); }
/********************************************************************* * Function: void SetAddress(SHORT x, SHORT y) * * Overview: Writes address pointer. * * PreCondition: none * * Input: x - horizontal position * y - vertical position * * Output: none * * Side Effects: none * ********************************************************************/ inline void SetAddress(SHORT x, SHORT y) { DeviceSelect(); DeviceSetCommand(); DeviceWrite(0x02); DeviceSetData(); DeviceWrite(((WORD_VAL) (WORD) x).v[1]); DeviceSetCommand(); DeviceWrite(0x03); DeviceSetData(); DeviceWrite(((WORD_VAL) (WORD) x).v[0]); DeviceSetCommand(); DeviceWrite(0x06); DeviceSetData(); DeviceWrite(((WORD_VAL) (WORD) y).v[1]); DeviceSetCommand(); DeviceWrite(0x07); DeviceSetData(); DeviceWrite(((WORD_VAL) (WORD) y).v[0]); DeviceSetCommand(); DeviceWrite(0x22); DeviceSetData(); }
int KPmacC::SelectDevice( UINT hwnd ) { return DeviceSelect((HWND)hwnd); }
/********************************************************************* * Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) * * PreCondition: none * * Input: left,top - left top image corner, bitmap - image pointer, * stretch - image stretch factor * * Output: none * * Side Effects: none * * Overview: outputs 16 color image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) { register FLASH_BYTE *flashAddress; register FLASH_BYTE *tempFlashAddress; WORD sizeX, sizeY; register WORD x, y; BYTE temp; register BYTE stretchX, stretchY; WORD pallete[16]; WORD counter; // Move pointer to size information flashAddress = bitmap + 2; // Read image size sizeY = *((FLASH_WORD *)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD *)flashAddress); flashAddress += 2; // Read pallete for(counter = 0; counter < 16; counter++) { pallete[counter] = *((FLASH_WORD *)flashAddress); flashAddress += 2; } DeviceSelect(); for(y = 0; y < sizeY; y++) { tempFlashAddress = flashAddress; for(stretchY = 0; stretchY < stretch; stretchY++) { flashAddress = tempFlashAddress; SetAddress(left, top + y); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); for(x = 0; x < sizeX; x++) { // Read 2 pixels from flash if((x & 0x0001) == 0) { // Set color SetColor(pallete[temp >> 4]); } else { temp = *flashAddress; flashAddress++; // Set color SetColor(pallete[temp & 0x0f]); } // Write pixel to screen for(stretchX = 0; stretchX < stretch; stretchX++) { DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); } // Shift to the next pixel temp >>= 4; } }
/********************************************************************* * Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch) * * PreCondition: none * * Input: left,top - left top image corner, bitmap - image pointer, * stretch - image stretch factor * * Output: none * * Side Effects: none * * Overview: outputs monochrome image starting from left,top coordinates * * Note: image must be located in flash * ********************************************************************/ void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch) { register FLASH_BYTE *flashAddress; register FLASH_BYTE *tempFlashAddress; BYTE temp; WORD sizeX, sizeY; WORD x, y; BYTE stretchX, stretchY; WORD pallete[2]; BYTE mask; // Move pointer to size information flashAddress = bitmap + 2; // Read image size sizeY = *((FLASH_WORD *)flashAddress); flashAddress += 2; sizeX = *((FLASH_WORD *)flashAddress); flashAddress += 2; pallete[0] = *((FLASH_WORD *)flashAddress); flashAddress += 2; pallete[1] = *((FLASH_WORD *)flashAddress); flashAddress += 2; DeviceSelect(); for(y = 0; y < sizeY; y++) { tempFlashAddress = flashAddress; for(stretchY = 0; stretchY < stretch; stretchY++) { flashAddress = tempFlashAddress; SetAddress(left, top + y); DeviceSetCommand(); DeviceWrite(CMD_WRITE); DeviceSetData(); mask = 0; for(x = 0; x < sizeX; x++) { // Read 8 pixels from flash if(mask == 0) { temp = *flashAddress; flashAddress++; mask = 0x80; } // Set color if(mask & temp) { SetColor(pallete[1]); } else { SetColor(pallete[0]); } // Write pixel to screen for(stretchX = 0; stretchX < stretch; stretchX++) { DeviceWrite(_color.v[1]); DeviceWrite(_color.v[0]); } // Shift to the next pixel mask >>= 1; } } } DeviceDeselect(); }