mirror of https://github.com/PrimeDecomp/prime.git
Text parser progress, add missing OSFont.c file
This commit is contained in:
parent
cc524f13d4
commit
a425ca9b42
|
@ -14908,8 +14908,8 @@ fn_80355E6C = .text:0x80355E6C; // type:function size:0x54
|
|||
__ct__6CModelFRCQ24rstl12auto_ptr<Uc>iR12IObjectStore = .text:0x80355EC0; // type:function size:0x324 scope:global
|
||||
fn_803561E4 = .text:0x803561E4; // type:function size:0x7C
|
||||
fn_80356260 = .text:0x80356260; // type:function size:0xE0
|
||||
advanceSectionInfo = .text:0x80356340; // type:function size:0x3C scope:global
|
||||
fn_8035637C = .text:0x8035637C; // type:function size:0xD0
|
||||
MemoryFromPartData__FRPUcRPi = .text:0x80356340; // type:function size:0x3C scope:local
|
||||
reserve__Q24rstl52vector<Q26CModel7SShader,Q24rstl17rmemory_allocator>Fi = .text:0x8035637C; // type:function size:0xD0
|
||||
fn_8035644C = .text:0x8035644C; // type:function size:0x4C
|
||||
fn_80356498 = .text:0x80356498; // type:function size:0x68
|
||||
FStringTableFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x80356500; // type:function size:0x64 scope:global
|
||||
|
|
|
@ -14923,8 +14923,8 @@ fn_80355E6C = .text:0x80355F70; // type:function size:0x54 scope:global
|
|||
__ct__6CModelFRCQ24rstl12auto_ptr<Uc>iR12IObjectStore = .text:0x80355FC4; // type:function size:0x324 scope:global
|
||||
fn_803561E4 = .text:0x803562E8; // type:function size:0x7C scope:global
|
||||
fn_80356260 = .text:0x80356364; // type:function size:0xE0 scope:global
|
||||
advanceSectionInfo = .text:0x80356444; // type:function size:0x3C scope:global
|
||||
fn_8035637C = .text:0x80356480; // type:function size:0xD0 scope:global
|
||||
MemoryFromPartData__FRPUcRPi = .text:0x80356444; // type:function size:0x3C scope:local
|
||||
reserve__Q24rstl52vector<Q26CModel7SShader,Q24rstl17rmemory_allocator>Fi = .text:0x80356480; // type:function size:0xD0 scope:global
|
||||
fn_8035644C = .text:0x80356550; // type:function size:0x4C scope:global
|
||||
fn_80356498 = .text:0x8035659C; // type:function size:0x68 scope:global
|
||||
FStringTableFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x80356604; // type:function size:0x64 scope:global
|
||||
|
@ -19056,7 +19056,7 @@ DSPInitCode = .data:0x803F1188; // type:object size:0x80 scope:local
|
|||
@86 = .data:0x803F18B4; // type:object size:0x35 scope:local data:string
|
||||
@87 = .data:0x803F18EC; // type:object size:0x40 scope:local
|
||||
HankakuToCode = .data:0x803F1930; // type:object size:0x180 scope:global
|
||||
Zenkaku2Code = .data:0x803F1AB0; // type:object size:0x98a scope:global
|
||||
Zenkaku2Code = .data:0x803F1AB0; // type:object size:0x98A scope:global
|
||||
InterruptPrioTable = .data:0x803F2440; // type:object size:0x2C scope:local data:4byte
|
||||
@62 = .data:0x803F2470; // type:object size:0x25 scope:local data:string
|
||||
@167 = .data:0x803F2498; // type:object size:0x27 scope:local data:string
|
||||
|
|
|
@ -672,7 +672,7 @@ config.libs = [
|
|||
Object(NonMatching, "MetroidPrime/Enemies/CEyeBall.cpp"),
|
||||
Object(NonMatching, "MetroidPrime/CIkChain.cpp"),
|
||||
Object(Matching, "MetroidPrime/ScriptObjects/CScriptCameraPitchVolume.cpp"),
|
||||
Object(Matching if config.version == "GM8E01_00" else NonMatching, "MetroidPrime/RumbleFxTable.cpp"),
|
||||
Object(MatchingFor("GM8E01_00"), "MetroidPrime/RumbleFxTable.cpp"),
|
||||
Object(NonMatching, "MetroidPrime/Enemies/CElitePirate.cpp"),
|
||||
Object(Matching, "MetroidPrime/CRumbleManager.cpp"),
|
||||
Object(NonMatching, "MetroidPrime/Enemies/CBouncyGrenade.cpp"),
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
#ifndef _CCUBEMODEL
|
||||
#define _CCUBEMODEL
|
||||
|
||||
#include <Kyoto/TToken.hpp>
|
||||
#include <rstl/vector.hpp>
|
||||
|
||||
class CAABox;
|
||||
class IObjectStore;
|
||||
class CTexture;
|
||||
class CTransform4f;
|
||||
class CCubeSurface;
|
||||
|
||||
class CCubeModel {
|
||||
public:
|
||||
CCubeModel(rstl::vector< CCubeSurface* >* surfaces, rstl::vector< TCachedToken< CTexture > >* textures,
|
||||
void* materialData, void* positions, void* normals, void* vtxColors, void* floatUvs,
|
||||
void* shortUvs, const CAABox& aabox, uint visorFlags, bool texturesLoaded, uint idx);
|
||||
static void SetRenderModelBlack(bool v);
|
||||
static void DisableShadowMaps();
|
||||
static void EnableShadowMaps(const CTexture*, const CTransform4f&, unsigned char, unsigned char);
|
||||
static void SetDrawingOccluders(bool);
|
||||
static void MakeTexturesFromMats(uchar* data, rstl::vector< TCachedToken< CTexture > >& textures,
|
||||
IObjectStore& store, bool cache);
|
||||
};
|
||||
|
||||
#endif // _CCUBEMODEL
|
||||
|
|
|
@ -1,17 +1,50 @@
|
|||
#ifndef _CMODEL
|
||||
#define _CMODEL
|
||||
|
||||
class CModelFlags;
|
||||
#include "Kyoto/Graphics/CCubeModel.hpp"
|
||||
#include "rstl/single_ptr.hpp"
|
||||
#include <Kyoto/Graphics/CTexture.hpp>
|
||||
#include <Kyoto/TToken.hpp>
|
||||
#include <rstl/auto_ptr.hpp>
|
||||
#include <rstl/vector.hpp>
|
||||
|
||||
class CModelFlags;
|
||||
class IObjectStore;
|
||||
class CCubeSurface;
|
||||
class CModel {
|
||||
struct SShader {
|
||||
rstl::vector< TCachedToken< CTexture > > x0_textures;
|
||||
uchar* x10_data;
|
||||
|
||||
SShader(uchar* data) : x10_data(data) {};
|
||||
|
||||
void UnlockTextures();
|
||||
};
|
||||
static uint sTotalMemory;
|
||||
static CModel* sThisFrameList;
|
||||
static CModel* sOneFrameList;
|
||||
static CModel* sTwoFrameList;
|
||||
|
||||
public:
|
||||
CModel(const rstl::auto_ptr< uchar >& data, int length, IObjectStore& store);
|
||||
void Touch(int) const;
|
||||
void Draw(const CModelFlags&) const;
|
||||
bool IsLoaded(int matIdx) const;
|
||||
|
||||
static void AddToTotal(uint amt) { sTotalMemory += amt; }
|
||||
static void RemoveFromTotal(uint amt) { sTotalMemory -= amt; }
|
||||
|
||||
private:
|
||||
rstl::auto_ptr< uchar > x0_data;
|
||||
uint x4_dataLen;
|
||||
rstl::vector< CCubeSurface* > x8_surfaces;
|
||||
rstl::vector<SShader> x18_matSets;
|
||||
rstl::single_ptr<CCubeModel> x28_modelInstance;
|
||||
ushort x2c_currentMatxIdx;
|
||||
ushort x2e_lastMaterialFrame;
|
||||
CModel* x30_prev;
|
||||
CModel* x34_next;
|
||||
uint x38_lastFrame;
|
||||
};
|
||||
|
||||
#endif // _CMODEL
|
||||
|
|
|
@ -6,50 +6,85 @@
|
|||
#include "Kyoto/Math/CTransform4f.hpp"
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CInputStream;
|
||||
class CMatrix3f {
|
||||
static const CMatrix3f sIdentity;
|
||||
|
||||
public:
|
||||
CMatrix3f(float _m00, float _m01, float _m02, float _m10, float _m11, float _m12, float _m20,
|
||||
float _m21, float _m22)
|
||||
: m00(_m00)
|
||||
, m01(_m01)
|
||||
, m02(_m02)
|
||||
, m10(_m10)
|
||||
, m11(_m11)
|
||||
, m12(_m12)
|
||||
, m20(_m20)
|
||||
, m21(_m21)
|
||||
, m22(_m22) {}
|
||||
CMatrix3f(const CVector3f& _m0, const CVector3f& _m1, const CVector3f& _m2);
|
||||
CMatrix3f(const CMatrix3f& left, float leftScale, const CMatrix3f& right, float rightScale);
|
||||
CMatrix3f(CInputStream& in);
|
||||
CMatrix3f(const CMatrix3f&);
|
||||
CMatrix3f(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2);
|
||||
// fake but useful for CEulerAngles?
|
||||
CMatrix3f(const CTransform4f& xf);/*
|
||||
: m0(xf.GetRow(kDX))
|
||||
, m1(xf.GetRow(kDY))
|
||||
, m2(xf.GetRow(kDZ)) {}*/
|
||||
CMatrix3f(const CTransform4f& xf); /*
|
||||
: m0(xf.GetRow(kDX))
|
||||
, m1(xf.GetRow(kDY))
|
||||
, m2(xf.GetRow(kDZ)) {}*/
|
||||
|
||||
void RotateY(const CRelAngle& angle);
|
||||
void RotateZ(const CRelAngle& angle);
|
||||
const CMatrix3f& operator=(const CMatrix3f& other);
|
||||
const CVector3f operator*(const CVector3f&) const;
|
||||
const CMatrix3f operator*(const CMatrix3f&) const;
|
||||
|
||||
static const CMatrix3f& Identity() { return sIdentity; }
|
||||
|
||||
CMatrix3f Orthonormalized() const;
|
||||
float Determinant() const;
|
||||
void AddScaledMatrix(const CMatrix3f& mat, float scale);
|
||||
|
||||
// TODO: names/check
|
||||
inline const CVector3f& GetRow(EDimX dim) const { return m0; }
|
||||
inline const CVector3f& GetRow(EDimY dim) const { return m1; }
|
||||
inline const CVector3f& GetRow(EDimZ dim) const { return m2; }
|
||||
inline const CVector3f& GetRow(EDimX dim) const {
|
||||
return *reinterpret_cast< const CVector3f* >(&m00);
|
||||
}
|
||||
inline const CVector3f& GetRow(EDimY dim) const {
|
||||
return *reinterpret_cast< const CVector3f* >(&m10);
|
||||
}
|
||||
inline const CVector3f& GetRow(EDimZ dim) const {
|
||||
return *reinterpret_cast< const CVector3f* >(&m20);
|
||||
}
|
||||
|
||||
float Get00() const { return m0.GetX(); }
|
||||
float Get01() const { return m0.GetY(); }
|
||||
float Get02() const { return m0.GetZ(); }
|
||||
float Get10() const { return m1.GetX(); }
|
||||
float Get11() const { return m1.GetY(); }
|
||||
float Get12() const { return m1.GetZ(); }
|
||||
float Get20() const { return m2.GetX(); }
|
||||
float Get21() const { return m2.GetY(); }
|
||||
float Get22() const { return m2.GetZ(); }
|
||||
float Get00() const { return m00; }
|
||||
float Get01() const { return m01; }
|
||||
float Get02() const { return m02; }
|
||||
float Get10() const { return m10; }
|
||||
float Get11() const { return m11; }
|
||||
float Get12() const { return m12; }
|
||||
float Get20() const { return m20; }
|
||||
float Get21() const { return m21; }
|
||||
float Get22() const { return m22; }
|
||||
|
||||
inline CVector3f GetColumn(EDimY dim) const { return CVector3f(m0.GetY(), m1.GetY(), m2.GetY()); }
|
||||
inline CVector3f GetColumn(EDimY dim) const { return CVector3f(m01, m11, m21); }
|
||||
|
||||
static CMatrix3f FromTransform(const CTransform4f& xf);/* {
|
||||
return CMatrix3f(xf.GetRow(kDX), xf.GetRow(kDY), xf.GetRow(kDZ));
|
||||
}*/
|
||||
static CMatrix3f FromTransform(const CTransform4f& xf); /* {
|
||||
return CMatrix3f(xf.GetRow(kDX), xf.GetRow(kDY), xf.GetRow(kDZ));
|
||||
}*/
|
||||
|
||||
private:
|
||||
// TODO maybe individual floats
|
||||
CVector3f m0;
|
||||
CVector3f m1;
|
||||
CVector3f m2;
|
||||
float m00;
|
||||
float m01;
|
||||
float m02;
|
||||
float m10;
|
||||
float m11;
|
||||
float m12;
|
||||
float m20;
|
||||
float m21;
|
||||
float m22;
|
||||
// CVector3f m0;
|
||||
// CVector3f m1;
|
||||
// CVector3f m2;
|
||||
};
|
||||
CHECK_SIZEOF(CMatrix3f, 0x24);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _CFONTRENDERSTATE
|
||||
|
||||
#include "Kyoto/Text/CDrawStringOptions.hpp"
|
||||
#include "Kyoto/Text/CRasterFont.hpp"
|
||||
#include "Kyoto/Text/CSaveableState.hpp"
|
||||
#include "Kyoto/Text/TextCommon.hpp"
|
||||
|
||||
|
@ -17,6 +18,7 @@ public:
|
|||
void RefreshPalette();
|
||||
CDrawStringOptions& GetOptions() { return x0_state.GetOptions(); }
|
||||
TToken< CRasterFont >& GetFont() { return x0_state.GetFont(); }
|
||||
void SetFont(const TToken<CRasterFont>& font) { x0_state.SetFont(font); }
|
||||
rstl::vector< CTextColor >& GetColors() { return x0_state.GetColors(); }
|
||||
rstl::vector< bool >& GetOverride() { return x0_state.GetOverride(); }
|
||||
void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); }
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
|
||||
CDrawStringOptions& GetOptions() { return x0_drawStringOptions; }
|
||||
TToken<CRasterFont>& GetFont() { return *x48_font; }
|
||||
void SetFont(const TToken<CRasterFont>& font) { x48_font = font; }
|
||||
rstl::vector<CTextColor>& GetColors() { return x54_colors; }
|
||||
rstl::vector<bool>& GetOverride() { return x64_colorOverrides; }
|
||||
void SetLineSpacing(float spacing) { x74_lineSpacing = spacing; }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _CTEXTEXECUTEBUFFER
|
||||
#define _CTEXTEXECUTEBUFFER
|
||||
|
||||
#include "Kyoto/Text/TextCommon.hpp"
|
||||
#include "rstl/list.hpp"
|
||||
#include "rstl/rc_ptr.hpp"
|
||||
|
||||
|
@ -15,6 +16,14 @@ class CTextExecuteBuffer {
|
|||
|
||||
public:
|
||||
CTextExecuteBuffer();
|
||||
|
||||
void AddFont(const TToken< CRasterFont >& font);
|
||||
void AddLineSpacing(float spacing);
|
||||
void AddLineExtraSpace(int space);
|
||||
void AddJustification(EJustification just);
|
||||
void AddVerticalJustification(EVerticalJustification just);
|
||||
void AddPushState();
|
||||
void AddPopState();
|
||||
|
||||
private:
|
||||
InstList x0_instructions;
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#include <types.h>
|
||||
|
||||
#include <Kyoto/Text/CTextColor.hpp>
|
||||
#include <Kyoto/TToken.hpp>
|
||||
|
||||
class IObjectStore;
|
||||
class CRasterFont;
|
||||
class CTextExecuteBuffer;
|
||||
|
||||
class CTextParser {
|
||||
|
@ -14,7 +16,7 @@ public:
|
|||
CTextParser(IObjectStore& store);
|
||||
void ParseText(CTextExecuteBuffer&, const wchar_t* str, int len);
|
||||
uint GetAssetIdFromString(const rstl::string& str);
|
||||
uint GetFont(const wchar_t* str, int len);
|
||||
TToken< CRasterFont > GetFont(const wchar_t* str, int len);
|
||||
uint GetImage(const wchar_t* str, int len);
|
||||
uint HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* str, int len);
|
||||
void ParseTag(CTextExecuteBuffer&, const wchar_t* str, int len);
|
||||
|
|
|
@ -0,0 +1,356 @@
|
|||
#include <dolphin/OSRtcPriv.h>
|
||||
#include <dolphin/hw_regs.h>
|
||||
#include <dolphin/os.h>
|
||||
|
||||
static OSFontHeader* FontData;
|
||||
static u8* SheetImage;
|
||||
static u8* WidthTable;
|
||||
static int CharsInSheet;
|
||||
|
||||
static u16 HankakuToCode[] = {
|
||||
0x20C, 0x20D, 0x20E, 0x20F, 0x210, 0x211, 0x212, 0x213, 0x214, 0x215, 0x216, 0x217, 0x218,
|
||||
0x219, 0x21A, 0x21B, 0x21C, 0x21D, 0x21E, 0x21F, 0x220, 0x221, 0x222, 0x223, 0x224, 0x225,
|
||||
0x226, 0x227, 0x228, 0x229, 0x22A, 0x22B, 0x22C, 0x22D, 0x22E, 0x22F, 0x230, 0x231, 0x232,
|
||||
0x233, 0x234, 0x235, 0x236, 0x237, 0x238, 0x239, 0x23A, 0x23B, 0x23C, 0x23D, 0x23E, 0x23F,
|
||||
0x240, 0x241, 0x242, 0x243, 0x244, 0x245, 0x246, 0x247, 0x248, 0x249, 0x24A, 0x24B, 0x24C,
|
||||
0x24D, 0x24E, 0x24F, 0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, 0x258, 0x259,
|
||||
0x25A, 0x25B, 0x25C, 0x25D, 0x25E, 0x25F, 0x260, 0x261, 0x262, 0x263, 0x264, 0x265, 0x266,
|
||||
0x267, 0x268, 0x269, 0x26A, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C,
|
||||
0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C,
|
||||
0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x20C, 0x26B,
|
||||
0x26C, 0x26D, 0x26E, 0x26F, 0x270, 0x271, 0x272, 0x273, 0x274, 0x275, 0x276, 0x277, 0x278,
|
||||
0x279, 0x27A, 0x27B, 0x27C, 0x27D, 0x27E, 0x27F, 0x280, 0x281, 0x282, 0x283, 0x284, 0x285,
|
||||
0x286, 0x287, 0x288, 0x289, 0x28A, 0x28B, 0x28C, 0x28D, 0x28E, 0x28F, 0x290, 0x291, 0x292,
|
||||
0x293, 0x294, 0x295, 0x296, 0x297, 0x298, 0x299, 0x29A, 0x29B, 0x29C, 0x29D, 0x29E, 0x29F,
|
||||
0x2A0, 0x2A1, 0x2A2, 0x2A3, 0x2A4, 0x2A5, 0x2A6, 0x2A7, 0x2A8, 0x2A9,
|
||||
};
|
||||
|
||||
static u16 Zenkaku2Code[] = {
|
||||
0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x009, 0x00A, 0x00B, 0x00C,
|
||||
0x00D, 0x00E, 0x00F, 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x018, 0x019,
|
||||
0x01A, 0x01B, 0x01C, 0x01D, 0x01E, 0x01F, 0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026,
|
||||
0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x02D, 0x02E, 0x02F, 0x030, 0x031, 0x032, 0x033,
|
||||
0x034, 0x035, 0x036, 0x037, 0x038, 0x039, 0x03A, 0x03B, 0x03C, 0x03D, 0x03E, 0x03F, 0x040,
|
||||
0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047, 0x048, 0x049, 0x04A, 0x04B, 0x04C, 0x04D,
|
||||
0x04E, 0x04F, 0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057, 0x058, 0x059, 0x05A,
|
||||
0x05B, 0x05C, 0x05D, 0x05E, 0x05F, 0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x067,
|
||||
0x068, 0x069, 0x06A, 0x06B, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x06C, 0x06D, 0x06E, 0x06F, 0x070, 0x071, 0x072, 0x073, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x074, 0x075, 0x076, 0x077, 0x078, 0x079, 0x07A, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x07B, 0x07C, 0x07D,
|
||||
0x07E, 0x07F, 0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x087, 0x088, 0x089, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x08A, 0x08B, 0x08C, 0x08D, 0x08E, 0x08F, 0x090,
|
||||
0x091, 0x000, 0x000, 0x000, 0x000, 0x092, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x093, 0x094, 0x095, 0x096, 0x097,
|
||||
0x098, 0x099, 0x09A, 0x09B, 0x09C, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x09D,
|
||||
0x09E, 0x09F, 0x0A0, 0x0A1, 0x0A2, 0x0A3, 0x0A4, 0x0A5, 0x0A6, 0x0A7, 0x0A8, 0x0A9, 0x0AA,
|
||||
0x0AB, 0x0AC, 0x0AD, 0x0AE, 0x0AF, 0x0B0, 0x0B1, 0x0B2, 0x0B3, 0x0B4, 0x0B5, 0x0B6, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x0B7, 0x0B8, 0x0B9, 0x0BA, 0x0BB, 0x0BC, 0x0BD, 0x0BE,
|
||||
0x0BF, 0x0C0, 0x0C1, 0x0C2, 0x0C3, 0x0C4, 0x0C5, 0x0C6, 0x0C7, 0x0C8, 0x0C9, 0x0CA, 0x0CB,
|
||||
0x0CC, 0x0CD, 0x0CE, 0x0CF, 0x0D0, 0x000, 0x000, 0x000, 0x000, 0x0D1, 0x0D2, 0x0D3, 0x0D4,
|
||||
0x0D5, 0x0D6, 0x0D7, 0x0D8, 0x0D9, 0x0DA, 0x0DB, 0x0DC, 0x0DD, 0x0DE, 0x0DF, 0x0E0, 0x0E1,
|
||||
0x0E2, 0x0E3, 0x0E4, 0x0E5, 0x0E6, 0x0E7, 0x0E8, 0x0E9, 0x0EA, 0x0EB, 0x0EC, 0x0ED, 0x0EE,
|
||||
0x0EF, 0x0F0, 0x0F1, 0x0F2, 0x0F3, 0x0F4, 0x0F5, 0x0F6, 0x0F7, 0x0F8, 0x0F9, 0x0FA, 0x0FB,
|
||||
0x0FC, 0x0FD, 0x0FE, 0x0FF, 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108,
|
||||
0x109, 0x10A, 0x10B, 0x10C, 0x10D, 0x10E, 0x10F, 0x110, 0x111, 0x112, 0x113, 0x114, 0x115,
|
||||
0x116, 0x117, 0x118, 0x119, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122,
|
||||
0x123, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x124,
|
||||
0x125, 0x126, 0x127, 0x128, 0x129, 0x12A, 0x12B, 0x12C, 0x12D, 0x12E, 0x12F, 0x130, 0x131,
|
||||
0x132, 0x133, 0x134, 0x135, 0x136, 0x137, 0x138, 0x139, 0x13A, 0x13B, 0x13C, 0x13D, 0x13E,
|
||||
0x13F, 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147, 0x148, 0x149, 0x14A, 0x14B,
|
||||
0x14C, 0x14D, 0x14E, 0x14F, 0x150, 0x151, 0x152, 0x153, 0x154, 0x155, 0x156, 0x157, 0x158,
|
||||
0x159, 0x15A, 0x15B, 0x15C, 0x15D, 0x15E, 0x15F, 0x160, 0x161, 0x162, 0x163, 0x164, 0x165,
|
||||
0x166, 0x167, 0x168, 0x169, 0x16A, 0x16B, 0x16C, 0x16D, 0x16E, 0x16F, 0x170, 0x171, 0x172,
|
||||
0x173, 0x174, 0x175, 0x176, 0x177, 0x178, 0x179, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x17A, 0x17B, 0x17C, 0x17D, 0x17E, 0x17F, 0x180, 0x181, 0x182, 0x183, 0x184,
|
||||
0x185, 0x186, 0x187, 0x188, 0x189, 0x18A, 0x18B, 0x18C, 0x18D, 0x18E, 0x18F, 0x190, 0x191,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x192, 0x193, 0x194, 0x195, 0x196,
|
||||
0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0x19E, 0x19F, 0x1A0, 0x1A1, 0x1A2, 0x1A3,
|
||||
0x1A4, 0x1A5, 0x1A6, 0x1A7, 0x1A8, 0x1A9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x1AA, 0x1AB, 0x1AC, 0x1AD, 0x1AE, 0x1AF, 0x1B0, 0x1B1,
|
||||
0x1B2, 0x1B3, 0x1B4, 0x1B5, 0x1B6, 0x1B7, 0x1B8, 0x1B9, 0x1BA, 0x1BB, 0x1BC, 0x1BD, 0x1BE,
|
||||
0x1BF, 0x1C0, 0x1C1, 0x1C2, 0x1C3, 0x1C4, 0x1C5, 0x1C6, 0x1C7, 0x1C8, 0x1C9, 0x1CA, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x1CB, 0x1CC, 0x1CD, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6,
|
||||
0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3,
|
||||
0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0,
|
||||
0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD,
|
||||
0x1FE, 0x1FF, 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207, 0x208, 0x209, 0x20A,
|
||||
0x20B, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x20C, 0x20D, 0x20E,
|
||||
0x20F, 0x210, 0x211, 0x212, 0x213, 0x214, 0x215, 0x216, 0x217, 0x218, 0x219, 0x21A, 0x21B,
|
||||
0x21C, 0x21D, 0x21E, 0x21F, 0x220, 0x221, 0x222, 0x223, 0x224, 0x225, 0x226, 0x227, 0x228,
|
||||
0x229, 0x22A, 0x22B, 0x22C, 0x22D, 0x22E, 0x22F, 0x230, 0x231, 0x232, 0x233, 0x234, 0x235,
|
||||
0x236, 0x237, 0x238, 0x239, 0x23A, 0x23B, 0x23C, 0x23D, 0x23E, 0x23F, 0x240, 0x241, 0x242,
|
||||
0x243, 0x244, 0x245, 0x246, 0x247, 0x248, 0x249, 0x24A, 0x24B, 0x24C, 0x24D, 0x24E, 0x24F,
|
||||
0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, 0x258, 0x259, 0x25A, 0x25B, 0x25C,
|
||||
0x25D, 0x25E, 0x25F, 0x260, 0x261, 0x262, 0x263, 0x264, 0x265, 0x266, 0x267, 0x268, 0x269,
|
||||
0x26A, 0x26B, 0x26C, 0x26D, 0x26E, 0x26F, 0x270, 0x271, 0x272, 0x273, 0x274, 0x275, 0x276,
|
||||
0x277, 0x278, 0x279, 0x27A, 0x27B, 0x27C, 0x27D, 0x27E, 0x27F, 0x280, 0x281, 0x282, 0x283,
|
||||
0x284, 0x285, 0x286, 0x287, 0x288, 0x289, 0x28A, 0x28B, 0x28C, 0x28D, 0x28E, 0x28F, 0x290,
|
||||
0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0x297, 0x298, 0x299, 0x29A, 0x29B, 0x29C, 0x29D,
|
||||
0x29E, 0x29F, 0x2A0, 0x2A1, 0x2A2, 0x2A3, 0x2A4, 0x2A5, 0x2A6, 0x2A7, 0x2A8, 0x2A9, 0x2AA,
|
||||
0x2AB, 0x2AC, 0x2AD, 0x2AE, 0x2AF, 0x2B0, 0x2B1, 0x2B2, 0x2B3, 0x2B4, 0x2B5, 0x2B6, 0x2B7,
|
||||
0x2B8, 0x2B9, 0x2BA, 0x2BB, 0x2BC, 0x2BD, 0x2BE, 0x2BF, 0x2C0, 0x2C1, 0x2C2, 0x2C3, 0x2C4,
|
||||
0x2C5, 0x2C6, 0x2C7, 0x2C8, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x2C9, 0x2CA, 0x2CB,
|
||||
0x2CC, 0x2CD, 0x2CE, 0x2CF, 0x2D0, 0x2D1, 0x2D2, 0x2D3, 0x2D4, 0x2D5, 0x2D6, 0x2D7, 0x2D8,
|
||||
0x2D9, 0x2DA, 0x2DB, 0x2DC, 0x2DD, 0x2DE, 0x2DF, 0x2E0, 0x2E1, 0x2E2, 0x2E3, 0x2E4, 0x2E5,
|
||||
0x2E6, 0x000, 0x2E7, 0x2E8, 0x2E9, 0x2EA, 0x2EB, 0x2EC, 0x2ED, 0x2EE, 0x2EF, 0x2F0, 0x2F1,
|
||||
0x2F2, 0x2F3, 0x2F4, 0x2F5, 0x2F6, 0x2F7, 0x2F8, 0x2F9, 0x2FA, 0x2FB, 0x2FC, 0x2FD, 0x000,
|
||||
0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x2FE, 0x2FF, 0x300, 0x301, 0x302, 0x303,
|
||||
0x304, 0x305, 0x306, 0x307, 0x308, 0x309, 0x30A, 0x30B, 0x30C, 0x30D, 0x30E, 0x30F, 0x310,
|
||||
0x311, 0x312, 0x313, 0x314, 0x315, 0x316, 0x317, 0x318, 0x319, 0x31A, 0x31B, 0x000,
|
||||
};
|
||||
|
||||
static int GetFontCode(unsigned short code) {
|
||||
if (OSGetFontEncode() == OS_FONT_ENCODE_SJIS) {
|
||||
if (code >= 0x20 && code <= 0xDF) {
|
||||
return HankakuToCode[code - 0x20];
|
||||
}
|
||||
|
||||
if (code > 0x889E) {
|
||||
int i = ((code >> 8) - 0x88) * 188;
|
||||
int j = (code & 0xFF) - 0x40;
|
||||
|
||||
if (j >= 0x40) {
|
||||
j--;
|
||||
}
|
||||
|
||||
return (i + j + 0x2BE);
|
||||
}
|
||||
|
||||
if (code < 0x879E) {
|
||||
int i = ((code >> 8) - 0x81) * 188;
|
||||
int j = (code & 0xFF) - 0x40;
|
||||
|
||||
if (j >= 0x40) {
|
||||
j--;
|
||||
}
|
||||
|
||||
return Zenkaku2Code[i + j];
|
||||
}
|
||||
} else if (code > 0x20 && code <= 0xFF) {
|
||||
return code - 0x20;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void Decode(unsigned char* s, unsigned char* d) {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int p;
|
||||
int q;
|
||||
int r7; // huh? DWARF info says these 2 variables might be register names and not actual names.
|
||||
int r25;
|
||||
int cnt;
|
||||
int os;
|
||||
unsigned int flag;
|
||||
unsigned int code;
|
||||
|
||||
os = *(int*)(s + 0x4);
|
||||
r7 = *(int*)(s + 0x8);
|
||||
r25 = *(int*)(s + 0xC);
|
||||
|
||||
q = 0;
|
||||
flag = 0;
|
||||
p = 16;
|
||||
|
||||
do {
|
||||
// Get next mask
|
||||
if (flag == 0) {
|
||||
code = *(u32*)(s + p);
|
||||
p += sizeof(u32);
|
||||
flag = sizeof(u32) * 8;
|
||||
}
|
||||
|
||||
// Non-linked chunk
|
||||
if (code & 0x80000000) {
|
||||
d[q++] = s[r25++];
|
||||
}
|
||||
// Linked chunk
|
||||
else {
|
||||
// Read offset from link table
|
||||
j = s[r7] << 8 | s[r7 + 1];
|
||||
r7 += sizeof(u16);
|
||||
|
||||
// Apply offset
|
||||
k = q - (j & 0x0FFF);
|
||||
cnt = j >> 12;
|
||||
if (cnt == 0) {
|
||||
cnt = s[r25++] + 0x12;
|
||||
} else {
|
||||
cnt += 2;
|
||||
}
|
||||
|
||||
// Copy chunk
|
||||
for (i = 0; i < cnt; i++, q++, k++) {
|
||||
d[q] = d[k - 1];
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare next mask bit
|
||||
code <<= 1;
|
||||
flag--;
|
||||
} while (q < os);
|
||||
}
|
||||
|
||||
static u32 GetFontSize(u8* buf) {
|
||||
if (buf[0] == 'Y' && buf[1] == 'a' && buf[2] == 'y') {
|
||||
return *(u32*)(buf + 0x4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 OSGetFontEncode(void) {
|
||||
static u16 fontEncode = 0xFFFF;
|
||||
if (fontEncode <= 1) {
|
||||
return fontEncode;
|
||||
}
|
||||
switch (*(int*)OSPhysicalToCached(0xCC)) {
|
||||
case VI_NTSC:
|
||||
fontEncode = (__VIRegs[VI_DTV_STAT] & 2) ? OS_FONT_ENCODE_SJIS : OS_FONT_ENCODE_ANSI;
|
||||
break;
|
||||
|
||||
case VI_PAL:
|
||||
case VI_MPAL:
|
||||
case VI_DEBUG:
|
||||
case VI_DEBUG_PAL:
|
||||
case VI_EURGB60:
|
||||
default:
|
||||
fontEncode = OS_FONT_ENCODE_ANSI;
|
||||
}
|
||||
|
||||
return fontEncode;
|
||||
}
|
||||
|
||||
static void ReadROM(void* buf, int length, int offset) {
|
||||
int len;
|
||||
while (length > 0) {
|
||||
len = (length <= 0x100) ? length : 0x100;
|
||||
length -= len;
|
||||
|
||||
while (!__OSReadROM(buf, len, offset)) {
|
||||
;
|
||||
}
|
||||
|
||||
offset += len;
|
||||
(u8*)buf += len;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 ReadFont(void* img) {
|
||||
if (OSGetFontEncode() == OS_FONT_ENCODE_SJIS) {
|
||||
ReadROM(img, OS_FONT_ROM_SIZE_SJIS, 0x1AFF00);
|
||||
} else {
|
||||
ReadROM(img, OS_FONT_ROM_SIZE_ANSI, 0x1FCF00);
|
||||
}
|
||||
|
||||
return GetFontSize(img);
|
||||
}
|
||||
|
||||
u32 OSLoadFont(OSFontHeader* fontData, void* temp) {
|
||||
u32 size;
|
||||
|
||||
SheetImage = NULL;
|
||||
size = ReadFont(temp);
|
||||
if (size) {
|
||||
Decode(temp, (void*)fontData);
|
||||
FontData = fontData;
|
||||
WidthTable = (u8*)FontData + FontData->widthTable;
|
||||
CharsInSheet = FontData->sheetColumn * FontData->sheetRow;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
char* OSGetFontTexel(char* string, void* image, long pos, long stride, long* width) {
|
||||
unsigned short code;
|
||||
unsigned char* src;
|
||||
unsigned char* dst;
|
||||
int fontCode;
|
||||
int sheet;
|
||||
int numChars;
|
||||
int row;
|
||||
int column;
|
||||
int x;
|
||||
int y;
|
||||
int offsetSrc;
|
||||
int offsetDst;
|
||||
unsigned char* colorIndex;
|
||||
unsigned char* imageSrc;
|
||||
|
||||
//ASSERTLINE(0x1F6, FontData && !SheetImage);
|
||||
|
||||
code = *string;
|
||||
if (code == '\0') {
|
||||
return string;
|
||||
}
|
||||
|
||||
string++;
|
||||
if (OSGetFontEncode() == OS_FONT_ENCODE_SJIS) {
|
||||
if ((((code >= 0x80) && (code <= 0x9F)) || ((code >= 0xE0) && (code <= 0xFF))) &&
|
||||
((s8)*string != 0U)) {
|
||||
code = (code << 8) | (*string++); // Shift-JIS encoded byte
|
||||
}
|
||||
}
|
||||
colorIndex = &FontData->c0;
|
||||
|
||||
//ASSERTLINE(0x209, FontData->sheetFormat == GX_TF_I4);
|
||||
|
||||
fontCode = GetFontCode(code);
|
||||
|
||||
sheet = fontCode / CharsInSheet;
|
||||
numChars = fontCode - (sheet * CharsInSheet);
|
||||
row = numChars / FontData->sheetColumn;
|
||||
column = (numChars - (row * FontData->sheetColumn));
|
||||
row *= FontData->cellHeight;
|
||||
column *= FontData->cellWidth;
|
||||
imageSrc = (u8*)FontData + FontData->sheetImage;
|
||||
imageSrc += (sheet * FontData->sheetSize) / 2;
|
||||
|
||||
for (y = 0; y < FontData->cellHeight; y++) {
|
||||
for (x = 0; x < FontData->cellWidth; x++) {
|
||||
src = imageSrc + (((FontData->sheetWidth / 8) * 32) / 2) * ((row + y) / 8);
|
||||
src += ((column + x) / 8) * 16;
|
||||
src += ((row + y) % 8) * 2;
|
||||
src += ((column + x) % 8) / 4;
|
||||
|
||||
offsetSrc = (column + x) % 4;
|
||||
|
||||
dst = (u8*)image + ((y / 8) * (((stride * 4) / 8) * 32));
|
||||
dst += (((pos + x) / 8) * 32);
|
||||
dst += ((y % 8) * 4);
|
||||
dst += ((pos + x) % 8) / 2;
|
||||
|
||||
offsetDst = (pos + x) % 2;
|
||||
|
||||
*dst |= colorIndex[*src >> (6 - (offsetSrc * 2)) & 3] & ((offsetDst != 0) ? 0x0F : 0xF0);
|
||||
}
|
||||
}
|
||||
*width = WidthTable[fontCode];
|
||||
|
||||
return string;
|
||||
}
|
|
@ -9,8 +9,8 @@ uint CARAMManager::mChunkSize = 0;
|
|||
uint CARAMManager::mNumChunks = 0;
|
||||
uint* CARAMManager::mpBookKeepingMemory;
|
||||
uint CARAMManager::mPreInitializeAlloc = 16 * 1024;
|
||||
uint CARAMManager::mDMAUniqueID;
|
||||
uint CARAMManager::mChunksAllocated;
|
||||
uint CARAMManager::mDMAUniqueID = 0;
|
||||
uint CARAMManager::mChunksAllocated = 0;
|
||||
const int CARAMManager::kInvalidAlloc = -1;
|
||||
const int CARAMManager::kInvalidHandle = -1;
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#include <Kyoto/Text/CFontInstruction.hpp>
|
||||
#include <Kyoto/Text/CFontRenderState.hpp>
|
||||
#include <Kyoto/Text/CTextRenderBuffer.hpp>
|
||||
|
||||
void CFontInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
|
||||
if (buf != nullptr) {
|
||||
buf->AddFontChange(x4_font);
|
||||
}
|
||||
state.SetFont(x4_font);
|
||||
state.RefreshPalette();
|
||||
}
|
||||
|
||||
void CFontInstruction::GetAssets(rstl::vector< CToken >& assets) const {}
|
||||
|
||||
uint CFontInstruction::GetAssetCount() const { return 2; }
|
||||
|
||||
void CFontInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
|
||||
Invoke(state, buf);
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#include "Kyoto/SObjectTag.hpp"
|
||||
#include "Kyoto/Text/TextCommon.hpp"
|
||||
#include <Kyoto/Text/CTextParser.hpp>
|
||||
|
||||
#include <Kyoto/IObjectStore.hpp>
|
||||
#include <Kyoto/Text/CRasterFont.hpp>
|
||||
#include <Kyoto/Text/CTextExecuteBuffer.hpp>
|
||||
|
||||
CTextParser::CTextParser(IObjectStore& store) : mObjectStore(store) {}
|
||||
|
@ -9,7 +11,12 @@ void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int
|
|||
|
||||
uint CTextParser::GetAssetIdFromString(const rstl::string& str) {}
|
||||
|
||||
uint CTextParser::GetFont(const wchar_t* str, int len) { return -1; }
|
||||
TToken< CRasterFont > CTextParser::GetFont(const wchar_t* str, int len) {
|
||||
uint id = (GetColorValue(str) << 24) | GetColorValue(str + 2) << 16 |
|
||||
GetColorValue(str + 4) << 8 | GetColorValue(str + 6);
|
||||
|
||||
return mObjectStore.GetObj(SObjectTag('FONT', id));
|
||||
}
|
||||
|
||||
uint CTextParser::GetImage(const wchar_t* str, int len) { return -1; }
|
||||
|
||||
|
@ -17,7 +24,66 @@ uint CTextParser::HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* strin
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) {}
|
||||
void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) {
|
||||
if (BeginsWith(string, len, L"font=")) {
|
||||
buffer.AddFont(GetFont(string + 5, len - 5));
|
||||
} else if (BeginsWith(string, len, L"image=")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"fg-color=")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"main-color=")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"geometry-color=")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"outline-color=")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"color")) {
|
||||
|
||||
} else if (BeginsWith(string, len, L"line-spacing=")) {
|
||||
const float v = (float)ParseInt(string + 13, len - 13, true);
|
||||
buffer.AddLineSpacing(v / 100.f);
|
||||
} else if (BeginsWith(string, len, L"line-extra-space=")) {
|
||||
buffer.AddLineExtraSpace(ParseInt(string + 17, len - 17, true));
|
||||
} else if (BeginsWith(string, len, L"just=")) {
|
||||
if (Equals(string + 5, len - 5, L"left")) {
|
||||
buffer.AddJustification(kJustification_Left);
|
||||
} else if (Equals(string + 5, len - 5, L"center")) {
|
||||
buffer.AddJustification(kJustification_Center);
|
||||
} else if (Equals(string + 5, len - 5, L"right")) {
|
||||
buffer.AddJustification(kJustification_Right);
|
||||
} else if (Equals(string + 5, len - 5, L"full")) {
|
||||
buffer.AddJustification(kJustification_Full);
|
||||
} else if (Equals(string + 5, len - 5, L"nleft")) {
|
||||
buffer.AddJustification(kJustification_NLeft);
|
||||
} else if (Equals(string + 5, len - 5, L"ncenter")) {
|
||||
buffer.AddJustification(kJustification_NCenter);
|
||||
} else if (Equals(string + 5, len - 5, L"nright")) {
|
||||
buffer.AddJustification(kJustification_NRight);
|
||||
}
|
||||
} else if (BeginsWith(string, len, L"vjust=")) {
|
||||
if (Equals(string + 6, len - 6, L"top")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_Top);
|
||||
} else if (Equals(string + 6, len - 6, L"center")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_Center);
|
||||
} else if (Equals(string + 6, len - 6, L"bottom")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_Bottom);
|
||||
} else if (Equals(string + 6, len - 6, L"full")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_Full);
|
||||
} else if (Equals(string + 6, len - 6, L"ntop")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_NTop);
|
||||
} else if (Equals(string + 6, len - 6, L"ncenter")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_NCenter);
|
||||
} else if (Equals(string + 6, len - 6, L"nbottom")) {
|
||||
buffer.AddVerticalJustification(kVerticalJustification_NBottom);
|
||||
}
|
||||
} else if (BeginsWith(string, len, L"push")) {
|
||||
buffer.AddPushState();
|
||||
} else if (BeginsWith(string, len, L"pop")) {
|
||||
buffer.AddPopState();
|
||||
} else {
|
||||
HandleUserTag(buffer, string, len);
|
||||
}
|
||||
}
|
||||
|
||||
bool CTextParser::BeginsWith(const wchar_t* str1, int len, const wchar_t* str2) {
|
||||
int i = 0;
|
||||
|
@ -74,9 +140,7 @@ uint CTextParser::FromHex(wchar_t ch) {
|
|||
}
|
||||
|
||||
uint CTextParser::GetColorValue(const wchar_t* str) {
|
||||
uint a = (FromHex(str[0]) << 4);
|
||||
uint b = FromHex(str[1]);
|
||||
return b + a;
|
||||
return FromHex(str[1]) + (FromHex(str[0]) << 4);
|
||||
}
|
||||
|
||||
CTextColor CTextParser::ParseColor(const wchar_t* str, int len) {
|
||||
|
|
Loading…
Reference in New Issue