hedgewars/pas2cSystem.pas
author Wuzzy <almikes@aol.com>
Wed, 16 Nov 2016 18:02:22 +0100
changeset 11898 25a6faa5ac46
parent 11805 6e6248c43942
child 12109 f61bd25b9f70
permissions -rw-r--r--
Fix low gravity utility not working in Gravity script (fixes #13) Using low gravity halves the gravity. For using a range, both the minimum and maximum gravities are halved. Negative gravities are doubled. Bonus: game modifier “low gravity” will be force-disabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6512
0df7f6697939 "System" unit to help converter
unc0rr
parents:
diff changeset
     1
system;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
     2
{This file contains functions that are external}
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
     3
type
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
     4
    uinteger = uinteger;
6635
c2fa29fe2a58 Some progress, still can't find the source of bad behavior
unc0rr
parents: 6552
diff changeset
     5
    Integer = integer;
6512
0df7f6697939 "System" unit to help converter
unc0rr
parents:
diff changeset
     6
    LongInt = integer;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
     7
    LongWord = uinteger;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
     8
    Cardinal = uinteger;
6516
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
     9
    PtrInt = integer;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    10
    Word = uinteger;
6520
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    11
    Byte = integer;
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    12
    SmallInt = integer;
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    13
    ShortInt = integer;
8105
d088be5ecdcb ok at least pas2c now parses allnots.......
koda
parents: 8026
diff changeset
    14
    Int64 = integer;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    15
    QWord = uinteger;
6891
ab9843957664 Improve rendering of function types, ranges, and more
unc0rr
parents: 6873
diff changeset
    16
    GLint = integer;
11805
6e6248c43942 ansistring, not Ansistring
unc0rr
parents: 11648
diff changeset
    17
    GLsizei = integer;
6891
ab9843957664 Improve rendering of function types, ranges, and more
unc0rr
parents: 6873
diff changeset
    18
    GLuint = integer;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    19
    GLenum = integer;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    20
7044
46cb4e8cedfb Fix for Int type and sysutils in hwengine.pas
unc0rr
parents: 7041
diff changeset
    21
    int = integer;
7073
26f960656cc9 help pas2c
unc0rr
parents: 7069
diff changeset
    22
    size_t = integer;
6516
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    23
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    24
    pointer = pointer;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    25
6649
7f78e8a6db69 Fix a bug with type declaration trying to resolve type being declared
unc0rr
parents: 6635
diff changeset
    26
    float = float;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    27
    single = float;
6516
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    28
    double = float;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    29
    real = float;
6653
d45b6dbd2ad6 Move a bit further
unc0rr
parents: 6649
diff changeset
    30
    extended = float;
6891
ab9843957664 Improve rendering of function types, ranges, and more
unc0rr
parents: 6873
diff changeset
    31
    GLfloat = float;
6516
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    32
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    33
    boolean = boolean;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    34
    LongBool = boolean;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    35
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    36
    string = string;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    37
    shortstring = string;
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    38
    ansistring = string;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    39
    widechar = string;
6516
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    40
addaeb1b9539 Further progress on dealing with namespaces
unc0rr
parents: 6512
diff changeset
    41
    char = char;
6873
30840365af0a Eraser tool
unc0rr
parents: 6860
diff changeset
    42
    PChar = ^char;
6926
6e832f8f4d8e Make adler32 friendlier for pas2c - this should work the same (needs testing ofc)
nemo
parents: 6902
diff changeset
    43
    PPChar = ^Pchar;
10131
4b4a043111f4 - pas2c recognizes typecasts in initialization expressions
unc0rr
parents: 10129
diff changeset
    44
    PWideChar = ^WideChar;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    45
6520
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    46
    PByte = ^Byte;
7616
dcda1c2b77e4 Small fix
unc0rr
parents: 7151
diff changeset
    47
    PWord = ^Word;
6520
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    48
    PLongInt = ^LongInt;
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    49
    PLongWord = ^LongWord;
6fecdc5d182f Some more work on scopes
unc0rr
parents: 6516
diff changeset
    50
    PInteger = ^Integer;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    51
6663
2c4151afad0c Workaround pointers to not yet defined types
unc0rr
parents: 6653
diff changeset
    52
    Handle = integer;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    53
6893
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
    54
    png_structp = pointer;
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
    55
    png_size_t = integer;
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
    56
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    57
var
6512
0df7f6697939 "System" unit to help converter
unc0rr
parents:
diff changeset
    58
    false, true: boolean;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    59
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    60
    ord, Succ, Pred : function : integer;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    61
    inc, dec, Low, High, Lo, Hi : function : integer;
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    62
6902
7d4e5ce73b98 Make pas2c even smarter. Now uIO.c compiles fine, and only 1 warning when compiled with -Wall (clang).
unc0rr
parents: 6898
diff changeset
    63
    IOResult : integer;
6853
affeaba0af71 Fix withState' not returning lastType
unc0rr
parents: 6843
diff changeset
    64
    exit, break, halt, continue : procedure;
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    65
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    66
    TextFile, File : Handle;
6853
affeaba0af71 Fix withState' not returning lastType
unc0rr
parents: 6843
diff changeset
    67
    FileMode : integer;
6855
807156c01475 Finish the toughest part of the converter. Now it knows types of everything, so could correctly recognize bitwise operators and type convertions.
unc0rr
parents: 6854
diff changeset
    68
    exitcode : integer;
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7134
diff changeset
    69
    stdout, stderr : Handle;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    70
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    71
    sqrt, cos, sin: function : float;
7062
7efe16575779 Recognize length on arrays as a separate function
unc0rr
parents: 7054
diff changeset
    72
    pi : float;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    73
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    74
    sizeof : function : integer;
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
    75
7064
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    76
    glGetString : function : pchar;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    77
7064
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    78
    glBegin, glBindTexture, glBlendFunc, glClear, glClearColor,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    79
    glColor4ub, glColorMask, glColorPointer, glDeleteTextures,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    80
    glDisable, glDisableClientState, glDrawArrays, glEnable,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    81
    glEnableClientState, glEnd, glGenTextures, glGetIntegerv,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    82
    glHint, glLineWidth, glLoadIdentity, glMatrixMode, glPopMatrix,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    83
    glPushMatrix, glReadPixels, glRotatef, glScalef, glTexCoord2f,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    84
    glTexCoordPointer, glTexImage2D, glTexParameterf,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
    85
    glTexParameteri, glTranslatef, glVertex2d, glVertexPointer,
7065
e80e0d3273c5 Add missing identifiers
unc0rr
parents: 7064
diff changeset
    86
    glViewport, glext_LoadExtension, glDeleteRenderbuffersEXT,
e80e0d3273c5 Add missing identifiers
unc0rr
parents: 7064
diff changeset
    87
    glDeleteFramebuffersEXT, glGenFramebuffersEXT,
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
    88
    glGenRenderbuffersEXT, glBindFramebufferEXT,
7065
e80e0d3273c5 Add missing identifiers
unc0rr
parents: 7064
diff changeset
    89
    glBindRenderbufferEXT, glRenderbufferStorageEXT,
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    90
    glFramebufferRenderbufferEXT, glFramebufferTexture2DEXT,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    91
    glUniformMatrix4fv, glVertexAttribPointer, glCreateShader,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    92
    glShaderSource, glCompileShader, glGetShaderiv, glGetShaderInfoLog,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    93
    glCreateProgram, glAttachShader, glBindAttribLocation, glLinkProgram,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    94
    glDeleteShader, glGetProgramiv, glGetProgramInfoLog, glUseProgram,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    95
    glUniform1i, glGetUniformLocation, glEnableVertexAttribArray,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    96
    glGetError, glDeleteProgram, glDeleteBuffers,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
    97
    glGenBuffers, glBufferData, glBindBuffer, glewInit,
10133
d73412fbf3b4 - Remove few PAS2C ifdef's
unc0rr
parents: 10131
diff changeset
    98
    glUniform4f, glDisableVertexAttribArray, glTexEnvi,
d73412fbf3b4 - Remove few PAS2C ifdef's
unc0rr
parents: 10131
diff changeset
    99
    glLoadMatrixf, glMultMatrixf, glGetFloatv: procedure;
7064
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   100
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   101
    GL_BGRA, GL_BLEND, GL_CLAMP_TO_EDGE, GL_COLOR_ARRAY,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   102
    GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_DEPTH_COMPONENT,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   103
    GL_DITHER, GL_EXTENSIONS, GL_FALSE, GL_FASTEST, GL_LINEAR,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   104
    GL_LINE_LOOP, GL_LINES, GL_LINE_SMOOTH, GL_LINE_STRIP,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   105
    GL_MAX_TEXTURE_SIZE, GL_MODELVIEW, GL_ONE_MINUS_SRC_ALPHA,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   106
    GL_PERSPECTIVE_CORRECTION_HINT, GL_PROJECTION, GL_QUADS,
10535
428085a1be6e fix pas2c(?)
sheepluva
parents: 10319
diff changeset
   107
    GL_RENDERER, GL_RGB, GL_RGB8, GL_RGBA, GL_RGBA8, GL_SRC_ALPHA, GL_TEXTURE_2D,
7064
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   108
    GL_TEXTURE_COORD_ARRAY, GL_TEXTURE_MAG_FILTER,
0cf7cad767aa Fix casing and type for gl
nemo
parents: 7062
diff changeset
   109
    GL_TEXTURE_MIN_FILTER, GL_TEXTURE_PRIORITY, GL_TEXTURE_WRAP_S,
10319
240775460dc5 fix pas2c build
sheepluva
parents: 10133
diff changeset
   110
    GL_TEXTURE_WRAP_T, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRUE, GL_VENDOR,
7065
e80e0d3273c5 Add missing identifiers
unc0rr
parents: 7064
diff changeset
   111
    GL_VERSION, GL_VERTEX_ARRAY, GLenum,  GL_FRAMEBUFFER_EXT,
e80e0d3273c5 Add missing identifiers
unc0rr
parents: 7064
diff changeset
   112
    GL_RENDERBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
   113
    GL_COLOR_ATTACHMENT0_EXT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_COMPILE_STATUS,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
   114
    GL_INFO_LOG_LENGTH, GL_LINK_STATUS, GL_VERTEX_SHADER, GL_FRAGMENT_SHADER,
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
   115
    GL_NO_ERROR, GL_ARRAY_BUFFER, GL_STATIC_DRAW, GLEW_OK,
10133
d73412fbf3b4 - Remove few PAS2C ifdef's
unc0rr
parents: 10131
diff changeset
   116
    GL_AUX_BUFFERS, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE, GL_ADD,
d73412fbf3b4 - Remove few PAS2C ifdef's
unc0rr
parents: 10131
diff changeset
   117
    GL_MODELVIEW_MATRIX: integer;
6838
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
   118
b1a0e7a52c04 More clean namespace, some fixes
unc0rr
parents: 6837
diff changeset
   119
    TThreadId : function : integer;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 9954
diff changeset
   120
7151
ec15d9e1a7e3 pas2c stuff
unc0rr
parents: 7134
diff changeset
   121
    _strconcat, _strappend, _strprepend, _chrconcat : function : string;
10124
aabd1b75d5a3 Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents: 10120
diff changeset
   122
    _strcompare, _strncompare, _strcomparec, _strncompareA : function : boolean;
10120
b7f632c12784 Pas2C recognizes ansistrings
unc0rr
parents: 10080
diff changeset
   123
    _strconcatA, _strappendA : function : ansistring;
6893
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   124
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   125
    png_structp, png_set_write_fn, png_get_io_ptr,
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   126
    png_get_libpng_ver, png_create_write_struct,
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   127
    png_create_info_struct, png_destroy_write_struct,
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   128
    png_write_row, png_set_ihdr, png_write_info,
69cc0166be8d - Track array size to use for High function
unc0rr
parents: 6891
diff changeset
   129
    png_write_end : procedure;
6894
555a8d8db228 Some more progress with pas2c
unc0rr
parents: 6893
diff changeset
   130
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
   131
    clear_filelist_hook, add_file_hook, idb_loader_hook, mainloop_hook, drawworld_hook : procedure;
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7616
diff changeset
   132
    SDL_InitPatch : procedure;
7066
12cc2bd84b0b Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents: 7065
diff changeset
   133
11648
3bff941c035f Fix pas2c build
unc0rr
parents: 10535
diff changeset
   134
    PHYSFS_init, PHYSFS_deinit, PHYSFS_mount, PHYSFS_readBytes, PHYSFS_writeBytes, PHYSFS_read : function : LongInt;
3bff941c035f Fix pas2c build
unc0rr
parents: 10535
diff changeset
   135
    PHYSFSRWOPS_openRead, PHYSFSRWOPS_openWrite, PHYSFS_openRead, PHYSFS_openWrite : function : pointer;
3bff941c035f Fix pas2c build
unc0rr
parents: 10535
diff changeset
   136
    PHYSFS_eof, PHYSFS_close, PHYSFS_exists, PHYSFS_mkdir, PHYSFS_flush, PHYSFS_setWriteDir : function : boolean;
10080
ac51bcb534ef Even more love to pas2c
unc0rr
parents: 10015
diff changeset
   137
    PHYSFS_getLastError : function : PChar;
11648
3bff941c035f Fix pas2c build
unc0rr
parents: 10535
diff changeset
   138
    PHYSFS_enumerateFiles : function : PPChar;
3bff941c035f Fix pas2c build
unc0rr
parents: 10535
diff changeset
   139
    PHYSFS_freeList : procedure;
9260
64718974158f Reduce number of link errors
unc0rr
parents: 8105
diff changeset
   140
64718974158f Reduce number of link errors
unc0rr
parents: 8105
diff changeset
   141
    hedgewarsMountPackages, physfsReaderSetBuffer, hedgewarsMountPackage : procedure;
64718974158f Reduce number of link errors
unc0rr
parents: 8105
diff changeset
   142
    physfsReader : function : pointer;