# HG changeset patch # User unc0rr # Date 1391798577 -14400 # Node ID 8b65699beb56e617469c946a02dfe942b6dd1f7d # Parent b7f632c127849313b56f8e9ce337e5eabf0f372b Implement a bit of astring diff -r b7f632c12784 -r 8b65699beb56 hedgewars/uVisualGears.pas --- a/hedgewars/uVisualGears.pas Fri Feb 07 15:44:27 2014 +0400 +++ b/hedgewars/uVisualGears.pas Fri Feb 07 22:42:57 2014 +0400 @@ -51,18 +51,14 @@ , uVisualGearsList; procedure AddDamageTag(X, Y, Damage, Color: LongWord); -var s: shortstring; - Gear: PVisualGear; +var Gear: PVisualGear; begin if cAltDamage then begin Gear:= AddVisualGear(X, Y, vgtSmallDamageTag); if Gear <> nil then with Gear^ do - begin - str(Damage, s); - Tex:= RenderStringTex(s, Color, fntSmall); - end + Tex:= RenderStringTex(ansistring(inttostr(Damage)), Color, fntSmall); end end; diff -r b7f632c12784 -r 8b65699beb56 project_files/hwc/rtl/misc.h --- a/project_files/hwc/rtl/misc.h Fri Feb 07 15:44:27 2014 +0400 +++ b/project_files/hwc/rtl/misc.h Fri Feb 07 22:42:57 2014 +0400 @@ -45,9 +45,9 @@ bool fpcrtl_strcomparec(string255 a, char b); bool fpcrtl_strncompare(string255 a, string255 b); -#define fpcrtl__pchar(s) ((s).str) +char* fpcrtl__pchar(string255 s); string255 fpcrtl_pchar2str(char *s); - +astring fpcrtl_str2astr(string255 s); #define fpcrtl_TypeInfo sizeof // dummy #ifdef EMSCRIPTEN diff -r b7f632c12784 -r 8b65699beb56 project_files/hwc/rtl/pas2c.h --- a/project_files/hwc/rtl/pas2c.h Fri Feb 07 15:44:27 2014 +0400 +++ b/project_files/hwc/rtl/pas2c.h Fri Feb 07 22:42:57 2014 +0400 @@ -7,32 +7,35 @@ #include #define MAX_PARAMS 64 +#define MAX_ANSISTRING_LENGTH 16384 typedef union string255_ { struct { - unsigned char s[257]; + unsigned char s[256]; }; struct { unsigned char len; - unsigned char str[256]; + unsigned char str[255]; }; } string255; -typedef struct string192_ - { - unsigned char s[193]; - } string192; -typedef struct string31_ + +typedef union astring_ { - unsigned char s[32]; - } string31; -typedef struct string15_ - { - unsigned char s[16]; - } string15; + struct { + unsigned char _dummy1; + string255 str255; + }; + struct { + unsigned char _dummy2; + unsigned char str[MAX_ANSISTRING_LENGTH]; + }; + struct { + uint16_t len; + }; + } astring; typedef string255 shortstring; -typedef string255 ansistring; typedef uint8_t Byte; typedef int8_t ShortInt; diff -r b7f632c12784 -r 8b65699beb56 tools/pas2c/Pas2C.hs --- a/tools/pas2c/Pas2C.hs Fri Feb 07 15:44:27 2014 +0400 +++ b/tools/pas2c/Pas2C.hs Fri Feb 07 22:42:57 2014 +0400 @@ -1200,6 +1200,7 @@ ("pchar", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pchar" $ BTPointerTo BTChar)) ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar)) ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString)) + ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString)) (a, _) -> do e <- expr2C expr t <- id2C IOLookup t'