port 2A step 4: platform skeleton + rest of the 2V3 header closure

- Mirror the remaining non-Python 2V3 closure headers (98 more, 173 total): EffectLib,
  EterGrnLib, SpeedTreeLib, SphereLib, PRTerrainLib, EterImageLib, EterBase/Poly, cipher/tea,
  EterLib Grp*/IME/Input/MSWindow/StateManager, GameLib actor/map/race headers, EterPack.
- SDK shims: granny.h, SpeedTreeRT.h, imm.h, Dimm.h (the SDK MIDL header, not mirrored),
  dinput/d3dx8 additions; D3D8 render-state enums, FVF macros and the COM resource hierarchy;
  more Win32 GDI/handle types with layout static_asserts.
- PORT edits for MSVC-permissive code (typename, friend visibility, <algorithm>, pointer→uintptr_t)
  and PRTerrainLib/StdAfx.h dropping the ScriptLib/Python include.
- port_logic links the vendored cryptopp/minilzo.
- extension/src/platform: port_platform target with 103 generated stub files (1917 function
  stubs, 146 static members) from the new platform_stub.py (clang -ast-dump-filter);
  MT_PLATFORM_STUB() marks every unimplemented body. libmtgodot links port_platform and
  port_gate.sh builds it.

Gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-22 21:46:24 +09:00
co-authored by Claude Opus 5
parent fc47582017
commit 9a8e11f3dd
220 changed files with 24287 additions and 25 deletions
+189 -6
View File
@@ -162,6 +162,186 @@ typedef enum _D3DLIGHTTYPE
D3DLIGHT_FORCE_DWORD = 0x7fffffff
} D3DLIGHTTYPE;
// Render-state enums and FVF/transform macros, generated from the SDK d3d8types.h.
typedef enum _D3DPRIMITIVETYPE
{
D3DPT_POINTLIST = 1,
D3DPT_LINELIST = 2,
D3DPT_LINESTRIP = 3,
D3DPT_TRIANGLELIST = 4,
D3DPT_TRIANGLESTRIP = 5,
D3DPT_TRIANGLEFAN = 6,
D3DPT_FORCE_DWORD = 0x7fffffff,
} D3DPRIMITIVETYPE;
typedef enum _D3DTRANSFORMSTATETYPE
{
D3DTS_VIEW = 2,
D3DTS_PROJECTION = 3,
D3DTS_TEXTURE0 = 16,
D3DTS_TEXTURE1 = 17,
D3DTS_TEXTURE2 = 18,
D3DTS_TEXTURE3 = 19,
D3DTS_TEXTURE4 = 20,
D3DTS_TEXTURE5 = 21,
D3DTS_TEXTURE6 = 22,
D3DTS_TEXTURE7 = 23,
D3DTS_FORCE_DWORD = 0x7fffffff,
} D3DTRANSFORMSTATETYPE;
typedef enum _D3DRENDERSTATETYPE
{
D3DRS_ZENABLE = 7,
D3DRS_FILLMODE = 8,
D3DRS_SHADEMODE = 9,
D3DRS_LINEPATTERN = 10,
D3DRS_ZWRITEENABLE = 14,
D3DRS_ALPHATESTENABLE = 15,
D3DRS_LASTPIXEL = 16,
D3DRS_SRCBLEND = 19,
D3DRS_DESTBLEND = 20,
D3DRS_CULLMODE = 22,
D3DRS_ZFUNC = 23,
D3DRS_ALPHAREF = 24,
D3DRS_ALPHAFUNC = 25,
D3DRS_DITHERENABLE = 26,
D3DRS_ALPHABLENDENABLE = 27,
D3DRS_FOGENABLE = 28,
D3DRS_SPECULARENABLE = 29,
D3DRS_ZVISIBLE = 30,
D3DRS_FOGCOLOR = 34,
D3DRS_FOGTABLEMODE = 35,
D3DRS_FOGSTART = 36,
D3DRS_FOGEND = 37,
D3DRS_FOGDENSITY = 38,
D3DRS_EDGEANTIALIAS = 40,
D3DRS_ZBIAS = 47,
D3DRS_RANGEFOGENABLE = 48,
D3DRS_STENCILENABLE = 52,
D3DRS_STENCILFAIL = 53,
D3DRS_STENCILZFAIL = 54,
D3DRS_STENCILPASS = 55,
D3DRS_STENCILFUNC = 56,
D3DRS_STENCILREF = 57,
D3DRS_STENCILMASK = 58,
D3DRS_STENCILWRITEMASK = 59,
D3DRS_TEXTUREFACTOR = 60,
D3DRS_WRAP0 = 128,
D3DRS_WRAP1 = 129,
D3DRS_WRAP2 = 130,
D3DRS_WRAP3 = 131,
D3DRS_WRAP4 = 132,
D3DRS_WRAP5 = 133,
D3DRS_WRAP6 = 134,
D3DRS_WRAP7 = 135,
D3DRS_CLIPPING = 136,
D3DRS_LIGHTING = 137,
D3DRS_AMBIENT = 139,
D3DRS_FOGVERTEXMODE = 140,
D3DRS_COLORVERTEX = 141,
D3DRS_LOCALVIEWER = 142,
D3DRS_NORMALIZENORMALS = 143,
D3DRS_DIFFUSEMATERIALSOURCE = 145,
D3DRS_SPECULARMATERIALSOURCE = 146,
D3DRS_AMBIENTMATERIALSOURCE = 147,
D3DRS_EMISSIVEMATERIALSOURCE = 148,
D3DRS_VERTEXBLEND = 151,
D3DRS_CLIPPLANEENABLE = 152,
D3DRS_SOFTWAREVERTEXPROCESSING = 153,
D3DRS_POINTSIZE = 154,
D3DRS_POINTSIZE_MIN = 155,
D3DRS_POINTSPRITEENABLE = 156,
D3DRS_POINTSCALEENABLE = 157,
D3DRS_POINTSCALE_A = 158,
D3DRS_POINTSCALE_B = 159,
D3DRS_POINTSCALE_C = 160,
D3DRS_MULTISAMPLEANTIALIAS = 161,
D3DRS_MULTISAMPLEMASK = 162,
D3DRS_PATCHEDGESTYLE = 163,
D3DRS_PATCHSEGMENTS = 164,
D3DRS_DEBUGMONITORTOKEN = 165,
D3DRS_POINTSIZE_MAX = 166,
D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
D3DRS_COLORWRITEENABLE = 168,
D3DRS_TWEENFACTOR = 170,
D3DRS_BLENDOP = 171,
D3DRS_POSITIONORDER = 172,
D3DRS_NORMALORDER = 173,
D3DRS_FORCE_DWORD = 0x7fffffff,
} D3DRENDERSTATETYPE;
typedef enum _D3DTEXTURESTAGESTATETYPE
{
D3DTSS_COLOROP = 1,
D3DTSS_COLORARG1 = 2,
D3DTSS_COLORARG2 = 3,
D3DTSS_ALPHAOP = 4,
D3DTSS_ALPHAARG1 = 5,
D3DTSS_ALPHAARG2 = 6,
D3DTSS_BUMPENVMAT00 = 7,
D3DTSS_BUMPENVMAT01 = 8,
D3DTSS_BUMPENVMAT10 = 9,
D3DTSS_BUMPENVMAT11 = 10,
D3DTSS_TEXCOORDINDEX = 11,
D3DTSS_ADDRESSU = 13,
D3DTSS_ADDRESSV = 14,
D3DTSS_BORDERCOLOR = 15,
D3DTSS_MAGFILTER = 16,
D3DTSS_MINFILTER = 17,
D3DTSS_MIPFILTER = 18,
D3DTSS_MIPMAPLODBIAS = 19,
D3DTSS_MAXMIPLEVEL = 20,
D3DTSS_MAXANISOTROPY = 21,
D3DTSS_BUMPENVLSCALE = 22,
D3DTSS_BUMPENVLOFFSET = 23,
D3DTSS_TEXTURETRANSFORMFLAGS = 24,
D3DTSS_ADDRESSW = 25,
D3DTSS_COLORARG0 = 26,
D3DTSS_ALPHAARG0 = 27,
D3DTSS_RESULTARG = 28,
D3DTSS_FORCE_DWORD = 0x7fffffff,
} D3DTEXTURESTAGESTATETYPE;
#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
#define D3DTS_WORLD D3DTS_WORLDMATRIX(0)
#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
#define D3DFVF_RESERVED0 0x001
#define D3DFVF_POSITION_MASK 0x00E
#define D3DFVF_XYZ 0x002
#define D3DFVF_XYZRHW 0x004
#define D3DFVF_XYZB1 0x006
#define D3DFVF_XYZB2 0x008
#define D3DFVF_XYZB3 0x00a
#define D3DFVF_XYZB4 0x00c
#define D3DFVF_XYZB5 0x00e
#define D3DFVF_NORMAL 0x010
#define D3DFVF_PSIZE 0x020
#define D3DFVF_DIFFUSE 0x040
#define D3DFVF_SPECULAR 0x080
#define D3DFVF_TEXCOUNT_MASK 0xf00
#define D3DFVF_TEXCOUNT_SHIFT 8
#define D3DFVF_TEX0 0x000
#define D3DFVF_TEX1 0x100
#define D3DFVF_TEX2 0x200
#define D3DFVF_TEX3 0x300
#define D3DFVF_TEX4 0x400
#define D3DFVF_TEX5 0x500
#define D3DFVF_TEX6 0x600
#define D3DFVF_TEX7 0x700
#define D3DFVF_TEX8 0x800
#define D3DFVF_LASTBETA_UBYTE4 0x1000
#define D3DFVF_RESERVED2 0xE000
#define D3DFVF_TEXTUREFORMAT2 0
#define D3DFVF_TEXTUREFORMAT1 3
#define D3DFVF_TEXTUREFORMAT3 1
#define D3DFVF_TEXTUREFORMAT4 2
#define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
#define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
#define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
#define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
typedef struct _D3DDISPLAYMODE
{
UINT Width;
@@ -293,16 +473,19 @@ typedef struct _D3DCAPS8
float MaxPixelShaderValue;
} D3DCAPS8;
// COM interfaces: opaque here; platform/ owns every instance.
// COM interfaces: no methods here; platform/ owns every instance. The resource hierarchy is kept
// so the implicit upcasts 40250 relies on (texture -> base texture) compile.
struct IDirect3D8;
struct IDirect3DDevice8;
struct IDirect3DBaseTexture8;
struct IDirect3DTexture8;
struct IDirect3DSurface8;
struct IDirect3DVertexBuffer8;
struct IDirect3DIndexBuffer8;
struct IDirect3DResource8 {};
struct IDirect3DBaseTexture8 : IDirect3DResource8 {};
struct IDirect3DTexture8 : IDirect3DBaseTexture8 {};
struct IDirect3DSurface8 : IDirect3DResource8 {};
struct IDirect3DVertexBuffer8 : IDirect3DResource8 {};
struct IDirect3DIndexBuffer8 : IDirect3DResource8 {};
typedef IDirect3D8* LPDIRECT3D8;
typedef IDirect3DDevice8* LPDIRECT3DDEVICE8;
typedef IDirect3DResource8* LPDIRECT3DRESOURCE8;
typedef IDirect3DBaseTexture8* LPDIRECT3DBASETEXTURE8;
typedef IDirect3DTexture8* LPDIRECT3DTEXTURE8;
typedef IDirect3DSurface8* LPDIRECT3DSURFACE8;
+57
View File
@@ -55,6 +55,12 @@ typedef DWORD* PDWORD;
typedef LONG* LPLONG;
typedef BOOL* LPBOOL;
typedef INT* LPINT;
typedef INT* PINT;
typedef UINT* PUINT;
typedef WCHAR* LPWSTR;
typedef const WCHAR* LPCWSTR;
typedef uintptr_t SIZE_T;
typedef WORD LANGID;
typedef intptr_t INT_PTR;
typedef uintptr_t UINT_PTR;
@@ -82,6 +88,16 @@ typedef HINSTANCE__* HINSTANCE;
typedef HINSTANCE HMODULE;
struct HDC__;
typedef HDC__* HDC;
struct HBITMAP__;
typedef HBITMAP__* HBITMAP;
struct HICON__;
typedef HICON__* HICON;
typedef HICON HCURSOR;
struct HBRUSH__;
typedef HBRUSH__* HBRUSH;
struct HKL__;
typedef HKL__* HKL;
typedef LRESULT (*WNDPROC)(HWND, UINT, WPARAM, LPARAM);
typedef struct tagPOINT
{
@@ -168,6 +184,45 @@ typedef struct tagTEXTMETRICA
BYTE tmCharSet;
} TEXTMETRICA, TEXTMETRIC, *PTEXTMETRIC, *LPTEXTMETRIC;
typedef struct tagBITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, *LPBITMAPINFOHEADER;
typedef struct tagRGBQUAD
{
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
typedef struct tagBITMAPINFO
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *LPBITMAPINFO;
typedef struct _OSVERSIONINFOA
{
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
CHAR szCSDVersion[128];
} OSVERSIONINFOA, OSVERSIONINFO, *LPOSVERSIONINFOA, *LPOSVERSIONINFO;
struct HFONT__;
typedef HFONT__* HFONT;
@@ -215,4 +270,6 @@ static_assert(sizeof(SHORT) == 2 && sizeof(FLOAT) == 4, "Win32 short/float width
static_assert(sizeof(POINT) == 8 && sizeof(RECT) == 16, "Win32 POINT/RECT layout");
static_assert(sizeof(GUID) == 16 && sizeof(LARGE_INTEGER) == 8, "Win32 GUID/LARGE_INTEGER layout");
static_assert(sizeof(LOGFONTA) == 60 && sizeof(TEXTMETRICA) == 56, "Win32 GDI struct layout");
static_assert(sizeof(OSVERSIONINFOA) == 148, "Win32 OSVERSIONINFOA layout");
static_assert(sizeof(BITMAPINFOHEADER) == 40 && sizeof(BITMAPINFO) == 44, "Win32 DIB header layout");
static_assert(sizeof(WPARAM) == sizeof(void*) && sizeof(HANDLE) == sizeof(void*), "handles stay pointer-sized");
@@ -0,0 +1,21 @@
#pragma once
// Shim for IDV SpeedTreeRT <SpeedTreeRT.h> (40250 extern/include): the CSpeedTreeRT members that
// SpeedTreeLib headers name. Tree geometry and wind go through platform/, which defines them.
class CSpeedTreeRT
{
public:
enum ECollisionObjectType
{
CO_SPHERE,
CO_CYLINDER,
CO_BOX
};
struct SGeometry;
struct STextures;
float GetLeafLightingAdjustment() const;
float SetWindStrength(float fNewStrength, float fOldStrength = -1.0f, float fFrequencyTimeOffset = -1.0f);
void GetCollisionObject(unsigned int nIndex, ECollisionObjectType& eType, float* pPosition, float* pDimensions);
};
+2 -1
View File
@@ -1,4 +1,5 @@
#pragma once
// Shim for <d3d8.h>: the D3D8 value types 40250 logic uses as data. Rendering goes through
// platform/, never through these declarations.
// platform/, never through these declarations. The real header pulls in <string.h> (objbase.h).
#include <string.h>
#include "../../D3DXMath.h"
@@ -0,0 +1,70 @@
#pragma once
// Shim for RAD Granny 2.11 <granny.h> (40250 extern/include): the scalar types and structs that
// EterGrnLib headers name, with the SDK's layout; every other Granny object is opaque. Loading and
// skinning go through platform/ (backed by libgr2), never through these declarations.
#include <stdint.h>
typedef uint32_t granny_uint32;
typedef int32_t granny_int32;
typedef uint16_t granny_uint16;
typedef int16_t granny_int16;
typedef uint8_t granny_uint8;
typedef int8_t granny_int8;
typedef float granny_real32;
typedef granny_uint32 granny_bool32;
typedef uintptr_t granny_uintaddrx;
typedef granny_real32 granny_triple[3];
typedef granny_real32 granny_quad[4];
typedef enum granny_member_type
{
GrannyEndMember,
GrannyInlineMember,
GrannyReferenceMember,
GrannyReferenceToArrayMember,
GrannyArrayOfReferencesMember,
GrannyVariantReferenceMember,
GrannyUnsupportedMemberType_Remove,
GrannyReferenceToVariantArrayMember,
GrannyStringMember,
GrannyTransformMember,
GrannyReal32Member,
GrannyInt8Member,
GrannyUInt8Member,
GrannyBinormalInt8Member,
GrannyNormalUInt8Member,
GrannyInt16Member,
GrannyUInt16Member,
GrannyBinormalInt16Member,
GrannyNormalUInt16Member,
GrannyInt32Member,
GrannyUInt32Member,
GrannyReal16Member,
GrannyEmptyReferenceMember,
GrannyOnePastLastMemberType,
GrannyBool32Member = GrannyInt32Member,
Grannymember_type_forceint = 0x7fffffff
} granny_member_type;
struct granny_data_type_definition
{
granny_member_type Type;
char const* Name;
granny_data_type_definition* ReferenceType;
granny_int32 ArrayWidth;
granny_int32 Extra[3];
granny_uintaddrx Ignored_Ignored;
};
struct granny_animation;
struct granny_control;
struct granny_file;
struct granny_file_info;
struct granny_material;
struct granny_mesh;
struct granny_mesh_binding;
struct granny_mesh_deformer;
struct granny_model;
struct granny_model_instance;
struct granny_skeleton;
struct granny_world_pose;
@@ -0,0 +1,7 @@
#pragma once
// Shim for the Active IMM COM interfaces (<dimm.h>; 40250 vendors the MIDL output as
// EterLib/Dimm.h, which is the SDK header and not part of the port mirror) on non-Windows targets.
#include <imm.h>
struct IActiveIMMApp;
struct IActiveIMMMessagePumpOwner;
+11 -1
View File
@@ -1,3 +1,13 @@
#pragma once
// Shim for <dinput.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
// Shim for DirectInput 8 <dinput.h> on non-Windows targets: the interfaces 40250 headers name, as
// opaque types. Input goes through platform/.
#include "windows.h"
#ifndef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x0800
#endif
struct IDirectInput8;
struct IDirectInputDevice8;
typedef IDirectInput8* LPDIRECTINPUT8;
typedef IDirectInputDevice8* LPDIRECTINPUTDEVICE8;
@@ -0,0 +1,11 @@
#pragma once
// Shim for <imm.h> on non-Windows targets: the input-method handles 40250's IME declarations name.
// Text input goes through platform/.
#include "windows.h"
struct HIMC__;
typedef HIMC__* HIMC;
struct HIMCC__;
typedef HIMCC__* HIMCC;
struct tagINPUTCONTEXT;
typedef tagINPUTCONTEXT INPUTCONTEXT;
+15 -1
View File
@@ -1,5 +1,19 @@
#pragma once
// Shim for <windows.h> on non-Windows targets: the Win32 scalar types and CRT spellings
// 40250 sources use (common/Win32Types.h, common/Win32Crt.h).
// 40250 sources use (common/Win32Types.h, common/Win32Crt.h), plus the headers the real one pulls
// in that 40250 relies on transitively (winnt.h brings <string.h> for memcpy/memset).
#include <string.h>
#include "../../Win32Types.h"
#include "../../Win32Crt.h"
// winuser.h / wingdi.h constants named in 40250 declarations (default arguments).
#define WS_OVERLAPPED 0x00000000L
#define WS_CAPTION 0x00C00000L
#define WS_SYSMENU 0x00080000L
#define WS_THICKFRAME 0x00040000L
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MAXIMIZEBOX 0x00010000L
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define WHITE_BRUSH 0
#define BLACK_BRUSH 4
#define KL_NAMELENGTH 9