mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 23:00:42 +00:00
More work. Audio driver works enough to play music now.
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
#include "PLQuickdraw.h"
|
||||
#include "QDManager.h"
|
||||
#include "QDState.h"
|
||||
#include "DisplayDeviceManager.h"
|
||||
#include "MMHandleBlock.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "ResTypeID.h"
|
||||
#include "RGBAColor.h"
|
||||
#include "WindowManager.h"
|
||||
#include "QDGraf.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "QDUtils.h"
|
||||
|
||||
void GetPort(GrafPtr *graf)
|
||||
{
|
||||
@@ -8,15 +18,19 @@ void GetPort(GrafPtr *graf)
|
||||
|
||||
void SetPort(GrafPtr graf)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::QDManager *qd = PortabilityLayer::QDManager::GetInstance();
|
||||
|
||||
GDHandle device;
|
||||
qd->GetPort(nullptr, &device);
|
||||
qd->SetPort(graf, device);
|
||||
}
|
||||
|
||||
void BeginUpdate(GrafPtr graf)
|
||||
void BeginUpdate(WindowPtr graf)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void EndUpdate(GrafPtr graf)
|
||||
void EndUpdate(WindowPtr graf)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
@@ -65,7 +79,11 @@ GDHandle GetMainDevice()
|
||||
|
||||
void SetPortWindowPort(WindowPtr window)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
GDevice **device = wm->GetWindowDevice(window);
|
||||
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_port, device);
|
||||
}
|
||||
|
||||
void SetPortDialogPort(Dialog *dialog)
|
||||
@@ -73,20 +91,19 @@ void SetPortDialogPort(Dialog *dialog)
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
|
||||
void TextSize(int sz)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::QDManager::GetInstance()->GetState()->m_textSize = sz;
|
||||
}
|
||||
|
||||
void TextFace(int face)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::QDManager::GetInstance()->GetState()->m_textFace = face;
|
||||
}
|
||||
|
||||
void TextFont(int fontID)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::QDManager::GetInstance()->GetState()->m_fontID = fontID;
|
||||
}
|
||||
|
||||
int TextWidth(const PLPasStr &str, int firstChar1Based, int length)
|
||||
@@ -110,14 +127,69 @@ void SetOrigin(int x, int y)
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static bool SystemColorToRGBAColor(SystemColorID color, PortabilityLayer::RGBAColor &rgbaColor)
|
||||
{
|
||||
switch (color)
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
case whiteColor:
|
||||
rgbaColor.r = rgbaColor.g = rgbaColor.b = 255;
|
||||
break;
|
||||
case blackColor:
|
||||
rgbaColor.r = rgbaColor.g = rgbaColor.b = 0;
|
||||
break;
|
||||
case yellowColor:
|
||||
rgbaColor.r = rgbaColor.g = 255;
|
||||
rgbaColor.b = 0;
|
||||
break;
|
||||
case magentaColor:
|
||||
rgbaColor.r = rgbaColor.b = 255;
|
||||
rgbaColor.g = 0;
|
||||
break;
|
||||
case redColor:
|
||||
rgbaColor.r = 255;
|
||||
rgbaColor.g = rgbaColor.b = 0;
|
||||
break;
|
||||
case cyanColor:
|
||||
rgbaColor.g = rgbaColor.b = 255;
|
||||
rgbaColor.r = 0;
|
||||
break;
|
||||
case greenColor:
|
||||
rgbaColor.g = 255;
|
||||
rgbaColor.r = rgbaColor.b = 0;
|
||||
break;
|
||||
case blueColor:
|
||||
rgbaColor.b = 255;
|
||||
rgbaColor.r = rgbaColor.g = 0;
|
||||
break;
|
||||
}
|
||||
rgbaColor.a = 255;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ForeColor(SystemColorID color)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::RGBAColor rgbaColor;
|
||||
if (SystemColorToRGBAColor(color, rgbaColor))
|
||||
{
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
qdState->SetForeColor(rgbaColor);
|
||||
}
|
||||
}
|
||||
|
||||
void BackColor(SystemColorID color)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::RGBAColor rgbaColor;
|
||||
if (SystemColorToRGBAColor(color, rgbaColor))
|
||||
{
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
qdState->SetBackColor(rgbaColor);
|
||||
}
|
||||
}
|
||||
|
||||
void GetForeColor(RGBColor *color)
|
||||
@@ -142,7 +214,59 @@ void DrawString(const PLPasStr &str)
|
||||
|
||||
void PaintRect(const Rect *rect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
if (!rect->IsValid())
|
||||
return;
|
||||
|
||||
PortabilityLayer::QDPort *qdPort;
|
||||
PortabilityLayer::QDManager::GetInstance()->GetPort(&qdPort, nullptr);
|
||||
|
||||
PortabilityLayer::PixelFormat pixelFormat = qdPort->GetPixelFormat();
|
||||
|
||||
Rect constrainedRect = *rect;
|
||||
|
||||
PortabilityLayer::QDState *qdState = qdPort->GetState();
|
||||
|
||||
if (qdState->m_clipRegion)
|
||||
{
|
||||
const Region ®ion = **qdState->m_clipRegion;
|
||||
|
||||
if (region.size > sizeof(Region))
|
||||
PL_NotYetImplemented();
|
||||
|
||||
constrainedRect = constrainedRect.Intersect(region.rect);
|
||||
}
|
||||
|
||||
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
|
||||
|
||||
if (!constrainedRect.IsValid())
|
||||
return;
|
||||
|
||||
PortabilityLayer::PixMapImpl *pixMap = static_cast<PortabilityLayer::PixMapImpl*>(*qdPort->GetPixMap());
|
||||
const size_t pitch = pixMap->GetPitch();
|
||||
const size_t firstIndex = static_cast<size_t>(constrainedRect.top) * pitch + static_cast<size_t>(constrainedRect.left);
|
||||
const size_t numLines = static_cast<size_t>(constrainedRect.bottom - constrainedRect.top);
|
||||
const size_t numCols = static_cast<size_t>(constrainedRect.right - constrainedRect.left);
|
||||
uint8_t *pixData = static_cast<uint8_t*>(pixMap->GetPixelData());
|
||||
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case PortabilityLayer::PixelFormat_8BitStandard:
|
||||
{
|
||||
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
||||
|
||||
size_t scanlineIndex = 0;
|
||||
for (size_t ln = 0; ln < numLines; ln++)
|
||||
{
|
||||
const size_t firstLineIndex = firstIndex + ln * pitch;
|
||||
for (size_t col = 0; col < numCols; col++)
|
||||
pixData[firstLineIndex + col] = color;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PL_NotYetImplemented();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PaintOval(const Rect *rect)
|
||||
@@ -157,7 +281,14 @@ void PaintRgn(RgnHandle region)
|
||||
|
||||
void ClipRect(const Rect *rect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
if (!rect->IsValid())
|
||||
return;
|
||||
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
if (!qdState->m_clipRegion)
|
||||
qdState->m_clipRegion = PortabilityLayer::QDUtils::CreateRegion(*rect);
|
||||
else
|
||||
PortabilityLayer::QDUtils::ResetRegionToRect(qdState->m_clipRegion, *rect);
|
||||
}
|
||||
|
||||
void FrameRect(const Rect *rect)
|
||||
@@ -239,7 +370,17 @@ Pattern *GetQDGlobalsBlack(Pattern *pattern)
|
||||
|
||||
void GetIndPattern(Pattern *pattern, int patListID, int index)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
if (index < 1)
|
||||
return;
|
||||
|
||||
PortabilityLayer::MMHandleBlock *patternList = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PAT#', patListID);
|
||||
const uint8_t *patternRes = static_cast<const uint8_t*>(patternList->m_contents);
|
||||
|
||||
int numPatterns = (patternRes[0] << 8) | patternRes[1];
|
||||
if (index > numPatterns)
|
||||
return;
|
||||
|
||||
memcpy(pattern, patternRes + 2 + (index - 1) * 8, 8);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user