📄 amadisp.cpp
字号:
SCODE AMADisp::MovePointer(INT xPosition, INT yPosition)
{
DWORD dwCursorX, dwCursorY;
DEBUGMSG(GPE_ZONE_CURSOR,
(TEXT("AMADisp::MovePointer\r\n")));
// If the position is out of screen, disable cursor.
if (xPosition < 0 || xPosition >= m_nScreenWidth
|| yPosition < 0 || yPosition >= m_nScreenHeight) {
m_pDisplayOutRegs[DO_DSMR2] &= 0xFFFFFFFD; // turn off cursor1
}
else {
dwCursorX = (DWORD)xPosition - gxHot;
dwCursorY = (DWORD)yPosition - gyHot;
m_pDisplayOutRegs[DO_DSMR2] |= 0x00000002; // turn on cursor1
m_pDisplayOutRegs[DO_HCS1] = g_dwCursorBlinkFrames << 10 | dwCursorX;
m_pDisplayOutRegs[DO_VCS1] = g_dwCursorBlinkFrames << 10 | dwCursorY;
}
return S_OK;
}
void AMADisp::WaitForNotBusy()
{
DEBUGMSG(GPE_ZONE_ENTER,
(TEXT("AMADisp::WaitForNotBusy\r\n")));
return;
}
int AMADisp::IsBusy()
{
DEBUGMSG(GPE_ZONE_ENTER,
(TEXT("AMADisp::IsBusy\r\n")));
return 0; // Never busy as there is no acceleration
}
void AMADisp::GetPhysicalVideoMemory (
unsigned long *pPhysicalMemoryBase,
unsigned long *pVideoMemorySize )
{
DEBUGMSG(GPE_ZONE_ENTER,(TEXT("DispOut::GetPhysicalVideoMemory\r\n")));
*pPhysicalMemoryBase = g_dwLocalMemoryAddress + g_dwVideoMemoryOffset;
*pVideoMemorySize = m_nScreenHeight * m_nScreenStride;
}
SCODE AMADisp::AllocSurface(
GPESurf **ppSurf,
int width,
int height,
EGPEFormat format,
int surfaceFlags )
{
DEBUGMSG(GPE_ZONE_ENTER,
(TEXT("AMADisp::AllocSurface\r\n")));
if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
return E_OUTOFMEMORY; // Can't allocate video-memory surfaces
*ppSurf = new GPESurf( width, height, format );
if (*ppSurf) {
// check we allocated bits succesfully
if ( !((*ppSurf)->Buffer()) )
delete *ppSurf; // and then return E_OUTOFMEMORY
else
return S_OK;
}
return E_OUTOFMEMORY;
}
SCODE AMADisp::Line(
GPELineParms *pLineParms,
EGPEPhase phase )
{
DEBUGMSG(GPE_ZONE_LINE,
(TEXT("AMADisp::Line\r\n")));
if (phase == gpeSingle || phase == gpePrepare)
pLineParms->pLine = EmulatedLine;
return S_OK;
}
#define FUNCNAME(basename) \
(SCODE (GPE::*)(struct GPEBltParms *))Emulator::Emulated##basename
SCODE AMADisp::BltPrepare(
GPEBltParms *pBltParms )
{
DEBUGMSG(GPE_ZONE_BLT_HI, (TEXT("AMADisp::BltPrepare\r\n")));
pBltParms->pBlt = EmulatedBlt;
#ifdef ENABLE_EMULATION
//
// None of our emulation functions can handle stretching or transparency
//
if ( (pBltParms->bltFlags & (BLT_TRANSPARENT | BLT_STRETCH)) )
return S_OK;
#endif
//
// Bail on any parameter values that would make this
// blt non-emulatable
//
if ( EGPEFormatToBpp[pBltParms->pDst->Format()] != 8 ||
pBltParms->pLookup ||
pBltParms->pConvert)
{
return S_OK;
}
#ifdef ENABLE_EMULATION
switch( pBltParms->rop4 )
{
case 0x0000: // BLACKNESS
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - BLACKNESS\r\n")));
pBltParms->solidColor = 0;
pBltParms->pBlt = FUNCNAME(BltFill08);
return S_OK;
case 0xFFFF: // WHITENESS
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - WHITENESS\r\n")));
pBltParms->solidColor = 0x00ffffff;
pBltParms->pBlt = FUNCNAME(BltFill08);
return S_OK;
case 0xF0F0: // PATCOPY
if( pBltParms->solidColor != -1 )
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - PATCOPY - solid brush\r\n")));
pBltParms->pBlt = FUNCNAME(BltFill08);
return S_OK;
}
break;
case 0x5A5A: // PATINVERT
if( pBltParms->solidColor != -1 )
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - PATINVERT - solid brush\r\n")));
pBltParms->pBlt = FUNCNAME(BltPatInvert08);
return S_OK;
}
break;
case 0x5555: // DSTINVERT
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - DSTINVERT\r\n")));
pBltParms->pBlt = FUNCNAME(BltDstInvert08);
return S_OK;
case 0xCCCC: // SRCCOPY
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - SRCCOPY\r\n")));
pBltParms->pBlt = FUNCNAME(BltSrcCopy0808);
return S_OK;
case 0x8888: // SRCAND
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - SRCAND\r\n")));
pBltParms->pBlt = FUNCNAME(BltSrcAnd0808);
return S_OK;
case 0xEEEE: // SRCPAINT
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - SRCPAINT\r\n")));
pBltParms->pBlt = FUNCNAME(BltSrcPaint0808);
return S_OK;
case 0x6666: // SRCINVERT
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - SRCINVERT\r\n")));
pBltParms->pBlt = FUNCNAME(BltSrcInvert0808);
return S_OK;
case 0xAAF0: // Special PATCOPY rop for text output -- fill where mask is 1.
// Not a pattern brush?
if( pBltParms->solidColor != -1 )
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::Blt - 0xAAF0\r\n")));
pBltParms->pBlt = FUNCNAME(BltText08);
return S_OK;
}
break;
default:
;
}
#endif // ENABLE_EMULATION
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE AMADisp::BltComplete( GPEBltParms *pBltParms )
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::BltComplete\r\n")));
return S_OK;
}
int AMADisp::InVBlank()
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::InVBlank\r\n")));
return 0;
}
SCODE AMADisp::SetPalette
(
const PALETTEENTRY *src,
unsigned short firstEntry,
unsigned short numEntries
)
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp::SetPalette\r\n")));
DWORD index;
DWORD color;
index = _PLT + (DWORD)(firstEntry << 1);
// HD64404 accepts writings only in the v-blank period because the
// palette RAM is neither double-buffered nor dual-ported.
if (firstEntry < 0 || firstEntry + numEntries > 256) {
return E_INVALIDARG;
}
while (numEntries > 0) {
color = src->peRed << 16 | src->peGreen << 8 | src->peBlue;
while (!(m_pDisplayOutRegs[DO_SR] & VBA_FLAG)); // wait until v-blank
m_pDisplayOutRegs[index] = color;
/*m_pDisplayRegs[index + 1] = color;*/ // for Q2SD mode
if (m_pDisplayOutRegs[DO_SR] & VBA_FLAG) {
// We check v-blank again and we can step to the next only
// we are still in it. Other case, if the v-blank has gone
// while writing, we have to retry.
index += 2;
src++;
numEntries--;
}
}
return S_OK;
}
void RegisterDDHALAPI()
{
; // Currently no DDHAL support.
}
ulong BitMasks[] = { 0, 0, 0, 0 };
ULONG *APIENTRY DrvGetMasks(
DHPDEV dhpdev)
{
DEBUGMSG(GPE_ZONE_BLT_LO,(TEXT("AMADisp - DrvGetMasks\r\n")));
if (AMADispMode[0].gpeMode.format == gpe16Bpp) {
BitMasks[0] = 0xF800;
BitMasks[1] = 0x07E0;
BitMasks[2] = 0x001F;
BitMasks[3] = 0x0000;
}
else { // assuming 8bpp
BitMasks[0] = 0x0000;
BitMasks[1] = 0x0000;
BitMasks[2] = 0x0000;
BitMasks[3] = 0x0000;
}
return BitMasks;
}
BOOL AMADisp::ContrastControl(
ULONG cmd,
ULONG *pValue)
{
DEBUGMSG(GPE_ZONE_ENTER,(TEXT("AMADisp::ContrastControl\r\n")));
return FALSE; // We have no contrast control hardware.
}
VOID AMADisp::PowerHandler(
BOOL bOff)
{
DWORD dwDOBase = g_dwRegisterAddress + HD64404_DISPLAYOUT_OFFSET;
DWORD dwGEBase = g_dwRegisterAddress + HD64404_GE_OFFSET;
DWORD dwPCCBase = g_dwRegisterAddress + HD64404_POWER_OFFSET;
// No system calls are allowed in power handler.
// To avoid TLB miss, all register base addresses are in P2.
if (bOff) { // Fall into power down state
// First, turn off display and enter it to reset state.
// DRES=1, DEN=0, DC=0, Q2SD=0
*(volatile DWORD*)(dwDOBase + DO_SYSR * 4) = 0x00004000;
// SRES=1, RBRK=0, RS=0
*(volatile DWORD*)(dwGEBase + GE_RCR * 4) = 0x80000000;
BusyWait(25 * g_dwLoop1ms); // 25ms (at least 1 VSYNC)
// Be sure GE is not rendering.
// Next, clear DO module enable bit.
*(volatile DWORD*)(dwDOBase + DO_PLL * 4) &= ~0x04000000;
BusyWait(25 * g_dwLoop1ms); // 25ms
// Then, turn off PLL when it is used.
if (AMADispMode[0].DORegs[DO_PLL] & 0x00000001)
*(volatile DWORD*)(dwDOBase + DO_PLL * 4) &= ~0x00000001;
// Finally, stop the DisplayOut and GE module clock.
*(volatile DWORD*)(dwPCCBase + POWER_CC2_OFFSET) &= ~0x00000011;
}
else { // wake up from power down state
// First, start the DisplayOut and GE module clock.
*(volatile DWORD*)(dwPCCBase + POWER_CC2_OFFSET) |= 0x00000011;
// Next, on PLL when it is used.
if (AMADispMode[0].DORegs[DO_PLL] & 0x00000001)
*(volatile DWORD*)(dwDOBase + DO_PLL * 4) |= 0x00000001;
BusyWait(25 * g_dwLoop1ms); // 25ms (at least 1 VSYNC)
// Then, set DisplayOut module enable bit.
*(volatile DWORD*)(dwDOBase + DO_PLL * 4) |= 0x04000000;
BusyWait(25 * g_dwLoop1ms); // 25ms
// Finally, clear reset bit and set display enable bit for DO, then
// clear reset bit for GE.
// DRES=0, DEN=1, DC=0, Q2SD=0
*(volatile DWORD*)(dwDOBase + DO_SYSR * 4) = 0x00002000;
// SRES=0, RBRK=0, RS=0
*(volatile DWORD*)(dwGEBase + GE_RCR * 4) = 0x00000000;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -