Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,98 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Size and VideoArray extracted from defines.h, copyright 2015 Joseph Forgione.
|
||||
#pragma once
|
||||
#include "BuildConfig.h"
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
namespace VCC {
|
||||
struct Size
|
||||
{
|
||||
int w{}, h{};
|
||||
|
||||
Size() = default;
|
||||
Size(int w, int h) :w(w), h(h) {}
|
||||
};
|
||||
|
||||
template <class T, size_t Size>
|
||||
struct VideoArray
|
||||
{
|
||||
explicit VideoArray(T* p) : data(p) {}
|
||||
|
||||
#if USE_DEBUG_VIDEO_BUFFER
|
||||
T& operator[](size_t index)
|
||||
{
|
||||
assert(index < Size);
|
||||
return data[index % Size];
|
||||
}
|
||||
|
||||
const T& operator[](size_t index) const
|
||||
{
|
||||
assert(index < Size);
|
||||
return data[index % Size];
|
||||
}
|
||||
#else
|
||||
inline T& operator[](size_t index)
|
||||
{
|
||||
return data[index];
|
||||
}
|
||||
|
||||
inline const T& operator[](size_t index) const
|
||||
{
|
||||
return data[index];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
T* data;
|
||||
};
|
||||
|
||||
|
||||
// Active raster bounds, independent of pixel colors. Union all rendered rows
|
||||
// so split-screen modes retain every active column and line in a frame.
|
||||
struct VideoRect {
|
||||
int x = 0, y = 0, width = 0, height = 0;
|
||||
void include(int left, int top, int w, int h, Size limit) {
|
||||
const int right = std::clamp(left + w, 0, limit.w);
|
||||
const int bottom = std::clamp(top + h, 0, limit.h);
|
||||
left = std::clamp(left, 0, limit.w); top = std::clamp(top, 0, limit.h);
|
||||
if (right <= left || bottom <= top) return;
|
||||
if (!width || !height) { *this = {left, top, right-left, bottom-top}; return; }
|
||||
const int farX = std::max(x+width, right), farY = std::max(y+height, bottom);
|
||||
x = std::min(x,left); y = std::min(y,top); width = farX-x; height = farY-y;
|
||||
}
|
||||
};
|
||||
|
||||
// Borrowed emulated RAM and host-owned render surface. Pitch is in pixels
|
||||
// for the selected depth (0=8, 1=16, 2=24, 3=32), not bytes. The Mac path
|
||||
// uses a packed 640x480 array of uint32_t values in 0x00RRGGBB format.
|
||||
struct VideoState {
|
||||
unsigned char* RamBuffer = nullptr;
|
||||
unsigned short* WRamBuffer = nullptr;
|
||||
unsigned char BitDepth = 0;
|
||||
unsigned char* PTRsurface8 = nullptr;
|
||||
unsigned short* PTRsurface16 = nullptr;
|
||||
unsigned int* PTRsurface32 = nullptr;
|
||||
// Pixel row stride uses the same 32-bit range on Windows and macOS.
|
||||
int SurfacePitch = 0;
|
||||
unsigned short LineCounter = 0;
|
||||
unsigned char ScanLines = 0;
|
||||
Size WindowSize;
|
||||
};
|
||||
class VideoHost {
|
||||
public:
|
||||
virtual ~VideoHost() = default;
|
||||
virtual VideoState& Surface() = 0;
|
||||
virtual void ClearSurface() = 0;
|
||||
virtual bool UseNtscArtifacts() const = 0;
|
||||
virtual void ActiveVideoArea(int, int, int, int) {}
|
||||
// Called at the actual raster boundary, including when one instruction
|
||||
// (e.g. debugger-stepped 6309 TFM) spans several complete frames.
|
||||
virtual void FrameCompleted() {}
|
||||
};
|
||||
// Install before running the raster clock and detach after stopping it.
|
||||
VideoHost& Video();
|
||||
void SetVideoHost(VideoHost* host);
|
||||
}
|
||||
Reference in new issue
Block a user