diff --git a/README.md b/README.md index 9c514a0b..87f74a33 100644 --- a/README.md +++ b/README.md @@ -3,21 +3,19 @@ Classic Tomb Raider open-source engine [WebGL build with demo level](http://xproger.info/projects/OpenLara/) -inspired by OpenTomb project http://opentomb.github.io/ +[Standalone version](https://github.com/XProger/OpenLara/releases/tag/latest) + +[Roadmap](https://github.com/XProger/OpenLara/issues/353) [![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause) ## Links -* [YouTube channel](https://youtu.be/Rbl3NmKAZoM?list=PL7DiEQQWqCj79eodyi2R_vi87IdONIR-B) -* [Discord channel](https://discord.gg/EF8JaQB) +[![Twitter](https://badgen.net/badge/icon/twitter?icon=twitter&label)](https://twitter.com/XProger_san) +[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/EF8JaQB) +[![Telegram](https://badgen.net/badge/icon/telegram?icon=telegram&label)](https://t.me/openlara) +* [YouTube channel](https://www.youtube.com/c/TimurGagiev) * [Tomb Raider Forums thread](http://www.tombraiderforums.com/showthread.php?t=216618) -## Roadmap -- graphics improvements -- bug fixes -- RELEASE 1 -- OpenLara 2... - ## Screenshots ![Waterfall](http://xproger.info/projects/OpenLara/shots/waterfall.jpg) ![Double-aim](http://xproger.info/projects/OpenLara/shots/multi-aim.jpg) diff --git a/bin/audio/1/readme.txt b/bin/audio/1/readme.txt deleted file mode 100644 index 3a620a37..00000000 --- a/bin/audio/1/readme.txt +++ /dev/null @@ -1 +0,0 @@ -- track_XX.ogg, track_XX.mp3, track_XX.wav for *_EN, *_DE, *_FR, *_IT, *_JA, *_RU \ No newline at end of file diff --git a/bin/audio/2/readme.txt b/bin/audio/2/readme.txt deleted file mode 100644 index 919f44a5..00000000 --- a/bin/audio/2/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -- track_XX.ogg, track_XX.mp3, track_XX.wav for *_EN, *_DE, *_FR, *_IT, *_JA, *_RU -- MAIN.SFX \ No newline at end of file diff --git a/bin/audio/3/readme.txt b/bin/audio/3/readme.txt deleted file mode 100644 index 123a51a5..00000000 --- a/bin/audio/3/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -- cdaudio.wad -- MAIN.SFX \ No newline at end of file diff --git a/bin/level/1/readme.txt b/bin/level/1/readme.txt deleted file mode 100644 index ea5d0741..00000000 --- a/bin/level/1/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -- *.PHD, *.PSX -- *.PCX \ No newline at end of file diff --git a/bin/level/2/readme.txt b/bin/level/2/readme.txt deleted file mode 100644 index 228be7e5..00000000 --- a/bin/level/2/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -- *.TR2, *.PSX -- *.PCX \ No newline at end of file diff --git a/bin/level/3/readme.txt b/bin/level/3/readme.txt deleted file mode 100644 index a83abc9b..00000000 --- a/bin/level/3/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -- *.TR2 -- *.BMP \ No newline at end of file diff --git a/bin/openvr_api.dll b/bin/openvr_api.dll new file mode 100644 index 00000000..c440068c Binary files /dev/null and b/bin/openvr_api.dll differ diff --git a/src/cache.h b/src/cache.h index 438eb80b..d47ce3e2 100644 --- a/src/cache.h +++ b/src/cache.h @@ -6,28 +6,34 @@ #include "controller.h" #include "camera.h" -#define NO_CLIP_PLANE 1000000.0f -//#define LOG_SHADERS +#define NO_WATER_HEIGHT 1000000.0f + +#if defined(_OS_IOS) || defined(_GAPI_D3D9) || defined(_GAPI_D3D11) || defined(_GAPI_GXM) + #define USE_SCREEN_TEX +#endif + +#if defined(_GAPI_D3D8) || defined(_GAPI_D3D9) || defined(_GAPI_D3D11) + #define EARLY_CLEAR +#endif struct ShaderCache { - enum Effect { FX_NONE = 0, FX_UNDERWATER = 1, FX_ALPHA_TEST = 2, FX_CLIP_PLANE = 4 }; + enum Effect { FX_NONE = 0, FX_UNDERWATER = 1, FX_ALPHA_TEST = 2 }; - Shader *shaders[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST | FX_CLIP_PLANE) + 1]; - PSO *pso[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST | FX_CLIP_PLANE) + 1][bmMAX]; + Shader *shaders[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST) + 1]; + PSO *pso[Core::passMAX][Shader::MAX][(FX_UNDERWATER | FX_ALPHA_TEST) + 1][bmMAX]; ShaderCache() { memset(shaders, 0, sizeof(shaders)); LOG("shader: cache warm-up...\n"); prepareCompose(FX_NONE); - if (Core::settings.detail.water > Core::Settings::LOW && !Core::support.clipDist) - prepareCompose(FX_CLIP_PLANE); - prepareAmbient(FX_NONE); if (Core::settings.detail.shadows > Core::Settings::LOW) prepareShadows(FX_NONE); + prepareSky(FX_NONE); + if (Core::settings.detail.water > Core::Settings::LOW) prepareWater(FX_NONE); @@ -66,29 +72,37 @@ struct ShaderCache { compile(Core::passCompose, Shader::SPRITE, fx, rsFull | RS_DISCARD); compile(Core::passCompose, Shader::SPRITE, fx | FX_UNDERWATER, rsFull | RS_DISCARD); - compile(Core::passCompose, Shader::FLASH, fx, rsFull | RS_BLEND_MULT); + compile(Core::passCompose, Shader::FLASH, fx, rsFull | RS_BLEND_MULT); // spot shadow } void prepareAmbient(int fx) { - compile(Core::passAmbient, Shader::ROOM, fx, rsFull); - compile(Core::passAmbient, Shader::ROOM, fx, rsFull | RS_DISCARD); - compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER, rsFull); - compile(Core::passAmbient, Shader::ROOM, fx | FX_UNDERWATER, rsFull | RS_DISCARD); - compile(Core::passAmbient, Shader::SPRITE, fx, rsFull | RS_DISCARD); - compile(Core::passAmbient, Shader::SPRITE, fx | FX_UNDERWATER, rsFull | RS_DISCARD); + compile(Core::passAmbient, Shader::ROOM, fx, rsFull); + compile(Core::passAmbient, Shader::ROOM, fx, rsFull | RS_DISCARD); + compile(Core::passAmbient, Shader::SPRITE, fx, rsFull | RS_DISCARD); } void prepareShadows(int fx) { + compile(Core::passShadow, Shader::MIRROR, fx, rsShadow); compile(Core::passShadow, Shader::ENTITY, fx, rsShadow); compile(Core::passShadow, Shader::ENTITY, fx, rsShadow | RS_DISCARD); } + void prepareSky(int fx) { + compile(Core::passSky, Shader::DEFAULT, fx, rsBase); + if (Core::support.tex3D) { + compile(Core::passSky, Shader::SKY_CLOUDS, fx, rsBase); + compile(Core::passSky, Shader::SKY_AZURE, fx, rsBase); + } + } + void prepareWater(int fx) { compile(Core::passWater, Shader::WATER_MASK, fx, RS_COLOR_WRITE_A | RS_DEPTH_TEST); compile(Core::passWater, Shader::WATER_SIMULATE, fx, RS_COLOR_WRITE); compile(Core::passWater, Shader::WATER_DROP, fx, RS_COLOR_WRITE); compile(Core::passWater, Shader::WATER_RAYS, fx, RS_COLOR_WRITE | RS_DEPTH_TEST); - compile(Core::passWater, Shader::WATER_CAUSTICS, fx, RS_COLOR_WRITE); + if (Core::support.derivatives) { + compile(Core::passWater, Shader::WATER_CAUSTICS, fx, RS_COLOR_WRITE); + } compile(Core::passWater, Shader::WATER_COMPOSE, fx, RS_COLOR_WRITE | RS_DEPTH_TEST); } @@ -97,6 +111,7 @@ struct ShaderCache { compile(Core::passFilter, Shader::FILTER_DOWNSAMPLE, fx, RS_COLOR_WRITE); compile(Core::passFilter, Shader::FILTER_GRAYSCALE, fx, RS_COLOR_WRITE); compile(Core::passFilter, Shader::FILTER_BLUR, fx, RS_COLOR_WRITE); + compile(Core::passFilter, Shader::FILTER_ANAGLYPH, fx, RS_COLOR_WRITE); } void prepareGUI(int fx) { @@ -141,8 +156,6 @@ struct ShaderCache { if (fx & FX_ALPHA_TEST) SD_ADD(ALPHA_TEST); if (pass == Core::passCompose) { - if (fx & FX_CLIP_PLANE) - SD_ADD(CLIP_PLANE); if (Core::settings.detail.lighting > Core::Settings::MEDIUM && (type == Shader::ENTITY)) SD_ADD(OPT_AMBIENT); if (Core::settings.detail.shadows > Core::Settings::LOW && (type == Shader::ENTITY || type == Shader::ROOM)) @@ -154,6 +167,7 @@ struct ShaderCache { } break; } + case Core::passSky : def[defCount++] = SD_SKY_TEXTURE + type; break; case Core::passWater : def[defCount++] = SD_WATER_DROP + type; break; case Core::passFilter : def[defCount++] = SD_FILTER_UPSCALE + type; break; case Core::passGUI : break; @@ -162,48 +176,6 @@ struct ShaderCache { #undef SD_ADD - #ifdef LOG_SHADERS - { - static const char *DefineName[SD_MAX] = { SHADER_DEFINES(DECL_STR) }; - - int id = 0; - /* - id |= flags[ 5]; - id |= flags[ 6]; - id |= flags[ 7]; - id |= flags[ 8]; - id |= flags[ 9]; - id |= flags[10]; - id |= flags[11]; - */ - char defines[1024]; - defines[0] = 0; - - for (int i = 0; i < defCount; i++) { // base shader defines - strcat(defines, " /D"); - strcat(defines, DefineName[def[i]]); - strcat(defines, "=1"); - } - - const char *name = NULL; - - switch (pass) { - case passCompose : name = "compose"; break; - case passShadow : name = "shadow"; break; - case passAmbient : name = "ambient"; break; - case passWater : name = "water" ; break; - case passFilter : name = "filter"; break; - case passGUI : name = "gui"; break; - } - - char buf[256]; - sprintf(buf, "%s_%d_%02X", name, type, id); - LOG("fxc /nologo /T vs_3_0 /O3 /Gec /Vn %s_vs /Fh d3d9/%s_vs.h %s.hlsl /DVERTEX%s\n", buf, buf, name, defines); - LOG("fxc /nologo /T vs_3_0 /O3 /Gec /Vn %s_ps /Fh d3d9/%s_ps.h %s.hlsl /DPIXEL%s\n", buf, buf, name, defines); - } - #endif - - return shaders[pass][type][fx] = new Shader(pass, type, def, defCount); #else return NULL; @@ -223,12 +195,10 @@ struct ShaderCache { void bind(Core::Pass pass, Shader::Type type, int fx) { Core::pass = pass; - if (Core::support.clipDist) - fx &= ~ShaderCache::FX_CLIP_PLANE; - Shader *shader = getShader(pass, type, fx); - if (shader) + if (shader) { shader->setup(); + } Core::setAlphaTest((fx & FX_ALPHA_TEST) != 0); } @@ -271,7 +241,7 @@ struct AmbientCache { // init downsample textures for (int j = 0; j < 6; j++) for (int i = 0; i < 4; i++) - textures[j * 4 + i] = new Texture(64 >> (i << 1), 64 >> (i << 1), FMT_RGBA, OPT_TARGET | OPT_NEAREST); + textures[j * 4 + i] = new Texture(64 >> (i << 1), 64 >> (i << 1), 1, FMT_RGBA, OPT_TARGET | OPT_NEAREST); } ~AmbientCache() { @@ -310,6 +280,11 @@ struct AmbientCache { // second pass - downsample it Core::setDepthTest(false); + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / 32767.0f)); + Core::setViewProj(mView, mProj); game->setShader(Core::passFilter, Shader::FILTER_DOWNSAMPLE); for (int i = 1; i < 4; i++) { @@ -320,7 +295,8 @@ struct AmbientCache { for (int j = 0; j < 6; j++) { Texture *src = textures[j * 4 + i - 1]; Texture *dst = textures[j * 4 + i]; - Core::setTarget(dst, RT_STORE_COLOR); + Core::setTarget(dst, NULL, RT_STORE_COLOR); + Core::validateRenderState(); src->bind(sDiffuse); game->getMesh()->renderQuad(); } @@ -328,7 +304,7 @@ struct AmbientCache { // get result color from 1x1 textures for (int j = 0; j < 6; j++) { - Core::setTarget(textures[j * 4 + 3], RT_LOAD_COLOR); + Core::setTarget(textures[j * 4 + 3], NULL, RT_LOAD_COLOR); colors[j] = Core::copyPixel(0, 0); } @@ -452,7 +428,8 @@ struct WaterCache { #define MAX_SURFACES 16 #define MAX_INVISIBLE_TIME 5.0f #define SIMULATE_TIMESTEP (1.0f / 40.0f) - #define DETAIL (64.0f / 1024.0f) + #define WATER_TILE_SIZE 64 + #define DETAIL (WATER_TILE_SIZE / 1024.0f) #define MAX_DROPS 32 IGame *game; @@ -470,9 +447,6 @@ struct WaterCache { vec3 pos, size; Texture *mask; Texture *caustics; - #ifdef BLUR_CAUSTICS - Texture *caustics_tmp; - #endif Texture *data[2]; Item() { @@ -518,10 +492,10 @@ struct WaterCache { maxX++; maxZ++; - int w = nextPow2(maxX - minX); - int h = nextPow2(maxZ - minZ); + int w = maxX - minX; + int h = maxZ - minZ; - uint16 *m = new uint16[w * h]; + uint8 *m = new uint8[w * h]; memset(m, 0, w * h * sizeof(m[0])); for (int z = minZ; z < maxZ; z++) @@ -541,24 +515,21 @@ struct WaterCache { } } - m[(x - minX) + w * (z - minZ)] = hasWater ? 0xF800 : 0; + m[(x - minX) + w * (z - minZ)] = hasWater ? 0xFF : 0x00; // TODO: flow map } - mask = new Texture(w, h, FMT_RGB16, OPT_NEAREST, m); + mask = new Texture(w, h, 1, FMT_LUMINANCE, OPT_NEAREST, m); delete[] m; size = vec3(float((maxX - minX) * 512), 1.0f, float((maxZ - minZ) * 512)); // half size pos = vec3(r.info.x + minX * 1024 + size.x, float(posY), r.info.z + minZ * 1024 + size.z); - int *mf = new int[4 * w * 64 * h * 64]; - memset(mf, 0, sizeof(int) * 4 * w * 64 * h * 64); - data[0] = new Texture(w * 64, h * 64, FMT_RGBA_HALF, OPT_TARGET | OPT_VERTEX, mf); - data[1] = new Texture(w * 64, h * 64, FMT_RGBA_HALF, OPT_TARGET | OPT_VERTEX); + int *mf = new int[4 * w * h * SQR(WATER_TILE_SIZE)]; + memset(mf, 0, sizeof(int) * 4 * w * h * SQR(WATER_TILE_SIZE)); + data[0] = new Texture(w * WATER_TILE_SIZE, h * WATER_TILE_SIZE, 1, FMT_RG_HALF, OPT_TARGET | OPT_VERTEX, mf); + data[1] = new Texture(w * WATER_TILE_SIZE, h * WATER_TILE_SIZE, 1, FMT_RG_HALF, OPT_TARGET | OPT_VERTEX); delete[] mf; - caustics = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, FMT_RGBA, OPT_TARGET) : NULL; - #ifdef BLUR_CAUSTICS - caustics_tmp = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, Texture::RGBA) : NULL; - #endif + caustics = Core::settings.detail.water > Core::Settings::MEDIUM ? new Texture(512, 512, 1, FMT_RGBA, OPT_TARGET | OPT_DEPEND) : NULL; blank = false; } @@ -567,9 +538,6 @@ struct WaterCache { delete data[0]; delete data[1]; delete caustics; - #ifdef BLUR_CAUSTICS - delete caustics_tmp; - #endif delete mask; mask = caustics = data[0] = data[1] = NULL; } @@ -587,7 +555,7 @@ struct WaterCache { } drops[MAX_DROPS]; WaterCache(IGame *game) : game(game), level(game->getLevel()), screen(NULL), refract(NULL), count(0), dropCount(0) { - reflect = new Texture(512, 512, FMT_RGBA, OPT_TARGET); + reflect = new Texture(512, 512, 1, FMT_RGBA, OPT_TARGET); } ~WaterCache() { @@ -717,10 +685,12 @@ struct WaterCache { Core::active.shader->setParam(uParam, vec4(p.x, p.z, drop.radius * DETAIL, -drop.strength)); - item.data[0]->bind(sDiffuse); - Core::setTarget(item.data[1], RT_STORE_COLOR); + Core::setTarget(item.data[1], NULL, RT_STORE_COLOR); Core::setViewport(0, 0, int(s.x + 0.5f), int(s.y + 0.5f)); + Core::validateRenderState(); + item.data[0]->bind(sNormal); game->getMesh()->renderQuad(); + item.data[0]->unbind(sNormal); swap(item.data[0], item.data[1]); } } @@ -731,15 +701,18 @@ struct WaterCache { vec2 s(item.size.x * DETAIL * 2.0f, item.size.z * DETAIL * 2.0f); game->setShader(Core::passWater, Shader::WATER_SIMULATE); - Core::active.shader->setParam(uParam, vec4(0.995f, 1.0f, 0, Core::params.x)); + Core::active.shader->setParam(uParam, vec4(0.995f, 1.0f, randf() * 0.5f, Core::params.x)); Core::active.shader->setParam(uTexParam, vec4(1.0f / item.data[0]->width, 1.0f / item.data[0]->height, s.x / item.data[0]->width, s.y / item.data[0]->height)); - + Core::active.shader->setParam(uRoomSize, vec4(1.0f / item.mask->origWidth, 1.0f / item.mask->origHeight, float(item.mask->origWidth) / item.mask->width, float(item.mask->origHeight) / item.mask->height)); + while (item.timer >= SIMULATE_TIMESTEP) { // water step - item.data[0]->bind(sDiffuse); - Core::setTarget(item.data[1], RT_STORE_COLOR); + Core::setTarget(item.data[1], NULL, RT_STORE_COLOR); Core::setViewport(0, 0, int(s.x + 0.5f), int(s.y + 0.5f)); + Core::validateRenderState(); + item.data[0]->bind(sNormal); game->getMesh()->renderQuad(); + item.data[0]->unbind(sNormal); swap(item.data[0], item.data[1]); item.timer -= SIMULATE_TIMESTEP; } @@ -755,33 +728,22 @@ struct WaterCache { float sx = item.size.x * DETAIL / (item.data[0]->width / 2); float sz = item.size.z * DETAIL / (item.data[0]->height / 2); - Core::active.shader->setParam(uTexParam, vec4(0.0f, 0.0f, sx, sz)); + Core::active.shader->setParam(uTexParam, vec4(1.0f / item.data[0]->width, 1.0f / item.data[0]->height, sx, sz)); + item.caustics->unbind(sReflect); + Core::setTarget(item.caustics, NULL, RT_CLEAR_COLOR | RT_STORE_COLOR); + Core::validateRenderState(); // force clear color for borders + Core::setViewport(1, 1, item.caustics->width - 1, item.caustics->width - 1); // leave 2px for black border Core::whiteTex->bind(sReflect); item.data[0]->bind(sNormal); - Core::setTarget(item.caustics, RT_CLEAR_COLOR | RT_STORE_COLOR); - Core::setViewport(1, 1, item.caustics->width - 2, item.caustics->width - 2); // leave 1px for black border game->getMesh()->renderPlane(); - #ifdef BLUR_CAUSTICS - // v blur - Core::setTarget(item.caustics_tmp, CLEAR_ALL); - game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); - Core::active.shader->setParam(uParam, vec4(0, 1, 1.0f / item.caustics->width, 0));; - item.caustics->bind(sDiffuse); - game->getMesh()->renderQuad(); - Core::invalidateTarget(false, true); - - // h blur - Core::setTarget(item.caustics, CLEAR_ALL); - game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); - Core::active.shader->setParam(uParam, vec4(1, 0, 1.0f / item.caustics->width, 0));; - item.caustics_tmp->bind(sDiffuse); - game->getMesh()->renderQuad(); - Core::invalidateTarget(false, true); - #endif + item.data[0]->unbind(sNormal); } void renderRays() { + #ifdef _OS_PSV // TODO + return; + #endif if (!visible) return; PROFILE_MARKER("WATER_RAYS"); @@ -824,6 +786,7 @@ struct WaterCache { Core::setColorWrite(false, false, false, true); Core::setDepthWrite(false); Core::setCullMode(cmNone); + Core::setBlendMode(bmNone); for (int i = 0; i < count; i++) { Item &item = items[i]; @@ -842,16 +805,16 @@ struct WaterCache { Texture* getScreenTex() { - int w = Core::viewportDef.width; - int h = Core::viewportDef.height; + int w = Core::viewportDef.z; + int h = Core::viewportDef.w; // get refraction texture if (!refract || w != refract->origWidth || h != refract->origHeight) { PROFILE_MARKER("WATER_REFRACT_INIT"); delete refract; - refract = new Texture(w, h, FMT_RGBA, OPT_TARGET); - #ifdef _OS_IOS + refract = new Texture(w, h, 1, FMT_RGBA, OPT_TARGET); + #ifdef USE_SCREEN_TEX delete screen; - screen = new Texture(w, h, FMT_RGBA, OPT_TARGET); + screen = new Texture(w, h, 1, FMT_RGBA, OPT_TARGET); #endif } return screen; @@ -864,19 +827,27 @@ struct WaterCache { if (!screen) { x = Core::viewportDef.x; y = Core::viewportDef.y; - } else + } else { x = y = 0; + } - if (screen) { // only for iOS devices - Core::setTarget(refract, RT_LOAD_DEPTH | RT_STORE_COLOR | RT_STORE_DEPTH); - blitTexture(screen); - Core::setTarget(screen, RT_LOAD_COLOR | RT_LOAD_DEPTH | RT_STORE_COLOR); - } else - Core::copyTarget(refract, 0, 0, x, y, Core::viewportDef.width, Core::viewportDef.height); // copy framebuffer into refraction texture + if (screen) { + Core::setTarget(refract, NULL, RT_LOAD_DEPTH | RT_STORE_COLOR | RT_STORE_DEPTH); + Core::validateRenderState(); + bool flip = false; + #if defined(_GAPI_D3D9) || defined(_GAPI_D3D11) || defined(_GAPI_GXM) + flip = true; + #endif + blitTexture(screen, flip); + Core::setTarget(screen, NULL, RT_LOAD_COLOR | RT_LOAD_DEPTH | RT_STORE_COLOR); + Core::validateRenderState(); + } else { + Core::copyTarget(refract, 0, 0, x, y, Core::viewportDef.z, Core::viewportDef.w); // copy framebuffer into refraction texture + } } void simulate() { - PROFILE_MARKER("WATER_SIMULATE"); + PROFILE_MARKER("WATER_SIMULATE"); // simulate water Core::setDepthTest(false); Core::setBlendMode(bmNone); @@ -885,9 +856,10 @@ struct WaterCache { if (!item.visible) continue; if (item.timer >= SIMULATE_TIMESTEP || dropCount) { + Core::noiseTex->bind(sDiffuse); item.mask->bind(sMask); // add water drops - drop(item); + drop(item); // simulation step step(item); } @@ -906,12 +878,12 @@ struct WaterCache { } // render mirror reflection - Core::setTarget(reflect, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); + Core::setTarget(reflect, NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); Camera *camera = (Camera*)game->getCamera(); game->setupBinding(); // merge visible rooms for all items - int roomsList[256]; + RoomDesc roomsList[256]; int roomsCount = 0; for (int i = 0; i < level->roomsCount; i++) @@ -949,19 +921,15 @@ struct WaterCache { } float waterLevel = items[waterItem].pos.y; - - reflectPlane = vec4(0, 1, 0, -waterLevel); + float sign = underwater ? -1.0f : 1.0f; + reflectPlane = vec4(0.0f, -1.0f, 0.0f, waterLevel) * sign; camera->reflectPlane = &reflectPlane; camera->setup(true); // render reflections frame - float sign = underwater ? -1.0f : 1.0f; - game->setClipParams(sign, waterLevel * sign); - game->renderView(TR::NO_ROOM, false, roomsCount, roomsList); + game->renderView(TR::NO_ROOM, false, false, roomsCount, roomsList); } - game->setClipParams(1.0f, NO_CLIP_PLANE); - camera->reflectPlane = NULL; camera->setup(true); } @@ -977,12 +945,13 @@ struct WaterCache { game->setShader(Core::passWater, Shader::WATER_COMPOSE); Core::updateLights(); - Core::active.shader->setParam(uParam, vec4(float(refract->origWidth) / refract->width, float(refract->origHeight) / refract->height, 0.05f, 0.03f)); + Core::active.shader->setParam(uParam, vec4(float(refract->origWidth) / refract->width, float(refract->origHeight) / refract->height, 0.05f, 0.0f)); float sx = item.size.x * DETAIL / (item.data[0]->width / 2); float sz = item.size.z * DETAIL / (item.data[0]->height / 2); - Core::active.shader->setParam(uTexParam, vec4(0.0f, 0.0f, sx, sz)); + Core::active.shader->setParam(uTexParam, vec4(1.0f / item.data[0]->width, 1.0f / item.data[0]->height, sx, sz)); + Core::active.shader->setParam(uRoomSize, vec4(1.0f / item.mask->origWidth, 1.0f / item.mask->origHeight, float(item.mask->origWidth) / item.mask->width, float(item.mask->origHeight) / item.mask->height)); refract->bind(sDiffuse); reflect->bind(sReflect); @@ -1005,17 +974,21 @@ struct WaterCache { dropCount = 0; } - void blitTexture(Texture *tex) { + void blitTexture(Texture *tex, bool flip = false) { ASSERT(tex); game->setShader(Core::passGUI, Shader::DEFAULT); mat4 mProj = GAPI::ortho(0.0f, float(tex->origWidth), 0.0f, float(tex->origHeight), 0.0f, 1.0f); + #ifdef _OS_WP8 + mProj.unrot90(); + #endif + Core::active.shader->setParam(uViewProj, mProj); Core::active.shader->setParam(uMaterial, vec4(1.0f)); - tex->bind(0); + tex->bind(sDiffuse); int w = tex->width; int h = tex->height; @@ -1029,10 +1002,22 @@ struct WaterCache { vertices[1].light = vertices[2].light = vertices[3].light = ubyte4(255, 255, 255, 255); - vertices[0].texCoord = short4( 0, 32767, 0, 0); - vertices[1].texCoord = short4(32767, 32767, 0, 0); - vertices[2].texCoord = short4(32767, 0, 0, 0); - vertices[3].texCoord = short4( 0, 0, 0, 0); + + #if defined(_GAPI_D3D9) || defined(_GAPI_D3D11) || defined(_GAPI_GXM) + flip = !flip; + #endif + + if (flip) { + vertices[0].texCoord = short4( 0, 0, 0, 0); + vertices[1].texCoord = short4(32767, 0, 0, 0); + vertices[2].texCoord = short4(32767, 32767, 0, 0); + vertices[3].texCoord = short4( 0, 32767, 0, 0); + } else { + vertices[0].texCoord = short4( 0, 32767, 0, 0); + vertices[1].texCoord = short4(32767, 32767, 0, 0); + vertices[2].texCoord = short4(32767, 0, 0, 0); + vertices[3].texCoord = short4( 0, 0, 0, 0); + } Core::setDepthTest(false); Core::setBlendMode(bmNone); @@ -1040,11 +1025,13 @@ struct WaterCache { game->getMesh()->renderBuffer(indices, COUNT(indices), vertices, COUNT(vertices)); Core::setDepthTest(true); + + tex->unbind(sDiffuse); } - #undef MAX_WATER_SURFACES - #undef MAX_WATER_INVISIBLE_TIME - #undef WATER_SIMULATE_TIMESTEP + #undef MAX_SURFACES + #undef MAX_INVISIBLE_TIME + #undef SIMULATE_TIMESTEP #undef DETAIL }; diff --git a/src/camera.h b/src/camera.h index 0b48da8f..524124a7 100644 --- a/src/camera.h +++ b/src/camera.h @@ -6,18 +6,37 @@ #include "controller.h" #include "character.h" -#define CAM_OFFSET_FOLLOW (1024.0f + 512.0f) -#define CAM_OFFSET_COMBAT (2048.0f + 512.0f) -#define CAM_OFFSET_LOOK (512.0f) - #define CAM_SPEED_FOLLOW 12 #define CAM_SPEED_COMBAT 8 +#define CAM_EYE_SEPARATION 16.0f + +#ifdef _OS_3DS + #define CAM_FOCAL_LENGTH 512.0f +#else + #define CAM_FOCAL_LENGTH 1536.0f +#endif + +#define CAM_OFFSET_FOLLOW (1024.0f + 512.0f) + +#ifdef _OS_BITTBOY + #define CAM_OFFSET_COMBAT CAM_OFFSET_FOLLOW +#else + #define CAM_OFFSET_COMBAT (CAM_OFFSET_FOLLOW + 512.0f) +#endif + +#define CAM_OFFSET_LOOK (512.0f) + #define CAM_FOLLOW_ANGLE 0.0f #define CAM_LOOK_ANGLE_XMAX ( 55.0f * DEG2RAD) #define CAM_LOOK_ANGLE_XMIN (-75.0f * DEG2RAD) #define CAM_LOOK_ANGLE_Y ( 80.0f * DEG2RAD) +#define SPECTATOR_TIMER 1.0f +#define SPECTATOR_POS_SPEED 4096.0f +#define SPECTATOR_ROT_SPEED PI +#define SPECTATOR_SMOOTH 4.0f + struct Camera : ICamera { IGame *game; TR::Level *level; @@ -25,7 +44,7 @@ struct Camera : ICamera { Frustum *frustum; float fov, aspect, znear, zfar; - vec3 lookAngle, targetAngle; + vec3 lookAngle, targetAngle, viewAngle; mat4 mViewInv; float timer; @@ -33,13 +52,24 @@ struct Camera : ICamera { int viewIndex; int viewIndexLast; Controller* viewTarget; + Controller* viewTargetLast; Basis fpHead; int speed; bool smooth; + bool spectator; + vec3 specPos, specPosSmooth; + vec3 specRot, specRotSmooth; + float specTimer; + int16 specRoom; + Camera(IGame *game, Character *owner) : ICamera(), game(game), level(game->getLevel()), frustum(new Frustum()), timer(-1.0f), viewIndex(-1), viewIndexLast(-1), viewTarget(NULL) { this->owner = owner; reset(); + + spectator = false; + specTimer = 0.0f; + targetAngle = vec3(0.0f); } void reset() { @@ -77,7 +107,7 @@ struct Camera : ICamera { } virtual int getRoomIndex() const { - return eye.room; + return spectator ? specRoom : eye.room; } void updateListener(const mat4 &matrix) { @@ -85,8 +115,8 @@ struct Camera : ICamera { Sound::listener[cameraIndex].matrix = matrix; if (cameraIndex == 0) { // reverb effect only for main player TR::Room &r = level->rooms[getRoomIndex()]; - int h = (r.info.yBottom - r.info.yTop) / 1024; - Sound::reverb.setRoomSize(vec3(float(r.xSectors), float(h), float(r.zSectors)) * 2.419f); // convert cells size into meters + float h = (r.info.yBottom - r.info.yTop) / 1024.0f; + Sound::reverb.setRoomSize(vec3(float(r.xSectors), h, float(r.zSectors)) * 2.419f); // convert cells size into meters } } @@ -94,9 +124,21 @@ struct Camera : ICamera { return level->rooms[getRoomIndex()].flags.water; } - vec3 getViewPoint() { + vec3 getViewPoint(bool useBounds = true) { Box box = owner->getBoundingBox(); vec3 pos = owner->pos; + + if (!useBounds) { + if (owner->getEntity().type == TR::Entity::LARA && + owner->stand != Character::STAND_UNDERWATER && + owner->stand != Character::STAND_ONWATER) + { + pos.y -= 512.0f; + } + return pos; + } + + vec3 center = box.center(); if (centerView) { @@ -104,41 +146,27 @@ struct Camera : ICamera { pos.z = center.z; } - if (mode == MODE_LOOK) { - Basis b = owner->getJoint(owner->jointHead); - b.translate(vec3(0, -128, 0)); - pos = b.pos; - } else { - if (mode != MODE_STATIC) - pos.y = box.max.y + (box.min.y - box.max.y) * (3.0f / 4.0f); - else - pos.y = center.y; + if (owner->getEntity().type == TR::Entity::LARA) { + if (mode == MODE_LOOK) { + Basis b = owner->getJoint(owner->jointHead); + b.translate(vec3(0, -128, 0)); + pos = b.pos; + } else { + if (mode != MODE_STATIC) + pos.y = box.max.y + (box.min.y - box.max.y) * (3.0f / 4.0f); + else + pos.y = center.y; - if (owner->stand != Character::STAND_UNDERWATER) - pos.y -= 256; + if (owner->stand != Character::STAND_UNDERWATER) + pos.y -= 256; + } + } else { + pos.y = center.y; } return pos; } - void setView(int viewIndex, float timer, int speed) { - viewIndexLast = viewIndex; - smooth = speed > 0; - mode = MODE_STATIC; - this->viewIndex = viewIndex; - this->timer = timer; - this->speed = speed * 8; - } - - void resetTarget() { - smooth = speed > 0; - mode = MODE_FOLLOW; - viewIndex = -1; - viewTarget = NULL; - timer = -1.0f; - speed = CAM_SPEED_FOLLOW; - } - virtual void doCutscene(const vec3 &pos, float rotation) { mode = Camera::MODE_CUTSCENE; level->cutMatrix.identity(); @@ -166,8 +194,9 @@ struct Camera : ICamera { fpHead.pos -= joint.rot * vec3(0, 48, -24); } - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { fpHead.rot = quat(vec3(1, 0, 0), PI); + } mViewInv.identity(); mViewInv.setRot(fpHead.rot); @@ -330,6 +359,16 @@ struct Camera : ICamera { Input::setJoyVibration(cameraIndex, clamp(shake, 0.0f, 1.0f), 0); } + if (mode == MODE_FOLLOW) { + speed = CAM_SPEED_FOLLOW; + } + + if (mode == MODE_COMBAT) { + speed = CAM_SPEED_COMBAT; + } + + viewAngle = vec3(0.0f); + if (mode == MODE_CUTSCENE) { ASSERT(level->cameraFramesCount && level->cameraFrames); @@ -350,31 +389,33 @@ struct Camera : ICamera { } } - if (!firstPerson) { - TR::CameraFrame *frameA = &level->cameraFrames[indexA]; - TR::CameraFrame *frameB = &level->cameraFrames[indexB]; + if (!spectator) { + if (!firstPerson) { + TR::CameraFrame *frameA = &level->cameraFrames[indexA]; + TR::CameraFrame *frameB = &level->cameraFrames[indexB]; - const float maxDelta = 512 * 512; + const float maxDelta = 512 * 512; - float dp = (vec3(frameA->pos) - vec3(frameB->pos)).length2(); - float dt = (vec3(frameA->target) - vec3(frameB->target)).length2(); + float dp = (vec3(frameA->pos) - vec3(frameB->pos)).length2(); + float dt = (vec3(frameA->target) - vec3(frameB->target)).length2(); - if (dp > maxDelta || dt > maxDelta) { - eye.pos = frameA->pos; - target.pos = frameA->target; - fov = frameA->fov / 32767.0f * 120.0f; - } else { - eye.pos = vec3(frameA->pos).lerp(frameB->pos, t); - target.pos = vec3(frameA->target).lerp(frameB->target, t); - fov = lerp(frameA->fov / 32767.0f * 120.0f, frameB->fov / 32767.0f * 120.0f, t); - } + if (dp > maxDelta || dt > maxDelta) { + eye.pos = frameA->pos; + target.pos = frameA->target; + fov = frameA->fov / 32767.0f * 120.0f; + } else { + eye.pos = vec3(frameA->pos).lerp(frameB->pos, t); + target.pos = vec3(frameA->target).lerp(frameB->target, t); + fov = lerp(frameA->fov / 32767.0f * 120.0f, frameB->fov / 32767.0f * 120.0f, t); + } - eye.pos = level->cutMatrix * eye.pos; - target.pos = level->cutMatrix * target.pos; + eye.pos = level->cutMatrix * eye.pos; + target.pos = level->cutMatrix * target.pos; - mViewInv = mat4(eye.pos, target.pos, vec3(0, -1, 0)); - } else - updateFirstPerson(); + mViewInv = mat4(eye.pos, target.pos, vec3(0, -1, 0)); + } else + updateFirstPerson(); + } } else { if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { lookAngle = vec3(0.0f); @@ -382,8 +423,11 @@ struct Camera : ICamera { if (mode == MODE_LOOK) { float d = 3.0f * Core::deltaTime; - lookAngle.x += Input::joy[cameraIndex].L.y * d; - lookAngle.y += Input::joy[cameraIndex].L.x * d; + vec2 L = Input::joy[Core::settings.controls[cameraIndex].joyIndex].L; + L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK); + + lookAngle.x += L.y * d; + lookAngle.y += L.x * d; if (Input::state[cameraIndex][cUp]) lookAngle.x -= d; if (Input::state[cameraIndex][cDown]) lookAngle.x += d; @@ -392,7 +436,7 @@ struct Camera : ICamera { lookAngle.x = clamp(lookAngle.x, CAM_LOOK_ANGLE_XMIN, CAM_LOOK_ANGLE_XMAX); lookAngle.y = clamp(lookAngle.y, -CAM_LOOK_ANGLE_Y, CAM_LOOK_ANGLE_Y); - } else + } else { if (lookAngle.x != CAM_FOLLOW_ANGLE || lookAngle.y != 0.0f) { float t = 10.0f * Core::deltaTime; lookAngle.x = lerp(clampAngle(lookAngle.x), CAM_FOLLOW_ANGLE, t); @@ -400,9 +444,20 @@ struct Camera : ICamera { if (fabsf(lookAngle.x - CAM_FOLLOW_ANGLE) < EPS) lookAngle.x = CAM_FOLLOW_ANGLE; if (lookAngle.y < EPS) lookAngle.y = 0.0f; } + + if (!spectator) { + vec2 R = Input::joy[Core::settings.controls[cameraIndex].joyIndex].R; + R.x = sign(R.x) * max(0.0f, (fabsf(R.x) - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK)); + R.y = sign(R.y) * max(0.0f, (fabsf(R.y) - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK)); + + viewAngle.x = -R.y * PI * 0.375f; + viewAngle.y = R.x * PI * 0.5f; + viewAngle.z = 0.0f; + } + } } - targetAngle = owner->angle + lookAngle; + targetAngle = owner->angle + lookAngle + viewAngle; targetAngle.x = clampAngle(targetAngle.x); targetAngle.y = clampAngle(targetAngle.y); @@ -415,11 +470,13 @@ struct Camera : ICamera { if (!owner->viewTarget) { if (viewTarget && !viewTarget->flags.invisible) { vec3 targetVec = (viewTarget->pos - owner->pos).normal(); - if (targetVec.dot(owner->getDir()) > 0.5f) + if (targetVec.dot(owner->getDir()) > 0.1f) { lookAt = viewTarget; + } } - } else + } else { lookAt = owner->viewTarget; + } owner->lookAt(lookAt); } else { @@ -427,21 +484,17 @@ struct Camera : ICamera { owner->lookAt(NULL); } - if (!firstPerson && (mode == MODE_FOLLOW || mode == MODE_COMBAT)) + if (!firstPerson && (mode == MODE_FOLLOW || mode == MODE_COMBAT)) { targetAngle += angle; + } - if (!firstPerson || viewIndex != -1) { - - if (timer > 0.0f) { - timer -= Core::deltaTime; - if (timer <= 0.0f) - resetTarget(); - } + bool isStatic = (mode == MODE_STATIC || mode == MODE_HEAVY) && viewTarget; + if (!firstPerson || isStatic) { TR::Location to; target.box = TR::NO_BOX; - if (viewIndex > -1) { + if (mode == MODE_STATIC && viewIndex > -1) { TR::Camera &cam = level->cameras[viewIndex]; to.room = cam.room; to.pos = vec3(float(cam.x), float(cam.y), float(cam.z)); @@ -450,8 +503,7 @@ struct Camera : ICamera { target.pos = lookAt->getBoundingBox().center(); } else { target.room = owner->getRoomIndex(); - target.pos = owner->pos; - target.pos.y -= 512.0f; + target.pos = getViewPoint(false); } } else { vec3 p = getViewPoint(); @@ -467,7 +519,7 @@ struct Camera : ICamera { if (mode == MODE_LOOK) offset = CAM_OFFSET_LOOK; else - offset = (mode == MODE_COMBAT ? CAM_OFFSET_COMBAT : CAM_OFFSET_FOLLOW) * cosf(targetAngle.x); + offset = (mode == MODE_COMBAT ? CAM_OFFSET_COMBAT : CAM_OFFSET_FOLLOW); vec3 dir = vec3(targetAngle.x, targetAngle.y) * offset; to.pos = target.pos - dir; @@ -478,9 +530,6 @@ struct Camera : ICamera { move(to); - if (timer <= 0.0f) - resetTarget(); - mViewInv = mat4(eye.pos, target.pos, vec3(0, -1, 0)); } else updateFirstPerson(); @@ -488,12 +537,98 @@ struct Camera : ICamera { level->getSector(eye.room, eye.pos); + smooth = true; + + viewIndexLast = viewIndex; + + if ((mode == MODE_STATIC || mode == MODE_HEAVY) && timer != 0.0f) { + timer -= Core::deltaTime; + if (timer <= 0.0f) { + timer = -1.0f; + smooth = false; + } + } + + if (mode != MODE_CUTSCENE && (mode != MODE_HEAVY || timer == -1.0f)) { + mode = MODE_FOLLOW; + viewIndex = -1; + viewTargetLast = viewTarget; + viewTarget = NULL; + } + + Input::Joystick &specJoy = Input::joy[Core::settings.controls[cameraIndex].joyIndex]; + + if (specJoy.down[jkL] && specJoy.down[jkR]) { + specTimer += Core::deltaTime; + if (specTimer > SPECTATOR_TIMER) { + firstPerson = false; + spectator = !spectator; + specTimer = 0.0f; + specPos = eye.pos; + specRot = targetAngle; + specRot.z = PI; + specRot.y += PI; + specPosSmooth = specPos; + specRotSmooth = specRot; + specRoom = eye.room; + } + } else { + specTimer = 0.0f; + } + + if (spectator) { + vec2 L = specJoy.L; + vec2 R = specJoy.R; + float U = specJoy.RT; + float D = specJoy.LT; + + L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK); + R = R.normal() * max(0.0f, R.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK); + U = max(0.0f, U - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER); + D = max(0.0f, D - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER); + + // apply dead zone + if (L.length() < 0.05f) L = vec2(0.0f); + if (R.length() < 0.05f) R = vec2(0.0f); + if (U < 0.05) U = 0.0f; + if (D < 0.05) D = 0.0f; + + vec3 dir = vec3(L.x, D - U, L.y) * (SPECTATOR_POS_SPEED * Core::deltaTime); + vec2 rot = R * (SPECTATOR_ROT_SPEED * Core::deltaTime); + + vec3 d = vec3(specRot.x, specRot.y); + vec3 r = d.cross(vec3(0.0f, 1.0f, 0.0f)).normal(); + + specPos += r * dir.x + vec3(0.0f, dir.y, 0.0f) + d * dir.z; + + specRot.x += rot.y; + specRot.y += rot.x; + specRot.x = clamp(specRot.x, -PIH, +PIH); + + specPosSmooth = specPosSmooth.lerp(specPos, SPECTATOR_SMOOTH * Core::deltaTime); + specRotSmooth = specRotSmooth.lerp(specRot, SPECTATOR_SMOOTH * Core::deltaTime); + + mViewInv.identity(); + mViewInv.translate(specPosSmooth); + mViewInv.rotateY(specRotSmooth.y); + mViewInv.rotateX(specRotSmooth.x); + mViewInv.rotateZ(specRotSmooth.z); + + for (int i = 0; i < level->roomsCount; i++) { + TR::Room &room = level->rooms[i]; + if (room.contains(specPos)) { + specRoom = i; + break; + } + } + + level->getSector(specRoom, specPos); + } + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) updateListener(mViewInv * Input::hmd.head); else updateListener(mViewInv); - - smooth = true; } virtual void setup(bool calcMatrices) { @@ -506,8 +641,15 @@ struct Camera : ICamera { if (shake > 0.0f) Core::mViewInv.setPos(Core::mViewInv.getPos() + vec3(0.0f, sinf(shake * PI * 7) * shake * 48.0f, 0.0f)); - if (Core::settings.detail.stereo == Core::Settings::STEREO_ON) - Core::mViewInv.setPos(Core::mViewInv.getPos() + Core::mViewInv.right().xyz() * (Core::eye * (firstPerson ? 8.0f : 32.0f) )); + if (Core::settings.detail.stereo == Core::Settings::STEREO_SBS || Core::settings.detail.stereo == Core::Settings::STEREO_ANAGLYPH) { + float separation = Core::eye * CAM_EYE_SEPARATION; + #ifdef _OS_3DS + if (firstPerson) { + separation *= 0.125; + } + #endif + Core::mViewInv.setPos(Core::mViewInv.getPos() + Core::mViewInv.right().xyz() * separation); + } if (reflectPlane) { Core::mViewInv = mat4(*reflectPlane) * Core::mViewInv; @@ -516,23 +658,56 @@ struct Camera : ICamera { Core::mView = Core::mViewInv.inverseOrtho(); - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { Core::mProj = Input::hmd.proj[Core::eye == -1.0f ? 0 : 1]; - else - Core::mProj = GAPI::perspective(fov, aspect, znear, zfar); + } else { + float eyeSep = (Core::eye * CAM_EYE_SEPARATION) * znear / CAM_FOCAL_LENGTH; + Core::mProj = GAPI::perspective(fov, aspect, znear, zfar, eyeSep); + } + + if (reflectPlane) { + setOblique(*reflectPlane); + } } Core::setViewProj(Core::mView, Core::mProj); Core::viewPos = Core::mViewInv.getPos(); // update room for eye (with HMD offset) - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) + if (Core::settings.detail.isStereo()) level->getSector(eye.room, Core::viewPos.xyz()); frustum->pos = Core::viewPos.xyz(); frustum->calcPlanes(Core::mViewProj); } + void setOblique(const vec4 &clipPlane) { // http://www.terathon.com/code/oblique.html + #ifdef _OS_WP8 + Core::mProj.unrot90(); + #endif + + vec4 p = Core::mViewInv.transpose() * clipPlane; + + vec4 q; + q.x = (sign(p.x) + Core::mProj.e02) / Core::mProj.e00; + q.y = (sign(p.y) + Core::mProj.e12) / Core::mProj.e11; + q.z = -1.0f; + q.w = (1.0f + Core::mProj.e22) / Core::mProj.e23; + + float f = GAPI::getProjRange() == mat4::PROJ_NEG_POS ? 2.0f : 1.0f; + + vec4 c = p * (f / p.dot(q)); + + Core::mProj.e20 = c.x; + Core::mProj.e21 = c.y; + Core::mProj.e22 = c.z + (f - 1.0f); + Core::mProj.e23 = c.w; + + #ifdef _OS_WP8 + Core::mProj.rot90(); + #endif + } + void changeView(bool firstPerson) { this->firstPerson = firstPerson; diff --git a/src/character.h b/src/character.h index 77a6c345..f3e954ff 100644 --- a/src/character.h +++ b/src/character.h @@ -44,6 +44,7 @@ struct Character : Controller { vec3 velocity; float angleExt; float speed; + float lookAtSpeed; int stepHeight; int dropHeight; @@ -60,6 +61,8 @@ struct Character : Controller { stepHeight = 256; dropHeight = -256; + lookAtSpeed = 8.0f; + rangeChest = vec4(-0.80f, 0.80f, -0.75f, 0.75f) * PI; rangeHead = vec4(-0.25f, 0.25f, -0.50f, 0.50f) * PI; animation.initOverrides(); @@ -245,7 +248,7 @@ struct Character : Controller { void lookAtPos(const vec3 *t = NULL) { - float speed = 8.0f * Core::deltaTime; + float speed = lookAtSpeed * Core::deltaTime; quat rot; if (jointChest > -1) { @@ -269,7 +272,7 @@ struct Character : Controller { } void addSparks(uint32 mask) { - Sphere spheres[MAX_SPHERES]; + Sphere spheres[MAX_JOINTS]; int count = getSpheres(spheres); for (int i = 0; i < count; i++) if (mask & (1 << i)) { @@ -304,6 +307,25 @@ struct Character : Controller { addBloodSpikes(); } + void bakeEnvironment(Texture *&environment) { + Core::beginFrame(); + + flags.invisible = true; + if (!environment) { + uint32 opt = OPT_CUBEMAP | OPT_TARGET; + #ifdef USE_CUBEMAP_MIPS + opt |= OPT_MIPMAPS; + #endif + environment = new Texture(256, 256, 1, FMT_RGB16, opt); + } + game->renderEnvironment(getRoomIndex(), pos - vec3(0.0f, 384.0f, 0.0f), &environment); + #ifdef USE_CUBEMAP_MIPS + environment->generateMipMap(); + #endif + flags.invisible = false; + + Core::endFrame(); + } }; #endif \ No newline at end of file diff --git a/src/collision.h b/src/collision.h index 336d3459..0029c6eb 100644 --- a/src/collision.h +++ b/src/collision.h @@ -22,7 +22,7 @@ struct Collision { angle = normalizeAngle(PI2 + vec2(velocity.z, velocity.x).angle()); pos += velocity; - int q = angleQuadrant(angle); + int q = angleQuadrant(angle, 0.25f); const vec2 v[] = { vec2( -radius, radius ), diff --git a/src/controller.h b/src/controller.h index b2e6e23c..fb1c5a3f 100644 --- a/src/controller.h +++ b/src/controller.h @@ -6,11 +6,10 @@ #include "mesh.h" #include "animation.h" -#define GRAVITY (6.0f * 30.0f) +#define GRAVITY 6.0f #define SPRITE_FPS 10.0f #define MAX_LAYERS 4 -#define MAX_SPHERES 32 #define UNLIMITED_AMMO 10000 @@ -47,6 +46,14 @@ struct ICamera { } }; +struct RoomDesc { + int32 index; + vec4 portal; + + RoomDesc() {} + RoomDesc(int32 index, const vec4 &portal) : index(index), portal(portal) {} +}; + struct IGame { virtual ~IGame() {} virtual void loadLevel(TR::LevelID id) {} @@ -57,7 +64,6 @@ struct IGame { virtual TR::Level* getLevel() { return NULL; } virtual MeshBuilder* getMesh() { return NULL; } - virtual Texture* getAtlas() { return NULL; } virtual ICamera* getCamera(int index = -1) { return NULL; } virtual Controller* getLara(int index = 0) { return NULL; } virtual Controller* getLara(const vec3 &pos) { return NULL; } @@ -65,19 +71,20 @@ struct IGame { virtual uint16 getRandomBox(uint16 zone, uint16 *zones) { return 0; } virtual uint16 findPath(int ascend, int descend, bool big, int boxStart, int boxEnd, uint16 *zones, uint16 **boxes) { return 0; } virtual void flipMap(bool water = true) {} - virtual void setClipParams(float clipSign, float clipHeight) {} virtual void setWaterParams(float height) {} virtual void waterDrop(const vec3 &pos, float radius, float strength) {} virtual void setShader(Core::Pass pass, Shader::Type type, bool underwater = false, bool alphaTest = false) {} virtual void setRoomParams(int roomIndex, Shader::Type type, float diffuse, float ambient, float specular, float alpha, bool alphaTest = false) {} virtual void setupBinding() {} - virtual void getVisibleRooms(int *roomsList, int &roomsCount, int from, int to, const vec4 &viewPort, bool water, int count = 0) {} + virtual void getVisibleRooms(RoomDesc *roomsList, int &roomsCount, int from, int to, const vec4 &viewPort, bool water, int count = 0) {} virtual void renderEnvironment(int roomIndex, const vec3 &pos, Texture **targets, int stride = 0, Core::Pass pass = Core::passAmbient) {} + virtual void renderModelFull(int modelIndex, bool underwater, Basis *joints) {} virtual void renderCompose(int roomIndex) {} - virtual void renderView(int roomIndex, bool water, int roomsCount = 0, int *roomsList = NULL) {} - virtual void renderGame(bool showUI) {} + virtual void renderView(int roomIndex, bool water, bool showUI, int roomsCount = 0, RoomDesc *roomsList = NULL) {} + virtual void renderGame(bool showUI, bool invBG) {} virtual void setEffect(Controller *controller, TR::Effect::Type effect) {} + virtual vec4 projectPoint(const vec4 &p) { return vec4(0.0f); } virtual void checkTrigger(Controller *controller, bool heavy) {} virtual void shakeCamera(float value, bool add = false) {} @@ -622,7 +629,9 @@ struct Controller { return e.isEnemy() || e.isVehicle() || e.isDoor() || - e.type == TR::Entity::SCION_HOLDER; + e.type == TR::Entity::SCION_HOLDER || + e.type == TR::Entity::TRAP_BOULDER || + e.type == TR::Entity::MUTANT_EGG_SMALL; } virtual bool activate() { @@ -777,11 +786,11 @@ struct Controller { } static inline void applyGravity(float &speed) { - speed += (speed < 128.0f ? GRAVITY : 30.0f) * Core::deltaTime; + speed += (speed < 128.0f ? GRAVITY : 1.0f) * (30.0f * Core::deltaTime); } bool alignToWall(float offset = 0.0f, int quadrant = -1, int maxDist = 0, int maxWidth = 0) { - int q = angleQuadrant(angle.y); + int q = angleQuadrant(angle.y, 0.25f); int ix = int(pos.x); int iz = int(pos.z); int x = ix & ~1023; @@ -829,9 +838,11 @@ struct Controller { int getSpheres(Sphere *spheres) { const TR::Model *m = getModel(); - ASSERT(m->mCount <= MAX_SPHERES); + ASSERT(m->mCount <= MAX_JOINTS); + int jFrame = jointsFrame; updateJoints(); + jointsFrame = jFrame; int count = 0; for (int i = 0; i < m->mCount; i++) { @@ -844,7 +855,7 @@ struct Controller { } Box getSpheresBox(bool local = false) { - Sphere spheres[MAX_SPHERES]; + Sphere spheres[MAX_JOINTS]; int count = getSpheres(spheres); if (count) { @@ -876,8 +887,8 @@ struct Controller { ASSERT(a->mCount <= 34); ASSERT(b->mCount <= 34); - Sphere aSpheres[MAX_SPHERES]; - Sphere bSpheres[MAX_SPHERES]; + Sphere aSpheres[MAX_JOINTS]; + Sphere bSpheres[MAX_JOINTS]; int aCount = getSpheres(aSpheres); int bCount = controller->getSpheres(bSpheres); @@ -1043,17 +1054,17 @@ struct Controller { bool trace(const TR::Location &from, TR::Location &to) { int rx, rz; - if (fabsf(to.pos.x - from.pos.x) < fabsf(to.pos.z - from.pos.z)) { + if (fabsf(to.pos.x - from.pos.x) > fabsf(to.pos.z - from.pos.z)) { rz = traceZ(from, to); - if (!rz) return false; rx = traceX(from, to); + if (!rx) return false; } else { rx = traceX(from, to); - if (!rx) return false; rz = traceZ(from, to); + if (!rz) return false; } TR::Room::Sector *sector = level->getSector(to.room, to.pos); - return clipHeight(from, to, sector) && rx == 1 && rz == 1; + return !(!clipHeight(from, to, sector) || rx != 1 || rz != 1); } bool clipHeight(const TR::Location &from, TR::Location &to, TR::Room::Sector *sector) { @@ -1265,40 +1276,28 @@ struct Controller { return getRoom(); } - void updateLights(bool lerp = true) { - TR::Room::Light sunLight; + #define LIGHT_DIST 8192.0f + void updateLights(bool lerp = true) { const TR::Room &room = getLightRoom(); - if (getModel()) { - vec3 center = getBoundingBox().center(); - float maxAtt = 0.0f; - /* - if (room.flags.sky) { // TODO trace rooms up for sun light, add direct light projection - sunLight.x = int32(center.x); - sunLight.y = int32(center.y) - 8192; - sunLight.z = int32(center.z); - sunLight.color = Color32(255, 255, 255, 255); - sunLight.radius = 1000 * 1024; - targetLight = &sunLight; - } else { - */ - { - for (int i = 0; i < room.lightsCount; i++) { - TR::Room::Light &light = room.lights[i]; - if ((light.color.r | light.color.g | light.color.b) == 0) continue; - - vec3 dir = vec3(float(light.x), float(light.y), float(light.z)) - center; - float att = max(0.0f, 1.0f - dir.length2() / SQR(light.radius)) * ((light.color.r + light.color.g + light.color.b) / (3.0f * 255.0f)); - - if (att > maxAtt) { - maxAtt = att; - targetLight = &light; - } - } + targetLight = NULL; + + if (getEntity().intensity == -1) { + int ambient = room.ambient; + + if (room.lightsCount && getModel()) { + vec3 center = getBoundingBox().center(); + + int x = int(center.x); + int y = int(center.y); + int z = int(center.z); + + ambient = room.getAmbient(x, y, z, &targetLight); } - } else - targetLight = NULL; + + intensity = intensityf(ambient); + } if (targetLight == NULL) { mainLightPos = vec3(0); @@ -1322,10 +1321,21 @@ struct Controller { mainLightPos = tpos; mainLightColor = tcolor; } + + // fix position and radius + mainLightColor.w = min(LIGHT_DIST * 1.5f, mainLightColor.w); + vec3 dir = mainLightPos - pos; + float dist = dir.length(); + if (dist > LIGHT_DIST) { + dir *= (LIGHT_DIST / dist); + mainLightPos = pos + dir; + } } mat4 getMatrix() { - if (level->isCutsceneLevel() && (getEntity().isActor() || getEntity().isLara())) + const TR::Entity &e = getEntity(); + + if (level->isCutsceneLevel() && (e.isActor() || e.isLara()) && e.type != TR::Entity::CUT_4) return level->cutMatrix; if (!lockMatrix) { @@ -1408,8 +1418,8 @@ struct Controller { Core::active.shader->setParam(uViewProj, Core::mViewProj * m); Core::setBasis(&b, 1); - float alpha = lerp(0.7f, 0.90f, clamp((info.floor - boxA.max.y) / 1024.0f, 0.0f, 1.0f) ); - float lum = 0.5f * (1.0f - alpha); + float alpha = lerp(0.7f, 0.9f, clamp((info.floor - boxA.max.y) / 1024.0f, 0.0f, 1.0f) ); + float lum = 1.0f - alpha; Core::setMaterial(lum, lum, lum, alpha); Core::setDepthWrite(false); @@ -1446,7 +1456,7 @@ struct Controller { vec3 p = pos - Core::viewPos.xyz(); - game->getMesh()->addDynSprite(level->spriteSequences[-(getEntity().modelIndex + 1)].sStart + frame, short3(int16(p.x), int16(p.y), int16(p.z)), color, color); + game->getMesh()->addDynSprite(level->spriteSequences[-(getEntity().modelIndex + 1)].sStart + frame, short3(int16(p.x), int16(p.y), int16(p.z)), false, false, color, color); } virtual void render(Frustum *frustum, MeshBuilder *mesh, Shader::Type type, bool caustics) { @@ -1509,6 +1519,14 @@ struct Controller { } }; +struct DummyController : Controller { + + DummyController(IGame *game, int entity) : Controller(game, entity) {} + + virtual void update() {} +}; + + Controller *Controller::first = NULL; #endif diff --git a/src/core.h b/src/core.h index 31ed08fc..5bdb8740 100644 --- a/src/core.h +++ b/src/core.h @@ -6,42 +6,120 @@ #endif #include +#include #define OS_FILEIO_CACHE #define OS_PTHREAD_MT -#ifdef WIN32 +#define USE_CUBEMAP_MIPS + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + #define _OS_WP8 1 + #define _GAPI_D3D11 1 + + #undef OS_PTHREAD_MT + + #define INV_SINGLE_PLAYER + #define INV_VIBRATION + #define INV_GAMEPAD_ONLY +#elif __UWP__ + #define _OS_UWP 1 + #define _GAPI_D3D11 1 + + #ifdef __XB1__ + #define _OS_XB1 + #define INV_VIBRATION + #define INV_GAMEPAD_ONLY + #endif + + #undef OS_PTHREAD_MT +#elif WIN32 #define _OS_WIN 1 #define _GAPI_GL 1 //#define _GAPI_D3D9 1 + //#define _GAPI_D3D11 1 //#define _GAPI_VULKAN 1 + //#define _GAPI_SW 1 + //#define _NAPI_SOCKET #include #undef OS_PTHREAD_MT + + #ifdef _GAPI_GL + #define VR_SUPPORT + #endif + + #define INV_VIBRATION + #define INV_QUALITY #elif ANDROID #define _OS_ANDROID 1 #define _GAPI_GL 1 #define _GAPI_GLES 1 //#define _GAPI_VULKAN - extern void osToggleVR(bool enable); + #define VR_SUPPORT + #define INV_QUALITY + #define INV_STEREO +#elif __SDL2__ + #define _GAPI_GL 1 + #ifdef SDL2_GLES + #define _GAPI_GLES 1 + #define DYNGEOM_NO_VBO + #endif + #define INV_QUALITY + #define INV_STEREO #elif __RPI__ #define _OS_RPI 1 #define _GAPI_GL 1 #define _GAPI_GLES 1 #define DYNGEOM_NO_VBO + #define INV_VIBRATION + #define INV_QUALITY + #define INV_STEREO #elif __CLOVER__ #define _OS_CLOVER 1 #define _GAPI_GL 1 #define _GAPI_GLES 1 #define DYNGEOM_NO_VBO + #define INV_GAMEPAD_NO_TRIGGER + #define INV_GAMEPAD_ONLY + #define INV_STEREO +#elif __PSC__ + #define _OS_PSC 1 + #define _GAPI_GL 1 + #define _GAPI_GLES 1 + + #define DYNGEOM_NO_VBO + #define INV_GAMEPAD_ONLY + #define INV_STEREO +#elif __BITTBOY__ || __MIYOO__ + #define _OS_BITTBOY 1 + #define _OS_LINUX 1 + #define _GAPI_SW 1 +#elif __GCW0__ + #define _OS_GCW0 1 + #define _GAPI_GL 1 + #define _GAPI_GLES 1 + + #define DYNGEOM_NO_VBO + + // etnaviv driver has a bug with cubemap mips generator + #undef USE_CUBEMAP_MIPS + + #define INV_SINGLE_PLAYER + #define INV_VIBRATION + #define INV_GAMEPAD_ONLY #elif __linux__ #define _OS_LINUX 1 #define _GAPI_GL 1 + + #define INV_VIBRATION + #define INV_QUALITY + #define INV_STEREO #elif __APPLE__ #define _GAPI_GL 1 #include "TargetConditionals.h" @@ -51,36 +129,96 @@ #define _GAPI_GLES 1 #else #define _OS_MAC 1 + #define INV_STEREO #endif + #define INV_QUALITY #elif __EMSCRIPTEN__ #define _OS_WEB 1 #define _GAPI_GL 1 #define _GAPI_GLES 1 #undef OS_FILEIO_CACHE + + extern int WEBGL_VERSION; + + #define INV_QUALITY + #define INV_STEREO +#elif _3DS + #include <3ds.h> + + #define _OS_3DS 1 + #define _GAPI_C3D 1 + + #undef OS_PTHREAD_MT + #undef USE_CUBEMAP_MIPS + #define USE_ATLAS_RGBA16 + + // for 2352 stereo samples + // stb_vorbis - 8 ms + // libvorbis - 6 ms + #define USE_LIBVORBIS + + #define INV_SINGLE_PLAYER + #define INV_GAMEPAD_NO_TRIGGER + #define INV_GAMEPAD_ONLY + //#define INV_STEREO // hardware switch #elif _PSP #define _OS_PSP 1 #define _GAPI_GU 1 - #define FFP #define TEX_SWIZZLE //#define EDRAM_MESH #define EDRAM_TEX #undef OS_PTHREAD_MT + + #define INV_SINGLE_PLAYER + #define INV_GAMEPAD_NO_TRIGGER + #define INV_GAMEPAD_ONLY #elif __vita__ #define _OS_PSV 1 #define _GAPI_GXM 1 #undef OS_PTHREAD_MT + + //#define USE_LIBVORBIS // TODO crash + + #define INV_SINGLE_PLAYER + #define INV_GAMEPAD_NO_TRIGGER + #define INV_GAMEPAD_ONLY #elif __SWITCH__ - #define _OS_NX 1 - #define _GAPI_GL 1 + #define _OS_SWITCH 1 + #define _GAPI_GL 1 + + #undef OS_PTHREAD_MT + #define INV_QUALITY + #define INV_STEREO +#elif _XBOX + #define _OS_XBOX 1 + #define _GAPI_D3D8 1 - #undef OS_PTHREAD_MT + #undef OS_PTHREAD_MT + #undef USE_CUBEMAP_MIPS + + #define NOMINMAX + #include + #include + + #define INV_GAMEPAD_NO_TRIGGER + #define INV_GAMEPAD_ONLY + #define INV_VIBRATION +#elif _X360 + #define _OS_X360 1 + // TODO +#elif __NDLESS__ + #define _OS_TNS 1 + #define _GAPI_SW 1 + #include + + #undef OS_PTHREAD_MT #endif -#ifndef _OS_PSP +#if !defined(_OS_PSP) && !defined(_OS_TNS) #define USE_INFLATE #endif @@ -88,77 +226,59 @@ #include "libs/tinf/tinf.h" #endif +#if defined(_GAPI_SW) || defined(_GAPI_GU) + #define FFP +#endif + #ifdef FFP #define SPLIT_BY_TILE - #ifdef _OS_PSP + #if defined(_GAPI_GU) #define SPLIT_BY_CLUT #endif #else - #define MERGE_MODELS + // current etnaviv driver implementation uses uncompatible Mesa GLSL compiler + // it produce unimplemented TRUNC/ARL instructions instead of F2I + // so we can't use joints indexing in the shader (see MESH_SKINNING) + #ifndef _OS_GCW0 + #define MERGE_MODELS + #endif #define MERGE_SPRITES #define GENERATE_WATER_PLANE #endif #include "utils.h" -// muse be equal with base shader -#define SHADOW_TEX_SIZE 1024 +#if defined(_OS_3DS) + #define SHADOW_TEX_SIZE 512 +#elif defined(_OS_GCW0) + #define SHADOW_TEX_SIZE 256 +#elif defined(_OS_PSV) + #define SHADOW_TEX_SIZE 1024 +#else + #define SHADOW_TEX_SIZE 2048 +#endif extern void* osMutexInit (); extern void osMutexFree (void *obj); extern void osMutexLock (void *obj); extern void osMutexUnlock (void *obj); -extern int osGetTime (); +extern int osGetTimeMS (); extern bool osJoyReady (int index); extern void osJoyVibrate (int index, float L, float R); #define OS_LOCK(mutex) Core::Lock _lock(mutex) -/* -extern void* osRWLockInit (); -extern void osRWLockFree (void *obj); -extern void osRWLockRead (void *obj); -extern void osRWUnlockRead (void *obj); -extern void osRWLockWrite (void *obj); -extern void osRWUnlockWrite (void *obj); - -struct RWLock { - void *obj; - - RWLock() { obj = osRWLockInit(); } - ~RWLock() { osRWLockFree(obj); } - void lockRead() { osRWLockRead(obj); } - void unlockRead() { osRWUnlockRead(obj); } - void lockWrite() { osRWLockWrite(obj); } - void unlockWrite() { osRWUnlockWrite(obj); } -}; - -struct LockRead { - RWLock &lock; - - LockRead(RWLock &lock) : lock(lock) { lock.lockRead(); } - ~LockRead() { lock.unlockRead(); } -}; - -struct LockWrite { - RWLock &lock; - - LockWrite(RWLock &lock) : lock(lock) { lock.lockWrite(); } - ~LockWrite() { lock.unlockWrite(); } -}; - -#define OS_LOCK_READ(rwLock) LockRead _rLock(rwLock) -#define OS_LOCK_WRITE(rwLock) LockWrite _wLock(rwLock) -*/ - enum InputKey { ikNone, // keyboard ikLeft, ikRight, ikUp, ikDown, ikSpace, ikTab, ikEnter, ikEscape, ikShift, ikCtrl, ikAlt, ik0, ik1, ik2, ik3, ik4, ik5, ik6, ik7, ik8, ik9, ikA, ikB, ikC, ikD, ikE, ikF, ikG, ikH, ikI, ikJ, ikK, ikL, ikM, ikN, ikO, ikP, ikQ, ikR, ikS, ikT, ikU, ikV, ikW, ikX, ikY, ikZ, + ikN0, ikN1, ikN2, ikN3, ikN4, ikN5, ikN6, ikN7, ikN8, ikN9, ikNAdd, ikNSub, ikNMul, ikNDiv, ikNDot, + ikF1, ikF2, ikF3, ikF4, ikF5, ikF6, ikF7, ikF8, ikF9, ikF10, ikF11, ikF12, + ikMinus, ikPlus, ikLSB, ikRSB, ikSlash, ikBSlash, ikComma, ikDot, ikTilda, ikColon, ikApos, ikPrev, ikNext, ikHome, ikEnd, ikDel, ikIns, ikBack, // mouse ikMouseL, ikMouseR, ikMouseM, // touch @@ -199,10 +319,10 @@ namespace Core { struct Mutex { void *obj; - Mutex() { obj = osMutexInit(); } - ~Mutex() { osMutexFree(obj); } - void lock() { osMutexLock(obj); } - void unlock() { osMutexUnlock(obj); } + Mutex() { obj = osMutexInit(); } + ~Mutex() { if (obj) osMutexFree(obj); } + void lock() { if (obj) osMutexLock(obj); } + void unlock() { if (obj) osMutexUnlock(obj); } }; struct Lock { @@ -219,29 +339,34 @@ namespace Core { struct Support { int maxVectors; int maxAniso; + int texMinSize; bool shaderBinary; bool VAO; + bool VBO; bool depthTexture; bool shadowSampler; bool discardFrame; + bool derivatives; bool texNPOT; + bool tex3D; bool texRG; bool texBorder; + bool texMaxLevel; bool colorFloat, texFloat, texFloatLinear; bool colorHalf, texHalf, texHalfLinear; - bool clipDist; #ifdef PROFILE bool profMarker; bool profTiming; #endif } support; -#define SETTINGS_VERSION 3 +#define SETTINGS_VERSION 7 #define SETTINGS_READING 0xFF struct Settings { enum Quality { LOW, MEDIUM, HIGH }; - enum Stereo { STEREO_OFF, STEREO_ON, STEREO_SPLIT, STEREO_VR }; + enum Stereo { STEREO_OFF, STEREO_SBS, STEREO_ANAGLYPH, STEREO_SPLIT, STEREO_VR }; + enum Scale { SCALE_25, SCALE_50, SCALE_75, SCALE_100 }; uint8 version; @@ -256,6 +381,7 @@ namespace Core { uint8 quality[4]; }; uint8 simple; + uint8 scale; uint8 vsync; uint8 stereo; void setFilter(Quality value) { @@ -265,7 +391,7 @@ namespace Core { } void setLighting(Quality value) { - #ifdef _OS_PSP + #if defined(_GAPI_SW) || defined(_GAPI_GU) lighting = LOW; #else lighting = value; @@ -273,7 +399,7 @@ namespace Core { } void setShadows(Quality value) { - #ifdef _OS_PSP + #if defined(_GAPI_SW) || defined(_GAPI_GU) shadows = LOW; #else shadows = value; @@ -281,20 +407,28 @@ namespace Core { } void setWater(Quality value) { - #ifdef _OS_PSP + #if defined(_GAPI_SW) || defined(_GAPI_GU) water = LOW; #else if (value > LOW && !(support.texFloat || support.texHalf)) value = LOW; + if (value > MEDIUM && !support.derivatives) + value = MEDIUM; water = value; #endif } + + bool isStereo() { + return stereo == STEREO_SBS || stereo == STEREO_ANAGLYPH || stereo == STEREO_VR; + } } detail; struct { uint8 music; uint8 sound; uint8 reverb; + uint8 subtitles; + uint8 language; } audio; struct Controls { @@ -314,7 +448,7 @@ namespace Core { bool isQuit; int getTime() { - return osGetTime(); + return osGetTimeMS(); } void resetTime() { @@ -327,6 +461,32 @@ namespace Core { } } +#ifdef VR_SUPPORT +extern void osToggleVR(bool enable); +#else +void osToggleVR(bool enable) { + Core::settings.detail.stereo = Core::Settings::STEREO_OFF; +} +#endif + +#ifdef PROFILE + struct TimingCPU { + int &result; + + TimingCPU(int &result) : result(result) { + result = Core::getTime(); + } + + ~TimingCPU() { + result = Core::getTime() - result; + } + }; + + #define PROFILE_CPU_TIMING(result) TimingCPU timingCPU(result) +#else + #define PROFILE_CPU_TIMING(result) +#endif + #include "input.h" #include "sound.h" @@ -336,9 +496,13 @@ namespace Core { #include "napi_dummy.h" #endif +#define LIGHT_STACK_SIZE 1 #define MAX_LIGHTS 4 #define MAX_RENDER_BUFFERS 32 #define MAX_CONTACTS 15 +#define NOISE_TEX_SIZE 32 +#define PERLIN_TEX_SIZE 128 +#define PERLIN_TEX_NAME "perlin3_128.raw" struct Shader; struct Texture; @@ -351,22 +515,23 @@ namespace GAPI { enum RenderState { RS_TARGET = 1 << 0, RS_VIEWPORT = 1 << 1, - RS_DEPTH_TEST = 1 << 2, - RS_DEPTH_WRITE = 1 << 3, - RS_COLOR_WRITE_R = 1 << 4, - RS_COLOR_WRITE_G = 1 << 5, - RS_COLOR_WRITE_B = 1 << 6, - RS_COLOR_WRITE_A = 1 << 7, + RS_SCISSOR = 1 << 2, + RS_DEPTH_TEST = 1 << 3, + RS_DEPTH_WRITE = 1 << 4, + RS_COLOR_WRITE_R = 1 << 5, + RS_COLOR_WRITE_G = 1 << 6, + RS_COLOR_WRITE_B = 1 << 7, + RS_COLOR_WRITE_A = 1 << 8, RS_COLOR_WRITE = RS_COLOR_WRITE_R | RS_COLOR_WRITE_G | RS_COLOR_WRITE_B | RS_COLOR_WRITE_A, - RS_CULL_BACK = 1 << 8, - RS_CULL_FRONT = 1 << 9, + RS_CULL_BACK = 1 << 9, + RS_CULL_FRONT = 1 << 10, RS_CULL = RS_CULL_BACK | RS_CULL_FRONT, - RS_BLEND_ALPHA = 1 << 10, - RS_BLEND_ADD = 1 << 11, - RS_BLEND_MULT = 1 << 12, - RS_BLEND_PREMULT = 1 << 13, + RS_BLEND_ALPHA = 1 << 11, + RS_BLEND_ADD = 1 << 12, + RS_BLEND_MULT = 1 << 13, + RS_BLEND_PREMULT = 1 << 14, RS_BLEND = RS_BLEND_ALPHA | RS_BLEND_ADD | RS_BLEND_MULT | RS_BLEND_PREMULT, - RS_DISCARD = 1 << 14, + RS_DISCARD = 1 << 15, }; // Texture image format @@ -375,8 +540,8 @@ enum TexFormat { FMT_RGBA, FMT_RGB16, FMT_RGBA16, - FMT_RGBA_FLOAT, - FMT_RGBA_HALF, + FMT_RG_FLOAT, + FMT_RG_HALF, FMT_DEPTH, FMT_SHADOW, FMT_MAX, @@ -384,13 +549,17 @@ enum TexFormat { // Texture options enum TexOption { - OPT_REPEAT = 1, - OPT_CUBEMAP = 2, - OPT_MIPMAPS = 4, - OPT_NEAREST = 8, - OPT_TARGET = 16, - OPT_VERTEX = 32, - OPT_PROXY = 64, + OPT_REPEAT = 0x0001, + OPT_CUBEMAP = 0x0002, + OPT_VOLUME = 0x0004, + OPT_MIPMAPS = 0x0008, + OPT_NEAREST = 0x0010, + OPT_TARGET = 0x0020, + OPT_VERTEX = 0x0040, + OPT_DYNAMIC = 0x0080, + OPT_DEPEND = 0x0100, + OPT_PROXY = 0x0200, + OPT_VRAM_3DS = 0x0400, }; // Pipeline State Object @@ -403,7 +572,11 @@ struct PSO { uint32 renderState; }; -typedef uint16 Index; +#if !defined(FFP) && (defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_MAC) || defined(_OS_WEB)) + typedef uint32 Index; +#else + typedef uint16 Index; +#endif struct Edge { Index a, b; @@ -414,7 +587,7 @@ struct Edge { struct Vertex { short4 coord; // xyz - position, w - joint index (for entities only) - short4 normal; // xyz - vertex normal, w - unused + short4 normal; // xyz - vertex normal, w - quad(0) or triangle (1) short4 texCoord; // xy - texture coordinates, zw - trapezoid warping ubyte4 color; // for non-textured geometry ubyte4 light; // xyz - color, w - use premultiplied alpha @@ -444,11 +617,9 @@ struct MeshRange { E( sNormal ) \ E( sReflect ) \ E( sShadow ) \ - E( sEnvironment ) \ E( sMask ) #define SHADER_UNIFORMS(E) \ - E( uFlags ) \ E( uParam ) \ E( uTexParam ) \ E( uViewProj ) \ @@ -475,6 +646,10 @@ struct MeshRange { E( TYPE_ROOM ) \ E( TYPE_ENTITY ) \ E( TYPE_MIRROR ) \ + /* sky */ \ + E( SKY_TEXTURE ) \ + E( SKY_CLOUDS ) \ + E( SKY_CLOUDS_AZURE ) \ /* water sub-passes */ \ E( WATER_DROP ) \ E( WATER_SIMULATE ) \ @@ -483,15 +658,16 @@ struct MeshRange { E( WATER_MASK ) \ E( WATER_COMPOSE ) \ /* filter types */ \ - E( FILTER_UPSCALE ) \ - E( FILTER_DOWNSAMPLE ) \ - E( FILTER_GRAYSCALE ) \ - E( FILTER_BLUR ) \ - E( FILTER_EQUIRECTANGULAR ) \ + E( FILTER_UPSCALE ) \ + E( FILTER_DOWNSAMPLE ) \ + E( FILTER_DOWNSAMPLE_DEPTH ) \ + E( FILTER_GRAYSCALE ) \ + E( FILTER_BLUR ) \ + E( FILTER_ANAGLYPH ) \ + E( FILTER_EQUIRECTANGULAR ) \ /* options */ \ E( UNDERWATER ) \ E( ALPHA_TEST ) \ - E( CLIP_PLANE ) \ E( OPT_AMBIENT ) \ E( OPT_SHADOW ) \ E( OPT_CONTACT ) \ @@ -513,22 +689,14 @@ const char *UniformName[uMAX] = { SHADER_UNIFORMS(DECL_STR) }; #undef SHADER_SAMPLERS #undef SHADER_UNIFORMS -enum CullMode { cmNone, cmBack, cmFront }; +enum CullMode { cmNone, cmBack, cmFront, cmMAX }; enum BlendMode { bmNone, bmAlpha, bmAdd, bmMult, bmPremult, bmMAX }; -struct Viewport { - int x, y, width, height; - - Viewport() : x(0), y(0), width(0), height(0) {} - Viewport(int x, int y, int width, int height) : x(x), y(y), width(width), height(height) {} - - inline bool operator == (const Viewport &vp) const { return x == vp.x && y == vp.y && width == vp.width && height == vp.height; } - inline bool operator != (const Viewport &vp) const { return !(*this == vp); } -}; - namespace Core { float eye; - Viewport viewport, viewportDef; + float aspectFix = 1.0f; + Texture *eyeTex[2]; + short4 viewport, viewportDef, scissor; mat4 mModel, mView, mProj, mViewProj, mViewInv; mat4 mLightProj; Basis basis; @@ -536,14 +704,17 @@ namespace Core { vec4 lightPos[MAX_LIGHTS]; vec4 lightColor[MAX_LIGHTS]; vec4 params; - vec4 fogParams; vec4 contacts[MAX_CONTACTS]; - Texture *whiteTex, *whiteCube, *blackTex, *ditherTex; + struct LightStack { + vec4 pos[MAX_LIGHTS]; + vec4 color[MAX_LIGHTS]; + } lightStack[LIGHT_STACK_SIZE]; + int lightStackCount; - enum Pass { passCompose, passShadow, passAmbient, passWater, passFilter, passGUI, passMAX } pass; + Texture *whiteTex, *whiteCube, *blackTex, *ditherTex, *noiseTex, *perlinTex; - const char *passNames[Core::passMAX] = { "COMPOSE", "SHADOW", "AMBIENT", "WATER", "FILTER", "GUI" }; + enum Pass { passCompose, passShadow, passAmbient, passSky, passWater, passFilter, passGUI, passMAX } pass; GAPI::Texture *defaultTarget; @@ -557,7 +728,8 @@ namespace Core { int32 renderState; uint32 targetFace; uint32 targetOp; - Viewport viewport; // TODO: ivec4 + short4 viewport; // x, y, width, height + short4 scissor; // x, y, width, height vec4 material; #ifdef _GAPI_GL @@ -570,6 +742,10 @@ namespace Core { Vertex *vBuffer; #endif + #ifdef _GAPI_C3D + void *VAO; + #endif + int32 basisCount; Basis *basis; } active; @@ -585,6 +761,7 @@ namespace Core { int fpsTime; #ifdef PROFILE int tFrame; + int video; #endif Stats() : frame(0), frameIndex(0), fps(0), fpsTime(0) {} @@ -595,9 +772,11 @@ namespace Core { void stop() { if (fpsTime < Core::getTime()) { - LOG("FPS: %d DIP: %d TRI: %d RT: %d CB: %d\n", fps, dips, tris, rt, cb); + LOG("FPS: %d DIP: %d TRI: %d RT: %d\n", fps, dips, tris, rt); #ifdef PROFILE LOG("frame time: %d mcs\n", tFrame / 1000); + LOG("sound: mix %d rev %d ren %d/%d ogg %d\n", Sound::stats.mixer, Sound::stats.reverb, Sound::stats.render[0], Sound::stats.render[1], Sound::stats.ogg); + LOG("video: %d\n", video); #endif fps = frame; frame = 0; @@ -610,18 +789,24 @@ namespace Core { } stats; } -#ifdef _GAPI_GL - #include "gapi_gl.h" +#ifdef _GAPI_SW + #include "gapi/sw.h" +#elif _GAPI_GL + #include "gapi/gl.h" +#elif _GAPI_D3D8 + #include "gapi/d3d8.h" #elif _GAPI_D3D9 - #include "gapi_d3d9.h" -#elif _GAPI_GX - #include "gapi_gx.h" + #include "gapi/d3d9.h" +#elif _GAPI_D3D11 + #include "gapi/d3d11.h" +#elif _OS_3DS + #include "gapi/c3d.h" #elif _GAPI_GU - #include "gapi_gu.h" + #include "gapi/gu.h" #elif _GAPI_GXM - #include "gapi_gxm.h" + #include "gapi/gxm.h" #elif _GAPI_VULKAN - #include "gapi_vk.h" + #include "gapi/vk.h" #endif #include "texture.h" @@ -631,10 +816,53 @@ namespace Core { namespace Core { static const char *version = __DATE__; + static int defLang = 0; + + void readPerlinAsync(Stream *stream, void *userData) { + int size = PERLIN_TEX_SIZE * PERLIN_TEX_SIZE * PERLIN_TEX_SIZE; + uint8 *perlinData = NULL; + + if (stream && stream->size == size) { + perlinData = new uint8[size]; + stream->raw(perlinData, size); + } else { + perlinData = Noise::generate(123456, PERLIN_TEX_SIZE, 5, 8, 1.0f); + Stream::cacheWrite(PERLIN_TEX_NAME, (char*)perlinData, size); + } + delete stream; + + perlinTex = new Texture(PERLIN_TEX_SIZE, PERLIN_TEX_SIZE, PERLIN_TEX_SIZE, FMT_LUMINANCE, OPT_REPEAT | OPT_VOLUME, perlinData); + /*/ + uint8 *pdata = new uint8[SQR(PERLIN_TEX_SIZE) * 4]; + int offset = 0; + for (int k = 0; k < PERLIN_TEX_SIZE; k++) { + int j = 0; + for (int i = 0; i < SQR(PERLIN_TEX_SIZE); i++) { + pdata[j + 0] = pdata[j + 1] = pdata[j + 2] = perlinData[offset + i]; + pdata[j + 3] = 255; + j += 4; + } + char buf[256]; + sprintf(buf, "noise/perlin_%03d", k); + Texture::SaveBMP(buf, (char*)pdata, PERLIN_TEX_SIZE, PERLIN_TEX_SIZE); + offset += PERLIN_TEX_SIZE * PERLIN_TEX_SIZE; + } + delete[] pdata; + */ + delete[] perlinData; + } void init() { LOG("OpenLara (%s)\n", version); + x = y = 0; + eyeTex[0] = eyeTex[1] = NULL; + lightStackCount = 0; + + memset(&support, 0, sizeof(support)); + support.texMinSize = 1; + support.texMaxLevel = true; + support.derivatives = true; #ifdef USE_INFLATE tinf_init(); @@ -648,6 +876,13 @@ namespace Core { GAPI::init(); + #ifdef _OS_3DS + Core::eyeTex[0] = new Texture(Core::width, Core::height, 1, TexFormat::FMT_RGB16, OPT_TARGET | OPT_PROXY); + Core::eyeTex[1] = new Texture(Core::width, Core::height, 1, TexFormat::FMT_RGB16, OPT_TARGET | OPT_PROXY); + GAPI::Texture *outputTex[2] = { Core::eyeTex[0], Core::eyeTex[1] }; + GAPI::initOutput(outputTex); + #endif + LOG("cache : %s\n", cacheDir); LOG("supports :\n"); LOG(" variyngs count : %d\n", support.maxVectors); @@ -657,9 +892,10 @@ namespace Core { LOG(" shadow sampler : %s\n", support.shadowSampler ? "true" : "false"); LOG(" discard frame : %s\n", support.discardFrame ? "true" : "false"); LOG(" NPOT textures : %s\n", support.texNPOT ? "true" : "false"); + LOG(" 3D textures : %s\n", support.tex3D ? "true" : "false"); LOG(" RG textures : %s\n", support.texRG ? "true" : "false"); LOG(" border color : %s\n", support.texBorder ? "true" : "false"); - LOG(" clip distance : %s\n", support.clipDist ? "true" : "false"); + LOG(" max level : %s\n", support.texMaxLevel ? "true" : "false"); LOG(" anisotropic : %d\n", support.maxAniso); LOG(" float textures : float = %s, half = %s\n", support.colorFloat ? "full" : (support.texFloat ? (support.texFloatLinear ? "linear" : "nearest") : "false"), @@ -674,25 +910,46 @@ namespace Core { } eye = 0.0f; - uint32 data = 0xFFFFFFFF; - whiteTex = new Texture(1, 1, FMT_RGBA, OPT_NEAREST, &data); - whiteCube = new Texture(1, 1, FMT_RGBA, OPT_CUBEMAP, &data); - data = 0; - blackTex = new Texture(1, 1, FMT_RGBA, OPT_NEAREST, &data); - - uint8 ditherData[] = { - 0x00, 0x7F, 0x1F, 0x9F, 0x07, 0x87, 0x27, 0xA7, - 0xBF, 0x3F, 0xDF, 0x5F, 0xC7, 0x47, 0xE7, 0x67, - 0x2F, 0xAF, 0x0F, 0x8F, 0x37, 0xB7, 0x17, 0x97, - 0xEF, 0x6F, 0xCF, 0x4F, 0xF7, 0x77, 0xD7, 0x57, - 0x0B, 0x8B, 0x2B, 0xAB, 0x03, 0x83, 0x23, 0xA3, - 0xCB, 0x4B, 0xEB, 0x6B, 0xC3, 0x43, 0xE3, 0x63, - 0x3B, 0xBB, 0x1B, 0x9B, 0x33, 0xB3, 0x13, 0x93, - 0xFB, 0x7B, 0xDB, 0x5B, 0xF3, 0x73, 0xD3, 0x53, - }; - ditherTex = new Texture(8, 8, FMT_LUMINANCE, OPT_REPEAT | OPT_NEAREST, &ditherData); - -// init settings + { // init dummy textures + int size = SQR(support.texMinSize) * 6; + uint32 *data = new uint32[size]; + memset(data, 0xFF, size * sizeof(data[0])); + whiteTex = new Texture(support.texMinSize, support.texMinSize, 1, FMT_RGBA, OPT_NEAREST, data); + whiteCube = new Texture(support.texMinSize, support.texMinSize, 1, FMT_RGBA, OPT_CUBEMAP, data); + memset(data, 0x00, size * sizeof(data[0])); + blackTex = new Texture(support.texMinSize, support.texMinSize, 1, FMT_RGBA, OPT_NEAREST, data); + delete[] data; + } + + { // generate dithering texture + uint8 ditherData[] = { + 0x00, 0x7F, 0x1F, 0x9F, 0x07, 0x87, 0x27, 0xA7, + 0xBF, 0x3F, 0xDF, 0x5F, 0xC7, 0x47, 0xE7, 0x67, + 0x2F, 0xAF, 0x0F, 0x8F, 0x37, 0xB7, 0x17, 0x97, + 0xEF, 0x6F, 0xCF, 0x4F, 0xF7, 0x77, 0xD7, 0x57, + 0x0B, 0x8B, 0x2B, 0xAB, 0x03, 0x83, 0x23, 0xA3, + 0xCB, 0x4B, 0xEB, 0x6B, 0xC3, 0x43, 0xE3, 0x63, + 0x3B, 0xBB, 0x1B, 0x9B, 0x33, 0xB3, 0x13, 0x93, + 0xFB, 0x7B, 0xDB, 0x5B, 0xF3, 0x73, 0xD3, 0x53, + }; + ditherTex = new Texture(8, 8, 1, FMT_LUMINANCE, OPT_REPEAT | OPT_NEAREST, &ditherData); + } + + { // generate noise texture + uint8 *noiseData = new uint8[SQR(NOISE_TEX_SIZE) * 4]; + for (int i = 0; i < SQR(NOISE_TEX_SIZE) * 4; i++) { + noiseData[i] = rand() % 255; + } + noiseTex = new Texture(NOISE_TEX_SIZE, NOISE_TEX_SIZE, 1, FMT_RGBA, OPT_REPEAT, noiseData); + delete[] noiseData; + } + + perlinTex = NULL; + if (support.tex3D) { + Stream::cacheRead(PERLIN_TEX_NAME, readPerlinAsync); + } + + // init settings settings.version = SETTINGS_VERSION; settings.detail.setFilter (Core::Settings::HIGH); @@ -702,9 +959,12 @@ namespace Core { settings.detail.simple = false; settings.detail.vsync = true; settings.detail.stereo = Settings::STEREO_OFF; - settings.audio.music = 14; - settings.audio.sound = 14; + settings.detail.scale = Settings::SCALE_100; + settings.audio.music = SND_MAX_VOLUME; + settings.audio.sound = SND_MAX_VOLUME; settings.audio.reverb = true; + settings.audio.subtitles = true; + settings.audio.language = defLang; // player 1 { @@ -763,6 +1023,9 @@ namespace Core { #ifdef _OS_WEB settings.controls[0].keys[ cJump ].key = ikD; settings.controls[0].keys[ cInventory ].key = ikTab; + + settings.audio.music = 14; + settings.audio.sound = 14; #endif #if defined(_OS_RPI) || defined(_OS_CLOVER) @@ -770,6 +1033,28 @@ namespace Core { settings.detail.setLighting (Core::Settings::MEDIUM); #endif + #if defined(_OS_GCW0) + settings.detail.setFilter (Core::Settings::MEDIUM); + settings.detail.setShadows (Core::Settings::MEDIUM); + settings.detail.setLighting (Core::Settings::MEDIUM); + settings.audio.subtitles = false; + #endif + + #ifdef _OS_PSC + settings.detail.setLighting (Core::Settings::MEDIUM); + settings.detail.setShadows (Core::Settings::LOW); + settings.detail.setWater (Core::Settings::LOW); + #endif + + #ifdef _OS_3DS + settings.detail.setFilter (Core::Settings::MEDIUM); + settings.detail.setLighting (Core::Settings::LOW); + settings.detail.setShadows (Core::Settings::LOW); + settings.detail.setWater (Core::Settings::LOW); + + settings.audio.reverb = false; + #endif + #ifdef FFP settings.detail.setFilter (Core::Settings::MEDIUM); settings.detail.setLighting (Core::Settings::LOW); @@ -781,6 +1066,27 @@ namespace Core { settings.audio.reverb = false; #endif + #ifdef _OS_PSV + settings.detail.setFilter (Core::Settings::HIGH); + settings.detail.setLighting (Core::Settings::LOW); + settings.detail.setShadows (Core::Settings::MEDIUM); + settings.detail.setWater (Core::Settings::MEDIUM); + #endif + + #ifdef _OS_XBOX + settings.detail.setFilter (Core::Settings::HIGH); + settings.detail.setLighting (Core::Settings::LOW); + settings.detail.setShadows (Core::Settings::LOW); + settings.detail.setWater (Core::Settings::LOW); + #endif + + #ifdef _OS_WP8 + settings.detail.setFilter(Core::Settings::HIGH); + settings.detail.setLighting(Core::Settings::LOW); + settings.detail.setShadows(Core::Settings::LOW); + settings.detail.setWater(Core::Settings::LOW); + #endif + memset(&active, 0, sizeof(active)); renderState = 0; @@ -788,14 +1094,19 @@ namespace Core { } void deinit() { + delete eyeTex[0]; + delete eyeTex[1]; delete whiteTex; delete whiteCube; delete blackTex; delete ditherTex; + delete noiseTex; + delete perlinTex; GAPI::deinit(); NAPI::deinit(); Sound::deinit(); + Stream::deinit(); } void setVSync(bool enable) { @@ -825,7 +1136,7 @@ namespace Core { GAPI::discardTarget(!(active.targetOp & RT_STORE_COLOR), !(active.targetOp & RT_STORE_DEPTH)); GAPI::Texture *target = reqTarget.texture; - uint32 face = reqTarget.face; + uint32 face = reqTarget.face; if (target != active.target || face != active.targetFace) { Core::stats.rt++; @@ -852,6 +1163,14 @@ namespace Core { renderState &= ~RS_VIEWPORT; } + if (mask & RS_SCISSOR) { + if (scissor != active.scissor) { + active.scissor = scissor; + GAPI::setScissor(scissor); + } + renderState &= ~RS_SCISSOR; + } + if (mask & RS_DEPTH_TEST) GAPI::setDepthTest((renderState & RS_DEPTH_TEST) != 0); @@ -882,21 +1201,26 @@ namespace Core { GAPI::setClearColor(color); } - void setViewport(const Viewport &vp) { - viewport = vp; + void setViewport(const short4 &v) { + viewport = v; renderState |= RS_VIEWPORT; } void setViewport(int x, int y, int width, int height) { - setViewport(Viewport(x, y, width, height)); + setViewport(short4(x, y, width, height)); + } + + void setScissor(const short4 &s) { + scissor = s; + renderState |= RS_SCISSOR; } void setCullMode(CullMode mode) { renderState &= ~RS_CULL; switch (mode) { - case cmNone : break; case cmBack : renderState |= RS_CULL_BACK; break; case cmFront : renderState |= RS_CULL_FRONT; break; + default : ; } } @@ -939,19 +1263,21 @@ namespace Core { renderState &= ~RS_DEPTH_TEST; } - void setTarget(GAPI::Texture *target, int op, int face = 0) { - if (!target) - target = defaultTarget; + void setTarget(GAPI::Texture *color, GAPI::Texture *depth, int op, int face = 0) { + if (!color) + color = defaultTarget; - bool color = !target || (target->fmt != FMT_DEPTH && target->fmt != FMT_SHADOW); - setColorWrite(color, color, color, color); + bool isColor = !color || (color->fmt != FMT_DEPTH && color->fmt != FMT_SHADOW); + setColorWrite(isColor, isColor, isColor, isColor); - if (target == defaultTarget) // backbuffer + if (color == defaultTarget) // backbuffer setViewport(viewportDef); else - setViewport(0, 0, target->origWidth, target->origHeight); + setViewport(0, 0, color->origWidth, color->origHeight); - reqTarget.texture = target; + setScissor(viewport); + + reqTarget.texture = color; reqTarget.op = op; reqTarget.face = face; renderState |= RS_TARGET; @@ -961,7 +1287,11 @@ namespace Core { Core::active.basis = basis; Core::active.basisCount = count; - Core::active.shader->setParam(uBasis, basis[0], count); + #ifndef MERGE_MODELS + count = min(1, count); + #endif + + Core::active.shader->setParam(uBasis, *(vec4*)basis, count * 2); } void setMaterial(float diffuse, float ambient, float specular, float alpha) { @@ -970,6 +1300,15 @@ namespace Core { Core::active.shader->setParam(uMaterial, Core::active.material); } + void setFog(const vec4 ¶ms) { + #if defined(_GAPI_D3D8) || defined(_GAPI_C3D) || defined(_GAPI_SW) || defined(FFP) + GAPI::setFog(params); + #else + ASSERT(Core::active.shader); + Core::active.shader->setParam(uFogParams, params); + #endif + } + void updateLights() { GAPI::updateLights(lightPos, lightColor, MAX_LIGHTS); } @@ -982,6 +1321,21 @@ namespace Core { updateLights(); } + void pushLights() { + ASSERT(lightStackCount < LIGHT_STACK_SIZE); + memcpy(lightStack[lightStackCount].pos, lightPos, sizeof(lightPos)); + memcpy(lightStack[lightStackCount].color, lightColor, sizeof(lightColor)); + lightStackCount++; + } + + void popLights() { + ASSERT(lightStackCount > 0); + lightStackCount--; + memcpy(lightPos, lightStack[lightStackCount].pos, sizeof(lightPos)); + memcpy(lightColor, lightStack[lightStackCount].color, sizeof(lightColor)); + updateLights(); + } + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { validateRenderState(); GAPI::copyTarget(dst, xOffset, yOffset, x, y, width, height); @@ -1000,6 +1354,7 @@ namespace Core { setViewport(Core::x, Core::y, Core::width, Core::height); viewportDef = viewport; + scissor = viewport; setCullMode(cmFront); setBlendMode(bmAlpha); @@ -1016,7 +1371,7 @@ namespace Core { void endFrame() { if (active.target != defaultTarget) { - GAPI::setTarget(NULL, 0); + setTarget(NULL, NULL, 0); validateRenderState(); } GAPI::endFrame(); @@ -1040,33 +1395,6 @@ namespace Core { stats.dips++; stats.tris += range.iCount / 3; } - - PSO* psoCreate(Shader *shader, uint32 renderState, TexFormat colorFormat = FMT_RGBA, TexFormat depthFormat = FMT_DEPTH, const vec4 &clearColor = vec4(0.0f)) { - PSO *pso = new PSO(); - pso->data = NULL; - pso->shader = shader; - pso->renderState = renderState; - pso->colorFormat = colorFormat; - pso->depthFormat = depthFormat; - pso->clearColor = clearColor; - GAPI::initPSO(pso); - return pso; - } - - void psoDestroy(PSO *pso) { - GAPI::deinitPSO(pso); - delete pso; - } - - void psoBind(PSO *pso) { - ASSERT(pso); - ASSERT(pso->data); - ASSERT(pso->shader); - ((Shader*)pso->shader)->setup(); - GAPI::bindPSO(pso); - - Core::active.pso = pso; - } } #include "mesh.h" diff --git a/src/debug.h b/src/debug.h index 7e6955ea..a82b1a49 100644 --- a/src/debug.h +++ b/src/debug.h @@ -48,7 +48,10 @@ namespace Debug { } void begin() { + #ifndef FFP glActiveTexture(GL_TEXTURE0); + glUseProgram(0); + #endif glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadMatrixf((GLfloat*)&Core::mProj); @@ -59,7 +62,6 @@ namespace Debug { glLineWidth(3); glPointSize(32); - glUseProgram(0); Core::active.shader = NULL; Core::active.textures[0] = NULL; Core::validateRenderState(); @@ -206,8 +208,8 @@ namespace Debug { vec4 p = Core::mViewProj * vec4(pos, 1); if (p.w > 0) { p.xyz() = p.xyz() * (1.0f / p.w); - p.y = -p.y; - p.xyz() = (p.xyz() * 0.5f + vec3(0.5f)) * vec3(float(Core::width), float(Core::height), 1.0f); + p.y = -p.y; + p.xyz() = (p.xyz() * 0.5f + vec3(0.5f)) * vec3(float(Core::width), float(Core::height), 1.0f); text(vec2(p.x, p.y), color, str); } } @@ -258,6 +260,8 @@ namespace Debug { return TR_TYPE_NAMES[entity.type - TR2_TYPES_START + (TR::Entity::TR1_TYPE_MAX - TR1_TYPES_START) + 1]; if (entity.type < TR::Entity::TR3_TYPE_MAX) return TR_TYPE_NAMES[entity.type - TR3_TYPES_START + (TR::Entity::TR1_TYPE_MAX - TR1_TYPES_START) + (TR::Entity::TR2_TYPE_MAX - TR2_TYPES_START) + 2]; + if (entity.type < TR::Entity::TR4_TYPE_MAX) + return TR_TYPE_NAMES[entity.type - TR4_TYPES_START + (TR::Entity::TR1_TYPE_MAX - TR1_TYPES_START) + (TR::Entity::TR2_TYPE_MAX - TR2_TYPES_START) + (TR::Entity::TR3_TYPE_MAX - TR3_TYPES_START) + 3]; return "UNKNOWN"; } @@ -544,6 +548,9 @@ namespace Debug { for (int i = 0; i < level.roomsCount; i++) for (int j = 0; j < level.rooms[i].lightsCount; j++) { TR::Room::Light &l = level.rooms[i].lights[j]; + + if (!level.rooms[i].flags.visible) continue; + vec3 p = vec3(float(l.x), float(l.y), float(l.z)); vec4 color = vec4(l.color.r, l.color.g, l.color.b, 255) * (1.0f / 255.0f); @@ -622,7 +629,7 @@ namespace Debug { Box box = controller->getBoundingBoxLocal(); Debug::Draw::box(matrix, box.min, box.max, bboxIntersect ? vec4(1, 0, 0, 1): vec4(1)); - Sphere spheres[MAX_SPHERES]; + Sphere spheres[MAX_JOINTS]; int count = controller->getSpheres(spheres); for (int joint = 0; joint < count; joint++) { @@ -639,13 +646,36 @@ namespace Debug { } } - void dumpSample(TR::Level *level, int index) { + void dumpPalette(TR::Level *level, int index) + { char buf[255]; - sprintf(buf, "samples_PSX/%03d.wav", index); + sprintf(buf, "tiles_PC/%02d.pal", index); + FILE *f = fopen(buf, "wb"); + for (int i = 0; i < 256; i++) { + Color24 c = level->palette[i]; + uint16 res = (c.r >> 3) | ((c.g >> 3) << 5) | ((c.b >> 3) << 10); + fwrite(&res, 2, 1, f); + } + fclose(f); + } + + void dumpSample(TR::Level *level, int index, int id, int sample) { + char buf[255]; + sprintf(buf, "samples_PSX/%03d_%d.wav", id, sample); if (level->version == TR::VER_TR1_PSX) { uint32 dataSize = level->soundSize[index] / 16 * 28 * 2 * 4; + uint32 size = -1; + + FILE *f = fopen(buf, "rb"); + if (f) { + fseek(f, 0, SEEK_END); + size = ftell(f); + fclose(f); + } + + f = fopen(buf, "wb"); struct Header { uint32 RIFF; @@ -672,19 +702,30 @@ namespace Debug { fwrite(&header, sizeof(header), 1, f); - Sound::VAG vag(new Stream(NULL, &level->soundData[level->soundOffsets[index]], dataSize)); + Sound::VAG vag(level->getSampleStream(index)); Sound::Frame frames[4 * 28]; while (int count = vag.decode(frames, 4 * 28)) + { for (int i = 0; i < count; i++) - fwrite(&frames[i].L, 2, 1, f); + { + fwrite(&frames[i].L, 2, 1, f); + } + } + + dataSize = ftell(f); + if (size != -1 && size != dataSize) { + LOG("audio diff %03d_%d : %d -> %d\n", id, sample, size, dataSize); + } + + fclose(f); } if (level->version == TR::VER_TR1_PC) { uint32 *data = (uint32*)&level->soundData[level->soundOffsets[index]]; + FILE *f = fopen(buf, "wb"); fwrite(data, data[1] + 8, 1, f); + fclose(f); } - - fclose(f); } void info(IGame *game, Controller *controller, Animation &anim) { @@ -744,9 +785,9 @@ namespace Debug { for (int i = 0; i < info.trigCmdCount; i++) { TR::FloorData::TriggerCommand &cmd = info.trigCmd[i]; - const char *ent = (cmd.action == TR::Action::ACTIVATE || cmd.action == TR::Action::CAMERA_TARGET) ? getEntityName(level, level.entities[cmd.args]) : ""; + const char *ent = (cmd.action == TR::Action::ACTIVATE || cmd.action == TR::Action::CAMERA_TARGET) ? (cmd.args < level.entitiesBaseCount ? getEntityName(level, level.entities[cmd.args]) : "BAD_ENTITY_INDEX") : ""; sprintf(buf, "%s -> %s (%d)", getTriggerAction(level, cmd.action), ent, cmd.args); - if (cmd.action == TR::Action::CAMERA_SWITCH) { + if (cmd.action == TR::Action::CAMERA_SWITCH || cmd.action == TR::Action::FLYBY || cmd.action == TR::Action::CUTSCENE) { i++; sprintf(buf, "%s delay: %d speed: %d", buf, int(info.trigCmd[i].timer), int(info.trigCmd[i].speed)); } diff --git a/src/enemy.h b/src/enemy.h index f499c3be..d83afe67 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -2,7 +2,7 @@ #define H_ENEMY #include "character.h" -#include "trigger.h" +#include "objects.h" #define STALK_BOX (1024 * 3) #define ESCAPE_BOX (1024 * 5) @@ -79,6 +79,7 @@ struct Enemy : Character { Enemy(IGame *game, int entity, float health, int radius, float length, float aggression) : Character(game, entity, health), ai(AI_RANDOM), mood(MOOD_SLEEP), wound(false), nextState(0), targetBox(TR::NO_BOX), thinkTime(1.0f / 30.0f), length(length), aggression(aggression), radius(radius), hitSound(-1), target(NULL), path(NULL) { targetDist = +INF; targetInView = targetFromView = targetCanAttack = false; + waypoint = pos; } virtual ~Enemy() { @@ -167,7 +168,7 @@ struct Enemy : Character { if (enemy->health > 0.0f) { vec3 dir = vec3(enemy->pos.x - pos.x, 0.0f, enemy->pos.z - pos.z); float D = dir.length2(); - float R = float(enemy->radius + radius); + float R = float((enemy->radius + radius) / 2); if (D < R * R) { D = sqrtf(D); pos -= dir.normal() * (R - D); @@ -227,22 +228,6 @@ struct Enemy : Character { animation.overrideMask &= ~(1 << chest); } - void getTargetInfo(int height, vec3 *pos, float *angleX, float *angleY, float *dist) { - vec3 p = waypoint; - p.y -= height; - if (pos) *pos = p; - vec3 a = p - this->pos; - if (dist) *dist = a.length(); - - if (angleX || angleY) { - a = a.normal(); - vec3 b = getDir(); - vec3 n = vec3(0, 1, 0); - if (angleX) *angleX = 0.0f; - if (angleY) *angleY = atan2f(b.cross(a).dot(n), a.dot(b)); - } - } - bool targetIsVisible(float maxDist) { if (targetInView && targetDist < maxDist && target->health > 0.0f) { TR::Location from, to; @@ -264,28 +249,28 @@ struct Enemy : Character { Character::lookAt(targetInView ? target : NULL); } - int turn(float delta, float speed) { - float w = speed * Core::deltaTime; - - updateTilt(delta, w, speed * 0.1f); + void turn(bool tilt, float w) { + float speed = animation.getSpeed(); - if (delta != 0.0f) { - decrease(delta, angle.y, w); - if (speed != 0.0f) { - velocity = velocity.rotateY(-w); - return speed < 0 ? LEFT : RIGHT; - } + if (!target || speed == 0.0f || w == 0.0f) { + angle.z = lerp(angle.z, 0.0f, 4.0f * Core::deltaTime); + return; } - return 0; - } - void turn(bool tilt, float w) { - float angleY = 0.0f; + vec3 d = waypoint - pos; + float a = clampAngle(normalizeAngle(PIH - d.angleY() - angle.y)); + + w /= 30.0f; + + float minDist = speed * PIH / w; - if (tilt) - getTargetInfo(0, NULL, NULL, &angleY, NULL); + if ( (a > PIH || a < -PIH) && (SQR(d.x) + SQR(d.z) < SQR(minDist)) ) + w *= 0.5f; - turn(angleY, w); + a = clamp(a, -w, w); + + angle.y += a * 30.0f * Core::deltaTime; + angle.z = lerp(angle.z, tilt ? a * 2.0f : 0.0f, 4.0f * Core::deltaTime); } int lift(float delta, float speed) { @@ -487,7 +472,14 @@ struct Enemy : Character { int z = (b.minZ + b.maxZ) / 2 - int(target->pos.z); if (abs(z) > STALK_BOX) return false; - // TODO: check for some quadrant shit + int target_quadrant = angleQuadrant(target->angle.y, 0.0); + int box_quadrant = z > 0 ? (x > 0 ? 2 : 1) : (x > 0 ? 3 : 0); + + if (target_quadrant == box_quadrant) return false; + + int controller_quadrant = pos.z > target->pos.z ? (pos.x > target->pos.x ? 2 : 1) : (pos.x > target->pos.x ? 3 : 0); + + if (target_quadrant == controller_quadrant && abs(target_quadrant - box_quadrant) == 2) return false; return true; } @@ -1065,9 +1057,11 @@ struct Rat : Enemy { modelLand = level->getModelIndex(TR::Entity::ENEMY_RAT_LAND) - 1; modelWater = level->getModelIndex(TR::Entity::ENEMY_RAT_WATER) - 1; } - + const virtual TR::Model* getModel() { - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; + stand = water ? STAND_ONWATER : STAND_GROUND; + int modelIndex = water ? modelWater : modelLand; if (modelIndex == -1) { @@ -1080,7 +1074,6 @@ struct Rat : Enemy { if (animation.model != model) { targetBox = TR::NO_BOX; animation.setModel(model); - stand = water ? STAND_ONWATER : STAND_GROUND; int16 rIndex = getRoomIndex(); if (water) { @@ -1090,7 +1083,6 @@ struct Rat : Enemy { roomIndex = rIndex; } } else { - int16 rIndex = getRoomIndex(); TR::Room::Sector *sector = level->getSector(rIndex, pos); if (sector) { pos.y = float(sector->floor * 256); @@ -1244,13 +1236,15 @@ struct Crocodile : Enemy { modelLand = level->getModelIndex(TR::Entity::ENEMY_CROCODILE_LAND) - 1; modelWater = level->getModelIndex(TR::Entity::ENEMY_CROCODILE_WATER) - 1; - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; flying = water; stand = water ? STAND_UNDERWATER : STAND_GROUND; } const virtual TR::Model* getModel() { - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; + stand = water ? STAND_UNDERWATER : STAND_GROUND; + int modelIndex = water ? modelWater : modelLand; if (modelIndex == -1) { @@ -1263,7 +1257,6 @@ struct Crocodile : Enemy { if (animation.model != model) { targetBox = TR::NO_BOX; animation.setModel(model); - stand = water ? STAND_UNDERWATER : STAND_GROUND; flying = water; int16 rIndex = getRoomIndex(); @@ -1274,7 +1267,6 @@ struct Crocodile : Enemy { roomIndex = rIndex; } } else { - int16 rIndex = getRoomIndex(); TR::Room::Sector *sector = level->getSector(rIndex, pos); if (sector) { pos.y = float(sector->floor * 256); @@ -1619,6 +1611,9 @@ struct Bat : Enemy { virtual void updatePosition() { turn(state == STATE_FLY || state == STATE_ATTACK, BAT_TURN_SPEED); + if (!target) + target = (Character*)game->getLara(pos); + if (flying) { float wy = waypoint.y - (target->stand != STAND_ONWATER ? 765.0f : 64.0f); lift(wy - pos.y, BAT_LIFT_SPEED); @@ -1918,7 +1913,7 @@ struct Mutant : Enemy { } virtual void setSaveData(const SaveEntity &data) { - Character::setSaveData(data); + Enemy::setSaveData(data); if (flags.invisible) deactivate(true); } @@ -2147,7 +2142,7 @@ struct GiantMutant : Enemy { } virtual void setSaveData(const SaveEntity &data) { - Character::setSaveData(data); + Enemy::setSaveData(data); if (flags.invisible) deactivate(true); } @@ -2234,7 +2229,7 @@ struct GiantMutant : Enemy { } break; case STATE_ATTACK_3 : - if (target->stand != STAND_HANG) { + if ((mask & HIT_MASK_HAND) && (target->stand != STAND_HANG)) { target->hit(GIANT_MUTANT_DAMAGE_FATAL, this, TR::HIT_GIANT_MUTANT); return STATE_FATAL; } @@ -2251,12 +2246,32 @@ struct GiantMutant : Enemy { return state; } + int turn(float delta, float speed) { + float w = speed * Core::deltaTime; + + updateTilt(delta, w, speed * 0.1f); + + if (delta != 0.0f) { + decrease(delta, angle.y, w); + if (speed != 0.0f) { + velocity = velocity.rotateY(-w); + return speed < 0 ? LEFT : RIGHT; + } + } + + angle.z = 0.0f; + return 0; + } + virtual void updatePosition() { float angleY = 0.0f; if (target && target->health > 0.0f && fabsf(targetAngle) > GIANT_MUTANT_MIN_ANGLE) if (state == STATE_TURN_LEFT || state == STATE_TURN_RIGHT || state == STATE_WALK || state == STATE_STOP) angleY = targetAngle; - turn(angleY, GIANT_MUTANT_TURN_SLOW); + + if (angleY != 0.0f) { + turn(targetAngle, GIANT_MUTANT_TURN_SLOW); + } Enemy::updatePosition(); //setOverrides(true, jointChest, jointHead); @@ -2294,7 +2309,7 @@ struct Centaur : Enemy { } virtual void setSaveData(const SaveEntity &data) { - Character::setSaveData(data); + Enemy::setSaveData(data); if (flags.invisible) deactivate(true); } @@ -2545,7 +2560,7 @@ struct Human : Enemy { int jointGun; int animDeath; - Human(IGame *game, int entity, float health) : Enemy(game, entity, health, 100, 375.0f, 1.0f), animDeath(-1) { + Human(IGame *game, int entity, float health) : Enemy(game, entity, health, 100, 0.0f, 1.0f), animDeath(-1) { jointGun = 0; jointChest = 7; jointHead = 8; @@ -2809,15 +2824,20 @@ struct SkaterBoy : Human { game->addEntity(TR::Entity::UZIS, getRoomIndex(), pos, 0); } + virtual void hit(float damage, Controller *enemy = NULL, TR::HitType hitType = TR::HIT_DEFAULT) { + bool flag = health >= 120; + Human::hit(damage, enemy, hitType); + if (flag && health < 120) { + game->playTrack(56, true); + } + }; + virtual int getStateGround() { if (!think(false)) return state; fullChestRotation = state == STATE_STAND_FIRE || state == STATE_MOVE_FIRE; - if (health < 120) - game->playTrack(56, true); - switch (state) { case STATE_STOP : flags.unused = 0; @@ -3361,4 +3381,139 @@ struct Tiger : Enemy { } }; -#endif \ No newline at end of file + +#define WINSTON_DIST 1536.0f +#define WINSTON_TURN_SLOW (DEG2RAD * 60) +#define WINSTON_FREEZE_TIME 60.0f + +struct Winston : Enemy { + + enum { + STATE_NONE , + STATE_STOP , + STATE_WALK , + }; + + Texture *environment; + + Winston(IGame *game, int entity) : Enemy(game, entity, 20, 341, 200.0f, 0.25f), environment(NULL) { + dropHeight = -1024; + jointChest = 11; + jointHead = 25; + nextState = STATE_NONE; + lookAtSpeed = 1.0f; + timer = 0.0f; + } + + virtual ~Winston() { + delete environment; + } + + virtual int getStateGround() { + if (getRoomIndex() == 94) { + int doorIndex = (level->version & TR::VER_TR2) ? 38 : 68; + + Controller *door = (Controller*)game->getLevel()->entities[doorIndex].controller; + if (!door->isActive()) { + if (timer > WINSTON_FREEZE_TIME) { + flags.unused |= 4; + if (!environment) { + bakeEnvironment(environment); + } + } else { + timer += Core::deltaTime; + } + return STATE_STOP; + } else { + if (!(flags.unused & 4)) { + timer = 0.0f; + } + } + } + + if (flags.unused & 4) { + timer -= Core::deltaTime; + if (timer < 0.0f) { + timer = 0.0f; + flags.unused &= ~4; + } + return STATE_STOP; + } + + if (!think(false)) + return state; + + if (nextState == state) + nextState = STATE_NONE; + + if (nextState != STATE_NONE) + return nextState; + + switch (state) { + case STATE_STOP : + if ((targetDist > WINSTON_DIST || !targetInView) && nextState != STATE_WALK) { + nextState = STATE_WALK; + game->playSound(TR::SND_WINSTON_WALK, pos, Sound::PAN); + } + case STATE_WALK : + if (targetDist < WINSTON_DIST) { + if (targetInView) { + nextState = STATE_STOP; + flags.unused &= ~1; + } else if (!(flags.unused & 1)) { + game->playSound(TR::SND_WINSTON_SCARED, pos, Sound::PAN); + game->playSound(TR::SND_WINSTON_TRAY, pos, Sound::PAN); + flags.unused |= 1; + } + } + } + + bool touch = collide(target) != 0; + bool push = (flags.unused & 2) != 0; + + if (!push && touch) { + game->playSound(TR::SND_WINSTON_PUSH, pos, Sound::PAN); + game->playSound(TR::SND_WINSTON_TRAY, pos, Sound::PAN); + flags.unused |= 2; + } + + if (push && !touch) { + flags.unused &= ~2; + } + + if (rand() < 0x100) { + game->playSound(TR::SND_WINSTON_TRAY, pos, Sound::PAN); + } + + return state; + } + + virtual void updatePosition() { + if (flags.unused & 4) { + animation.time = 0.0f; + animation.updateInfo(); + return; + } + + turn(state == STATE_WALK, WINSTON_TURN_SLOW); + angle.z = 0.0f; + + Enemy::updatePosition(); + setOverrides(true, jointChest, jointHead); + lookAt(target); + } + + virtual void render(Frustum *frustum, MeshBuilder *mesh, Shader::Type type, bool caustics) { + if (environment && (flags.unused & 4)) { + game->setRoomParams(getRoomIndex(), Shader::MIRROR, 1.5f, 2.0f, 2.5f, 1.0f, false); + GAPI::Texture *dtex = Core::active.textures[sDiffuse]; + environment->bind(sDiffuse); + Controller::render(frustum, mesh, type, caustics); + if (dtex) dtex->bind(sDiffuse); + } else { + Enemy::render(frustum, mesh, type, caustics); + } + } +}; + +#endif diff --git a/src/extension.h b/src/extension.h new file mode 100644 index 00000000..b7878429 --- /dev/null +++ b/src/extension.h @@ -0,0 +1,521 @@ +#ifndef _H_EXTENSION +#define _H_EXTENSION + +#include "mesh.h" + +#if defined(_DEBUG) && defined(_OS_WIN) && defined(_GAPI_GL) && !defined(_GAPI_GLES) + #define GEOMETRY_EXPORT + + #include "animation.h" + #include "gltf.h" +#endif + +namespace Extension { + + const float MESH_SCALE = 1.0f / 256.0f; + +#ifdef GEOMETRY_EXPORT + void exportTexture(const char *dir, const char *name, Texture *tex) { + char *data32 = new char[tex->width * tex->height * 4]; + + tex->bind(sDiffuse); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data32); + + char path[256]; + sprintf(path, "%s/%s", dir, name); + Texture::SaveBMP(path, data32, tex->width, tex->height); + + delete[] data32; + } + + void exportRooms(IGame *game, const char *dir) { + TR::Level *level = game->getLevel(); + MeshBuilder *mesh = game->getMesh(); + + typedef uint32 MeshIndex; + + struct MeshVertex { + vec3 coord; + vec3 normal; + vec2 texCoord; + ubyte4 color; + }; + + char name[256]; + sprintf(name, "%s/rooms.glb", dir); + + LOG("export rooms: %s\n", name); + + FILE *file = fopen(name, "wb"); + if (!file) { + LOG("dump: can't dump rooms to file \"%s\"!\n", name); + return; + } + + Index *indices = new Index[1024 * 1024]; + Vertex *vertices = new Vertex[1024 * 1024]; + + mat4 flip = mat4( + -1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); + mat4 flipInv = flip.inverseOrtho(); + + struct RoomParams { + int iStart; + int vStart; + int iCount; + int vCount; + } roomParams[1024]; + + int iCount = 0, vCount = 0; + + // get geometry data + for (int roomIndex = 0; roomIndex < level->roomsCount; roomIndex++) { + RoomParams ¶ms = roomParams[roomIndex]; + params.iStart = iCount; + params.vStart = vCount; + + MeshBuilder::Geometry geom; + + for (int transp = 0; transp < 3; transp++) { + int blendMask = mesh->getBlendMask(transp); + + TR::Room &room = level->rooms[roomIndex]; + + // room geometry + mesh->buildRoom(geom, NULL, blendMask, room, level, indices, vertices, iCount, vCount, params.vStart); + + // static meshes + for (int j = 0; j < room.meshesCount; j++) { + TR::Room::Mesh &m = room.meshes[j]; + TR::StaticMesh *s = &level->staticMeshes[m.meshIndex]; + if (!level->meshOffsets[s->mesh]) continue; + TR::Mesh &staticMesh = level->meshes[level->meshOffsets[s->mesh]]; + + int x = m.x - room.info.x; + int y = m.y; + int z = m.z - room.info.z; + int d = m.rotation.value / 0x4000; + mesh->buildMesh(geom, blendMask, staticMesh, level, indices, vertices, iCount, vCount, params.vStart, 0, x, y, z, d, m.color, true, false); + } + } + + params.iCount = iCount - params.iStart; + params.vCount = vCount - params.vStart; + } + + for (int i = 0; i < iCount; i += 3) { // CCW -> CW + swap(indices[i], indices[i + 2]); + } + + // get model geometry + int verticesOffset = 0; + int indicesOffset = verticesOffset + vCount * sizeof(MeshVertex); + int bufferSize = indicesOffset + iCount * sizeof(MeshIndex); + + char *bufferData = new char[bufferSize]; + + MeshVertex *gVertices = (MeshVertex*)(bufferData + verticesOffset); + for (int i = 0; i < vCount; i++) { + Vertex &src = vertices[i]; + MeshVertex &dst = gVertices[i]; + + dst.coord = src.coord; + + dst.normal = src.normal; + dst.texCoord = src.texCoord; + dst.normal = dst.normal.normal(); + + dst.coord = flip * (dst.coord * MESH_SCALE); + dst.normal = flip * dst.normal; + + dst.texCoord *= (1.0f / 32767.0f); + dst.color = src.light; + } + + for (int i = 0; i < iCount; i++) { + MeshIndex &dst = ((MeshIndex*)(bufferData + indicesOffset))[i]; + dst = indices[i]; + } + + GLTF *gltf = new GLTF(); + + JSON *nodes; + gltf->addScene("Scene", &nodes); + + int accessorIndex = 0; + int nodeIndex = 0; + + for (int roomIndex = 0; roomIndex < level->roomsCount; roomIndex++) { + TR::Room &room = level->rooms[roomIndex]; + + RoomParams ¶ms = roomParams[roomIndex]; + if (params.iCount == 0) { + continue; + } + + sprintf(name, "%d_mesh", roomIndex); + gltf->addMesh(name, 0, accessorIndex + 0, accessorIndex + 1, accessorIndex + 2, accessorIndex + 3, accessorIndex + 4, -1, -1); + + sprintf(name, "%d", roomIndex); + gltf->addNode(name, nodeIndex, -1, vec3(float(-room.info.x), 0, float(room.info.z)) * MESH_SCALE, quat(0, 0, 0, 1)); + nodes->add(NULL, nodeIndex); // mesh + nodeIndex++; + + vec4 vMin(+INF), vMax(-INF); + + for (int i = params.vStart; i < params.vStart + params.vCount; i++) { + MeshVertex &v = gVertices[i]; + + vMin.x = min(vMin.x, v.coord.x); + vMin.y = min(vMin.y, v.coord.y); + vMin.z = min(vMin.z, v.coord.z); + + vMax.x = max(vMax.x, v.coord.x); + vMax.y = max(vMax.y, v.coord.y); + vMax.z = max(vMax.z, v.coord.z); + } + + gltf->addAccessor(0, sizeof(MeshIndex), params.iStart * sizeof(MeshIndex), params.iCount, GLTF::SCALAR, GL_UNSIGNED_INT); // 0 + gltf->addAccessor(1, sizeof(MeshVertex), params.vStart * sizeof(MeshVertex) + (int)OFFSETOF(MeshVertex, coord), params.vCount, GLTF::VEC3, GL_FLOAT, false, vMin, vMax); // 1 + gltf->addAccessor(1, sizeof(MeshVertex), params.vStart * sizeof(MeshVertex) + (int)OFFSETOF(MeshVertex, normal), params.vCount, GLTF::VEC3, GL_FLOAT); // 2 + gltf->addAccessor(1, sizeof(MeshVertex), params.vStart * sizeof(MeshVertex) + (int)OFFSETOF(MeshVertex, texCoord), params.vCount, GLTF::VEC2, GL_FLOAT); // 3 + gltf->addAccessor(1, sizeof(MeshVertex), params.vStart * sizeof(MeshVertex) + (int)OFFSETOF(MeshVertex, color), params.vCount, GLTF::VEC4, GL_UNSIGNED_BYTE, true); // 4 + + accessorIndex += 5; + } + + gltf->addSampler(GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT); + gltf->addImage("rooms.bmp"); + gltf->addTexture("texture", 0, 0); + gltf->addMaterial("material", 0, 0, 1.0f, 0.0f); + + delete[] vertices; + delete[] indices; + + gltf->addBufferView(0, 0, indicesOffset, sizeof(MeshIndex) * iCount); // 0 + gltf->addBufferView(0, sizeof(MeshVertex), verticesOffset, sizeof(MeshVertex) * vCount); // 1 + + gltf->addBuffer(bufferData, bufferSize); // 0 + + delete[] bufferData; + + char *buffer = new char[gltf->getBufferSize()]; + int size = gltf->save(buffer); + delete gltf; + + fwrite(buffer, 1, size, file); + + delete[] buffer; + + fclose(file); + } + + void exportModel(IGame *game, const char *dir, TR::Model &model) { + TR::Level *level = game->getLevel(); + MeshBuilder *mesh = game->getMesh(); + + typedef uint32 MeshIndex; + + struct ModelVertex { + vec3 coord; + vec3 normal; + vec2 texCoord; + ubyte4 joints; + ubyte4 weights; + }; + + char name[256]; + sprintf(name, "%s/model_%d.glb", dir, int(model.type)); + + LOG("export model: %s\n", name); + + FILE *file = fopen(name, "wb"); + if (!file) { + LOG("dump: can't dump model to file \"%s\"!\n", name); + return; + } + + Index *indices = new Index[64 * 1024]; + Vertex *vertices = new Vertex[64 * 1024]; + + int iCount = 0, vCount = 0; + + int animRate = 1, animFrames = 0; + + Animation *anim = NULL; + if (model.animation != 0xFFFF) { + anim = new Animation(level, &model, true); + anim->setAnim(0); + animRate = max((int)(anim->anims + anim->index)->frameRate, 1); + animFrames = anim->framesCount / animRate; + ASSERT(animFrames > 0); + } + + // get model geometry + MeshBuilder::Geometry geom[3]; + for (int transp = 0; transp < 3; transp++) { + int blendMask = mesh->getBlendMask(transp); + + for (int j = 0; j < model.mCount; j++) { + bool forceOpaque = false; + TR::Entity::fixOpaque(model.type, forceOpaque); + + int index = level->meshOffsets[model.mStart + j]; + if (index || model.mStart + j <= 0) { + TR::Mesh &m = level->meshes[index]; + mesh->buildMesh(geom[transp], blendMask, m, level, indices, vertices, iCount, vCount, 0, j, 0, 0, 0, 0, COLOR_WHITE, false, forceOpaque); + } + } + } + + for (int i = 0; i < iCount; i += 3) { // CCW -> CW + swap(indices[i], indices[i + 2]); + } + + int timelineOffset = 0; + int translationOffset = timelineOffset + animFrames * sizeof(float); + int rotationOffset = translationOffset + animFrames * sizeof(vec3); + int verticesOffset = rotationOffset + model.mCount * animFrames * sizeof(quat); + int indicesOffset = verticesOffset + vCount * sizeof(ModelVertex); + int bufferSize = indicesOffset + iCount * sizeof(MeshIndex); + + char *bufferData = new char[bufferSize]; + + vec4 vMin(+INF), vMax(-INF); + + mat4 flip = mat4( + -1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); + mat4 flipInv = flip.inverseOrtho(); + + ModelVertex *gVertices = (ModelVertex*)(bufferData + verticesOffset); + for (int i = 0; i < vCount; i++) { + Vertex &src = vertices[i]; + ModelVertex &dst = gVertices[i]; + + dst.coord = src.coord; + dst.normal = src.normal; + dst.texCoord = src.texCoord; + dst.normal = dst.normal.normal(); + + dst.coord = flip * (dst.coord * MESH_SCALE); + dst.normal = flip * dst.normal; + + dst.texCoord *= (1.0f / 32767.0f); + dst.joints = ubyte4(uint8(src.coord.w / 2), 0, 0, 0); + dst.weights = ubyte4(255, 0, 0, 0); + + vMin.x = min(vMin.x, dst.coord.x); + vMin.y = min(vMin.y, dst.coord.y); + vMin.z = min(vMin.z, dst.coord.z); + + vMax.x = max(vMax.x, dst.coord.x); + vMax.y = max(vMax.y, dst.coord.y); + vMax.z = max(vMax.z, dst.coord.z); + } + + for (int i = 0; i < iCount; i++) { + MeshIndex &dst = ((MeshIndex*)(bufferData + indicesOffset))[i]; + dst = indices[i]; + } + + GLTF *gltf = new GLTF(); + + gltf->addSampler(GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT); + gltf->addImage("models.bmp"); + gltf->addTexture("texture", 0, 0); + gltf->addMaterial("material", 0, 0, 1.0f, 0.0f); + + delete[] vertices; + delete[] indices; + + gltf->addAccessor(0, sizeof(MeshIndex), 0, iCount, GLTF::SCALAR, GL_UNSIGNED_INT); // 0 + gltf->addAccessor(1, sizeof(ModelVertex), (int)OFFSETOF(ModelVertex, coord), vCount, GLTF::VEC3, GL_FLOAT, false, vMin, vMax); // 1 + gltf->addAccessor(1, sizeof(ModelVertex), (int)OFFSETOF(ModelVertex, normal), vCount, GLTF::VEC3, GL_FLOAT); // 2 + gltf->addAccessor(1, sizeof(ModelVertex), (int)OFFSETOF(ModelVertex, texCoord), vCount, GLTF::VEC2, GL_FLOAT); // 3 + gltf->addAccessor(1, sizeof(ModelVertex), (int)OFFSETOF(ModelVertex, joints), vCount, GLTF::VEC4, GL_UNSIGNED_BYTE); // 4 + gltf->addAccessor(1, sizeof(ModelVertex), (int)OFFSETOF(ModelVertex, weights), vCount, GLTF::VEC4, GL_UNSIGNED_BYTE, true); // 5 + + gltf->addBufferView(0, 0, indicesOffset, sizeof(MeshIndex) * iCount); // 0 + gltf->addBufferView(0, sizeof(ModelVertex), verticesOffset, sizeof(ModelVertex) * vCount); // 1 + + sprintf(name, "%d_mesh", int(model.type)); + gltf->addMesh(name, 0, 0, 1, 2, 3, -1, 4, 5); + + JSON *nodes; + gltf->addScene("Scene", &nodes); + + sprintf(name, "%d", int(model.type)); + gltf->addNode(name, 0, 0, vec3(0, 0, 0), quat(0, 0, 0, 1)); + nodes->add(NULL, 0); // mesh + nodes->add(NULL, 1); // skeleton + + int joints[64]; + bool links[32][32]; + memset(links, 0, sizeof(links)); + + if (anim) { + JSON *samplers; + JSON *channels; + gltf->addAnimation("0_anim", &samplers, &channels); + + { // timeline (input) + float *timeline = (float*)(bufferData + timelineOffset); + for (int i = 0; i < animFrames; i++) { + timeline[i] = i * animRate / 30.0f; + } + gltf->addBufferView(0, 0, timelineOffset, animFrames * sizeof(float)); // 2 + gltf->addAccessor(2, 0, 0, animFrames, GLTF::SCALAR, GL_FLOAT, false, vec4(timeline[0], 0, 0, 0), vec4(timeline[animFrames - 1], 0, 0, 1)); // 6 + } + + { // root translation (output) + vec3 *translation = (vec3*)(bufferData + translationOffset); + gltf->addBufferView(0, 0, translationOffset, animFrames * sizeof(vec3)); // 3 + gltf->addAccessor(3, 0, 0, animFrames, GLTF::VEC3, GL_FLOAT); // 7+ + + JSON *sampler = samplers->add(JSON::OBJECT); // 0 + sampler->add("input", 6); // timeline + sampler->add("output", 7); // translations for this node + + JSON *channel = channels->add(JSON::OBJECT); + channel->add("sampler", 0); + JSON *target = channel->add(JSON::OBJECT, "target"); + target->add("node", 1); // 0 - mesh, 1+ - skeleton (1 = root) + target->add("path", "translation"); + + for (int j = 0; j < animFrames; j++) { + TR::AnimFrame *frame = anim->getFrame(anim->anims + anim->index, j); + + translation[j] = flip * (vec3((float)frame->pos.x, (float)frame->pos.y, (float)frame->pos.z) * MESH_SCALE); + } + } + + { // rotations (output) + gltf->addBufferView(0, 0, rotationOffset, model.mCount * animFrames * sizeof(quat)); // 4 + + quat *rotation = (quat*)(bufferData + rotationOffset); + quat *ptr = rotation; + for (int i = 0; i < model.mCount; i++) { + for (int j = 0; j < animFrames; j++) { + TR::AnimFrame *frame = anim->getFrame(anim->anims + anim->index, j); + + vec3 angles = frame->getAngle(level->version, i); + + mat4 matrix; + matrix.identity(); + matrix.rotateYXZ(angles); + matrix = flip * matrix * flipInv; + + *ptr = matrix.getRot(); + ptr++; + } + gltf->addAccessor(4, 0, i * animFrames * sizeof(quat), animFrames, GLTF::VEC4, GL_FLOAT); // 8+ + + JSON *sampler = samplers->add(JSON::OBJECT); // 1+ + sampler->add("input", 6); // timeline + sampler->add("output", 8 + i); // rotations for this node + + JSON *channel = channels->add(JSON::OBJECT); + channel->add("sampler", 1 + i); // 0 - translation, 1+ - rotation samplers + JSON *target = channel->add(JSON::OBJECT, "target"); + target->add("node", 1 + i); // 0 - mesh, 1+ - skeleton + target->add("path", "rotation"); + } + } + } + + gltf->addBuffer(bufferData, bufferSize); // 0 + + delete[] bufferData; + + { + int nIndex = 0; + int sIndex = 0; + int stack[16]; + + TR::Node *node = (TR::Node*)&level->nodesData[model.node]; + + for (int i = 0; i < model.mCount; i++) { + if (i > 0) { + links[nIndex][i] = true; + } + + nIndex = i; + if (node[i].flags & 0x01) nIndex = stack[--sIndex]; + if (node[i].flags & 0x02) stack[sIndex++] = nIndex; + } + } + + delete anim; + + vec3 jointPos = vec3(0); + + for (int i = 0; i < model.mCount; i++) { + sprintf(name, "joint_%d", i + 1); + + JSON* node = gltf->addNode(name, -1, -1, jointPos * MESH_SCALE, quat(0, 0, 0, 1)); + JSON* children = new JSON(JSON::ARRAY, "children"); + + for (int j = 0; j < model.mCount; j++) { + if (links[i][j]) { + children->add(NULL, j + 1); + } + } + + if (children->nodes) { + node->add(children); + } else { + delete children; + } + + joints[i] = i + 1; + + TR::Node &t = *((TR::Node*)&level->nodesData[model.node] + i); + jointPos = flip * vec3((float)t.x, (float)t.y, (float)t.z); + } + + gltf->addSkin("skin", -1, 1, joints, model.mCount); + + char *buffer = new char[gltf->getBufferSize()]; + int size = gltf->save(buffer); + delete gltf; + + fwrite(buffer, 1, size, file); + + delete[] buffer; + + fclose(file); + } + + void exportGeometry(IGame *game, Texture *atlasRooms, Texture *atlasObjects, Texture *atlasSprites) { + + char dir[256]; + sprintf(dir, "dump/%s", TR::LEVEL_INFO[game->getLevel()->id].name); + + CreateDirectory("dump", NULL); + CreateDirectory(dir, NULL); + + exportTexture(dir, "rooms", atlasRooms); + exportTexture(dir, "models", atlasObjects); + + TR::Level *level = game->getLevel(); + MeshBuilder *mesh = game->getMesh(); + + exportRooms(game, dir); + + for (int i = 0; i < level->modelsCount; i++) { + exportModel(game, dir, level->models[i]); + } + } +#endif + +} + +#endif diff --git a/src/fixed/camera.h b/src/fixed/camera.h new file mode 100644 index 00000000..fc4b271a --- /dev/null +++ b/src/fixed/camera.h @@ -0,0 +1,527 @@ +#ifndef H_CAMERA +#define H_CAMERA + +#include "common.h" + +#define CAM_SPEED (1 << 3) +#define CAM_ROT_SPEED (1 << 9) +#define CAM_DIST_FOLLOW 1536 +#define CAM_DIST_LOOK 768 +#define CAM_DIST_COMBAT 2048 +#define CAM_RADIUS 255 +#define CAM_ANGLE_FOLLOW ANGLE(-10) +#define CAM_ANGLE_COMBAT ANGLE(-10) +#define CAM_ANGLE_MAX ANGLE(85) + +void Camera::initCinematic() +{ + switch (gLevelID) + { + case LVL_TR1_CUT_1: + gCinematicCamera.view.pos.x = 36668; + gCinematicCamera.view.pos.z = 63180; + gCinematicCamera.targetAngle.y = -ANGLE(128); + break; + case LVL_TR1_CUT_2: + gCinematicCamera.view.pos.x = 51962; + gCinematicCamera.view.pos.z = 53760; + gCinematicCamera.targetAngle.y = ANGLE_90 - 4; + break; + case LVL_TR1_CUT_3: + gCinematicCamera.targetAngle.y = ANGLE_90; + //level.flip(); + break; + case LVL_TR1_CUT_4: + gCinematicCamera.targetAngle.y = ANGLE_90; + break; + default: + ASSERT(false); + break; + } +} + +void Camera::updateCinematic() +{ + const CameraFrame &frame = level.cameraFrames[timer++]; + + int32 px = frame.pos.x; + int32 py = frame.pos.y; + int32 pz = frame.pos.z; + + int32 dx = frame.target.x - px; + int32 dy = frame.target.y - py; + int32 dz = frame.target.z - pz; + + anglesFromVector(dx, dy, dz, angle.x, angle.y); + + int32 s, c; + sincos(targetAngle.y, s, c); + + X_ROTXY(pz, px, s, c); + + px += view.pos.x; + py += view.pos.y; + pz += view.pos.z; + + matrixSetView(_vec3i(px, py, pz), angle.x, angle.y + targetAngle.y); + + Room* nextRoom = view.room->getRoom(px, py, pz); + if (nextRoom) { + view.room = nextRoom; + } + + if (timer >= level.cameraFramesCount) { + timer = level.cameraFramesCount - 1; + nextLevel(LevelID(gLevelID + 1)); + } +} + +void Camera::init(ItemObj* lara) +{ + ASSERT(lara->extraL); + + target.pos = lara->pos; + target.pos.y -= 1024; + target.room = lara->room; + + view = target; + view.pos.z -= 100; + + targetDist = CAM_DIST_FOLLOW; + targetAngle = _vec3s(0, 0, 0); + angle = _vec3s(0, 0, 0); + + laraItem = lara; + lastItem = NULL; + lookAtItem = NULL; + + speed = 1; + timer = 0; + index = -1; + lastIndex = -1; + + mode = CAMERA_MODE_FOLLOW; + + lastFixed = false; + center = false; +} + +Location Camera::getLocationForAngle(int32 angle, int32 distH, int32 distV) +{ + int32 s, c; + sincos(angle, s, c); + + Location res; + res.pos.x = target.pos.x - (distH * s >> FIXED_SHIFT); + res.pos.y = target.pos.y + (distV); + res.pos.z = target.pos.z - (distH * c >> FIXED_SHIFT); + res.room = target.room; + return res; +} + +bool checkWall(Room* room, int32 x, int32 y, int32 z) +{ + Room* nextRoom = room->getRoom(x, y, z); + + const Sector* sector = nextRoom->getSector(x, z); + int32 floor = sector->getFloor(x, y, z); + int32 ceiling = sector->getCeiling(x, y, z); + return (floor == WALL || ceiling == WALL || ceiling >= floor || y > floor || y < ceiling); +} + +int32 checkHeight(Room* room, int32 x, int32 y, int32 z) +{ + Room* nextRoom = room->getRoom(x, y, z); + const Sector* sector = nextRoom->getSector(x, z); + int32 floor = sector->getFloor(x, y, z); + int32 ceiling = sector->getCeiling(x, y, z); + + if (floor != WALL && ceiling != WALL && ceiling < floor) + { + if (y - CAM_RADIUS < ceiling && y + CAM_RADIUS > floor) + return (floor + ceiling) >> 1; + + if (y + CAM_RADIUS > floor) + return floor - CAM_RADIUS; + + if (y - CAM_RADIUS < ceiling) + return ceiling + CAM_RADIUS; + } + + return y; +} + +void Camera::clip(Location &loc) +{ + loc.pos.y = checkHeight(loc.room, loc.pos.x, loc.pos.y, loc.pos.z); + + if (checkWall(loc.room, loc.pos.x - CAM_RADIUS, loc.pos.y, loc.pos.z)) { + loc.pos.x = (loc.pos.x & (~1023)) + CAM_RADIUS; + } + + if (checkWall(loc.room, loc.pos.x + CAM_RADIUS, loc.pos.y, loc.pos.z)) { + loc.pos.x = (loc.pos.x | 1023) - CAM_RADIUS; + } + + if (checkWall(loc.room, loc.pos.x, loc.pos.y, loc.pos.z - CAM_RADIUS)) { + loc.pos.z = (loc.pos.z & (~1023)) + CAM_RADIUS; + } + + if (checkWall(loc.room, loc.pos.x, loc.pos.y, loc.pos.z + CAM_RADIUS)) { + loc.pos.z = (loc.pos.z | 1023) - CAM_RADIUS; + } + + loc.room = loc.room->getRoom(loc.pos.x, loc.pos.y, loc.pos.z); +} + +Location Camera::getBestLocation(bool clip) +{ + int32 s, c; + sincos(targetAngle.x, s, c); + + int32 distH = targetDist * c >> FIXED_SHIFT; + int32 distV = targetDist * s >> FIXED_SHIFT; + + Location best = getLocationForAngle(targetAngle.y, distH, distV); + + if (trace(target, best, true)) + return best; + + if (clip && best.pos != target.pos) + return best; + + int32 dist = fastLength(target.pos.x - best.pos.x, target.pos.z - best.pos.z); + + if (dist > 768) + return best; + + int32 minDist = INT_MAX; + + for (int32 i = 0; i < 4; i++) + { + Location tmpDest = getLocationForAngle(i * ANGLE_90, distH, distV); + Location tmpView = view; + + if (!trace(target, tmpDest, true) || !trace(tmpDest, tmpView, false)) + continue; + + dist = fastLength(view.pos.x - tmpDest.pos.x, view.pos.z - tmpDest.pos.z); + + if (dist < minDist) + { + minDist = dist; + best = tmpDest; + } + } + + return best; +} + +void Camera::move(Location &to, int32 speed) +{ + clip(to); + + vec3i d = to.pos - view.pos; + + if (speed > 1) + { + if (speed == 8) + { + d.x >>= 3; + d.y >>= 3; + d.z >>= 3; + } + else + { + d.x /= speed; + d.y /= speed; + d.z /= speed; + } + } + + view.pos += d; + view.room = to.room->getRoom(view.pos.x, view.pos.y, view.pos.z); + + const Sector* sector = view.room->getSector(view.pos.x, view.pos.z); + + int32 floor = sector->getFloor(view.pos.x, view.pos.y, view.pos.z) - 256; + if (view.pos.y >= floor && to.pos.y >= floor) + { + trace(target, view, true); + view.room = view.room->getRoom(view.pos.x, view.pos.y, view.pos.z); + } +} + +void Camera::updateFree() +{ + matrixSetView(view.pos, angle.x, angle.y); + + Matrix &m = matrixGet(); + + if (keys & IK_UP) angle.x -= CAM_ROT_SPEED; + if (keys & IK_DOWN) angle.x += CAM_ROT_SPEED; + if (keys & IK_LEFT) angle.y -= CAM_ROT_SPEED; + if (keys & IK_RIGHT) angle.y += CAM_ROT_SPEED; + + angle.x = X_CLAMP(angle.x, -CAM_ANGLE_MAX, CAM_ANGLE_MAX); + + if (keys & IK_A) + { + view.pos.x += m.e20 * CAM_SPEED >> 10; + view.pos.y += m.e21 * CAM_SPEED >> 10; + view.pos.z += m.e22 * CAM_SPEED >> 10; + } + + if (keys & IK_B) + { + view.pos.x -= m.e20 * CAM_SPEED >> 10; + view.pos.y -= m.e21 * CAM_SPEED >> 10; + view.pos.z -= m.e22 * CAM_SPEED >> 10; + } + + if (keys & IK_R) + { + view.pos.x += m.e00 * CAM_SPEED >> 10; + view.pos.y += m.e01 * CAM_SPEED >> 10; + view.pos.z += m.e02 * CAM_SPEED >> 10; + } + + if (keys & IK_L) + { + view.pos.x -= m.e00 * CAM_SPEED >> 10; + view.pos.y -= m.e01 * CAM_SPEED >> 10; + view.pos.z -= m.e02 * CAM_SPEED >> 10; + } + + view.room = view.room->getRoom(view.pos.x, view.pos.y, view.pos.z); +} + +void Camera::updateFollow(ItemObj* item) +{ + if (targetAngle.x == 0) { + targetAngle.x = CAM_ANGLE_FOLLOW; + } + + targetAngle.x = X_CLAMP(targetAngle.x + item->angle.x, -CAM_ANGLE_MAX, CAM_ANGLE_MAX); + targetAngle.y += item->angle.y; + + Location best = getBestLocation(false); + + move(best, lastFixed ? speed : 8); +} + +void Camera::updateCombat(ItemObj* item) +{ + ASSERT(item->type == ITEM_LARA); + + targetAngle.x = item->angle.x + CAM_ANGLE_COMBAT; + targetAngle.y = item->angle.y; + + if (item->extraL->armR.target || item->extraL->armL.target) + { + int32 aX = item->extraL->armR.angleAim.x + item->extraL->armL.angleAim.x; + int32 aY = item->extraL->armR.angleAim.y + item->extraL->armL.angleAim.y; + + if (item->extraL->armR.target && item->extraL->armL.target) { + targetAngle.x += aX >> 1; + targetAngle.y += aY >> 1; + } else { + targetAngle.x += aX; + targetAngle.y += aY; + } + } else { + targetAngle.x += item->extraL->head.angle.x + item->extraL->torso.angle.x; + targetAngle.y += item->extraL->head.angle.y + item->extraL->torso.angle.y; + } + + targetDist = CAM_DIST_COMBAT; + + Location best = getBestLocation(true); + + move(best, speed); +} + +void Camera::updateLook(ItemObj* item) +{ + ASSERT(item->type == ITEM_LARA); + + targetAngle.x = item->extraL->head.angle.x + item->extraL->torso.angle.x + item->angle.x; + targetAngle.y = item->extraL->head.angle.y + item->extraL->torso.angle.y + item->angle.y; + targetDist = lookAtItem ? CAM_DIST_FOLLOW : CAM_DIST_LOOK; + + Location best = getBestLocation(true); + + move(best, speed); +} + +void Camera::updateFixed() +{ + const FixedCamera* cam = level.cameras + index; + + Location best; + best.pos = cam->pos; + best.room = rooms + cam->roomIndex; + + lastFixed = true; + move(best, 1); + + if (timer != 0) + { + timer--; + if (timer == 0) { + timer = -1; + } + } +} + +void Camera::lookAt(int32 offset) +{ + int32 dx = lookAtItem->pos.x - laraItem->pos.x; + int32 dz = lookAtItem->pos.z - laraItem->pos.z; + + int16 ay = int16(phd_atan(dz, dx) - laraItem->angle.y) >> 1; + + if (abs(ay) >= LARA_LOOK_ANGLE_Y) + { + lookAtItem = NULL; + return; + } + + const AABBs& box = lookAtItem->getBoundingBox(true); + + offset -= lookAtItem->pos.y + ((box.minY + box.maxY) >> 1); + + int16 ax = int16(phd_atan(phd_sqrt(X_SQR(dx) + X_SQR(dz)), offset)) >> 1; + + if (ax < LARA_LOOK_ANGLE_MIN || ax > LARA_LOOK_ANGLE_MAX) + { + lookAtItem = NULL; + return; + } + + laraItem->extraL->head.angle.x = angleLerp(laraItem->extraL->head.angle.x, ax, LARA_LOOK_TURN_SPEED); + laraItem->extraL->head.angle.y = angleLerp(laraItem->extraL->head.angle.y, ay, LARA_LOOK_TURN_SPEED); + + laraItem->extraL->torso.angle = laraItem->extraL->head.angle; + + lookAtItem->flags |= ITEM_FLAG_ANIMATED; // use as once flag + mode = CAMERA_MODE_LOOK; +} + +void Camera::update() +{ + if (mode == CAMERA_MODE_FREE) + { + updateFree(); + matrixSetView(view.pos, angle.x, angle.y); + return; + } + + bool isFixed = false; + ItemObj* item = laraItem; + + if (lookAtItem && (mode == CAMERA_MODE_FIXED || mode == CAMERA_MODE_OBJECT)) + { + isFixed = true; + item = lookAtItem; + } + + ASSERT(item); + + target.room = item->room; + target.pos.x = item->pos.x; + target.pos.z = item->pos.z; + + const AABBs &box = item->getBoundingBox(true); + + int32 y = item->pos.y; + if (isFixed) { + y += (box.minY + box.maxY) >> 1; + } else { + y += box.maxY + ((box.minY - box.maxY) * 3 >> 2); + } + + if (!isFixed && lookAtItem) { + lookAt(y); + } + + if (mode == CAMERA_MODE_LOOK || mode == CAMERA_MODE_COMBAT) + { + y -= 256; + + if (lastFixed) { + target.pos.y = 0; + speed = 1; + } else { + target.pos.y += (y - target.pos.y) >> 2; + speed = (mode == CAMERA_MODE_LOOK) ? 4 : 8; + } + + } else { + + if (center) + { + int32 dx = (box.minX + box.maxX) >> 1; + int32 dz = (box.minZ + box.maxZ) >> 1; + int32 s, c; + sincos(item->angle.y, s, c); + X_ROTXY(dz, dx, s, c); + + target.pos.x += dx; + target.pos.z += dz; + } + + lastFixed = (int32(lastFixed) ^ int32(isFixed)) != 0; // armcpp 3DO compiler (lastFixed ^= isFixed) + + if (lastFixed) { + target.pos.y = y; + speed = 1; + } else { + target.pos.y += (y - target.pos.y) >> 2; + } + } + + switch (mode) + { + case CAMERA_MODE_FOLLOW : updateFollow(item); break; + case CAMERA_MODE_COMBAT : updateCombat(item); break; + case CAMERA_MODE_LOOK : updateLook(item); break; + default : updateFixed(); + } + + lastFixed = isFixed; + lastIndex = index; + + if (mode != CAMERA_MODE_OBJECT || timer == -1) + { + mode = CAMERA_MODE_FOLLOW; + index = -1; + lastItem = lookAtItem; + lookAtItem = NULL; + targetAngle.x = 0; + targetAngle.y = 0; + targetDist = CAM_DIST_FOLLOW; + center = false; + } + + vec3i dir = target.pos - view.pos; + anglesFromVector(dir.x, dir.y, dir.z, angle.x, angle.y); + + matrixSetView(view.pos, angle.x, angle.y); +} + +void Camera::toCombat() +{ + if (mode == CAMERA_MODE_FREE) + return; + + if (mode == CAMERA_MODE_CUTSCENE) + return; + + if (mode == CAMERA_MODE_LOOK) + return; + + mode = CAMERA_MODE_COMBAT; +} + +#endif diff --git a/src/fixed/common.cpp b/src/fixed/common.cpp new file mode 100644 index 00000000..e8f5106c --- /dev/null +++ b/src/fixed/common.cpp @@ -0,0 +1,1598 @@ +#include "common.h" +#include "lang/en.h" + +EWRAM_DATA uint32 keys; +EWRAM_DATA RectMinMax viewport; +vec3i gCameraViewPos; +Matrix gMatrixStack[MAX_MATRICES]; +Matrix* gMatrixPtr = gMatrixStack; + +EWRAM_DATA Sphere gSpheres[2][MAX_SPHERES]; // EWRAM 1k + +const FloorData* gLastFloorData; +FloorData gLastFloorSlant; +EWRAM_DATA TargetInfo tinfo; + +EWRAM_DATA Settings gSettings; +EWRAM_DATA SaveGame gSaveGame; +EWRAM_DATA uint8 gSaveData[SAVEGAME_SIZE - sizeof(SaveGame)]; + +EWRAM_DATA int32 gCurTrack; +EWRAM_DATA int32 gAnimTexFrame; + +int32 gLightAmbient; +int32 gRandTable[MAX_RAND_TABLE]; +int32 gCaustics[MAX_CAUSTICS]; +int32 gCausticsFrame; + +EWRAM_DATA const char* const* STR = STR_EN; + +EWRAM_DATA ExtraInfoLara playersExtra[MAX_PLAYERS]; + +#if defined(__GBA__) + #include "TRACKS_AD4.h" + #include "TITLE_SCR.h" + #include "TITLE_PKD.h" + #include "GYM_PKD.h" + #include "LEVEL1_PKD.h" + #include "LEVEL2_PKD.h" + + #define LEVEL_INFO(data, title, track, secrets) { data##_PKD, title, track, secrets } +#else + #define LEVEL_INFO(data, title, track, secrets) { #data, title, track, secrets } +#endif + +EWRAM_DATA LevelID gLevelID = LVL_TR1_TITLE; + +const LevelInfo gLevelInfo[LVL_MAX] = { +// TR1 + LEVEL_INFO( TITLE , STR_EMPTY , TRACK_TR1_TITLE , 0 ), + LEVEL_INFO( GYM , STR_TR1_GYM , TRACK_NONE , 0 ), + LEVEL_INFO( LEVEL1 , STR_TR1_LEVEL1 , TRACK_TR1_CAVES , 3 ), + LEVEL_INFO( LEVEL2 , STR_TR1_LEVEL2 , TRACK_TR1_CAVES , 3 ), + //LEVEL_INFO( LEVEL3A , STR_TR1_LEVEL3A , TRACK_TR1_CAVES , 5 ), + //LEVEL_INFO( LEVEL3B , STR_TR1_LEVEL3B , TRACK_TR1_CAVES , 3 ), + //LEVEL_INFO( CUT1 , STR_EMPTY , TRACK_TR1_CUT_1 , 0 ), + //LEVEL_INFO( LEVEL4 , STR_TR1_LEVEL4 , TRACK_TR1_WIND , 4 ), + //LEVEL_INFO( LEVEL5 , STR_TR1_LEVEL5 , TRACK_TR1_WIND , 3 ), + //LEVEL_INFO( LEVEL6 , STR_TR1_LEVEL6 , TRACK_TR1_WIND , 3 ), + //LEVEL_INFO( LEVEL7A , STR_TR1_LEVEL7A , TRACK_TR1_CISTERN , 3 ), + //LEVEL_INFO( LEVEL7B , STR_TR1_LEVEL7B , TRACK_TR1_CISTERN , 2 ), + //LEVEL_INFO( CUT2 , STR_EMPTY , TRACK_TR1_CUT_2 , 0 ), + //LEVEL_INFO( LEVEL8A , STR_TR1_LEVEL8A , TRACK_TR1_WIND , 3 ), + //LEVEL_INFO( LEVEL8B , STR_TR1_LEVEL8B , TRACK_TR1_WIND , 3 ), + //LEVEL_INFO( LEVEL8C , STR_TR1_LEVEL8C , TRACK_TR1_WIND , 1 ), + //LEVEL_INFO( LEVEL10A , STR_TR1_LEVEL10A , TRACK_TR1_CISTERN , 3 ), + //LEVEL_INFO( CUT3 , STR_EMPTY , TRACK_TR1_CUT_3 , 0 ), + //LEVEL_INFO( LEVEL10B , STR_TR1_LEVEL10B , TRACK_TR1_PYRAMID , 3 ), + //LEVEL_INFO( CUT4 , STR_EMPTY , TRACK_TR1_CUT_4 , 0 ), + //LEVEL_INFO( LEVEL10C , STR_TR1_LEVEL10C , TRACK_TR1_PYRAMID , 3 ), + //LEVEL_INFO( EGYPT , STR_TR1_EGYPT , TRACK_TR1_WIND , 3 ), + //LEVEL_INFO( CAT , STR_TR1_CAT , TRACK_TR1_WIND , 4 ), + //LEVEL_INFO( END , STR_TR1_END , TRACK_TR1_WIND , 2 ) +}; + +#ifdef PROFILING + uint32 gCounters[CNT_MAX]; +#endif + +int32 gRandSeedLogic; +int32 gRandSeedDraw; + +#define X_RAND(seed) (((seed = 0x3039 + seed * 0x41C64E6D) >> 10) & 0x7FFF); + +int32 rand_logic() +{ + return X_RAND(gRandSeedLogic); +} + +int32 rand_draw() +{ + return X_RAND(gRandSeedDraw); +} + +#ifdef USE_DIV_TABLE +EWRAM_DATA ALIGN16 divTableInt divTable[DIV_TABLE_SIZE] = { // must be at EWRAM start + 0x0000, 0x7FFF, 0x7FFF, 0x5555, 0x4000, 0x3333, 0x2AAA, 0x2492, + 0x2000, 0x1C71, 0x1999, 0x1745, 0x1555, 0x13B1, 0x1249, 0x1111, + 0x1000, 0x0F0F, 0x0E38, 0x0D79, 0x0CCC, 0x0C30, 0x0BA2, 0x0B21, + 0x0AAA, 0x0A3D, 0x09D8, 0x097B, 0x0924, 0x08D3, 0x0888, 0x0842, + 0x0800, 0x07C1, 0x0787, 0x0750, 0x071C, 0x06EB, 0x06BC, 0x0690, + 0x0666, 0x063E, 0x0618, 0x05F4, 0x05D1, 0x05B0, 0x0590, 0x0572, + 0x0555, 0x0539, 0x051E, 0x0505, 0x04EC, 0x04D4, 0x04BD, 0x04A7, + 0x0492, 0x047D, 0x0469, 0x0456, 0x0444, 0x0432, 0x0421, 0x0410, + 0x0400, 0x03F0, 0x03E0, 0x03D2, 0x03C3, 0x03B5, 0x03A8, 0x039B, + 0x038E, 0x0381, 0x0375, 0x0369, 0x035E, 0x0353, 0x0348, 0x033D, + 0x0333, 0x0329, 0x031F, 0x0315, 0x030C, 0x0303, 0x02FA, 0x02F1, + 0x02E8, 0x02E0, 0x02D8, 0x02D0, 0x02C8, 0x02C0, 0x02B9, 0x02B1, + 0x02AA, 0x02A3, 0x029C, 0x0295, 0x028F, 0x0288, 0x0282, 0x027C, + 0x0276, 0x0270, 0x026A, 0x0264, 0x025E, 0x0259, 0x0253, 0x024E, + 0x0249, 0x0243, 0x023E, 0x0239, 0x0234, 0x0230, 0x022B, 0x0226, + 0x0222, 0x021D, 0x0219, 0x0214, 0x0210, 0x020C, 0x0208, 0x0204, + 0x0200, 0x01FC, 0x01F8, 0x01F4, 0x01F0, 0x01EC, 0x01E9, 0x01E5, + 0x01E1, 0x01DE, 0x01DA, 0x01D7, 0x01D4, 0x01D0, 0x01CD, 0x01CA, + 0x01C7, 0x01C3, 0x01C0, 0x01BD, 0x01BA, 0x01B7, 0x01B4, 0x01B2, + 0x01AF, 0x01AC, 0x01A9, 0x01A6, 0x01A4, 0x01A1, 0x019E, 0x019C, + 0x0199, 0x0197, 0x0194, 0x0192, 0x018F, 0x018D, 0x018A, 0x0188, + 0x0186, 0x0183, 0x0181, 0x017F, 0x017D, 0x017A, 0x0178, 0x0176, + 0x0174, 0x0172, 0x0170, 0x016E, 0x016C, 0x016A, 0x0168, 0x0166, + 0x0164, 0x0162, 0x0160, 0x015E, 0x015C, 0x015A, 0x0158, 0x0157, + 0x0155, 0x0153, 0x0151, 0x0150, 0x014E, 0x014C, 0x014A, 0x0149, + 0x0147, 0x0146, 0x0144, 0x0142, 0x0141, 0x013F, 0x013E, 0x013C, + 0x013B, 0x0139, 0x0138, 0x0136, 0x0135, 0x0133, 0x0132, 0x0130, + 0x012F, 0x012E, 0x012C, 0x012B, 0x0129, 0x0128, 0x0127, 0x0125, + 0x0124, 0x0123, 0x0121, 0x0120, 0x011F, 0x011E, 0x011C, 0x011B, + 0x011A, 0x0119, 0x0118, 0x0116, 0x0115, 0x0114, 0x0113, 0x0112, + 0x0111, 0x010F, 0x010E, 0x010D, 0x010C, 0x010B, 0x010A, 0x0109, + 0x0108, 0x0107, 0x0106, 0x0105, 0x0104, 0x0103, 0x0102, 0x0101, + 0x0100, 0x00FF, 0x00FE, 0x00FD, 0x00FC, 0x00FB, 0x00FA, 0x00F9, + 0x00F8, 0x00F7, 0x00F6, 0x00F5, 0x00F4, 0x00F3, 0x00F2, 0x00F1, + 0x00F0, 0x00F0, 0x00EF, 0x00EE, 0x00ED, 0x00EC, 0x00EB, 0x00EA, + 0x00EA, 0x00E9, 0x00E8, 0x00E7, 0x00E6, 0x00E5, 0x00E5, 0x00E4, + 0x00E3, 0x00E2, 0x00E1, 0x00E1, 0x00E0, 0x00DF, 0x00DE, 0x00DE, + 0x00DD, 0x00DC, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D8, + 0x00D7, 0x00D6, 0x00D6, 0x00D5, 0x00D4, 0x00D4, 0x00D3, 0x00D2, + 0x00D2, 0x00D1, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CD, + 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C9, 0x00C8, + 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C4, 0x00C3, + 0x00C3, 0x00C2, 0x00C1, 0x00C1, 0x00C0, 0x00C0, 0x00BF, 0x00BF, + 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BB, 0x00BA, + 0x00BA, 0x00B9, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 0x00B7, 0x00B6, + 0x00B6, 0x00B5, 0x00B5, 0x00B4, 0x00B4, 0x00B3, 0x00B3, 0x00B2, + 0x00B2, 0x00B1, 0x00B1, 0x00B0, 0x00B0, 0x00AF, 0x00AF, 0x00AE, + 0x00AE, 0x00AD, 0x00AD, 0x00AC, 0x00AC, 0x00AC, 0x00AB, 0x00AB, + 0x00AA, 0x00AA, 0x00A9, 0x00A9, 0x00A8, 0x00A8, 0x00A8, 0x00A7, + 0x00A7, 0x00A6, 0x00A6, 0x00A5, 0x00A5, 0x00A5, 0x00A4, 0x00A4, + 0x00A3, 0x00A3, 0x00A3, 0x00A2, 0x00A2, 0x00A1, 0x00A1, 0x00A1, + 0x00A0, 0x00A0, 0x009F, 0x009F, 0x009F, 0x009E, 0x009E, 0x009D, + 0x009D, 0x009D, 0x009C, 0x009C, 0x009C, 0x009B, 0x009B, 0x009A, + 0x009A, 0x009A, 0x0099, 0x0099, 0x0099, 0x0098, 0x0098, 0x0098, + 0x0097, 0x0097, 0x0097, 0x0096, 0x0096, 0x0095, 0x0095, 0x0095, + 0x0094, 0x0094, 0x0094, 0x0093, 0x0093, 0x0093, 0x0092, 0x0092, + 0x0092, 0x0091, 0x0091, 0x0091, 0x0090, 0x0090, 0x0090, 0x0090, + 0x008F, 0x008F, 0x008F, 0x008E, 0x008E, 0x008E, 0x008D, 0x008D, + 0x008D, 0x008C, 0x008C, 0x008C, 0x008C, 0x008B, 0x008B, 0x008B, + 0x008A, 0x008A, 0x008A, 0x0089, 0x0089, 0x0089, 0x0089, 0x0088, + 0x0088, 0x0088, 0x0087, 0x0087, 0x0087, 0x0087, 0x0086, 0x0086, + 0x0086, 0x0086, 0x0085, 0x0085, 0x0085, 0x0084, 0x0084, 0x0084, + 0x0084, 0x0083, 0x0083, 0x0083, 0x0083, 0x0082, 0x0082, 0x0082, + 0x0082, 0x0081, 0x0081, 0x0081, 0x0081, 0x0080, 0x0080, 0x0080, + 0x0080, 0x007F, 0x007F, 0x007F, 0x007F, 0x007E, 0x007E, 0x007E, + 0x007E, 0x007D, 0x007D, 0x007D, 0x007D, 0x007C, 0x007C, 0x007C, + 0x007C, 0x007B, 0x007B, 0x007B, 0x007B, 0x007A, 0x007A, 0x007A, + 0x007A, 0x007A, 0x0079, 0x0079, 0x0079, 0x0079, 0x0078, 0x0078, + 0x0078, 0x0078, 0x0078, 0x0077, 0x0077, 0x0077, 0x0077, 0x0076, + 0x0076, 0x0076, 0x0076, 0x0076, 0x0075, 0x0075, 0x0075, 0x0075, + 0x0075, 0x0074, 0x0074, 0x0074, 0x0074, 0x0073, 0x0073, 0x0073, + 0x0073, 0x0073, 0x0072, 0x0072, 0x0072, 0x0072, 0x0072, 0x0071, + 0x0071, 0x0071, 0x0071, 0x0071, 0x0070, 0x0070, 0x0070, 0x0070, + 0x0070, 0x0070, 0x006F, 0x006F, 0x006F, 0x006F, 0x006F, 0x006E, + 0x006E, 0x006E, 0x006E, 0x006E, 0x006D, 0x006D, 0x006D, 0x006D, + 0x006D, 0x006D, 0x006C, 0x006C, 0x006C, 0x006C, 0x006C, 0x006B, + 0x006B, 0x006B, 0x006B, 0x006B, 0x006B, 0x006A, 0x006A, 0x006A, + 0x006A, 0x006A, 0x006A, 0x0069, 0x0069, 0x0069, 0x0069, 0x0069, + 0x0069, 0x0068, 0x0068, 0x0068, 0x0068, 0x0068, 0x0068, 0x0067, + 0x0067, 0x0067, 0x0067, 0x0067, 0x0067, 0x0066, 0x0066, 0x0066, + 0x0066, 0x0066, 0x0066, 0x0065, 0x0065, 0x0065, 0x0065, 0x0065, + 0x0065, 0x0064, 0x0064, 0x0064, 0x0064, 0x0064, 0x0064, 0x0064, + 0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x0063, 0x0062, 0x0062, + 0x0062, 0x0062, 0x0062, 0x0062, 0x0062, 0x0061, 0x0061, 0x0061, + 0x0061, 0x0061, 0x0061, 0x0061, 0x0060, 0x0060, 0x0060, 0x0060, + 0x0060, 0x0060, 0x0060, 0x005F, 0x005F, 0x005F, 0x005F, 0x005F, + 0x005F, 0x005F, 0x005E, 0x005E, 0x005E, 0x005E, 0x005E, 0x005E, + 0x005E, 0x005E, 0x005D, 0x005D, 0x005D, 0x005D, 0x005D, 0x005D, + 0x005D, 0x005C, 0x005C, 0x005C, 0x005C, 0x005C, 0x005C, 0x005C, + 0x005C, 0x005B, 0x005B, 0x005B, 0x005B, 0x005B, 0x005B, 0x005B, + 0x005B, 0x005A, 0x005A, 0x005A, 0x005A, 0x005A, 0x005A, 0x005A, + 0x005A, 0x0059, 0x0059, 0x0059, 0x0059, 0x0059, 0x0059, 0x0059, + 0x0059, 0x0058, 0x0058, 0x0058, 0x0058, 0x0058, 0x0058, 0x0058, + 0x0058, 0x0057, 0x0057, 0x0057, 0x0057, 0x0057, 0x0057, 0x0057, + 0x0057, 0x0057, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, + 0x0056, 0x0056, 0x0056, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, + 0x0055, 0x0055, 0x0055, 0x0055, 0x0054, 0x0054, 0x0054, 0x0054, + 0x0054, 0x0054, 0x0054, 0x0054, 0x0054, 0x0053, 0x0053, 0x0053, + 0x0053, 0x0053, 0x0053, 0x0053, 0x0053, 0x0053, 0x0052, 0x0052, + 0x0052, 0x0052, 0x0052, 0x0052, 0x0052, 0x0052, 0x0052, 0x0052, + 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, + 0x0051, 0x0051, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, + 0x0050, 0x0050, 0x0050, 0x0050, 0x004F, 0x004F, 0x004F, 0x004F, + 0x004F, 0x004F, 0x004F, 0x004F, 0x004F, 0x004F, 0x004E, 0x004E, + 0x004E, 0x004E, 0x004E, 0x004E, 0x004E, 0x004E, 0x004E, 0x004E, + 0x004E, 0x004D, 0x004D, 0x004D, 0x004D, 0x004D, 0x004D, 0x004D, + 0x004D, 0x004D, 0x004D, 0x004D, 0x004C, 0x004C, 0x004C, 0x004C, + 0x004C, 0x004C, 0x004C, 0x004C, 0x004C, 0x004C, 0x004C, 0x004B, + 0x004B, 0x004B, 0x004B, 0x004B, 0x004B, 0x004B, 0x004B, 0x004B, + 0x004B, 0x004B, 0x004A, 0x004A, 0x004A, 0x004A, 0x004A, 0x004A, + 0x004A, 0x004A, 0x004A, 0x004A, 0x004A, 0x004A, 0x0049, 0x0049, + 0x0049, 0x0049, 0x0049, 0x0049, 0x0049, 0x0049, 0x0049, 0x0049, + 0x0049, 0x0049, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, + 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0047, + 0x0047, 0x0047, 0x0047, 0x0047, 0x0047, 0x0047, 0x0047, 0x0047, + 0x0047, 0x0047, 0x0047, 0x0047, 0x0046, 0x0046, 0x0046, 0x0046, + 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, + 0x0046, 0x0045, 0x0045, 0x0045, 0x0045, 0x0045, 0x0045, 0x0045, + 0x0045, 0x0045, 0x0045, 0x0045, 0x0045, 0x0045, 0x0044, 0x0044, + 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, 0x0044, + 0x0044, 0x0044, 0x0044, 0x0044, 0x0043, 0x0043, 0x0043, 0x0043, + 0x0043, 0x0043, 0x0043, 0x0043, 0x0043, 0x0043, 0x0043, 0x0043, + 0x0043, 0x0043, 0x0043, 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, + 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, 0x0042, + 0x0042, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, + 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, 0x0041, + 0x0041, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, + 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040 +}; +#endif + +const uint32 gSinCosTable[4096] = { // ROM + 0x00004000, 0x00194000, 0x00324000, 0x004B4000, 0x00654000, 0x007E4000, 0x00973FFF, 0x00B03FFF, + 0x00C93FFF, 0x00E23FFE, 0x00FB3FFE, 0x01143FFE, 0x012E3FFD, 0x01473FFD, 0x01603FFC, 0x01793FFC, + 0x01923FFB, 0x01AB3FFA, 0x01C43FFA, 0x01DD3FF9, 0x01F73FF8, 0x02103FF7, 0x02293FF7, 0x02423FF6, + 0x025B3FF5, 0x02743FF4, 0x028D3FF3, 0x02A63FF2, 0x02C03FF1, 0x02D93FF0, 0x02F23FEF, 0x030B3FED, + 0x03243FEC, 0x033D3FEB, 0x03563FEA, 0x036F3FE8, 0x03883FE7, 0x03A13FE6, 0x03BB3FE4, 0x03D43FE3, + 0x03ED3FE1, 0x04063FE0, 0x041F3FDE, 0x04383FDC, 0x04513FDB, 0x046A3FD9, 0x04833FD7, 0x049C3FD5, + 0x04B53FD4, 0x04CE3FD2, 0x04E73FD0, 0x05003FCE, 0x051A3FCC, 0x05333FCA, 0x054C3FC8, 0x05653FC6, + 0x057E3FC4, 0x05973FC1, 0x05B03FBF, 0x05C93FBD, 0x05E23FBB, 0x05FB3FB8, 0x06143FB6, 0x062D3FB4, + 0x06463FB1, 0x065F3FAF, 0x06783FAC, 0x06913FAA, 0x06AA3FA7, 0x06C33FA4, 0x06DC3FA2, 0x06F53F9F, + 0x070E3F9C, 0x07273F99, 0x07403F97, 0x07593F94, 0x07723F91, 0x078B3F8E, 0x07A43F8B, 0x07BD3F88, + 0x07D63F85, 0x07EF3F82, 0x08073F7F, 0x08203F7B, 0x08393F78, 0x08523F75, 0x086B3F72, 0x08843F6E, + 0x089D3F6B, 0x08B63F68, 0x08CF3F64, 0x08E83F61, 0x09013F5D, 0x09193F5A, 0x09323F56, 0x094B3F52, + 0x09643F4F, 0x097D3F4B, 0x09963F47, 0x09AF3F43, 0x09C73F40, 0x09E03F3C, 0x09F93F38, 0x0A123F34, + 0x0A2B3F30, 0x0A443F2C, 0x0A5C3F28, 0x0A753F24, 0x0A8E3F20, 0x0AA73F1C, 0x0AC03F17, 0x0AD83F13, + 0x0AF13F0F, 0x0B0A3F0A, 0x0B233F06, 0x0B3B3F02, 0x0B543EFD, 0x0B6D3EF9, 0x0B853EF4, 0x0B9E3EF0, + 0x0BB73EEB, 0x0BD03EE7, 0x0BE83EE2, 0x0C013EDD, 0x0C1A3ED8, 0x0C323ED4, 0x0C4B3ECF, 0x0C643ECA, + 0x0C7C3EC5, 0x0C953EC0, 0x0CAE3EBB, 0x0CC63EB6, 0x0CDF3EB1, 0x0CF83EAC, 0x0D103EA7, 0x0D293EA2, + 0x0D413E9D, 0x0D5A3E98, 0x0D723E92, 0x0D8B3E8D, 0x0DA43E88, 0x0DBC3E82, 0x0DD53E7D, 0x0DED3E77, + 0x0E063E72, 0x0E1E3E6C, 0x0E373E67, 0x0E4F3E61, 0x0E683E5C, 0x0E803E56, 0x0E993E50, 0x0EB13E4A, + 0x0ECA3E45, 0x0EE23E3F, 0x0EFB3E39, 0x0F133E33, 0x0F2B3E2D, 0x0F443E27, 0x0F5C3E21, 0x0F753E1B, + 0x0F8D3E15, 0x0FA53E0F, 0x0FBE3E09, 0x0FD63E03, 0x0FEE3DFC, 0x10073DF6, 0x101F3DF0, 0x10373DE9, + 0x10503DE3, 0x10683DDD, 0x10803DD6, 0x10993DD0, 0x10B13DC9, 0x10C93DC2, 0x10E13DBC, 0x10FA3DB5, + 0x11123DAF, 0x112A3DA8, 0x11423DA1, 0x115A3D9A, 0x11733D93, 0x118B3D8D, 0x11A33D86, 0x11BB3D7F, + 0x11D33D78, 0x11EB3D71, 0x12043D6A, 0x121C3D63, 0x12343D5B, 0x124C3D54, 0x12643D4D, 0x127C3D46, + 0x12943D3F, 0x12AC3D37, 0x12C43D30, 0x12DC3D28, 0x12F43D21, 0x130C3D1A, 0x13243D12, 0x133C3D0B, + 0x13543D03, 0x136C3CFB, 0x13843CF4, 0x139C3CEC, 0x13B43CE4, 0x13CC3CDD, 0x13E43CD5, 0x13FB3CCD, + 0x14133CC5, 0x142B3CBD, 0x14433CB5, 0x145B3CAD, 0x14733CA5, 0x148B3C9D, 0x14A23C95, 0x14BA3C8D, + 0x14D23C85, 0x14EA3C7D, 0x15013C74, 0x15193C6C, 0x15313C64, 0x15493C5B, 0x15603C53, 0x15783C4B, + 0x15903C42, 0x15A73C3A, 0x15BF3C31, 0x15D73C29, 0x15EE3C20, 0x16063C17, 0x161D3C0F, 0x16353C06, + 0x164C3BFD, 0x16643BF5, 0x167C3BEC, 0x16933BE3, 0x16AB3BDA, 0x16C23BD1, 0x16DA3BC8, 0x16F13BBF, + 0x17093BB6, 0x17203BAD, 0x17373BA4, 0x174F3B9B, 0x17663B92, 0x177E3B88, 0x17953B7F, 0x17AC3B76, + 0x17C43B6D, 0x17DB3B63, 0x17F23B5A, 0x180A3B50, 0x18213B47, 0x18383B3E, 0x184F3B34, 0x18673B2A, + 0x187E3B21, 0x18953B17, 0x18AC3B0E, 0x18C33B04, 0x18DB3AFA, 0x18F23AF0, 0x19093AE6, 0x19203ADD, + 0x19373AD3, 0x194E3AC9, 0x19653ABF, 0x197C3AB5, 0x19933AAB, 0x19AA3AA1, 0x19C13A97, 0x19D83A8D, + 0x19EF3A82, 0x1A063A78, 0x1A1D3A6E, 0x1A343A64, 0x1A4B3A59, 0x1A623A4F, 0x1A793A45, 0x1A903A3A, + 0x1AA73A30, 0x1ABE3A25, 0x1AD43A1B, 0x1AEB3A10, 0x1B023A06, 0x1B1939FB, 0x1B3039F0, 0x1B4639E6, + 0x1B5D39DB, 0x1B7439D0, 0x1B8A39C5, 0x1BA139BB, 0x1BB839B0, 0x1BCE39A5, 0x1BE5399A, 0x1BFC398F, + 0x1C123984, 0x1C293979, 0x1C3F396E, 0x1C563963, 0x1C6C3958, 0x1C83394C, 0x1C993941, 0x1CB03936, + 0x1CC6392B, 0x1CDD391F, 0x1CF33914, 0x1D0A3909, 0x1D2038FD, 0x1D3638F2, 0x1D4D38E6, 0x1D6338DB, + 0x1D7938CF, 0x1D9038C3, 0x1DA638B8, 0x1DBC38AC, 0x1DD338A1, 0x1DE93895, 0x1DFF3889, 0x1E15387D, + 0x1E2B3871, 0x1E423866, 0x1E58385A, 0x1E6E384E, 0x1E843842, 0x1E9A3836, 0x1EB0382A, 0x1EC6381E, + 0x1EDC3812, 0x1EF23805, 0x1F0837F9, 0x1F1E37ED, 0x1F3437E1, 0x1F4A37D5, 0x1F6037C8, 0x1F7637BC, + 0x1F8C37B0, 0x1FA237A3, 0x1FB73797, 0x1FCD378A, 0x1FE3377E, 0x1FF93771, 0x200F3765, 0x20243758, + 0x203A374B, 0x2050373F, 0x20653732, 0x207B3725, 0x20913718, 0x20A6370C, 0x20BC36FF, 0x20D136F2, + 0x20E736E5, 0x20FD36D8, 0x211236CB, 0x212836BE, 0x213D36B1, 0x215336A4, 0x21683697, 0x217D368A, + 0x2193367D, 0x21A8366F, 0x21BE3662, 0x21D33655, 0x21E83648, 0x21FE363A, 0x2213362D, 0x22283620, + 0x223D3612, 0x22533605, 0x226835F7, 0x227D35EA, 0x229235DC, 0x22A735CE, 0x22BC35C1, 0x22D235B3, + 0x22E735A5, 0x22FC3598, 0x2311358A, 0x2326357C, 0x233B356E, 0x23503561, 0x23653553, 0x237A3545, + 0x238E3537, 0x23A33529, 0x23B8351B, 0x23CD350D, 0x23E234FF, 0x23F734F1, 0x240B34E2, 0x242034D4, + 0x243534C6, 0x244A34B8, 0x245E34AA, 0x2473349B, 0x2488348D, 0x249C347F, 0x24B13470, 0x24C53462, + 0x24DA3453, 0x24EF3445, 0x25033436, 0x25183428, 0x252C3419, 0x2541340B, 0x255533FC, 0x256933ED, + 0x257E33DF, 0x259233D0, 0x25A633C1, 0x25BB33B2, 0x25CF33A3, 0x25E33395, 0x25F83386, 0x260C3377, + 0x26203368, 0x26343359, 0x2648334A, 0x265C333B, 0x2671332C, 0x2685331D, 0x2699330D, 0x26AD32FE, + 0x26C132EF, 0x26D532E0, 0x26E932D0, 0x26FD32C1, 0x271132B2, 0x272432A3, 0x27383293, 0x274C3284, + 0x27603274, 0x27743265, 0x27883255, 0x279B3246, 0x27AF3236, 0x27C33227, 0x27D63217, 0x27EA3207, + 0x27FE31F8, 0x281131E8, 0x282531D8, 0x283831C8, 0x284C31B9, 0x286031A9, 0x28733199, 0x28863189, + 0x289A3179, 0x28AD3169, 0x28C13159, 0x28D43149, 0x28E73139, 0x28FB3129, 0x290E3119, 0x29213109, + 0x293530F9, 0x294830E8, 0x295B30D8, 0x296E30C8, 0x298130B8, 0x299430A7, 0x29A73097, 0x29BB3087, + 0x29CE3076, 0x29E13066, 0x29F43055, 0x2A073045, 0x2A1A3034, 0x2A2C3024, 0x2A3F3013, 0x2A523002, + 0x2A652FF2, 0x2A782FE1, 0x2A8B2FD0, 0x2A9D2FC0, 0x2AB02FAF, 0x2AC32F9E, 0x2AD62F8D, 0x2AE82F7D, + 0x2AFB2F6C, 0x2B0D2F5B, 0x2B202F4A, 0x2B332F39, 0x2B452F28, 0x2B582F17, 0x2B6A2F06, 0x2B7D2EF5, + 0x2B8F2EE4, 0x2BA12ED3, 0x2BB42EC2, 0x2BC62EB0, 0x2BD82E9F, 0x2BEB2E8E, 0x2BFD2E7D, 0x2C0F2E6B, + 0x2C212E5A, 0x2C342E49, 0x2C462E37, 0x2C582E26, 0x2C6A2E15, 0x2C7C2E03, 0x2C8E2DF2, 0x2CA02DE0, + 0x2CB22DCF, 0x2CC42DBD, 0x2CD62DAB, 0x2CE82D9A, 0x2CFA2D88, 0x2D0C2D76, 0x2D1E2D65, 0x2D2F2D53, + 0x2D412D41, 0x2D532D2F, 0x2D652D1E, 0x2D762D0C, 0x2D882CFA, 0x2D9A2CE8, 0x2DAB2CD6, 0x2DBD2CC4, + 0x2DCF2CB2, 0x2DE02CA0, 0x2DF22C8E, 0x2E032C7C, 0x2E152C6A, 0x2E262C58, 0x2E372C46, 0x2E492C34, + 0x2E5A2C21, 0x2E6B2C0F, 0x2E7D2BFD, 0x2E8E2BEB, 0x2E9F2BD8, 0x2EB02BC6, 0x2EC22BB4, 0x2ED32BA1, + 0x2EE42B8F, 0x2EF52B7D, 0x2F062B6A, 0x2F172B58, 0x2F282B45, 0x2F392B33, 0x2F4A2B20, 0x2F5B2B0D, + 0x2F6C2AFB, 0x2F7D2AE8, 0x2F8D2AD6, 0x2F9E2AC3, 0x2FAF2AB0, 0x2FC02A9D, 0x2FD02A8B, 0x2FE12A78, + 0x2FF22A65, 0x30022A52, 0x30132A3F, 0x30242A2C, 0x30342A1A, 0x30452A07, 0x305529F4, 0x306629E1, + 0x307629CE, 0x308729BB, 0x309729A7, 0x30A72994, 0x30B82981, 0x30C8296E, 0x30D8295B, 0x30E82948, + 0x30F92935, 0x31092921, 0x3119290E, 0x312928FB, 0x313928E7, 0x314928D4, 0x315928C1, 0x316928AD, + 0x3179289A, 0x31892886, 0x31992873, 0x31A92860, 0x31B9284C, 0x31C82838, 0x31D82825, 0x31E82811, + 0x31F827FE, 0x320727EA, 0x321727D6, 0x322727C3, 0x323627AF, 0x3246279B, 0x32552788, 0x32652774, + 0x32742760, 0x3284274C, 0x32932738, 0x32A32724, 0x32B22711, 0x32C126FD, 0x32D026E9, 0x32E026D5, + 0x32EF26C1, 0x32FE26AD, 0x330D2699, 0x331D2685, 0x332C2671, 0x333B265C, 0x334A2648, 0x33592634, + 0x33682620, 0x3377260C, 0x338625F8, 0x339525E3, 0x33A325CF, 0x33B225BB, 0x33C125A6, 0x33D02592, + 0x33DF257E, 0x33ED2569, 0x33FC2555, 0x340B2541, 0x3419252C, 0x34282518, 0x34362503, 0x344524EF, + 0x345324DA, 0x346224C5, 0x347024B1, 0x347F249C, 0x348D2488, 0x349B2473, 0x34AA245E, 0x34B8244A, + 0x34C62435, 0x34D42420, 0x34E2240B, 0x34F123F7, 0x34FF23E2, 0x350D23CD, 0x351B23B8, 0x352923A3, + 0x3537238E, 0x3545237A, 0x35532365, 0x35612350, 0x356E233B, 0x357C2326, 0x358A2311, 0x359822FC, + 0x35A522E7, 0x35B322D2, 0x35C122BC, 0x35CE22A7, 0x35DC2292, 0x35EA227D, 0x35F72268, 0x36052253, + 0x3612223D, 0x36202228, 0x362D2213, 0x363A21FE, 0x364821E8, 0x365521D3, 0x366221BE, 0x366F21A8, + 0x367D2193, 0x368A217D, 0x36972168, 0x36A42153, 0x36B1213D, 0x36BE2128, 0x36CB2112, 0x36D820FD, + 0x36E520E7, 0x36F220D1, 0x36FF20BC, 0x370C20A6, 0x37182091, 0x3725207B, 0x37322065, 0x373F2050, + 0x374B203A, 0x37582024, 0x3765200F, 0x37711FF9, 0x377E1FE3, 0x378A1FCD, 0x37971FB7, 0x37A31FA2, + 0x37B01F8C, 0x37BC1F76, 0x37C81F60, 0x37D51F4A, 0x37E11F34, 0x37ED1F1E, 0x37F91F08, 0x38051EF2, + 0x38121EDC, 0x381E1EC6, 0x382A1EB0, 0x38361E9A, 0x38421E84, 0x384E1E6E, 0x385A1E58, 0x38661E42, + 0x38711E2B, 0x387D1E15, 0x38891DFF, 0x38951DE9, 0x38A11DD3, 0x38AC1DBC, 0x38B81DA6, 0x38C31D90, + 0x38CF1D79, 0x38DB1D63, 0x38E61D4D, 0x38F21D36, 0x38FD1D20, 0x39091D0A, 0x39141CF3, 0x391F1CDD, + 0x392B1CC6, 0x39361CB0, 0x39411C99, 0x394C1C83, 0x39581C6C, 0x39631C56, 0x396E1C3F, 0x39791C29, + 0x39841C12, 0x398F1BFC, 0x399A1BE5, 0x39A51BCE, 0x39B01BB8, 0x39BB1BA1, 0x39C51B8A, 0x39D01B74, + 0x39DB1B5D, 0x39E61B46, 0x39F01B30, 0x39FB1B19, 0x3A061B02, 0x3A101AEB, 0x3A1B1AD4, 0x3A251ABE, + 0x3A301AA7, 0x3A3A1A90, 0x3A451A79, 0x3A4F1A62, 0x3A591A4B, 0x3A641A34, 0x3A6E1A1D, 0x3A781A06, + 0x3A8219EF, 0x3A8D19D8, 0x3A9719C1, 0x3AA119AA, 0x3AAB1993, 0x3AB5197C, 0x3ABF1965, 0x3AC9194E, + 0x3AD31937, 0x3ADD1920, 0x3AE61909, 0x3AF018F2, 0x3AFA18DB, 0x3B0418C3, 0x3B0E18AC, 0x3B171895, + 0x3B21187E, 0x3B2A1867, 0x3B34184F, 0x3B3E1838, 0x3B471821, 0x3B50180A, 0x3B5A17F2, 0x3B6317DB, + 0x3B6D17C4, 0x3B7617AC, 0x3B7F1795, 0x3B88177E, 0x3B921766, 0x3B9B174F, 0x3BA41737, 0x3BAD1720, + 0x3BB61709, 0x3BBF16F1, 0x3BC816DA, 0x3BD116C2, 0x3BDA16AB, 0x3BE31693, 0x3BEC167C, 0x3BF51664, + 0x3BFD164C, 0x3C061635, 0x3C0F161D, 0x3C171606, 0x3C2015EE, 0x3C2915D7, 0x3C3115BF, 0x3C3A15A7, + 0x3C421590, 0x3C4B1578, 0x3C531560, 0x3C5B1549, 0x3C641531, 0x3C6C1519, 0x3C741501, 0x3C7D14EA, + 0x3C8514D2, 0x3C8D14BA, 0x3C9514A2, 0x3C9D148B, 0x3CA51473, 0x3CAD145B, 0x3CB51443, 0x3CBD142B, + 0x3CC51413, 0x3CCD13FB, 0x3CD513E4, 0x3CDD13CC, 0x3CE413B4, 0x3CEC139C, 0x3CF41384, 0x3CFB136C, + 0x3D031354, 0x3D0B133C, 0x3D121324, 0x3D1A130C, 0x3D2112F4, 0x3D2812DC, 0x3D3012C4, 0x3D3712AC, + 0x3D3F1294, 0x3D46127C, 0x3D4D1264, 0x3D54124C, 0x3D5B1234, 0x3D63121C, 0x3D6A1204, 0x3D7111EB, + 0x3D7811D3, 0x3D7F11BB, 0x3D8611A3, 0x3D8D118B, 0x3D931173, 0x3D9A115A, 0x3DA11142, 0x3DA8112A, + 0x3DAF1112, 0x3DB510FA, 0x3DBC10E1, 0x3DC210C9, 0x3DC910B1, 0x3DD01099, 0x3DD61080, 0x3DDD1068, + 0x3DE31050, 0x3DE91037, 0x3DF0101F, 0x3DF61007, 0x3DFC0FEE, 0x3E030FD6, 0x3E090FBE, 0x3E0F0FA5, + 0x3E150F8D, 0x3E1B0F75, 0x3E210F5C, 0x3E270F44, 0x3E2D0F2B, 0x3E330F13, 0x3E390EFB, 0x3E3F0EE2, + 0x3E450ECA, 0x3E4A0EB1, 0x3E500E99, 0x3E560E80, 0x3E5C0E68, 0x3E610E4F, 0x3E670E37, 0x3E6C0E1E, + 0x3E720E06, 0x3E770DED, 0x3E7D0DD5, 0x3E820DBC, 0x3E880DA4, 0x3E8D0D8B, 0x3E920D72, 0x3E980D5A, + 0x3E9D0D41, 0x3EA20D29, 0x3EA70D10, 0x3EAC0CF8, 0x3EB10CDF, 0x3EB60CC6, 0x3EBB0CAE, 0x3EC00C95, + 0x3EC50C7C, 0x3ECA0C64, 0x3ECF0C4B, 0x3ED40C32, 0x3ED80C1A, 0x3EDD0C01, 0x3EE20BE8, 0x3EE70BD0, + 0x3EEB0BB7, 0x3EF00B9E, 0x3EF40B85, 0x3EF90B6D, 0x3EFD0B54, 0x3F020B3B, 0x3F060B23, 0x3F0A0B0A, + 0x3F0F0AF1, 0x3F130AD8, 0x3F170AC0, 0x3F1C0AA7, 0x3F200A8E, 0x3F240A75, 0x3F280A5C, 0x3F2C0A44, + 0x3F300A2B, 0x3F340A12, 0x3F3809F9, 0x3F3C09E0, 0x3F4009C7, 0x3F4309AF, 0x3F470996, 0x3F4B097D, + 0x3F4F0964, 0x3F52094B, 0x3F560932, 0x3F5A0919, 0x3F5D0901, 0x3F6108E8, 0x3F6408CF, 0x3F6808B6, + 0x3F6B089D, 0x3F6E0884, 0x3F72086B, 0x3F750852, 0x3F780839, 0x3F7B0820, 0x3F7F0807, 0x3F8207EF, + 0x3F8507D6, 0x3F8807BD, 0x3F8B07A4, 0x3F8E078B, 0x3F910772, 0x3F940759, 0x3F970740, 0x3F990727, + 0x3F9C070E, 0x3F9F06F5, 0x3FA206DC, 0x3FA406C3, 0x3FA706AA, 0x3FAA0691, 0x3FAC0678, 0x3FAF065F, + 0x3FB10646, 0x3FB4062D, 0x3FB60614, 0x3FB805FB, 0x3FBB05E2, 0x3FBD05C9, 0x3FBF05B0, 0x3FC10597, + 0x3FC4057E, 0x3FC60565, 0x3FC8054C, 0x3FCA0533, 0x3FCC051A, 0x3FCE0500, 0x3FD004E7, 0x3FD204CE, + 0x3FD404B5, 0x3FD5049C, 0x3FD70483, 0x3FD9046A, 0x3FDB0451, 0x3FDC0438, 0x3FDE041F, 0x3FE00406, + 0x3FE103ED, 0x3FE303D4, 0x3FE403BB, 0x3FE603A1, 0x3FE70388, 0x3FE8036F, 0x3FEA0356, 0x3FEB033D, + 0x3FEC0324, 0x3FED030B, 0x3FEF02F2, 0x3FF002D9, 0x3FF102C0, 0x3FF202A6, 0x3FF3028D, 0x3FF40274, + 0x3FF5025B, 0x3FF60242, 0x3FF70229, 0x3FF70210, 0x3FF801F7, 0x3FF901DD, 0x3FFA01C4, 0x3FFA01AB, + 0x3FFB0192, 0x3FFC0179, 0x3FFC0160, 0x3FFD0147, 0x3FFD012E, 0x3FFE0114, 0x3FFE00FB, 0x3FFE00E2, + 0x3FFF00C9, 0x3FFF00B0, 0x3FFF0097, 0x4000007E, 0x40000065, 0x4000004B, 0x40000032, 0x40000019, + 0x40000000, 0x4000FFE7, 0x4000FFCE, 0x4000FFB5, 0x4000FF9B, 0x4000FF82, 0x3FFFFF69, 0x3FFFFF50, + 0x3FFFFF37, 0x3FFEFF1E, 0x3FFEFF05, 0x3FFEFEEC, 0x3FFDFED2, 0x3FFDFEB9, 0x3FFCFEA0, 0x3FFCFE87, + 0x3FFBFE6E, 0x3FFAFE55, 0x3FFAFE3C, 0x3FF9FE23, 0x3FF8FE09, 0x3FF7FDF0, 0x3FF7FDD7, 0x3FF6FDBE, + 0x3FF5FDA5, 0x3FF4FD8C, 0x3FF3FD73, 0x3FF2FD5A, 0x3FF1FD40, 0x3FF0FD27, 0x3FEFFD0E, 0x3FEDFCF5, + 0x3FECFCDC, 0x3FEBFCC3, 0x3FEAFCAA, 0x3FE8FC91, 0x3FE7FC78, 0x3FE6FC5F, 0x3FE4FC45, 0x3FE3FC2C, + 0x3FE1FC13, 0x3FE0FBFA, 0x3FDEFBE1, 0x3FDCFBC8, 0x3FDBFBAF, 0x3FD9FB96, 0x3FD7FB7D, 0x3FD5FB64, + 0x3FD4FB4B, 0x3FD2FB32, 0x3FD0FB19, 0x3FCEFB00, 0x3FCCFAE6, 0x3FCAFACD, 0x3FC8FAB4, 0x3FC6FA9B, + 0x3FC4FA82, 0x3FC1FA69, 0x3FBFFA50, 0x3FBDFA37, 0x3FBBFA1E, 0x3FB8FA05, 0x3FB6F9EC, 0x3FB4F9D3, + 0x3FB1F9BA, 0x3FAFF9A1, 0x3FACF988, 0x3FAAF96F, 0x3FA7F956, 0x3FA4F93D, 0x3FA2F924, 0x3F9FF90B, + 0x3F9CF8F2, 0x3F99F8D9, 0x3F97F8C0, 0x3F94F8A7, 0x3F91F88E, 0x3F8EF875, 0x3F8BF85C, 0x3F88F843, + 0x3F85F82A, 0x3F82F811, 0x3F7FF7F9, 0x3F7BF7E0, 0x3F78F7C7, 0x3F75F7AE, 0x3F72F795, 0x3F6EF77C, + 0x3F6BF763, 0x3F68F74A, 0x3F64F731, 0x3F61F718, 0x3F5DF6FF, 0x3F5AF6E7, 0x3F56F6CE, 0x3F52F6B5, + 0x3F4FF69C, 0x3F4BF683, 0x3F47F66A, 0x3F43F651, 0x3F40F639, 0x3F3CF620, 0x3F38F607, 0x3F34F5EE, + 0x3F30F5D5, 0x3F2CF5BC, 0x3F28F5A4, 0x3F24F58B, 0x3F20F572, 0x3F1CF559, 0x3F17F540, 0x3F13F528, + 0x3F0FF50F, 0x3F0AF4F6, 0x3F06F4DD, 0x3F02F4C5, 0x3EFDF4AC, 0x3EF9F493, 0x3EF4F47B, 0x3EF0F462, + 0x3EEBF449, 0x3EE7F430, 0x3EE2F418, 0x3EDDF3FF, 0x3ED8F3E6, 0x3ED4F3CE, 0x3ECFF3B5, 0x3ECAF39C, + 0x3EC5F384, 0x3EC0F36B, 0x3EBBF352, 0x3EB6F33A, 0x3EB1F321, 0x3EACF308, 0x3EA7F2F0, 0x3EA2F2D7, + 0x3E9DF2BF, 0x3E98F2A6, 0x3E92F28E, 0x3E8DF275, 0x3E88F25C, 0x3E82F244, 0x3E7DF22B, 0x3E77F213, + 0x3E72F1FA, 0x3E6CF1E2, 0x3E67F1C9, 0x3E61F1B1, 0x3E5CF198, 0x3E56F180, 0x3E50F167, 0x3E4AF14F, + 0x3E45F136, 0x3E3FF11E, 0x3E39F105, 0x3E33F0ED, 0x3E2DF0D5, 0x3E27F0BC, 0x3E21F0A4, 0x3E1BF08B, + 0x3E15F073, 0x3E0FF05B, 0x3E09F042, 0x3E03F02A, 0x3DFCF012, 0x3DF6EFF9, 0x3DF0EFE1, 0x3DE9EFC9, + 0x3DE3EFB0, 0x3DDDEF98, 0x3DD6EF80, 0x3DD0EF67, 0x3DC9EF4F, 0x3DC2EF37, 0x3DBCEF1F, 0x3DB5EF06, + 0x3DAFEEEE, 0x3DA8EED6, 0x3DA1EEBE, 0x3D9AEEA6, 0x3D93EE8D, 0x3D8DEE75, 0x3D86EE5D, 0x3D7FEE45, + 0x3D78EE2D, 0x3D71EE15, 0x3D6AEDFC, 0x3D63EDE4, 0x3D5BEDCC, 0x3D54EDB4, 0x3D4DED9C, 0x3D46ED84, + 0x3D3FED6C, 0x3D37ED54, 0x3D30ED3C, 0x3D28ED24, 0x3D21ED0C, 0x3D1AECF4, 0x3D12ECDC, 0x3D0BECC4, + 0x3D03ECAC, 0x3CFBEC94, 0x3CF4EC7C, 0x3CECEC64, 0x3CE4EC4C, 0x3CDDEC34, 0x3CD5EC1C, 0x3CCDEC05, + 0x3CC5EBED, 0x3CBDEBD5, 0x3CB5EBBD, 0x3CADEBA5, 0x3CA5EB8D, 0x3C9DEB75, 0x3C95EB5E, 0x3C8DEB46, + 0x3C85EB2E, 0x3C7DEB16, 0x3C74EAFF, 0x3C6CEAE7, 0x3C64EACF, 0x3C5BEAB7, 0x3C53EAA0, 0x3C4BEA88, + 0x3C42EA70, 0x3C3AEA59, 0x3C31EA41, 0x3C29EA29, 0x3C20EA12, 0x3C17E9FA, 0x3C0FE9E3, 0x3C06E9CB, + 0x3BFDE9B4, 0x3BF5E99C, 0x3BECE984, 0x3BE3E96D, 0x3BDAE955, 0x3BD1E93E, 0x3BC8E926, 0x3BBFE90F, + 0x3BB6E8F7, 0x3BADE8E0, 0x3BA4E8C9, 0x3B9BE8B1, 0x3B92E89A, 0x3B88E882, 0x3B7FE86B, 0x3B76E854, + 0x3B6DE83C, 0x3B63E825, 0x3B5AE80E, 0x3B50E7F6, 0x3B47E7DF, 0x3B3EE7C8, 0x3B34E7B1, 0x3B2AE799, + 0x3B21E782, 0x3B17E76B, 0x3B0EE754, 0x3B04E73D, 0x3AFAE725, 0x3AF0E70E, 0x3AE6E6F7, 0x3ADDE6E0, + 0x3AD3E6C9, 0x3AC9E6B2, 0x3ABFE69B, 0x3AB5E684, 0x3AABE66D, 0x3AA1E656, 0x3A97E63F, 0x3A8DE628, + 0x3A82E611, 0x3A78E5FA, 0x3A6EE5E3, 0x3A64E5CC, 0x3A59E5B5, 0x3A4FE59E, 0x3A45E587, 0x3A3AE570, + 0x3A30E559, 0x3A25E542, 0x3A1BE52C, 0x3A10E515, 0x3A06E4FE, 0x39FBE4E7, 0x39F0E4D0, 0x39E6E4BA, + 0x39DBE4A3, 0x39D0E48C, 0x39C5E476, 0x39BBE45F, 0x39B0E448, 0x39A5E432, 0x399AE41B, 0x398FE404, + 0x3984E3EE, 0x3979E3D7, 0x396EE3C1, 0x3963E3AA, 0x3958E394, 0x394CE37D, 0x3941E367, 0x3936E350, + 0x392BE33A, 0x391FE323, 0x3914E30D, 0x3909E2F6, 0x38FDE2E0, 0x38F2E2CA, 0x38E6E2B3, 0x38DBE29D, + 0x38CFE287, 0x38C3E270, 0x38B8E25A, 0x38ACE244, 0x38A1E22D, 0x3895E217, 0x3889E201, 0x387DE1EB, + 0x3871E1D5, 0x3866E1BE, 0x385AE1A8, 0x384EE192, 0x3842E17C, 0x3836E166, 0x382AE150, 0x381EE13A, + 0x3812E124, 0x3805E10E, 0x37F9E0F8, 0x37EDE0E2, 0x37E1E0CC, 0x37D5E0B6, 0x37C8E0A0, 0x37BCE08A, + 0x37B0E074, 0x37A3E05E, 0x3797E049, 0x378AE033, 0x377EE01D, 0x3771E007, 0x3765DFF1, 0x3758DFDC, + 0x374BDFC6, 0x373FDFB0, 0x3732DF9B, 0x3725DF85, 0x3718DF6F, 0x370CDF5A, 0x36FFDF44, 0x36F2DF2F, + 0x36E5DF19, 0x36D8DF03, 0x36CBDEEE, 0x36BEDED8, 0x36B1DEC3, 0x36A4DEAD, 0x3697DE98, 0x368ADE83, + 0x367DDE6D, 0x366FDE58, 0x3662DE42, 0x3655DE2D, 0x3648DE18, 0x363ADE02, 0x362DDDED, 0x3620DDD8, + 0x3612DDC3, 0x3605DDAD, 0x35F7DD98, 0x35EADD83, 0x35DCDD6E, 0x35CEDD59, 0x35C1DD44, 0x35B3DD2E, + 0x35A5DD19, 0x3598DD04, 0x358ADCEF, 0x357CDCDA, 0x356EDCC5, 0x3561DCB0, 0x3553DC9B, 0x3545DC86, + 0x3537DC72, 0x3529DC5D, 0x351BDC48, 0x350DDC33, 0x34FFDC1E, 0x34F1DC09, 0x34E2DBF5, 0x34D4DBE0, + 0x34C6DBCB, 0x34B8DBB6, 0x34AADBA2, 0x349BDB8D, 0x348DDB78, 0x347FDB64, 0x3470DB4F, 0x3462DB3B, + 0x3453DB26, 0x3445DB11, 0x3436DAFD, 0x3428DAE8, 0x3419DAD4, 0x340BDABF, 0x33FCDAAB, 0x33EDDA97, + 0x33DFDA82, 0x33D0DA6E, 0x33C1DA5A, 0x33B2DA45, 0x33A3DA31, 0x3395DA1D, 0x3386DA08, 0x3377D9F4, + 0x3368D9E0, 0x3359D9CC, 0x334AD9B8, 0x333BD9A4, 0x332CD98F, 0x331DD97B, 0x330DD967, 0x32FED953, + 0x32EFD93F, 0x32E0D92B, 0x32D0D917, 0x32C1D903, 0x32B2D8EF, 0x32A3D8DC, 0x3293D8C8, 0x3284D8B4, + 0x3274D8A0, 0x3265D88C, 0x3255D878, 0x3246D865, 0x3236D851, 0x3227D83D, 0x3217D82A, 0x3207D816, + 0x31F8D802, 0x31E8D7EF, 0x31D8D7DB, 0x31C8D7C8, 0x31B9D7B4, 0x31A9D7A0, 0x3199D78D, 0x3189D77A, + 0x3179D766, 0x3169D753, 0x3159D73F, 0x3149D72C, 0x3139D719, 0x3129D705, 0x3119D6F2, 0x3109D6DF, + 0x30F9D6CB, 0x30E8D6B8, 0x30D8D6A5, 0x30C8D692, 0x30B8D67F, 0x30A7D66C, 0x3097D659, 0x3087D645, + 0x3076D632, 0x3066D61F, 0x3055D60C, 0x3045D5F9, 0x3034D5E6, 0x3024D5D4, 0x3013D5C1, 0x3002D5AE, + 0x2FF2D59B, 0x2FE1D588, 0x2FD0D575, 0x2FC0D563, 0x2FAFD550, 0x2F9ED53D, 0x2F8DD52A, 0x2F7DD518, + 0x2F6CD505, 0x2F5BD4F3, 0x2F4AD4E0, 0x2F39D4CD, 0x2F28D4BB, 0x2F17D4A8, 0x2F06D496, 0x2EF5D483, + 0x2EE4D471, 0x2ED3D45F, 0x2EC2D44C, 0x2EB0D43A, 0x2E9FD428, 0x2E8ED415, 0x2E7DD403, 0x2E6BD3F1, + 0x2E5AD3DF, 0x2E49D3CC, 0x2E37D3BA, 0x2E26D3A8, 0x2E15D396, 0x2E03D384, 0x2DF2D372, 0x2DE0D360, + 0x2DCFD34E, 0x2DBDD33C, 0x2DABD32A, 0x2D9AD318, 0x2D88D306, 0x2D76D2F4, 0x2D65D2E2, 0x2D53D2D1, + 0x2D41D2BF, 0x2D2FD2AD, 0x2D1ED29B, 0x2D0CD28A, 0x2CFAD278, 0x2CE8D266, 0x2CD6D255, 0x2CC4D243, + 0x2CB2D231, 0x2CA0D220, 0x2C8ED20E, 0x2C7CD1FD, 0x2C6AD1EB, 0x2C58D1DA, 0x2C46D1C9, 0x2C34D1B7, + 0x2C21D1A6, 0x2C0FD195, 0x2BFDD183, 0x2BEBD172, 0x2BD8D161, 0x2BC6D150, 0x2BB4D13E, 0x2BA1D12D, + 0x2B8FD11C, 0x2B7DD10B, 0x2B6AD0FA, 0x2B58D0E9, 0x2B45D0D8, 0x2B33D0C7, 0x2B20D0B6, 0x2B0DD0A5, + 0x2AFBD094, 0x2AE8D083, 0x2AD6D073, 0x2AC3D062, 0x2AB0D051, 0x2A9DD040, 0x2A8BD030, 0x2A78D01F, + 0x2A65D00E, 0x2A52CFFE, 0x2A3FCFED, 0x2A2CCFDC, 0x2A1ACFCC, 0x2A07CFBB, 0x29F4CFAB, 0x29E1CF9A, + 0x29CECF8A, 0x29BBCF79, 0x29A7CF69, 0x2994CF59, 0x2981CF48, 0x296ECF38, 0x295BCF28, 0x2948CF18, + 0x2935CF07, 0x2921CEF7, 0x290ECEE7, 0x28FBCED7, 0x28E7CEC7, 0x28D4CEB7, 0x28C1CEA7, 0x28ADCE97, + 0x289ACE87, 0x2886CE77, 0x2873CE67, 0x2860CE57, 0x284CCE47, 0x2838CE38, 0x2825CE28, 0x2811CE18, + 0x27FECE08, 0x27EACDF9, 0x27D6CDE9, 0x27C3CDD9, 0x27AFCDCA, 0x279BCDBA, 0x2788CDAB, 0x2774CD9B, + 0x2760CD8C, 0x274CCD7C, 0x2738CD6D, 0x2724CD5D, 0x2711CD4E, 0x26FDCD3F, 0x26E9CD30, 0x26D5CD20, + 0x26C1CD11, 0x26ADCD02, 0x2699CCF3, 0x2685CCE3, 0x2671CCD4, 0x265CCCC5, 0x2648CCB6, 0x2634CCA7, + 0x2620CC98, 0x260CCC89, 0x25F8CC7A, 0x25E3CC6B, 0x25CFCC5D, 0x25BBCC4E, 0x25A6CC3F, 0x2592CC30, + 0x257ECC21, 0x2569CC13, 0x2555CC04, 0x2541CBF5, 0x252CCBE7, 0x2518CBD8, 0x2503CBCA, 0x24EFCBBB, + 0x24DACBAD, 0x24C5CB9E, 0x24B1CB90, 0x249CCB81, 0x2488CB73, 0x2473CB65, 0x245ECB56, 0x244ACB48, + 0x2435CB3A, 0x2420CB2C, 0x240BCB1E, 0x23F7CB0F, 0x23E2CB01, 0x23CDCAF3, 0x23B8CAE5, 0x23A3CAD7, + 0x238ECAC9, 0x237ACABB, 0x2365CAAD, 0x2350CA9F, 0x233BCA92, 0x2326CA84, 0x2311CA76, 0x22FCCA68, + 0x22E7CA5B, 0x22D2CA4D, 0x22BCCA3F, 0x22A7CA32, 0x2292CA24, 0x227DCA16, 0x2268CA09, 0x2253C9FB, + 0x223DC9EE, 0x2228C9E0, 0x2213C9D3, 0x21FEC9C6, 0x21E8C9B8, 0x21D3C9AB, 0x21BEC99E, 0x21A8C991, + 0x2193C983, 0x217DC976, 0x2168C969, 0x2153C95C, 0x213DC94F, 0x2128C942, 0x2112C935, 0x20FDC928, + 0x20E7C91B, 0x20D1C90E, 0x20BCC901, 0x20A6C8F4, 0x2091C8E8, 0x207BC8DB, 0x2065C8CE, 0x2050C8C1, + 0x203AC8B5, 0x2024C8A8, 0x200FC89B, 0x1FF9C88F, 0x1FE3C882, 0x1FCDC876, 0x1FB7C869, 0x1FA2C85D, + 0x1F8CC850, 0x1F76C844, 0x1F60C838, 0x1F4AC82B, 0x1F34C81F, 0x1F1EC813, 0x1F08C807, 0x1EF2C7FB, + 0x1EDCC7EE, 0x1EC6C7E2, 0x1EB0C7D6, 0x1E9AC7CA, 0x1E84C7BE, 0x1E6EC7B2, 0x1E58C7A6, 0x1E42C79A, + 0x1E2BC78F, 0x1E15C783, 0x1DFFC777, 0x1DE9C76B, 0x1DD3C75F, 0x1DBCC754, 0x1DA6C748, 0x1D90C73D, + 0x1D79C731, 0x1D63C725, 0x1D4DC71A, 0x1D36C70E, 0x1D20C703, 0x1D0AC6F7, 0x1CF3C6EC, 0x1CDDC6E1, + 0x1CC6C6D5, 0x1CB0C6CA, 0x1C99C6BF, 0x1C83C6B4, 0x1C6CC6A8, 0x1C56C69D, 0x1C3FC692, 0x1C29C687, + 0x1C12C67C, 0x1BFCC671, 0x1BE5C666, 0x1BCEC65B, 0x1BB8C650, 0x1BA1C645, 0x1B8AC63B, 0x1B74C630, + 0x1B5DC625, 0x1B46C61A, 0x1B30C610, 0x1B19C605, 0x1B02C5FA, 0x1AEBC5F0, 0x1AD4C5E5, 0x1ABEC5DB, + 0x1AA7C5D0, 0x1A90C5C6, 0x1A79C5BB, 0x1A62C5B1, 0x1A4BC5A7, 0x1A34C59C, 0x1A1DC592, 0x1A06C588, + 0x19EFC57E, 0x19D8C573, 0x19C1C569, 0x19AAC55F, 0x1993C555, 0x197CC54B, 0x1965C541, 0x194EC537, + 0x1937C52D, 0x1920C523, 0x1909C51A, 0x18F2C510, 0x18DBC506, 0x18C3C4FC, 0x18ACC4F2, 0x1895C4E9, + 0x187EC4DF, 0x1867C4D6, 0x184FC4CC, 0x1838C4C2, 0x1821C4B9, 0x180AC4B0, 0x17F2C4A6, 0x17DBC49D, + 0x17C4C493, 0x17ACC48A, 0x1795C481, 0x177EC478, 0x1766C46E, 0x174FC465, 0x1737C45C, 0x1720C453, + 0x1709C44A, 0x16F1C441, 0x16DAC438, 0x16C2C42F, 0x16ABC426, 0x1693C41D, 0x167CC414, 0x1664C40B, + 0x164CC403, 0x1635C3FA, 0x161DC3F1, 0x1606C3E9, 0x15EEC3E0, 0x15D7C3D7, 0x15BFC3CF, 0x15A7C3C6, + 0x1590C3BE, 0x1578C3B5, 0x1560C3AD, 0x1549C3A5, 0x1531C39C, 0x1519C394, 0x1501C38C, 0x14EAC383, + 0x14D2C37B, 0x14BAC373, 0x14A2C36B, 0x148BC363, 0x1473C35B, 0x145BC353, 0x1443C34B, 0x142BC343, + 0x1413C33B, 0x13FBC333, 0x13E4C32B, 0x13CCC323, 0x13B4C31C, 0x139CC314, 0x1384C30C, 0x136CC305, + 0x1354C2FD, 0x133CC2F5, 0x1324C2EE, 0x130CC2E6, 0x12F4C2DF, 0x12DCC2D8, 0x12C4C2D0, 0x12ACC2C9, + 0x1294C2C1, 0x127CC2BA, 0x1264C2B3, 0x124CC2AC, 0x1234C2A5, 0x121CC29D, 0x1204C296, 0x11EBC28F, + 0x11D3C288, 0x11BBC281, 0x11A3C27A, 0x118BC273, 0x1173C26D, 0x115AC266, 0x1142C25F, 0x112AC258, + 0x1112C251, 0x10FAC24B, 0x10E1C244, 0x10C9C23E, 0x10B1C237, 0x1099C230, 0x1080C22A, 0x1068C223, + 0x1050C21D, 0x1037C217, 0x101FC210, 0x1007C20A, 0x0FEEC204, 0x0FD6C1FD, 0x0FBEC1F7, 0x0FA5C1F1, + 0x0F8DC1EB, 0x0F75C1E5, 0x0F5CC1DF, 0x0F44C1D9, 0x0F2BC1D3, 0x0F13C1CD, 0x0EFBC1C7, 0x0EE2C1C1, + 0x0ECAC1BB, 0x0EB1C1B6, 0x0E99C1B0, 0x0E80C1AA, 0x0E68C1A4, 0x0E4FC19F, 0x0E37C199, 0x0E1EC194, + 0x0E06C18E, 0x0DEDC189, 0x0DD5C183, 0x0DBCC17E, 0x0DA4C178, 0x0D8BC173, 0x0D72C16E, 0x0D5AC168, + 0x0D41C163, 0x0D29C15E, 0x0D10C159, 0x0CF8C154, 0x0CDFC14F, 0x0CC6C14A, 0x0CAEC145, 0x0C95C140, + 0x0C7CC13B, 0x0C64C136, 0x0C4BC131, 0x0C32C12C, 0x0C1AC128, 0x0C01C123, 0x0BE8C11E, 0x0BD0C119, + 0x0BB7C115, 0x0B9EC110, 0x0B85C10C, 0x0B6DC107, 0x0B54C103, 0x0B3BC0FE, 0x0B23C0FA, 0x0B0AC0F6, + 0x0AF1C0F1, 0x0AD8C0ED, 0x0AC0C0E9, 0x0AA7C0E4, 0x0A8EC0E0, 0x0A75C0DC, 0x0A5CC0D8, 0x0A44C0D4, + 0x0A2BC0D0, 0x0A12C0CC, 0x09F9C0C8, 0x09E0C0C4, 0x09C7C0C0, 0x09AFC0BD, 0x0996C0B9, 0x097DC0B5, + 0x0964C0B1, 0x094BC0AE, 0x0932C0AA, 0x0919C0A6, 0x0901C0A3, 0x08E8C09F, 0x08CFC09C, 0x08B6C098, + 0x089DC095, 0x0884C092, 0x086BC08E, 0x0852C08B, 0x0839C088, 0x0820C085, 0x0807C081, 0x07EFC07E, + 0x07D6C07B, 0x07BDC078, 0x07A4C075, 0x078BC072, 0x0772C06F, 0x0759C06C, 0x0740C069, 0x0727C067, + 0x070EC064, 0x06F5C061, 0x06DCC05E, 0x06C3C05C, 0x06AAC059, 0x0691C056, 0x0678C054, 0x065FC051, + 0x0646C04F, 0x062DC04C, 0x0614C04A, 0x05FBC048, 0x05E2C045, 0x05C9C043, 0x05B0C041, 0x0597C03F, + 0x057EC03C, 0x0565C03A, 0x054CC038, 0x0533C036, 0x051AC034, 0x0500C032, 0x04E7C030, 0x04CEC02E, + 0x04B5C02C, 0x049CC02B, 0x0483C029, 0x046AC027, 0x0451C025, 0x0438C024, 0x041FC022, 0x0406C020, + 0x03EDC01F, 0x03D4C01D, 0x03BBC01C, 0x03A1C01A, 0x0388C019, 0x036FC018, 0x0356C016, 0x033DC015, + 0x0324C014, 0x030BC013, 0x02F2C011, 0x02D9C010, 0x02C0C00F, 0x02A6C00E, 0x028DC00D, 0x0274C00C, + 0x025BC00B, 0x0242C00A, 0x0229C009, 0x0210C009, 0x01F7C008, 0x01DDC007, 0x01C4C006, 0x01ABC006, + 0x0192C005, 0x0179C004, 0x0160C004, 0x0147C003, 0x012EC003, 0x0114C002, 0x00FBC002, 0x00E2C002, + 0x00C9C001, 0x00B0C001, 0x0097C001, 0x007EC000, 0x0065C000, 0x004BC000, 0x0032C000, 0x0019C000, + 0x0000C000, 0xFFE7C000, 0xFFCEC000, 0xFFB5C000, 0xFF9BC000, 0xFF82C000, 0xFF69C001, 0xFF50C001, + 0xFF37C001, 0xFF1EC002, 0xFF05C002, 0xFEECC002, 0xFED2C003, 0xFEB9C003, 0xFEA0C004, 0xFE87C004, + 0xFE6EC005, 0xFE55C006, 0xFE3CC006, 0xFE23C007, 0xFE09C008, 0xFDF0C009, 0xFDD7C009, 0xFDBEC00A, + 0xFDA5C00B, 0xFD8CC00C, 0xFD73C00D, 0xFD5AC00E, 0xFD40C00F, 0xFD27C010, 0xFD0EC011, 0xFCF5C013, + 0xFCDCC014, 0xFCC3C015, 0xFCAAC016, 0xFC91C018, 0xFC78C019, 0xFC5FC01A, 0xFC45C01C, 0xFC2CC01D, + 0xFC13C01F, 0xFBFAC020, 0xFBE1C022, 0xFBC8C024, 0xFBAFC025, 0xFB96C027, 0xFB7DC029, 0xFB64C02B, + 0xFB4BC02C, 0xFB32C02E, 0xFB19C030, 0xFB00C032, 0xFAE6C034, 0xFACDC036, 0xFAB4C038, 0xFA9BC03A, + 0xFA82C03C, 0xFA69C03F, 0xFA50C041, 0xFA37C043, 0xFA1EC045, 0xFA05C048, 0xF9ECC04A, 0xF9D3C04C, + 0xF9BAC04F, 0xF9A1C051, 0xF988C054, 0xF96FC056, 0xF956C059, 0xF93DC05C, 0xF924C05E, 0xF90BC061, + 0xF8F2C064, 0xF8D9C067, 0xF8C0C069, 0xF8A7C06C, 0xF88EC06F, 0xF875C072, 0xF85CC075, 0xF843C078, + 0xF82AC07B, 0xF811C07E, 0xF7F9C081, 0xF7E0C085, 0xF7C7C088, 0xF7AEC08B, 0xF795C08E, 0xF77CC092, + 0xF763C095, 0xF74AC098, 0xF731C09C, 0xF718C09F, 0xF6FFC0A3, 0xF6E7C0A6, 0xF6CEC0AA, 0xF6B5C0AE, + 0xF69CC0B1, 0xF683C0B5, 0xF66AC0B9, 0xF651C0BD, 0xF639C0C0, 0xF620C0C4, 0xF607C0C8, 0xF5EEC0CC, + 0xF5D5C0D0, 0xF5BCC0D4, 0xF5A4C0D8, 0xF58BC0DC, 0xF572C0E0, 0xF559C0E4, 0xF540C0E9, 0xF528C0ED, + 0xF50FC0F1, 0xF4F6C0F6, 0xF4DDC0FA, 0xF4C5C0FE, 0xF4ACC103, 0xF493C107, 0xF47BC10C, 0xF462C110, + 0xF449C115, 0xF430C119, 0xF418C11E, 0xF3FFC123, 0xF3E6C128, 0xF3CEC12C, 0xF3B5C131, 0xF39CC136, + 0xF384C13B, 0xF36BC140, 0xF352C145, 0xF33AC14A, 0xF321C14F, 0xF308C154, 0xF2F0C159, 0xF2D7C15E, + 0xF2BFC163, 0xF2A6C168, 0xF28EC16E, 0xF275C173, 0xF25CC178, 0xF244C17E, 0xF22BC183, 0xF213C189, + 0xF1FAC18E, 0xF1E2C194, 0xF1C9C199, 0xF1B1C19F, 0xF198C1A4, 0xF180C1AA, 0xF167C1B0, 0xF14FC1B6, + 0xF136C1BB, 0xF11EC1C1, 0xF105C1C7, 0xF0EDC1CD, 0xF0D5C1D3, 0xF0BCC1D9, 0xF0A4C1DF, 0xF08BC1E5, + 0xF073C1EB, 0xF05BC1F1, 0xF042C1F7, 0xF02AC1FD, 0xF012C204, 0xEFF9C20A, 0xEFE1C210, 0xEFC9C217, + 0xEFB0C21D, 0xEF98C223, 0xEF80C22A, 0xEF67C230, 0xEF4FC237, 0xEF37C23E, 0xEF1FC244, 0xEF06C24B, + 0xEEEEC251, 0xEED6C258, 0xEEBEC25F, 0xEEA6C266, 0xEE8DC26D, 0xEE75C273, 0xEE5DC27A, 0xEE45C281, + 0xEE2DC288, 0xEE15C28F, 0xEDFCC296, 0xEDE4C29D, 0xEDCCC2A5, 0xEDB4C2AC, 0xED9CC2B3, 0xED84C2BA, + 0xED6CC2C1, 0xED54C2C9, 0xED3CC2D0, 0xED24C2D8, 0xED0CC2DF, 0xECF4C2E6, 0xECDCC2EE, 0xECC4C2F5, + 0xECACC2FD, 0xEC94C305, 0xEC7CC30C, 0xEC64C314, 0xEC4CC31C, 0xEC34C323, 0xEC1CC32B, 0xEC05C333, + 0xEBEDC33B, 0xEBD5C343, 0xEBBDC34B, 0xEBA5C353, 0xEB8DC35B, 0xEB75C363, 0xEB5EC36B, 0xEB46C373, + 0xEB2EC37B, 0xEB16C383, 0xEAFFC38C, 0xEAE7C394, 0xEACFC39C, 0xEAB7C3A5, 0xEAA0C3AD, 0xEA88C3B5, + 0xEA70C3BE, 0xEA59C3C6, 0xEA41C3CF, 0xEA29C3D7, 0xEA12C3E0, 0xE9FAC3E9, 0xE9E3C3F1, 0xE9CBC3FA, + 0xE9B4C403, 0xE99CC40B, 0xE984C414, 0xE96DC41D, 0xE955C426, 0xE93EC42F, 0xE926C438, 0xE90FC441, + 0xE8F7C44A, 0xE8E0C453, 0xE8C9C45C, 0xE8B1C465, 0xE89AC46E, 0xE882C478, 0xE86BC481, 0xE854C48A, + 0xE83CC493, 0xE825C49D, 0xE80EC4A6, 0xE7F6C4B0, 0xE7DFC4B9, 0xE7C8C4C2, 0xE7B1C4CC, 0xE799C4D6, + 0xE782C4DF, 0xE76BC4E9, 0xE754C4F2, 0xE73DC4FC, 0xE725C506, 0xE70EC510, 0xE6F7C51A, 0xE6E0C523, + 0xE6C9C52D, 0xE6B2C537, 0xE69BC541, 0xE684C54B, 0xE66DC555, 0xE656C55F, 0xE63FC569, 0xE628C573, + 0xE611C57E, 0xE5FAC588, 0xE5E3C592, 0xE5CCC59C, 0xE5B5C5A7, 0xE59EC5B1, 0xE587C5BB, 0xE570C5C6, + 0xE559C5D0, 0xE542C5DB, 0xE52CC5E5, 0xE515C5F0, 0xE4FEC5FA, 0xE4E7C605, 0xE4D0C610, 0xE4BAC61A, + 0xE4A3C625, 0xE48CC630, 0xE476C63B, 0xE45FC645, 0xE448C650, 0xE432C65B, 0xE41BC666, 0xE404C671, + 0xE3EEC67C, 0xE3D7C687, 0xE3C1C692, 0xE3AAC69D, 0xE394C6A8, 0xE37DC6B4, 0xE367C6BF, 0xE350C6CA, + 0xE33AC6D5, 0xE323C6E1, 0xE30DC6EC, 0xE2F6C6F7, 0xE2E0C703, 0xE2CAC70E, 0xE2B3C71A, 0xE29DC725, + 0xE287C731, 0xE270C73D, 0xE25AC748, 0xE244C754, 0xE22DC75F, 0xE217C76B, 0xE201C777, 0xE1EBC783, + 0xE1D5C78F, 0xE1BEC79A, 0xE1A8C7A6, 0xE192C7B2, 0xE17CC7BE, 0xE166C7CA, 0xE150C7D6, 0xE13AC7E2, + 0xE124C7EE, 0xE10EC7FB, 0xE0F8C807, 0xE0E2C813, 0xE0CCC81F, 0xE0B6C82B, 0xE0A0C838, 0xE08AC844, + 0xE074C850, 0xE05EC85D, 0xE049C869, 0xE033C876, 0xE01DC882, 0xE007C88F, 0xDFF1C89B, 0xDFDCC8A8, + 0xDFC6C8B5, 0xDFB0C8C1, 0xDF9BC8CE, 0xDF85C8DB, 0xDF6FC8E8, 0xDF5AC8F4, 0xDF44C901, 0xDF2FC90E, + 0xDF19C91B, 0xDF03C928, 0xDEEEC935, 0xDED8C942, 0xDEC3C94F, 0xDEADC95C, 0xDE98C969, 0xDE83C976, + 0xDE6DC983, 0xDE58C991, 0xDE42C99E, 0xDE2DC9AB, 0xDE18C9B8, 0xDE02C9C6, 0xDDEDC9D3, 0xDDD8C9E0, + 0xDDC3C9EE, 0xDDADC9FB, 0xDD98CA09, 0xDD83CA16, 0xDD6ECA24, 0xDD59CA32, 0xDD44CA3F, 0xDD2ECA4D, + 0xDD19CA5B, 0xDD04CA68, 0xDCEFCA76, 0xDCDACA84, 0xDCC5CA92, 0xDCB0CA9F, 0xDC9BCAAD, 0xDC86CABB, + 0xDC72CAC9, 0xDC5DCAD7, 0xDC48CAE5, 0xDC33CAF3, 0xDC1ECB01, 0xDC09CB0F, 0xDBF5CB1E, 0xDBE0CB2C, + 0xDBCBCB3A, 0xDBB6CB48, 0xDBA2CB56, 0xDB8DCB65, 0xDB78CB73, 0xDB64CB81, 0xDB4FCB90, 0xDB3BCB9E, + 0xDB26CBAD, 0xDB11CBBB, 0xDAFDCBCA, 0xDAE8CBD8, 0xDAD4CBE7, 0xDABFCBF5, 0xDAABCC04, 0xDA97CC13, + 0xDA82CC21, 0xDA6ECC30, 0xDA5ACC3F, 0xDA45CC4E, 0xDA31CC5D, 0xDA1DCC6B, 0xDA08CC7A, 0xD9F4CC89, + 0xD9E0CC98, 0xD9CCCCA7, 0xD9B8CCB6, 0xD9A4CCC5, 0xD98FCCD4, 0xD97BCCE3, 0xD967CCF3, 0xD953CD02, + 0xD93FCD11, 0xD92BCD20, 0xD917CD30, 0xD903CD3F, 0xD8EFCD4E, 0xD8DCCD5D, 0xD8C8CD6D, 0xD8B4CD7C, + 0xD8A0CD8C, 0xD88CCD9B, 0xD878CDAB, 0xD865CDBA, 0xD851CDCA, 0xD83DCDD9, 0xD82ACDE9, 0xD816CDF9, + 0xD802CE08, 0xD7EFCE18, 0xD7DBCE28, 0xD7C8CE38, 0xD7B4CE47, 0xD7A0CE57, 0xD78DCE67, 0xD77ACE77, + 0xD766CE87, 0xD753CE97, 0xD73FCEA7, 0xD72CCEB7, 0xD719CEC7, 0xD705CED7, 0xD6F2CEE7, 0xD6DFCEF7, + 0xD6CBCF07, 0xD6B8CF18, 0xD6A5CF28, 0xD692CF38, 0xD67FCF48, 0xD66CCF59, 0xD659CF69, 0xD645CF79, + 0xD632CF8A, 0xD61FCF9A, 0xD60CCFAB, 0xD5F9CFBB, 0xD5E6CFCC, 0xD5D4CFDC, 0xD5C1CFED, 0xD5AECFFE, + 0xD59BD00E, 0xD588D01F, 0xD575D030, 0xD563D040, 0xD550D051, 0xD53DD062, 0xD52AD073, 0xD518D083, + 0xD505D094, 0xD4F3D0A5, 0xD4E0D0B6, 0xD4CDD0C7, 0xD4BBD0D8, 0xD4A8D0E9, 0xD496D0FA, 0xD483D10B, + 0xD471D11C, 0xD45FD12D, 0xD44CD13E, 0xD43AD150, 0xD428D161, 0xD415D172, 0xD403D183, 0xD3F1D195, + 0xD3DFD1A6, 0xD3CCD1B7, 0xD3BAD1C9, 0xD3A8D1DA, 0xD396D1EB, 0xD384D1FD, 0xD372D20E, 0xD360D220, + 0xD34ED231, 0xD33CD243, 0xD32AD255, 0xD318D266, 0xD306D278, 0xD2F4D28A, 0xD2E2D29B, 0xD2D1D2AD, + 0xD2BFD2BF, 0xD2ADD2D1, 0xD29BD2E2, 0xD28AD2F4, 0xD278D306, 0xD266D318, 0xD255D32A, 0xD243D33C, + 0xD231D34E, 0xD220D360, 0xD20ED372, 0xD1FDD384, 0xD1EBD396, 0xD1DAD3A8, 0xD1C9D3BA, 0xD1B7D3CC, + 0xD1A6D3DF, 0xD195D3F1, 0xD183D403, 0xD172D415, 0xD161D428, 0xD150D43A, 0xD13ED44C, 0xD12DD45F, + 0xD11CD471, 0xD10BD483, 0xD0FAD496, 0xD0E9D4A8, 0xD0D8D4BB, 0xD0C7D4CD, 0xD0B6D4E0, 0xD0A5D4F3, + 0xD094D505, 0xD083D518, 0xD073D52A, 0xD062D53D, 0xD051D550, 0xD040D563, 0xD030D575, 0xD01FD588, + 0xD00ED59B, 0xCFFED5AE, 0xCFEDD5C1, 0xCFDCD5D4, 0xCFCCD5E6, 0xCFBBD5F9, 0xCFABD60C, 0xCF9AD61F, + 0xCF8AD632, 0xCF79D645, 0xCF69D659, 0xCF59D66C, 0xCF48D67F, 0xCF38D692, 0xCF28D6A5, 0xCF18D6B8, + 0xCF07D6CB, 0xCEF7D6DF, 0xCEE7D6F2, 0xCED7D705, 0xCEC7D719, 0xCEB7D72C, 0xCEA7D73F, 0xCE97D753, + 0xCE87D766, 0xCE77D77A, 0xCE67D78D, 0xCE57D7A0, 0xCE47D7B4, 0xCE38D7C8, 0xCE28D7DB, 0xCE18D7EF, + 0xCE08D802, 0xCDF9D816, 0xCDE9D82A, 0xCDD9D83D, 0xCDCAD851, 0xCDBAD865, 0xCDABD878, 0xCD9BD88C, + 0xCD8CD8A0, 0xCD7CD8B4, 0xCD6DD8C8, 0xCD5DD8DC, 0xCD4ED8EF, 0xCD3FD903, 0xCD30D917, 0xCD20D92B, + 0xCD11D93F, 0xCD02D953, 0xCCF3D967, 0xCCE3D97B, 0xCCD4D98F, 0xCCC5D9A4, 0xCCB6D9B8, 0xCCA7D9CC, + 0xCC98D9E0, 0xCC89D9F4, 0xCC7ADA08, 0xCC6BDA1D, 0xCC5DDA31, 0xCC4EDA45, 0xCC3FDA5A, 0xCC30DA6E, + 0xCC21DA82, 0xCC13DA97, 0xCC04DAAB, 0xCBF5DABF, 0xCBE7DAD4, 0xCBD8DAE8, 0xCBCADAFD, 0xCBBBDB11, + 0xCBADDB26, 0xCB9EDB3B, 0xCB90DB4F, 0xCB81DB64, 0xCB73DB78, 0xCB65DB8D, 0xCB56DBA2, 0xCB48DBB6, + 0xCB3ADBCB, 0xCB2CDBE0, 0xCB1EDBF5, 0xCB0FDC09, 0xCB01DC1E, 0xCAF3DC33, 0xCAE5DC48, 0xCAD7DC5D, + 0xCAC9DC72, 0xCABBDC86, 0xCAADDC9B, 0xCA9FDCB0, 0xCA92DCC5, 0xCA84DCDA, 0xCA76DCEF, 0xCA68DD04, + 0xCA5BDD19, 0xCA4DDD2E, 0xCA3FDD44, 0xCA32DD59, 0xCA24DD6E, 0xCA16DD83, 0xCA09DD98, 0xC9FBDDAD, + 0xC9EEDDC3, 0xC9E0DDD8, 0xC9D3DDED, 0xC9C6DE02, 0xC9B8DE18, 0xC9ABDE2D, 0xC99EDE42, 0xC991DE58, + 0xC983DE6D, 0xC976DE83, 0xC969DE98, 0xC95CDEAD, 0xC94FDEC3, 0xC942DED8, 0xC935DEEE, 0xC928DF03, + 0xC91BDF19, 0xC90EDF2F, 0xC901DF44, 0xC8F4DF5A, 0xC8E8DF6F, 0xC8DBDF85, 0xC8CEDF9B, 0xC8C1DFB0, + 0xC8B5DFC6, 0xC8A8DFDC, 0xC89BDFF1, 0xC88FE007, 0xC882E01D, 0xC876E033, 0xC869E049, 0xC85DE05E, + 0xC850E074, 0xC844E08A, 0xC838E0A0, 0xC82BE0B6, 0xC81FE0CC, 0xC813E0E2, 0xC807E0F8, 0xC7FBE10E, + 0xC7EEE124, 0xC7E2E13A, 0xC7D6E150, 0xC7CAE166, 0xC7BEE17C, 0xC7B2E192, 0xC7A6E1A8, 0xC79AE1BE, + 0xC78FE1D5, 0xC783E1EB, 0xC777E201, 0xC76BE217, 0xC75FE22D, 0xC754E244, 0xC748E25A, 0xC73DE270, + 0xC731E287, 0xC725E29D, 0xC71AE2B3, 0xC70EE2CA, 0xC703E2E0, 0xC6F7E2F6, 0xC6ECE30D, 0xC6E1E323, + 0xC6D5E33A, 0xC6CAE350, 0xC6BFE367, 0xC6B4E37D, 0xC6A8E394, 0xC69DE3AA, 0xC692E3C1, 0xC687E3D7, + 0xC67CE3EE, 0xC671E404, 0xC666E41B, 0xC65BE432, 0xC650E448, 0xC645E45F, 0xC63BE476, 0xC630E48C, + 0xC625E4A3, 0xC61AE4BA, 0xC610E4D0, 0xC605E4E7, 0xC5FAE4FE, 0xC5F0E515, 0xC5E5E52C, 0xC5DBE542, + 0xC5D0E559, 0xC5C6E570, 0xC5BBE587, 0xC5B1E59E, 0xC5A7E5B5, 0xC59CE5CC, 0xC592E5E3, 0xC588E5FA, + 0xC57EE611, 0xC573E628, 0xC569E63F, 0xC55FE656, 0xC555E66D, 0xC54BE684, 0xC541E69B, 0xC537E6B2, + 0xC52DE6C9, 0xC523E6E0, 0xC51AE6F7, 0xC510E70E, 0xC506E725, 0xC4FCE73D, 0xC4F2E754, 0xC4E9E76B, + 0xC4DFE782, 0xC4D6E799, 0xC4CCE7B1, 0xC4C2E7C8, 0xC4B9E7DF, 0xC4B0E7F6, 0xC4A6E80E, 0xC49DE825, + 0xC493E83C, 0xC48AE854, 0xC481E86B, 0xC478E882, 0xC46EE89A, 0xC465E8B1, 0xC45CE8C9, 0xC453E8E0, + 0xC44AE8F7, 0xC441E90F, 0xC438E926, 0xC42FE93E, 0xC426E955, 0xC41DE96D, 0xC414E984, 0xC40BE99C, + 0xC403E9B4, 0xC3FAE9CB, 0xC3F1E9E3, 0xC3E9E9FA, 0xC3E0EA12, 0xC3D7EA29, 0xC3CFEA41, 0xC3C6EA59, + 0xC3BEEA70, 0xC3B5EA88, 0xC3ADEAA0, 0xC3A5EAB7, 0xC39CEACF, 0xC394EAE7, 0xC38CEAFF, 0xC383EB16, + 0xC37BEB2E, 0xC373EB46, 0xC36BEB5E, 0xC363EB75, 0xC35BEB8D, 0xC353EBA5, 0xC34BEBBD, 0xC343EBD5, + 0xC33BEBED, 0xC333EC05, 0xC32BEC1C, 0xC323EC34, 0xC31CEC4C, 0xC314EC64, 0xC30CEC7C, 0xC305EC94, + 0xC2FDECAC, 0xC2F5ECC4, 0xC2EEECDC, 0xC2E6ECF4, 0xC2DFED0C, 0xC2D8ED24, 0xC2D0ED3C, 0xC2C9ED54, + 0xC2C1ED6C, 0xC2BAED84, 0xC2B3ED9C, 0xC2ACEDB4, 0xC2A5EDCC, 0xC29DEDE4, 0xC296EDFC, 0xC28FEE15, + 0xC288EE2D, 0xC281EE45, 0xC27AEE5D, 0xC273EE75, 0xC26DEE8D, 0xC266EEA6, 0xC25FEEBE, 0xC258EED6, + 0xC251EEEE, 0xC24BEF06, 0xC244EF1F, 0xC23EEF37, 0xC237EF4F, 0xC230EF67, 0xC22AEF80, 0xC223EF98, + 0xC21DEFB0, 0xC217EFC9, 0xC210EFE1, 0xC20AEFF9, 0xC204F012, 0xC1FDF02A, 0xC1F7F042, 0xC1F1F05B, + 0xC1EBF073, 0xC1E5F08B, 0xC1DFF0A4, 0xC1D9F0BC, 0xC1D3F0D5, 0xC1CDF0ED, 0xC1C7F105, 0xC1C1F11E, + 0xC1BBF136, 0xC1B6F14F, 0xC1B0F167, 0xC1AAF180, 0xC1A4F198, 0xC19FF1B1, 0xC199F1C9, 0xC194F1E2, + 0xC18EF1FA, 0xC189F213, 0xC183F22B, 0xC17EF244, 0xC178F25C, 0xC173F275, 0xC16EF28E, 0xC168F2A6, + 0xC163F2BF, 0xC15EF2D7, 0xC159F2F0, 0xC154F308, 0xC14FF321, 0xC14AF33A, 0xC145F352, 0xC140F36B, + 0xC13BF384, 0xC136F39C, 0xC131F3B5, 0xC12CF3CE, 0xC128F3E6, 0xC123F3FF, 0xC11EF418, 0xC119F430, + 0xC115F449, 0xC110F462, 0xC10CF47B, 0xC107F493, 0xC103F4AC, 0xC0FEF4C5, 0xC0FAF4DD, 0xC0F6F4F6, + 0xC0F1F50F, 0xC0EDF528, 0xC0E9F540, 0xC0E4F559, 0xC0E0F572, 0xC0DCF58B, 0xC0D8F5A4, 0xC0D4F5BC, + 0xC0D0F5D5, 0xC0CCF5EE, 0xC0C8F607, 0xC0C4F620, 0xC0C0F639, 0xC0BDF651, 0xC0B9F66A, 0xC0B5F683, + 0xC0B1F69C, 0xC0AEF6B5, 0xC0AAF6CE, 0xC0A6F6E7, 0xC0A3F6FF, 0xC09FF718, 0xC09CF731, 0xC098F74A, + 0xC095F763, 0xC092F77C, 0xC08EF795, 0xC08BF7AE, 0xC088F7C7, 0xC085F7E0, 0xC081F7F9, 0xC07EF811, + 0xC07BF82A, 0xC078F843, 0xC075F85C, 0xC072F875, 0xC06FF88E, 0xC06CF8A7, 0xC069F8C0, 0xC067F8D9, + 0xC064F8F2, 0xC061F90B, 0xC05EF924, 0xC05CF93D, 0xC059F956, 0xC056F96F, 0xC054F988, 0xC051F9A1, + 0xC04FF9BA, 0xC04CF9D3, 0xC04AF9EC, 0xC048FA05, 0xC045FA1E, 0xC043FA37, 0xC041FA50, 0xC03FFA69, + 0xC03CFA82, 0xC03AFA9B, 0xC038FAB4, 0xC036FACD, 0xC034FAE6, 0xC032FB00, 0xC030FB19, 0xC02EFB32, + 0xC02CFB4B, 0xC02BFB64, 0xC029FB7D, 0xC027FB96, 0xC025FBAF, 0xC024FBC8, 0xC022FBE1, 0xC020FBFA, + 0xC01FFC13, 0xC01DFC2C, 0xC01CFC45, 0xC01AFC5F, 0xC019FC78, 0xC018FC91, 0xC016FCAA, 0xC015FCC3, + 0xC014FCDC, 0xC013FCF5, 0xC011FD0E, 0xC010FD27, 0xC00FFD40, 0xC00EFD5A, 0xC00DFD73, 0xC00CFD8C, + 0xC00BFDA5, 0xC00AFDBE, 0xC009FDD7, 0xC009FDF0, 0xC008FE09, 0xC007FE23, 0xC006FE3C, 0xC006FE55, + 0xC005FE6E, 0xC004FE87, 0xC004FEA0, 0xC003FEB9, 0xC003FED2, 0xC002FEEC, 0xC002FF05, 0xC002FF1E, + 0xC001FF37, 0xC001FF50, 0xC001FF69, 0xC000FF82, 0xC000FF9B, 0xC000FFB5, 0xC000FFCE, 0xC000FFE7, + 0xC0000000, 0xC0000019, 0xC0000032, 0xC000004B, 0xC0000065, 0xC000007E, 0xC0010097, 0xC00100B0, + 0xC00100C9, 0xC00200E2, 0xC00200FB, 0xC0020114, 0xC003012E, 0xC0030147, 0xC0040160, 0xC0040179, + 0xC0050192, 0xC00601AB, 0xC00601C4, 0xC00701DD, 0xC00801F7, 0xC0090210, 0xC0090229, 0xC00A0242, + 0xC00B025B, 0xC00C0274, 0xC00D028D, 0xC00E02A6, 0xC00F02C0, 0xC01002D9, 0xC01102F2, 0xC013030B, + 0xC0140324, 0xC015033D, 0xC0160356, 0xC018036F, 0xC0190388, 0xC01A03A1, 0xC01C03BB, 0xC01D03D4, + 0xC01F03ED, 0xC0200406, 0xC022041F, 0xC0240438, 0xC0250451, 0xC027046A, 0xC0290483, 0xC02B049C, + 0xC02C04B5, 0xC02E04CE, 0xC03004E7, 0xC0320500, 0xC034051A, 0xC0360533, 0xC038054C, 0xC03A0565, + 0xC03C057E, 0xC03F0597, 0xC04105B0, 0xC04305C9, 0xC04505E2, 0xC04805FB, 0xC04A0614, 0xC04C062D, + 0xC04F0646, 0xC051065F, 0xC0540678, 0xC0560691, 0xC05906AA, 0xC05C06C3, 0xC05E06DC, 0xC06106F5, + 0xC064070E, 0xC0670727, 0xC0690740, 0xC06C0759, 0xC06F0772, 0xC072078B, 0xC07507A4, 0xC07807BD, + 0xC07B07D6, 0xC07E07EF, 0xC0810807, 0xC0850820, 0xC0880839, 0xC08B0852, 0xC08E086B, 0xC0920884, + 0xC095089D, 0xC09808B6, 0xC09C08CF, 0xC09F08E8, 0xC0A30901, 0xC0A60919, 0xC0AA0932, 0xC0AE094B, + 0xC0B10964, 0xC0B5097D, 0xC0B90996, 0xC0BD09AF, 0xC0C009C7, 0xC0C409E0, 0xC0C809F9, 0xC0CC0A12, + 0xC0D00A2B, 0xC0D40A44, 0xC0D80A5C, 0xC0DC0A75, 0xC0E00A8E, 0xC0E40AA7, 0xC0E90AC0, 0xC0ED0AD8, + 0xC0F10AF1, 0xC0F60B0A, 0xC0FA0B23, 0xC0FE0B3B, 0xC1030B54, 0xC1070B6D, 0xC10C0B85, 0xC1100B9E, + 0xC1150BB7, 0xC1190BD0, 0xC11E0BE8, 0xC1230C01, 0xC1280C1A, 0xC12C0C32, 0xC1310C4B, 0xC1360C64, + 0xC13B0C7C, 0xC1400C95, 0xC1450CAE, 0xC14A0CC6, 0xC14F0CDF, 0xC1540CF8, 0xC1590D10, 0xC15E0D29, + 0xC1630D41, 0xC1680D5A, 0xC16E0D72, 0xC1730D8B, 0xC1780DA4, 0xC17E0DBC, 0xC1830DD5, 0xC1890DED, + 0xC18E0E06, 0xC1940E1E, 0xC1990E37, 0xC19F0E4F, 0xC1A40E68, 0xC1AA0E80, 0xC1B00E99, 0xC1B60EB1, + 0xC1BB0ECA, 0xC1C10EE2, 0xC1C70EFB, 0xC1CD0F13, 0xC1D30F2B, 0xC1D90F44, 0xC1DF0F5C, 0xC1E50F75, + 0xC1EB0F8D, 0xC1F10FA5, 0xC1F70FBE, 0xC1FD0FD6, 0xC2040FEE, 0xC20A1007, 0xC210101F, 0xC2171037, + 0xC21D1050, 0xC2231068, 0xC22A1080, 0xC2301099, 0xC23710B1, 0xC23E10C9, 0xC24410E1, 0xC24B10FA, + 0xC2511112, 0xC258112A, 0xC25F1142, 0xC266115A, 0xC26D1173, 0xC273118B, 0xC27A11A3, 0xC28111BB, + 0xC28811D3, 0xC28F11EB, 0xC2961204, 0xC29D121C, 0xC2A51234, 0xC2AC124C, 0xC2B31264, 0xC2BA127C, + 0xC2C11294, 0xC2C912AC, 0xC2D012C4, 0xC2D812DC, 0xC2DF12F4, 0xC2E6130C, 0xC2EE1324, 0xC2F5133C, + 0xC2FD1354, 0xC305136C, 0xC30C1384, 0xC314139C, 0xC31C13B4, 0xC32313CC, 0xC32B13E4, 0xC33313FB, + 0xC33B1413, 0xC343142B, 0xC34B1443, 0xC353145B, 0xC35B1473, 0xC363148B, 0xC36B14A2, 0xC37314BA, + 0xC37B14D2, 0xC38314EA, 0xC38C1501, 0xC3941519, 0xC39C1531, 0xC3A51549, 0xC3AD1560, 0xC3B51578, + 0xC3BE1590, 0xC3C615A7, 0xC3CF15BF, 0xC3D715D7, 0xC3E015EE, 0xC3E91606, 0xC3F1161D, 0xC3FA1635, + 0xC403164C, 0xC40B1664, 0xC414167C, 0xC41D1693, 0xC42616AB, 0xC42F16C2, 0xC43816DA, 0xC44116F1, + 0xC44A1709, 0xC4531720, 0xC45C1737, 0xC465174F, 0xC46E1766, 0xC478177E, 0xC4811795, 0xC48A17AC, + 0xC49317C4, 0xC49D17DB, 0xC4A617F2, 0xC4B0180A, 0xC4B91821, 0xC4C21838, 0xC4CC184F, 0xC4D61867, + 0xC4DF187E, 0xC4E91895, 0xC4F218AC, 0xC4FC18C3, 0xC50618DB, 0xC51018F2, 0xC51A1909, 0xC5231920, + 0xC52D1937, 0xC537194E, 0xC5411965, 0xC54B197C, 0xC5551993, 0xC55F19AA, 0xC56919C1, 0xC57319D8, + 0xC57E19EF, 0xC5881A06, 0xC5921A1D, 0xC59C1A34, 0xC5A71A4B, 0xC5B11A62, 0xC5BB1A79, 0xC5C61A90, + 0xC5D01AA7, 0xC5DB1ABE, 0xC5E51AD4, 0xC5F01AEB, 0xC5FA1B02, 0xC6051B19, 0xC6101B30, 0xC61A1B46, + 0xC6251B5D, 0xC6301B74, 0xC63B1B8A, 0xC6451BA1, 0xC6501BB8, 0xC65B1BCE, 0xC6661BE5, 0xC6711BFC, + 0xC67C1C12, 0xC6871C29, 0xC6921C3F, 0xC69D1C56, 0xC6A81C6C, 0xC6B41C83, 0xC6BF1C99, 0xC6CA1CB0, + 0xC6D51CC6, 0xC6E11CDD, 0xC6EC1CF3, 0xC6F71D0A, 0xC7031D20, 0xC70E1D36, 0xC71A1D4D, 0xC7251D63, + 0xC7311D79, 0xC73D1D90, 0xC7481DA6, 0xC7541DBC, 0xC75F1DD3, 0xC76B1DE9, 0xC7771DFF, 0xC7831E15, + 0xC78F1E2B, 0xC79A1E42, 0xC7A61E58, 0xC7B21E6E, 0xC7BE1E84, 0xC7CA1E9A, 0xC7D61EB0, 0xC7E21EC6, + 0xC7EE1EDC, 0xC7FB1EF2, 0xC8071F08, 0xC8131F1E, 0xC81F1F34, 0xC82B1F4A, 0xC8381F60, 0xC8441F76, + 0xC8501F8C, 0xC85D1FA2, 0xC8691FB7, 0xC8761FCD, 0xC8821FE3, 0xC88F1FF9, 0xC89B200F, 0xC8A82024, + 0xC8B5203A, 0xC8C12050, 0xC8CE2065, 0xC8DB207B, 0xC8E82091, 0xC8F420A6, 0xC90120BC, 0xC90E20D1, + 0xC91B20E7, 0xC92820FD, 0xC9352112, 0xC9422128, 0xC94F213D, 0xC95C2153, 0xC9692168, 0xC976217D, + 0xC9832193, 0xC99121A8, 0xC99E21BE, 0xC9AB21D3, 0xC9B821E8, 0xC9C621FE, 0xC9D32213, 0xC9E02228, + 0xC9EE223D, 0xC9FB2253, 0xCA092268, 0xCA16227D, 0xCA242292, 0xCA3222A7, 0xCA3F22BC, 0xCA4D22D2, + 0xCA5B22E7, 0xCA6822FC, 0xCA762311, 0xCA842326, 0xCA92233B, 0xCA9F2350, 0xCAAD2365, 0xCABB237A, + 0xCAC9238E, 0xCAD723A3, 0xCAE523B8, 0xCAF323CD, 0xCB0123E2, 0xCB0F23F7, 0xCB1E240B, 0xCB2C2420, + 0xCB3A2435, 0xCB48244A, 0xCB56245E, 0xCB652473, 0xCB732488, 0xCB81249C, 0xCB9024B1, 0xCB9E24C5, + 0xCBAD24DA, 0xCBBB24EF, 0xCBCA2503, 0xCBD82518, 0xCBE7252C, 0xCBF52541, 0xCC042555, 0xCC132569, + 0xCC21257E, 0xCC302592, 0xCC3F25A6, 0xCC4E25BB, 0xCC5D25CF, 0xCC6B25E3, 0xCC7A25F8, 0xCC89260C, + 0xCC982620, 0xCCA72634, 0xCCB62648, 0xCCC5265C, 0xCCD42671, 0xCCE32685, 0xCCF32699, 0xCD0226AD, + 0xCD1126C1, 0xCD2026D5, 0xCD3026E9, 0xCD3F26FD, 0xCD4E2711, 0xCD5D2724, 0xCD6D2738, 0xCD7C274C, + 0xCD8C2760, 0xCD9B2774, 0xCDAB2788, 0xCDBA279B, 0xCDCA27AF, 0xCDD927C3, 0xCDE927D6, 0xCDF927EA, + 0xCE0827FE, 0xCE182811, 0xCE282825, 0xCE382838, 0xCE47284C, 0xCE572860, 0xCE672873, 0xCE772886, + 0xCE87289A, 0xCE9728AD, 0xCEA728C1, 0xCEB728D4, 0xCEC728E7, 0xCED728FB, 0xCEE7290E, 0xCEF72921, + 0xCF072935, 0xCF182948, 0xCF28295B, 0xCF38296E, 0xCF482981, 0xCF592994, 0xCF6929A7, 0xCF7929BB, + 0xCF8A29CE, 0xCF9A29E1, 0xCFAB29F4, 0xCFBB2A07, 0xCFCC2A1A, 0xCFDC2A2C, 0xCFED2A3F, 0xCFFE2A52, + 0xD00E2A65, 0xD01F2A78, 0xD0302A8B, 0xD0402A9D, 0xD0512AB0, 0xD0622AC3, 0xD0732AD6, 0xD0832AE8, + 0xD0942AFB, 0xD0A52B0D, 0xD0B62B20, 0xD0C72B33, 0xD0D82B45, 0xD0E92B58, 0xD0FA2B6A, 0xD10B2B7D, + 0xD11C2B8F, 0xD12D2BA1, 0xD13E2BB4, 0xD1502BC6, 0xD1612BD8, 0xD1722BEB, 0xD1832BFD, 0xD1952C0F, + 0xD1A62C21, 0xD1B72C34, 0xD1C92C46, 0xD1DA2C58, 0xD1EB2C6A, 0xD1FD2C7C, 0xD20E2C8E, 0xD2202CA0, + 0xD2312CB2, 0xD2432CC4, 0xD2552CD6, 0xD2662CE8, 0xD2782CFA, 0xD28A2D0C, 0xD29B2D1E, 0xD2AD2D2F, + 0xD2BF2D41, 0xD2D12D53, 0xD2E22D65, 0xD2F42D76, 0xD3062D88, 0xD3182D9A, 0xD32A2DAB, 0xD33C2DBD, + 0xD34E2DCF, 0xD3602DE0, 0xD3722DF2, 0xD3842E03, 0xD3962E15, 0xD3A82E26, 0xD3BA2E37, 0xD3CC2E49, + 0xD3DF2E5A, 0xD3F12E6B, 0xD4032E7D, 0xD4152E8E, 0xD4282E9F, 0xD43A2EB0, 0xD44C2EC2, 0xD45F2ED3, + 0xD4712EE4, 0xD4832EF5, 0xD4962F06, 0xD4A82F17, 0xD4BB2F28, 0xD4CD2F39, 0xD4E02F4A, 0xD4F32F5B, + 0xD5052F6C, 0xD5182F7D, 0xD52A2F8D, 0xD53D2F9E, 0xD5502FAF, 0xD5632FC0, 0xD5752FD0, 0xD5882FE1, + 0xD59B2FF2, 0xD5AE3002, 0xD5C13013, 0xD5D43024, 0xD5E63034, 0xD5F93045, 0xD60C3055, 0xD61F3066, + 0xD6323076, 0xD6453087, 0xD6593097, 0xD66C30A7, 0xD67F30B8, 0xD69230C8, 0xD6A530D8, 0xD6B830E8, + 0xD6CB30F9, 0xD6DF3109, 0xD6F23119, 0xD7053129, 0xD7193139, 0xD72C3149, 0xD73F3159, 0xD7533169, + 0xD7663179, 0xD77A3189, 0xD78D3199, 0xD7A031A9, 0xD7B431B9, 0xD7C831C8, 0xD7DB31D8, 0xD7EF31E8, + 0xD80231F8, 0xD8163207, 0xD82A3217, 0xD83D3227, 0xD8513236, 0xD8653246, 0xD8783255, 0xD88C3265, + 0xD8A03274, 0xD8B43284, 0xD8C83293, 0xD8DC32A3, 0xD8EF32B2, 0xD90332C1, 0xD91732D0, 0xD92B32E0, + 0xD93F32EF, 0xD95332FE, 0xD967330D, 0xD97B331D, 0xD98F332C, 0xD9A4333B, 0xD9B8334A, 0xD9CC3359, + 0xD9E03368, 0xD9F43377, 0xDA083386, 0xDA1D3395, 0xDA3133A3, 0xDA4533B2, 0xDA5A33C1, 0xDA6E33D0, + 0xDA8233DF, 0xDA9733ED, 0xDAAB33FC, 0xDABF340B, 0xDAD43419, 0xDAE83428, 0xDAFD3436, 0xDB113445, + 0xDB263453, 0xDB3B3462, 0xDB4F3470, 0xDB64347F, 0xDB78348D, 0xDB8D349B, 0xDBA234AA, 0xDBB634B8, + 0xDBCB34C6, 0xDBE034D4, 0xDBF534E2, 0xDC0934F1, 0xDC1E34FF, 0xDC33350D, 0xDC48351B, 0xDC5D3529, + 0xDC723537, 0xDC863545, 0xDC9B3553, 0xDCB03561, 0xDCC5356E, 0xDCDA357C, 0xDCEF358A, 0xDD043598, + 0xDD1935A5, 0xDD2E35B3, 0xDD4435C1, 0xDD5935CE, 0xDD6E35DC, 0xDD8335EA, 0xDD9835F7, 0xDDAD3605, + 0xDDC33612, 0xDDD83620, 0xDDED362D, 0xDE02363A, 0xDE183648, 0xDE2D3655, 0xDE423662, 0xDE58366F, + 0xDE6D367D, 0xDE83368A, 0xDE983697, 0xDEAD36A4, 0xDEC336B1, 0xDED836BE, 0xDEEE36CB, 0xDF0336D8, + 0xDF1936E5, 0xDF2F36F2, 0xDF4436FF, 0xDF5A370C, 0xDF6F3718, 0xDF853725, 0xDF9B3732, 0xDFB0373F, + 0xDFC6374B, 0xDFDC3758, 0xDFF13765, 0xE0073771, 0xE01D377E, 0xE033378A, 0xE0493797, 0xE05E37A3, + 0xE07437B0, 0xE08A37BC, 0xE0A037C8, 0xE0B637D5, 0xE0CC37E1, 0xE0E237ED, 0xE0F837F9, 0xE10E3805, + 0xE1243812, 0xE13A381E, 0xE150382A, 0xE1663836, 0xE17C3842, 0xE192384E, 0xE1A8385A, 0xE1BE3866, + 0xE1D53871, 0xE1EB387D, 0xE2013889, 0xE2173895, 0xE22D38A1, 0xE24438AC, 0xE25A38B8, 0xE27038C3, + 0xE28738CF, 0xE29D38DB, 0xE2B338E6, 0xE2CA38F2, 0xE2E038FD, 0xE2F63909, 0xE30D3914, 0xE323391F, + 0xE33A392B, 0xE3503936, 0xE3673941, 0xE37D394C, 0xE3943958, 0xE3AA3963, 0xE3C1396E, 0xE3D73979, + 0xE3EE3984, 0xE404398F, 0xE41B399A, 0xE43239A5, 0xE44839B0, 0xE45F39BB, 0xE47639C5, 0xE48C39D0, + 0xE4A339DB, 0xE4BA39E6, 0xE4D039F0, 0xE4E739FB, 0xE4FE3A06, 0xE5153A10, 0xE52C3A1B, 0xE5423A25, + 0xE5593A30, 0xE5703A3A, 0xE5873A45, 0xE59E3A4F, 0xE5B53A59, 0xE5CC3A64, 0xE5E33A6E, 0xE5FA3A78, + 0xE6113A82, 0xE6283A8D, 0xE63F3A97, 0xE6563AA1, 0xE66D3AAB, 0xE6843AB5, 0xE69B3ABF, 0xE6B23AC9, + 0xE6C93AD3, 0xE6E03ADD, 0xE6F73AE6, 0xE70E3AF0, 0xE7253AFA, 0xE73D3B04, 0xE7543B0E, 0xE76B3B17, + 0xE7823B21, 0xE7993B2A, 0xE7B13B34, 0xE7C83B3E, 0xE7DF3B47, 0xE7F63B50, 0xE80E3B5A, 0xE8253B63, + 0xE83C3B6D, 0xE8543B76, 0xE86B3B7F, 0xE8823B88, 0xE89A3B92, 0xE8B13B9B, 0xE8C93BA4, 0xE8E03BAD, + 0xE8F73BB6, 0xE90F3BBF, 0xE9263BC8, 0xE93E3BD1, 0xE9553BDA, 0xE96D3BE3, 0xE9843BEC, 0xE99C3BF5, + 0xE9B43BFD, 0xE9CB3C06, 0xE9E33C0F, 0xE9FA3C17, 0xEA123C20, 0xEA293C29, 0xEA413C31, 0xEA593C3A, + 0xEA703C42, 0xEA883C4B, 0xEAA03C53, 0xEAB73C5B, 0xEACF3C64, 0xEAE73C6C, 0xEAFF3C74, 0xEB163C7D, + 0xEB2E3C85, 0xEB463C8D, 0xEB5E3C95, 0xEB753C9D, 0xEB8D3CA5, 0xEBA53CAD, 0xEBBD3CB5, 0xEBD53CBD, + 0xEBED3CC5, 0xEC053CCD, 0xEC1C3CD5, 0xEC343CDD, 0xEC4C3CE4, 0xEC643CEC, 0xEC7C3CF4, 0xEC943CFB, + 0xECAC3D03, 0xECC43D0B, 0xECDC3D12, 0xECF43D1A, 0xED0C3D21, 0xED243D28, 0xED3C3D30, 0xED543D37, + 0xED6C3D3F, 0xED843D46, 0xED9C3D4D, 0xEDB43D54, 0xEDCC3D5B, 0xEDE43D63, 0xEDFC3D6A, 0xEE153D71, + 0xEE2D3D78, 0xEE453D7F, 0xEE5D3D86, 0xEE753D8D, 0xEE8D3D93, 0xEEA63D9A, 0xEEBE3DA1, 0xEED63DA8, + 0xEEEE3DAF, 0xEF063DB5, 0xEF1F3DBC, 0xEF373DC2, 0xEF4F3DC9, 0xEF673DD0, 0xEF803DD6, 0xEF983DDD, + 0xEFB03DE3, 0xEFC93DE9, 0xEFE13DF0, 0xEFF93DF6, 0xF0123DFC, 0xF02A3E03, 0xF0423E09, 0xF05B3E0F, + 0xF0733E15, 0xF08B3E1B, 0xF0A43E21, 0xF0BC3E27, 0xF0D53E2D, 0xF0ED3E33, 0xF1053E39, 0xF11E3E3F, + 0xF1363E45, 0xF14F3E4A, 0xF1673E50, 0xF1803E56, 0xF1983E5C, 0xF1B13E61, 0xF1C93E67, 0xF1E23E6C, + 0xF1FA3E72, 0xF2133E77, 0xF22B3E7D, 0xF2443E82, 0xF25C3E88, 0xF2753E8D, 0xF28E3E92, 0xF2A63E98, + 0xF2BF3E9D, 0xF2D73EA2, 0xF2F03EA7, 0xF3083EAC, 0xF3213EB1, 0xF33A3EB6, 0xF3523EBB, 0xF36B3EC0, + 0xF3843EC5, 0xF39C3ECA, 0xF3B53ECF, 0xF3CE3ED4, 0xF3E63ED8, 0xF3FF3EDD, 0xF4183EE2, 0xF4303EE7, + 0xF4493EEB, 0xF4623EF0, 0xF47B3EF4, 0xF4933EF9, 0xF4AC3EFD, 0xF4C53F02, 0xF4DD3F06, 0xF4F63F0A, + 0xF50F3F0F, 0xF5283F13, 0xF5403F17, 0xF5593F1C, 0xF5723F20, 0xF58B3F24, 0xF5A43F28, 0xF5BC3F2C, + 0xF5D53F30, 0xF5EE3F34, 0xF6073F38, 0xF6203F3C, 0xF6393F40, 0xF6513F43, 0xF66A3F47, 0xF6833F4B, + 0xF69C3F4F, 0xF6B53F52, 0xF6CE3F56, 0xF6E73F5A, 0xF6FF3F5D, 0xF7183F61, 0xF7313F64, 0xF74A3F68, + 0xF7633F6B, 0xF77C3F6E, 0xF7953F72, 0xF7AE3F75, 0xF7C73F78, 0xF7E03F7B, 0xF7F93F7F, 0xF8113F82, + 0xF82A3F85, 0xF8433F88, 0xF85C3F8B, 0xF8753F8E, 0xF88E3F91, 0xF8A73F94, 0xF8C03F97, 0xF8D93F99, + 0xF8F23F9C, 0xF90B3F9F, 0xF9243FA2, 0xF93D3FA4, 0xF9563FA7, 0xF96F3FAA, 0xF9883FAC, 0xF9A13FAF, + 0xF9BA3FB1, 0xF9D33FB4, 0xF9EC3FB6, 0xFA053FB8, 0xFA1E3FBB, 0xFA373FBD, 0xFA503FBF, 0xFA693FC1, + 0xFA823FC4, 0xFA9B3FC6, 0xFAB43FC8, 0xFACD3FCA, 0xFAE63FCC, 0xFB003FCE, 0xFB193FD0, 0xFB323FD2, + 0xFB4B3FD4, 0xFB643FD5, 0xFB7D3FD7, 0xFB963FD9, 0xFBAF3FDB, 0xFBC83FDC, 0xFBE13FDE, 0xFBFA3FE0, + 0xFC133FE1, 0xFC2C3FE3, 0xFC453FE4, 0xFC5F3FE6, 0xFC783FE7, 0xFC913FE8, 0xFCAA3FEA, 0xFCC33FEB, + 0xFCDC3FEC, 0xFCF53FED, 0xFD0E3FEF, 0xFD273FF0, 0xFD403FF1, 0xFD5A3FF2, 0xFD733FF3, 0xFD8C3FF4, + 0xFDA53FF5, 0xFDBE3FF6, 0xFDD73FF7, 0xFDF03FF7, 0xFE093FF8, 0xFE233FF9, 0xFE3C3FFA, 0xFE553FFA, + 0xFE6E3FFB, 0xFE873FFC, 0xFEA03FFC, 0xFEB93FFD, 0xFED23FFD, 0xFEEC3FFE, 0xFF053FFE, 0xFF1E3FFE, + 0xFF373FFF, 0xFF503FFF, 0xFF693FFF, 0xFF824000, 0xFF9B4000, 0xFFB54000, 0xFFCE4000, 0xFFE74000, +}; + +const int16 atanTable[2050] = { // ROM + 0x0000, 0x0005, 0x000A, 0x000F, 0x0014, 0x0019, 0x001F, 0x0024, + 0x0029, 0x002E, 0x0033, 0x0038, 0x003D, 0x0042, 0x0047, 0x004C, + 0x0051, 0x0057, 0x005C, 0x0061, 0x0066, 0x006B, 0x0070, 0x0075, + 0x007A, 0x007F, 0x0084, 0x008A, 0x008F, 0x0094, 0x0099, 0x009E, + 0x00A3, 0x00A8, 0x00AD, 0x00B2, 0x00B7, 0x00BC, 0x00C2, 0x00C7, + 0x00CC, 0x00D1, 0x00D6, 0x00DB, 0x00E0, 0x00E5, 0x00EA, 0x00EF, + 0x00F4, 0x00FA, 0x00FF, 0x0104, 0x0109, 0x010E, 0x0113, 0x0118, + 0x011D, 0x0122, 0x0127, 0x012C, 0x0131, 0x0137, 0x013C, 0x0141, + 0x0146, 0x014B, 0x0150, 0x0155, 0x015A, 0x015F, 0x0164, 0x0169, + 0x016F, 0x0174, 0x0179, 0x017E, 0x0183, 0x0188, 0x018D, 0x0192, + 0x0197, 0x019C, 0x01A1, 0x01A6, 0x01AC, 0x01B1, 0x01B6, 0x01BB, + 0x01C0, 0x01C5, 0x01CA, 0x01CF, 0x01D4, 0x01D9, 0x01DE, 0x01E3, + 0x01E9, 0x01EE, 0x01F3, 0x01F8, 0x01FD, 0x0202, 0x0207, 0x020C, + 0x0211, 0x0216, 0x021B, 0x0220, 0x0226, 0x022B, 0x0230, 0x0235, + 0x023A, 0x023F, 0x0244, 0x0249, 0x024E, 0x0253, 0x0258, 0x025D, + 0x0262, 0x0268, 0x026D, 0x0272, 0x0277, 0x027C, 0x0281, 0x0286, + 0x028B, 0x0290, 0x0295, 0x029A, 0x029F, 0x02A4, 0x02A9, 0x02AF, + 0x02B4, 0x02B9, 0x02BE, 0x02C3, 0x02C8, 0x02CD, 0x02D2, 0x02D7, + 0x02DC, 0x02E1, 0x02E6, 0x02EB, 0x02F0, 0x02F6, 0x02FB, 0x0300, + 0x0305, 0x030A, 0x030F, 0x0314, 0x0319, 0x031E, 0x0323, 0x0328, + 0x032D, 0x0332, 0x0337, 0x033C, 0x0341, 0x0347, 0x034C, 0x0351, + 0x0356, 0x035B, 0x0360, 0x0365, 0x036A, 0x036F, 0x0374, 0x0379, + 0x037E, 0x0383, 0x0388, 0x038D, 0x0392, 0x0397, 0x039C, 0x03A2, + 0x03A7, 0x03AC, 0x03B1, 0x03B6, 0x03BB, 0x03C0, 0x03C5, 0x03CA, + 0x03CF, 0x03D4, 0x03D9, 0x03DE, 0x03E3, 0x03E8, 0x03ED, 0x03F2, + 0x03F7, 0x03FC, 0x0401, 0x0407, 0x040C, 0x0411, 0x0416, 0x041B, + 0x0420, 0x0425, 0x042A, 0x042F, 0x0434, 0x0439, 0x043E, 0x0443, + 0x0448, 0x044D, 0x0452, 0x0457, 0x045C, 0x0461, 0x0466, 0x046B, + 0x0470, 0x0475, 0x047A, 0x047F, 0x0484, 0x0489, 0x048E, 0x0494, + 0x0499, 0x049E, 0x04A3, 0x04A8, 0x04AD, 0x04B2, 0x04B7, 0x04BC, + 0x04C1, 0x04C6, 0x04CB, 0x04D0, 0x04D5, 0x04DA, 0x04DF, 0x04E4, + 0x04E9, 0x04EE, 0x04F3, 0x04F8, 0x04FD, 0x0502, 0x0507, 0x050C, + 0x0511, 0x0516, 0x051B, 0x0520, 0x0525, 0x052A, 0x052F, 0x0534, + 0x0539, 0x053E, 0x0543, 0x0548, 0x054D, 0x0552, 0x0557, 0x055C, + 0x0561, 0x0566, 0x056B, 0x0570, 0x0575, 0x057A, 0x057F, 0x0584, + 0x0589, 0x058E, 0x0593, 0x0598, 0x059D, 0x05A2, 0x05A7, 0x05AC, + 0x05B1, 0x05B6, 0x05BB, 0x05C0, 0x05C5, 0x05CA, 0x05CF, 0x05D4, + 0x05D9, 0x05DE, 0x05E3, 0x05E8, 0x05ED, 0x05F2, 0x05F7, 0x05FC, + 0x0601, 0x0606, 0x060B, 0x0610, 0x0615, 0x061A, 0x061F, 0x0624, + 0x0629, 0x062E, 0x0633, 0x0638, 0x063D, 0x0642, 0x0647, 0x064C, + 0x0651, 0x0656, 0x065B, 0x0660, 0x0665, 0x066A, 0x066E, 0x0673, + 0x0678, 0x067D, 0x0682, 0x0687, 0x068C, 0x0691, 0x0696, 0x069B, + 0x06A0, 0x06A5, 0x06AA, 0x06AF, 0x06B4, 0x06B9, 0x06BE, 0x06C3, + 0x06C8, 0x06CD, 0x06D2, 0x06D7, 0x06DC, 0x06E1, 0x06E5, 0x06EA, + 0x06EF, 0x06F4, 0x06F9, 0x06FE, 0x0703, 0x0708, 0x070D, 0x0712, + 0x0717, 0x071C, 0x0721, 0x0726, 0x072B, 0x0730, 0x0735, 0x0739, + 0x073E, 0x0743, 0x0748, 0x074D, 0x0752, 0x0757, 0x075C, 0x0761, + 0x0766, 0x076B, 0x0770, 0x0775, 0x077A, 0x077E, 0x0783, 0x0788, + 0x078D, 0x0792, 0x0797, 0x079C, 0x07A1, 0x07A6, 0x07AB, 0x07B0, + 0x07B5, 0x07B9, 0x07BE, 0x07C3, 0x07C8, 0x07CD, 0x07D2, 0x07D7, + 0x07DC, 0x07E1, 0x07E6, 0x07EB, 0x07EF, 0x07F4, 0x07F9, 0x07FE, + 0x0803, 0x0808, 0x080D, 0x0812, 0x0817, 0x081C, 0x0820, 0x0825, + 0x082A, 0x082F, 0x0834, 0x0839, 0x083E, 0x0843, 0x0848, 0x084C, + 0x0851, 0x0856, 0x085B, 0x0860, 0x0865, 0x086A, 0x086F, 0x0873, + 0x0878, 0x087D, 0x0882, 0x0887, 0x088C, 0x0891, 0x0896, 0x089A, + 0x089F, 0x08A4, 0x08A9, 0x08AE, 0x08B3, 0x08B8, 0x08BD, 0x08C1, + 0x08C6, 0x08CB, 0x08D0, 0x08D5, 0x08DA, 0x08DF, 0x08E3, 0x08E8, + 0x08ED, 0x08F2, 0x08F7, 0x08FC, 0x0901, 0x0905, 0x090A, 0x090F, + 0x0914, 0x0919, 0x091E, 0x0922, 0x0927, 0x092C, 0x0931, 0x0936, + 0x093B, 0x093F, 0x0944, 0x0949, 0x094E, 0x0953, 0x0958, 0x095C, + 0x0961, 0x0966, 0x096B, 0x0970, 0x0975, 0x0979, 0x097E, 0x0983, + 0x0988, 0x098D, 0x0992, 0x0996, 0x099B, 0x09A0, 0x09A5, 0x09AA, + 0x09AE, 0x09B3, 0x09B8, 0x09BD, 0x09C2, 0x09C6, 0x09CB, 0x09D0, + 0x09D5, 0x09DA, 0x09DE, 0x09E3, 0x09E8, 0x09ED, 0x09F2, 0x09F6, + 0x09FB, 0x0A00, 0x0A05, 0x0A0A, 0x0A0E, 0x0A13, 0x0A18, 0x0A1D, + 0x0A22, 0x0A26, 0x0A2B, 0x0A30, 0x0A35, 0x0A39, 0x0A3E, 0x0A43, + 0x0A48, 0x0A4D, 0x0A51, 0x0A56, 0x0A5B, 0x0A60, 0x0A64, 0x0A69, + 0x0A6E, 0x0A73, 0x0A77, 0x0A7C, 0x0A81, 0x0A86, 0x0A8B, 0x0A8F, + 0x0A94, 0x0A99, 0x0A9E, 0x0AA2, 0x0AA7, 0x0AAC, 0x0AB1, 0x0AB5, + 0x0ABA, 0x0ABF, 0x0AC4, 0x0AC8, 0x0ACD, 0x0AD2, 0x0AD7, 0x0ADB, + 0x0AE0, 0x0AE5, 0x0AE9, 0x0AEE, 0x0AF3, 0x0AF8, 0x0AFC, 0x0B01, + 0x0B06, 0x0B0B, 0x0B0F, 0x0B14, 0x0B19, 0x0B1E, 0x0B22, 0x0B27, + 0x0B2C, 0x0B30, 0x0B35, 0x0B3A, 0x0B3F, 0x0B43, 0x0B48, 0x0B4D, + 0x0B51, 0x0B56, 0x0B5B, 0x0B60, 0x0B64, 0x0B69, 0x0B6E, 0x0B72, + 0x0B77, 0x0B7C, 0x0B80, 0x0B85, 0x0B8A, 0x0B8F, 0x0B93, 0x0B98, + 0x0B9D, 0x0BA1, 0x0BA6, 0x0BAB, 0x0BAF, 0x0BB4, 0x0BB9, 0x0BBD, + 0x0BC2, 0x0BC7, 0x0BCB, 0x0BD0, 0x0BD5, 0x0BD9, 0x0BDE, 0x0BE3, + 0x0B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49, 0x0E4E, 0x0E52, + 0x0E56, 0x0E5B, 0x0E5F, 0x0E64, 0x0E68, 0x0E6D, 0x0E71, 0x0E76, + 0x0E7A, 0x0E7F, 0x0E83, 0x0E88, 0x0E8C, 0x0E91, 0x0E95, 0x0E9A, + 0x0E9E, 0x0EA3, 0x0EA7, 0x0EAC, 0x0EB0, 0x0EB4, 0x0EB9, 0x0EBD, + 0x0EC2, 0x0EC6, 0x0ECB, 0x0ECF, 0x0ED4, 0x0ED8, 0x0EDC, 0x0EE1, + 0x0EE5, 0x0EEA, 0x0EEE, 0x0EF3, 0x0EF7, 0x0EFC, 0x0F00, 0x0F04, + 0x0F09, 0x0F0D, 0x0F12, 0x0F16, 0x0F1B, 0x0F1F, 0x0F23, 0x0F28, + 0x0F2C, 0x0F31, 0x0F35, 0x0F3A, 0x0F3E, 0x0F42, 0x0F47, 0x0F4B, + 0x0F50, 0x0F54, 0x0F58, 0x0F5D, 0x0F61, 0x0F66, 0x0F6A, 0x0F6E, + 0x0F73, 0x0F77, 0x0F7C, 0x0F80, 0x0F84, 0x0F89, 0x0F8D, 0x0F91, + 0x0F96, 0x0F9A, 0x0F9F, 0x0FA3, 0x0FA7, 0x0FAC, 0x0FB0, 0x0FB5, + 0x0FB9, 0x0FBD, 0x0FC2, 0x0FC6, 0x0FCA, 0x0FCF, 0x0FD3, 0x0FD7, + 0x0FDC, 0x0FE0, 0x0FE5, 0x0FE9, 0x0FED, 0x0FF2, 0x0FF6, 0x0FFA, + 0x0FFF, 0x1003, 0x1007, 0x100C, 0x1010, 0x1014, 0x1019, 0x101D, + 0x1021, 0x1026, 0x102A, 0x102E, 0x1033, 0x1037, 0x103B, 0x1040, + 0x1044, 0x1048, 0x104D, 0x1051, 0x1055, 0x105A, 0x105E, 0x1062, + 0x1067, 0x106B, 0x106F, 0x1073, 0x1078, 0x107C, 0x1080, 0x1085, + 0x1089, 0x108D, 0x1092, 0x1096, 0x109A, 0x109E, 0x10A3, 0x10A7, + 0x10AB, 0x10B0, 0x10B4, 0x10B8, 0x10BC, 0x10C1, 0x10C5, 0x10C9, + 0x10CE, 0x10D2, 0x10D6, 0x10DA, 0x10DF, 0x10E3, 0x10E7, 0x10EB, + 0x10F0, 0x10F4, 0x10F8, 0x10FD, 0x1101, 0x1105, 0x1109, 0x110E, + 0x1112, 0x1116, 0x111A, 0x111F, 0x1123, 0x1127, 0x112B, 0x1130, + 0x1134, 0x1138, 0x113C, 0x1140, 0x1145, 0x1149, 0x114D, 0x1151, + 0x1156, 0x115A, 0x115E, 0x1162, 0x1166, 0x116B, 0x116F, 0x1173, + 0x1177, 0x117C, 0x1180, 0x1184, 0x1188, 0x118C, 0x1191, 0x1195, + 0x1199, 0x119D, 0x11A1, 0x11A6, 0x11AA, 0x11AE, 0x11B2, 0x11B6, + 0x11BB, 0x11BF, 0x11C3, 0x11C7, 0x11CB, 0x11CF, 0x11D4, 0x11D8, + 0x11DC, 0x11E0, 0x11E4, 0x11E9, 0x11ED, 0x11F1, 0x11F5, 0x11F9, + 0x11FD, 0x1202, 0x1206, 0x120A, 0x120E, 0x1212, 0x1216, 0x121A, + 0x121F, 0x1223, 0x1227, 0x122B, 0x122F, 0x1233, 0x1237, 0x123C, + 0x1240, 0x1244, 0x1248, 0x124C, 0x1250, 0x1254, 0x1259, 0x125D, + 0x1261, 0x1265, 0x1269, 0x126D, 0x1271, 0x1275, 0x127A, 0x127E, + 0x1282, 0x1286, 0x128A, 0x128E, 0x1292, 0x1296, 0x129A, 0x129F, + 0x12A3, 0x12A7, 0x12AB, 0x12AF, 0x12B3, 0x12B7, 0x12BB, 0x12BF, + 0x12C3, 0x12C7, 0x12CC, 0x12D0, 0x12D4, 0x12D8, 0x12DC, 0x12E0, + 0x12E4, 0x12E8, 0x12EC, 0x12F0, 0x12F4, 0x12F8, 0x12FC, 0x1301, + 0x1305, 0x1309, 0x130D, 0x1311, 0x1315, 0x1319, 0x131D, 0x1321, + 0x1325, 0x1329, 0x132D, 0x1331, 0x1335, 0x1339, 0x133D, 0x1341, + 0x1345, 0x1349, 0x134D, 0x1351, 0x1355, 0x135A, 0x135E, 0x1362, + 0x1366, 0x136A, 0x136E, 0x1372, 0x1376, 0x137A, 0x137E, 0x1382, + 0x1386, 0x138A, 0x138E, 0x1392, 0x1396, 0x139A, 0x139E, 0x13A2, + 0x13A6, 0x13AA, 0x13AE, 0x13B2, 0x13B6, 0x13BA, 0x13BE, 0x13C2, + 0x13C6, 0x13CA, 0x13CE, 0x13D2, 0x13D6, 0x13DA, 0x13DE, 0x13E2, + 0x13E6, 0x13E9, 0x13ED, 0x13F1, 0x13F5, 0x13F9, 0x13FD, 0x1401, + 0x1405, 0x1409, 0x140D, 0x1411, 0x1415, 0x1419, 0x141D, 0x1421, + 0x1425, 0x1429, 0x142D, 0x1431, 0x1435, 0x1439, 0x143D, 0x1440, + 0x1444, 0x1448, 0x144C, 0x1450, 0x1454, 0x1458, 0x145C, 0x1460, + 0x1464, 0x1468, 0x146C, 0x1470, 0x1473, 0x1477, 0x147B, 0x147F, + 0x1483, 0x1487, 0x148B, 0x148F, 0x1493, 0x1497, 0x149B, 0x149E, + 0x14A2, 0x14A6, 0x14AA, 0x14AE, 0x14B2, 0x14B6, 0x14BA, 0x14BE, + 0x14C1, 0x14C5, 0x14C9, 0x14CD, 0x14D1, 0x14D5, 0x14D9, 0x14DD, + 0x14E0, 0x14E4, 0x14E8, 0x14EC, 0x14F0, 0x14F4, 0x14F8, 0x14FB, + 0x14FF, 0x1503, 0x1507, 0x150B, 0x150F, 0x1513, 0x1516, 0x151A, + 0x151E, 0x1522, 0x1526, 0x152A, 0x152D, 0x1531, 0x1535, 0x1539, + 0x153D, 0x1541, 0x1544, 0x1548, 0x154C, 0x1550, 0x1554, 0x1558, + 0x155B, 0x155F, 0x1563, 0x1567, 0x156B, 0x156E, 0x1572, 0x1576, + 0x157A, 0x157E, 0x1581, 0x1585, 0x1589, 0x158D, 0x1591, 0x1594, + 0x1598, 0x159C, 0x15A0, 0x15A4, 0x15A7, 0x15AB, 0x15AF, 0x15B3, + 0x15B7, 0x15BA, 0x15BE, 0x15C2, 0x15C6, 0x15C9, 0x15CD, 0x15D1, + 0x15D5, 0x15D8, 0x15DC, 0x15E0, 0x15E4, 0x15E8, 0x15EB, 0x15EF, + 0x15F3, 0x15F7, 0x15FA, 0x15FE, 0x1602, 0x1606, 0x1609, 0x160D, + 0x1611, 0x1614, 0x1618, 0x161C, 0x1620, 0x1623, 0x1627, 0x162B, + 0x162F, 0x1632, 0x1636, 0x163A, 0x163E, 0x1641, 0x1645, 0x1649, + 0x164C, 0x1650, 0x1654, 0x1658, 0x165B, 0x165F, 0x1663, 0x1666, + 0x166A, 0x166E, 0x1671, 0x1675, 0x1679, 0x167D, 0x1680, 0x1684, + 0x1688, 0x168B, 0x168F, 0x1693, 0x1696, 0x169A, 0x169E, 0x16A1, + 0x16A5, 0x16A9, 0x16AC, 0x16B0, 0x16B4, 0x16B7, 0x16BB, 0x16BF, + 0x16C2, 0x16C6, 0x16CA, 0x16CD, 0x16D1, 0x16D5, 0x16D8, 0x16DC, + 0x16E0, 0x16E3, 0x16E7, 0x16EB, 0x16EE, 0x16F2, 0x16F6, 0x16F9, + 0x16FD, 0x1700, 0x1704, 0x1708, 0x170B, 0x170F, 0x1713, 0x1716, + 0x171A, 0x171D, 0x1721, 0x1725, 0x1728, 0x172C, 0x1730, 0x1733, + 0x1737, 0x173A, 0x173E, 0x1742, 0x1745, 0x1749, 0x174C, 0x1750, + 0x1754, 0x1757, 0x175B, 0x175E, 0x1762, 0x1766, 0x1769, 0x176D, + 0x1770, 0x1774, 0x1778, 0x177B, 0x177F, 0x1782, 0x1786, 0x1789, + 0x178D, 0x1791, 0x1794, 0x1798, 0x179B, 0x179F, 0x17A2, 0x17A6, + 0x17AA, 0x17AD, 0x17B1, 0x17B4, 0x17B8, 0x17BB, 0x17BF, 0x17C2, + 0x17C6, 0x17C9, 0x17CD, 0x17D1, 0x17D4, 0x17D8, 0x17DB, 0x17DF, + 0x17E2, 0x17E6, 0x17E9, 0x17ED, 0x17F0, 0x17F4, 0x17F7, 0x17FB, + 0x17FE, 0x1802, 0x1806, 0x1809, 0x180D, 0x1810, 0x1814, 0x1817, + 0x181B, 0x181E, 0x1822, 0x1825, 0x1829, 0x182C, 0x1830, 0x1833, + 0x1837, 0x183A, 0x183E, 0x1841, 0x1845, 0x1848, 0x184C, 0x184F, + 0x1853, 0x1856, 0x185A, 0x185D, 0x1860, 0x1864, 0x1867, 0x186B, + 0x186E, 0x1872, 0x1875, 0x1879, 0x187C, 0x1880, 0x1883, 0x1887, + 0x188A, 0x188E, 0x1891, 0x1894, 0x1898, 0x189B, 0x189F, 0x18A2, + 0x18A6, 0x18A9, 0x18AD, 0x18B0, 0x18B3, 0x18B7, 0x18BA, 0x18BE, + 0x18C1, 0x18C5, 0x18C8, 0x18CC, 0x18CF, 0x18D2, 0x18D6, 0x18D9, + 0x18DD, 0x18E0, 0x18E3, 0x18E7, 0x18EA, 0x18EE, 0x18F1, 0x18F5, + 0x18F8, 0x18FB, 0x18FF, 0x1902, 0x1906, 0x1909, 0x190C, 0x1910, + 0x1913, 0x1917, 0x191A, 0x191D, 0x1921, 0x1924, 0x1928, 0x192B, + 0x192E, 0x1932, 0x1935, 0x1938, 0x193C, 0x193F, 0x1943, 0x1946, + 0x1949, 0x194D, 0x1950, 0x1953, 0x1957, 0x195A, 0x195D, 0x1961, + 0x1964, 0x1968, 0x196B, 0x196E, 0x1972, 0x1975, 0x1978, 0x197C, + 0x197F, 0x1982, 0x1986, 0x1989, 0x198C, 0x1990, 0x1993, 0x1996, + 0x199A, 0x199D, 0x19A0, 0x19A4, 0x19A7, 0x19AA, 0x19AE, 0x19B1, + 0x19B4, 0x19B8, 0x19BB, 0x19BE, 0x19C2, 0x19C5, 0x19C8, 0x19CC, + 0x19CF, 0x19D2, 0x19D5, 0x19D9, 0x19DC, 0x19DF, 0x19E3, 0x19E6, + 0x19E9, 0x19ED, 0x19F0, 0x19F3, 0x19F6, 0x19F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 0x1FFD, + 0x2000, 0x2000, +}; + +const int32 atanOctant[] = { + 0, -16384, -65535, 49152, -32768, 16384, 32768, -49152 +}; + +int32 phd_atan(int32 x, int32 y) +{ + if (x == 0 && y == 0) + return 0; + + int32 o = 0; + + if (x < 0) { + o += 4; + x = -x; + } + + if (y < 0) { + o += 2; + y = -y; + } + + if (y > x) { + o++; + swap(x, y); + } + + return abs(atanTable[(y << 11) / x] + atanOctant[o]); //@DIV +} + +uint32 phd_sqrt(uint32 x) +{ + uint32 m = 0x40000000; + uint32 y = 0; + uint32 z = 0; + + do { + y += m; + + if (y > x) { + y = z; + } else { + x -= y; + y = z + m; + } + + z = y >> 1; + } while (m >>= 2); + + return y; +} + +void anglesFromVector(int32 x, int32 y, int32 z, int16 &angleX, int16 &angleY) +{ + angleY = phd_atan(z, x); + angleX = phd_atan(phd_sqrt(x * x + z * z), -y); +} + +bool boxIntersect(const AABBi &a, const AABBi &b) +{ + return !(a.maxX <= b.minX || a.minX >= b.maxX || + a.maxY <= b.minY || a.minY >= b.maxY || + a.maxZ <= b.minZ || a.minZ >= b.maxZ); +} + +bool boxContains(const AABBi &a, const vec3i &p) +{ + return !(a.minX > p.x || a.maxX < p.x || + a.minY > p.y || a.maxY < p.y || + a.minZ > p.z || a.maxZ < p.z); +} + +vec3i boxPushOut(const AABBi &a, const AABBi &b) +{ + int32 ax = b.maxX - a.minX; + int32 bx = a.maxX - b.minX; + int32 az = b.maxZ - a.minZ; + int32 bz = a.maxZ - b.minZ; + + vec3i p; + p.y = 0; + p.x = (ax < bx) ? -ax : bx; + p.z = (az < bz) ? -az : bz; + + return p; +} + +/* +#ifdef USE_DIV_TABLE +void initDivTable() +{ + uint16 divTable[DIV_TABLE_SIZE]; + + divTable[0] = 0xFFFF; + divTable[1] = 0xFFFF; + for (uint32 i = 2; i < DIV_TABLE_SIZE; i++) { + divTable[i] = (1 << 16) / i; + } + + ASSERT((DIV_TABLE_SIZE & 8) == 0) + + printf("const uint16 divTable[DIV_TABLE_SIZE] = {\n"); + for (int i = 0; i < DIV_TABLE_SIZE; i += 8) { + printf(" 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X,\n", + divTable[i + 0], divTable[i + 1], divTable[i + 2], divTable[i + 3], + divTable[i + 4], divTable[i + 5], divTable[i + 6], divTable[i + 7]); + } + printf("};\n"); +} +#endif +*/ + +X_INLINE int16 lerpAngle(int16 a, int16 b, int32 t) +{ + int32 d = b - a; + + if (d > 0x8000) { + d -= 0x10000; + } else if (d < -0x8000) { + d += 0x10000; + } + + return a + ((d * t) >> FIXED_SHIFT); +} + +X_INLINE int16 lerpAngleSlow(int16 a, int16 b, int32 mul, int32 div) +{ + int32 d = b - a; + + if (d > 0x8000) { + d -= 0x10000; + } else if (d < -0x8000) { + d += 0x10000; + } + + return a + d * mul / div; +} + +#ifndef USE_ASM +void matrixPush_c() +{ + ASSERT(gMatrixPtr - gMatrixStack < MAX_MATRICES); + gMatrixPtr[1] = gMatrixPtr[0]; + gMatrixPtr++; +} + +void matrixSetIdentity_c() +{ + Matrix &m = matrixGet(); + + m.e00 = 0x4000; + m.e01 = 0; + m.e02 = 0; + m.e03 = 0; + + m.e10 = 0; + m.e11 = 0x4000; + m.e12 = 0; + m.e13 = 0; + + m.e20 = 0; + m.e21 = 0; + m.e22 = 0x4000; + m.e23 = 0; +} + +void matrixSetBasis_c(Matrix &dst, const Matrix &src) +{ + dst.e00 = src.e00; + dst.e01 = src.e01; + dst.e02 = src.e02; + + dst.e10 = src.e10; + dst.e11 = src.e11; + dst.e12 = src.e12; + + dst.e10 = src.e10; + dst.e11 = src.e11; + dst.e12 = src.e12; +} + +#define LERP_1_2(a, b) a = (b + a) >> 1 +#define LERP_1_3(a, b) a = a + (b - a) / 3 +#define LERP_2_3(a, b) a = b - (b - a) / 3 +#define LERP_1_4(a, b) a = a + ((b - a) >> 2) +#define LERP_3_4(a, b) a = b - ((b - a) >> 2) +#define LERP_1_5(a, b) a = a + (b - a) / 5 +#define LERP_2_5(a, b) a = a + ((b - a) << 1) / 5 +#define LERP_3_5(a, b) a = b - ((b - a) << 1) / 5 +#define LERP_4_5(a, b) a = b - (b - a) / 5 +#define LERP_SLOW(a, b) a = a + ((b - a) * t >> 8) + +#define LERP_ROW(lerp_func, a, b, row) \ + lerp_func(a.e##row##0, b.e##row##0); \ + lerp_func(a.e##row##1, b.e##row##1); \ + lerp_func(a.e##row##2, b.e##row##2); \ + lerp_func(a.e##row##3, b.e##row##3); + +#define LERP_MATRIX(lerp_func) \ + LERP_ROW(lerp_func, m, n, 0); \ + LERP_ROW(lerp_func, m, n, 1); \ + LERP_ROW(lerp_func, m, n, 2); + +void matrixLerp_c(const Matrix &n, int32 pmul, int32 pdiv) +{ + Matrix &m = matrixGet(); + + if ((pdiv == 2) || ((pdiv == 4) && (pmul == 2))) { + LERP_MATRIX(LERP_1_2); + } else if (pdiv == 4) { + + if (pmul == 1) { + LERP_MATRIX(LERP_1_4); + } else { + LERP_MATRIX(LERP_3_4); + } + + } else { + int32 t = pmul * FixedInvU(pdiv) >> 8; + LERP_MATRIX(LERP_SLOW); + } +} + +#define MATRIX_TRANS(x,y,z)\ + Matrix &m = matrixGet();\ + int32 tx = DP33(m.e00, m.e01, m.e02, x, y, z);\ + int32 ty = DP33(m.e10, m.e11, m.e12, x, y, z);\ + int32 tz = DP33(m.e20, m.e21, m.e22, x, y, z); + +void matrixTranslateRel_c(int32 x, int32 y, int32 z) +{ + MATRIX_TRANS(x, y, z); + m.e03 += tx >> MATRIX_FIXED_SHIFT; + m.e13 += ty >> MATRIX_FIXED_SHIFT; + m.e23 += tz >> MATRIX_FIXED_SHIFT; +} + +void matrixTranslateAbs_c(int32 x, int32 y, int32 z) +{ + x -= gCameraViewPos.x; + y -= gCameraViewPos.y; + z -= gCameraViewPos.z; + MATRIX_TRANS(x, y, z); + m.e03 = tx >> MATRIX_FIXED_SHIFT; + m.e13 = ty >> MATRIX_FIXED_SHIFT; + m.e23 = tz >> MATRIX_FIXED_SHIFT; +} + +void matrixTranslateSet_c(int32 x, int32 y, int32 z) +{ + MATRIX_TRANS(x, y, z); + m.e03 = tx >> MATRIX_FIXED_SHIFT; + m.e13 = ty >> MATRIX_FIXED_SHIFT; + m.e23 = tz >> MATRIX_FIXED_SHIFT; +} + +void matrixRotateX_c(int32 angle) +{ + int32 s, c; + sincos(angle, s, c); + + Matrix &m = matrixGet(); + X_ROTXY(m.e02, m.e01, s, c); + X_ROTXY(m.e12, m.e11, s, c); + X_ROTXY(m.e22, m.e21, s, c); +} + +void matrixRotateY_c(int32 angle) +{ + int32 s, c; + sincos(angle, s, c); + + Matrix &m = matrixGet(); + X_ROTXY(m.e00, m.e02, s, c); + X_ROTXY(m.e10, m.e12, s, c); + X_ROTXY(m.e20, m.e22, s, c); +} + +void matrixRotateZ_c(int32 angle) +{ + int32 s, c; + sincos(angle, s, c); + + Matrix &m = matrixGet(); + X_ROTXY(m.e01, m.e00, s, c); + X_ROTXY(m.e11, m.e10, s, c); + X_ROTXY(m.e21, m.e20, s, c); +} + +void matrixRotateYQ_c(int32 quadrant) +{ + if (quadrant == 2) + return; + + Matrix &m = matrixGet(); + + if (quadrant == 0) { + m.e00 = -m.e00; + m.e10 = -m.e10; + m.e20 = -m.e20; + m.e02 = -m.e02; + m.e12 = -m.e12; + m.e22 = -m.e22; + } else if (quadrant == 1) { + int32 e0 = m.e02; + int32 e1 = m.e12; + int32 e2 = m.e22; + + m.e02 = -m.e00; + m.e12 = -m.e10; + m.e22 = -m.e20; + + m.e00 = e0; + m.e10 = e1; + m.e20 = e2; + } else { + int32 e0 = m.e02; + int32 e1 = m.e12; + int32 e2 = m.e22; + + m.e02 = m.e00; + m.e12 = m.e10; + m.e22 = m.e20; + + m.e00 = -e0; + m.e10 = -e1; + m.e20 = -e2; + } +} + +void matrixRotateYXZ_c(int32 angleX, int32 angleY, int32 angleZ) +{ + if (angleY) matrixRotateY(angleY); + if (angleX) matrixRotateX(angleX); + if (angleZ) matrixRotateZ(angleZ); +} + +void matrixFrame_c(const void* pos, const void* angles) +{ + int16 aX, aY, aZ; + DECODE_ANGLES(*(uint32*)angles, aX, aY, aZ); + + uint32 xy = ((uint32*)pos)[0]; + uint32 zu = ((uint32*)pos)[1]; + +#ifdef CPU_BIG_ENDIAN + int32 posX = int16(xy >> 16); + int32 posY = int16(xy & 0xFFFF); + int32 posZ = int16(zu >> 16); +#else + int32 posX = int16(xy & 0xFFFF); + int32 posY = int16(xy >> 16); + int32 posZ = int16(zu & 0xFFFF); +#endif + + matrixTranslateRel(posX, posY, posZ); + matrixRotateYXZ(aX, aY, aZ); +} + +void boxTranslate_c(AABBi &box, int32 x, int32 y, int32 z) +{ + box.minX += x; + box.maxX += x; + box.minY += y; + box.maxY += y; + box.minZ += z; + box.maxZ += z; +} + +void boxRotateYQ_c(AABBi &box, int32 quadrant) +{ + if (quadrant == 2) + return; + + int32 minX = box.minX; + int32 maxX = box.maxX; + int32 minZ = box.minZ; + int32 maxZ = box.maxZ; + + if (quadrant == 3) { + box.minX = minZ; + box.maxX = maxZ; + box.minZ = -maxX; + box.maxZ = -minX; + } else if (quadrant == 1) { + box.minX = -maxZ; + box.maxX = -minZ; + box.minZ = minX; + box.maxZ = maxX; + } else if (quadrant == 0) { + box.minX = -maxX; + box.maxX = -minX; + box.minZ = -maxZ; + box.maxZ = -minZ; + } +} +#endif + +void matrixFrameLerp(const void* pos, const void* anglesA, const void* anglesB, int32 delta, int32 rate) +{ + int16 aX, aY, aZ; + int16 bX, bY, bZ; + + DECODE_ANGLES(*(uint32*)anglesA, aX, aY, aZ); + DECODE_ANGLES(*(uint32*)anglesB, bX, bY, bZ); + + uint32 xy = ((uint32*)pos)[0]; + uint32 zu = ((uint32*)pos)[1]; + +#ifdef CPU_BIG_ENDIAN + int32 posX = int16(xy >> 16); + int32 posY = int16(xy & 0xFFFF); + int32 posZ = int16(zu >> 16); +#else + int32 posX = int16(xy & 0xFFFF); + int32 posY = int16(xy >> 16); + int32 posZ = int16(zu & 0xFFFF); +#endif + + matrixTranslateRel(posX, posY, posZ); + + matrixPush(); + matrixRotateYXZ(bX, bY, bZ); + matrixPop(); + + matrixRotateYXZ(aX, aY, aZ); + + matrixLerp(*(gMatrixPtr + 1), delta, rate); +} + +void matrixSetView(const vec3i &pos, int32 angleX, int32 angleY) +{ + int32 sx, cx; + int32 sy, cy; + + sincos(angleX, sx, cx); + sincos(angleY, sy, cy); + + Matrix &m = matrixGet(); + + m.e00 = cy; + m.e01 = 0; + m.e02 = -sy; + m.e03 = 0; + + m.e10 = (sx * sy) >> FIXED_SHIFT; + m.e11 = cx; + m.e12 = (sx * cy) >> FIXED_SHIFT; + m.e13 = 0; + + m.e20 = (cx * sy) >> FIXED_SHIFT; + m.e21 = -sx; + m.e22 = (cx * cy) >> FIXED_SHIFT; + m.e23 = 0; + + gCameraViewPos = pos; +} + +void CollisionInfo::setSide(CollisionInfo::SideType st, int32 floor, int32 ceiling) +{ + SlantType slantType; + + if (FD_SLANT_X(gLastFloorSlant) == 0 && FD_SLANT_Z(gLastFloorSlant) == 0) { + slantType = SLANT_NONE; + } else if (abs(FD_SLANT_X(gLastFloorSlant)) < 3 && abs(FD_SLANT_Z(gLastFloorSlant)) < 3) { + slantType = SLANT_LOW; + } else { + slantType = SLANT_HIGH; + } + + if (st != ST_MIDDLE) { + if (stopOnSlant && floor < 0 && slantType == SLANT_HIGH) { + floor = -0x7FFF; + } else if (stopOnSlant && floor > 0 && slantType == SLANT_HIGH) { + floor = 512; + }/* TODO lava else if (stopOnLava && floor > 0 && trigger && FloorData(*(uint16*)trigger).cmd.func == FloorData::LAVA) { + floor = 512; + }*/ + } + + Side *s = &m + st; + s->slantType = slantType; + s->floor = floor; + s->ceiling = ceiling; +} + +void palGamma(const uint16* srcPal, uint16* dstPal, int32 value) +{ + for (int32 i = 0; i < 256; i++) + { + uint16 src = *srcPal++; + int32 r = 31 & (src); + int32 g = 31 & (src >> 5); + int32 b = 31 & (src >> 10); + + r = X_MIN(31, r + (((r * r >> 2) - r) * value >> 10)); + g = X_MIN(31, g + (((g * g >> 2) - g) * value >> 10)); + b = X_MIN(31, b + (((b * b >> 2) - b) * value >> 10)); + + *dstPal++ = r | (g << 5) | (b << 10); + } +} + +void palBright(const uint16* srcPal, uint16* dstPal, int32 value) +{ + value >>= 2; + + for (int32 i = 0; i < 256; i++) + { + uint16 src = *srcPal++; + int32 r = 31 & (src); + int32 g = 31 & (src >> 5); + int32 b = 31 & (src >> 10); + + r = X_CLAMP(r + value, 0, 31); + g = X_CLAMP(g + value, 0, 31); + b = X_CLAMP(b + value, 0, 31); + + *dstPal++ = r | (g << 5) | (b << 10); + } +} + +void palGrayRemap(uint8* data, int32 size) +{ + static const uint8 grad[8] = { + 1, 22, 21, 20, 19, 18, 17, 33 + }; + + uint8 remap[256]; + + for (int32 i = 0; i < 256; i++) + { + uint16 p = level.palette[i]; + uint8 r = (p & 31); + uint8 g = ((p >> 5) & 31); + uint8 b = ((p >> 10) & 31); + + int32 lum = (r * 77 + g * 150 + b * 29) >> (8 + 2); + + remap[i] = grad[lum]; + } + + for (int32 i = 0; i < size; i++) + { + data[i] = remap[data[i]]; + } +} + +void palSet(const uint16* palette, int32 gamma, int32 bright) +{ + const uint16* pal = palette; + + if (gamma || bright) + { + //STATIC_ASSERT(sizeof(gSpheres) >= 512); + uint16* tmp = (uint16*)gSpheres; + + if (gamma) { + palGamma(pal, tmp, gamma); + pal = tmp; + } + + if (bright) { + palBright(pal, tmp, bright); + pal = tmp; + } + } + + osSetPalette(pal); +} + +void dmaFill(void* dst, uint8 value, uint32 count) +{ + ASSERT((count & 3) == 0); +#if defined(__GBA__) + vu32 v = value; + dma3_fill(dst, v, count); +#elif defined(__32X__) + fast_memset(dst, value, count >> 2); +#else + memset(dst, value, count); +#endif +} + +#ifndef __NDS__ +void dmaCopy(const void* src, void* dst, uint32 size) +{ + ASSERT((size & 3) == 0); +#if defined(__GBA__) + dma3_cpy(dst, src, size); +#elif defined(__32X__) + fast_memcpy(dst, src, size >> 2); +#else + memcpy(dst, src, size); +#endif +} + +#endif diff --git a/src/fixed/common.h b/src/fixed/common.h new file mode 100644 index 00000000..a7d39f1e --- /dev/null +++ b/src/fixed/common.h @@ -0,0 +1,3011 @@ +#ifndef H_COMMON +#define H_COMMON +//#define STATIC_ITEMS +//#define PROFILING +#ifdef PROFILING + #define STATIC_ITEMS + #define PROFILE_FRAMETIME +// #define PROFILE_SOUNDTIME +#endif + +// supported formats +// level +#define LVL_FMT_PHD (1 << 0) +#define LVL_FMT_PSX (1 << 1) +#define LVL_FMT_SAT (1 << 2) +#define LVL_FMT_TR2 (1 << 3) +#define LVL_FMT_TR4 (1 << 4) +#define LVL_FMT_PKD (1 << 5) +// video +#define FMV_FMT_RPL (1 << 6) +#define FMV_FMT_STR (1 << 7) +#define FMV_FMT_MP1 (1 << 8) +// audio +#define SND_FMT_PCM (1 << 9) +#define SND_FMT_ADPCM (1 << 10) +#define SND_FMT_IMA (1 << 11) +#define SND_FMT_VAG (1 << 12) +#define SND_FMT_XA (1 << 13) +#define SND_FMT_OGG (1 << 14) +#define SND_FMT_MP3 (1 << 15) + +#define FIXED_SHIFT 14 + +#if defined(__WIN32__) + #define USE_DIV_TABLE + #define MODEHW + #define GAPI_GL1 + + extern int FRAME_WIDTH; + extern int FRAME_HEIGHT; + extern float FRAME_PERSP; + + #define USE_FMT (LVL_FMT_PHD) + + #define _CRT_SECURE_NO_WARNINGS + #include +#elif defined(__GBA_WIN__) + #define USE_DIV_TABLE + + #define MODE4 + #define FRAME_WIDTH 240 + #define FRAME_HEIGHT 160 + + #define USE_FMT (LVL_FMT_PKD) + + #define _CRT_SECURE_NO_WARNINGS + #include +#elif defined(__GBA__) + #define USE_DIV_TABLE + #define ROM_READ + #define USE_ASM + #define ALIGNED_LIGHTMAP + + #define MODE4 + #define FRAME_WIDTH 240 + #define FRAME_HEIGHT 160 + + #define USE_FMT (LVL_FMT_PKD) + #define USE_VRAM_MESH // experimental + //#define USE_VRAM_ROOM // experimental + + #include +#elif defined(__NDS__) + #define USE_DIV_TABLE + + #define MODEHW + #define FRAME_WIDTH 256 + #define FRAME_HEIGHT 192 + + #define USE_FMT (LVL_FMT_PSX) + + #include + #include + #include +#elif defined(__TNS__) + #define USE_DIV_TABLE + + #define MODE13 + #define FRAME_WIDTH 320 + #define FRAME_HEIGHT 240 + + #define USE_FMT (LVL_FMT_PKD) + + #include +#elif defined(__DOS__) + #define USE_DIV_TABLE + + #define MODE13 + #define FRAME_WIDTH 320 + #define FRAME_HEIGHT 200 + + #define USE_FMT (LVL_FMT_PKD) + + #include + #include + #include + #include + #include +#elif defined(__3DO__) + #define USE_DIV_TABLE // 4k of DRAM + #define CPU_BIG_ENDIAN + #define USE_ASM + #define F16_SHIFT 2 + + #define MODEHW + #define FRAME_WIDTH 320 + #define FRAME_HEIGHT 240 + + #define USE_FMT (LVL_FMT_PKD) + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#elif defined(__32X__) + #define USE_DIV_TABLE + #define CPU_BIG_ENDIAN + #define ROM_READ + #define TEX_2PX + #define ALIGNED_LIGHTMAP + #define USE_MATRIX_INT16 + #define F16_SHIFT 2 + + #define MODE13 + #define FRAME_WIDTH 320 + #define FRAME_HEIGHT 224 + + #define USE_FMT (LVL_FMT_PKD) + + #include "32x.h" + + enum MarsCmd { + MARS_CMD_NONE = 0, + MARS_CMD_CLEAR, + MARS_CMD_FLUSH + }; +#else + #error unsupported platform +#endif + +#ifdef _DEBUG + #if defined(__WIN32__) + #include + inline void LOG(const char* format, ...) + { + char str[1024]; + va_list arglist; + va_start(arglist, format); + _vsnprintf(str, 1024, format, arglist); + va_end(arglist); + OutputDebugStringA(str); + } + #else + #define LOG(...) printf(__VA_ARGS__) + #endif +#else + #define LOG() +#endif + +#if !defined(__3DO__) + #include +#endif + +#include "stdio.h" // TODO_3DO armcpp bug? + +#include +#include + +#ifndef USE_FMT + #define USE_FMT (LVL_FMT_PHD | LVL_FMT_PSX | LVL_FMT_SAT | LVL_FMT_TR2 | LVL_FMT_TR4) +#endif + +// Optimization flags ========================================================= +#ifdef __GBA__ +// hide dead enemies after a while to reduce the number of polygons on the screen + #define HIDE_CORPSES (30*10) // 10 sec +// replace trap flor geometry by two flat quads in the static state + #define LOD_TRAP_FLOOR +// disable some plants environment to reduce overdraw of transparent geometry + #define NO_STATIC_MESH_PLANTS +// the maximum of active enemies + #define MAX_ENEMIES 3 +// visibility distance + #define VIEW_DIST (10 << 10) +// skip collideSpheres for enemies + #define FAST_HITMASK +#endif + +#ifdef __3DO__ +// hide dead enemies after a while to reduce the number of polygons on the screen + #define HIDE_CORPSES (30*10) // 10 sec +// replace trap flor geometry by two flat quads in the static state + #define LOD_TRAP_FLOOR +// disable matrix interpolation + //#define NO_ANIM_LERP +// the maximum navigation iterations per simulation tick + #define NAV_STEPS 1 +// the maximum of active enemies + #define MAX_ENEMIES 3 +// set the maximum number of simultaneously played channels + #define SND_CHANNELS 4 +// visibility distance + #define VIEW_DIST (10 << 10) +// skip collideSpheres for enemies + #define FAST_HITMASK +#endif + +#ifdef __32X__ +// hide dead enemies after a while to reduce the number of polygons on the screen + #define HIDE_CORPSES (30*10) // 10 sec +// replace trap flor geometry by two flat quads in the static state + #define LOD_TRAP_FLOOR +// disable some plants environment to reduce overdraw of transparent geometry + #define NO_STATIC_MESH_PLANTS +// the maximum of active enemies + #define MAX_ENEMIES 3 +// visibility distance + #define VIEW_DIST (10 << 10) +// skip collideSpheres for enemies + #define FAST_HITMASK +#endif + +#ifndef NAV_STEPS + #define NAV_STEPS 5 +#endif + +#ifndef MAX_ENEMIES + #define MAX_ENEMIES 8 +#endif + +// ============================================================================ + +#if defined(_MSC_VER) + #define X_INLINE inline + #define X_NOINLINE __declspec(noinline) + #define ALIGN4 __declspec(align(4)) + #define ALIGN8 __declspec(align(8)) + #define ALIGN16 __declspec(align(16)) +#elif defined(__WATCOMC__) || defined(__3DO__) + #define X_INLINE inline + #define X_NOINLINE + #define ALIGN4 + #define ALIGN8 + #define ALIGN16 +#else + #define X_INLINE __attribute__((always_inline)) inline + #define X_NOINLINE __attribute__((noinline)) + #define ALIGN4 __attribute__((aligned(4))) + #define ALIGN8 __attribute__((aligned(8))) + #define ALIGN16 __attribute__((aligned(16))) +#endif + +#if defined(__3DO__) +typedef size_t intptr_t; +typedef uint32 divTableInt; +#else +typedef signed char int8; +typedef signed short int16; +#if !defined(__NDS__) +typedef signed int int32; +#endif +typedef unsigned char uint8; +typedef unsigned short uint16; +#if !defined(__NDS__) +typedef unsigned int uint32; +#endif +typedef uint16 divTableInt; +#endif + +#if defined(__32X__) + typedef int8 ColorIndex; +#else + typedef uint8 ColorIndex; +#endif + +#define ADDR_ALIGN4(x) ((uint8*)x += ((intptr_t(x) + 3) & ~3) - intptr_t(x)) + +//#include +inline void* operator new(size_t, void *ptr) +{ + return ptr; +} + +#if defined(__3DO__) || defined(__32X__) +X_INLINE int32 abs(int32 x) { + return (x >= 0) ? x : -x; +} +#endif + +#if defined(__GBA__) || defined(__NDS__) || defined(__32X__) + #define int2str(x,str) itoa(x, str, 10) +#elif defined(__3DO__) + #define int2str(x,str) sprintf(str, "%d", x) +#elif defined(__TNS__) + #define int2str(x,str) __itoa(x, str, 10) +#else + #define int2str(x,str) _itoa(x, str, 10) +#endif + +#ifdef __GBA__ + #define ARM_CODE __attribute__((target("arm"))) +#else + #define ARM_CODE + #define THUMB_CODE + #define IWRAM_DATA + #define EWRAM_DATA + #define EWRAM_BSS + #define IWRAM_CODE + #define EWRAM_CODE +#endif + +#if defined(__WIN32__) || defined(__GBA_WIN__) + #define ASSERT(x) { if (!(x)) { DebugBreak(); } } + #define STATIC_ASSERT(x) typedef char static_assert_##__COUNTER__[(x) ? 1 : -1] +#else + #define ASSERT(x) + #define STATIC_ASSERT(x) +#endif + +#if defined(__GBA_WIN__) + extern uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#elif defined(__GBA__) + extern uint32 fb; +#elif defined(__TNS__) + extern uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#elif defined(__DOS__) + extern uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#endif + +#define STATIC_MESH_FLAG_NO_COLLISION 1 +#define STATIC_MESH_FLAG_VISIBLE 2 +#define MAX_STATIC_MESH_RADIUS (5 * 1024) + +extern int32 fps; + +#if defined(USE_VRAM_MESH) || defined(USE_VRAM_ROOM) +extern uint8* vramPtr; +#endif + +#ifndef F16_SHIFT + #define F16_SHIFT 0 +#endif + +#ifdef USE_MATRIX_INT16 + #define MATRIX_FIXED_SHIFT FIXED_SHIFT +#endif + +#ifndef MATRIX_FIXED_SHIFT + #define MATRIX_FIXED_SHIFT 0 +#endif + +#define SND_MAX_DIST (8 * 1024) + +#ifndef SND_CHANNELS + #define SND_CHANNELS 6 +#endif + +#define SND_FIXED_SHIFT 8 +#define SND_VOL_SHIFT 6 +#define SND_PITCH_SHIFT 7 + +#if defined(__WIN32__) + #define SND_SAMPLES 1024 + #define SND_OUTPUT_FREQ 22050 + #define SND_SAMPLE_FREQ 22050 + #define SND_ENCODE(x) ((x) + 128) + #define SND_DECODE(x) ((x) - 128) + #define SND_MIN -128 + #define SND_MAX 127 +#elif defined(__GBA_WIN__) + #define SND_SAMPLES 1024 + #define SND_OUTPUT_FREQ 22050 + #define SND_SAMPLE_FREQ 22050 + #define SND_ENCODE(x) ((x) + 128) + #define SND_DECODE(x) ((x) - 128) + #define SND_MIN -128 + #define SND_MAX 127 +#elif defined(__GBA__) + #define SND_SAMPLES 176 + #define SND_OUTPUT_FREQ 10512 + #define SND_SAMPLE_FREQ 22050 + #define SND_ENCODE(x) (x) + #define SND_DECODE(x) ((x) - 128) + #define SND_MIN -128 + #define SND_MAX 127 +#elif defined(__DOS__) + #define SND_SAMPLES 1024 + #define SND_OUTPUT_FREQ 11025 + #define SND_SAMPLE_FREQ 11025 + #define SND_ENCODE(x) ((x) + 128) + #define SND_DECODE(x) ((x) - 128) + #define SND_MIN -128 + #define SND_MAX 127 +#elif defined(__3DO__) + #define SND_SAMPLES 1024 + #define SND_OUTPUT_FREQ 11025 + #define SND_SAMPLE_FREQ 11025 + #define SND_ENCODE(x) ((x) + 128) + #define SND_DECODE(x) ((x) - 128) + #define SND_MIN -128 + #define SND_MAX 127 +#endif + +#if defined(__3DO__) + #define MAX_VERTICES (1024 + 32) // for mesh (max = LEVEL10A room:58) +#elif defined(__GBA__) + #define MAX_VERTICES (5*1024) // for frame (max is 8191 - check the assumption in flush.s) +#else + #define MAX_VERTICES (5*1024) // for frame +#endif + +#define MAX_UPDATE_FRAMES 10 +#define MAX_PLAYERS 1 // TODO 2 players for non-potato platforms +#define MAX_SPHERES 32 +#define MAX_MATRICES 8 +#define MAX_ROOMS 139 // LEVEL7A +#define MAX_ITEMS 256 +#define MAX_MODELS ITEM_MAX +#define MAX_MESHES 512 +#define MAX_STATIC_MESHES 50 +#define MAX_CAMERAS 16 +#define MAX_BOXES 1024 +#define MAX_TEXTURES 1536 +#define MAX_SPRITES 180 +#define MAX_FACES 1920 +#define MAX_ROOM_LIST 32 +#define MAX_PORTALS 16 +#define MAX_CAUSTICS 32 +#define MAX_RAND_TABLE 32 +#define MAX_DYN_SECTORS (1024*3) +#define MAX_SAMPLES 180 + +#ifndef VIEW_DIST + #define VIEW_DIST (1024 * 10) +#endif + +#define FOV_SHIFT 3 +#define FOG_SHIFT 1 +#define FOG_MAX VIEW_DIST +#define FOG_MIN (FOG_MAX - 2048) +#define VIEW_MIN_F (64 << FIXED_SHIFT) +#define VIEW_MAX_F (VIEW_DIST << FIXED_SHIFT) + +#define MESH_SHIFT 2 + +#define TEX_ATTR_AKILL 1 + +#define NOT_ENEMY -0x4000 // default hp for non enemies +#define NO_ROOM 0xFF +#define NO_MODEL 0xFF +#define NO_BOX 0xFFFF +#define NO_FLOOR -127 +#define WALL (NO_FLOOR * 256) + +#define ANGLE_360 0x10000 +#define ANGLE_0 0 +#define ANGLE_1 (ANGLE_360 / 360) +#define ANGLE_45 (ANGLE_360 / 8) // != 45 * ANGLE_1 !!! +#define ANGLE_90 (ANGLE_360 / 4) // != 90 * ANGLE_1 !!! +#define ANGLE_180 -(ANGLE_360 / 2) // INT16_MIN +#define ANGLE(x) ((x) * ANGLE_1) +#define ANGLE_SHIFT_45 13 +#define ANGLE_SHIFT_90 14 +#define ANGLE_SHIFT_180 15 + +#define LARA_MAX_HEALTH 1000 +#define LARA_MAX_OXYGEN 1800 // TODO +30 sec for TR5 + +#define X_CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x))) +#define X_MIN(a,b) ((a) < (b) ? (a) : (b)) +#define X_MAX(a,b) ((a) > (b) ? (a) : (b)) +#define X_SQR(x) ((x) * (x)) +#define X_COUNT(x) int32(sizeof(x) / sizeof(x[0])) + +#define X_ROTX(x,y,s,c) (((x) * (c) - (y) * (s)) >> FIXED_SHIFT) +#define X_ROTY(x,y,s,c) (((y) * (c) + (x) * (s)) >> FIXED_SHIFT) +#define X_ROTXY(x,y,s,c) {\ + int32 _x = X_ROTX(x,y,s,c);\ + int32 _y = X_ROTY(x,y,s,c);\ + x = _x;\ + y = _y;\ +} + +#define DP43(ax,ay,az,aw,bx,by,bz) (ax * bx + ay * by + az * bz + (aw << MATRIX_FIXED_SHIFT)) +#define DP33(ax,ay,az,bx,by,bz) (ax * bx + ay * by + az * bz) + +#ifdef USE_DIV_TABLE + #define DIV_TABLE_SIZE 1025 // to compare with #1024 without extra LDR + #define FixedInvS(x) ((x < 0) ? -divTable[abs(x)] : divTable[x]) + #define FixedInvU(x) divTable[x] + extern divTableInt divTable[DIV_TABLE_SIZE]; + + #define GET_FRAME_T(x,n) (FixedInvU(n) * x) +#else + #define GET_FRAME_T(x,n) ((x << 16) / n) +#endif + +#define OT_SHIFT 4 +#define OT_SIZE ((VIEW_MAX_F >> (FIXED_SHIFT + OT_SHIFT)) + 1) + +// system keys (keys) +enum InputKey { + IK_NONE = 0, + IK_UP = (1 << 0), + IK_RIGHT = (1 << 1), + IK_DOWN = (1 << 2), + IK_LEFT = (1 << 3), + IK_A = (1 << 4), + IK_B = (1 << 5), + IK_C = (1 << 6), + IK_X = (1 << 7), + IK_Y = (1 << 8), + IK_Z = (1 << 9), + IK_L = (1 << 10), + IK_R = (1 << 11), + IK_LT = (1 << 12), + IK_RT = (1 << 13), + IK_START = (1 << 14), + IK_SELECT = (1 << 15) +}; + +// action keys (ItemObj::input) +enum InputState { + IN_LEFT = (1 << 1), + IN_RIGHT = (1 << 2), + IN_UP = (1 << 3), + IN_DOWN = (1 << 4), + IN_JUMP = (1 << 5), + IN_WALK = (1 << 6), + IN_ACTION = (1 << 7), + IN_WEAPON = (1 << 8), + IN_LOOK = (1 << 9), + IN_START = (1 << 10), + IN_SELECT = (1 << 11) +}; + +struct vec3s { + int16 x, y, z; + + X_INLINE static vec3s create(int16 x, int16 y, int16 z) { + vec3s r; + r.x = x; + r.y = y; + r.z = z; + return r; + } + + X_INLINE vec3s operator + (const vec3s &v) const { return create(x + v.x, y + v.y, z + v.z); } + X_INLINE vec3s operator - (const vec3s &v) const { return create(x - v.x, y - v.y, z - v.z); } + X_INLINE bool operator == (const vec3s &v) { return x == v.x && y == v.y && z == v.z; } + X_INLINE bool operator != (const vec3s &v) { return x != v.x || y != v.y || z != v.z; } + X_INLINE vec3s& operator += (const vec3s &v) { x += v.x; y += v.y; z += v.z; return *this; } + X_INLINE vec3s& operator -= (const vec3s &v) { x -= v.x; y -= v.y; z -= v.z; return *this; } +}; + +#define _vec3s(x,y,z) vec3s::create(x, y, z) + +struct vec4s { + int16 x, y, z, w; +}; + +struct vec3i { + int32 x, y, z; + + X_INLINE static vec3i create(int32 x, int32 y, int32 z) { + vec3i r; + r.x = x; + r.y = y; + r.z = z; + return r; + } + + X_INLINE vec3i operator + (const vec3i &v) const { return create(x + v.x, y + v.y, z + v.z); } + X_INLINE vec3i operator - (const vec3i &v) const { return create(x - v.x, y - v.y, z - v.z); } + X_INLINE vec3i operator * (int32 s) const { return create(x * s, y * s, z * s); } + X_INLINE bool operator == (const vec3i &v) const { return x == v.x && y == v.y && z == v.z; } + X_INLINE bool operator != (const vec3i &v) const { return x != v.x || y != v.y || z != v.z; } + X_INLINE vec3i& operator += (const vec3i &v) { x += v.x; y += v.y; z += v.z; return *this; } + X_INLINE vec3i& operator -= (const vec3i &v) { x -= v.x; y -= v.y; z -= v.z; return *this; } + X_INLINE vec3i& operator *= (int32 s) { x *= s; y *= s; z *= s; return *this; } +}; + +#define _vec3i(x,y,z) vec3i::create(x, y, z) + +struct vec4i { + int32 x, y, z, w; + + X_INLINE int32& operator [] (int32 index) const { + ASSERT(index >= 0 && index <= 3); + return ((int32*)this)[index]; + } +}; + +struct Matrix +{ +#if defined(__3DO__) + int32 e00, e10, e20; + int32 e01, e11, e21; + int32 e02, e12, e22; + int32 e03, e13, e23; +#elif defined(USE_MATRIX_INT16) + int16 e00, e01, e02; + int16 e10, e11, e12; + int16 e20, e21, e22; + int16 e03, e13, e23; +#else + int32 e00, e01, e02, e03; + int32 e10, e11, e12, e13; + int32 e20, e21, e22, e23; +#endif +}; + +struct RoomQuad +{ +#if defined(__3DO__) + uint32 flags; + uint16 indices[4]; +#elif defined(__32X__) + uint32 flags; + int8 indices[4]; +#else + int8 indices[4]; + uint16 flags; + uint16 padding; +#endif +}; + +struct RoomTriangle +{ +#if defined(__3DO__) + uint32 flags; + uint16 indices[4]; +#elif defined(__32X__) + uint16 flags; + uint16 indices[3]; +#else + uint16 indices[3]; + uint16 flags; +#endif +}; + +struct MeshQuad +{ +#if defined(__3DO__) + uint32 flags; + uint32 indices; +#elif defined(__32X__) + uint16 flags; + uint8 indices[4]; +#else + int8 indices[4]; + uint16 flags; + uint16 padding; +#endif +}; + +struct MeshTriangle +{ +#if defined(__3DO__) + uint32 flags; + uint32 indices; +#elif defined(__32X__) + uint16 flags; + uint8 indices[4]; +#else + int8 indices[4]; + uint16 flags; + uint16 padding; +#endif +}; + +struct RectMinMax +{ + int32 x0; + int32 y0; + int32 x1; + int32 y1; + + RectMinMax() {} + RectMinMax(int32 x0, int32 y0, int32 x1, int32 y1) : x0(x0), y0(y0), x1(x1), y1(y1) {} +}; + +union TexCoord +{ + struct { uint16 v, u; } uv; + uint32 t; +}; + +#ifdef __3DO__ +struct Face +{ + uint32 ccb_Flags; + Face* ccb_NextPtr; + CelData* ccb_SourcePtr; + void* ccb_PLUTPtr; + Coord ccb_XPos; + Coord ccb_YPos; + int32 ccb_HDX; + int32 ccb_HDY; + int32 ccb_VDX; + int32 ccb_VDY; + int32 ccb_HDDX; + int32 ccb_HDDY; + uint32 ccb_PIXC; + // TODO use 1x1 textures instead of colored faces to remove preamble words (8 bytes per face - 15k) + uint32 ccb_PRE0; + uint32 ccb_PRE1; + //int32 ccb_Width; + //int32 ccb_Height; +}; + + #define BLOCK_SIZE_DRAM (32 * 1024) + #define BLOCK_SIZE_VRAM (16 * 1024) + #define BLOCK_SIZE_CD (2 * 1024) + + #define SND_BUFFER_SIZE (4 * BLOCK_SIZE_CD) + #define SND_BUFFERS 4 + + #define MAX_RAM_LVL (BLOCK_SIZE_DRAM * 29) // 34 for LEVEL10C! >_< + #define MAX_RAM_TEX (BLOCK_SIZE_VRAM * 44) + #define MAX_RAM_CEL (MAX_FACES * sizeof(Face)) + #define MAX_RAM_SND (SND_BUFFERS * SND_BUFFER_SIZE) + + extern void* RAM_LVL; + extern void* RAM_TEX; + extern void* RAM_CEL; + extern void* RAM_SND; +#else +struct Face +{ + uint32 flags; + Face* next; + int16 indices[4]; +}; +#endif + +struct AABBs +{ + int16 minX; + int16 maxX; + int16 minY; + int16 maxY; + int16 minZ; + int16 maxZ; + + X_INLINE AABBs() {} + X_INLINE AABBs(int16 minX, int16 maxX, int16 minY, int16 maxY, int16 minZ, int16 maxZ) : + minX(minX), maxX(maxX), minY(minY), maxY(maxY), minZ(minZ), maxZ(maxZ) {} + + X_INLINE vec3i getCenter() const { + return _vec3i((maxX + minX) >> 1, (maxY + minY) >> 1, (maxZ + minZ) >> 1); + } +}; + +struct AABBi +{ + int32 minX; + int32 maxX; + int32 minY; + int32 maxY; + int32 minZ; + int32 maxZ; + + X_INLINE AABBi() {} + X_INLINE AABBi(const AABBs &b) : + minX(b.minX), maxX(b.maxX), minY(b.minY), maxY(b.maxY), minZ(b.minZ), maxZ(b.maxZ) {} + X_INLINE AABBi(int32 minX, int32 maxX, int32 minY, int32 maxY, int32 minZ, int32 maxZ) : + minX(minX), maxX(maxX), minY(minY), maxY(maxY), minZ(minZ), maxZ(maxZ) {} + + X_INLINE vec3i getCenter() const { + return _vec3i((maxX + minX) >> 1, (maxY + minY) >> 1, (maxZ + minZ) >> 1); + } +}; + +struct Sphere +{ + vec3i center; + int32 radius; +}; + +struct Room; + +struct RoomVertex +{ +#if defined(__3DO__) + uint16 xyz565; +#elif defined(__GBA__) || defined(__GBA_WIN__) || defined(__32X__) + uint8 x, y, z, g; +#else + uint8 x, y, z, g; +#endif +}; + +struct RoomSprite +{ + vec3s pos; + uint8 g; + uint8 index; +}; + +struct MeshVertex +{ + int16 x, y, z; +}; + +struct Portal +{ + uint16 roomIndex; + vec3s n; + vec3s v[4]; +}; + +struct Sector +{ + uint16 floorIndex; + uint16 boxIndex; + uint8 roomBelow; + int8 floor; + uint8 roomAbove; + int8 ceiling; + + const Sector* getSectorBelow(int32 posX, int32 posZ) const; + const Sector* getSectorAbove(int32 posX, int32 posZ) const; + int32 getFloor(int32 x, int32 y, int32 z) const; + int32 getCeiling(int32 x, int32 y, int32 z) const; + Room* getNextRoom() const; + void getTriggerFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int32* ceiling) const; +}; + +struct Light +{ + vec3s pos; + uint8 radius; + uint8 intensity; +}; + +#define STATIC_MESH_ID(flags) ((flags) & 0x3F) +#define STATIC_MESH_QUADRANT(flags) (((flags) >> 6) & 3) +#define STATIC_MESH_ROT(flags) ((STATIC_MESH_QUADRANT(flags) - 2) * ANGLE_90) +#define STATIC_MESH_INTENSITY(flags) ((((flags) >> 8) & 0xFF) << 5) + +struct RoomMesh +{ + uint32 xy; // (x << 16) | y + uint32 zf; // (z << 16) | (intensity << 8) | flags +}; + +struct ItemObj; + +struct RoomData +{ + const RoomQuad* quads; + const RoomTriangle* triangles; + const RoomVertex* vertices; + const RoomSprite* sprites; + const Portal* portals; + const Sector* sectors; + const Light* lights; + const RoomMesh* meshes; +}; + +#define ROOM_FLAG_WATER(x) ((x) & 1) + +struct RoomInfo +{ + int16 x; + int16 z; + + int16 yBottom; + int16 yTop; + + uint16 quadsCount; + uint16 trianglesCount; + + uint16 verticesCount; + uint16 spritesCount; + + uint8 portalsCount; + uint8 lightsCount; + uint8 meshesCount; + uint8 ambient; + + uint8 xSectors; + uint8 zSectors; + uint8 alternateRoom; + uint8 flags; + + RoomData data; +}; + +struct CollisionInfo; + +struct Room { + ItemObj* firstItem; + const RoomInfo* info; + const Sector* sectors; // == info->sectors (const) by default (see roomModify) + + RoomData data; + + RectMinMax clip; + uint8 _reserved; + bool visible; + + void modify(); + void reset(); + + void add(ItemObj* item); + void remove(ItemObj* item); + + const Sector* getSector(int32 x, int32 z) const; + const Sector* getWaterSector(int32 x, int32 z) const; + Room* getRoom(int32 x, int32 y, int32 z); + bool collideStatic(CollisionInfo &cinfo, const vec3i &p, int32 height); + bool checkPortal(const Portal* portal); + + Room** addVisibleRoom(Room** list); + Room** addNearRoom(Room** list, int32 x, int32 y, int32 z); + Room** getNearRooms(const vec3i &pos, int32 radius, int32 height); + Room** getAdjRooms(); + Room** getVisibleRooms(); +}; + +enum NodeFlag { + NODE_FLAG_POP = (1 << 0), + NODE_FLAG_PUSH = (1 << 1), + NODE_FLAG_ROTX = (1 << 2), + NODE_FLAG_ROTY = (1 << 3), + NODE_FLAG_ROTZ = (1 << 4) +}; + +struct ModelNode { + vec3s pos; + uint16 flags; +}; + +struct Model { + uint8 type; + int8 count; + uint16 start; + uint16 nodeIndex; + uint16 animIndex; +}; + +#define FILE_MODEL_SIZE (sizeof(Model) - 2) // -padding + +struct Mesh { + vec3s center; + int16 radius; + uint16 intensity; + uint8 vCount; + uint8 hasNormals; + int16 rCount; + int16 tCount; + int16 crCount; + int16 ctCount; + // data... +}; + +struct Sphere16 { + uint32 xy; + uint32 zr; +}; + +struct StaticMesh { + uint16 id; + uint16 meshIndex; + uint32 flags; + Sphere16 vs; + AABBs vbox; + AABBs cbox; +}; + +#define SI_MODE(x) (x & 3) +#define SI_COUNT(x) ((x >> 2) & 15) +#define SI_CAMERA(x) ((x >> 12) & 1) +#define SI_PITCH(x) ((x >> 13) & 1) +#define SI_GAIN(x) ((x >> 14) & 1) + +struct SoundInfo +{ + uint16 index; + uint16 volume; + uint16 chance; + uint16 flags; +}; + +struct SoundSource +{ + vec3i pos; + uint16 id; + uint16 flags; +}; + +struct Anim { + uint32 frameOffset; + uint8 frameRate; + uint8 frameSize; + uint16 state; + int32 speed; + int32 accel; + uint16 frameBegin; + uint16 frameEnd; + uint16 nextAnimIndex; + uint16 nextFrameIndex; + uint16 statesCount; + uint16 statesStart; + uint16 commandsCount; + uint16 commandsStart; +}; + +struct AnimState { + uint8 state; + uint8 rangesCount; + uint16 rangesStart; +}; + +struct AnimRange { + uint16 frameBegin; + uint16 frameEnd; + uint16 nextAnimIndex; + uint16 nextFrameIndex; +}; + +struct AnimFrame { + AABBs box; + vec3s pos; + uint16 angles[1]; +}; + +struct Texture +{ +#ifdef __3DO__ + uint8* data; + uint32 shift; +#else + uint32 tile; + uint32 uv01; + uint32 uv23; +#endif +}; + +struct Sprite +{ +#ifdef __3DO__ + uint32 texture; + int32 l, t, r, b; +#else + uint32 tile; + uint32 uwvh; + int16 l, t, r, b; +#endif +}; + +struct SpriteSeq { + uint16 type; + uint16 unused; + int16 count; + uint16 start; +}; + + +#define FIXED_CAMERA_FLAG_TIMER 0xFF +#define FIXED_CAMERA_FLAG_ONCE (1 << 8) +#define FIXED_CAMERA_FLAG_SPEED_SHIFT 9 +#define FIXED_CAMERA_FLAG_SPEED (31 << FIXED_CAMERA_FLAG_SPEED_SHIFT) + +struct FixedCamera { + vec3i pos; + int16 roomIndex; + uint16 flags; +}; + +#define ITEM_FLAGS_STATUS_SHIFT 3 +#define ITEM_FLAGS_MASK_SHIFT 9 +#define ITEM_FLAGS_MASK_ALL 31 + +#define ITEM_FLAG_GRAVITY (1 << 1) +#define ITEM_FLAG_ACTIVE (1 << 2) +#define ITEM_FLAG_STATUS (3 << ITEM_FLAGS_STATUS_SHIFT) +#define ITEM_FLAG_STATUS_ACTIVE (1 << ITEM_FLAGS_STATUS_SHIFT) +#define ITEM_FLAG_STATUS_INACTIVE (2 << ITEM_FLAGS_STATUS_SHIFT) +#define ITEM_FLAG_STATUS_INVISIBLE (3 << ITEM_FLAGS_STATUS_SHIFT) +#define ITEM_FLAG_COLLISION (1 << 5) +#define ITEM_FLAG_INJURED (1 << 6) +#define ITEM_FLAG_ANIMATED (1 << 7) +#define ITEM_FLAG_ONCE (1 << 8) +#define ITEM_FLAG_MASK (ITEM_FLAGS_MASK_ALL << ITEM_FLAGS_MASK_SHIFT) +#define ITEM_FLAG_REVERSE (1 << 14) +#define ITEM_FLAG_SHADOW (1 << 15) + +struct ItemObjInfo { + uint8 type; + uint8 roomIndex; + vec3s pos; + uint16 intensity; + uint16 flags; +}; + +#define FILE_ITEM_SIZE (sizeof(ItemObjInfo) - 2) + +struct CollisionInfo; +struct Lara; + +#define ITEM_TYPES(E) \ + E( LARA ) \ + E( LARA_PISTOLS ) \ + E( LARA_SHOTGUN ) \ + E( LARA_MAGNUMS ) \ + E( LARA_UZIS ) \ + E( LARA_SPEC ) \ + E( DOPPELGANGER ) \ + E( WOLF ) \ + E( BEAR ) \ + E( BAT ) \ + E( CROCODILE_LAND ) \ + E( CROCODILE_WATER ) \ + E( LION_MALE ) \ + E( LION_FEMALE ) \ + E( PUMA ) \ + E( GORILLA ) \ + E( RAT_LAND ) \ + E( RAT_WATER ) \ + E( REX ) \ + E( RAPTOR ) \ + E( MUTANT_1 ) \ + E( MUTANT_2 ) \ + E( MUTANT_3 ) \ + E( CENTAUR ) \ + E( MUMMY ) \ + E( UNUSED_1 ) \ + E( UNUSED_2 ) \ + E( LARSON ) \ + E( PIERRE ) \ + E( SKATEBOARD ) \ + E( SKATER ) \ + E( COWBOY ) \ + E( MR_T ) \ + E( NATLA ) \ + E( ADAM ) \ + E( TRAP_FLOOR ) \ + E( TRAP_SWING_BLADE ) \ + E( TRAP_SPIKES ) \ + E( TRAP_BOULDER ) \ + E( DART ) \ + E( TRAP_DART_EMITTER ) \ + E( DRAWBRIDGE ) \ + E( TRAP_SLAM ) \ + E( TRAP_SWORD ) \ + E( HAMMER_HANDLE ) \ + E( HAMMER_BLOCK ) \ + E( LIGHTNING ) \ + E( MOVING_OBJECT ) \ + E( BLOCK_1 ) \ + E( BLOCK_2 ) \ + E( BLOCK_3 ) \ + E( BLOCK_4 ) \ + E( MOVING_BLOCK ) \ + E( TRAP_CEILING ) \ + E( TRAP_FLOOR_LOD ) \ + E( SWITCH ) \ + E( SWITCH_WATER ) \ + E( DOOR_1 ) \ + E( DOOR_2 ) \ + E( DOOR_3 ) \ + E( DOOR_4 ) \ + E( DOOR_5 ) \ + E( DOOR_6 ) \ + E( DOOR_7 ) \ + E( DOOR_8 ) \ + E( TRAP_DOOR_1 ) \ + E( TRAP_DOOR_2 ) \ + E( TRAP_DOOR_LOD ) \ + E( BRIDGE_FLAT ) \ + E( BRIDGE_TILT_1 ) \ + E( BRIDGE_TILT_2 ) \ + E( INV_PASSPORT ) \ + E( INV_COMPASS ) \ + E( INV_HOME ) \ + E( GEARS_1 ) \ + E( GEARS_2 ) \ + E( GEARS_3 ) \ + E( CUT_1 ) \ + E( CUT_2 ) \ + E( CUT_3 ) \ + E( CUT_4 ) \ + E( INV_PASSPORT_CLOSED ) \ + E( INV_MAP ) \ + E( CRYSTAL ) \ + E( PISTOLS ) \ + E( SHOTGUN ) \ + E( MAGNUMS ) \ + E( UZIS ) \ + E( AMMO_PISTOLS ) \ + E( AMMO_SHOTGUN ) \ + E( AMMO_MAGNUMS ) \ + E( AMMO_UZIS ) \ + E( EXPLOSIVE ) \ + E( MEDIKIT_SMALL ) \ + E( MEDIKIT_BIG ) \ + E( INV_DETAIL ) \ + E( INV_SOUND ) \ + E( INV_CONTROLS ) \ + E( INV_GAMMA ) \ + E( INV_PISTOLS ) \ + E( INV_SHOTGUN ) \ + E( INV_MAGNUMS ) \ + E( INV_UZIS ) \ + E( INV_AMMO_PISTOLS ) \ + E( INV_AMMO_SHOTGUN ) \ + E( INV_AMMO_MAGNUMS ) \ + E( INV_AMMO_UZIS ) \ + E( INV_EXPLOSIVE ) \ + E( INV_MEDIKIT_SMALL ) \ + E( INV_MEDIKIT_BIG ) \ + E( PUZZLE_1 ) \ + E( PUZZLE_2 ) \ + E( PUZZLE_3 ) \ + E( PUZZLE_4 ) \ + E( INV_PUZZLE_1 ) \ + E( INV_PUZZLE_2 ) \ + E( INV_PUZZLE_3 ) \ + E( INV_PUZZLE_4 ) \ + E( PUZZLEHOLE_1 ) \ + E( PUZZLEHOLE_2 ) \ + E( PUZZLEHOLE_3 ) \ + E( PUZZLEHOLE_4 ) \ + E( PUZZLEHOLE_DONE_1 ) \ + E( PUZZLEHOLE_DONE_2 ) \ + E( PUZZLEHOLE_DONE_3 ) \ + E( PUZZLEHOLE_DONE_4 ) \ + E( LEADBAR ) \ + E( INV_LEADBAR ) \ + E( MIDAS_HAND ) \ + E( KEY_ITEM_1 ) \ + E( KEY_ITEM_2 ) \ + E( KEY_ITEM_3 ) \ + E( KEY_ITEM_4 ) \ + E( INV_KEY_ITEM_1 ) \ + E( INV_KEY_ITEM_2 ) \ + E( INV_KEY_ITEM_3 ) \ + E( INV_KEY_ITEM_4 ) \ + E( KEYHOLE_1 ) \ + E( KEYHOLE_2 ) \ + E( KEYHOLE_3 ) \ + E( KEYHOLE_4 ) \ + E( UNUSED_5 ) \ + E( UNUSED_6 ) \ + E( SCION_PICKUP_QUALOPEC ) \ + E( SCION_PICKUP_DROP ) \ + E( SCION_TARGET ) \ + E( SCION_PICKUP_HOLDER ) \ + E( SCION_HOLDER ) \ + E( UNUSED_7 ) \ + E( UNUSED_8 ) \ + E( INV_SCION ) \ + E( EXPLOSION ) \ + E( UNUSED_9 ) \ + E( SPLASH ) \ + E( UNUSED_10 ) \ + E( BUBBLE ) \ + E( UNUSED_11 ) \ + E( UNUSED_12 ) \ + E( BLOOD ) \ + E( UNUSED_13 ) \ + E( SMOKE ) \ + E( CENTAUR_STATUE ) \ + E( CABIN ) \ + E( MUTANT_EGG_SMALL ) \ + E( RICOCHET ) \ + E( SPARKLES ) \ + E( MUZZLE_FLASH ) \ + E( UNUSED_14 ) \ + E( UNUSED_15 ) \ + E( VIEW_TARGET ) \ + E( WATERFALL ) \ + E( NATLA_BULLET ) \ + E( MUTANT_BULLET ) \ + E( CENTAUR_BULLET ) \ + E( UNUSED_16 ) \ + E( UNUSED_17 ) \ + E( LAVA_PARTICLE ) \ + E( LAVA_EMITTER ) \ + E( FLAME ) \ + E( FLAME_EMITTER ) \ + E( TRAP_LAVA ) \ + E( MUTANT_EGG_BIG ) \ + E( BOAT ) \ + E( EARTHQUAKE ) \ + E( UNUSED_18 ) \ + E( UNUSED_19 ) \ + E( UNUSED_20 ) \ + E( UNUSED_21 ) \ + E( UNUSED_22 ) \ + E( LARA_BRAID ) \ + E( GLYPHS ) + +#define DECL_ENUM(v) ITEM_##v, + +enum ItemType { + ITEM_TYPES(DECL_ENUM) + TR1_ITEM_MAX, + ITEM_MAX = TR1_ITEM_MAX +}; + +#undef DECL_ENUM + +struct Location { + Room* room; + vec3i pos; +}; + +enum CameraMode { + CAMERA_MODE_FREE, + CAMERA_MODE_FOLLOW, + CAMERA_MODE_COMBAT, + CAMERA_MODE_LOOK, + CAMERA_MODE_FIXED, + CAMERA_MODE_OBJECT, + CAMERA_MODE_CUTSCENE +}; + +struct Camera { + Location view; + Location target; + + int32 targetDist; + vec3s targetAngle; + + vec3s angle; + + ItemObj* laraItem; + ItemObj* lastItem; + ItemObj* lookAtItem; + + int32 speed; + int32 timer; + int32 index; + int32 lastIndex; + + CameraMode mode; + + bool lastFixed; + bool center; + + void initCinematic(); + void updateCinematic(); + + void init(ItemObj* lara); + Location getLocationForAngle(int32 angle, int32 distH, int32 distV); + void clip(Location &loc); + Location getBestLocation(bool clip); + void move(Location &to, int32 speed); + void updateFree(); + void updateFollow(ItemObj* item); + void updateCombat(ItemObj* item); + void updateLook(ItemObj* item); + void updateFixed(); + void lookAt(int32 offset); + void update(); + void toCombat(); +}; + +enum ZoneType +{ + ZONE_GROUND_1, + ZONE_GROUND_2, + ZONE_FLY, + ZONE_MAX +}; + +struct Nav +{ + struct Cell + { + uint16 boxIndex; + uint16 weight; + uint16 end; + uint16 next; + }; + + Cell cells[MAX_BOXES]; + uint32 cellsCount; + + uint32 zoneType; + uint32 weight; + + uint32 endBox; + uint32 nextBox; + uint32 headBox; + uint32 tailBox; + int32 stepHeight; + int32 dropHeight; + int32 vSpeed; + uint32 mask; + + vec3i pos; + + void init(uint32 boxIndex); + void search(uint16 zone, const uint16* zones); + vec3i getWaypoint(uint32 boxIndex, const vec3i &from); +}; + +enum WeaponState +{ + WEAPON_STATE_FREE, + WEAPON_STATE_BUSY, + WEAPON_STATE_DRAW, + WEAPON_STATE_HOLSTER, + WEAPON_STATE_READY +}; + +enum Weapon +{ + WEAPON_PISTOLS, + WEAPON_MAGNUMS, + WEAPON_UZIS, + WEAPON_SHOTGUN, + // WEAPON_DESERT_EAGLE, + // WEAPON_REVOLVER, + // WEAPON_M16 + // WEAPON_MP5 + // WEAPON_HK + // WEAPON_ROCKET + // WEAPON_GRENADE + // WEAPON_HARPOON + // WEAPON_CROSSBOW + // WEAPON_GRAPPLING + // WEAPON_FLARE + WEAPON_NONE, + WEAPON_MAX +}; + +struct WeaponParams +{ + ItemType modelType; + ItemType animType; + uint16 damage; + uint16 spread; + uint16 range; + int16 height; + int16 soundId; + uint8 reloadTimer; + uint8 flashOffset; + uint8 flashTimer; + uint8 flashIntensity; + int16 aimX; + int16 aimY; + int16 armX; + int16 armMinY; + int16 armMaxY; +}; + +enum LaraArm +{ + LARA_ARM_R, + LARA_ARM_L, + LARA_ARM_MAX +}; + +enum LaraJoint +{ + JOINT_HIPS = 0, + JOINT_LEG_L1, + JOINT_LEG_L2, + JOINT_LEG_L3, + JOINT_LEG_R1, + JOINT_LEG_R2, + JOINT_LEG_R3, + JOINT_TORSO, + JOINT_ARM_R1, + JOINT_ARM_R2, + JOINT_ARM_R3, + JOINT_ARM_L1, + JOINT_ARM_L2, + JOINT_ARM_L3, + JOINT_HEAD, + JOINT_MAX +}; + +struct ExtraInfoLara +{ + int16 swimTimer; + uint8 weaponState; + uint8 vSpeedHack; + + int16 moveAngle; + int16 hitFrame; + + int8 hitTimer; + int8 hitQuadrant; + + uint8 weapon; + uint8 goalWeapon; + + struct Head { + vec3s angle; + } head; + + struct Torso { + vec3s angle; + } torso; + + struct Arm + { + vec3s angle; + vec3s angleAim; + + uint16 animIndex; + uint16 frameIndex; + + struct Flash { + int16 timer; + int16 angle; + int16 offset; + int16 intensity; + } flash; + + ItemObj* target; + + bool aim; + bool useBasis; + }; + + Arm armR; + Arm armL; + + Camera camera; + + uint16 meshes[JOINT_MAX]; + + int16 ammo[WEAPON_MAX]; // TODO make global + + Nav nav; + + uint16 lastInput; + int8 healthTimer; + + bool dozy; +}; + +extern ExtraInfoLara playersExtra[MAX_PLAYERS]; + +#define gCinematicCamera playersExtra[0].camera + +struct Enemy; + +enum EnemyMood +{ + MOOD_SLEEP, + MOOD_STALK, + MOOD_ATTACK, + MOOD_ESCAPE +}; + +struct ExtraInfoEnemy +{ + int16 rotHead; + int16 rotNeck; + + int16 maxTurn; + int16 _reserved; + + Enemy* enemy; + + Nav nav; +}; + +struct ItemObj +{ + Room* room; + + vec3i pos; + vec3s angle; + + uint16 flags; + + int16 vSpeed; + int16 hSpeed; + + union { + uint16 animIndex; + int16 tick; // effects only + }; + + uint16 frameIndex; + + uint8 state; + uint8 nextState; // enemies only + uint8 goalState; + uint8 waterState; + + uint16 headOffset; // enemies only + union { + uint16 gymTimer; // lara only + uint16 aggression; // enemies only + }; + + int16 health; + union { + int16 timer; + int16 oxygen; // Lara only + int16 radius; // enemies only TODO + }; + + union { + uint16 input; // Lara only + uint16 mood; // enemies only + int16 corpseTimer; // enemies only + }; + int16 turnSpeed; + + uint8 type; + uint8 intensity; + int16 roomFloor; + + uint32 hitMask; + uint32 visibleMask; + + union { + uint8* extra; + ExtraInfoLara* extraL; + ExtraInfoEnemy* extraE; + }; + + ItemObj* nextItem; + ItemObj* nextActive; + + static ItemObj* sFirstActive; + static ItemObj* sFirstFree; + + static ItemObj* add(ItemType type, Room* room, const vec3i &pos, int32 angleY); + void remove(); + + void fxBubbles(Room *fxRoom, int32 fxJoint, const vec3i &fxOffset); + void fxRicochet(Room *fxRoom, const vec3i &fxPos, bool fxSound); + void fxBlood(const vec3i &fxPos, int16 fxAngleY, int16 fxSpeed); + void fxSmoke(const vec3i &fxPos); + void fxSplash(); + + int32 getFrames(const AnimFrame* &frameA, const AnimFrame* &frameB, int32 &animFrameRate) const; + const AnimFrame* getFrame() const; + const AABBs& getBoundingBox(bool lerp) const; + void move(); + const Anim* animSet(int32 newAnimIndex, bool resetState, int32 frameOffset = 0); + const Anim* animChange(const Anim* anim); + void animCmd(bool fx, const Anim* anim); + void animSkip(int32 stateBefore, int32 stateAfter, bool advance = false); + void animProcess(bool movement = true); + bool animIsEnd(int32 offset) const; + void animHit(int32 dirX, int32 dirZ, int32 hitTimer); + bool moveTo(const vec3i &point, ItemObj* item, bool lerp); + + void updateRoom(int32 offset = 0); + + bool isKeyHit(InputState state) const; // Lara only + + vec3i getRelative(const vec3i &point) const; + + int32 getWaterLevel() const; + int32 getWaterDepth() const; + int32 getBridgeFloor(int32 x, int32 z) const; + int32 getTrapDoorFloor(int32 x, int32 z) const; + int32 getDrawBridgeFloor(int32 x, int32 z) const; + void getItemFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int32* ceiling) const; + + vec3i getJoint(int32 jointIndex, const vec3i &offset) const; + int32 getSpheres(Sphere* spheres, bool flag) const; + + uint32 collideSpheres(Lara* lara) const; + bool collideBounds(Lara* lara, CollisionInfo* cinfo) const; + void collidePush(Lara* lara, CollisionInfo* cinfo, bool enemyHit) const; + void collideRoom(int32 height, int32 yOffset) const; + + uint32 updateHitMask(Lara* lara, CollisionInfo* cinfo); + + void meshSwap(ItemType type, uint32 mask); + + ItemObj* init(Room* room); + + X_INLINE ItemObj() {} + ItemObj(Room* room); + virtual void activate(); + virtual void deactivate(); + virtual void hit(int32 damage, const vec3i &point, int32 soundId); + virtual void collide(Lara* lara, CollisionInfo* cinfo); + virtual void update(); + virtual void draw(); + virtual uint8* save(uint8* data); + virtual uint8* load(uint8* data); +}; + +#define TRACK_FLAG_ONCE 32 +#define TRACK_FLAG_MASK 31 + +#define SAVEGAME_VER 2 +#define SAVEGAME_SIZE (8 * 1024) // 8k EWRAM + +struct SaveGame +{ + uint32 version; + uint32 dataSize; + + uint8 level; + int8 track; + uint8 secrets; + uint8 pickups; + uint32 time; + uint32 distance; + uint32 randSeedLogic; + uint32 randSeedDraw; + uint16 mediUsed; + uint16 ammoUsed; + uint16 kills; + uint16 flipped; + uint8 tracks[64]; + uint16 invSlots[64]; +}; + +#define SETTINGS_VER 3 +#define SETTINGS_SIZE 128 + +struct Settings +{ + uint8 version; + uint8 controls_vibration:1; + uint8 controls_swap:1; + uint8 audio_sfx:1; + uint8 audio_music:1; + uint8 video_gamma:5; + uint8 video_fps:1; + uint8 video_vsync:1; +}; + +#define FD_SET_END(x,end) ((x) |= ((end) << 15)) +#define FD_END(x) ((x) >> 15) +#define FD_FLOOR_TYPE(x) ((x) & 0x1F) +#define FD_TRIGGER_TYPE(x) (((x) >> 8) & 0x7F) +#define FD_TIMER(x) ((x) & 0xFF) +#define FD_ONCE(x) (((x) >> 8) & 1) +#define FD_SPEED(x) (((x) >> 9) & 0x1F) +#define FD_MASK(x) (((x) >> 9) & 0x1F) +#define FD_ACTION(x) (((x) >> 10) & 0x1F) +#define FD_ARGS(x) ((x) & 0x03FF) +#define FD_SLANT_X(x) int8((x) & 0xFF) +#define FD_SLANT_Z(x) int8((x) >> 8) + +typedef uint16 FloorData; + +enum FloorType +{ + FLOOR_TYPE_NONE, + FLOOR_TYPE_PORTAL, + FLOOR_TYPE_FLOOR, + FLOOR_TYPE_CEILING, + FLOOR_TYPE_TRIGGER, + FLOOR_TYPE_LAVA +}; + +enum TriggerType +{ + TRIGGER_TYPE_ACTIVATE, + TRIGGER_TYPE_PAD, + TRIGGER_TYPE_SWITCH, + TRIGGER_TYPE_KEY, + TRIGGER_TYPE_PICKUP, + TRIGGER_TYPE_OBJECT, + TRIGGER_TYPE_ANTIPAD, + TRIGGER_TYPE_COMBAT, + TRIGGER_TYPE_DUMMY +}; + +enum TriggerAction +{ + TRIGGER_ACTION_ACTIVATE_OBJECT, + TRIGGER_ACTION_ACTIVATE_CAMERA, + TRIGGER_ACTION_FLOW, + TRIGGER_ACTION_FLIP, + TRIGGER_ACTION_FLIP_ON, + TRIGGER_ACTION_FLIP_OFF, + TRIGGER_ACTION_CAMERA_TARGET, + TRIGGER_ACTION_END, + TRIGGER_ACTION_SOUNDTRACK, + TRIGGER_ACTION_EFFECT, + TRIGGER_ACTION_SECRET, + TRIGGER_ACTION_CLEAR_BODIES, + TRIGGER_ACTION_FLYBY, + TRIGGER_ACTION_CUTSCENE +}; + +enum SlantType +{ + SLANT_NONE, + SLANT_LOW, + SLANT_HIGH +}; + +enum WaterState +{ + WATER_STATE_ABOVE, + WATER_STATE_WADE, + WATER_STATE_SURFACE, + WATER_STATE_UNDER +}; + +enum AnimCommand +{ + ANIM_CMD_NONE, + ANIM_CMD_OFFSET, + ANIM_CMD_JUMP, + ANIM_CMD_EMPTY, + ANIM_CMD_KILL, + ANIM_CMD_SOUND, + ANIM_CMD_EFFECT +}; + +enum EffectType +{ + FX_NONE = -1, + FX_ROTATE_180 , + FX_FLOOR_SHAKE , + FX_LARA_NORMAL , + FX_LARA_BUBBLES , + FX_FINISH_LEVEL , + FX_EARTHQUAKE , + FX_FLOOD , + FX_UNK1 , + FX_STAIRS2SLOPE , + FX_UNK3 , + FX_UNK4 , + FX_EXPLOSION , + FX_LARA_HANDSFREE , + FX_FLIP_MAP , + FX_DRAW_RIGHTGUN , + FX_DRAW_LEFTGUN , + FX_SHOT_RIGHTGUN , + FX_SHOT_LEFTGUN , + FX_MESH_SWAP_1 , + FX_MESH_SWAP_2 , + FX_MESH_SWAP_3 , + FX_INV_ON , + FX_INV_OFF , + FX_DYN_ON , + FX_DYN_OFF , + FX_STATUE_FX , + FX_RESET_HAIR , + FX_BOILER_FX , + FX_ASSAULT_RESET , + FX_ASSAULT_STOP , + FX_ASSAULT_START , + FX_ASSAULT_FINISH , + FX_FOOTPRINT , +// specific + FX_TR1_FLICKER = 16 +}; + +enum SoundMode { + UNIQUE, + REPLAY, + LOOP +}; + +enum SoundID +{ + SND_NO = 2, + + SND_LANDING = 4, + + SND_DRAW = 6, + SND_HOLSTER = 7, + SND_PISTOLS_SHOT = 8, + SND_SHOTGUN_RELOAD = 9, + SND_RICOCHET = 10, + + SND_HIT_BEAR = 16, + SND_HIT_WOLF = 20, + + SND_SCREAM = 30, + SND_HIT = 27, + SND_DAMAGE = 31, + + SND_SPLASH = 33, + + SND_BUBBLE = 37, + + SND_UZIS_SHOT = 43, + SND_MAGNUMS_SHOT = 44, + SND_SHOTGUN_SHOT = 45, + SND_EMPTY = 48, + SND_HIT_UNDERWATER = 50, + + SND_UNDERWATER = 60, + + SND_BOULDER = 70, + + SND_FLOOD = 81, + + SND_HIT_LION = 85, + + SND_HIT_RAT = 95, + + SND_LIGHTNING = 98, + SND_ROCK = 99, + + SND_SWORD = 103, + SND_EXPLOSION = 104, + + SND_INV_SPIN = 108, + SND_INV_HOME = 109, + SND_INV_CONTROLS = 110, + SND_INV_SHOW = 111, + SND_INV_HIDE = 112, + SND_INV_COMPASS = 113, + SND_INV_WEAPON = 114, + SND_INV_PAGE = 115, + SND_HEALTH = 116, + + SND_STAIRS2SLOPE = 119, + + SND_NATLA_SHOT = 123, + + SND_HIT_SKATER = 132, + + SND_HIT_ADAM = 142, + SND_STOMP = 147, + + SND_LAVA = 149, + SND_FLAME = 150, + SND_DART = 151, + + SND_TNT = 170, + SND_MUTANT_DEATH = 171, + SND_SECRET = 173, + + SND_HELICOPTER = 297, + + SND_WINSTON_SCARED = 344, + SND_WINSTON_WALK = 345, + SND_WINSTON_PUSH = 346, + SND_WINSTON_TRAY = 347 +}; + +#define LARA_LOOK_ANGLE_MAX ANGLE(22) +#define LARA_LOOK_ANGLE_MIN ANGLE(-42) +#define LARA_LOOK_ANGLE_Y ANGLE(44) +#define LARA_LOOK_TURN_SPEED ANGLE(2) + +enum CollisionType +{ + CT_NONE = 0, + CT_FRONT = (1 << 0), + CT_LEFT = (1 << 1), + CT_RIGHT = (1 << 2), + CT_CEILING = (1 << 3), + CT_FRONT_CEILING = (1 << 4), + CT_FLOOR_CEILING = (1 << 5) +}; + +struct CollisionInfo +{ + enum SideType + { + ST_MIDDLE, + ST_FRONT, + ST_LEFT, + ST_RIGHT, + ST_MAX + }; + + struct Side + { + int32 floor; + int32 ceiling; + SlantType slantType; + }; + + const FloorData* trigger; + + Side m; + Side f; + Side l; + Side r; + + int32 radius; + + int32 gapPos; + int32 gapNeg; + int32 gapCeiling; + + vec3i offset; + vec3i pos; + + int16 angle; + uint16 quadrant; + + CollisionType type; + + int8 slantX; + int8 slantZ; + + bool enemyPush; + bool enemyHit; + bool staticHit; + bool stopOnSlant; + bool stopOnLava; + + void setSide(SideType st, int32 floor, int32 ceiling); + + X_INLINE void setAngle(int16 value) + { + angle = value; + quadrant = uint16(value + ANGLE_45) >> ANGLE_SHIFT_90; + } +}; + +struct Box +{ + uint8 minZ, maxZ; + uint8 minX, maxX; + int16 floor; + uint16 overlap; +}; + +struct CameraFrame +{ + vec3s target; + vec3s pos; + int16 fov; + int16 roll; +}; + +enum Version +{ + VER_TR1_GBA, + VER_TR1_3DO, + VER_TR1_32X, + VER_TR1_PC +}; + +struct Level +{ + uint32 version; + + uint16 tilesCount; + uint16 roomsCount; + uint16 modelsCount; + uint16 meshesCount; + uint16 staticMeshesCount; + uint16 spriteSequencesCount; + uint16 soundSourcesCount; + uint16 boxesCount; + uint16 texturesCount; + uint16 spritesCount; + uint16 itemsCount; + uint16 camerasCount; + uint16 cameraFramesCount; + uint16 soundOffsetsCount; + + const uint16* palette; + const uint8* lightmap; + const uint8* tiles; + const RoomInfo* roomsInfo; + const FloorData* floors; + const Mesh** meshes; + const int32* meshOffsets; + const Anim* anims; + const AnimState* animStates; + const AnimRange* animRanges; + const int16* animCommands; + const ModelNode* nodes; + const uint16* animFrames; + const Model* models; + const StaticMesh* staticMeshes; + Texture* textures; + Sprite* sprites; + const SpriteSeq* spriteSequences; + FixedCamera* cameras; + const SoundSource* soundSources; + Box* boxes; + const uint16* overlaps; + const uint16* zones[2][ZONE_MAX]; + const uint16* animTexData; + const ItemObjInfo* itemsInfo; + const CameraFrame* cameraFrames; + const uint16* soundMap; + const SoundInfo* soundsInfo; + const uint8* soundData; + const int32* soundOffsets; +}; + +// used by enemies +struct TargetInfo +{ + ItemObj* target; + vec3i waypoint; + vec3i pos; + int16 angle; + int16 rotHead; + int16 tilt; + int16 turn; + uint32 dist; + uint16 boxIndex; + uint16 boxIndexTarget; + uint16 zoneIndex; + uint16 zoneIndexTarget; + bool front; + bool behind; + bool canAttack; +}; + +extern TargetInfo tinfo; + +extern Level level; + +struct IMA_STATE +{ + int32 smp; + int32 idx; +}; + +// Currently only used for GBA +struct ADPCM4_STATE +{ + int32 zM1, zM2; + int32 tap; + int32 quant; +}; + +#if defined(GAPI_GL1) + #define PERSPECTIVE_DZ(z) z + + #define PERSPECTIVE(x, y, z) {\ + float invZ = FRAME_PERSP / PERSPECTIVE_DZ(z);\ + x = int32(x * (FRAME_HEIGHT >> 1) * invZ);\ + y = int32(y * (FRAME_HEIGHT >> 1) * invZ);\ + } +#elif defined(MODEHW) || defined(MODE13) + #define PROJ_SHIFT 4 + + #define PERSPECTIVE_DZ(z) (z >> PROJ_SHIFT) + + #define PERSPECTIVE(x, y, z) {\ + int32 dz = PERSPECTIVE_DZ(z);\ + if (dz >= DIV_TABLE_SIZE) dz = DIV_TABLE_SIZE - 1;\ + int32 d = FixedInvU(dz);\ + x = (x * d) >> (16 - PROJ_SHIFT);\ + y = (y * d) >> (16 - PROJ_SHIFT);\ + } +#elif defined(MODE4) + #define PROJ_SHIFT 4 + + #define PERSPECTIVE_DZ(z) ((z >> 4) + (z >> 6)) + + #define PERSPECTIVE(x, y, z) {\ + int32 dz = PERSPECTIVE_DZ(z);\ + if (dz >= DIV_TABLE_SIZE) dz = DIV_TABLE_SIZE - 1;\ + int32 d = FixedInvU(dz);\ + x = (x * d) >> (16 - PROJ_SHIFT);\ + y = (y * d) >> (16 - PROJ_SHIFT);\ + } +#else + #define PERSPECTIVE(x, y, z) {\ + int32 dz = (z >> (FIXED_SHIFT + FOV_SHIFT - 1)) / 3;\ + if (dz >= DIV_TABLE_SIZE) dz = DIV_TABLE_SIZE - 1;\ + int32 d = FixedInvU(dz);\ + x = d * (x >> FIXED_SHIFT) >> 13;\ + y = d * (y >> FIXED_SHIFT) >> 13;\ + } +#endif + +#define STR_LANGUAGES \ + "English" \ + , "Fran|cais" \ + , "Deutsch" + +#define STR_SCALE "25", "50", "75", "100" + +enum StringID { + STR_EMPTY + , STR_ALPHA_END_1 + , STR_ALPHA_END_2 + , STR_ALPHA_END_3 + , STR_ALPHA_END_4 + , STR_ALPHA_END_5 + , STR_ALPHA_END_6 + , STR_GBA_SAVE_WARNING_1 + , STR_GBA_SAVE_WARNING_2 + , STR_GBA_SAVE_WARNING_3 +// common + , STR_LOADING + , STR_LEVEL_STATS + , STR_HINT_SAVING + , STR_HINT_SAVING_DONE + , STR_HINT_SAVING_ERROR + , STR_YES + , STR_NO + , STR_OFF + , STR_ON + , STR_OK + , STR_SBS + , STR_ANAGLYPH + , STR_SPLIT + , STR_VR + , STR_QUALITY_LOW + , STR_QUALITY_MEDIUM + , STR_QUALITY_HIGH + , STR_LANG_EN + , STR_LANG_FR + , STR_LANG_DE +// , STR_LANG_ES +// , STR_LANG_IT +// , STR_LANG_PL +// , STR_LANG_PT +// , STR_LANG_RU +// , STR_LANG_JA +// , STR_LANG_GR +// , STR_LANG_FI +// , STR_LANG_CZ +// , STR_LANG_CN +// , STR_LANG_HU +// , STR_LANG_SV + , STR_APPLY + , STR_GAMEPAD_1 + , STR_GAMEPAD_2 + , STR_GAMEPAD_3 + , STR_GAMEPAD_4 + , STR_NOT_READY + , STR_PLAYER_1 + , STR_PLAYER_2 + , STR_PRESS_ANY_KEY + , STR_HELP_SELECT + , STR_HELP_BACK +// inventory pages + , STR_INV_TITLE_OPTIONS + , STR_INV_TITLE_MAIN + , STR_INV_TITLE_KEYS +// save game page + , STR_SAVEGAME + , STR_CURRENT_POSITION +// inventory option + , STR_GAME + , STR_MAP + , STR_COMPASS + , STR_STOPWATCH + , STR_HOME + , STR_DETAIL + , STR_SOUND + , STR_CONTROLS + , STR_GAMMA +// passport menu + , STR_LOAD_GAME + , STR_SAVE_GAME + , STR_START_GAME + , STR_RESTART_LEVEL + , STR_EXIT_TO_TITLE + , STR_EXIT_GAME + , STR_SELECT_LEVEL +// detail options + , STR_SELECT_DETAIL + , STR_OPT_DETAIL_GAMMA + , STR_OPT_DETAIL_FPS + , STR_OPT_DETAIL_FILTER + , STR_OPT_DETAIL_LIGHTING + , STR_OPT_DETAIL_SHADOWS + , STR_OPT_DETAIL_WATER + , STR_OPT_DETAIL_VSYNC + , STR_OPT_DETAIL_STEREO + , STR_OPT_SIMPLE_ITEMS + , STR_OPT_RESOLUTION + , STR_SCALE_25 + , STR_SCALE_50 + , STR_SCALE_75 + , STR_SCALE_100 +// sound options + , STR_SET_VOLUMES + , STR_REVERBERATION + , STR_OPT_SUBTITLES + , STR_OPT_LANGUAGE + , STR_OPT_SOUND_SFX + , STR_OPT_SOUND_MUSIC +// controls options + , STR_SET_CONTROLS + , STR_OPT_CONTROLS_KEYBOARD + , STR_OPT_CONTROLS_GAMEPAD + , STR_OPT_CONTROLS_VIBRATION + , STR_OPT_CONTROLS_RETARGET + , STR_OPT_CONTROLS_MULTIAIM + , STR_OPT_CONTROLS_SWAP + // controls + , STR_CTRL_RUN + , STR_CTRL_BACK + , STR_CTRL_RIGHT + , STR_CTRL_LEFT + , STR_CTRL_WALK + , STR_CTRL_JUMP + , STR_CTRL_ACTION + , STR_CTRL_WEAPON + , STR_CTRL_LOOK + , STR_CTRL_ROLL + , STR_CTRL_INVENTORY + , STR_CTRL_PAUSE + // control keys + , STR_KEY_UP + , STR_KEY_DOWN + , STR_KEY_RIGHT + , STR_KEY_LEFT + , STR_KEY_A + , STR_KEY_B + , STR_KEY_L + , STR_KEY_R + , STR_KEY_SELECT + , STR_KEY_START + , STR_KEY_L_R + , STR_KEY_L_A + , STR_KEY_L_B +// inventory items + , STR_UNKNOWN + , STR_EXPLOSIVE + , STR_PISTOLS + , STR_SHOTGUN + , STR_MAGNUMS + , STR_UZIS + , STR_AMMO_PISTOLS + , STR_AMMO_SHOTGUN + , STR_AMMO_MAGNUMS + , STR_AMMO_UZIS + , STR_MEDI_SMALL + , STR_MEDI_BIG + , STR_LEAD_BAR + , STR_SCION +// keys + , STR_KEY + , STR_KEY_SILVER + , STR_KEY_RUSTY + , STR_KEY_GOLD + , STR_KEY_SAPPHIRE + , STR_KEY_NEPTUNE + , STR_KEY_ATLAS + , STR_KEY_DAMOCLES + , STR_KEY_THOR + , STR_KEY_ORNATE +// puzzles + , STR_PUZZLE + , STR_PUZZLE_GOLD_IDOL + , STR_PUZZLE_GOLD_BAR + , STR_PUZZLE_COG + , STR_PUZZLE_FUSE + , STR_PUZZLE_ANKH + , STR_PUZZLE_HORUS + , STR_PUZZLE_ANUBIS + , STR_PUZZLE_SCARAB + , STR_PUZZLE_PYRAMID +#ifdef USE_SUBTITLES +// TR1 subtitles + , STR_TR1_SUB_CAFE + , STR_TR1_SUB_LIFT + , STR_TR1_SUB_CANYON + , STR_TR1_SUB_PRISON + , STR_TR1_SUB_22 // CUT4 + , STR_TR1_SUB_23 // CUT1 + , STR_TR1_SUB_24 + , STR_TR1_SUB_25 // CUT3 + , STR_TR1_SUB_26 + , STR_TR1_SUB_27 + , STR_TR1_SUB_28 + , STR_TR1_SUB_29 + , STR_TR1_SUB_30 + , STR_TR1_SUB_31 + , STR_TR1_SUB_32 + , STR_TR1_SUB_33 + , STR_TR1_SUB_34 + , STR_TR1_SUB_35 + , STR_TR1_SUB_36 + , STR_TR1_SUB_37 + , STR_TR1_SUB_38 + , STR_TR1_SUB_39 + , STR_TR1_SUB_40 + , STR_TR1_SUB_41 + , STR_TR1_SUB_42 + , STR_TR1_SUB_43 + , STR_TR1_SUB_44 + , STR_TR1_SUB_45 + , STR_TR1_SUB_46 + , STR_TR1_SUB_47 + , STR_TR1_SUB_48 + , STR_TR1_SUB_49 + , STR_TR1_SUB_50 + , STR_TR1_SUB_51 + , STR_TR1_SUB_52 + , STR_TR1_SUB_53 + , STR_TR1_SUB_54 + , STR_TR1_SUB_55 + , STR_TR1_SUB_56 +#endif +// TR1 levels + , STR_TR1_GYM + , STR_TR1_LEVEL1 + , STR_TR1_LEVEL2 + , STR_TR1_LEVEL3A + , STR_TR1_LEVEL3B + , STR_TR1_LEVEL4 + , STR_TR1_LEVEL5 + , STR_TR1_LEVEL6 + , STR_TR1_LEVEL7A + , STR_TR1_LEVEL7B + , STR_TR1_LEVEL8A + , STR_TR1_LEVEL8B + , STR_TR1_LEVEL8C + , STR_TR1_LEVEL10A + , STR_TR1_LEVEL10B + , STR_TR1_LEVEL10C + , STR_TR1_EGYPT + , STR_TR1_CAT + , STR_TR1_END + , STR_TR1_END2 +// TR2 levels + , STR_TR2_ASSAULT + , STR_TR2_WALL + , STR_TR2_BOAT + , STR_TR2_VENICE + , STR_TR2_OPERA + , STR_TR2_RIG + , STR_TR2_PLATFORM + , STR_TR2_UNWATER + , STR_TR2_KEEL + , STR_TR2_LIVING + , STR_TR2_DECK + , STR_TR2_SKIDOO + , STR_TR2_MONASTRY + , STR_TR2_CATACOMB + , STR_TR2_ICECAVE + , STR_TR2_EMPRTOMB + , STR_TR2_FLOATING + , STR_TR2_XIAN + , STR_TR2_HOUSE +// TR3 levels + , STR_TR3_HOUSE + , STR_TR3_JUNGLE + , STR_TR3_TEMPLE + , STR_TR3_QUADCHAS + , STR_TR3_TONYBOSS + , STR_TR3_SHORE + , STR_TR3_CRASH + , STR_TR3_RAPIDS + , STR_TR3_TRIBOSS + , STR_TR3_ROOFS + , STR_TR3_SEWER + , STR_TR3_TOWER + , STR_TR3_OFFICE + , STR_TR3_NEVADA + , STR_TR3_COMPOUND + , STR_TR3_AREA51 + , STR_TR3_ANTARC + , STR_TR3_MINES + , STR_TR3_CITY + , STR_TR3_CHAMBER + , STR_TR3_STPAUL + + , STR_MAX +}; + +extern const char* const* STR; + +enum TrackID +{ + TRACK_NONE = -1, +// TR1 + TRACK_TR1_TITLE = 4, // TODO 2 + TRACK_TR1_CAVES = 5, + TRACK_TR1_SECRET = 13, + TRACK_TR1_CISTERN = 57, + TRACK_TR1_WIND = 58, + TRACK_TR1_PYRAMID = 59, + TRACK_TR1_CUT_1 = 23, + TRACK_TR1_CUT_2 = 25, + TRACK_TR1_CUT_3 = 24, + TRACK_TR1_CUT_4 = 22 +}; + +struct LevelInfo +{ + const void* data; + StringID title; + TrackID track; + uint8 secrets; +}; + +enum LevelID +{ + LVL_TR1_TITLE, + LVL_TR1_GYM, + LVL_TR1_1, + LVL_TR1_2, + LVL_TR1_3A, + LVL_TR1_3B, + LVL_TR1_CUT_1, + LVL_TR1_4, + LVL_TR1_5, + LVL_TR1_6, + LVL_TR1_7A, + LVL_TR1_7B, + LVL_TR1_CUT_2, + LVL_TR1_8A, + LVL_TR1_8B, + LVL_TR1_8C, + LVL_TR1_10A, + LVL_TR1_CUT_3, + LVL_TR1_10B, + LVL_TR1_CUT_4, + LVL_TR1_10C, + LVL_TR1_EGYPT, + LVL_TR1_CAT, + LVL_TR1_END, + LVL_TR1_END2, + LVL_LOAD, + LVL_MAX +}; + +extern const LevelInfo gLevelInfo[LVL_MAX]; +extern LevelID gLevelID; + +enum BarType { + BAR_HEALTH, + BAR_OXYGEN, + BAR_DASH, + BAR_OPTION, + BAR_MAX +}; + +enum TextAlign { + TEXT_ALIGN_LEFT, + TEXT_ALIGN_RIGHT, + TEXT_ALIGN_CENTER +}; + +// renderer internal +extern uint32 keys; +extern RectMinMax viewport; +extern vec3i gCameraViewPos; +extern Matrix* gMatrixPtr; +extern Matrix gMatrixStack[MAX_MATRICES]; +extern const uint32 gSinCosTable[4096]; + +extern Sphere gSpheres[2][MAX_SPHERES]; + +extern Settings gSettings; +extern SaveGame gSaveGame; +extern uint8 gSaveData[SAVEGAME_SIZE - sizeof(SaveGame)]; + +extern int32 gCurTrack; +extern int32 gAnimTexFrame; +extern int32 gBrightness; +extern int32 gLightAmbient; +extern int32 gRandTable[MAX_RAND_TABLE]; +extern int32 gCaustics[MAX_CAUSTICS]; +extern int32 gCausticsFrame; + +extern const FloorData* gLastFloorData; +extern FloorData gLastFloorSlant; + +extern Room rooms[MAX_ROOMS]; +extern ItemObj items[MAX_ITEMS]; + +template +X_INLINE void swap(T &a, T &b) { + T tmp = a; + a = b; + b = tmp; +} + +X_INLINE uint16 swap16(uint16 x) { + return ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8); +} + +X_INLINE uint32 swap32(uint32 x) { + return ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24); +} + + +extern int32 gRandSeedLogic; +extern int32 gRandSeedDraw; + +int32 rand_logic(); +int32 rand_draw(); + +#define RAND_LOGIC(r) (rand_logic() * (r) >> 15) +#define RAND_DRAW(r) (rand_draw() * (r) >> 15) + +#define sincos(x,s,c) {\ + uint32 sc = gSinCosTable[uint32(x << 16) >> 20];\ + s = int32(sc) >> 16;\ + c = int32(sc) << 16 >> 16;\ +} + +#define sin(x) (int32(gSinCosTable[uint32(x << 16) >> 20]) >> 16) + +int32 phd_atan(int32 x, int32 y); +uint32 phd_sqrt(uint32 x); + +X_INLINE int32 dot(const vec3i &a, const vec3i &b) +{ + return a.x * b.x + a.y * b.y + a.z * b.z; +} + +X_INLINE int32 fastLength(int32 dx, int32 dy) +{ + dx = abs(dx); + dy = abs(dy); + return (dx > dy) ? (dx + (dy >> 1)) : (dy + (dx >> 1)); +} + +void anglesFromVector(int32 x, int32 y, int32 z, int16 &angleX, int16 &angleY); + +X_INLINE int16 angleLerp(int16 a, int16 b, int32 w) +{ + int16 d = b - a; + if (d > +w) return a + w; + if (d < -w) return a - w; + return b; +} + +#define angleDec(angle, value) angleLerp(angle, 0, value) + +bool boxIntersect(const AABBi &i, const AABBi &b); +bool boxContains(const AABBi &a, const vec3i &p); +vec3i boxPushOut(const AABBi &a, const AABBi &b); + +#ifdef CPU_BIG_ENDIAN +#define DECODE_ANGLES(a,x,y,z)\ + x = (a & 0x3FF0) << 2;\ + y = (a & 0x000F) << 12 | ((a >> 16) & 0xFC00) >> 4;\ + z = ((a >> 16) & 0x03FF) << 6; +#else +#define DECODE_ANGLES(a,x,y,z)\ + x = ((a >> 16) & 0x3FF0) << 2;\ + y = ((a >> 16) & 0x000F) << 12 | (a & 0xFC00) >> 4;\ + z = (a & 0x03FF) << 6; +#endif + +#define matrixGet() *gMatrixPtr + +#ifdef USE_ASM + extern "C" { + void matrixPush_asm(); + void matrixSetIdentity_asm(); + void matrixSetBasis_asm(Matrix &dst, const Matrix &src); + void matrixLerp_asm(const Matrix &n, int32 pmul, int32 pdiv); + void matrixTranslateRel_asm(int32 x, int32 y, int32 z); + void matrixTranslateAbs_asm(int32 x, int32 y, int32 z); + void matrixTranslateSet_asm(int32 x, int32 y, int32 z); + void matrixRotateX_asm(int32 angle); + void matrixRotateY_asm(int32 angle); + void matrixRotateZ_asm(int32 angle); + void matrixRotateYQ_asm(int32 quadrant); + void matrixRotateYXZ_asm(int32 angleX, int32 angleY, int32 angleZ); + void matrixFrame_asm(const void* pos, const void* angles); + void boxTranslate_asm(AABBi &box, int32 x, int32 y, int32 z); + void boxRotateYQ_asm(AABBi &box, int32 quadrant); + int32 sphereIsVisible_asm(int32 x, int32 y, int32 z, int32 r); + void flush_asm(); + } + + #define matrixPush matrixPush_asm + #define matrixSetIdentity matrixSetIdentity_asm + #define matrixSetBasis matrixSetBasis_asm + #define matrixLerp matrixLerp_asm + #define matrixTranslateRel matrixTranslateRel_asm + #define matrixTranslateAbs matrixTranslateAbs_asm + #define matrixTranslateSet matrixTranslateSet_asm + #define matrixRotateX matrixRotateX_asm + #define matrixRotateY matrixRotateY_asm + #define matrixRotateZ matrixRotateZ_asm + #define matrixRotateYXZ matrixRotateYXZ_asm + #define matrixRotateYQ matrixRotateYQ_asm + #define matrixFrame matrixFrame_asm + #define boxTranslate boxTranslate_asm + #define boxRotateYQ boxRotateYQ_asm + #define sphereIsVisible sphereIsVisible_asm + #define flush flush_asm +#else + #define matrixPush matrixPush_c + #define matrixSetIdentity matrixSetIdentity_c + #define matrixSetBasis matrixSetBasis_c + #define matrixLerp matrixLerp_c + #define matrixTranslateRel matrixTranslateRel_c + #define matrixTranslateAbs matrixTranslateAbs_c + #define matrixTranslateSet matrixTranslateSet_c + #define matrixRotateX matrixRotateX_c + #define matrixRotateY matrixRotateY_c + #define matrixRotateZ matrixRotateZ_c + #define matrixRotateYXZ matrixRotateYXZ_c + #define matrixRotateYQ matrixRotateYQ_c + #define matrixFrame matrixFrame_c + #define boxTranslate boxTranslate_c + #define boxRotateYQ boxRotateYQ_c + #define sphereIsVisible sphereIsVisible_c + #define flush flush_c + + void matrixPush_c(); + void matrixSetIdentity_c(); + void matrixSetBasis_c(Matrix &dst, const Matrix &src); + void matrixLerp_c(const Matrix &n, int32 pmul, int32 pdiv); + void matrixTranslateRel_c(int32 x, int32 y, int32 z); + void matrixTranslateAbs_c(int32 x, int32 y, int32 z); + void matrixTranslateSet_c(int32 x, int32 y, int32 z); + void matrixRotateX_c(int32 angle); + void matrixRotateY_c(int32 angle); + void matrixRotateZ_c(int32 angle); + void matrixRotateYQ_c(int32 quadrant); + void matrixRotateYXZ_c(int32 angleX, int32 angleY, int32 angleZ); + void matrixFrame_c(const void* pos, const void* angles); + + void boxTranslate_c(AABBi &box, int32 x, int32 y, int32 z); + void boxRotateYQ_c(AABBi &box, int32 quadrant); + int32 sphereIsVisible_c(int32 x, int32 y, int32 z, int32 r); + void flush_c(); +#endif + +#ifdef __32X__ // TODO + #undef matrixPush + #undef matrixSetIdentity + #undef matrixSetBasis + #undef matrixLerp + #undef matrixTranslateRel + #undef matrixTranslateAbs + #undef matrixTranslateSet + #undef matrixRotateX + #undef matrixRotateY + #undef matrixRotateZ + #undef matrixRotateYXZ + #undef matrixRotateYQ + //#undef boxTranslate + //#undef boxRotateYQ + //#undef sphereIsVisible + //#undef flush + + #define matrixPush matrixPush_asm + #define matrixSetIdentity matrixSetIdentity_asm + #define matrixSetBasis matrixSetBasis_asm + #define matrixLerp matrixLerp_asm + #define matrixTranslateRel matrixTranslateRel_asm + #define matrixTranslateAbs matrixTranslateAbs_asm + #define matrixTranslateSet matrixTranslateSet_asm + #define matrixRotateX matrixRotateX_asm + #define matrixRotateY matrixRotateY_asm + #define matrixRotateZ matrixRotateZ_asm + #define matrixRotateYXZ matrixRotateYXZ_asm + #define matrixRotateYQ matrixRotateYQ_asm + //#define boxTranslate boxTranslate_asm + //#define boxRotateYQ boxRotateYQ_asm + //#define sphereIsVisible sphereIsVisible_asm + //#define flush flush_asm + + extern "C" + { + void matrixPush_asm(); + void matrixSetIdentity_asm(); + void matrixSetBasis_asm(Matrix &dst, const Matrix &src); + void matrixLerp_asm(const Matrix &n, int32 pmul, int32 pdiv); + void matrixTranslateRel_asm(int32 x, int32 y, int32 z); + void matrixTranslateAbs_asm(int32 x, int32 y, int32 z); + void matrixTranslateSet_asm(int32 x, int32 y, int32 z); + void matrixRotateX_asm(int32 angle); + void matrixRotateY_asm(int32 angle); + void matrixRotateZ_asm(int32 angle); + void matrixRotateYQ_asm(int32 quadrant); + void matrixRotateYXZ_asm(int32 angleX, int32 angleY, int32 angleZ); + void boxTranslate_asm(AABBi &box, int32 x, int32 y, int32 z); + void boxRotateYQ_asm(AABBi &box, int32 quadrant); + int32 sphereIsVisible_asm(int32 x, int32 y, int32 z, int32 r); + void flush_asm(); + } +#endif + +#define matrixPop() gMatrixPtr--; ASSERT(gMatrixPtr >= gMatrixStack); + +X_INLINE vec3i matrixGetDir(const Matrix &m) +{ + return _vec3i(m.e20, m.e21, m.e22); +} + +void matrixFrame_c(const void* pos, const void* angles); +void matrixFrameLerp(const void* pos, const void* anglesA, const void* anglesB, int32 delta, int32 rate); +void matrixSetView(const vec3i &pos, int32 angleX, int32 angleY); + +#if defined(__GBA__) || defined(__GBA_WIN__) +#define renderInit() +#define renderFree() +#define renderSwap() +#define renderLevelInit() +#define renderLevelFree() +#else +void renderInit(); +void renderFree(); +void renderSwap(); +void renderLevelInit(); +void renderLevelFree(); +#endif + +void setViewport(const RectMinMax &vp); +void setPaletteIndex(int32 index); +void clear(); +void renderRoom(Room* room); +void renderMesh(const Mesh* mesh); +void renderShadow(int32 x, int32 z, int32 sx, int32 sz); +void renderSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index); +void renderGlyph(int32 vx, int32 vy, int32 index); +void renderFill(int32 x, int32 y, int32 width, int32 height, int32 shade, int32 z); +void renderBorder(int32 x, int32 y, int32 width, int32 height, int32 color1, int32 color2, int32 z); +void renderBar(int32 x, int32 y, int32 width, int32 value, BarType type); +void renderBackground(const void* background); +void* copyBackground(); + +int32 getTextWidth(const char* text); + +void drawInit(); +void drawFree(); +void drawLevelInit(); +void drawLevelFree(); +void drawText(int32 x, int32 y, const char* text, TextAlign align); +void drawModel(const ItemObj* item); +void drawSprite(const ItemObj* item); +void drawRooms(Camera* camera); +void drawCinematicRooms(); +void drawHUD(Lara* lara); +void drawNodesLerp(const ItemObj* item, const AnimFrame* frameA, const AnimFrame* frameB, int32 frameDelta, int32 frameRate); + +void calcLightingDynamic(const Room* room, const vec3i &point); +void calcLightingStatic(int32 intensity); + +void checkTrigger(const FloorData* fd, ItemObj* lara); +void readLevel(const uint8 *data); +bool trace(const Location &from, Location &to, bool accurate); + +Lara* getLara(const vec3i &pos); + +bool useSwitch(ItemObj* item, int32 timer); +bool useKey(ItemObj* item, ItemObj* lara); +bool usePickup(ItemObj* item); + +void startLevel(LevelID id); +void nextLevel(LevelID next); +bool gameSave(); +bool gameLoad(); + +int32 doTutorial(ItemObj* lara, int32 track); + +void sndInit(); +void sndInitSamples(); +void sndFreeSamples(); +void sndFill(int8* buffer); +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode); +void sndPlayTrack(int32 track); +bool sndTrackIsPlaying(); +void sndStopTrack(); +void sndStopSample(int32 index); +void sndStop(); + +void palGrayRemap(uint8* data, int32 size); +void palSet(const uint16* palette, int32 gamma, int32 bright); + +void updateFading(int32 frames); + +void dmaFill(void* dst, uint8 value, uint32 count); +void dmaCopy(const void* src, void* dst, uint32 size); + +// system +int32 osGetSystemTimeMS(); +bool osSaveSettings(); +bool osLoadSettings(); +bool osCheckSave(); +bool osSaveGame(); +bool osLoadGame(); +void osJoyVibrate(int32 index, int32 L, int32 R); +void osSetPalette(const uint16* palette); +const void* osLoadScreen(LevelID id); +const void* osLoadLevel(LevelID id); + +#ifdef PROFILING + #define PROFILE_FRAME\ + CNT_UPDATE,\ + CNT_RENDER + + #define PROFILE_STAGES\ + CNT_TRANSFORM,\ + CNT_ADD,\ + CNT_FLUSH,\ + CNT_VERT,\ + CNT_POLY + + #define PROFILE_SOUND\ + CNT_SOUND + + #if defined(PROFILE_FRAMETIME) + enum ProfileCounterId { + PROFILE_FRAME, + CNT_MAX, + PROFILE_STAGES, + PROFILE_SOUND + }; + #elif defined(PROFILE_SOUNDTIME) + enum ProfileCounterId { + PROFILE_SOUND, + CNT_MAX, + PROFILE_FRAME, + PROFILE_STAGES + }; + #else + enum ProfileCounterId { + PROFILE_STAGES, + CNT_MAX, + PROFILE_FRAME, + PROFILE_SOUND + }; + #endif + + extern uint32 gCounters[CNT_MAX]; + + #if defined(__3DO__) || defined(__32X__) // should be first, armcpp bug (#elif) + extern int32 g_timer; + + #define PROFILE_START() {\ + g_timer = osGetSystemTimeMS();\ + } + + #define PROFILE_STOP(value) {\ + value += (osGetSystemTimeMS() - g_timer);\ + } + #elif defined(__WIN32__) || defined(__GBA_WIN__) + extern LARGE_INTEGER g_timer; + extern LARGE_INTEGER g_current; + + #define PROFILE_START() {\ + QueryPerformanceCounter(&g_timer);\ + } + + #define PROFILE_STOP(value) {\ + QueryPerformanceCounter(&g_current);\ + value += uint32(g_current.QuadPart - g_timer.QuadPart);\ + } + #elif defined(__GBA__) + #ifdef PROFILE_SOUNDTIME + #define TIMER_FREQ_DIV 1 + #else + #define TIMER_FREQ_DIV 3 + #endif + + #define PROFILE_START() {\ + REG_TM2CNT_L = 0;\ + REG_TM2CNT_H = (1 << 7) | TIMER_FREQ_DIV;\ + } + + #define PROFILE_STOP(value) {\ + value += REG_TM2CNT_L;\ + REG_TM2CNT_H = 0;\ + } + #else + #define PROFILE_START() aaa + #define PROFILE_STOP(value) bbb + #endif + + struct ProfileCounter + { + ProfileCounterId cnt; + + ProfileCounter(ProfileCounterId cnt) : cnt(cnt) { + if (cnt < CNT_MAX) { + PROFILE_START() + } + } + + ~ProfileCounter() { + if (cnt < CNT_MAX) { + PROFILE_STOP(gCounters[cnt]); + } + } + }; + + #define PROFILE(cnt) ProfileCounter profileCounter(cnt) + #define PROFILE_CLEAR() memset(gCounters, 0, sizeof(gCounters)); +#else + #define PROFILE(cnt) + #define PROFILE_CLEAR() +#endif + + +#endif diff --git a/src/fixed/draw.h b/src/fixed/draw.h new file mode 100644 index 00000000..f65c4900 --- /dev/null +++ b/src/fixed/draw.h @@ -0,0 +1,936 @@ +#ifndef H_DRAW +#define H_DRAW + +#include "common.h" +#include "item.h" + +//#define TEST_ROOM_CACHE + +#ifdef TEST_ROOM_CACHE +RoomVertex roomVert[512]; +EWRAM_DATA RoomQuad roomQuads[512]; +EWRAM_DATA RoomTriangle roomTri[64]; +#endif + +void drawInit() +{ + renderInit(); + + for (int32 i = 0; i < MAX_RAND_TABLE; i++) + { + gRandTable[i] = (rand_draw() >> 5) - 511; + } + + for (int32 i = 0; i < MAX_CAUSTICS; i++) + { + int16 rot = i * (ANGLE_90 * 4) / MAX_CAUSTICS; + gCaustics[i] = sin(rot) * 768 >> FIXED_SHIFT; + } +} + +void drawFree() +{ + renderFree(); +} + +void drawLevelInit() +{ + renderLevelInit(); + +#ifdef TEST_ROOM_CACHE + Room &room = rooms[14]; + + memcpy(roomVert, room.data.vertices, sizeof(RoomVertex) * room.info->verticesCount); + memcpy(roomQuads, room.data.quads, sizeof(RoomQuad) * room.info->quadsCount); + memcpy(roomTri, room.data.triangles, sizeof(RoomTriangle) * room.info->trianglesCount); + + room.data.vertices = roomVert; + room.data.quads = roomQuads; + room.data.triangles = roomTri; +#endif +} + +void drawLevelFree() +{ + renderLevelFree(); +} + +void calcLightingDynamic(const Room* room, const vec3i &point) +{ + const RoomInfo* info = room->info; + + gLightAmbient = (info->ambient << 5); + + if (!info->lightsCount) + return; + + gLightAmbient = 8191 - gLightAmbient; + int32 maxLum = 0; + + for (int i = 0; i < info->lightsCount; i++) + { + const Light* light = room->data.lights + i; + + vec3i pos; + pos.x = light->pos.x + (info->x << 8); + pos.y = light->pos.y; + pos.z = light->pos.z + (info->z << 8); + + int32 radius = light->radius << 8; + int32 intensity = light->intensity << 5; + + vec3i d = point - pos; + int32 dist = dot(d, d) >> 12; + int32 att = X_SQR(radius) >> 12; + + int32 lum = (intensity * att) / (dist + att) + gLightAmbient; + + if (lum > maxLum) { + maxLum = lum; + } + } + + gLightAmbient = 8191 - ((maxLum + gLightAmbient) >> 1); + + Matrix &m = matrixGet(); + + int32 fogZ = m.e23 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT); + if (fogZ > FOG_MIN) { + gLightAmbient += (fogZ - FOG_MIN) << FOG_SHIFT; + gLightAmbient = X_MIN(gLightAmbient, 8191); + } +} + +void calcLightingStatic(int32 intensity) +{ + gLightAmbient = intensity - 4096; + + Matrix &m = matrixGet(); + + int32 fogZ = m.e23 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT); + if (fogZ > FOG_MIN) { + gLightAmbient += (fogZ - FOG_MIN) << FOG_SHIFT; + gLightAmbient = X_MIN(gLightAmbient, 8191); + } +} + +const static uint8 char_width[110] = { + 14, 11, 11, 11, 11, 11, 11, 13, 8, 11, 12, 11, 13, 13, 12, 11, 12, 12, 11, 12, 13, 13, 13, 12, 12, 11, // A-Z + 9, 9, 9, 9, 9, 9, 9, 9, 5, 9, 9, 5, 12, 10, 9, 9, 9, 8, 9, 8, 9, 9, 11, 9, 9, 9, // a-z + 12, 8, 10, 10, 10, 10, 10, 9, 10, 10, // 0-9 + 5, 5, 5, 11, 9, 7, 8, 6, 0, 7, 7, 3, 8, 8, 13, 7, 9, 4, 12, 12, + 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 16, 14, 14, 14, 16, 16, 16, 16, 16, 12, 14, 8, 8, 8, 8, 8, 8, 8 +}; + +static const uint8 char_map[102] = { + 0, 64, 66, 78, 77, 74, 78, 79, 69, 70, 92, 72, 63, 71, 62, 68, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 73, 73, 66, 74, 75, 65, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 80, 76, 81, 97, 98, 77, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 100, 101, 102, 67, 0, 0, 0, 0, 0, 0, 0 +}; + +X_INLINE int32 charRemap(char c) +{ + if (c < 11) + return c + 81; + if (c < 16) + return c + 91; + return char_map[c - 32]; +} + +int32 getTextWidth(const char* text) +{ + int32 w = 0; + + char c; + while ((c = *text++) != 0) + { + if (c == ' ') { + w += 6; + continue; + } + w += char_width[charRemap(c)] + 1; + } + + return w; +} + +void drawText(int32 x, int32 y, const char* text, TextAlign align) +{ + if (!text || !*text) + return; + + if (align == TEXT_ALIGN_CENTER) { + x += (FRAME_WIDTH - getTextWidth(text)) >> 1; + } + + if (align == TEXT_ALIGN_RIGHT) { + x += FRAME_WIDTH - getTextWidth(text); + } + + int32 index; + char c; + while ((c = *text++) != 0) + { + if (c == ' ') { + x += 6; + continue; + } + + if (c == '$') { // special char + index = *text++; + } else { + index = charRemap(c); + } + + int32 iy = y; + + if (c == 'p') { // TODO investigate! + iy--; + } + + renderGlyph(x, iy, level.models[ITEM_GLYPHS].start + index); + x += char_width[index] + 1; + } +} + +void drawMesh(int32 meshIndex) +{ + renderMesh(level.meshes[meshIndex]); +} + +void drawShadow(const ItemObj* item, int32 size) +{ + const Sector* sector = item->room->getSector(item->pos.x, item->pos.z); + int32 floor = sector->getFloor(item->pos.x, item->pos.y, item->pos.z); + + if (floor == WALL) + return; + + const AABBs& box = item->getBoundingBox(true); + int32 x = (box.maxX + box.minX) >> 1; + int32 z = (box.maxZ + box.minZ) >> 1; + int32 sx = (box.maxX - box.minX) * size >> 10; + int32 sz = (box.maxZ - box.minZ) * size >> 10; + + matrixPush(); + matrixTranslateAbs(item->pos.x, floor, item->pos.z); + matrixRotateY(item->angle.y); + + renderShadow(x, z, sx, sz); + + matrixPop(); +} + +void drawSprite(const ItemObj* item) +{ + renderSprite(item->pos.x, item->pos.y, item->pos.z, item->intensity << 5, level.models[item->type].start + item->frameIndex); +} + +void drawFlash(const ExtraInfoLara::Arm::Flash &flash) +{ + matrixPush(); + matrixTranslateRel(0, flash.offset, 55); + matrixRotateYXZ(-ANGLE_90, 0, flash.angle); + + int32 tmp = gLightAmbient; + calcLightingStatic(flash.intensity); + + drawMesh(level.models[ITEM_MUZZLE_FLASH].start); + + gLightAmbient = tmp; + + matrixPop(); +} + +void drawNodes(const ItemObj* item, const AnimFrame* frameA) +{ + const Model* model = level.models + item->type; + const ModelNode* node = level.nodes + model->nodeIndex; + int32 meshIndex = model->start; + int32 meshCount = model->count; + uint32 visibleMask = item->visibleMask; + + const uint32* angles = (uint32*)(frameA->angles + 1); + const int16* extraAngles = (int16*)item->extra; + + matrixFrame(&frameA->pos, angles); + if (visibleMask & 1) { + drawMesh(meshIndex); + } + + while (meshCount > 1) + { + meshIndex++; + visibleMask >>= 1; + angles++; + + if (node->flags & NODE_FLAG_POP) matrixPop(); + if (node->flags & NODE_FLAG_PUSH) matrixPush(); + + matrixFrame(&node->pos, angles); + + if (extraAngles) + { + if (node->flags & NODE_FLAG_ROTY) matrixRotateY(*extraAngles++); + if (node->flags & NODE_FLAG_ROTX) matrixRotateX(*extraAngles++); + if (node->flags & NODE_FLAG_ROTZ) matrixRotateZ(*extraAngles++); + } + + if (visibleMask & 1) { + drawMesh(meshIndex); + } + + meshCount--; + node++; + } +} + +void drawNodesLerp(const ItemObj* item, const AnimFrame* frameA, const AnimFrame* frameB, int32 frameDelta, int32 frameRate) +{ + if (frameDelta == 0) + { + drawNodes(item, frameA); + return; + } + + const Model* model = level.models + item->type; + const ModelNode* node = level.nodes + model->nodeIndex; + int32 meshIndex = model->start; + int32 meshCount = model->count; + uint32 visibleMask = item->visibleMask; + + const uint32* anglesA = (uint32*)(frameA->angles + 1); + const uint32* anglesB = (uint32*)(frameB->angles + 1); + const int16* extraAngles = (int16*)item->extra; + + int32 t = GET_FRAME_T(frameDelta, frameRate); + + vec4s posLerp; + posLerp.x = frameA->pos.x + ((frameB->pos.x - frameA->pos.x) * t >> 16); + posLerp.y = frameA->pos.y + ((frameB->pos.y - frameA->pos.y) * t >> 16); + posLerp.z = frameA->pos.z + ((frameB->pos.z - frameA->pos.z) * t >> 16); + + matrixFrameLerp(&posLerp, anglesA, anglesB, frameDelta, frameRate); + if (visibleMask & 1) { + drawMesh(meshIndex); + } + + while (meshCount > 1) + { + meshIndex++; + visibleMask >>= 1; + anglesA++; + anglesB++; + + if (node->flags & NODE_FLAG_POP) matrixPop(); + if (node->flags & NODE_FLAG_PUSH) matrixPush(); + + matrixFrameLerp(&node->pos, anglesA, anglesB, frameDelta, frameRate); + + if (extraAngles) + { + if (node->flags & NODE_FLAG_ROTY) matrixRotateY(*extraAngles++); + if (node->flags & NODE_FLAG_ROTX) matrixRotateX(*extraAngles++); + if (node->flags & NODE_FLAG_ROTZ) matrixRotateZ(*extraAngles++); + } + + if (visibleMask & 1) { + drawMesh(meshIndex); + } + + meshCount--; + node++; + } +} + +#define DEF_TORSO_ANGLE_X 1216 +#define DEF_TORSO_ANGLE_Y -832 +#define DEF_TORSO_ANGLE_Z -192 + +uint32 ZERO_POS[2] = { 0, 0 }; + +void drawLaraNodes(const ItemObj* lara, const AnimFrame* frameA) +{ + const Model* model = level.models + lara->type; + const ModelNode* node = level.nodes + model->nodeIndex; + const ExtraInfoLara* extraL = lara->extraL; + + const uint16* mesh = extraL->meshes; + + const uint32* anglesArm[LARA_ARM_MAX]; + const uint32* angles = anglesArm[LARA_ARM_R] = anglesArm[LARA_ARM_L] = (uint32*)(frameA->angles + 1); + int32 frameSize = (sizeof(AnimFrame) >> 1) + (model->count << 1); + + vec3s torsoAngle = extraL->torso.angle; + + for (int32 i = 0; i < LARA_ARM_MAX; i++) + { + const ExtraInfoLara::Arm* arm = &extraL->armR + i; + + if (arm->animIndex) + { + const Anim* anim = level.anims + arm->animIndex; + const AnimFrame* frame = (AnimFrame*)(level.animFrames + (anim->frameOffset >> 1) + arm->frameIndex * frameSize); + anglesArm[i] = (uint32*)(frame->angles + 1); + + // additional torso animation for shotgun + if (extraL->weapon == WEAPON_SHOTGUN && i == LARA_ARM_R) + { + int32 aX, aY, aZ; + DECODE_ANGLES(*((uint32*)(frame->angles + 1) + JOINT_TORSO), aX, aY, aZ); + torsoAngle.x = torsoAngle.x + aX - DEF_TORSO_ANGLE_X; + torsoAngle.y = torsoAngle.y + aY - DEF_TORSO_ANGLE_Y; + torsoAngle.z = torsoAngle.z + aZ - DEF_TORSO_ANGLE_Z; + } + } + } + + anglesArm[LARA_ARM_R] += JOINT_ARM_R1; + anglesArm[LARA_ARM_L] += JOINT_ARM_L1; + + const Matrix& basis = matrixGet(); + + matrixPush(); + { // JOINT_HIPS + matrixFrame(&frameA->pos, angles++); + drawMesh(*mesh++); + + for (int32 i = 0; i < 2; i++) // draw Left & Right legs + { + matrixPush(); + { // JOINT_LEG_1 + matrixFrame(&(node++)->pos, angles++); + drawMesh(*mesh++); + + { // JOINT_LEG_2 + matrixFrame(&(node++)->pos, angles++); + drawMesh(*mesh++); + + { // JOINT_LEG_3 + matrixFrame(&(node++)->pos, angles++); + drawMesh(*mesh++); + } + } + } + matrixPop(); + } + + { // JOINT_TORSO + matrixFrame(&(node++)->pos, angles++); + matrixRotateYXZ(torsoAngle.x, torsoAngle.y, torsoAngle.z); + drawMesh(*mesh++); + + for (int32 i = 0; i < LARA_ARM_MAX; i++) // draw Right & Left arms + { + const ExtraInfoLara::Arm* arm = &extraL->armR + i; + + matrixPush(); + // JOINT_ARM_1 + matrixTranslateRel(node->pos.x, node->pos.y, node->pos.z); + node++; + if (arm->useBasis) { // hands are rotated relative to the basis + matrixSetBasis(matrixGet(), basis); + matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z); + } + matrixFrame(ZERO_POS, anglesArm[i]++); + drawMesh(*mesh++); + + { // JOINT_ARM_2 + matrixFrame(&(node++)->pos, anglesArm[i]++); + drawMesh(*mesh++); + + { // JOINT_ARM_3 + matrixFrame(&(node++)->pos, anglesArm[i]); + drawMesh(*mesh++); + + if (arm->flash.timer) { // muzzle flash + drawFlash(arm->flash); + } + } + } + matrixPop(); + } + + { // JOINT_HEAD + matrixFrame(&(node++)->pos, angles + 3 * LARA_ARM_MAX); + matrixRotateYXZ(extraL->head.angle.x, extraL->head.angle.y, extraL->head.angle.z); + drawMesh(*mesh++); + } + } + } + matrixPop(); +} + +void drawLaraNodesLerp(const ItemObj* lara, const AnimFrame* frameA, const AnimFrame* frameB, int32 frameDelta, int32 frameRate) +{ + if (frameDelta == 0) + { + drawLaraNodes(lara, frameA); + return; + } + + const Model* model = level.models + lara->type; + const ModelNode* node = level.nodes + model->nodeIndex; + const ExtraInfoLara* extraL = lara->extraL; + + const uint16* mesh = extraL->meshes; + + const uint32* anglesArmA[LARA_ARM_MAX]; + const uint32* anglesArmB[LARA_ARM_MAX]; + const uint32* anglesA = anglesArmA[LARA_ARM_R] = anglesArmA[LARA_ARM_L] = (uint32*)(frameA->angles + 1); + const uint32* anglesB = anglesArmB[LARA_ARM_R] = anglesArmB[LARA_ARM_L] = (uint32*)(frameB->angles + 1); + int32 frameRateArm[2]; + frameRateArm[0] = frameRateArm[1] = frameRate; + + int32 frameSize = (sizeof(AnimFrame) >> 1) + (model->count << 1); + + vec3s torsoAngle = extraL->torso.angle; + + for (int32 i = 0; i < LARA_ARM_MAX; i++) + { + const ExtraInfoLara::Arm* arm = &extraL->armR + i; + + if (arm->animIndex) + { + const Anim* anim = level.anims + arm->animIndex; + const AnimFrame* frame = (AnimFrame*)(level.animFrames + (anim->frameOffset >> 1) + arm->frameIndex * frameSize); + anglesArmA[i] = anglesArmB[i] = (uint32*)(frame->angles + 1); // no lerp for armed hands (frameRate == 1) + ASSERT(anim->frameRate == 1); + frameRateArm[i] = anim->frameRate; + + // additional torso animation for shotgun + if (extraL->weapon == WEAPON_SHOTGUN && i == LARA_ARM_R) + { + int32 aX, aY, aZ; + DECODE_ANGLES(*((uint32*)(frame->angles + 1) + JOINT_TORSO), aX, aY, aZ); + torsoAngle.x = torsoAngle.x + aX - DEF_TORSO_ANGLE_X; + torsoAngle.y = torsoAngle.y + aY - DEF_TORSO_ANGLE_Y; + torsoAngle.z = torsoAngle.z + aZ - DEF_TORSO_ANGLE_Z; + } + } + } + + anglesArmA[LARA_ARM_R] += JOINT_ARM_R1; + anglesArmB[LARA_ARM_R] += JOINT_ARM_R1; + anglesArmA[LARA_ARM_L] += JOINT_ARM_L1; + anglesArmB[LARA_ARM_L] += JOINT_ARM_L1; + + const Matrix& basis = matrixGet(); + + matrixPush(); + { // JOINT_HIPS + int32 t = GET_FRAME_T(frameDelta, frameRate); + + vec4s posLerp; + posLerp.x = frameA->pos.x + ((frameB->pos.x - frameA->pos.x) * t >> 16); + posLerp.y = frameA->pos.y + ((frameB->pos.y - frameA->pos.y) * t >> 16); + posLerp.z = frameA->pos.z + ((frameB->pos.z - frameA->pos.z) * t >> 16); + + matrixFrameLerp(&posLerp, anglesA++, anglesB++, frameDelta, frameRate); + drawMesh(*mesh++); + + for (int32 i = 0; i < 2; i++) // draw Left & Right legs + { + matrixPush(); + { // JOINT_LEG_1 + matrixFrameLerp(&(node++)->pos, anglesA++, anglesB++, frameDelta, frameRate); + drawMesh(*mesh++); + + { // JOINT_LEG_2 + matrixFrameLerp(&(node++)->pos, anglesA++, anglesB++, frameDelta, frameRate); + drawMesh(*mesh++); + + { // JOINT_LEG_3 + matrixFrameLerp(&(node++)->pos, anglesA++, anglesB++, frameDelta, frameRate); + drawMesh(*mesh++); + } + } + } + matrixPop(); + } + + { // JOINT_TORSO + matrixFrameLerp(&(node++)->pos, anglesA++, anglesB++, frameDelta, frameRate); + matrixRotateYXZ(torsoAngle.x, torsoAngle.y, torsoAngle.z); + drawMesh(*mesh++); + + for (int32 i = 0; i < LARA_ARM_MAX; i++) // draw Right & Left arms + { + const ExtraInfoLara::Arm* arm = &extraL->armR + i; + + matrixPush(); + // JOINT_ARM_1 + matrixTranslateRel(node->pos.x, node->pos.y, node->pos.z); + node++; + if (arm->useBasis) { // hands are rotated relative to the basis + matrixSetBasis(matrixGet(), basis); + matrixRotateYXZ(arm->angle.x, arm->angle.y, arm->angle.z); + } + + bool useLerp = frameRateArm[i] > 1; // armed hands always use frameRate == 1 (i.e. useLerp == false) + + if (useLerp) { + matrixFrameLerp(ZERO_POS, anglesArmA[i]++, anglesArmB[i]++, frameDelta, frameRate); + } else { + matrixFrame(ZERO_POS, anglesArmA[i]++); + } + drawMesh(*mesh++); + + { // JOINT_ARM_2 + if (useLerp) { + matrixFrameLerp(&(node++)->pos, anglesArmA[i]++, anglesArmB[i]++, frameDelta, frameRate); + } else { + matrixFrame(&(node++)->pos, anglesArmA[i]++); + } + drawMesh(*mesh++); + + { // JOINT_ARM_3 + if (useLerp) { + matrixFrameLerp(&(node++)->pos, anglesArmA[i], anglesArmB[i], frameDelta, frameRate); + } else { + matrixFrame(&(node++)->pos, anglesArmA[i]); + } + drawMesh(*mesh++); + + if (arm->flash.timer) { // muzzle flash + drawFlash(arm->flash); + } + } + } + matrixPop(); + } + + { // JOINT_HEAD + matrixFrameLerp(&(node++)->pos, anglesA + 3 * LARA_ARM_MAX, anglesB + 3 * LARA_ARM_MAX, frameDelta, frameRate); + matrixRotateYXZ(extraL->head.angle.x, extraL->head.angle.y, extraL->head.angle.z); + drawMesh(*mesh++); + } + } + } + matrixPop(); +} + +void drawModel(const ItemObj* item) +{ + const AnimFrame *frameA, *frameB; + + int32 frameRate; + int32 frameDelta = item->getFrames(frameA, frameB, frameRate); + +#ifdef NO_ANIM_LERP + frameDelta = 0; +#endif + + int32 sx, sy, sz, sr, smin, smax; + smin = frameA->box.minX; + smax = frameA->box.maxX; + sx = (smax + smin) >> 1; + sr = (smax - smin); + + smin = frameA->box.minY; + smax = frameA->box.maxY; + sy = (smax + smin) >> 1; + sr = X_MAX(sr, (smax - smin)); + + smin = frameA->box.minZ; + smax = frameA->box.maxZ; + sz = (smax + smin) >> 1; + sr = X_MAX(sr, (smax - smin)); + + // approx. radius (TODO more precise) + sr = (sr >> 1) + (sr >> 2); + + // rotate sphere center by quadrant + uint16 quadrant = uint16(item->angle.y + ANGLE_45) >> ANGLE_SHIFT_90; + + if (quadrant != 0) + { + int32 ix = sx; + int32 iz = sz; + + switch (quadrant) + { + case 1: + sx = iz; + sz = -ix; + break; + case 2: + sx = -ix; + sz = -iz; + break; + case 3: + sx = -iz; + sz = ix; + break; + } + } + + sx += item->pos.x - gCameraViewPos.x; + sy += item->pos.y - gCameraViewPos.y; + sz += item->pos.z - gCameraViewPos.z; + + if (!sphereIsVisible(sx, sy, sz, sr)) + return; + + matrixPush(); + matrixTranslateAbs(item->pos.x, item->pos.y, item->pos.z); + matrixRotateYXZ(item->angle.x, item->angle.y, item->angle.z); + + int32 intensity = item->intensity << 5; + + if (intensity == 0) { + vec3i point = item->getRelative(frameA->box.getCenter()); + calcLightingDynamic(item->room, point); + } else { + calcLightingStatic(intensity); + } + + // skip rooms portal clipping for objects + if (item->type == ITEM_LARA) { + drawLaraNodesLerp(item, frameA, frameB, frameDelta, frameRate); + } else { + drawNodesLerp(item, frameA, frameB, frameDelta, frameRate); + } + + matrixPop(); + +// shadow + if (item->flags & ITEM_FLAG_SHADOW) { + drawShadow(item, 160); // TODO per item shadow size + } +} + +void drawRoom(Room* room) +{ + setViewport(room->clip); + + const RoomInfo* info = room->info; + const RoomData& data = room->data; + + int32 rx = info->x << 8; + int32 ry = info->yTop; + int32 rz = info->z << 8; + + matrixPush(); + matrixTranslateAbs(rx, ry, rz); + + setPaletteIndex(ROOM_FLAG_WATER(info->flags) ? 1 : 0); + + renderRoom(room); + + matrixPop(); + + for (int32 i = 0; i < info->spritesCount; i++) + { + const RoomSprite* sprite = data.sprites + i; + renderSprite(sprite->pos.x + rx, sprite->pos.y, sprite->pos.z + rz, sprite->g << 5, sprite->index); + } + + rx -= gCameraViewPos.x; + ry = -gCameraViewPos.y; + rz -= gCameraViewPos.z; + + for (int32 i = 0; i < info->meshesCount; i++) + { + const RoomMesh* mesh = data.meshes + i; + + #ifdef NO_STATIC_MESH_PLANTS + if (STATIC_MESH_ID(mesh->zf) < 10) continue; + #endif + + const StaticMesh* staticMesh = level.staticMeshes + STATIC_MESH_ID(mesh->zf); + + if (!(staticMesh->flags & STATIC_MESH_FLAG_VISIBLE)) continue; // invisible + + int32 px = rx + (int32(mesh->xy) >> 16); + int32 py = ry + (int32(mesh->xy) << 16 >> 16); + int32 pz = rz + (int32(mesh->zf) >> 16); + + int32 sx = (int32(staticMesh->vs.xy) >> 16); + int32 sy = (int32(staticMesh->vs.xy) << 16 >> 16); + int32 sz = (int32(staticMesh->vs.zr) >> 16); + int32 sr = (int32(staticMesh->vs.zr) << 16 >> 16); + + // rotate visible sphere offset + int32 q = STATIC_MESH_QUADRANT(mesh->zf); + if (q == 0) { + sx = -sx; + sz = -sz; + } else if (q == 1) { + int32 t = sx; + sx = -sz; + sz = t; + } else if (q == 3) { + int32 t = sz; + sz = -sx; + sx = t; + } + + sx += px; + sy += py; + sz += pz; + + if (!sphereIsVisible(sx, sy, sz, sr)) + continue; + + matrixPush(); + matrixTranslateSet(px, py, pz); + matrixRotateYQ(q); + + calcLightingStatic(STATIC_MESH_INTENSITY(mesh->zf)); + drawMesh(staticMesh->meshIndex); + + matrixPop(); + } + + ItemObj* item = room->firstItem; + while (item) + { + if ((item->flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_INVISIBLE) { + item->draw(); + } + item = item->nextItem; + } +} + +void drawRooms(Camera* camera) +{ + RectMinMax vp = viewport; + + camera->view.room->clip = viewport; + + Room** visRoom = camera->view.room->getVisibleRooms(); + +#ifdef DRAW_LARA_FIRST + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + Lara* lara = players[i]; + if (lara) + { + lara->flags &= ~ITEM_FLAG_STATUS; + setPaletteIndex(ROOM_FLAG_WATER(lara->room->info->flags) ? 1 : 0); + lara->draw(); + lara->flags |= ITEM_FLAG_STATUS_INVISIBLE; // skip drawing in the general pass + } + } +#endif + // draw rooms and objects + while (*visRoom) + { + Room* room = *visRoom++; + drawRoom(room); + room->reset(); + } + +#ifdef DRAW_LARA_FIRST + // reset visibility flags for Lara + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + Lara* lara = players[i]; + if (lara) + { + lara->flags &= ~ITEM_FLAG_STATUS; + } + } +#endif + + setPaletteIndex(0); + setViewport(vp); +} + +void drawCinematicRooms() +{ + RectMinMax vp = viewport; +#if 1 + gCinematicCamera.view.room->clip = viewport; + + Room** visRoom = gCinematicCamera.view.room->getVisibleRooms(); + + // draw rooms and objects + while (*visRoom) + { + Room* room = *visRoom++; + drawRoom(room); + room->reset(); + } +#else + for (int32 i = 0; i < level.roomsCount; i++) + { + rooms[i].clip = vp; + } + + for (int32 i = 0; i < level.roomsCount; i++) + { + if (rooms[i].info->alternateRoom != NO_ROOM) { + rooms[rooms[i].info->alternateRoom].clip.x0 = 0xFFFF; + } + } + + for (int32 i = 0; i < level.roomsCount; i++) + { + const Room* room = rooms + i; + if (room->clip.x0 == 0xFFFF) + continue; + + drawRoom(room); + } +#endif + + setPaletteIndex(0); + setViewport(vp); +} + +void drawHUD(Lara* lara) +{ + int32 x = (FRAME_WIDTH - (100 + 2 + 2)) - 4; + int32 y = 4; + + if (lara->waterState == WATER_STATE_SURFACE || lara->waterState == WATER_STATE_UNDER) + { + int32 v = (lara->oxygen << 8) / LARA_MAX_OXYGEN; + renderBar(x, y, 100, v, BAR_OXYGEN); + y += 10; + } + + if (lara->extraL->healthTimer || lara->extraL->weaponState == WEAPON_STATE_READY) + { + int32 v = (lara->health << 8) / LARA_MAX_HEALTH; + renderBar(x, y, 100, v, BAR_HEALTH); + } +} + +void drawFPS() +{ +#ifdef __GBA__ + if (gLevelID == LVL_TR1_TITLE) + { + if (REG_WSCNT != (WS_ROM0_N2 | WS_ROM0_S1 | WS_PREFETCH)) + { + drawText(0, 15, "! slow cartridge !", TEXT_ALIGN_CENTER); + } + } +#endif + + if (!gSettings.video_fps) + return; + + char buf[32]; + int2str(fps, buf); + drawText(2, 16, buf, TEXT_ALIGN_LEFT); +} + +#ifdef PROFILING +void drawProfiling() +{ + for (int32 i = 0; i < CNT_MAX; i++) + { + char buf[32]; + int2str(gCounters[i], buf); + drawText(2, 16 + 32 + i * 16, buf, TEXT_ALIGN_LEFT); + } + flush(); +} +#endif + +#endif diff --git a/src/fixed/enemy.h b/src/fixed/enemy.h new file mode 100644 index 00000000..a0e7a7fe --- /dev/null +++ b/src/fixed/enemy.h @@ -0,0 +1,1558 @@ +#ifndef H_ENEMY +#define H_ENEMY + +#include "common.h" +#include "item.h" + +#define ENEMY_TURN_1 ANGLE(1) +#define ENEMY_TURN_2 ANGLE(2) +#define ENEMY_TURN_4 ANGLE(4) +#define ENEMY_TURN_5 ANGLE(5) + +EWRAM_DATA ExtraInfoEnemy enemiesExtra[MAX_ENEMIES]; + +enum AggressionLevel +{ + AGGRESSION_LVL_1 = 0x400, + AGGRESSION_LVL_2 = 0x2000, + AGGRESSION_LVL_3 = 0x4000, + AGGRESSION_LVL_MAX = 0x7FFF +}; + +struct Enemy : ItemObj +{ + Enemy(Room* room, int32 _health, int32 _radius, int32 _headOffset, int32 _aggression) : ItemObj(room) + { + flags |= ITEM_FLAG_SHADOW; + + #ifndef STATIC_ITEMS + angle.y += (rand_logic() - 0x4000) >> 1; + #endif + + ASSERT(_radius < 512); + + health = _health; + radius = _radius >> 1; + headOffset = _headOffset; + aggression = _aggression; + } + + void setExtra(ExtraInfoEnemy* extra) + { + ASSERT(!extraE); + ASSERT(extra); + + if (extra->enemy) + { + extra->enemy->flags &= ~ITEM_FLAG_STATUS; + extra->enemy->flags |= ITEM_FLAG_STATUS_INVISIBLE; + extra->enemy->disable(); + } + + extra->enemy = this; + extra->rotHead = extra->rotNeck = 0; + extra->maxTurn = 0; + extra->nav.stepHeight = 256; + extra->nav.dropHeight = -256; + extra->nav.vSpeed = 0; + extraE = extra; + + initExtra(); + + const Sector* sector = room->getSector(pos.x, pos.z); + ASSERT(sector->boxIndex != NO_BOX); + extraE->nav.init(sector->boxIndex); + } + + bool enable(bool forced) + { + if (extraE) + return true; + + int32 index = -1; + + for (int32 i = 0; i < MAX_ENEMIES; i++) + { + if (!enemiesExtra[i].enemy) + { + index = i; + break; + } + } + + if (index == -1) + { + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + if (!players[i]) + continue; + + vec3i &viewPos = players[i]->extraL->camera.view.pos; + + int32 maxDistQ = 0; + + if (!forced) + { + vec3i d = pos - viewPos; + maxDistQ = X_SQR(d.x >> 8) + X_SQR(d.y >> 8) + X_SQR(d.z >> 8); + } + + for (int32 j = 0; j < MAX_ENEMIES; j++) + { + vec3i d = enemiesExtra[j].enemy->pos - viewPos; + int32 distQ = X_SQR(d.x >> 8) + X_SQR(d.y >> 8) + X_SQR(d.z >> 8); + if (distQ > maxDistQ) + { + maxDistQ = distQ; + index = j; + } + } + } + } + + if (index == -1) + return false; + + setExtra(enemiesExtra + index); + return true; + } + + void disable() + { + ASSERT(extraE); + extraE->enemy = NULL; + extraE = NULL; + } + + void updateTargetInfo() + { + tinfo.target = getLara(pos); + + tinfo.tilt = 0; + tinfo.turn = 0; + tinfo.pos = pos; + + tinfo.dist = 16 * 1024; + tinfo.angle = 0; + tinfo.front = false; + tinfo.behind = false; + tinfo.canAttack = false; + tinfo.rotHead = 0; + + if (health <= 0) + return; + + // update navigation target + const uint16* zones = getZones(); + + tinfo.boxIndex = room->getSector(pos.x, pos.z)->boxIndex; + tinfo.boxIndexTarget = tinfo.target->room->getSector(tinfo.target->pos.x, tinfo.target->pos.z)->boxIndex; + tinfo.zoneIndex = zones[tinfo.boxIndex]; + tinfo.zoneIndexTarget = zones[tinfo.boxIndexTarget]; + + //@TODO blocking + + if (tinfo.target->health <= 0) + { + hitMask = 0; + return; + } + + int32 dx = tinfo.target->pos.x - pos.x; + int32 dz = tinfo.target->pos.z - pos.z; + + if (headOffset) + { + int32 s, c; + sincos(angle.y, s, c); + dx -= s * headOffset >> FIXED_SHIFT; + dz -= c * headOffset >> FIXED_SHIFT; + } + + int16 rot = phd_atan(dz, dx); + + tinfo.dist = fastLength(dx, dz); + tinfo.angle = rot - angle.y; + tinfo.front = abs(tinfo.angle) < ANGLE_90; + tinfo.behind = abs(rot - tinfo.target->angle.y - ANGLE_180) < ANGLE_90; + tinfo.canAttack = tinfo.front && (abs(tinfo.target->pos.y - pos.y) < 256); + tinfo.rotHead = (tinfo.front && mood != MOOD_SLEEP) ? tinfo.angle : 0; + } + + void updateMood() + { + //if (extraE->nav.cells[extraE->boxIndex].weight == ) //@TODO blocking + + if (mood != MOOD_ATTACK && extraE->nav.nextBox != NO_BOX && !checkZone(extraE->nav.endBox)) + { + bool inZone = checkZone(); + if (!inZone) { + mood = MOOD_SLEEP; + } + extraE->nav.nextBox = NO_BOX; + } + + uint32 nextMood = tinfo.target->health <= 0 ? MOOD_SLEEP : ((flags & ITEM_FLAG_ANIMATED) ? getMoodWild() : getMoodNormal()); + + flags &= ~ITEM_FLAG_INJURED; + + if (mood != nextMood) + { + if (mood == MOOD_ATTACK) { + setNextBox(extraE->nav.endBox); + } + extraE->nav.nextBox = NO_BOX; + mood = nextMood; + } + + switch (mood) + { + case MOOD_SLEEP : moodSleep(); break; + case MOOD_STALK : moodStalk(); break; + case MOOD_ATTACK : moodAttack(); break; + case MOOD_ESCAPE : moodEscape(); break; + } + + if (extraE->nav.endBox == NO_BOX) { + setNextBox(tinfo.boxIndex); + } + } + + void moodSleep() + { + int32 boxIndex = getRandomBox(); + + if (!checkZone(boxIndex)) + return; + + if (checkStalk(boxIndex)) + { + mood = MOOD_STALK; + setNextBox(boxIndex); + return; + } + + if (extraE->nav.nextBox != NO_BOX) + return; + + setNextBox(boxIndex); + } + + void moodStalk() + { + if (extraE->nav.nextBox != NO_BOX && checkStalk(extraE->nav.nextBox)) + return; + + int32 boxIndex = getRandomBox(); + + if (!checkZone(boxIndex)) + return; + + if (checkStalk(boxIndex)) + { + setNextBox(boxIndex); + return; + } + + if (extraE->nav.nextBox != NO_BOX) + return; + + setNextBox(boxIndex); + + if (tinfo.zoneIndex != tinfo.zoneIndexTarget) { + mood = MOOD_SLEEP; + } + } + + void moodAttack() + { + if (rand_logic() >= aggression) + return; + + extraE->nav.pos = tinfo.target->pos; + extraE->nav.nextBox = tinfo.boxIndexTarget; + + if (extraE->nav.zoneType == ZONE_FLY) { + extraE->nav.pos.y += tinfo.target->getFrame()->box.minY; // attack Laras head + } + } + + void moodEscape() + { + int32 boxIndex = getRandomBox(); + + if (!checkZone(boxIndex) || (extraE->nav.nextBox != NO_BOX)) + return; + + if (checkEscape(boxIndex)) + { + setNextBox(boxIndex); + return; + } + + if ((tinfo.zoneIndex != tinfo.zoneIndexTarget) || !checkStalk(boxIndex)) + return; + + mood = MOOD_STALK; + setNextBox(boxIndex); + } + + void updateNavigation() + { + tinfo.waypoint = extraE->nav.getWaypoint(tinfo.boxIndex, pos); + + int16 maxTurn = extraE->maxTurn; + + if (health <= 0 || !hSpeed || !maxTurn) + return; + + int32 dx = tinfo.waypoint.x - pos.x; + int32 dz = tinfo.waypoint.z - pos.z; + int16 turn = phd_atan(dz, dx) - angle.y; + int32 r = (hSpeed << FIXED_SHIFT) / maxTurn; //@DIV + int32 d = fastLength(dx, dz); + bool aim = (turn > -ANGLE_90) && (turn < ANGLE_90); + + if (!aim && (d < r)) + maxTurn >>= 1; + + tinfo.turn = X_CLAMP(turn, -maxTurn, maxTurn); + } + + void setNextBox(int16 boxIndex) + { + boxIndex &= 0x7FFF; + const Box* box = level.boxes + boxIndex; + + int32 bMinX = (box->minX << 10) + 512; + int32 bMaxX = (box->maxX << 10) - 512; + int32 bMinZ = (box->minZ << 10) + 512; + int32 bMaxZ = (box->maxZ << 10) - 512; + + extraE->nav.nextBox = boxIndex; + extraE->nav.pos.x = bMinX + RAND_LOGIC(bMaxX - bMinX); + extraE->nav.pos.z = bMinZ + RAND_LOGIC(bMaxZ - bMinZ); + extraE->nav.pos.y = box->floor; + if (extraE->nav.zoneType != ZONE_FLY) + extraE->nav.pos.y -= 384; + } + + uint32 getMoodWild() + { + bool inZone = checkZone(); + + if (mood == MOOD_SLEEP || mood == MOOD_STALK) + return inZone ? MOOD_ATTACK : ((flags & ITEM_FLAG_INJURED) ? MOOD_ESCAPE : mood); + + if (mood == MOOD_ATTACK) + return inZone ? mood : MOOD_SLEEP; + + return inZone ? MOOD_ATTACK : mood; + } + + uint32 getMoodNormal() + { + bool inZone = checkZone(); + + if (mood == MOOD_SLEEP || mood == MOOD_STALK) + { + if ((flags & ITEM_FLAG_INJURED) && (rand_logic() < 0x800 || !inZone)) + return MOOD_ESCAPE; + if (inZone) + return ((tinfo.dist < 3072) || (mood == MOOD_STALK && extraE->nav.nextBox == NO_BOX)) ? MOOD_ATTACK : MOOD_STALK; + return mood; + } + + if (mood == MOOD_ATTACK) + return ((flags & ITEM_FLAG_INJURED) && rand_logic() < 0x800) ? MOOD_ESCAPE : (!inZone ? MOOD_SLEEP : mood); + + return (inZone && rand_logic() < 0x100) ? MOOD_STALK : mood; + } + + X_INLINE bool checkZone() + { + return tinfo.zoneIndex == tinfo.zoneIndexTarget; + } + + X_INLINE int32 getRandomBox() + { + return extraE->nav.cells[RAND_LOGIC(extraE->nav.cellsCount)].boxIndex; + } + + bool checkZone(int16 boxIndex) + { + if (getZones()[boxIndex] != tinfo.zoneIndex) + return false; + + const Box &b = level.boxes[boxIndex]; + + //@TODO blocking + + return (pos.x <= (b.minX << 10)) || (pos.x >= ((b.maxX << 10) - 1)) || + (pos.z <= (b.minZ << 10)) || (pos.z >= ((b.maxZ << 10) - 1)); + } + + bool checkStalk(int16 boxIndex) + { + const Box &b = level.boxes[boxIndex]; + + int32 dx = (((b.minX + b.maxX) << 10) >> 1) - tinfo.target->pos.x; + int32 dz = (((b.minZ + b.maxZ) << 10) >> 1) - tinfo.target->pos.z; + + if (X_MAX(abs(dx), abs(dz)) > 3072) + return false; + + int32 qLara = (tinfo.target->angle.y >> 14) + 2; + int32 qBox = (dz > 0) ? ((dx > 0) ? 2 : 1) : ((dx > 0) ? 3 : 0); + + if (qLara == qBox) // Lara looks at this box + return false; + + if (abs(qLara - qBox) != 2) // Lara looks in the opposite direction + return true; + + dx = pos.x - tinfo.target->pos.x; + dz = pos.z - tinfo.target->pos.z; + + int32 qEnemy = (dz > 0) ? ((dx > 0) ? 2 : 1) : ((dx > 0) ? 3 : 0); + + return qLara != qEnemy; // Lara looks at enemy + } + + bool checkEscape(int16 boxIndex) + { + const Box &b = level.boxes[boxIndex]; + + int32 dx = (((b.minX + b.maxX) << 10) >> 1) - tinfo.target->pos.x; + int32 dz = (((b.minZ + b.maxZ) << 10) >> 1) - tinfo.target->pos.z; + + if (X_MAX(abs(dx), abs(dz)) < 5120) + return false; + + int32 px = pos.x - tinfo.target->pos.x; + int32 pz = pos.z - tinfo.target->pos.z; + + return !(((dx ^ px) & 0x80000000) && ((dz ^ pz) & 0x80000000)); + } + + const uint16* getZones() + { + return level.zones[gSaveGame.flipped][extraE->nav.zoneType]; + } + + void bite(int32 damage, const vec3i &offset, int32 joint) + { + if (!tinfo.target) + return; + + vec3i fxPos = pos + getJoint(joint, offset); + fxBlood(fxPos, 0, 0); + + tinfo.target->hit(damage, offset, 0); + } + + void updateLocation() + { + Room* oldRoom = room; + + updateRoom(); + + int32 h = pos.y - roomFloor; + bool badPos = (h > extraE->nav.stepHeight) || (h < extraE->nav.dropHeight); + + if (!badPos) + { + if (extraE->nav.zoneType == ZONE_FLY) + { + int32 dy = X_CLAMP(tinfo.waypoint.y - pos.y, -extraE->nav.vSpeed, extraE->nav.vSpeed); + int32 y = pos.y + dy; + + const Sector* sector = room->getSector(pos.x, pos.z); + + int32 floor = sector->getFloor(pos.x, y, pos.z); + if (y > floor) + { + if (pos.y > floor) + { + pos.x = tinfo.pos.x; + pos.z = tinfo.pos.z; + dy = -extraE->nav.vSpeed; // go up + } else { + pos.y = floor; + dy = 0; + } + } + + int32 ceiling = sector->getCeiling(pos.x, y, pos.z); + if (y < ceiling) + { + if (pos.y < ceiling) + { + pos.x = tinfo.pos.x; + pos.z = tinfo.pos.z; + dy = extraE->nav.vSpeed; // go down + } else { + pos.y = ceiling; + dy = 0; + } + } + + // update vertical position + pos.y += dy; + + // update pitch + int32 pitch = 0; + if (hSpeed) { + pitch = phd_atan(hSpeed, -dy); + } + angle.x = angleLerp(angle.x, pitch, ANGLE_1); + + updateRoom(); + } else { + if (pos.y > roomFloor) { + pos.y = roomFloor; + } else if (pos.y < roomFloor - 64) { + pos.y += 64; + } else { + pos.y = roomFloor; + } + } + } + + if (!badPos) // check for enemy vs enemy collision + { + ItemObj* item = room->firstItem; + while (item) + { + if (item->type != ITEM_LARA && item != this && item->health > 0 && ((item->flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_ACTIVE)) + { + int32 dx = item->pos.x - pos.x; + int32 dz = item->pos.z - pos.z; + int32 d = fastLength(dx, dz); + + if ((d < (radius << 1)) && hSpeed) + { + tinfo.turn = ANGLE(8); + badPos = true; + break; + } + } + item = item->nextItem; + } + } + + if (!badPos) // check for wrong zone or wall + { + const uint16* zones = getZones(); + uint32 boxIndex = room->getSector(pos.x, pos.z)->boxIndex; + badPos = (boxIndex == NO_BOX) || (tinfo.zoneIndex != zones[boxIndex]); + } + + if (badPos) + { + angle.y += tinfo.turn; // apply turn again for double rotation speed if blocked by something + pos = tinfo.pos; + + if (room != oldRoom) + { + room->remove(this); + oldRoom->add(this); + } + } + + #ifdef _DEBUG + {// TODO investigate enemies respawn + const Sector* sector = room->getSector(pos.x, pos.z); + ASSERT(sector->boxIndex != NO_BOX); + } + #endif + } + + virtual void activate() + { + if (health <= 0) + return; + + ItemObj::activate(); + + if (!enable(!(flags & ITEM_FLAG_STATUS))) { + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INVISIBLE; + } + } + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + ASSERT(health > 0); + + health -= damage; + + if (health > 0) + { + if (soundId) { + soundPlay(soundId, &pos); + } + } else { + gSaveGame.kills++; + #ifdef HIDE_CORPSES + corpseTimer = HIDE_CORPSES; + #endif + } + + if (type != ITEM_MUMMY) { + fxBlood(point, 0, 0); + } + + flags |= ITEM_FLAG_INJURED; + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (!extraE) // disabled + return; + + if (!updateHitMask(lara, cinfo)) + return; + + if (!cinfo->enemyPush) + return; + + int32 r = cinfo->radius; + cinfo->radius = 0; + collidePush(lara, cinfo, true); + cinfo->radius = r; + } + + virtual void update() + { + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INVISIBLE) + { + if (!enable(false)) + return; + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_ACTIVE; + } + + #ifdef HIDE_CORPSES + if ((health <= 0) && !corpseTimer--) + { + deactivate(); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INVISIBLE; + } + #endif + + if (!extraE) + return; + + updateTargetInfo(); + + if (health > 0) + { + updateMood(); + updateNavigation(); + } + + goalState = updateState(); + + animProcess(); + + updateLocation(); + + extraE->rotHead = angleLerp(extraE->rotHead, tinfo.rotHead, ANGLE(5)); + angle.z += X_CLAMP((tinfo.tilt << 2) - angle.z, -ANGLE(3), ANGLE(3)); + angle.y += tinfo.turn; + + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INACTIVE) + { + flags &= ~ITEM_FLAG_COLLISION; + health = NOT_ENEMY; + disable(); + #ifndef HIDE_CORPSES + deactivate(); + #endif + } + } + + virtual int32 updateState() + { + return goalState; + } + + virtual void initExtra() + { + // empty + } + + struct EnemySave { + int16 vSpeed; + int16 hSpeed; + int16 health; + uint8 mood; + uint8 waterState; + }; + + virtual uint8* save(uint8* data) + { + data = ItemObj::save(data); + + EnemySave* sg = (EnemySave*)data; + + sg->vSpeed = vSpeed; + sg->hSpeed = hSpeed; + sg->health = health; + sg->mood = uint8(mood); + sg->waterState = waterState; + + return data + sizeof(EnemySave); + } + + virtual uint8* load(uint8* data) + { + data = ItemObj::load(data); + + EnemySave* sg = (EnemySave*)data; + + vSpeed = sg->vSpeed; + hSpeed = sg->hSpeed; + health = sg->health; + mood = sg->mood; + waterState = sg->waterState; + + return data + sizeof(EnemySave); + } +}; + + +struct Doppelganger : Enemy +{ + Doppelganger(Room* room) : Enemy(room, LARA_MAX_HEALTH, 10, 0, 0) {} +}; + + +struct Wolf : Enemy +{ + enum { + HIT_MASK = 0x774F, // body, head, front legs + + DIST_STALK = 1023 * 3, + DIST_BITE = 345, + DIST_ATTACK = 1024 + 512, + + DAMAGE_BITE = 100, + DAMAGE_ATTACK = 50, + + ANIM_DEATH = 20, + ANIM_DEATH_RUN = 21, + ANIM_DEATH_JUMP = 22 + }; + + enum { + STATE_NONE, + STATE_STOP, + STATE_WALK, + STATE_RUN, + STATE_JUMP, // unused + STATE_STALK, + STATE_ATTACK, + STATE_HOWL, + STATE_SLEEP, + STATE_GROWL, + STATE_TURN, // unused + STATE_DEATH, + STATE_BITE + }; + + Wolf(Room* room) : Enemy(room, 6, 341, 375, AGGRESSION_LVL_2) + { + frameIndex = level.anims[animIndex].frameEnd - 1; + } + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, SND_HIT_WOLF); + + if (health <= 0) { + animSet(level.models[type].animIndex + ANIM_DEATH + RAND_LOGIC(3), true); + } + } + + virtual int32 updateState() + { + if (health <= 0) + return goalState; + + switch (state) + { + case STATE_STOP: + { + if (nextState) + return nextState; + return STATE_WALK; + } + + case STATE_WALK: + { + extraE->maxTurn = ENEMY_TURN_2; + tinfo.tilt = tinfo.turn >> 1; + + if (mood != MOOD_SLEEP) { + nextState = STATE_NONE; + return STATE_STALK; + } + if (rand_logic() < 0x20) { + nextState = STATE_SLEEP; + return STATE_STOP; + } + break; + } + + case STATE_RUN: + { + extraE->maxTurn = ENEMY_TURN_5; + tinfo.tilt = tinfo.turn; + + if (tinfo.front && tinfo.dist < DIST_ATTACK) + { + if (tinfo.dist <= (DIST_ATTACK >> 1) && !tinfo.behind) + { + nextState = STATE_NONE; + return STATE_ATTACK; + } + nextState = STATE_STALK; + return STATE_GROWL; + } + if (mood == MOOD_STALK && tinfo.dist < DIST_STALK) + { + nextState = STATE_STALK; + return STATE_GROWL; + } + if (mood == MOOD_SLEEP) + return STATE_GROWL; + break; + } + + case STATE_STALK: + { + extraE->maxTurn = ENEMY_TURN_2; + + if (mood == MOOD_ESCAPE) + return STATE_RUN; + if ((tinfo.dist < DIST_BITE) && tinfo.canAttack && (tinfo.target->health > 0)) + return STATE_BITE; + if (tinfo.dist > DIST_STALK) + return STATE_RUN; + if (mood == MOOD_ATTACK) + { + if (!tinfo.front || (tinfo.dist > DIST_ATTACK) || tinfo.behind) + return STATE_RUN; + break; + } + if (rand_logic() < 0x180) + { + nextState = STATE_HOWL; + return STATE_GROWL; + } + if (mood == MOOD_SLEEP) + return STATE_GROWL; + break; + } + + case STATE_SLEEP: + { + if ((mood == MOOD_ESCAPE) || checkZone()) + nextState = STATE_GROWL; + else if (rand_logic() < 0x20) + nextState = STATE_WALK; + else + break; + return STATE_STOP; + } + + case STATE_GROWL: + { + if (nextState) + return nextState; + if (mood == MOOD_ESCAPE) + return STATE_RUN; + if (tinfo.dist < DIST_BITE && tinfo.canAttack && (tinfo.target->health > 0)) + return STATE_BITE; + if (mood == MOOD_STALK) + return STATE_STALK; + if (mood == MOOD_SLEEP) + return STATE_STOP; + return STATE_RUN; + } + + case STATE_ATTACK: + { + tinfo.tilt = tinfo.turn; + + if (!nextState && (hitMask & HIT_MASK)) { + bite(DAMAGE_ATTACK, _vec3i(0, -14, 174), 6); + nextState = STATE_RUN; + } + return STATE_RUN; + } + + case STATE_BITE: + { + if (!nextState && (hitMask & HIT_MASK)) { + bite(DAMAGE_BITE, _vec3i(0, -14, 174), 6); + nextState = STATE_GROWL; + } + return STATE_RUN; + } + } + + return goalState; + } + + virtual void initExtra() + { + extraE->nav.stepHeight = 256; + extraE->nav.dropHeight = -1024; + } +}; + + +struct Bear : Enemy +{ + enum { + HIT_MASK = 0x2406C, // front legs and head + + DAMAGE_FALL = 200, + DAMAGE_BITE = 200, + DAMAGE_ATTACK = 400 + }; + + enum { + STATE_NONE = 0, // WTF? + STATE_WALK = 0, + STATE_STOP , + STATE_HIND , + STATE_RUN , + STATE_HOWL , + STATE_GROWL , + STATE_BITE , + STATE_ATTACK , + STATE_EAT , + STATE_DEATH + }; + + Bear(Room* room) : Enemy(room, 20, 341, 500, AGGRESSION_LVL_3) + { + flags |= ITEM_FLAG_ANIMATED; // TODO WILD flag + } + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, SND_HIT_BEAR); + } + + virtual int32 updateState() + { + if (health <= 0) + { + switch (state) + { + case STATE_HIND: + return STATE_HOWL; + case STATE_WALK: + case STATE_RUN: + return STATE_STOP; + case STATE_STOP: + flags &= ~ITEM_FLAG_REVERSE; // TODO special flag + return STATE_DEATH; + case STATE_HOWL: + flags |= ITEM_FLAG_REVERSE; + return STATE_DEATH; + case STATE_DEATH: + if ((flags & ITEM_FLAG_REVERSE) && (hitMask & HIT_MASK) && tinfo.target) // fall on Lara + { + tinfo.target->hit(DAMAGE_FALL, _vec3i(0, 0, 0), 0); + flags &= ~ITEM_FLAG_REVERSE; + } + return STATE_DEATH; + default: + return goalState; + } + } + + // hold the injured flag until death + if (flags & ITEM_FLAG_INJURED) { + flags |= ITEM_FLAG_REVERSE; + } else { + if (flags & ITEM_FLAG_REVERSE) { + flags |= ITEM_FLAG_INJURED; + } + } + + switch (state) + { + case STATE_WALK: + { + extraE->maxTurn = ENEMY_TURN_2; + + if (tinfo.target->health <= 0 && tinfo.front && (hitMask & HIT_MASK)) + return nextState = STATE_STOP; // eat lara! >:E + + if (mood != MOOD_SLEEP) + { + if (mood == MOOD_ESCAPE) { + nextState = STATE_NONE; + } + return STATE_STOP; + } + + if (rand_logic() < 0x50) + { + nextState = STATE_GROWL; + return STATE_STOP; + } + break; + } + + case STATE_STOP: + { + if (tinfo.target->health <= 0) + return (tinfo.canAttack && tinfo.dist < 768) ? STATE_EAT : STATE_WALK; + if (nextState) + return nextState; + return (mood == MOOD_SLEEP) ? STATE_WALK : STATE_RUN; + } + + case STATE_HIND: + { + if (flags & ITEM_FLAG_INJURED) { + nextState = STATE_NONE; + return STATE_HOWL; + } + if (tinfo.front && (hitMask & HIT_MASK)) + return STATE_HOWL; + if (mood == MOOD_ESCAPE) { + nextState = STATE_NONE; + return STATE_HOWL; + } + if (mood == MOOD_SLEEP || rand_logic() < 0x50) { + nextState = STATE_GROWL; + return STATE_HOWL; + } + if (tinfo.dist > 2048 || rand_logic() < 0x600) { + nextState = STATE_STOP; + return STATE_HOWL; + } + return STATE_HOWL; + } + + case STATE_RUN: + { + extraE->maxTurn = ENEMY_TURN_5; + + if (hitMask & HIT_MASK) { + tinfo.target->hit(3, pos, 0); + if (health >= 0) { + nextState = STATE_NONE; + } + } + + if (tinfo.target->health <= 0 || mood == MOOD_SLEEP) + return STATE_STOP; + + if (!nextState && tinfo.front) + { + if (tinfo.dist < 2048) + { + if (!(flags & ITEM_FLAG_INJURED) && (rand_logic() < 0x300)) + { + nextState = STATE_HOWL; + return STATE_STOP; + } + if (tinfo.dist < 1024) + return STATE_BITE; + } + } + break; + } + + case STATE_HOWL: + { + if (flags & ITEM_FLAG_INJURED) + { + nextState = STATE_NONE; + return STATE_STOP; + } + + if (nextState) + return nextState; + + if (mood == MOOD_SLEEP || mood == MOOD_ESCAPE) + return STATE_STOP; + + if (tinfo.canAttack && tinfo.dist < 600) + return STATE_ATTACK; + + return STATE_HIND; + } + + case STATE_BITE: + { + if (!nextState && (hitMask & HIT_MASK)) { + bite(DAMAGE_BITE, _vec3i(0, 96, 335), 14); + nextState = STATE_STOP; + } + break; + } + + case STATE_ATTACK: + { + if (!nextState && (hitMask & HIT_MASK) && tinfo.target) { + tinfo.target->hit(DAMAGE_ATTACK, _vec3i(0, 0, 0), 0); + nextState = STATE_HOWL; + } + break; + } + } + + return goalState; + } +}; + + +struct Bat : Enemy +{ + enum { + DAMAGE_ATTACK = 2 + }; + + enum { + STATE_NONE, + STATE_AWAKE, + STATE_FLY, + STATE_ATTACK, + STATE_CIRCLING, + STATE_DEATH + }; + + Bat(Room* room) : Enemy(room, 1, 102, 0, AGGRESSION_LVL_1) {} + + virtual int32 updateState() + { + if (health <= 0) + { + hSpeed = 0; + if (pos.y < roomFloor) { + flags |= ITEM_FLAG_GRAVITY; + } else { + flags &= ~ITEM_FLAG_GRAVITY; + } + + if (flags & ITEM_FLAG_GRAVITY) + return STATE_CIRCLING; + + pos.y = roomFloor; + return STATE_DEATH; + } + + switch (state) + { + case STATE_AWAKE: + { + return STATE_FLY; + } + + case STATE_FLY: + { + if (hitMask) + return STATE_ATTACK; + break; + } + + case STATE_ATTACK: + { + if (!hitMask) { + mood = MOOD_SLEEP; + return STATE_FLY; + } + bite(DAMAGE_ATTACK, _vec3i(0, 16, 45), 4); + break; + } + } + + return goalState; + } + + virtual void initExtra() + { + extraE->nav.stepHeight = 20 * 1024; + extraE->nav.dropHeight = -20 * 1024; + extraE->nav.vSpeed = 16; + extraE->maxTurn = ANGLE(20); + } +}; + + +struct Crocodile : Enemy +{ + Crocodile(Room* room) : Enemy(room, 20, 341, 600, AGGRESSION_LVL_2) {} + + virtual void initExtra() + { + if (type == ITEM_CROCODILE_LAND) { + extraE->nav.stepHeight = 256; + extraE->nav.dropHeight = -256; + } else { + extraE->nav.stepHeight = 20 * 1024; + extraE->nav.dropHeight = -20 * 1024; + } + } +}; + + +struct Lion : Enemy +{ + Lion(Room* room) : Enemy(room, 1, 341, 400, AGGRESSION_LVL_2) + { + switch (type) + { + case ITEM_LION_MALE : health = 30; aggression = AGGRESSION_LVL_MAX; break; + case ITEM_LION_FEMALE : health = 25; break; + case ITEM_PUMA : health = 40; break; + } + } + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, (type == ITEM_PUMA) ? 0 : SND_HIT_LION); + } + + virtual void initExtra() + { + extraE->nav.stepHeight = 256; + extraE->nav.dropHeight = -1024; + } +}; + + +struct Gorilla : Enemy +{ + Gorilla(Room* room) : Enemy(room, 22, 341, 250, AGGRESSION_LVL_MAX) {} + + virtual void initExtra() + { + extraE->nav.stepHeight = 512; + extraE->nav.dropHeight = -1024; + } +}; + + +struct Rat : Enemy +{ + Rat(Room* room) : Enemy(room, 5, 204, 200, AGGRESSION_LVL_2) {} + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, SND_HIT_RAT); + } +}; + + +struct Rex : Enemy +{ + enum { + HIT_MASK = 0x00003000, // head + DIST_BITE = 1500, + DIST_WALK = 4096, + DIST_RUN = 5120, + DAMAGE_RUN = 10, + DAMAGE_WALK = 1, + DAMAGE_FATAL = 1000 + }; + + enum { + STATE_NONE, + STATE_STOP, + STATE_WALK, + STATE_RUN, + STATE_UNUSED, + STATE_DEATH, + STATE_ROAR, + STATE_BITE, + STATE_FATAL + }; + + Rex(Room* room) : Enemy(room, 100, 341, 2000, AGGRESSION_LVL_MAX) {} + + virtual int32 updateState() + { + if (health <= 0) { + return (state == STATE_STOP) ? STATE_DEATH : STATE_STOP; + } + + extraE->rotNeck = (extraE->rotHead >>= 1); + + if (hitMask) + { + tinfo.target->hit((state == STATE_RUN) ? DAMAGE_RUN : DAMAGE_WALK, _vec3i(0, 0, 0), 0); + } + + bool walk = (tinfo.canAttack && (tinfo.dist > DIST_BITE) && (tinfo.dist < DIST_WALK)) || + (tinfo.behind && !tinfo.front && (mood != MOOD_ESCAPE)); + + switch (state) + { + case STATE_STOP: + { + if (nextState) + return nextState; + if (tinfo.canAttack && (tinfo.dist < DIST_BITE)) + return STATE_BITE; + if ((mood == MOOD_SLEEP) || walk) + return STATE_WALK; + return STATE_RUN; + } + + case STATE_WALK: + { + extraE->maxTurn = ENEMY_TURN_2; + if ((mood != MOOD_SLEEP) && !walk) + return STATE_STOP; + if (tinfo.front && (rand_logic() < 0x200)) + { + nextState = STATE_ROAR; + return STATE_STOP; + } + break; + } + + case STATE_RUN: + { + extraE->maxTurn = ENEMY_TURN_4; + if (((tinfo.dist < DIST_RUN) && tinfo.canAttack) || walk) + return STATE_STOP; + if ((mood != MOOD_ESCAPE) && tinfo.front && (rand_logic() < 0x200)) + { + nextState = STATE_ROAR; + return STATE_STOP; + } + if (mood == MOOD_SLEEP) + return STATE_STOP; + break; + } + + case STATE_BITE: + { + nextState = STATE_WALK; + if (hitMask & HIT_MASK) + { + angle.x = 0; + angle.z = 0; + + tinfo.target->pos = pos; + tinfo.target->angle = angle; + tinfo.target->flags &= ~ITEM_FLAG_GRAVITY; + tinfo.target->hit(DAMAGE_FATAL, _vec3i(0, 0, 0), 0); + tinfo.target->meshSwap(ITEM_LARA_SPEC, 0xFFFFFFFF); + tinfo.target->animSet(level.models[ITEM_LARA_SPEC].animIndex + 1, true); + + if (tinfo.target->room != room) + { + tinfo.target->room->remove(tinfo.target); + room->add(tinfo.target); + } + + return STATE_FATAL; + } + break; + } + } + + return goalState; + } +}; + + +struct Raptor : Enemy +{ + enum { + HIT_MASK = 0xFF7C00, // hands and head + + DIST_BITE = 680, + DIST_ATTACK = 1536, + + DAMAGE_ATTACK = 100, + + ANIM_DEATH_1 = 9, + ANIM_DEATH_2 = 10 + }; + + enum { + STATE_NONE = 0, + STATE_DEATH = 0, + STATE_STOP, + STATE_WALK, + STATE_RUN, + STATE_ATTACK_1, + STATE_UNUSED, + STATE_ROAR, + STATE_ATTACK_2, + STATE_BITE + }; + + Raptor(Room* room) : Enemy(room, 20, 341, 400, AGGRESSION_LVL_3) {} + + virtual void hit(int32 damage, const vec3i& point, int32 soundId) + { + Enemy::hit(damage, point, 0); + + if (health <= 0) { + animSet(level.models[type].animIndex + ANIM_DEATH_1 + RAND_LOGIC(2), true); + } + } + + virtual int32 updateState() + { + if (health <= 0) + return goalState; + + switch (state) + { + case STATE_STOP: { + if (nextState) + return nextState; + if ((hitMask & HIT_MASK) || (tinfo.canAttack && tinfo.dist < DIST_BITE)) + return STATE_BITE; + if (tinfo.canAttack && tinfo.dist < DIST_ATTACK) + return STATE_ATTACK_1; + if (mood == MOOD_SLEEP) + return STATE_WALK; + return STATE_RUN; + } + + case STATE_WALK: { + extraE->maxTurn = ENEMY_TURN_1; + tinfo.tilt = tinfo.turn >> 1; + + if (mood != MOOD_SLEEP) + return STATE_STOP; + + if (rand_logic() < 0x100) { + nextState = STATE_ROAR; + return STATE_STOP; + } + break; + } + + case STATE_RUN: { + extraE->maxTurn = ENEMY_TURN_4; + tinfo.tilt = tinfo.turn; + + if (hitMask & HIT_MASK) + return STATE_STOP; + + if (tinfo.canAttack && tinfo.dist < DIST_ATTACK) + { + if (goalState != STATE_RUN) + break; + return (rand_logic() < 0x2000) ? STATE_STOP : STATE_ATTACK_2; + } + + if (tinfo.front && (mood != MOOD_ESCAPE) && (rand_logic() < 0x100)) + { + nextState = STATE_ROAR; + return STATE_STOP; + } + + if (mood == MOOD_SLEEP) + return STATE_STOP; + break; + } + + case STATE_ATTACK_1: + case STATE_ATTACK_2: + case STATE_BITE: + { + tinfo.tilt = tinfo.turn; + if (!nextState && tinfo.front && (hitMask & HIT_MASK)) { + bite(DAMAGE_ATTACK, _vec3i(0, 66, 318), 22); + nextState = (state == STATE_ATTACK_2) ? STATE_RUN : STATE_STOP; + } + break; + } + } + + return goalState; + } +}; + + +struct Mutant : Enemy +{ + Mutant(Room* room) : Enemy(room, 50, 341, 150, AGGRESSION_LVL_MAX) {} +}; + + +struct Centaur : Enemy +{ + Centaur(Room* room) : Enemy(room, 120, 341, 400, AGGRESSION_LVL_MAX) {} +}; + + +struct Mummy : Enemy +{ + Mummy(Room* room) : Enemy(room, 18, 10, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct Larson : Enemy +{ + Larson(Room* room) : Enemy(room, 50, 102, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct Pierre : Enemy +{ + Pierre(Room* room) : Enemy(room, 70, 102, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct Skater : Enemy +{ + Skater(Room* room) : Enemy(room, 125, 204, 0, AGGRESSION_LVL_MAX) {} + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, SND_HIT_SKATER); + } +}; + + +struct Cowboy : Enemy +{ + Cowboy(Room* room) : Enemy(room, 150, 102, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct MrT : Enemy +{ + MrT(Room* room) : Enemy(room, 200, 102, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct Natla : Enemy +{ + Natla(Room* room) : Enemy(room, 400, 204, 0, AGGRESSION_LVL_MAX) {} +}; + + +struct Adam : Enemy +{ + Adam(Room* room) : Enemy(room, 500, 341, 0, AGGRESSION_LVL_MAX) {} + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + Enemy::hit(damage, point, SND_HIT_ADAM); + } +}; + +#endif diff --git a/src/fixed/fmt/phd.h b/src/fixed/fmt/phd.h new file mode 100644 index 00000000..dc9c97d3 --- /dev/null +++ b/src/fixed/fmt/phd.h @@ -0,0 +1,712 @@ +#ifndef H_PHD +#define H_PHD + +#include "common.h" +#include "stream.h" + +bool read_PHD(DataStream &f) +{ + uint8* ptr = gLevelData; + + uint32 magic = f.read32u(); + if (magic != 0x00000020) + return false; + + level.version = VER_TR1_PC; + + level.tilesCount = f.read32u(); + level.tiles = (uint8*)f.getPtr(); + + f.seek(level.tilesCount * 256 * 256 + 4); + + level.roomsCount = f.read16u(); + level.roomsInfo = (RoomInfo*)ptr; + ptr += level.roomsCount * sizeof(RoomInfo); + + for (uint32 i = 0; i < level.roomsCount; i++) + { + RoomInfo* info = (RoomInfo*)level.roomsInfo + i; + + info->x = f.read32s() >> 8; + info->z = f.read32s() >> 8; + f.seek(4 + 4 + 4); + + info->verticesCount = f.read16u(); + info->data.vertices = (RoomVertex*)ptr; + + int32 vertDataPos = f.getPos(); + + int32 yb = -32768; + int32 yt = 32767; + + f.seek(2); // skip x + for (uint32 j = 0; j < info->verticesCount; j++) + { + int32 y = f.read16s(); // read y + + if (y < yt) { + yt = y; + } + if (y > yb) { + yb = y; + } + + f.seek(2 + 2 + 2); // skip z, g, x + } + + info->yBottom = yb; + info->yTop = yt; + + f.setPos(vertDataPos); + + for (uint32 j = 0; j < info->verticesCount; j++) + { + RoomVertex *v = (RoomVertex*)ADDR_ALIGN4(ptr); + ptr += sizeof(RoomVertex); + + v->x = f.read16s() >> 8; + v->y = (f.read16s() - yt) >> 8; + v->z = f.read16s() >> 8; + v->g = f.read16u() >> 3; + } + + info->quadsCount = f.read16u(); + info->data.quads = (RoomQuad*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->quadsCount; j++) + { + RoomQuad *q = (RoomQuad*)ptr; + ptr += sizeof(RoomQuad); + + q->indices[0] = f.read16u(); + q->indices[1] = f.read16u(); + q->indices[2] = f.read16u(); + q->indices[3] = f.read16u(); + q->flags = f.read16u(); + } + + info->trianglesCount = f.read16u(); + info->data.triangles = (RoomTriangle*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->trianglesCount; j++) + { + RoomTriangle *t = (RoomTriangle*)ptr; + ptr += sizeof(RoomTriangle); + + t->indices[0] = f.read16u(); + t->indices[1] = f.read16u(); + t->indices[2] = f.read16u(); + t->flags = f.read16u(); + } + + info->spritesCount = f.read16u(); + info->data.sprites = (RoomSprite*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->spritesCount; j++) + { + RoomSprite *s = (RoomSprite*)ptr; + ptr += sizeof(RoomSprite); + + int32 idx = f.read16u(); + s->index = f.read16u() * 0xFF; + + int32 pos = f.getPos(); + f.setPos(vertDataPos + 8 * idx); + + s->pos.x = f.read16u(); + s->pos.y = f.read16u(); + s->pos.z = f.read16u(); + s->g = f.read16u() >> 3; + + f.setPos(pos); + } + + info->portalsCount = uint8(f.read16u()); + info->data.portals = (Portal*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->portalsCount; j++) + { + Portal *p = (Portal*)ptr; + ptr += sizeof(Portal); + + p->roomIndex = f.read16s(); + p->n.x = f.read16s(); + p->n.y = f.read16s(); + p->n.z = f.read16s(); + for (int32 k = 0; k < 4; k++) + { + p->v[k].x = f.read16s(); + p->v[k].y = f.read16s(); + p->v[k].z = f.read16s(); + } + } + + info->zSectors = uint8(f.read16u()); + info->xSectors = uint8(f.read16u()); + info->data.sectors = (Sector*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < uint32(info->zSectors) * uint32(info->xSectors); j++) + { + Sector *s = (Sector*)ptr; + ptr += sizeof(Sector); + + s->floorIndex = f.read16u(); + s->boxIndex = f.read16u(); + s->roomBelow = f.read8u(); + s->floor = f.read8s(); + s->roomAbove = f.read8u(); + s->ceiling = f.read8s(); + } + + info->ambient = f.read16u() >> 5; // TODO 3? + + info->lightsCount = uint8(f.read16u()); + info->data.lights = (Light*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->lightsCount; j++) + { + Light *l = (Light*)ptr; + ptr += sizeof(Light); + + l->pos.x = f.read32s() - (info->x << 8); + l->pos.y = f.read32s(); + l->pos.z = f.read32s() - (info->z << 8); + l->intensity = f.read16s() >> 5; // TODO 3? + l->radius = f.read32s() >> 8; + } + + info->meshesCount = uint8(f.read16u()); + info->data.meshes = (RoomMesh*)ADDR_ALIGN4(ptr); + for (uint32 j = 0; j < info->meshesCount; j++) + { + RoomMesh *m = (RoomMesh*)ptr; + ptr += sizeof(RoomMesh); + + vec3s pos; + uint8 intensity; + uint8 flags; + + pos.x = f.read32s() - (info->x << 8); + pos.y = f.read32s(); + pos.z = f.read32s() - (info->z << 8); + flags = ((f.read16s() / 0x4000 + 2) << 6); + intensity = f.read16u() >> 5; // TODO 3? + flags |= f.read16u(); + + m->xy = (pos.x << 16) | uint16(pos.y); + m->zf = (pos.z << 16) | (intensity << 8) | flags; + } + info->meshesCount = 0; // TODO + + info->alternateRoom = uint8(f.read16s()); + uint16 flags = f.read16u(); + + info->flags = 0; + if (flags & 1) info->flags |= 1; // TODO 1? + if (flags & 256) info->flags |= 2; // TODO 2? + + // prepare room + Room* room = rooms + i; + room->info = info; + room->data = info->data; + room->sectors = info->data.sectors; + room->firstItem = NULL; + } + + { // floors data + uint32 floorsCount = f.read32u(); + level.floors = (FloorData*)ADDR_ALIGN4(ptr); + FloorData *fd = (FloorData*)ptr; + for (uint32 i = 0; i < floorsCount; i++) + { + fd[i] = f.read16u(); + } + ptr += sizeof(FloorData) * floorsCount; + } + + { // mesh data + uint32 meshDataCount = f.read32u(); + int32 meshDataPos = f.getPos(); + f.seek(meshDataCount * sizeof(uint16)); + + level.meshesCount = f.read32u(); + level.meshOffsets = (int32*)ptr; + for (uint32 i = 0; i < level.meshesCount; i++) + { + ((int32*)ptr)[i] = f.read32s(); + } + ptr += level.meshesCount * sizeof(int32); + + int32 endPos = f.getPos(); + + level.meshes = (const Mesh**)ADDR_ALIGN4(ptr); + for (int32 i = 0; i < level.meshesCount; i++) + { + if ((level.meshOffsets[i] == 0) && (i > 0)) + continue; + f.setPos(meshDataPos + level.meshOffsets[i]); + + *(int32*)&level.meshOffsets[i] = ptr - (uint8*)level.meshes; + + Mesh* mesh = (Mesh*)ptr; + ptr += sizeof(Mesh); + + mesh->center.x = f.read16s(); + mesh->center.y = f.read16s(); + mesh->center.z = f.read16s(); + mesh->radius = f.read16s(); + mesh->intensity = 4096; + f.seek(2); // skip flags + + { // mesh vertices + mesh->vCount = uint8(f.read16s()); + for (int32 j = 0; j < mesh->vCount; j++) + { + MeshVertex* v = (MeshVertex*)ptr; + ptr += sizeof(MeshVertex); + v->x = f.read16s(); + v->y = f.read16s(); + v->z = f.read16s(); + } + } + + { // mesh lighting + mesh->hasNormals = (f.read16s() > 0); + + if (mesh->hasNormals) + { // normals + for (int32 j = 0; j < mesh->vCount; j++) + { + vec3s* v = (vec3s*)ptr; + ptr += sizeof(vec3s); + v->x = f.read16s(); + v->y = f.read16s(); + v->z = f.read16s(); + } + } + else + { // intensity + for (int32 j = 0; j < mesh->vCount; j++) + { + *(uint16*)ptr++ = f.read16u(); + } + } + } + + { // mesh rects + mesh->rCount = f.read16s(); + for (int32 j = 0; j < mesh->rCount; j++) + { + MeshQuad* v = (MeshQuad*)ptr; + ptr += sizeof(MeshQuad); + v->indices[0] = uint8(f.read16u()); + v->indices[1] = uint8(f.read16u()); + v->indices[2] = uint8(f.read16u()); + v->indices[3] = uint8(f.read16u()); + v->flags = f.read16u(); + } + } + + { // mesh triangles + mesh->tCount = f.read16s(); + for (int32 j = 0; j < mesh->tCount; j++) + { + MeshTriangle* v = (MeshTriangle*)ptr; + ptr += sizeof(MeshTriangle); + v->indices[0] = uint8(f.read16u()); + v->indices[1] = uint8(f.read16u()); + v->indices[2] = uint8(f.read16u()); + v->indices[3] = 0; + v->flags = f.read16u(); + } + } + + { // mesh colored rects + mesh->crCount = f.read16s(); + for (int32 j = 0; j < mesh->crCount; j++) + { + MeshQuad* v = (MeshQuad*)ptr; + ptr += sizeof(MeshQuad); + v->indices[0] = uint8(f.read16u()); + v->indices[1] = uint8(f.read16u()); + v->indices[2] = uint8(f.read16u()); + v->indices[3] = uint8(f.read16u()); + v->flags = f.read16u(); + } + } + + { // mesh colored triangles + mesh->ctCount = f.read16s(); + for (int32 j = 0; j < mesh->ctCount; j++) + { + MeshTriangle* v = (MeshTriangle*)ptr; + ptr += sizeof(MeshTriangle); + v->indices[0] = uint8(f.read16u()); + v->indices[1] = uint8(f.read16u()); + v->indices[2] = uint8(f.read16u()); + v->indices[3] = 0; + v->flags = f.read16u(); + } + } + } + + f.setPos(endPos); + } + + { // anims + uint32 animsCount = f.read32u(); + level.anims = (Anim*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animsCount; i++) + { + Anim* anim = (Anim*)ptr; + ptr += sizeof(Anim); + + anim->frameOffset = f.read32u(); + anim->frameRate = f.read8u(); + anim->frameSize = f.read8u(); + anim->state = f.read16u(); + anim->speed = f.read32u(); + anim->accel = f.read32u(); + anim->frameBegin = f.read16u(); + anim->frameEnd = f.read16u(); + anim->nextAnimIndex = f.read16u(); + anim->nextFrameIndex = f.read16u(); + anim->statesCount = f.read16u(); + anim->statesStart = f.read16u(); + anim->commandsCount = f.read16u(); + anim->commandsStart = f.read16u(); + } + } + + { // anim states + uint32 animStatesCount = f.read32u(); + level.animStates = (AnimState*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animStatesCount; i++) + { + AnimState* animState = (AnimState*)ptr; + ptr += sizeof(AnimState); + + animState->state = uint8(f.read16u()); + animState->rangesCount = uint8(f.read16u()); + animState->rangesStart = f.read16u(); + } + } + + { // anim ranges + uint32 animRangesCount = f.read32u(); + level.animRanges = (AnimRange*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animRangesCount; i++) + { + AnimRange* animRange = (AnimRange*)ptr; + ptr += sizeof(AnimRange); + + animRange->frameBegin = f.read16u(); + animRange->frameEnd = f.read16u(); + animRange->nextAnimIndex = f.read16u(); + animRange->nextFrameIndex = f.read16u(); + } + } + + { // anim commands + uint32 animCommandsCount = f.read32u(); + level.animCommands = (int16*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animCommandsCount; i++) + { + ((int16*)ptr)[i] = f.read16s(); + } + ptr += animCommandsCount * sizeof(int16); + } + + { // nodes + uint32 nodesSize = f.read32u(); + level.nodes = (ModelNode*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < nodesSize / 4; i++) + { + ModelNode* node = (ModelNode*)ptr; + ptr += sizeof(ModelNode); + + node->flags = uint16(f.read32u()); + node->pos.x = int16(f.read32s()); + node->pos.y = int16(f.read32s()); + node->pos.z = int16(f.read32s()); + } + } + + { // anim frames + uint32 animFramesCount = f.read32u(); + level.animFrames = (uint16*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animFramesCount; i++) + { + ((uint16*)ptr)[i] = f.read16u(); + } + ptr += animFramesCount * sizeof(uint16); + } + + { // models + level.modelsCount = f.read32u(); + level.models = (Model*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.modelsCount; i++) + { + Model* model = (Model*)ptr; + ptr += sizeof(Model); + + model->type = uint8(f.read32u()); + model->count = uint8(f.read16u()); + model->start = uint16(f.read16u()); + model->nodeIndex = uint16(f.read32u() / 4); + f.seek(4); // skip frameIndex + model->animIndex = uint16(f.read16u()); + } + } + + { // static meshes + level.staticMeshesCount = f.read32u(); + level.staticMeshes = (StaticMesh*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.staticMeshesCount; i++) + { + StaticMesh* staticMesh = (StaticMesh*)ptr; + ptr += sizeof(StaticMesh); + + staticMesh->id = uint16(f.read32u()); + staticMesh->meshIndex = f.read16u(); + staticMesh->vbox.minX = f.read16s(); + staticMesh->vbox.maxX = f.read16s(); + staticMesh->vbox.minY = f.read16s(); + staticMesh->vbox.maxY = f.read16s(); + staticMesh->vbox.minZ = f.read16s(); + staticMesh->vbox.maxZ = f.read16s(); + staticMesh->cbox.minX = f.read16s(); + staticMesh->cbox.maxX = f.read16s(); + staticMesh->cbox.minY = f.read16s(); + staticMesh->cbox.maxY = f.read16s(); + staticMesh->cbox.minZ = f.read16s(); + staticMesh->cbox.maxZ = f.read16s(); + staticMesh->flags = f.read16u(); + + // TODO calc Sphere16 + } + } + + { // textures + level.texturesCount = f.read32u(); + level.textures = (Texture*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.texturesCount; i++) + { + Texture* texture = (Texture*)ptr; + ptr += sizeof(Texture); + + f.seek(2); // skip attribute + + texture->tile = f.read16u(); + + uint32 uv0 = f.read32u() & 0xFF00FF00; + uint32 uv1 = f.read32u() & 0xFF00FF00; + uint32 uv2 = f.read32u() & 0xFF00FF00; + uint32 uv3 = f.read32u() & 0xFF00FF00; + + texture->uv01 = uv0 | (uv1 >> 8); + texture->uv23 = uv2 | (uv3 >> 8); + } + } + + { // sprite + level.spritesCount = f.read32u(); + level.sprites = (Sprite*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.spritesCount; i++) + { + Sprite* sprite = (Sprite*)ptr; + ptr += sizeof(Sprite); + + sprite->tile = f.read16u(); + uint32 u = f.read8u(); + uint32 v = f.read8u(); + uint32 w = (f.read16u() + 255) >> 8; + uint32 h = (f.read16u() + 255) >> 8; + sprite->uwvh = (u << 24) | (w << 16) | (v << 8) | h; + sprite->l = f.read16s(); + sprite->t = f.read16s(); + sprite->r = f.read16s(); + sprite->b = f.read16s(); + } + } + + { // sprite sequences + level.spriteSequencesCount = f.read32u(); + level.spriteSequences = (SpriteSeq*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.spriteSequencesCount; i++) + { + SpriteSeq* spriteSeq = (SpriteSeq*)ptr; + ptr += sizeof(SpriteSeq); + + spriteSeq->type = f.read16u(); + f.seek(2); + spriteSeq->unused = 0; + spriteSeq->count = f.read16s(); + spriteSeq->start = f.read16u(); + } + } + + { // cameras + level.camerasCount = f.read32u(); + level.cameras = (FixedCamera*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.camerasCount; i++) + { + FixedCamera* camera = (FixedCamera*)ptr; + ptr += sizeof(FixedCamera); + + camera->pos.x = f.read32s(); + camera->pos.y = f.read32s(); + camera->pos.z = f.read32s(); + camera->roomIndex = f.read16s(); + camera->flags = f.read16u(); + } + } + + { // sound sources + level.soundSourcesCount = f.read32u(); + level.soundSources = (SoundSource*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.soundSourcesCount; i++) + { + SoundSource* soundSrc = (SoundSource*)ptr; + ptr += sizeof(SoundSource); + + soundSrc->pos.x = f.read32s(); + soundSrc->pos.y = f.read32s(); + soundSrc->pos.z = f.read32s(); + soundSrc->id = f.read16u(); + soundSrc->flags = f.read16u(); + } + } + + { // boxes + level.boxesCount = f.read32u(); + level.boxes = (Box*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.boxesCount; i++) + { + Box* box = (Box*)ptr; + ptr += sizeof(Box); + + box->minZ = f.read32s() >> 10; + box->maxZ = (f.read32s() + 1) >> 10; + box->minX = f.read32s() >> 10; + box->maxX = (f.read32s() + 1) >> 10; + box->floor = f.read16s(); + box->overlap = f.read16s(); + } + } + + { // overlaps + uint32 overlapsCount = f.read32u(); + level.overlaps = (uint16*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < overlapsCount; i++) + { + ((uint16*)ptr)[i] = f.read16u(); + } + ptr += overlapsCount * sizeof(uint16); + } + + { // zones + for (int32 k = 0; k < 2; k++) + { + for (int32 j = 0; j < ZONE_MAX; j++) + { + level.zones[k][j] = (uint16*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.boxesCount; i++) + { + ((uint16*)ptr)[i] = f.read16u(); + } + ptr += level.boxesCount * sizeof(uint16); + } + } + } + + { // anim textures + uint32 animTexDataCount = f.read32u(); + level.animTexData = (uint16*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < animTexDataCount; i++) + { + ((uint16*)ptr)[i] = f.read16s(); + } + ptr += animTexDataCount * sizeof(uint16); + } + + { // items + level.itemsCount = f.read32u(); + level.itemsInfo = (ItemObjInfo*)ADDR_ALIGN4(ptr); + for (uint32 i = 0; i < level.itemsCount; i++) + { + ItemObjInfo* item = (ItemObjInfo*)ptr; + ptr += sizeof(ItemObjInfo); + + item->type = uint8(f.read16u()); + item->roomIndex = uint8(f.read16u()); + + const RoomInfo* info = level.roomsInfo + item->roomIndex; + item->pos.x = int16(f.read32s() - (info->x << 8)); + item->pos.y = int16(f.read32s()); + item->pos.z = int16(f.read32s() - (info->z << 8)); + + int16 angleY = f.read16s(); + int16 intensity = f.read16s(); + item->intensity = intensity < 0 ? 0 : (intensity >> 5); + item->flags = f.read16u() | ((angleY / ANGLE_90 + 2) << 14); + } + } + + // lightmap + f.seek(256 * 32); // skip + + { // palette + level.palette = (uint16*)ADDR_ALIGN4(ptr); + for (int32 i = 0; i < 256; i++) + { + *ptr++ = f.read8u() << 2; + *ptr++ = f.read8u() << 2; + *ptr++ = f.read8u() << 2; + } + } + + // TODO + // cameraFrames + // demoData + // soundMap + // soundInfo + // soundData + // soundOffsets + + { // fix head mask + #define SET_ROT(joint, mask) (((ModelNode*)level.nodes)[level.models[i].nodeIndex + joint]).flags |= mask; + + for (int32 i = 0; i < level.modelsCount; i++) + { + switch (level.models[i].type) + { + case ITEM_WOLF : SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_BEAR : SET_ROT(13, NODE_FLAG_ROTY); break; + //case ITEM_BAT : break; + case ITEM_CROCODILE_LAND : SET_ROT(7, NODE_FLAG_ROTY); break; + case ITEM_CROCODILE_WATER : SET_ROT(7, NODE_FLAG_ROTY); break; + case ITEM_LION_MALE : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_LION_FEMALE : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_PUMA : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_GORILLA : SET_ROT(13, NODE_FLAG_ROTY); break; + case ITEM_RAT_LAND : SET_ROT(1, NODE_FLAG_ROTY); break; + case ITEM_RAT_WATER : SET_ROT(1, NODE_FLAG_ROTY); break; + case ITEM_REX : SET_ROT(10, NODE_FLAG_ROTY); SET_ROT(11, NODE_FLAG_ROTY); break; + case ITEM_RAPTOR : SET_ROT(21, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_1 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_2 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_3 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_CENTAUR : SET_ROT(10, NODE_FLAG_ROTX | NODE_FLAG_ROTY); break; + case ITEM_MUMMY : SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_LARSON : SET_ROT(6, NODE_FLAG_ROTY); break; + case ITEM_PIERRE : SET_ROT(6, NODE_FLAG_ROTY); break; + case ITEM_SKATER : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_COWBOY : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_MR_T : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_NATLA : SET_ROT(2, NODE_FLAG_ROTX | NODE_FLAG_ROTZ); break; + case ITEM_ADAM : SET_ROT(1, NODE_FLAG_ROTY); break; + default : break; + } + } + + #undef SET_ROT + } + + return true; +} +#endif diff --git a/src/fixed/fmt/pkd.h b/src/fixed/fmt/pkd.h new file mode 100644 index 00000000..12627b10 --- /dev/null +++ b/src/fixed/fmt/pkd.h @@ -0,0 +1,86 @@ +#ifndef H_PKD +#define H_PKD + +#include "common.h" +#include "stream.h" + +bool read_PKD(DataStream &f) +{ + const uint8* data = f.getPtr(); + + memcpy(&level, data, sizeof(level)); + + { // fix level data offsets + uint32* ptr = (uint32*)&level.palette; + while (ptr <= (uint32*)&level.soundOffsets) + { + *ptr++ += (uint32)data; + } + } + + { // prepare rooms + for (int32 i = 0; i < level.roomsCount; i++) + { + Room* room = rooms + i; + room->info = level.roomsInfo + i; + room->data = room->info->data; + + for (uint32 j = 0; j < sizeof(room->data) / 4; j++) + { + int32* x = (int32*)&room->data + j; + *x += (int32)data; + } + + room->sectors = room->data.sectors; + room->firstItem = NULL; + } + } + +#ifndef MODEHW + // initialize global pointers + gBrightness = -128; + palSet(level.palette, gSettings.video_gamma << 4, gBrightness); + memcpy(gLightmap, level.lightmap, sizeof(gLightmap)); +#endif + +#ifdef ROM_READ + // prepare textures (required by anim tex logic) + memcpy(textures, level.textures, level.texturesCount * sizeof(Texture)); + level.textures = textures; + + // prepare sprites (TODO preprocess tile address in packer) + memcpy(sprites, level.sprites, level.spritesCount * sizeof(Sprite)); + level.sprites = sprites; + + // prepare boxes + memcpy(boxes, level.boxes, level.boxesCount * sizeof(Box)); + level.boxes = boxes; + + // prepare fixed cameras + memcpy(cameras, level.cameras, level.camerasCount * sizeof(FixedCamera)); + level.cameras = cameras; +#endif + +#ifdef __3DO__ + for (int32 i = 0; i < level.texturesCount; i++) + { + Texture* tex = level.textures + i; + tex->data += intptr_t(RAM_TEX); + } +#else + // TODO preprocess in packer + for (int32 i = 0; i < level.texturesCount; i++) + { + level.textures[i].tile += (uint32)level.tiles; + } + + for (int32 i = 0; i < level.spritesCount; i++) + { + level.sprites[i].tile += (uint32)level.tiles; + } +#endif + + return true; +} + +#endif diff --git a/src/fixed/game.h b/src/fixed/game.h new file mode 100644 index 00000000..f7023f3a --- /dev/null +++ b/src/fixed/game.h @@ -0,0 +1,367 @@ +#ifndef H_GAME +#define H_GAME + +#include "common.h" +#include "room.h" +#include "camera.h" +#include "item.h" +#include "draw.h" +#include "nav.h" +#include "level.h" +#include "inventory.h" + +EWRAM_DATA LevelID gNextLevel = LVL_MAX; + +void nextLevel(LevelID next) +{ + if ((next == LVL_TR1_3A) && (inventory.state == INV_STATE_NONE)) // alpha version + { + inventory.open(players[0], INV_PAGE_END); + return; + } + gNextLevel = next; +} + +bool gameSave() +{ + gSaveGame.version = SAVEGAME_VER; + gSaveGame.level = gLevelID; + gSaveGame.track = gCurTrack; + gSaveGame.randSeedLogic = gRandSeedLogic; + gSaveGame.randSeedDraw = gRandSeedDraw; + + memset(gSaveGame.invSlots, 0, sizeof(gSaveGame.invSlots)); + memcpy(gSaveGame.invSlots, inventory.counts, sizeof(inventory.counts)); + + uint8* ptr = gSaveData; + ItemObj* item = items; + for (int32 i = 0; i < level.itemsCount; i++, item++) + { + ptr = item->save(ptr); + } + gSaveGame.dataSize = ptr - gSaveData; + + return osSaveGame(); +} + +bool gameLoad() +{ + if (!osLoadGame()) + { + if (gSaveGame.dataSize == 0) + return false; + } + + SaveGame tmp = gSaveGame; + gLevelID = (LevelID)gSaveGame.level; + startLevel(gLevelID); + gSaveGame = tmp; + + inventory.setSlots(gSaveGame.invSlots); + + ItemObj::sFirstActive = NULL; + ItemObj::sFirstFree = items + level.itemsCount; + + uint8* ptr = gSaveData; + ItemObj* item = items; + for (int32 i = 0; i < level.itemsCount; i++, item++) + { + ptr = item->load(ptr); + + if (item->flags & ITEM_FLAG_ACTIVE) { + item->activate(); + } + } + + if (gSaveGame.track != -1) { + sndPlayTrack(gSaveGame.track); + } + + gRandSeedLogic = gSaveGame.randSeedLogic; + gRandSeedDraw = gSaveGame.randSeedDraw; + + return true; +} + +void gameInit() +{ + drawInit(); + + gSaveGame.dataSize = 0; + + gSettings.version = SETTINGS_VER; + gSettings.controls_vibration = 1; + gSettings.controls_swap = 0; + gSettings.audio_sfx = 1; + gSettings.audio_music = 1; + gSettings.video_gamma = 0; + gSettings.video_fps = 1; + gSettings.video_vsync = 0; + osLoadSettings(); + + inventory.init(); + + startLevel(gLevelID); +} + +void gameFree() +{ + drawLevelFree(); + drawFree(); +} + +void resetLara(int32 index, int32 roomIndex, const vec3i &pos, int32 angleY) +{ + Lara* lara = players[index]; + + lara->room->remove(lara); + + lara->pos = pos; + lara->angle.y = angleY; + lara->health = LARA_MAX_HEALTH; + + lara->extraL->camera.target.pos = lara->pos; + lara->extraL->camera.target.room = lara->room; + lara->extraL->camera.view = lara->extraL->camera.target; + + rooms[roomIndex].add(lara); +} + +void gameLoadLevel(const void* data) +{ + drawLevelFree(); + + memset(&gSaveGame, 0, sizeof(gSaveGame)); + memset(enemiesExtra, 0, sizeof(enemiesExtra)); + + ItemObj::sFirstActive = NULL; + ItemObj::sFirstFree = NULL; + + gCurTrack = -1; + + readLevel((uint8*)data); + + // prepare rooms + for (int32 i = 0; i < level.roomsCount; i++) + { + rooms[i].reset(); + } + + // prepare items free list + items[MAX_ITEMS - 1].nextItem = NULL; + for (int32 i = MAX_ITEMS - 2; i >= level.itemsCount; i--) + { + items[i].nextItem = items + i + 1; + } + ItemObj::sFirstFree = items + level.itemsCount; + + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + players[i] = NULL; + } + + if (gLevelID == LVL_TR1_TITLE) { + // init dummy Lara for updateInput() + items->extraL = playersExtra; + items->extraL->camera.mode = CAMERA_MODE_FOLLOW; + inventory.open(items, INV_PAGE_TITLE); + } else { + inventory.page = INV_PAGE_MAIN; + + // init items + for (int32 i = 0; i < level.itemsCount; i++) + { + const ItemObjInfo* info = level.itemsInfo + i; + ItemObj* item = items + i; + + item->type = info->type; + item->intensity = uint8(info->intensity); + + item->pos.x = info->pos.x + (rooms[info->roomIndex].info->x << 8); + item->pos.y = info->pos.y; + item->pos.z = info->pos.z + (rooms[info->roomIndex].info->z << 8); + + item->angle.y = ((info->flags >> 14) - 2) * ANGLE_90; + item->flags = info->flags; + + if (item->type == ITEM_LARA) { + players[0] = (Lara*)item; + } + + item->init(rooms + info->roomIndex); + } + + if (isCutsceneLevel()) + { + gCinematicCamera.initCinematic(); + } + + + // gym + //resetLara(0, 7, _vec3i(39038, -1280, 51712), ANGLE_90); // start + //resetLara(0, 8, _vec3i(55994, 0, 52603), ANGLE_90); // piano + //resetLara(0, 9, _vec3i(47672, 256, 40875), ANGLE_90); // hall + //resetLara(0, 13, _vec3i(38953, 3328, 63961), ANGLE_90 + ANGLE_45); // pool + // level 1 + //resetLara(0, 0, _vec3i(74588, 3072, 19673), ANGLE_0); // first darts + //resetLara(0, 9, _vec3i(49669, 7680, 57891), ANGLE_0); // first door + //resetLara(0, 10, _vec3i(43063, 7168, 61198), ANGLE_0); // transp + //resetLara(0, 14, _vec3i(20215, 6656, 52942), ANGLE_90 + ANGLE_45); // bridge + //resetLara(0, 25, _vec3i(8789, 5632, 80173), 0); // portal + //resetLara(0, 17, _vec3i(16475, 6656, 59845), ANGLE_90); // bear + //resetLara(0, 26, _vec3i(24475, 6912, 83505), ANGLE_90); // switch timer 1 + //resetLara(0, 35, _vec3i(35149, 2048, 74189), ANGLE_90); // switch timer 2 + // level 2 + //resetLara(0, 15, _vec3i(66179, 0, 25920), -ANGLE_90 - ANGLE_45); // sprites + //resetLara(0, 19, _vec3i(61018, 1024, 31214), ANGLE_180); // block + //resetLara(0, 14, _vec3i(64026, 512, 20806), ANGLE_0); // key and puzzle + //resetLara(0, 5, _vec3i(55644, 0, 29155), -ANGLE_90); // keyhole + //resetLara(0, 71, _vec3i(12705, -768, 30195), -ANGLE_90); // puzzle + //resetLara(0, 63, _vec3i(31055, -2048, 33406), ANGLE_0); // right room + //resetLara(0, 44, _vec3i(27868, -1024, 29191), -ANGLE_90); // swing blades + // level 3a + //resetLara(0, 44, _vec3i(73798, 2304, 9819), ANGLE_90); // uw gears + //resetLara(0, 51, _vec3i(41015, 3584, 34494), ANGLE_180); // valley + } + + drawLevelInit(); +} + +void startLevel(LevelID id) +{ + gRandSeedLogic = osGetSystemTimeMS() * 3; + gRandSeedDraw = osGetSystemTimeMS() * 7; + + sndStop(); + sndFreeSamples(); + + const void* data = osLoadLevel(id); + gameLoadLevel(data); + + sndInitSamples(); + sndPlayTrack(getAmbientTrack()); +} + +void updateItems() +{ + ItemObj* item = ItemObj::sFirstActive; + while (item) + { + ItemObj* next = item->nextActive; + item->update(); + item = next; + } + + if (isCutsceneLevel()) + { + gCinematicCamera.updateCinematic(); + } + else + { + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + if (players[i]) { + players[i]->update(); + } + } + } +} + +void gameUpdate(int32 frames) +{ + PROFILE(CNT_UPDATE); + + if (frames > MAX_UPDATE_FRAMES) { + frames = MAX_UPDATE_FRAMES; + } + + if (!sndTrackIsPlaying()) { + gCurTrack = -1; + sndPlayTrack(getAmbientTrack()); + } + + if (inventory.state != INV_STATE_NONE) + { + Lara* lara = (Lara*)inventory.lara; + ASSERT(lara); + lara->updateInput(); + inventory.update(frames); + + if ((inventory.page != INV_PAGE_TITLE) && (inventory.state == INV_STATE_NONE)) + { + if (lara->useItem(inventory.useSlot)) { + inventory.useSlot = SLOT_MAX; + } + } + } + + if ((inventory.page != INV_PAGE_TITLE) && (inventory.state == INV_STATE_NONE) && (gNextLevel == LVL_MAX)) + { + for (int32 i = 0; i < frames; i++) + { + updateItems(); + } + updateLevel(frames); + } + + if ((gNextLevel != LVL_MAX) && (inventory.state == INV_STATE_NONE)) + { + gLevelID = gNextLevel; + gNextLevel = LVL_MAX; + if (gLevelID == LVL_LOAD) { + gameLoad(); + } else { + startLevel(gLevelID); + } + gameUpdate(1); + } +} + +void gameRender() +{ + { + PROFILE(CNT_RENDER); + + setViewport(RectMinMax(0, 0, FRAME_WIDTH, FRAME_HEIGHT)); + + if (inventory.state == INV_STATE_NONE) + { + clear(); + + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + // TODO set viewports for coop + #ifndef PROFILE_SOUNDTIME + if (isCutsceneLevel()) { + drawCinematicRooms(); + } else { + drawRooms(&players[i]->extraL->camera); + } + #endif + + if (players[i]) + { + drawHUD(players[i]); + } + } + } else { + inventory.draw(); + } + + //if (inventory.state == INV_STATE_NONE) + { + drawFPS(); + } + + flush(); + } + +#ifdef PROFILING + drawProfiling(); + #ifndef PROFILE_SOUNDTIME + PROFILE_CLEAR(); + #endif +#endif +} + +#endif diff --git a/src/fixed/inventory.h b/src/fixed/inventory.h new file mode 100644 index 00000000..46898091 --- /dev/null +++ b/src/fixed/inventory.h @@ -0,0 +1,1532 @@ +#ifndef H_INVENTORY +#define H_INVENTORY + +#include "common.h" + +#ifdef __GBA__ +extern const uint8_t TITLE_SCR[]; +#else +extern const void* TITLE_SCR; +#endif + +#define INV_CAMERA_HEIGHT -1536 +#define INV_CAMERA_Y 96 +#define INV_CAMERA_Z 768 +#define INV_RING_RADIUS 688 +#define INV_TILT ANGLE(-45) + +enum InvState { + INV_STATE_NONE, + INV_STATE_OPENING, + INV_STATE_CLOSING, + INV_STATE_CLOSE, + INV_STATE_READY, + INV_STATE_DEATH, + INV_STATE_SPIN, + INV_STATE_SELECT, + INV_STATE_DESELECT, + INV_STATE_SHOW, + INV_STATE_PAGE_MAIN, + INV_STATE_PAGE_KEYS, + INV_STATE_PAGE_OPTIONS +}; + +enum InvPage { + INV_PAGE_TITLE, + INV_PAGE_DEATH, + INV_PAGE_END, + INV_PAGE_USE, + INV_PAGE_MAIN, + INV_PAGE_KEYS, + INV_PAGE_OPTIONS +}; + +enum InvSlot { +// Items + SLOT_LEADBAR, + SLOT_KEY_ITEM_1, + SLOT_KEY_ITEM_2, + SLOT_KEY_ITEM_3, + SLOT_KEY_ITEM_4, + SLOT_PUZZLE_4, + SLOT_PUZZLE_3, + SLOT_PUZZLE_2, + SLOT_PUZZLE_1, + SLOT_SCION, +// Inventory + SLOT_COMPASS, + SLOT_PISTOLS, + SLOT_AMMO_PISTOLS, + SLOT_SHOTGUN, + SLOT_AMMO_SHOTGUN, + SLOT_MAGNUMS, + SLOT_AMMO_MAGNUMS, + SLOT_UZIS, + SLOT_AMMO_UZIS, + SLOT_MEDIKIT_BIG, + SLOT_MEDIKIT_SMALL, +// Options + SLOT_PASSPORT, + SLOT_DETAIL, + SLOT_SOUND, + SLOT_CONTROLS, + SLOT_HOME, + SLOT_MAX +}; + +enum PassportPage { + PASSPORT_PAGE_LOAD_GAME, + PASSPORT_PAGE_SAVE_GAME, + PASSPORT_PAGE_EXIT_TO_TITLE +}; + +enum OptionID +{ +// controls + OPT_ID_RUMBLE = 0, + OPT_ID_SWAP = 1, +// audio + OPT_ID_SFX = 0, + OPT_ID_MUSIC = 1, +// video + OPT_ID_GAMMA = 0, + OPT_ID_FPS = 1, + OPT_ID_VSYNC = 2, +// passport + OPT_ID_OK = 5 +}; + +struct InvItem +{ + uint8 type; + uint8 snd; + int16 selDist; + int16 selRotPre; + int16 selRotX; + int16 selRotY; + StringID str; +}; + +const InvItem INV_SLOTS[SLOT_MAX] = { + { ITEM_INV_LEADBAR , SND_INV_SHOW , 256 , ANGLE(20) , ANGLE(44) , ANGLE(67) , STR_LEAD_BAR }, + { ITEM_INV_KEY_ITEM_1 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_KEY }, + { ITEM_INV_KEY_ITEM_2 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_KEY }, + { ITEM_INV_KEY_ITEM_3 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_KEY }, + { ITEM_INV_KEY_ITEM_4 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_KEY }, + { ITEM_INV_PUZZLE_4 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_PUZZLE }, + { ITEM_INV_PUZZLE_3 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_PUZZLE }, + { ITEM_INV_PUZZLE_2 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_PUZZLE }, + { ITEM_INV_PUZZLE_1 , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(0) , STR_PUZZLE }, + { ITEM_INV_SCION , SND_INV_SHOW , 296 , ANGLE(20) , ANGLE(15) , ANGLE(45) , STR_SCION }, + { ITEM_INV_COMPASS , SND_INV_COMPASS , 512 , ANGLE(20) , ANGLE(70) , ANGLE(0) , STR_COMPASS }, + { ITEM_INV_PISTOLS , SND_INV_WEAPON , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_PISTOLS }, + { ITEM_INV_AMMO_PISTOLS , SND_INV_SHOW , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_AMMO_PISTOLS }, + { ITEM_INV_SHOTGUN , SND_INV_WEAPON , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_SHOTGUN }, + { ITEM_INV_AMMO_SHOTGUN , SND_INV_SHOW , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_AMMO_SHOTGUN }, + { ITEM_INV_MAGNUMS , SND_INV_WEAPON , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_MAGNUMS }, + { ITEM_INV_AMMO_MAGNUMS , SND_INV_SHOW , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_AMMO_MAGNUMS }, + { ITEM_INV_UZIS , SND_INV_WEAPON , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_UZIS }, + { ITEM_INV_AMMO_UZIS , SND_INV_SHOW , 296 , ANGLE(17) , ANGLE(20) , ANGLE(0) , STR_AMMO_UZIS }, + { ITEM_INV_MEDIKIT_BIG , SND_INV_SHOW , 352 , ANGLE(20) , ANGLE(44) , ANGLE(22) , STR_MEDI_BIG }, + { ITEM_INV_MEDIKIT_SMALL , SND_INV_SHOW , 216 , ANGLE(22) , ANGLE(40) , ANGLE(22) , STR_MEDI_SMALL }, + { ITEM_INV_PASSPORT , SND_INV_SHOW , 384 , ANGLE(25) , ANGLE(23) , ANGLE(0) , STR_GAME }, + { ITEM_INV_DETAIL , SND_INV_SHOW , 424 , ANGLE(22) , ANGLE(36) , ANGLE(0) , STR_DETAIL }, + { ITEM_INV_SOUND , SND_INV_SHOW , 368 , ANGLE(26) , ANGLE(12) , ANGLE(0) , STR_SOUND }, + { ITEM_INV_CONTROLS , SND_INV_CONTROLS , 352 , ANGLE(30) , ANGLE(67) , ANGLE(0) , STR_CONTROLS }, + { ITEM_INV_HOME , SND_INV_HOME , 384 , ANGLE(25) , ANGLE(23) , ANGLE(0) , STR_HOME }, +}; + +#define FRAME_PASSPORT 14 +#define FRAME_COMPASS 10 + +struct Inventory +{ + InvSlot useSlot; + + int32 numKeys; + + int16 counts[SLOT_MAX]; + + int32 height; + int32 radius; + int16 pitch; + int16 rot; + int16 rotItem; + int32 selDist; + int16 selRotPre; + int16 selRotX; + int16 selRotY; + + ItemObj* lara; + InvPage page; + InvState state; + InvState nextState; + int32 timer; + + int32 heightTarget; + int32 heightInc; + int32 radiusTarget; + int32 radiusInc; + int32 pitchTarget; + int32 pitchInc; + int32 rotTarget; + int32 rotInc; + int32 rotItemInc; + int32 selDistTarget; + int32 selDistInc; + int32 selRotPreTarget; + int32 selRotPreInc; + int32 selRotXTarget; + int32 selRotXInc; + int32 selRotYTarget; + int32 selRotYInc; + + InvSlot itemsList[SLOT_MAX]; + int32 itemsCount; + uint32 itemVisMask; + int32 itemIndex; + int32 nextIndex; + int32 optionIndex; + int32 optionsCount; + int32 optionsWidth; + int32 optionsHeight; + + PassportPage passportPage; + + int32 frameIndex; + int32 frameTarget; + + const void* background; + + enum OptionType { + OPT_SPACE, + OPT_BUTTON, + OPT_BAR, + OPT_SWITCH, + OPT_VALUE, + OPT_TEXT + }; + + #define OPTION(t,s,v)\ + options[optionsCount].type = t;\ + options[optionsCount].str = s;\ + options[optionsCount].value = v;\ + optionsCount++ + + #define OPTION_SPACE() optionsHeight += 8; OPTION(OPT_SPACE, STR_EMPTY, 0) + #define OPTION_BTN(s,v) optionsHeight += 18; OPTION(OPT_BUTTON, s, v) + #define OPTION_BAR(s,v) optionsHeight += 18; OPTION(OPT_BAR, s, v) + #define OPTION_SWITCH(s,v) optionsHeight += 18; OPTION(OPT_SWITCH, s, v) + #define OPTION_TEXT(s) optionsHeight += 18; OPTION(OPT_TEXT, s, 0) + + struct Option + { + OptionType type; + StringID str; + int32 value; + }; + + Option options[32]; + + void init() + { + memset(counts, 0, sizeof(counts)); + + useSlot = SLOT_MAX; + numKeys = 0; + + add(ITEM_INV_PASSPORT); + add(ITEM_INV_DETAIL); + add(ITEM_INV_SOUND); + add(ITEM_INV_CONTROLS); + add(ITEM_INV_HOME); + + add(ITEM_INV_COMPASS); + + if (gLevelID != LVL_TR1_GYM) + { + add(ITEM_INV_PISTOLS); + add(ITEM_INV_SHOTGUN); + add(ITEM_INV_MAGNUMS); + add(ITEM_INV_UZIS); + add(ITEM_INV_MEDIKIT_SMALL, 10); + add(ITEM_INV_MEDIKIT_BIG, 5); + } + + //add(ITEM_INV_KEY_ITEM_1); + //add(ITEM_INV_PUZZLE_1); + } + + ItemType remapToInv(ItemType type) + { + switch (type) + { + case ITEM_PISTOLS : return ITEM_INV_PISTOLS; + case ITEM_SHOTGUN : return ITEM_INV_SHOTGUN; + case ITEM_MAGNUMS : return ITEM_INV_MAGNUMS; + case ITEM_UZIS : return ITEM_INV_UZIS; + case ITEM_AMMO_PISTOLS : return ITEM_INV_AMMO_PISTOLS; + case ITEM_AMMO_SHOTGUN : return ITEM_INV_AMMO_SHOTGUN; + case ITEM_AMMO_MAGNUMS : return ITEM_INV_AMMO_MAGNUMS; + case ITEM_AMMO_UZIS : return ITEM_INV_AMMO_UZIS; + case ITEM_MEDIKIT_SMALL : return ITEM_INV_MEDIKIT_SMALL; + case ITEM_MEDIKIT_BIG : return ITEM_INV_MEDIKIT_BIG; + case ITEM_PUZZLE_1 : return ITEM_INV_PUZZLE_1; + case ITEM_PUZZLE_2 : return ITEM_INV_PUZZLE_2; + case ITEM_PUZZLE_3 : return ITEM_INV_PUZZLE_3; + case ITEM_PUZZLE_4 : return ITEM_INV_PUZZLE_4; + case ITEM_LEADBAR : return ITEM_INV_LEADBAR; + case ITEM_KEY_ITEM_1 : return ITEM_INV_KEY_ITEM_1; + case ITEM_KEY_ITEM_2 : return ITEM_INV_KEY_ITEM_2; + case ITEM_KEY_ITEM_3 : return ITEM_INV_KEY_ITEM_3; + case ITEM_KEY_ITEM_4 : return ITEM_INV_KEY_ITEM_4; + case ITEM_SCION_PICKUP_QUALOPEC : + case ITEM_SCION_PICKUP_DROP : + case ITEM_SCION_PICKUP_HOLDER : return ITEM_INV_SCION; + default : ; + } + return type; + } + + InvSlot remapToSlot(ItemType type) + { + type = remapToInv(type); + + for (int32 i = 0; i < X_COUNT(INV_SLOTS); i++) + { + if (INV_SLOTS[i].type == type) + return (InvSlot)i; + } + + ASSERT(false); + return SLOT_COMPASS; + } + + InvSlot remapHoleToSlot(ItemType type) + { + switch (type) + { + case ITEM_PUZZLEHOLE_1 : return SLOT_PUZZLE_1; + case ITEM_PUZZLEHOLE_2 : return SLOT_PUZZLE_2; + case ITEM_PUZZLEHOLE_3 : return SLOT_PUZZLE_3; + case ITEM_PUZZLEHOLE_4 : return SLOT_PUZZLE_4; + case ITEM_KEYHOLE_1 : return SLOT_KEY_ITEM_1; + case ITEM_KEYHOLE_2 : return SLOT_KEY_ITEM_2; + case ITEM_KEYHOLE_3 : return SLOT_KEY_ITEM_3; + case ITEM_KEYHOLE_4 : return SLOT_KEY_ITEM_4; + default : ; + } + return SLOT_MAX; + } + + void add(ItemType type, int32 count = 1) + { + InvSlot slot = remapToSlot(type); + counts[slot] += count; + // TODO check max + + if (slot < SLOT_COMPASS) { + numKeys += count; + } + } + + void remove(InvSlot slot, int32 count) + { + counts[slot] -= count; + + if (slot < SLOT_COMPASS) { + numKeys -= count; + } + } + + void setSlots(uint16* invSlots) + { + numKeys = 0; + + memcpy(counts, invSlots, sizeof(counts)); + + for (int32 i = 0; i < SLOT_COMPASS; i++) + { + numKeys += counts[i]; + } + } + + bool applyItem(ItemObj* hole) + { + #define CHECK_CASE(A, B) case A: { if (useSlot != B) return false; break; } + + switch (hole->type) + { + CHECK_CASE(ITEM_PUZZLEHOLE_1, SLOT_PUZZLE_1); + CHECK_CASE(ITEM_PUZZLEHOLE_2, SLOT_PUZZLE_2); + CHECK_CASE(ITEM_PUZZLEHOLE_3, SLOT_PUZZLE_3); + CHECK_CASE(ITEM_PUZZLEHOLE_4, SLOT_PUZZLE_4); + CHECK_CASE(ITEM_KEYHOLE_1, SLOT_KEY_ITEM_1); + CHECK_CASE(ITEM_KEYHOLE_2, SLOT_KEY_ITEM_2); + CHECK_CASE(ITEM_KEYHOLE_3, SLOT_KEY_ITEM_3); + CHECK_CASE(ITEM_KEYHOLE_4, SLOT_KEY_ITEM_4); + default: return false; + } + + remove(useSlot, 1); + useSlot = SLOT_MAX; + + return true; + } + + void setState(InvState state, InvState nextState, int32 timer) + { + this->state = state; + this->nextState = nextState; + this->timer = timer; + + rotItemInc = -rotItem / timer; + } + + void setHeight(int32 target) + { + heightTarget = target; + heightInc = (target - height) / timer; + } + + void setRadius(int32 target) + { + radiusTarget = target; + radiusInc = (target - radius) / timer; + } + + void setPitch(int32 target) + { + pitchTarget = target; + pitchInc = (target - pitch) / timer; + } + + void setRot(int32 delta, int32 target) + { + rotTarget = target; + rotInc = delta / timer; + } + + void setSelection(bool selected) + { + InvSlot slot = itemsList[itemIndex]; + + if (selected) { + const InvItem &item = INV_SLOTS[slot]; + selDistTarget = item.selDist; + selRotPreTarget = item.selRotPre; + selRotXTarget = item.selRotX; + selRotYTarget = item.selRotY; + } else { + selDistTarget = 0; + selRotPreTarget = 0; + selRotXTarget = 0; + selRotYTarget = 0; + } + + selDistInc = (selDistTarget - selDist) / timer; + selRotPreInc = (selRotPreTarget - selRotPre) / timer; + selRotXInc = (selRotXTarget - selRotX) / timer; + selRotYInc = (selRotYTarget - selRotY) / timer; + + frameTarget = (selected) ? getAnimLength() : 0; + itemVisMask = 0xFFFFFFFF; + + if (selected && slot == SLOT_PASSPORT) { + passportPage = (page == INV_PAGE_OPTIONS) ? PASSPORT_PAGE_SAVE_GAME : PASSPORT_PAGE_LOAD_GAME; + frameTarget += passportPage * 5; + } + } + + void setPage(InvPage page) + { + this->page = page; + + itemsCount = 0; + + #define ADD_SLOT(slot) if (counts[slot]) itemsList[itemsCount++] = slot; + + switch (page) + { + case INV_PAGE_TITLE: + case INV_PAGE_DEATH: + case INV_PAGE_OPTIONS: + { + ADD_SLOT(SLOT_PASSPORT); + ADD_SLOT(SLOT_CONTROLS); + ADD_SLOT(SLOT_DETAIL); + ADD_SLOT(SLOT_SOUND); + if (page == INV_PAGE_TITLE) + { + ADD_SLOT(SLOT_HOME); + } + break; + } + + case INV_PAGE_MAIN: + { + ADD_SLOT(SLOT_COMPASS); + + if (gLevelID != LVL_TR1_GYM) + { + ADD_SLOT(SLOT_PISTOLS); + ADD_SLOT(SLOT_SHOTGUN); + ADD_SLOT(SLOT_MAGNUMS); + ADD_SLOT(SLOT_UZIS); + ADD_SLOT(SLOT_MEDIKIT_BIG); + ADD_SLOT(SLOT_MEDIKIT_SMALL); + } + break; + } + + case INV_PAGE_USE: + case INV_PAGE_KEYS: + { + ADD_SLOT(SLOT_LEADBAR); + ADD_SLOT(SLOT_KEY_ITEM_1); + ADD_SLOT(SLOT_KEY_ITEM_2); + ADD_SLOT(SLOT_KEY_ITEM_3); + ADD_SLOT(SLOT_KEY_ITEM_4); + ADD_SLOT(SLOT_PUZZLE_4); + ADD_SLOT(SLOT_PUZZLE_3); + ADD_SLOT(SLOT_PUZZLE_2); + ADD_SLOT(SLOT_PUZZLE_1); + ADD_SLOT(SLOT_SCION); + break; + } + default: ; + } + + itemIndex = nextIndex = 0; + + if (itemsCount > 0) { + setRot(ANGLE_180, itemIndex * ANGLE_360 / itemsCount); + } + + rot = rotTarget - ANGLE_180; + } + + int32 getItemIndexForSlot(InvSlot slot) + { + for (int32 i = 0; i < itemsCount; i++) + { + if (itemsList[i] == slot) + return i; + } + return 0; + } + + void open(ItemObj* lara, InvPage page, int32 arg = 0) + { + this->lara = lara; + + if (page == INV_PAGE_TITLE) { + background = osLoadScreen(LVL_TR1_TITLE); + } else { + background = copyBackground(); + } + + height = INV_CAMERA_HEIGHT; + pitch = (page == INV_PAGE_TITLE) ? 1024 : 0; + radius = 0; + frameIndex = 0; + useSlot = SLOT_MAX; + itemVisMask = 0xFFFFFFFF; + + if (page == INV_PAGE_END) + { + sndPlayTrack(3); + soundPlay(SND_HEALTH, NULL); + this->page = page; + this->state = INV_STATE_READY; + return; + } + + setState(INV_STATE_OPENING, (page == INV_PAGE_DEATH) ? INV_STATE_DEATH : INV_STATE_READY, 16); + setHeight(-256); + setRadius(INV_RING_RADIUS); + setPage(page); + + if (page == INV_PAGE_USE) + { + itemIndex = nextIndex = getItemIndexForSlot(remapHoleToSlot((ItemType)arg)); + setRot(ANGLE_180, itemIndex * ANGLE_360 / itemsCount); + rot = rotTarget - ANGLE_180; + } + + soundPlay(SND_INV_SHOW, NULL); + + update(1); + } + + void close() + { + setState(INV_STATE_CLOSING, INV_STATE_NONE, 16); + setHeight(-1536); + setRadius(0); + setRot(ANGLE_180, rot - ANGLE_180); + } + + StringID getTitleStr() + { + StringID title = STR_EMPTY; + + switch (page) + { + case INV_PAGE_MAIN: + { + title = STR_INV_TITLE_MAIN; + break; + } + + case INV_PAGE_USE: + case INV_PAGE_KEYS: + { + title = STR_INV_TITLE_KEYS; + break; + } + + case INV_PAGE_OPTIONS: + { + title = STR_INV_TITLE_OPTIONS; + break; + } + default: ; + } + return title; + } + + StringID getItemStr() + { + const InvItem &item = INV_SLOTS[itemsList[itemIndex]]; + int32 type = item.type; + + #define LVLCHECK(L, T, S) if (gLevelID == L && type == ITEM_INV_##T) return S; + + LVLCHECK(LVL_TR1_2, KEY_ITEM_1, STR_KEY_SILVER); + LVLCHECK(LVL_TR1_2, PUZZLE_1, STR_PUZZLE_GOLD_IDOL); + + LVLCHECK(LVL_TR1_3A, PUZZLE_1, STR_PUZZLE_COG); + + LVLCHECK(LVL_TR1_4, KEY_ITEM_1, STR_KEY_NEPTUNE); + LVLCHECK(LVL_TR1_4, KEY_ITEM_2, STR_KEY_ATLAS); + LVLCHECK(LVL_TR1_4, KEY_ITEM_3, STR_KEY_DAMOCLES); + LVLCHECK(LVL_TR1_4, KEY_ITEM_4, STR_KEY_THOR); + + LVLCHECK(LVL_TR1_5, KEY_ITEM_1, STR_KEY_RUSTY); + + LVLCHECK(LVL_TR1_6, PUZZLE_1, STR_PUZZLE_GOLD_BAR); + + LVLCHECK(LVL_TR1_7A, KEY_ITEM_1, STR_KEY_GOLD); + LVLCHECK(LVL_TR1_7A, KEY_ITEM_2, STR_KEY_SILVER); + LVLCHECK(LVL_TR1_7A, KEY_ITEM_3, STR_KEY_RUSTY); + + LVLCHECK(LVL_TR1_7B, KEY_ITEM_1, STR_KEY_GOLD); + LVLCHECK(LVL_TR1_7B, KEY_ITEM_2, STR_KEY_RUSTY); + LVLCHECK(LVL_TR1_7B, KEY_ITEM_3, STR_KEY_RUSTY); + + LVLCHECK(LVL_TR1_8A, KEY_ITEM_1, STR_KEY_SAPPHIRE); + + LVLCHECK(LVL_TR1_8B, KEY_ITEM_1, STR_KEY_SAPPHIRE); + LVLCHECK(LVL_TR1_8B, PUZZLE_2, STR_PUZZLE_SCARAB); + LVLCHECK(LVL_TR1_8B, PUZZLE_3, STR_PUZZLE_HORUS); + LVLCHECK(LVL_TR1_8B, PUZZLE_4, STR_PUZZLE_ANKH); + LVLCHECK(LVL_TR1_8B, PUZZLE_1, STR_PUZZLE_HORUS); + + LVLCHECK(LVL_TR1_8C, KEY_ITEM_1, STR_KEY_GOLD); + LVLCHECK(LVL_TR1_8C, PUZZLE_1, STR_PUZZLE_ANKH); + LVLCHECK(LVL_TR1_8C, PUZZLE_2, STR_PUZZLE_SCARAB); + + LVLCHECK(LVL_TR1_10A, PUZZLE_1, STR_PUZZLE_FUSE); + LVLCHECK(LVL_TR1_10A, PUZZLE_2, STR_PUZZLE_PYRAMID); + + LVLCHECK(LVL_TR1_EGYPT, KEY_ITEM_1, STR_KEY_GOLD); + LVLCHECK(LVL_TR1_CAT, KEY_ITEM_1, STR_KEY_ORNATE); + + if (state == INV_STATE_SHOW) + { + if (type == ITEM_INV_PASSPORT) + { + if (passportPage == PASSPORT_PAGE_LOAD_GAME) + return STR_LOAD_GAME; + if (passportPage == PASSPORT_PAGE_SAVE_GAME) + return STR_SAVE_GAME; + if (passportPage == PASSPORT_PAGE_EXIT_TO_TITLE) + return STR_EXIT_TO_TITLE; + } + } + + return item.str; + } + + int32 getAnimLength() + { + int32 type = INV_SLOTS[itemsList[itemIndex]].type; + + // HACK! override max animation length + if (type == ITEM_INV_PASSPORT) + { + return FRAME_PASSPORT; + } + + if (type == ITEM_INV_COMPASS) + { + return FRAME_COMPASS; + } + + const Anim &anim = level.anims[level.models[type].animIndex]; + + return anim.frameEnd - anim.frameBegin; + } + + bool animate(int32 frames) + { + if (frameIndex == frameTarget) + return false; + + if (frameIndex < frameTarget) + { + frameIndex += frames; + if (frameIndex >= frameTarget) + { + frameIndex = frameTarget; + updateVisMask(); + return false; + } + } + + if (frameIndex > frameTarget) + { + frameIndex -= frames; + if (frameIndex <= frameTarget) + { + frameIndex = frameTarget; + updateVisMask(); + return false; + } + } + + updateVisMask(); + return true; + } + + void updateVisMask() + { + #define PM(x) (1 << x) + + if (itemsList[itemIndex] == SLOT_PASSPORT) + { + itemVisMask = PM(0) | PM(1) | PM(4); + if (frameIndex <= 14) { + itemVisMask |= PM(2) | PM(6); + } else if (frameIndex > 14 && frameIndex < 19) { + itemVisMask |= PM(2) | PM(3) | PM(6); + } else if (frameIndex == 19) { + itemVisMask |= PM(3) | PM(6); + } else if (frameIndex > 19 && frameIndex < 24) { + itemVisMask |= PM(3) | PM(5) | PM(6); + } else if (frameIndex >= 24 && frameIndex < 29) { + itemVisMask |= PM(3) | PM(5); + } + } + } + + void onOption() + { + if (optionsCount == 0) + return; + + if (lara->isKeyHit(IN_DOWN)) + { + for (int32 i = 0; i < optionsCount; i++) + { + optionIndex++; + + if (optionIndex >= optionsCount) { + optionIndex = 0; + } + + if ((options[optionIndex].type == OPT_SPACE) || (options[optionIndex].type == OPT_TEXT)) { + continue; + } + + break; + } + } + + if (lara->isKeyHit(IN_UP)) + { + for (int32 i = 0; i < optionsCount; i++) + { + optionIndex--; + + if (optionIndex < 0) { + optionIndex = optionsCount - 1; + } + + if ((options[optionIndex].type == OPT_SPACE) || (options[optionIndex].type == OPT_TEXT)) { + continue; + } + + break; + } + } + + Option &opt = options[optionIndex]; + + switch (opt.type) + { + case OPT_BAR: + { + if (lara->isKeyHit(IN_LEFT)) + { + opt.value -= 16; + if (opt.value < 0) { + opt.value = 0; + } + } + + if (lara->isKeyHit(IN_RIGHT)) + { + opt.value += 16; + if (opt.value > 256) { + opt.value = 256; + } + } + break; + } + + case OPT_SWITCH: + { + if (lara->isKeyHit(IN_LEFT) || lara->isKeyHit(IN_RIGHT)) + { + opt.value = !opt.value; + } + break; + } + + default: ; + } + } + + void onKey() + { + if (lara->input & IN_ACTION) + { + nextState = INV_STATE_CLOSE; + useSlot = itemsList[itemIndex]; + } + } + + void onCompass() + { + if (lara->input & IN_ACTION) + { + frameTarget = 0; + nextState = INV_STATE_CLOSE; + } + } + + void onPassport() + { + if ((passportPage == PASSPORT_PAGE_SAVE_GAME) && (optionsCount > 0)) // error message + { + if (lara->isKeyHit(IN_ACTION) || lara->isKeyHit(IN_JUMP)) + { + frameTarget = 0; + nextState = INV_STATE_CLOSE; + } + return; + } + + if ((page == INV_PAGE_OPTIONS) || (page == INV_PAGE_DEATH)) + { + if ((passportPage == PASSPORT_PAGE_LOAD_GAME) && lara->isKeyHit(IN_RIGHT)) { + passportPage = PASSPORT_PAGE_SAVE_GAME; + frameTarget += 5; + initOptions(); + soundPlay(SND_INV_PAGE, NULL); + } else if ((passportPage == PASSPORT_PAGE_SAVE_GAME) && lara->isKeyHit(IN_RIGHT)) { + passportPage = PASSPORT_PAGE_EXIT_TO_TITLE; + frameTarget += 5; + initOptions(); + soundPlay(SND_INV_PAGE, NULL); + } else if ((passportPage == PASSPORT_PAGE_EXIT_TO_TITLE) && lara->isKeyHit(IN_LEFT)) { + passportPage = PASSPORT_PAGE_SAVE_GAME; + frameTarget -= 5; + initOptions(); + soundPlay(SND_INV_PAGE, NULL); + } else if ((passportPage == PASSPORT_PAGE_SAVE_GAME) && lara->isKeyHit(IN_LEFT)) { + passportPage = PASSPORT_PAGE_LOAD_GAME; + frameTarget -= 5; + initOptions(); + soundPlay(SND_INV_PAGE, NULL); + } + } + + if (lara->isKeyHit(IN_ACTION)) + { + Option &opt = options[optionIndex]; + + if (passportPage == PASSPORT_PAGE_LOAD_GAME) + { + nextLevel(LevelID(opt.value)); + frameTarget = 0; + nextState = INV_STATE_CLOSE; + } + + if (passportPage == PASSPORT_PAGE_SAVE_GAME) + { + if (!gameSave()) + { + optionsHeight = 4; + optionsCount = 0; + optionIndex = OPT_ID_OK; + OPTION_SPACE(); + OPTION_TEXT(STR_GBA_SAVE_WARNING_1); + OPTION_TEXT(STR_GBA_SAVE_WARNING_2); + OPTION_TEXT(STR_GBA_SAVE_WARNING_3); + OPTION_SPACE(); + OPTION_BTN(STR_OK, 0); + } else { + frameTarget = 0; + nextState = INV_STATE_CLOSE; + } + } + + if (passportPage == PASSPORT_PAGE_EXIT_TO_TITLE) + { + nextLevel(LVL_TR1_TITLE); + frameTarget = 0; + nextState = INV_STATE_CLOSE; + } + } + } + + void onDetail() + { + Option &opt = options[optionIndex]; + + if (optionIndex == OPT_ID_GAMMA) + { + int32 gamma = opt.value >> 4; + + if (gSettings.video_gamma != gamma) + { + gSettings.video_gamma = gamma; + palSet(level.palette, gamma << 4, gBrightness); + osSaveSettings(); + } + } + + if (optionIndex == OPT_ID_FPS) + { + if (gSettings.video_fps != opt.value) + { + gSettings.video_fps = opt.value; + osSaveSettings(); + } + } + + if (optionIndex == OPT_ID_VSYNC) + { + if (gSettings.video_vsync != opt.value) + { + gSettings.video_vsync = opt.value; + osSaveSettings(); + } + } + } + + void onSound() + { + Option &opt = options[optionIndex]; + + if ((optionIndex == OPT_ID_SFX) && (gSettings.audio_sfx != opt.value)) + { + gSettings.audio_sfx = opt.value; + osSaveSettings(); + } + + if ((optionIndex == OPT_ID_MUSIC) && (gSettings.audio_music != opt.value)) + { + gSettings.audio_music = opt.value; + osSaveSettings(); + } + } + + void onControls() + { + Option &opt = options[optionIndex]; + + if ((optionIndex == OPT_ID_RUMBLE) && (gSettings.controls_vibration != opt.value)) + { + gSettings.controls_vibration = opt.value; + osJoyVibrate(0, 0xFF, 0xFF); + osSaveSettings(); + } + + if ((optionIndex == OPT_ID_SWAP) && (gSettings.controls_swap != opt.value)) + { + gSettings.controls_swap = opt.value; + osSaveSettings(); + } + } + + void onHome() + { + if (lara->input & IN_ACTION) + { + nextState = INV_STATE_CLOSE; + useSlot = itemsList[itemIndex]; + nextLevel(LVL_TR1_GYM); + } + } + + void onEnd() + { + if (lara->isKeyHit(IN_ACTION) || lara->isKeyHit(IN_JUMP) || lara->isKeyHit(IN_SELECT)) + { + nextLevel(LVL_TR1_TITLE); + state = INV_STATE_NONE; + } + } + + bool onItem() + { + onOption(); + + if (lara->input & (IN_JUMP | IN_SELECT)) + { + frameTarget = 0; + nextState = INV_STATE_READY; + } + + InvSlot slot = itemsList[itemIndex]; + + switch (slot) + { + case SLOT_LEADBAR: + case SLOT_KEY_ITEM_1: + case SLOT_KEY_ITEM_2: + case SLOT_KEY_ITEM_3: + case SLOT_KEY_ITEM_4: + case SLOT_PUZZLE_4: + case SLOT_PUZZLE_3: + case SLOT_PUZZLE_2: + case SLOT_PUZZLE_1: + case SLOT_SCION: + case SLOT_PISTOLS: + case SLOT_SHOTGUN: + case SLOT_MAGNUMS: + case SLOT_UZIS: + case SLOT_MEDIKIT_BIG: + case SLOT_MEDIKIT_SMALL: + nextState = INV_STATE_CLOSE; + useSlot = slot; + break; + case SLOT_COMPASS: + onCompass(); + break; + case SLOT_PASSPORT: + onPassport(); + break; + case SLOT_DETAIL: + onDetail(); + break; + case SLOT_SOUND: + onSound(); + break; + case SLOT_CONTROLS: + onControls(); + break; + case SLOT_HOME: + onHome(); + break; + default: ; + } + + return nextState == INV_STATE_NONE; + } + + void update(int32 frames) + { + updateFading(frames); + + if (page == INV_PAGE_END) + { + onEnd(); + return; + } + + if (state != INV_STATE_SHOW) + { + rotItem += rotItemInc * frames; + } + + if (timer > 0) + { + timer -= frames; + + height += heightInc * frames; + radius += radiusInc * frames; + pitch += pitchInc * frames; + rot += rotInc * frames; + selDist += selDistInc * frames; + selRotPre += selRotPreInc * frames; + selRotX += selRotXInc * frames; + selRotY += selRotYInc * frames; + + if (timer <= 0) + { + timer = 0; + state = nextState; + nextState = INV_STATE_NONE; + height = heightTarget; + radius = radiusTarget; + pitch = pitchTarget; + rot = rotTarget; + selDist = selDistTarget; + selRotPre = selRotPreTarget; + selRotX = selRotXTarget; + selRotY = selRotYTarget; + + heightInc = 0; + radiusInc = 0; + pitchInc = 0; + rotInc = 0; + rotItem = 0; + rotItemInc = 512; + selDistInc = 0; + selRotPreInc = 0; + selRotXInc = 0; + selRotYInc = 0; + + itemIndex = nextIndex; + } + } + + switch (state) + { + case INV_STATE_CLOSE: + { + close(); + break; + } + + case INV_STATE_READY: + { + if ((lara->input & IN_LEFT) && (itemsCount > 1)) { + soundPlay(SND_INV_SPIN, NULL); + nextIndex = itemIndex + 1; + if (nextIndex >= itemsCount) { + nextIndex -= itemsCount; + } + setState(INV_STATE_SPIN, INV_STATE_READY, 12); + setRot(ANGLE_360 / itemsCount, nextIndex * ANGLE_360 / itemsCount); + } else if ((lara->input & IN_RIGHT) && (itemsCount > 1)) { + soundPlay(SND_INV_SPIN, NULL); + nextIndex = itemIndex - 1; + if (nextIndex < 0) { + nextIndex += itemsCount; + } + setState(INV_STATE_SPIN, INV_STATE_READY, 12); + setRot(-ANGLE_360 / itemsCount, nextIndex * ANGLE_360 / itemsCount); + } else { + if (lara->input & IN_UP) { + if (page == INV_PAGE_OPTIONS) { + setState(INV_STATE_CLOSING, INV_STATE_PAGE_MAIN, 12); + setRadius(0); + setRot(ANGLE_180, rot - ANGLE_180); + setPitch(ANGLE_45); + } else if ((page == INV_PAGE_MAIN) && (numKeys > 0)) { + setState(INV_STATE_CLOSING, INV_STATE_PAGE_KEYS, 12); + setRadius(0); + setRot(ANGLE_180, rot - ANGLE_180); + setPitch(ANGLE_45); + } + } else if (lara->input & IN_DOWN) { + if (page == INV_PAGE_KEYS) { + setState(INV_STATE_CLOSING, INV_STATE_PAGE_MAIN, 12); + setRadius(0); + setRot(ANGLE_180, rot - ANGLE_180); + setPitch(-ANGLE_45); + } else if (page == INV_PAGE_MAIN) { + setState(INV_STATE_CLOSING, INV_STATE_PAGE_OPTIONS, 12); + setRadius(0); + setRot(ANGLE_180, rot - ANGLE_180); + setPitch(-ANGLE_45); + } + } else if ((lara->isKeyHit(IN_SELECT) || lara->isKeyHit(IN_JUMP)) && (page != INV_PAGE_TITLE)) { + soundPlay(SND_INV_HIDE, NULL); + useSlot = SLOT_MAX; + close(); + } else if (lara->input & IN_ACTION) { + soundPlay(INV_SLOTS[itemsList[itemIndex]].snd, NULL); + setState(INV_STATE_SELECT, INV_STATE_SHOW, 8); + setSelection(true); + initOptions(); + } + } + + break; + } + + case INV_STATE_DEATH: + { + soundPlay(INV_SLOTS[itemsList[itemIndex]].snd, NULL); + setState(INV_STATE_SELECT, INV_STATE_SHOW, 8); + setSelection(true); + initOptions(); + break; + } + + case INV_STATE_SHOW: + { + rotItem = 0; + + if (animate(frames)) + break; + + if (!onItem() && (frameIndex == frameTarget)) + { + setState(INV_STATE_DESELECT, nextState, 8); + setSelection(false); + break; + } + + break; + } + + case INV_STATE_PAGE_MAIN: + { + pitch = -pitch; + setState(INV_STATE_OPENING, INV_STATE_READY, 12); + setRadius(INV_RING_RADIUS); + setPitch(0); + setPage(INV_PAGE_MAIN); + break; + } + + case INV_STATE_PAGE_KEYS: + { + pitch = -pitch; + setState(INV_STATE_OPENING, INV_STATE_READY, 12); + setRadius(INV_RING_RADIUS); + setPitch(0); + setPage(INV_PAGE_KEYS); + break; + } + + case INV_STATE_PAGE_OPTIONS: + { + pitch = -pitch; + setState(INV_STATE_OPENING, INV_STATE_READY, 12); + setRadius(INV_RING_RADIUS); + setPitch(0); + setPage(INV_PAGE_OPTIONS); + break; + } + + default: ; + } + } + + void initOptions() + { + optionsCount = 0; + optionIndex = 0; + optionsWidth = 216; + optionsHeight = 4; + + InvSlot slot = itemsList[itemIndex]; + + switch (slot) + { + case SLOT_PASSPORT: + { + if (passportPage == PASSPORT_PAGE_LOAD_GAME) + { + OPTION_BTN(STR_TR1_LEVEL1, LVL_TR1_1); + OPTION_BTN(STR_TR1_LEVEL2, LVL_TR1_2); + if (osCheckSave()) + { + OPTION_SPACE(); + OPTION_BTN(STR_CURRENT_POSITION, LVL_LOAD); + optionIndex = optionsCount - 1; + } + } + break; + } + case SLOT_DETAIL: + { + OPTION_BAR(STR_OPT_DETAIL_GAMMA, gSettings.video_gamma << 4); + OPTION_SWITCH(STR_OPT_DETAIL_FPS, gSettings.video_fps); + OPTION_SWITCH(STR_OPT_DETAIL_VSYNC, gSettings.video_vsync); + break; + } + case SLOT_SOUND: + { + OPTION_SWITCH(STR_OPT_SOUND_SFX, gSettings.audio_sfx); + OPTION_SWITCH(STR_OPT_SOUND_MUSIC, gSettings.audio_music); + break; + } + case SLOT_CONTROLS: + { + OPTION_SWITCH(STR_OPT_CONTROLS_VIBRATION, gSettings.controls_vibration); + OPTION_SWITCH(STR_OPT_CONTROLS_SWAP, gSettings.controls_swap); + /* + OPTION_SPACE(); + OPTION_CTRL(STR_CTRL_RUN, 0); + OPTION_CTRL(STR_CTRL_BACK, 0); + OPTION_CTRL(STR_CTRL_RIGHT, 0); + OPTION_CTRL(STR_CTRL_LEFT, 0); + OPTION_CTRL(STR_CTRL_WALK, 0); + OPTION_CTRL(STR_CTRL_JUMP, 0); + OPTION_CTRL(STR_CTRL_ACTION, 0); + OPTION_CTRL(STR_CTRL_WEAPON, 0); + OPTION_CTRL(STR_CTRL_LOOK, 0); + OPTION_CTRL(STR_CTRL_ROLL, 0); + OPTION_CTRL(STR_CTRL_INVENTORY, 0); + OPTION_CTRL(STR_CTRL_PAUSE, 0); + */ + break; + } + default: ; + } + } + + void drawOptions() + { + if (state != INV_STATE_SHOW) + return; + + if (optionsCount == 0) + return; + + int32 w = optionsWidth; + int32 h = optionsHeight; + int32 y = (FRAME_HEIGHT - h) / 2 - 12; + + renderFill((FRAME_WIDTH - w) / 2 + 1, y + 1, w - 2, h - 2, 25, 2); + renderBorder((FRAME_WIDTH - w) / 2, y, w, h, 14, 10, 2); + + w -= 4; + h = 18; + y += 2; + + for (int32 i = 0; i < optionsCount; i++) + { + const Option &opt = options[i]; + + if (optionIndex == i) { + renderBorder((FRAME_WIDTH - w) / 2, y, w, h, 15, 15, 1); + } + + switch (opt.type) + { + case OPT_SPACE: + { + y -= 10; + break; + } + + case OPT_BUTTON: + { + drawText(0, y + 16, STR[opt.str], TEXT_ALIGN_CENTER); + break; + } + + case OPT_BAR: + { + renderBar(FRAME_WIDTH / 2, y + 6, 80, opt.value, BAR_OPTION); + drawText(-FRAME_WIDTH / 2 - 8, y + 16, STR[opt.str], TEXT_ALIGN_RIGHT); + break; + } + + case OPT_SWITCH: + { + drawText(-FRAME_WIDTH / 2 - 8, y + 16, STR[opt.str], TEXT_ALIGN_RIGHT); + drawText(44, y + 16, STR[opt.value ? STR_ON : STR_OFF], TEXT_ALIGN_CENTER); + break; + } + + case OPT_VALUE: + { + break; + } + + case OPT_TEXT: + { + drawText(0, y + 16, STR[opt.str], TEXT_ALIGN_CENTER); + break; + } + } + + y += 18; + } + } + + void drawSlot(InvSlot slot) + { + int32 type = INV_SLOTS[slot].type; + + bool current = itemsList[itemIndex] == slot; + bool selected = current && ((state == INV_STATE_SHOW) || (frameTarget != frameIndex)); + + if ((type == ITEM_INV_PASSPORT) && !selected) { + type = ITEM_INV_PASSPORT_CLOSED; + } + + ItemObj item; + memset(&item, 0, sizeof(item)); + item.type = type; + item.intensity = 255; + item.visibleMask = itemVisMask; + item.animIndex = level.models[type].animIndex; + item.frameIndex = level.anims[item.animIndex].frameBegin + (selected ? frameIndex : 0); + + const AnimFrame *frameA, *frameB; + + int32 frameRate; + int32 frameDelta = item.getFrames(frameA, frameB, frameRate); + + calcLightingStatic(255 << 5); + drawNodesLerp(&item, frameA, frameB, frameDelta, frameRate); + + if ((state == INV_STATE_READY) && current && (counts[slot] > 1)) + { + char buf[32]; + int2str(counts[slot], buf); + + // convert ASCII to small digits (TR glyph) + char* ptr = buf; + while (*ptr) + { + *ptr -= 47; + ptr++; + } + + drawText(FRAME_WIDTH / 2 + 32, FRAME_HEIGHT - 32, buf, TEXT_ALIGN_LEFT); + + if (slot == SLOT_MEDIKIT_SMALL || slot == SLOT_MEDIKIT_BIG) + { + int32 v = (lara->health << 8) / LARA_MAX_HEALTH; + renderBar((FRAME_WIDTH - 104) / 2, 24, 100, v, BAR_HEALTH); + } + } + } + + void drawPage() + { + int16 angleX, angleY; + + anglesFromVector(0, -(height + INV_CAMERA_Y), -INV_CAMERA_Z, angleX, angleY); + + vec3i pos = _vec3i(0, height, radius + INV_CAMERA_Z); + + matrixSetView(pos, angleX + pitch, angleY); + matrixTranslateAbs(0, 0, 0); + + for (int32 i = itemsCount - 1; i >= 0; i--) + { + matrixPush(); + matrixRotateY(i * ANGLE_360 / itemsCount - rot - ANGLE_90); + matrixTranslateRel(radius, 0, 0); + matrixRotateYXZ(0, ANGLE_90, 0); + + if (itemIndex == i) + { + matrixRotateX(selRotPre); + matrixTranslateRel(0, 0, selDist); + matrixRotateYXZ(-selRotX, -selRotY, 0); + matrixRotateY(rotItem); + } + + drawSlot(itemsList[i]); + + matrixPop(); + } + + if (frameIndex == frameTarget) { + drawOptions(); + } + } + + void drawEndPage() + { + int32 y = 48; + for (int32 i = 0; i <= STR_ALPHA_END_6 - STR_ALPHA_END_1; i++) + { + drawText(0, y, STR[STR_ALPHA_END_1 + i], TEXT_ALIGN_CENTER); + y += 16; + } + } + + void draw() + { + //clear(); + ASSERT(background); + renderBackground(background); + + if (page == INV_PAGE_END) + { + drawEndPage(); + return; + } + + drawPage(); + + if (state == INV_STATE_READY || + state == INV_STATE_SPIN || + state == INV_STATE_SELECT || + state == INV_STATE_DESELECT || + state == INV_STATE_SHOW) + { + if (state != INV_STATE_SHOW && + state != INV_STATE_SELECT && + state != INV_STATE_DESELECT) + { + drawText(0, 20, STR[getTitleStr()], TEXT_ALIGN_CENTER); + + if ((page == INV_PAGE_OPTIONS) || (page == INV_PAGE_MAIN && numKeys)) + { + drawText(4, 4 + 16, "[", TEXT_ALIGN_LEFT); + drawText(-6, 4 + 16, "[", TEXT_ALIGN_RIGHT); + } + + if (page == INV_PAGE_MAIN || page == INV_PAGE_KEYS) + { + drawText(4, FRAME_HEIGHT - 5, "]", TEXT_ALIGN_LEFT); + drawText(-6, FRAME_HEIGHT - 5, "]", TEXT_ALIGN_RIGHT); + } + } + + if ((frameIndex == frameTarget) && (state != INV_STATE_SPIN)) + { + const char* str = STR[getItemStr()]; + + drawText(0, FRAME_HEIGHT - 8, str, TEXT_ALIGN_CENTER); + + if ((state == INV_STATE_SHOW) && (itemsList[itemIndex] == SLOT_PASSPORT)) + { + if ((page == INV_PAGE_OPTIONS) || (page == INV_PAGE_DEATH)) + { + int32 len = getTextWidth(str); + if ((passportPage == PASSPORT_PAGE_LOAD_GAME) || (passportPage == PASSPORT_PAGE_SAVE_GAME)) { + drawText((FRAME_WIDTH + len) / 2 + 4, FRAME_HEIGHT - 8, "$\x6D", TEXT_ALIGN_LEFT); + } + if ((passportPage == PASSPORT_PAGE_SAVE_GAME) || (passportPage == PASSPORT_PAGE_EXIT_TO_TITLE)) { + drawText((FRAME_WIDTH - len) / 2 - 18, FRAME_HEIGHT - 8, "$\x6C", TEXT_ALIGN_LEFT); + } + } + } + } + + } + } +}; + +EWRAM_DATA Inventory inventory; + +#endif diff --git a/src/fixed/item.h b/src/fixed/item.h new file mode 100644 index 00000000..3a104dd4 --- /dev/null +++ b/src/fixed/item.h @@ -0,0 +1,1659 @@ +#ifndef H_ITEM +#define H_ITEM + +#include "common.h" +#include "camera.h" +#include "room.h" + +EWRAM_DATA AABBs tmpBox; + +#define GRAVITY 6 + +int32 alignOffset(int32 a, int32 b) +{ + int32 ca = a >> 10; + int32 cb = b >> 10; + + if (ca == cb) { + return 0; + } + + a &= 1023; + + if (ca < cb) { + return 1025 - a; + } + + return -(a + 1); +} + +void* soundPlay(int16 id, const vec3i* pos) +{ +#if defined(__32X__) || defined(__WIN32__) // TODO + return NULL; +#endif + + if (!gSettings.audio_sfx) + return NULL; + + if (id < 0) + return NULL; + + // TODO gym + // 0 -> 200 + // 4 -> 204 + + int16 a = level.soundMap[id]; + + if (a == -1) + return NULL; + + const SoundInfo* b = level.soundsInfo + a; + + if (b->chance && b->chance < rand_draw()) + return NULL; + + int32 volume = b->volume; + + if (pos) + { + vec3i d = *pos - playersExtra[0].camera.target.pos; // TODO find nearest camera for coop + + if (abs(d.x) >= SND_MAX_DIST || abs(d.y) >= SND_MAX_DIST || abs(d.z) >= SND_MAX_DIST) + return NULL; + + volume -= (phd_sqrt(dot(d, d)) << 2); + } + + if (SI_GAIN(b->flags)) { + volume -= rand_draw() >> 2; + } + + volume = X_MIN(volume, 0x7FFF) >> 9; + + if (volume <= 0) + return NULL; + + volume += 1; // 63 to 64 (1 << SND_VOL_SHIFT) for 100% vol samples + + int32 pitch = 128; + + if (SI_PITCH(b->flags)) { + pitch += ((rand_draw() * 13) >> 14) - 13; + } + + int32 index = b->index; + if (SI_COUNT(b->flags) > 1) { + index += (rand_draw() * SI_COUNT(b->flags)) >> 15; + } + + return sndPlaySample(index, volume, pitch, SI_MODE(b->flags)); +} + +void soundStop(int16 id) +{ +#if defined(__32X__) || defined(__WIN32__) // TODO + return; +#endif + + int16 a = level.soundMap[id]; + + if (a == -1) + return; + + const SoundInfo* b = level.soundsInfo + a; + + for (int32 i = 0; i < SI_COUNT(b->flags); i++) + { + sndStopSample(b->index + i); + } +} + +int32 ItemObj::getFrames(const AnimFrame* &frameA, const AnimFrame* &frameB, int32 &animFrameRate) const +{ + const Anim* anim = level.anims + animIndex; + + if (anim->frameBegin == anim->frameEnd) + { + frameA = frameB = (AnimFrame*)(level.animFrames + (anim->frameOffset >> 1)); + animFrameRate = 1; + return 0; + } + + animFrameRate = anim->frameRate; + + int32 frameSize = (sizeof(AnimFrame) >> 1) + (level.models[type].count << 1); + + int32 frame = frameIndex - anim->frameBegin; + +// int32 d = FixedInvU(animFrameRate); +// int32 indexA = frame * d >> 16; + + int32 indexA, indexB; + int32 frameDelta; + + if (animFrameRate == 1) + { + indexA = frame; + frameDelta = frame - indexA; + } + else if (animFrameRate == 2) + { + indexA = frame >> 1; + frameDelta = frame - (indexA << 1); + } + else if (animFrameRate == 4) + { + indexA = frame >> 2; + frameDelta = frame - (indexA << 2); + } + else + { + indexA = frame / animFrameRate; + frameDelta = frame - (indexA * animFrameRate); + } + + indexB = indexA + 1; + + if (indexB * animFrameRate >= anim->frameEnd) + { + indexB = indexA; + } + + frameA = (AnimFrame*)(level.animFrames + (anim->frameOffset >> 1) + indexA * frameSize); + frameB = (AnimFrame*)(level.animFrames + (anim->frameOffset >> 1) + indexB * frameSize); + + if (!frameDelta || frameA == frameB) + return 0; + + indexB *= animFrameRate; + if (indexB > anim->frameEnd) { + animFrameRate -= indexB - anim->frameEnd; + } + + return frameDelta; +} + +const AnimFrame* ItemObj::getFrame() const +{ + const AnimFrame *frameA, *frameB; + + int32 frameRate; + int32 frameDelta = getFrames(frameA, frameB, frameRate); + + return (frameDelta <= (frameRate >> 1)) ? frameA : frameB; +} + +const AABBs& ItemObj::getBoundingBox(bool lerp) const +{ + if (!lerp) + return getFrame()->box; + + const AnimFrame *frameA, *frameB; + + int32 frameRate; + int32 frameDelta = getFrames(frameA, frameB, frameRate); + + if (!frameDelta) + return frameA->box; + + int32 d = GET_FRAME_T(frameDelta, frameRate); + + #define COMP_LERP(COMP) tmpBox.COMP = frameA->box.COMP + ((frameB->box.COMP - frameA->box.COMP) * d >> 16); + + COMP_LERP(minX); + COMP_LERP(maxX); + COMP_LERP(minY); + COMP_LERP(maxY); + COMP_LERP(minZ); + COMP_LERP(maxZ); + + #undef COMP_LERP + + return tmpBox; +} + +void ItemObj::move() +{ + const Anim* anim = level.anims + animIndex; + + int32 sp = anim->speed; + + if (flags & ITEM_FLAG_GRAVITY) + { + sp += anim->accel * (frameIndex - anim->frameBegin - 1); + hSpeed -= sp >> 16; + sp += anim->accel; + hSpeed += sp >> 16; + + vSpeed += (vSpeed < 128) ? GRAVITY : 1; + + pos.y += vSpeed; + } else { + sp += anim->accel * (frameIndex - anim->frameBegin); + + hSpeed = sp >> 16; + } + + int16 realAngle = (type == ITEM_LARA) ? extraL->moveAngle : angle.y; + + int32 s, c; + sincos(realAngle, s, c); + + pos.x += s * hSpeed >> FIXED_SHIFT; + pos.z += c * hSpeed >> FIXED_SHIFT; +} + +const Anim* ItemObj::animSet(int32 newAnimIndex, bool resetState, int32 frameOffset) +{ + const Anim* anim = level.anims + newAnimIndex; + + animIndex = newAnimIndex; + frameIndex = anim->frameBegin + frameOffset; + + if (resetState) { + state = goalState = uint8(anim->state); + } + + return anim; +} + +const Anim* ItemObj::animChange(const Anim* anim) +{ + if (goalState == state || !anim->statesCount) + return anim; + + const AnimState* animState = level.animStates + anim->statesStart; + + for (int32 i = 0; i < anim->statesCount; i++) + { + if (goalState == animState->state) + { + const AnimRange* animRange = level.animRanges + animState->rangesStart; + + for (int32 j = 0; j < animState->rangesCount; j++) + { + if ((frameIndex >= animRange->frameBegin) && (frameIndex <= animRange->frameEnd)) + { + frameIndex = animRange->nextFrameIndex; + animIndex = animRange->nextAnimIndex; + anim = level.anims + animRange->nextAnimIndex; + state = uint8(anim->state); + return anim; + } + animRange++; + } + } + animState++; + } + + return anim; +} + +void ItemObj::animCmd(bool fx, const Anim* anim) +{ + if (!anim->commandsCount) return; + + const int16 *ptr = level.animCommands + anim->commandsStart; + + for (int32 i = 0; i < anim->commandsCount; i++) + { + int32 cmd = *ptr++; + + switch (cmd) + { + case ANIM_CMD_NONE: + break; + + case ANIM_CMD_OFFSET: + { + if (!fx) + { + int32 s, c; + sincos(angle.y, s, c); + int32 x = ptr[0]; + int32 z = ptr[2]; + pos.x += X_ROTX(x, z, -s, c); + pos.y += ptr[1]; + pos.z += X_ROTY(x, z, -s, c); + } + ptr += 3; + break; + } + + case ANIM_CMD_JUMP: + { + if (!fx) + { + if (type == ITEM_LARA && extraL->vSpeedHack) { + vSpeed = -extraL->vSpeedHack; + extraL->vSpeedHack = 0; + } else { + vSpeed = ptr[0]; + } + hSpeed = ptr[1]; + flags |= ITEM_FLAG_GRAVITY; + } + ptr += 2; + break; + } + + case ANIM_CMD_EMPTY: + { + if (!fx) { + ASSERT(type == ITEM_LARA); + extraL->weaponState = WEAPON_STATE_FREE; + } + break; + } + + case ANIM_CMD_KILL: + { + if (!fx) { + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INACTIVE; + } + break; + } + + case ANIM_CMD_SOUND: + { + if (fx && frameIndex == ptr[0]) { + soundPlay(ptr[1] & 0x03FFF, &pos); + } + ptr += 2; + break; + } + + case ANIM_CMD_EFFECT: + { + if (fx && frameIndex == ptr[0]) + { + switch (ptr[1]) { + case FX_ROTATE_180 : + { + angle.y += ANGLE_180; + break; + } + + /* + case FX_FLOOR_SHAKE : ASSERT(false); + */ + + case FX_LARA_NORMAL : + { + ASSERT(type == ITEM_LARA); + animSet(11, true); // Lara::ANIM_STAND + break; + } + + case FX_LARA_BUBBLES : + { + fxBubbles(room, JOINT_HEAD, _vec3i(0, 0, 50)); + break; + } + + case FX_LARA_HANDSFREE : + { + ASSERT(type == ITEM_LARA && extraL); + extraL->weaponState = WEAPON_STATE_FREE; + break; + } + /* + case FX_DRAW_RIGHTGUN : drawGun(true); break; + case FX_DRAW_LEFTGUN : drawGun(false); break; + case FX_SHOT_RIGHTGUN : game->addMuzzleFlash(this, LARA_RGUN_JOINT, LARA_RGUN_OFFSET, 1 + camera->cameraIndex); break; + case FX_SHOT_LEFTGUN : game->addMuzzleFlash(this, LARA_LGUN_JOINT, LARA_LGUN_OFFSET, 1 + camera->cameraIndex); break; + case FX_MESH_SWAP_1 : + case FX_MESH_SWAP_2 : + case FX_MESH_SWAP_3 : Character::cmdEffect(fx); + case 26 : break; // TODO TR2 reset_hair + case 32 : break; // TODO TR3 footprint + default : LOG("unknown effect command %d (anim %d)\n", fx, animation.index); ASSERT(false); + */ + default : ; + } + } + ptr += 2; + break; + } + } + } +} + +void ItemObj::animSkip(int32 stateBefore, int32 stateAfter, bool advance) +{ + goalState = stateBefore; + + vec3i p = pos; + + while (state != goalState) + { + animProcess(false); + } + + if (advance) { + animProcess(); + } + + pos = p; + vSpeed = 0; + hSpeed = 0; + + goalState = stateAfter; +} + +#define ANIM_MOVE_LERP_POS_SHIFT 4 +#define ANIM_MOVE_LERP_POS (1 << ANIM_MOVE_LERP_POS_SHIFT) +#define ANIM_MOVE_LERP_ROT ANGLE(2) + +void ItemObj::animProcess(bool movement) +{ + ASSERT(level.models[type].count > 0); + + const Anim* anim = level.anims + animIndex; + +#ifndef STATIC_ITEMS + frameIndex++; +#endif + + anim = animChange(anim); + + if ((type != ITEM_LARA) && (nextState == state)) { + nextState = 0; + } + + if (frameIndex > anim->frameEnd) + { + animCmd(false, anim); + + frameIndex = anim->nextFrameIndex; + animIndex = anim->nextAnimIndex; + anim = level.anims + anim->nextAnimIndex; + state = uint8(anim->state); + + if (type != ITEM_LARA) + { + goalState = state; + if (nextState == state) { + nextState = 0; + } + } + } + + animCmd(true, anim); + +#ifndef STATIC_ITEMS + if (movement) { + move(); + } +#endif +} + +bool ItemObj::animIsEnd(int32 offset) const +{ + return frameIndex == level.anims[animIndex].frameEnd - offset; +} + +void ItemObj::animHit(int32 dirX, int32 dirZ, int32 hitTimer) +{ + ASSERT(type == ITEM_LARA); + ASSERT(extraL != NULL); + + extraL->hitQuadrant = uint16(angle.y - phd_atan(dirZ, dirX) + ANGLE_180 + ANGLE_45) >> ANGLE_SHIFT_90; + extraL->hitTimer = hitTimer; +} + +bool ItemObj::moveTo(const vec3i &point, ItemObj* item, bool lerp) +{ + // lerp position + vec3i p = item->getRelative(point); + + if (!lerp) + { + pos = p; + angle = item->angle; + return true; + } + + vec3i posDelta = p - pos; + + int32 dist = X_SQR(posDelta.x) + X_SQR(posDelta.y) + X_SQR(posDelta.z); + + if (dist > ANIM_MOVE_LERP_POS * ANIM_MOVE_LERP_POS) + { + dist = phd_sqrt(dist) >> 1; + ASSERT(dist < DIV_TABLE_SIZE); + dist = FixedInvU(dist); + + pos.x += posDelta.x * dist >> (16 + 1 - ANIM_MOVE_LERP_POS_SHIFT); + pos.y += posDelta.y * dist >> (16 + 1 - ANIM_MOVE_LERP_POS_SHIFT); + pos.z += posDelta.z * dist >> (16 + 1 - ANIM_MOVE_LERP_POS_SHIFT); + } + else + { + pos = p; + } + + // lerp rotation + angle.x = angleLerp(angle.x, item->angle.x, ANIM_MOVE_LERP_ROT); + angle.y = angleLerp(angle.y, item->angle.y, ANIM_MOVE_LERP_ROT); + angle.z = angleLerp(angle.z, item->angle.z, ANIM_MOVE_LERP_ROT); + + return (pos == p && angle == item->angle); +} + +ItemObj* ItemObj::add(ItemType type, Room* room, const vec3i &pos, int32 angleY) +{ + if (!ItemObj::sFirstFree) { + ASSERT(false); + return NULL; + } + + ItemObj* item = ItemObj::sFirstFree; + ItemObj::sFirstFree = item->nextItem; + + item->type = type; + item->pos = pos; + item->angle.y = angleY; + item->intensity = 128; + + item->init(room); + + return item; +} + +void ItemObj::remove() +{ + deactivate(); + room->remove(this); + + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + if (playersExtra[i].armR.target == this) playersExtra[i].armR.target = NULL; + if (playersExtra[i].armL.target == this) playersExtra[i].armL.target = NULL; + } + + nextItem = ItemObj::sFirstFree; + ItemObj::sFirstFree = this; +} + +void ItemObj::activate() +{ + //ASSERT(!flags.active) TODO check LEVEL3B + + flags |= ITEM_FLAG_ACTIVE; + + nextActive = ItemObj::sFirstActive; + ItemObj::sFirstActive = this; +} + +void ItemObj::deactivate() +{ + ItemObj* prev = NULL; + ItemObj* curr = ItemObj::sFirstActive; + + while (curr) + { + ItemObj* next = curr->nextActive; + + if (curr == this) + { + flags &= ~ITEM_FLAG_ACTIVE; + nextActive = NULL; + + if (prev) { + prev->nextActive = next; + } else { + ItemObj::sFirstActive = next; + } + + break; + } + + prev = curr; + curr = next; + } +} + +void ItemObj::hit(int32 damage, const vec3i &point, int32 soundId) +{ + // +} + +void ItemObj::fxBubbles(Room *fxRoom, int32 fxJoint, const vec3i &fxOffset) +{ + int32 count = rand_draw() % 3; + + if (!count) + return; + + vec3i fxPos = pos + getJoint(fxJoint, fxOffset); + + for (int32 i = 0; i < count; i++) + { + ItemObj::add(ITEM_BUBBLE, fxRoom, fxPos, 0); + } +} + +void ItemObj::fxRicochet(Room *fxRoom, const vec3i &fxPos, bool fxSound) +{ + ItemObj* ricochet = ItemObj::add(ITEM_RICOCHET, fxRoom, fxPos, 0); + + if (!ricochet) + return; + + ricochet->timer = 4; + ricochet->frameIndex = rand_draw() % (-level.models[ricochet->type].count); + + if (fxSound) { + soundPlay(SND_RICOCHET, &ricochet->pos); + } +} + +void ItemObj::fxBlood(const vec3i &fxPos, int16 fxAngleY, int16 fxSpeed) +{ + ItemObj* blood = ItemObj::add(ITEM_BLOOD, room, fxPos, fxAngleY); + + if (!blood) + return; + + blood->hSpeed = fxSpeed; + blood->timer = 4; + blood->flags |= ITEM_FLAG_ANIMATED; +} + +void ItemObj::fxSmoke(const vec3i &fxPos) +{ + ItemObj* smoke = ItemObj::add(ITEM_SMOKE, room, fxPos, 0); + + if (!smoke) + return; + + smoke->timer = 3; + smoke->flags |= ITEM_FLAG_ANIMATED; +} + +void ItemObj::fxSplash() +{ + vec3i fxPos = pos; + fxPos.y = getWaterLevel(); + + // TODO TR3+ + for (int32 i = 0; i < 10; i++) + { + ItemObj* splash = ItemObj::add(ITEM_SPLASH, room, fxPos, int16(rand_draw() - ANGLE_90) << 1); + + if (!splash) + return; + + splash->hSpeed = int16(rand_draw() >> 8); + splash->flags |= ITEM_FLAG_ANIMATED; + } +} + +void ItemObj::updateRoom(int32 offset) +{ + Room* nextRoom = room->getRoom(pos.x, pos.y + offset, pos.z); + + if (room != nextRoom) + { + room->remove(this); + nextRoom->add(this); + } + + const Sector* sector = room->getSector(pos.x, pos.z); + roomFloor = sector->getFloor(pos.x, pos.y, pos.z); +} + +bool ItemObj::isKeyHit(InputState state) const +{ + return (input & state) && !(extraL->lastInput & state); +} + +vec3i ItemObj::getRelative(const vec3i &point) const +{ + matrixPush(); + + Matrix &m = matrixGet(); + + matrixSetIdentity(); + matrixRotateYXZ(angle.x, angle.y, angle.z); + + vec3i p; + p.x = pos.x + (DP33(m.e00, m.e01, m.e02, point.x, point.y, point.z) >> FIXED_SHIFT); + p.y = pos.y + (DP33(m.e10, m.e11, m.e12, point.x, point.y, point.z) >> FIXED_SHIFT); + p.z = pos.z + (DP33(m.e20, m.e21, m.e22, point.x, point.y, point.z) >> FIXED_SHIFT); + + matrixPop(); + + return p; +} + +int32 ItemObj::getWaterLevel() const +{ + const Sector* sector = room->getWaterSector(pos.x, pos.z); + if (sector) { + if (sector->roomAbove == NO_ROOM) { + return sector->getCeiling(pos.x, pos.y, pos.z); + } else { + return sector->ceiling << 8; + } + } + + return WALL; +} + +int32 ItemObj::getWaterDepth() const +{ + const Sector* sector = room->getWaterSector(pos.x, pos.z); + + if (sector) + return sector->getFloor(pos.x, pos.y, pos.z) - (sector->ceiling * 256); + + return WALL; +} + +int32 ItemObj::getBridgeFloor(int32 x, int32 z) const +{ + if (type == ITEM_BRIDGE_FLAT) + return pos.y; + + int32 h; + if (angle.y == ANGLE_0) { + h = 1024 - x; + } else if (angle.y == ANGLE_180) { + h = x; + } else if (angle.y == ANGLE_90) { + h = z; + } else { + h = 1024 - z; + } + + h &= 1023; + + return pos.y + ((type == ITEM_BRIDGE_TILT_1) ? (h >> 2) : (h >> 1)); +} + +int32 ItemObj::getTrapDoorFloor(int32 x, int32 z) const +{ + int32 dx = (pos.x >> 10) - (x >> 10); + int32 dz = (pos.z >> 10) - (z >> 10); + + if (((dx == 0) && (dz == 0)) || + ((dx == 0) && (dz == 1) && (angle.y == ANGLE_0)) || + ((dx == 0) && (dz == -1) && (angle.y == ANGLE_180)) || + ((dx == 1) && (dz == 0) && (angle.y == ANGLE_90)) || + ((dx == -1) && (dz == 0) && (angle.y == -ANGLE_90))) + { + return pos.y; + } + + return WALL; +} + +int32 ItemObj::getDrawBridgeFloor(int32 x, int32 z) const +{ + int32 dx = (pos.x >> 10) - (x >> 10); + int32 dz = (pos.z >> 10) - (z >> 10); + + if (((dx == 0) && ((dz == -1) || (dz == -2)) && (angle.y == ANGLE_0)) || + ((dx == 0) && ((dz == 1) || (dz == 2)) && (angle.y == ANGLE_180)) || + ((dz == 0) && ((dx == -1) || (dz == -2)) && (angle.y == ANGLE_90)) || + ((dz == 0) && ((dx == 1) || (dz == 2)) && (angle.y == -ANGLE_90))) + { + return pos.y; + } + + return WALL; +} + +void ItemObj::getItemFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int32* ceiling) const +{ + int32 h = WALL; + + switch (type) + { + case ITEM_TRAP_FLOOR: + { + if (state == 0 || state == 1) { + h = pos.y - 512; + } + break; + } + case ITEM_DRAWBRIDGE: + { + if (state == 1) { + h = getDrawBridgeFloor(x, z); + } + break; + } + case ITEM_BRIDGE_FLAT: + case ITEM_BRIDGE_TILT_1: + case ITEM_BRIDGE_TILT_2: + { + h = getBridgeFloor(x, z); + break; + } + case ITEM_TRAP_DOOR_1: + case ITEM_TRAP_DOOR_2: + { + if (state != 0) + return; + + h = getTrapDoorFloor(x, z); + + if ((floor && (h >= *floor)) || (ceiling && (h <= *ceiling))) + return; + } + } + + if (h == WALL) + return; + + if (floor && (y <= h)) + { + *floor = h; + } + + if (ceiling && (y > h)) + { + *ceiling = h + 256; + } +} + +vec3i ItemObj::getJoint(int32 jointIndex, const vec3i &offset) const +{ + const Model* model = level.models + type; + + const AnimFrame* frame = getFrame(); + + const uint32* frameAngles = (uint32*)(frame->angles + 1); + + Matrix* oldMatrixPtr = gMatrixPtr; + + matrixPush(); + matrixSetIdentity(); + matrixRotateYXZ(angle.x, angle.y, angle.z); + + const ModelNode* node = level.nodes + model->nodeIndex; + + matrixFrame(&frame->pos, frameAngles); + + ASSERT(jointIndex < model->count); + + for (int32 i = 0; i < jointIndex; i++) + { + if (node->flags & 1) matrixPop(); + if (node->flags & 2) matrixPush(); + + matrixFrame(&node->pos, ++frameAngles); + + // TODO extra rotations + + node++; + } + + matrixTranslateRel(offset.x, offset.y, offset.z); + + Matrix &m = matrixGet(); + vec3i result = _vec3i(m.e03 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT), + m.e13 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT), + m.e23 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + + gMatrixPtr = oldMatrixPtr; + + return result; +} + +int32 ItemObj::getSpheres(Sphere* spheres, bool flag) const +{ + const Model* model = level.models + type; + + const AnimFrame* frame = getFrame(); + const uint32* frameAngles = (uint32*)(frame->angles + 1); + + const Mesh** meshPtr = level.meshes + model->start; + + int32 x, y, z; + + if (flag) { + x = pos.x; + y = pos.y; + z = pos.z; + matrixPush(); + matrixSetIdentity(); + } else { + x = y = z = 0; + matrixPush(); + matrixTranslateAbs(pos.x, pos.y, pos.z); + } + + matrixRotateYXZ(angle.x, angle.y, angle.z); + + const ModelNode* node = level.nodes + model->nodeIndex; + + matrixFrame(&frame->pos, frameAngles); + + Sphere* sphere = spheres; + + matrixPush(); + { + const Mesh* mesh = *meshPtr; + matrixTranslateRel(mesh->center.x, mesh->center.y, mesh->center.z); + Matrix &m = matrixGet(); + sphere->center.x = x + (m.e03 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->center.y = y + (m.e13 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->center.z = z + (m.e23 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->radius = mesh->radius; + sphere++; + meshPtr++; + } + matrixPop(); + + for (int32 i = 1; i < model->count; i++) + { + if (node->flags & 1) matrixPop(); + if (node->flags & 2) matrixPush(); + + matrixFrame(&node->pos, ++frameAngles); + + // TODO extra rotations + + matrixPush(); + { + const Mesh* mesh = *meshPtr; + matrixTranslateRel(mesh->center.x, mesh->center.y, mesh->center.z); + Matrix &m = matrixGet(); + sphere->center.x = x + (m.e03 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->center.y = y + (m.e13 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->center.z = z + (m.e23 >> (FIXED_SHIFT - MATRIX_FIXED_SHIFT)); + sphere->radius = mesh->radius; + sphere++; + meshPtr++; + } + matrixPop(); + + node++; + } + + matrixPop(); + + return sphere - spheres; +} + +#include "lara.h" +#include "enemy.h" +#include "object.h" + +#ifdef __GNUC__ +// ItemObj ctor is called on existing and pre-filled memory +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + +ItemObj::ItemObj(Room* room) +{ + angle.x = 0; + angle.z = 0; + vSpeed = 0; + hSpeed = 0; + nextItem = NULL; + nextActive = NULL; + animIndex = level.models[type].animIndex; + frameIndex = level.anims[animIndex].frameBegin; + state = uint8(level.anims[animIndex].state); + nextState = state; + goalState = state; + extra = NULL; + health = NOT_ENEMY; + hitMask = 0; + visibleMask = 0xFFFFFFFF; + + flags &= (ITEM_FLAG_ONCE | ITEM_FLAG_MASK); + + if ((type == ITEM_BRIDGE_FLAT) || + (type == ITEM_BRIDGE_TILT_1) || + (type == ITEM_BRIDGE_TILT_2) || + (type == ITEM_TRAP_FLOOR)) + { + // no collision + } else { + flags |= ITEM_FLAG_COLLISION; + } + + if (flags & ITEM_FLAG_ONCE) // once -> invisible + { + flags &= ~ITEM_FLAG_ONCE; + flags |= ITEM_FLAG_STATUS_INVISIBLE; + } + + if ((flags & ITEM_FLAG_MASK) == ITEM_FLAG_MASK) // full set of mask -> reverse + { + flags &= ~ITEM_FLAG_MASK; + flags |= ITEM_FLAG_REVERSE; + activate(); + } + + ASSERT(type <= ITEM_MAX); + + ASSERT(room); + + room->add(this); +} + +#ifdef __GNUC__ +#pragma GCC diagnostic warning "-Wuninitialized" +#endif + +void ItemObj::update() +{ + // +} + +void ItemObj::draw() +{ + if (level.models[type].count > 0) { + drawModel(this); + } else { + drawSprite(this); + } +} + +struct ItemSave { + int16 x; + int16 y; + int16 z; + int16 ax; + int16 ay; + uint16 animIndex; + uint16 frameIndex; + uint16 flags; + uint16 timer; + uint8 state; + uint8 nextState; + uint8 goalState; + uint8 roomIndex; +}; + +uint8* ItemObj::save(uint8* data) +{ + ItemSave* sg = (ItemSave*)data; + + sg->x = pos.x - (room->info->x << 8); + sg->y = pos.y - (room->info->yTop); + sg->z = pos.z - (room->info->z << 8); + sg->ax = angle.x; + sg->ay = angle.y; + sg->animIndex = animIndex; + sg->frameIndex = frameIndex; + sg->flags = flags; + sg->timer = timer; + sg->state = state; + sg->nextState = nextState; + sg->goalState = goalState; + sg->roomIndex = room - rooms; + + return data + sizeof(ItemSave); +} + +uint8* ItemObj::load(uint8* data) +{ + ItemSave* sg = (ItemSave*)data; + + if (room) { + room->remove(this); + } + + room = rooms + sg->roomIndex; + room->add(this); + + pos.x = sg->x + (room->info->x << 8); + pos.y = sg->y + (room->info->yTop); + pos.z = sg->z + (room->info->z << 8); + angle.x = sg->ax; + angle.y = sg->ay; + animIndex = sg->animIndex; + frameIndex = sg->frameIndex; + flags = sg->flags; + timer = sg->timer; + state = sg->state; + nextState = sg->nextState; + goalState = sg->goalState; + + return data + sizeof(ItemSave); +} + +void ItemObj::collide(Lara* lara, CollisionInfo* cinfo) +{ + // empty +} + +uint32 ItemObj::collideSpheres(Lara* lara) const +{ +#ifdef FAST_HITMASK + if (type != ITEM_TRAP_SWING_BLADE) + return 0xFFFFFFFF; +#endif + + Sphere *a = gSpheres[0]; + Sphere *b = gSpheres[1]; + + int32 aCount = getSpheres(a, true); + int32 bCount = lara->getSpheres(b, true); + + uint32 mask = 0; + + for (int32 i = 0; i < aCount; i++) + { + if (a[i].radius <= 0) + continue; + + for (int32 j = 0; j < bCount; j++) + { + if (b[j].radius <= 0) + continue; + + vec3i d = b[j].center - a[i].center; + int32 r = b[j].radius + a[i].radius; + + if (X_SQR(d.x) + X_SQR(d.y) + X_SQR(d.z) < X_SQR(r)) + { + mask |= (1 << i); + } + } + } + + return mask; +} + +bool ItemObj::collideBounds(Lara* lara, CollisionInfo* cinfo) const +{ + const AABBs &a = getBoundingBox(false); + const AABBs &b = lara->getBoundingBox(false); + + int32 dy = lara->pos.y - pos.y; + + if ((a.maxY - b.minY <= dy) || + (a.minY - b.maxY >= dy)) + return false; + + int32 dx = lara->pos.x - pos.x; + int32 dz = lara->pos.z - pos.z; + + int32 s, c; + sincos(angle.y, s, c); + + int32 px = X_ROTX(dx, dz, s, c); + int32 pz = X_ROTY(dx, dz, s, c); + + int32 r = cinfo->radius; + + return (px >= a.minX - r) && + (px <= a.maxX + r) && + (pz >= a.minZ - r) && + (pz <= a.maxZ + r); +} + +void ItemObj::collidePush(Lara* lara, CollisionInfo* cinfo, bool enemyHit) const +{ + int32 dx = lara->pos.x - pos.x; + int32 dz = lara->pos.z - pos.z; + + int32 s, c; + sincos(angle.y, s, c); + + int32 px = X_ROTX(dx, dz, s, c); + int32 pz = X_ROTY(dx, dz, s, c); + + const AABBs &box = getBoundingBox(false); + int32 minX = box.minX - cinfo->radius; + int32 maxX = box.maxX + cinfo->radius; + int32 minZ = box.minZ - cinfo->radius; + int32 maxZ = box.maxZ + cinfo->radius; + + if ((px < minX) || (px > maxX) || (pz < minZ) || (pz > maxZ)) + return; + + enemyHit = enemyHit && cinfo->enemyHit && ((box.maxY - box.minY) > 256); + + int32 ax = px - minX; + int32 bx = maxX - px; + int32 az = pz - minZ; + int32 bz = maxZ - pz; + + if (ax <= bx && ax <= az && ax <= bz) { + px -= ax; + } else if (bx <= ax && bx <= az && bx <= bz) { + px += bx; + } else if (az <= ax && az <= bx && az <= bz) { + pz -= az; + } else { + pz += bz; + } + + s = -s; + + lara->pos.x = pos.x + X_ROTX(px, pz, s, c); + lara->pos.z = pos.z + X_ROTY(px, pz, s, c); + + if (enemyHit) + { + int32 cx = (minX + maxX) >> 1; + int32 cz = (minZ + maxZ) >> 1; + dx -= X_ROTX(cx, cz, s, c); + dz -= X_ROTY(cx, cz, s, c); + lara->animHit(dx, dz, 5); + } + + int32 tmpAngle = cinfo->angle; + + cinfo->gapPos = -WALL; + cinfo->gapNeg = -LARA_STEP_HEIGHT; + cinfo->gapCeiling = 0; + + cinfo->setAngle(phd_atan(lara->pos.z - cinfo->pos.z, lara->pos.x - cinfo->pos.x)); + + collideRoom(LARA_HEIGHT, 0); + + cinfo->setAngle(tmpAngle); + + if (cinfo->type != CT_NONE) { + lara->pos.x = cinfo->pos.x; + lara->pos.z = cinfo->pos.z; + } else { + cinfo->pos = lara->pos; + lara->updateRoom(-10); + } +} + +void ItemObj::collideRoom(int32 height, int32 yOffset) const +{ + cinfo.type = CT_NONE; + cinfo.offset = _vec3i(0, 0, 0); + + vec3i p = pos; + p.y += yOffset; + + int32 y = p.y - height; + + int32 cy = y - 160; + + int32 floor, ceiling; + + Room* nextRoom = room; + + #define CHECK_HEIGHT(v) {\ + nextRoom = nextRoom->getRoom(v.x, cy, v.z);\ + const Sector* sector = nextRoom->getSector(v.x, v.z);\ + floor = sector->getFloor(v.x, cy, v.z);\ + if (floor != WALL) floor -= p.y;\ + ceiling = sector->getCeiling(v.x, cy, v.z);\ + if (ceiling != WALL) ceiling -= y;\ + } + +// middle + CHECK_HEIGHT(p); + + cinfo.trigger = gLastFloorData; + cinfo.slantX = FD_SLANT_X(gLastFloorSlant); + cinfo.slantZ = FD_SLANT_Z(gLastFloorSlant); + + cinfo.setSide(CollisionInfo::ST_MIDDLE, floor, ceiling); + + vec3i f, l, r; + int32 R = cinfo.radius; + + int32 s, c; + sincos(cinfo.angle, s, c); + + switch (cinfo.quadrant) { + case 0 : { + f = _vec3i((R * s) >> FIXED_SHIFT, 0, R); + l = _vec3i(-R, 0, R); + r = _vec3i( R, 0, R); + break; + } + case 1 : { + f = _vec3i( R, 0, (R * c) >> FIXED_SHIFT); + l = _vec3i( R, 0, R); + r = _vec3i( R, 0, -R); + break; + } + case 2 : { + f = _vec3i((R * s) >> FIXED_SHIFT, 0, -R); + l = _vec3i( R, 0, -R); + r = _vec3i(-R, 0, -R); + break; + } + case 3 : { + f = _vec3i(-R, 0, (R * c) >> FIXED_SHIFT); + l = _vec3i(-R, 0, -R); + r = _vec3i(-R, 0, R); + break; + } + default : { + f.x = f.y = f.z = 0; + l.x = l.y = l.z = 0; + r.x = r.y = r.z = 0; + ASSERT(false); + } + } + + f += p; + l += p; + r += p; + + vec3i delta; + delta.x = cinfo.pos.x - p.x; + delta.y = cinfo.pos.y - p.y; + delta.z = cinfo.pos.z - p.z; + +// front + CHECK_HEIGHT(f); + cinfo.setSide(CollisionInfo::ST_FRONT, floor, ceiling); + +// left + CHECK_HEIGHT(l); + cinfo.setSide(CollisionInfo::ST_LEFT, floor, ceiling); + +// right + CHECK_HEIGHT(r); + cinfo.setSide(CollisionInfo::ST_RIGHT, floor, ceiling); + +// static objects + room->collideStatic(cinfo, p, height); + +// check middle + if (cinfo.m.floor == WALL) + { + cinfo.offset = delta; + cinfo.type = CT_FRONT; + return; + } + + if (cinfo.m.floor <= cinfo.m.ceiling) + { + cinfo.offset = delta; + cinfo.type = CT_FLOOR_CEILING; + return; + } + + if (cinfo.m.ceiling >= 0) + { + cinfo.offset.y = cinfo.m.ceiling; + cinfo.type = CT_CEILING; + } + +// front + if (cinfo.f.floor > cinfo.gapPos || + cinfo.f.floor < cinfo.gapNeg || + cinfo.f.ceiling > cinfo.gapCeiling) + { + if (cinfo.quadrant & 1) + { + cinfo.offset.x = alignOffset(f.x, p.x); + cinfo.offset.z = delta.z; + } else { + cinfo.offset.x = delta.x; + cinfo.offset.z = alignOffset(f.z, p.z); + } + + cinfo.type = CT_FRONT; + return; + } + +// front ceiling + if (cinfo.f.ceiling >= cinfo.gapCeiling) + { + cinfo.offset = delta; + cinfo.type = CT_FRONT_CEILING; + return; + } + +// left + if (cinfo.l.floor > cinfo.gapPos || cinfo.l.floor < cinfo.gapNeg) + { + if (cinfo.quadrant & 1) { + cinfo.offset.z = alignOffset(l.z, f.z); + } else { + cinfo.offset.x = alignOffset(l.x, f.x); + } + cinfo.type = CT_LEFT; + return; + } + +// right + if (cinfo.r.floor > cinfo.gapPos || cinfo.r.floor < cinfo.gapNeg) + { + if (cinfo.quadrant & 1) { + cinfo.offset.z = alignOffset(r.z, f.z); + } else { + cinfo.offset.x = alignOffset(r.x, f.x); + } + cinfo.type = CT_RIGHT; + return; + } +} + +uint32 ItemObj::updateHitMask(Lara* lara, CollisionInfo* cinfo) +{ + hitMask = 0; + + if (!collideBounds(lara, cinfo)) // check bound box intersection + return false; + + hitMask = collideSpheres(lara); // get hitMask = spheres collision mask + + return hitMask; +} + +void ItemObj::meshSwap(ItemType type, uint32 mask) +{ + int32 start = level.models[type].start; + + for (int32 i = 0; i < JOINT_MAX && mask; i++, mask >>= 1) + { + if (mask & 1) { + extraL->meshes[i] = start + i; + } + } +} + +ItemObj* ItemObj::init(Room* room) +{ + #define INIT_ITEM(type, className) case ITEM_##type : return new (this) className(room) + + switch (type) + { + INIT_ITEM( LARA , Lara ); + INIT_ITEM( DOPPELGANGER , Doppelganger ); + INIT_ITEM( WOLF , Wolf ); + INIT_ITEM( BEAR , Bear ); + INIT_ITEM( BAT , Bat ); + INIT_ITEM( CROCODILE_LAND , Crocodile ); + INIT_ITEM( CROCODILE_WATER , Crocodile ); + INIT_ITEM( LION_MALE , Lion ); + INIT_ITEM( LION_FEMALE , Lion ); + INIT_ITEM( PUMA , Lion ); + INIT_ITEM( GORILLA , Gorilla ); + INIT_ITEM( RAT_LAND , Rat ); + INIT_ITEM( RAT_WATER , Rat ); + INIT_ITEM( REX , Rex ); + INIT_ITEM( RAPTOR , Raptor ); + INIT_ITEM( MUTANT_1 , Mutant ); + INIT_ITEM( MUTANT_2 , Mutant ); + INIT_ITEM( MUTANT_3 , Mutant ); + INIT_ITEM( CENTAUR , Centaur ); + INIT_ITEM( MUMMY , Mummy ); + // INIT_ITEM( UNUSED_1 , ??? ); + // INIT_ITEM( UNUSED_2 , ??? ); + INIT_ITEM( LARSON , Larson ); + INIT_ITEM( PIERRE , Pierre ); + // INIT_ITEM( SKATEBOARD , ??? ); + INIT_ITEM( SKATER , Skater ); + INIT_ITEM( COWBOY , Cowboy ); + INIT_ITEM( MR_T , MrT ); + INIT_ITEM( NATLA , Natla ); + INIT_ITEM( ADAM , Adam ); + INIT_ITEM( TRAP_FLOOR , TrapFloor ); + INIT_ITEM( TRAP_SWING_BLADE , TrapSwingBlade ); + // INIT_ITEM( TRAP_SPIKES , ??? ); + // INIT_ITEM( TRAP_BOULDER , ??? ); + INIT_ITEM( DART , Dart ); + INIT_ITEM( TRAP_DART_EMITTER , TrapDartEmitter ); + // INIT_ITEM( DRAWBRIDGE , ??? ); + // INIT_ITEM( TRAP_SLAM , ??? ); + // INIT_ITEM( TRAP_SWORD , ??? ); + // INIT_ITEM( HAMMER_HANDLE , ??? ); + // INIT_ITEM( HAMMER_BLOCK , ??? ); + // INIT_ITEM( LIGHTNING , ??? ); + // INIT_ITEM( MOVING_OBJECT , ??? ); + INIT_ITEM( BLOCK_1 , Block ); + INIT_ITEM( BLOCK_2 , Block ); + INIT_ITEM( BLOCK_3 , Block ); + INIT_ITEM( BLOCK_4 , Block ); + // INIT_ITEM( MOVING_BLOCK , ??? ); + // INIT_ITEM( TRAP_CEILING , ??? ); + // INIT_ITEM( TRAP_FLOOR_LOD , ??? ); + INIT_ITEM( SWITCH , Switch ); + INIT_ITEM( SWITCH_WATER , SwitchWater ); + INIT_ITEM( DOOR_1 , Door ); + INIT_ITEM( DOOR_2 , Door ); + INIT_ITEM( DOOR_3 , Door ); + INIT_ITEM( DOOR_4 , Door ); + INIT_ITEM( DOOR_5 , Door ); + INIT_ITEM( DOOR_6 , Door ); + INIT_ITEM( DOOR_7 , Door ); + INIT_ITEM( DOOR_8 , Door ); + INIT_ITEM( TRAP_DOOR_1 , TrapDoor ); + INIT_ITEM( TRAP_DOOR_2 , TrapDoor ); + // INIT_ITEM( TRAP_DOOR_LOD , ??? ); + // INIT_ITEM( BRIDGE_FLAT , ??? ); + // INIT_ITEM( BRIDGE_TILT_1 , ??? ); + // INIT_ITEM( BRIDGE_TILT_2 , ??? ); + // INIT_ITEM( INV_PASSPORT , ??? ); + // INIT_ITEM( INV_COMPASS , ??? ); + // INIT_ITEM( INV_HOME , ??? ); + INIT_ITEM( GEARS_1 , Gears ); + INIT_ITEM( GEARS_2 , Gears ); + INIT_ITEM( GEARS_3 , Gears ); + INIT_ITEM( CUT_1 , CinematicObject ); + INIT_ITEM( CUT_2 , CinematicObject ); + INIT_ITEM( CUT_3 , CinematicObject ); + INIT_ITEM( CUT_4 , CinematicObject ); + // INIT_ITEM( INV_PASSPORT_CLOSED , ??? ); + // INIT_ITEM( INV_MAP , ??? ); + INIT_ITEM( CRYSTAL , Crystal ); + INIT_ITEM( PISTOLS , Pickup ); + INIT_ITEM( SHOTGUN , Pickup ); + INIT_ITEM( MAGNUMS , Pickup ); + INIT_ITEM( UZIS , Pickup ); + INIT_ITEM( AMMO_PISTOLS , Pickup ); + INIT_ITEM( AMMO_SHOTGUN , Pickup ); + INIT_ITEM( AMMO_MAGNUMS , Pickup ); + INIT_ITEM( AMMO_UZIS , Pickup ); + INIT_ITEM( EXPLOSIVE , Pickup ); + INIT_ITEM( MEDIKIT_SMALL , Pickup ); + INIT_ITEM( MEDIKIT_BIG , Pickup ); + // INIT_ITEM( INV_DETAIL , ??? ); + // INIT_ITEM( INV_SOUND , ??? ); + // INIT_ITEM( INV_CONTROLS , ??? ); + // INIT_ITEM( INV_GAMMA , ??? ); + // INIT_ITEM( INV_PISTOLS , ??? ); + // INIT_ITEM( INV_SHOTGUN , ??? ); + // INIT_ITEM( INV_MAGNUMS , ??? ); + // INIT_ITEM( INV_UZIS , ??? ); + // INIT_ITEM( INV_AMMO_PISTOLS , ??? ); + // INIT_ITEM( INV_AMMO_SHOTGUN , ??? ); + // INIT_ITEM( INV_AMMO_MAGNUMS , ??? ); + // INIT_ITEM( INV_AMMO_UZIS , ??? ); + // INIT_ITEM( INV_EXPLOSIVE , ??? ); + // INIT_ITEM( INV_MEDIKIT_SMALL , ??? ); + // INIT_ITEM( INV_MEDIKIT_BIG , ??? ); + INIT_ITEM( PUZZLE_1 , Pickup ); + INIT_ITEM( PUZZLE_2 , Pickup ); + INIT_ITEM( PUZZLE_3 , Pickup ); + INIT_ITEM( PUZZLE_4 , Pickup ); + // INIT_ITEM( INV_PUZZLE_1 , ??? ); + // INIT_ITEM( INV_PUZZLE_2 , ??? ); + // INIT_ITEM( INV_PUZZLE_3 , ??? ); + // INIT_ITEM( INV_PUZZLE_4 , ??? ); + INIT_ITEM( PUZZLEHOLE_1 , PuzzleHole ); + INIT_ITEM( PUZZLEHOLE_2 , PuzzleHole ); + INIT_ITEM( PUZZLEHOLE_3 , PuzzleHole ); + INIT_ITEM( PUZZLEHOLE_4 , PuzzleHole ); + // INIT_ITEM( PUZZLE_DONE_1 , ??? ); + // INIT_ITEM( PUZZLE_DONE_2 , ??? ); + // INIT_ITEM( PUZZLE_DONE_3 , ??? ); + // INIT_ITEM( PUZZLE_DONE_4 , ??? ); + INIT_ITEM( LEADBAR , Pickup ); + // INIT_ITEM( INV_LEADBAR , ??? ); + // INIT_ITEM( MIDAS_HAND , ??? ); + INIT_ITEM( KEY_ITEM_1 , Pickup ); + INIT_ITEM( KEY_ITEM_2 , Pickup ); + INIT_ITEM( KEY_ITEM_3 , Pickup ); + INIT_ITEM( KEY_ITEM_4 , Pickup ); + // INIT_ITEM( INV_KEY_ITEM_1 , ??? ); + // INIT_ITEM( INV_KEY_ITEM_2 , ??? ); + // INIT_ITEM( INV_KEY_ITEM_3 , ??? ); + // INIT_ITEM( INV_KEY_ITEM_4 , ??? ); + INIT_ITEM( KEYHOLE_1 , KeyHole ); + INIT_ITEM( KEYHOLE_2 , KeyHole ); + INIT_ITEM( KEYHOLE_3 , KeyHole ); + INIT_ITEM( KEYHOLE_4 , KeyHole ); + // INIT_ITEM( UNUSED_4 , ??? ); + // INIT_ITEM( UNUSED_5 , ??? ); + // INIT_ITEM( SCION_PICKUP_QUALOPEC , ??? ); + INIT_ITEM( SCION_PICKUP_DROP , Pickup ); + INIT_ITEM( SCION_TARGET , ViewTarget ); + // INIT_ITEM( SCION_PICKUP_HOLDER , ??? ); + // INIT_ITEM( SCION_HOLDER , ??? ); + // INIT_ITEM( UNUSED_6 , ??? ); + // INIT_ITEM( UNUSED_7 , ??? ); + // INIT_ITEM( INV_SCION , ??? ); + // INIT_ITEM( EXPLOSION , ??? ); + // INIT_ITEM( UNUSED_8 , ??? ); + INIT_ITEM( SPLASH , SpriteEffect ); + // INIT_ITEM( UNUSED_9 , ??? ); + INIT_ITEM( BUBBLE , Bubble ); + // INIT_ITEM( UNUSED_10 , ??? ); + // INIT_ITEM( UNUSED_11 , ??? ); + INIT_ITEM( BLOOD , SpriteEffect ); + // INIT_ITEM( UNUSED_12 , ??? ); + INIT_ITEM( SMOKE , SpriteEffect ); + // INIT_ITEM( CENTAUR_STATUE , ??? ); + // INIT_ITEM( CABIN , ??? ); + // INIT_ITEM( MUTANT_EGG_SMALL , ??? ); + INIT_ITEM( RICOCHET , SpriteEffect ); + INIT_ITEM( SPARKLES , SpriteEffect ); + // INIT_ITEM( MUZZLE_FLASH , ??? ); + // INIT_ITEM( UNUSED_13 , ??? ); + // INIT_ITEM( UNUSED_14 , ??? ); + INIT_ITEM( VIEW_TARGET , ViewTarget ); + INIT_ITEM( WATERFALL , Waterfall ); + // INIT_ITEM( NATLA_BULLET , ??? ); + // INIT_ITEM( MUTANT_BULLET , ??? ); + // INIT_ITEM( CENTAUR_BULLET , ??? ); + // INIT_ITEM( UNUSED_15 , ??? ); + // INIT_ITEM( UNUSED_16 , ??? ); + // INIT_ITEM( LAVA_PARTICLE , ??? ); + INIT_ITEM( LAVA_EMITTER , LavaEmitter ); + // INIT_ITEM( FLAME , ??? ); + // INIT_ITEM( FLAME_EMITTER , ??? ); + // INIT_ITEM( TRAP_LAVA , ??? ); + // INIT_ITEM( MUTANT_EGG_BIG , ??? ); + // INIT_ITEM( BOAT , ??? ); + // INIT_ITEM( EARTHQUAKE , ??? ); + // INIT_ITEM( UNUSED_17 , ??? ); + // INIT_ITEM( UNUSED_18 , ??? ); + // INIT_ITEM( UNUSED_19 , ??? ); + // INIT_ITEM( UNUSED_20 , ??? ); + // INIT_ITEM( UNUSED_21 , ??? ); + // INIT_ITEM( LARA_BRAID , ??? ); + // INIT_ITEM( GLYPHS , ??? ); + } + + return new (this) ItemObj(room); +} + +#endif diff --git a/src/fixed/lang/en.h b/src/fixed/lang/en.h new file mode 100644 index 00000000..e9eeb6df --- /dev/null +++ b/src/fixed/lang/en.h @@ -0,0 +1,394 @@ +#ifndef H_LANG_EN +#define H_LANG_EN + +// Thanks: Nancy Charlton, Vague Rant + +const char* const STR_EN[STR_MAX] = { "" + , "Thanks for playing the" + , "OpenLara alpha demo!" + , "" + , "follow the project news:" + , "discord.gg/EF8JaQB" + , "t.me/openlara" + , "No SRAM or FRAM" + , "Saves will be lost" + , "after GBA reboot!" +// help + , "Loading..." + , "%s@@@" + "KILLS %d@@" + "PICKUPS %d@@" + "SECRETS %d of %d@@" + "TIME TAKEN %s" + , "Saving game..." + , "Saving done!" + , "SAVING ERROR!" + , "YES" + , "NO" + , "Off" + , "On" + , "OK" + , "Side-By-Side" + , "Anaglyph" + , "Split Screen" + , "VR" + , "Low" + , "Medium" + , "High" + , STR_LANGUAGES + , "Apply" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Not Ready" + , "Player 1" + , "Player 2" + , "Press Any Key" + , "%s - Select" + , "%s - Go Back" +// inventory pages + , "OPTIONS" + , "INVENTORY" + , "ITEMS" +// save game page + , "Save Game?" + , "Current Position" +// inventory option + , "Game" + , "Map" + , "Compass" + , "Statistics" + , "Lara's Home" + , "Graphics" //, "Detail Levels" + , "Sound" + , "Controls" + , "Gamma" +// passport menu + , "Load Game" + , "Save Game" + , "New Game" + , "Restart Level" + , "Exit to Title" + , "Exit Game" + , "Select Level" +// detail options + , "Select Detail" + , "Gamma" + , "Show FPS" + , "Filtering" + , "Lighting" + , "Shadows" + , "Water" + , "VSync" + , "Stereo" + , "Simple Items" + , "Resolution" + , STR_SCALE +// sound options + , "Set Volumes" + , "Reverberation" + , "Subtitles" + , "Language" + , "SFX" + , "Music" +// controls options + , "Set Controls" + , "Keyboard" + , "Gamepad" + , "Rumble" + , "Retargeting" + , "Multi-aiming" + , "Swap A B" + // controls + , "Run" + , "Back" + , "Right" + , "Left" + , "Walk" + , "Jump" + , "Action" + , "Weapon" + , "Look" + , "Roll" + , "Inventory" + , "Pause" + // control keys + , "Up" + , "Down" + , "Right" + , "Left" + , "A" + , "B" + , "L" + , "R" + , "Select" + , "Start" + , "L+R" + , "L+A" + , "L+B" +// inventory items + , "Unknown" + , "Explosive" + , "Pistols" + , "Shotgun" + , "Magnums" + , "Uzis" + , "Pistol Clips" + , "Shotgun Shells" + , "Magnum Clips" + , "Uzi Clips" + , "Small Medi Pack" + , "Large Medi Pack" + , "Lead Bar" + , "Scion" +// keys + , "Key" + , "Silver Key" + , "Rusty Key" + , "Gold Key" + , "Sapphire Key" + , "Neptune Key" + , "Atlas Key" + , "Damocles Key" + , "Thor Key" + , "Ornate Key" +// puzzles + , "Puzzle" + , "Gold Idol" + , "Gold Bar" + , "Machine Cog" + , "Fuse" + , "Ankh" + , "Eye of Horus" + , "Seal of Anubis" + , "Scarab" + , "Pyramid Key" +#ifdef USE_SUBTITLES +// TR1 subtitles + /* CAFE */ , + "[43500]What's a man gotta do to@get that kinda attention from ye?" + "[47500]It's hard to say exactly,@but you seem to be doing fine." + "[50000]Well, great. Though, truth is,@it ain't me that wants ye." + "[54500]No?" + "[55000]No. Miss Jacqueline Natla does,@from Natla Technologies." + "[59000]You know, creator of@all things bright and beautiful?" + "[64500]Seal it, Larson." + "[66000]Ma'am." + "[68000]Feast your eyes on this, Lara." + "[70500]How does that make your wallet rumble?" + "[73500]I'm sorry. I only play for sport." + "[76000]Then you'll like a big park." + "[78000]Peru. Vast mountain ranges to cover.@Sheer walls of ice. Rocky crags. Savage winds." + "[87500]And there's this little trinket:@an age old artefact of mystical powers" + "[92500]buried in the unfound tomb of Qualopec." + "[96000]That's my interest." + "[98000]You could leave tomorrow.@Are you busy tomorrow?" + /* LIFT */ , + "[49000]Relocated now to St. Francis' Folly, new temptations torment me." + "[53500]Rumour amongst my fellow brothers is that entombed@beneath our monastery lies the body of Tihocan," + "[60000]one of the three legendary rulers of@the lost continent, Atlantis," + "[64500]and that within lies his piece@of the Atlantean Scion." + "[68000]The pendant divided and shared between the three rulers@" + "[72500]which curbs tremendous powers.@Powers beyond the creator himself." + "[79000]My toes sweat at such possibilities@lying so close to my mortal self." + "[85500]Each night, I bid myself rid of these@fantasies, but it is indeed a test." + "[92000]" + "[93500]Pierre. Tsk. You litterbug." + /* CANYON */ , + "[13500]You just pulled the tough end of a wishbone." + "[16500]Howdy." + "[17500]Afternoon." + "[20000]Left Larson sucking wind then, eh?" + "[22500]If that is the phrase." + "[24000]Well, your little vacation riot's over now." + "[27000]Time to give back what you've hijacked off me." + "[30000]Let's try the lunch-box." + "[32000]" + "[42500]Well? Kill her!" + "[45000]Hey!" + "[48000]" + "[50500]You morons!" + "[53000]" + "[62500]Let's go." + "[65000]" + "[136000]What the heck was that?" + "[138000]What?" + "[138500]That-a-way." + "[140500]Probably just a fish." + "[142500]That's some fish, kid." + "[145000]Man, you have got to learn to chill.@I'm going back inside. You coming?" + "[152000]" + "[158000]Steady..." + "[160000]Here she goes." + "[161500]You ready yet?" + /* PRISON */ , + "[00001]You can't do this!" + "[01500]We condemn you, Natla of Atlantis, for your crimes." + "[06000]For the flagrant misuse of your powers@and for robbing us of our..." + "[11500]You can't! I..." + "[12500]Breaking the free bond of consent that our@people are ruled and secured under," + "[18500]and invading Tihocan and myself with our army." + "[23500]Our warriors emptied from our pyramid" + "[27000]so that you could use the pyramid - its powers@of creation - for your own mindless destruction." + "[33500]Mindless!? Look at you!" + "[35500]Neither of you have one squirt of@inventive juice in your heads." + "[40500]Wasters!" + "[41500]Let's just do it." + "[44000]Tihocan!" + "[45000]You used the sacramental place as a source@of individual pleasure," + "[49500]as some freak factory." + "[51000]They're survivalists. A new generation." + "[54000]A slaughter heap now." + "[56000]And you. We're going to lock you in limbo." + "[60000]Make your veins, heart, feet," + "[64000]and that diseased brain stick solid with frozen blood." + "[70000]Greet your eternal unrest, Natla." + "[73000]You won't rest either, or your@damned continent of Atlantis!" + /* 22 */ , + "[04000]Back again?" + "[05500]And you - for a grand re-opening, I assume." + "[09500]Evolution's in a rut - natural selection at an all time low..." + "[13500]shipping out fresh meat will incite territorial rages again" + "[17500] - will strengthen and advance us..." + "[20500]Even create new breeds." + "[22500]Kind of evolution on steroids, then." + "[24500]A kick in the pants...@those runts Qualopec and Tihocan had no idea" + "[29500] - the cataclysm of Atlantis struck a race of langouring wimps..." + "[33500]plummeted them to the very basics of survival again..." + "[37000]It shouldn't happen like that." + "[39000]Or like this." + "[40000]Hatching commences in 15 seconds." + "[43000]Too late for abortions now!" + "[45000]Not without the heart of the operation!" + "[47000]Noooo!" + "[50000]TEN" + "[54000]FIVE..." + "[55500]4...3...2..." + "[60000]ONE..." + /* 23 */ , + "[00001]Well, you have my total attention now" + "[02500]- I'm not quite sure if I've got yours, though." + "[05000]Hello?" + "[06000]I'll heel an' hide ye to a barn door yit." + "[09000]Of course." + "[10000]Ye and that drivelin' piece of the Scion." + "[13000]Ye want to keep it so bad, I'll harness it right up y..." + "[17000]Wait... we're talking about the artifact here?" + "[20000]Damn straight we are ... right up y ..." + "[22000]Hold on - I'm sorry" + "[24000]- this piece, you say - where's the rest?" + "[26500]Ms. Natla put Pierre Dupont on that trail." + "[29500]And where is that?" + "[30500]Hah. Ye ain't fast enough fer him." + "[34000]So you think all this talking is just holding me up?" + "[37000]I don't know where his little jackrabbit-frog-legs are runnin' him to." + "[42000]You'll have to ask Ms. Natla." + "[46000]" + "[51000]Thank you. I will." + /* 24 */ , "" + /* 25 */ , + "[03500]Here lies Tihocan" + "[05000]...one of the two just rulers of Atlantis..." + "[10000]Who even after the curse of the continent..." + "[13000]...had tried to keep rule here in these barren other-lands..." + "[19000]He died without child and his knowledge has no heritage..." + "[25500]Look over us kindly, Tihocan." + /* 26 */ , "Welcome to my home!@I'll take you on a guided tour." + /* 27 */ , "Use the directional keys to go into the music room." + /* 28 */ , "OK. Let's do some tumbling.@Press the jump button." + /* 29 */ , "Now press it again and quickly press one of@the directions and I'll jump that way." + /* 30 */ , "Ah, the main hall.@Sorry about the crates, I'm having some things put@ into storage and the delivery people haven't been yet." + /* 31 */ , "Run up to a crate, and while still pressing forward,@press action, and I'll vault up onto it." + /* 32 */ , "This used to be the ballroom, but I've@converted it into my own personal gym.@What do you think?@Well, let's do some exercises." + /* 33 */ , "I don't actually run everywhere.@When I want to be careful, I walk.@Hold down the walk button, and walk to the white line." + /* 34 */ , "With the walk button down, I won't fall off even if you try to make me.@Go on, try it." + /* 35 */ , "If you want look around, press and hold the look button.@Then press in the direction you want to look." + /* 36 */ , "If a jump is too far for me, I can grab the ledge and save myself@from a nasty fall. Walk to the edge with the white line until I@won't go any further. Then press jump, immediately followed by@forward and while I'm in the air, press and hold the action button." + /* 37 */ , "Press forward and I'll climb up." + /* 38 */ , "If I do a running jump, I can make a jump like that, no problem." + /* 39 */ , "Walk to the edge with the white line until I stop.@Then let go of walk and tap backwards to give me a run up.@Press forward, and almost immediately press and hold the jump button.@I won't actually jump until the last minute." + /* 40 */ , "Right. This is a really big one.@So do a running jump exactly as before except while I'm in the air@press and hold the action button to make me grab the ledge." + /* 41 */ , "Nice." + /* 42 */ , "Try to vault up here.@Press forward and hold action." + /* 43 */ , "I can't climb up because the gap is too small.@But press right and I'll shimmy sideways@until there is room, then press forward." + /* 44 */ , "Great!@If there is a long drop and I don't want to@hurt myself jumping off, I can let myself down carefully." + /* 45 */ , "Tap backwards, and I'll jump off backwards.@Immediately press and hold the action button,@and I'll grab the ledge on the way down." + /* 46 */ , "Then let go." + /* 47 */ , "Let's go for a swim." + /* 48 */ , "The jump button and the directions@move me around underwater." + /* 49 */ , "Ah! Air!@Just use forward and left and right@to manoeuvre around on the surface.@Press jump to dive down for another swim about.@Or go to the edge and press action to climb out." + /* 50 */ , "Right. Now I'd better take off these wet clothes." + /* 51 */ , "Say cheese!" + /* 52 */ , "Ain't nothin' personal." + /* 53 */ , "I still git a pain in my brain from ye.@An' it's tellin' me funny ideas now.@Like to shoot you to hell!" + /* 54 */ , "You can't bump off me and my brood so easy, Lara." + /* 55 */ , "A leetle late for ze prize giving - non?@Still, it is ze taking-part wheech counts." + /* 56 */ , "You firin' at me?@You firin' at me, huh?@Ain't nobody else here, you must be firin' at me!" +#endif +// TR1 levels + , "Lara's Home" + , "Caves" + , "City of Vilcabamba" + , "Lost Valley" + , "Tomb of Qualopec" + , "St. Francis' Folly" + , "Colosseum" + , "Palace Midas" + , "The Cistern" + , "Tomb of Tihocan" + , "City of Khamoon" + , "Obelisk of Khamoon" + , "Sanctuary of the Scion" + , "Natla's Mines" + , "Atlantis" + , "The Great Pyramid" + , "Return to Egypt" + , "Temple of the Cat" + , "Atlantean Stronghold" + , "The Hive" +// TR2 levels + , "Lara's Home" + , "The Great Wall" + , "Venice" + , "Bartoli's Hideout" + , "Opera House" + , "Offshore Rig" + , "Diving Area" + , "40 Fathoms" + , "Wreck of the Maria Doria" + , "Living Quarters" + , "The Deck" + , "Tibetan Foothills" + , "Barkhang Monastery" + , "Catacombs of the Talion" + , "Ice Palace" + , "Temple of Xian" + , "Floating Islands" + , "The Dragon's Lair" + , "Home Sweet Home" +// TR3 levels + , "Lara's House" + , "Jungle" + , "Temple Ruins" + , "The River Ganges" + , "Caves Of Kaliya" + , "Coastal Village" + , "Crash Site" + , "Madubu Gorge" + , "Temple Of Puna" + , "Thames Wharf" + , "Aldwych" + , "Lud's Gate" + , "City" + , "Nevada Desert" + , "High Security Compound" + , "Area 51" + , "Antarctica" + , "RX-Tech Mines" + , "Lost City Of Tinnos" + , "Meteorite Cavern" + , "All Hallows" +}; + +#endif \ No newline at end of file diff --git a/src/fixed/lara.h b/src/fixed/lara.h new file mode 100644 index 00000000..846ca623 --- /dev/null +++ b/src/fixed/lara.h @@ -0,0 +1,4147 @@ +#ifndef H_LARA +#define H_LARA + +#include "common.h" +#include "item.h" +#include "camera.h" +#include "inventory.h" + +#define LARA_STATES(E) \ + E( STATE_WALK ) \ + E( STATE_RUN ) \ + E( STATE_STOP ) \ + E( STATE_JUMP ) \ + E( STATE_POSE ) \ + E( STATE_BACK_FAST ) \ + E( STATE_TURN_RIGHT ) \ + E( STATE_TURN_LEFT ) \ + E( STATE_DEATH ) \ + E( STATE_FALL ) \ + E( STATE_HANG ) \ + E( STATE_REACH ) \ + E( STATE_SPLAT ) \ + E( STATE_UW_TREAD ) \ + E( STATE_LAND ) \ + E( STATE_COMPRESS ) \ + E( STATE_BACK ) \ + E( STATE_UW_SWIM ) \ + E( STATE_UW_GLIDE ) \ + E( STATE_HANG_UP ) \ + E( STATE_TURN_FAST ) \ + E( STATE_STEP_RIGHT ) \ + E( STATE_STEP_LEFT ) \ + E( STATE_ROLL_END ) \ + E( STATE_SLIDE ) \ + E( STATE_JUMP_BACK ) \ + E( STATE_JUMP_RIGHT ) \ + E( STATE_JUMP_LEFT ) \ + E( STATE_JUMP_UP ) \ + E( STATE_FALL_BACK ) \ + E( STATE_HANG_LEFT ) \ + E( STATE_HANG_RIGHT ) \ + E( STATE_SLIDE_BACK ) \ + E( STATE_SURF_TREAD ) \ + E( STATE_SURF_SWIM ) \ + E( STATE_UW_DIVE ) \ + E( STATE_BLOCK_PUSH ) \ + E( STATE_BLOCK_PULL ) \ + E( STATE_BLOCK_READY ) \ + E( STATE_PICKUP ) \ + E( STATE_SWITCH_DOWN ) \ + E( STATE_SWITCH_UP ) \ + E( STATE_USE_KEY ) \ + E( STATE_USE_PUZZLE ) \ + E( STATE_DEATH_UW ) \ + E( STATE_ROLL_START ) \ + E( STATE_SPECIAL ) \ + E( STATE_SURF_BACK ) \ + E( STATE_SURF_LEFT ) \ + E( STATE_SURF_RIGHT ) \ + E( STATE_USE_MIDAS ) \ + E( STATE_DEATH_MIDAS ) \ + E( STATE_SWAN_DIVE ) \ + E( STATE_FAST_DIVE ) \ + E( STATE_HANDSTAND ) \ + E( STATE_WATER_OUT ) \ + E( STATE_CLIMB_START ) \ + E( STATE_CLIMB_UP ) \ + E( STATE_CLIMB_LEFT ) \ + E( STATE_CLIMB_END ) \ + E( STATE_CLIMB_RIGHT ) \ + E( STATE_CLIMB_DOWN ) \ + E( STATE_UNUSED_1 ) \ + E( STATE_UNUSED_2 ) \ + E( STATE_UNUSED_3 ) \ + E( STATE_WADE ) \ + E( STATE_ROLL_UW ) \ + E( STATE_PICKUP_FLARE ) \ + E( STATE_ROLL_AIR ) \ + E( STATE_UNUSED_4 ) \ + E( STATE_ZIPLINE ) + +#define DECL_ENUM(v) v, +#define DECL_S_HANDLER(v) &Lara::s_##v, +#define DECL_C_HANDLER(v) &Lara::c_##v, +#define S_HANDLER(state) void s_##state() +#define C_HANDLER(state) void c_##state() + +#define LARA_HANG_SLANT 60 +#define LARA_HANG_OFFSET 724 +#define LARA_HEIGHT 762 +#define LARA_HEIGHT_JUMP 870 // LARA_HEIGHT + hands up +#define LARA_HEIGHT_UW 400 +#define LARA_HEIGHT_SURF 700 +#define LARA_RADIUS 100 +#define LARA_RADIUS_WATER 300 +#define LARA_RADIUS_CLIMB 220 +#define LARA_HEIGHT 762 +#define LARA_TURN_ACCEL (ANGLE(9) / 4) +#define LARA_TURN_JUMP ANGLE(3) +#define LARA_TURN_VERY_SLOW ANGLE(2) +#define LARA_TURN_SLOW ANGLE(4) +#define LARA_TURN_MED ANGLE(6) +#define LARA_TURN_FAST ANGLE(8) +#define LARA_TILT_ACCEL (ANGLE(3) / 2) +#define LARA_TILT_MAX ANGLE(11) +#define LARA_STEP_HEIGHT 384 +#define LARA_SMASH_HEIGHT 640 +#define LARA_FLOAT_UP_SPEED 5 +#define LARA_SWIM_FRICTION 6 +#define LARA_SWIM_ACCEL 8 +#define LARA_SWIM_SPEED_MIN 133 +#define LARA_SWIM_SPEED_MAX 200 +#define LARA_SWIM_TIMER 10 // 1/3 sec +#define LARA_SURF_FRICTION 4 +#define LARA_SURF_ACCEL 8 +#define LARA_SURF_SPEED_MAX 60 +#define LARA_DIVE_SPEED 80 +#define LARA_WADE_MIN_DEPTH 384 +#define LARA_WADE_MAX_DEPTH 730 +#define LARA_SWIM_MIN_DEPTH 512 + +enum { + JOINT_MASK_HIPS = 1 << JOINT_HIPS, + JOINT_MASK_LEG_L1 = 1 << JOINT_LEG_L1, + JOINT_MASK_LEG_L2 = 1 << JOINT_LEG_L2, + JOINT_MASK_LEG_L3 = 1 << JOINT_LEG_L3, + JOINT_MASK_LEG_R1 = 1 << JOINT_LEG_R1, + JOINT_MASK_LEG_R2 = 1 << JOINT_LEG_R2, + JOINT_MASK_LEG_R3 = 1 << JOINT_LEG_R3, + JOINT_MASK_TORSO = 1 << JOINT_TORSO, + JOINT_MASK_ARM_R1 = 1 << JOINT_ARM_R1, + JOINT_MASK_ARM_R2 = 1 << JOINT_ARM_R2, + JOINT_MASK_ARM_R3 = 1 << JOINT_ARM_R3, + JOINT_MASK_ARM_L1 = 1 << JOINT_ARM_L1, + JOINT_MASK_ARM_L2 = 1 << JOINT_ARM_L2, + JOINT_MASK_ARM_L3 = 1 << JOINT_ARM_L3, + JOINT_MASK_HEAD = 1 << JOINT_HEAD, + JOINT_MASK_ARM_L = JOINT_MASK_ARM_L1 | JOINT_MASK_ARM_L2 | JOINT_MASK_ARM_L3, + JOINT_MASK_ARM_R = JOINT_MASK_ARM_R1 | JOINT_MASK_ARM_R2 | JOINT_MASK_ARM_R3, + JOINT_MASK_LEG_L = JOINT_MASK_LEG_L1 | JOINT_MASK_LEG_L2 | JOINT_MASK_LEG_L3, + JOINT_MASK_LEG_R = JOINT_MASK_LEG_R1 | JOINT_MASK_LEG_R2 | JOINT_MASK_LEG_R3, + JOINT_MASK_UPPER = JOINT_MASK_TORSO | JOINT_MASK_ARM_L | JOINT_MASK_ARM_R, // without head + JOINT_MASK_LOWER = JOINT_MASK_HIPS | JOINT_MASK_LEG_L | JOINT_MASK_LEG_R, + JOINT_MASK_BRAID = JOINT_MASK_HEAD | JOINT_MASK_TORSO | JOINT_MASK_ARM_L1 | JOINT_MASK_ARM_L2 | JOINT_MASK_ARM_R1 | JOINT_MASK_ARM_R2 +}; + +EWRAM_DATA Lara* players[MAX_PLAYERS]; +EWRAM_DATA CollisionInfo cinfo; + +const WeaponParams weaponParams[WEAPON_MAX] = { + { // WEAPON_PISTOLS + ITEM_LARA_PISTOLS, // modelType + ITEM_LARA_PISTOLS, // animType + 1, // damage + ANGLE(8), // spread + 8192, // range + 650, // height + SND_PISTOLS_SHOT, // soundId + 9, // reloadTimer + 155, // flashOffset + 3, // flashTimer + 20, // flashIntensity + ANGLE(60), // aimX + ANGLE(60), // aimY + ANGLE(80), // armX + ANGLE(-60), // armMinY + ANGLE(170), // armMaxY + }, + { // WEAPON_MAGNUMS + ITEM_LARA_MAGNUMS, // modelType + ITEM_LARA_PISTOLS, // animType + 2, // damage + ANGLE(8), // spread + 8192, // range + 650, // height + SND_MAGNUMS_SHOT, // soundId + 9, // reloadTimer + 155, // flashOffset + 3, // flashTimer + 16, // flashIntensity + ANGLE(60), // aimX + ANGLE(60), // aimY + ANGLE(80), // armX + ANGLE(-60), // armMinY + ANGLE(170), // armMaxY + }, + { // WEAPON_UZIS + ITEM_LARA_UZIS, // modelType + ITEM_LARA_PISTOLS, // animType + 1, // damage + ANGLE(8), // spread + 8192, // range + 650, // height + SND_UZIS_SHOT, // soundId + 3, // reloadTimer + 180, // flashOffset + 2, // flashTimer + 10, // flashIntensity + ANGLE(60), // aimX + ANGLE(60), // aimY + ANGLE(80), // armX + ANGLE(-60), // armMinY + ANGLE(170), // armMaxY + }, + { // WEAPON_SHOTGUN + ITEM_LARA_SHOTGUN, // modelType + ITEM_LARA_SHOTGUN, // animType + 4, // damage + ANGLE(20), // spread + 8192, // range + 500, // height + SND_SHOTGUN_SHOT, // soundId + 26, // reloadTimer + 0, // flashOffset + 0, // flashTimer + 0, // flashIntensity + ANGLE(55), // aimX + ANGLE(60), // aimY + ANGLE(65), // armX + ANGLE(-80), // armMinY + ANGLE(80), // armMaxY + }, +}; + +struct Lara : ItemObj +{ + enum State { + LARA_STATES(DECL_ENUM) + X_MAX + }; + + enum { + ANIM_PISTOLS_AIM = 0, + ANIM_PISTOLS_PICK, + ANIM_PISTOLS_DRAW, + ANIM_PISTOLS_FIRE, + + ANIM_SHOTGUN_AIM = 0, + ANIM_SHOTGUN_DRAW, + ANIM_SHOTGUN_FIRE + }; + + enum { + ANIM_RUN = 0, + + ANIM_STAND_LEFT = 2, + ANIM_STAND_RIGHT = 3, + + ANIM_RUN_START = 6, + + ANIM_STAND = 11, + + ANIM_LANDING = 24, + + ANIM_CLIMB_JUMP = 26, + + ANIM_FALL_HANG = 28, + + ANIM_SMASH_JUMP = 32, + + ANIM_FALL_FORTH = 34, + + ANIM_BACK = 41, + ANIM_CLIMB_3 = 42, + + ANIM_CLIMB_2 = 50, + + ANIM_SMASH_RUN_LEFT = 53, + ANIM_SMASH_RUN_RIGHT = 54, + ANIM_RUN_ASCEND_LEFT = 55, + ANIM_RUN_ASCEND_RIGHT = 56, + ANIM_WALK_ASCEND_LEFT = 57, + ANIM_WALK_ASCEND_RIGHT = 58, + ANIM_WALK_DESCEND_RIGHT = 59, + ANIM_WALK_DESCEND_LEFT = 60, + ANIM_BACK_DESCEND_LEFT = 61, + ANIM_BACK_DESCEND_RIGHT = 62, + + ANIM_SLIDE_FORTH = 70, + + ANIM_UW_GLIDE = 87, + + ANIM_FALL_BACK = 93, + + ANIM_HANG = 96, + + ANIM_STAND_NORMAL = 103, + + ANIM_SLIDE_BACK = 104, + + ANIM_UNDERWATER = 108, + + ANIM_WATER_OUT = 111, + ANIM_WATER_FALL = 112, + ANIM_SURF = 114, + ANIM_SURF_SWIM = 116, + ANIM_SURF_DIVE = 119, + ANIM_BLOCK_READY = 120, + + ANIM_HIT_FRONT = 125, + ANIM_HIT_BACK = 126, + ANIM_HIT_LEFT = 127, + ANIM_HIT_RIGHT = 128, + + ANIM_DEATH_BOULDER = 139, + ANIM_SURF_BACK = 140, + + ANIM_SURF_LEFT = 143, + ANIM_SURF_RIGHT = 144, + + ANIM_STAND_ROLL_BEGIN = 146, + ANIM_STAND_ROLL_END = 147, + + ANIM_DEATH_SPIKES = 149, + ANIM_HANG_SWING = 150, + + ANIM_CLIMB_START = 164, + + ANIM_WADE_SWIM = 176, + ANIM_WADE = 177, + ANIM_WADE_RUN_LEFT = 178, + ANIM_WADE_RUN_RIGHT = 179, + ANIM_WADE_STAND = 186, + ANIM_WADE_ASCEND = 190, + ANIM_SURF_OUT = 191, + ANIM_SWIM_STAND = 192, + ANIM_SURF_STAND = 193, + + ANIM_SWITCH_BIG_DOWN = 195, + ANIM_SWITCH_BIG_UP = 196, + ANIM_PUSH_BUTTON = 197, + + ANIM_UW_ROLL = 203 + }; + + typedef void (Lara::*Handler)(); + + static const Handler sHandlers[X_MAX]; + static const Handler cHandlers[X_MAX]; + + void updateState() + { + (this->*sHandlers[state])(); + } + + void updateObjectsCollision() + { + if (health <= 0) + { + extraL->hitQuadrant = -1; + return; + } + + Room** adjRoom = room->getAdjRooms(); + while (*adjRoom) + { + ItemObj* item = (*adjRoom++)->firstItem; + + while (item) + { + if ((item->flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_INVISIBLE) + { + if (item->flags & ITEM_FLAG_COLLISION) + { + vec3i d = pos - item->pos; + + if (abs(d.x) < 4096 && abs(d.y) < 4096 && abs(d.z) < 4096) + { + item->collide(this, &cinfo); + } + } + } + item = item->nextItem; + } + } + } + + void updateCollision() + { + #ifndef __NDS__ // TODO + updateObjectsCollision(); + #endif + + (this->*cHandlers[state])(); + + // control hit animation + if (extraL->hitTimer <= 0) + return; + + if (!extraL->hitFrame) { + soundPlay(SND_HIT, &pos); + } + + extraL->hitFrame++; + if (extraL->hitFrame > 34) { + extraL->hitFrame = 34; + } + + extraL->hitTimer--; + if (extraL->hitTimer == 0) + { + extraL->hitQuadrant = -1; + extraL->hitFrame = 0; + } + } + + void startScreaming() + { + soundPlay(SND_SCREAM, &pos); + } + + void stopScreaming() + { + soundStop(SND_SCREAM); + } + + void restore() + { + if (health > 0) + return; + + health = LARA_MAX_HEALTH; + oxygen = LARA_MAX_OXYGEN; + animSet(ROOM_FLAG_WATER(room->info->flags) ? Lara::ANIM_UNDERWATER : Lara::ANIM_STAND, true, 0); + } + +// common + bool alignAngle(int16 &angle, int16 threshold) + { + if (angle >= -threshold && angle <= threshold) { + angle = 0; + } else if (angle >= ANGLE_90 - threshold && angle <= ANGLE_90 + threshold) { + angle = ANGLE_90; + } else if (angle >= -ANGLE_90 - threshold && angle <= -ANGLE_90 + threshold) { + angle = -ANGLE_90; + } else if (angle >= -(ANGLE_180 + 1 + threshold) || angle <= (ANGLE_180 + 1 + threshold)) { + angle = ANGLE_180; + } + + return (angle & (ANGLE_90 - 1)) > 0; + } + + void alignWall(int32 radius) + { + int x = pos.x & ~1023; + int z = pos.z & ~1023; + + switch (angle.y) + { + case ANGLE_0 : pos.z = z + 1024 - radius; break; + case ANGLE_90 : pos.x = x + 1024 - radius; break; + case -ANGLE_90 : pos.x = x + radius; break; + case ANGLE_180 : pos.z = z + radius; break; + default : ASSERT(false); + } + } + + bool s_getFront(int16 rot) + { + rot += angle.y; + + int32 s, c; + sincos(rot, s, c); + + int32 x = pos.x + (s >> (FIXED_SHIFT - 8)); + int32 y = pos.y - LARA_HEIGHT; + int32 z = pos.z + (c >> (FIXED_SHIFT - 8)); + + Room* roomFront = room->getRoom(x, y, z); + const Sector* sector = roomFront->getSector(x, z); + int32 floor = sector->getFloor(x, y, z); + + if (floor != WALL) { + floor -= pos.y; + } + + return floor >= -LARA_STEP_HEIGHT; + } + + bool s_checkDeath(int32 deathState) + { + if (health <= 0) { + goalState = deathState; + return true; + } + return false; + } + +// state control + bool s_checkFront(int16 angleDelta, int32 radius) + { + CollisionInfo tmpInfo = cinfo; + int16 tmpAngle = extraL->moveAngle; + + c_angle(angleDelta); + cinfo.radius = radius; + cinfo.type = CT_NONE; + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.stopOnSlant = true; + cinfo.gapCeiling = 0; + + if ((angleDelta == ANGLE_180) && ((input & IN_WALK) || (waterState == WATER_STATE_WADE))) { + cinfo.gapPos = LARA_STEP_HEIGHT; + cinfo.stopOnLava = true; + } + + collideRoom(LARA_HEIGHT, 0); + + bool collide = (cinfo.type == CT_FRONT) || (cinfo.type == CT_FRONT_CEILING); + + cinfo = tmpInfo; + extraL->moveAngle = tmpAngle; + + return !collide; + } + + void s_ignoreEnemy() + { + cinfo.enemyPush = false; + cinfo.enemyHit = false; + } + + void s_rotate(int32 maxSpeed, int32 tilt) + { + tilt *= LARA_TILT_ACCEL; + + if (input & IN_LEFT) { + turnSpeed = X_MAX(turnSpeed - LARA_TURN_ACCEL, -maxSpeed); + angle.z = X_MAX(angle.z - tilt, -LARA_TILT_MAX); + } else if (input & IN_RIGHT) { + turnSpeed = X_MIN(turnSpeed + LARA_TURN_ACCEL, maxSpeed); + angle.z = X_MIN(angle.z + tilt, LARA_TILT_MAX); + } + } + + bool s_checkFall() + { + if (vSpeed > 131) + { + if (state == STATE_SWAN_DIVE) { + goalState = STATE_FAST_DIVE; + } else { + goalState = STATE_FALL; + } + return true; + } + return false; + } + + void s_checkWalk(int32 stopState) + { + if ((input & IN_UP) && s_checkFront(ANGLE_0, LARA_RADIUS + 4)) { + if (input & IN_WALK) { + goalState = STATE_WALK; + } else { + goalState = STATE_RUN; + } + } else { + goalState = stopState; + } + } + + bool s_checkRoll() + { + if ((waterState != WATER_STATE_ABOVE) && (waterState != WATER_STATE_UNDER)) { + return false; + } + + bool roll = (input & (IN_UP | IN_DOWN)) == (IN_UP | IN_DOWN); + + if ((waterState == WATER_STATE_ABOVE) && roll) + { + if ((state == STATE_RUN) || (state == STATE_STOP)) + { + animSet(ANIM_STAND_ROLL_BEGIN, true, 2); + goalState = STATE_STOP; + return true; + } + } + + return false; + } + + void s_turnUW() + { + if (input & IN_UP) { + angle.x -= ANGLE(2); + } else if (input & IN_DOWN) { + angle.x += ANGLE(2); + } + + if (input & IN_LEFT) { + turnSpeed = X_MAX(turnSpeed - LARA_TURN_ACCEL, -LARA_TURN_MED); + angle.z -= LARA_TILT_ACCEL * 2; + } else if (input & IN_RIGHT) { + turnSpeed = X_MIN(turnSpeed + LARA_TURN_ACCEL, LARA_TURN_MED); + angle.z += LARA_TILT_ACCEL * 2; + } + } + + void s_dive() + { + animSet(ANIM_SURF_DIVE, true); + angle.x = ANGLE(-45); + vSpeed = LARA_DIVE_SPEED; + waterState = WATER_STATE_UNDER; + } + + bool s_checkLook() + { + if (input & IN_LOOK) { + extraL->camera.mode = CAMERA_MODE_LOOK; + return true; + } + + if (extraL->camera.mode == CAMERA_MODE_LOOK) { + extraL->camera.mode = CAMERA_MODE_FOLLOW; + } + + return false; + } + + S_HANDLER( STATE_WALK ) + { + if (s_checkDeath(STATE_STOP)) + return; + + s_rotate(LARA_TURN_SLOW, 0); + + s_checkWalk(STATE_STOP); + } + + S_HANDLER( STATE_RUN ) + { + if (s_checkDeath(STATE_DEATH)) + return; + + if (s_checkRoll()) + return; + + s_rotate(LARA_TURN_FAST, 1); + + if ((input & IN_JUMP) && !(flags & ITEM_FLAG_GRAVITY)) { + goalState = STATE_JUMP; + } else { + s_checkWalk(STATE_STOP); + } + } + + S_HANDLER( STATE_STOP ) + { + if (s_checkDeath(STATE_DEATH)) + return; + + if (s_checkRoll()) + return; + + goalState = STATE_STOP; + + if (s_checkLook()) + return; + + if (input & IN_WALK) { + if ((input & IN_LEFT) && s_checkFront(-ANGLE_90, LARA_RADIUS + 16)) { + goalState = STATE_STEP_LEFT; + } else if ((input & IN_RIGHT) && s_checkFront(ANGLE_90, LARA_RADIUS + 16)) { + goalState = STATE_STEP_RIGHT; + } + } else { + if (input & IN_LEFT) { + goalState = STATE_TURN_LEFT; + } else if (input & IN_RIGHT) { + goalState = STATE_TURN_RIGHT; + } + } + + if (input & IN_JUMP) { + goalState = STATE_COMPRESS; + } else if ((input & IN_UP) && s_checkFront(ANGLE_0, LARA_RADIUS + 4)) { + if (input & IN_WALK) { + s_STATE_WALK(); + } else { + s_STATE_RUN(); + } + } else if ((input & IN_DOWN) && s_checkFront(ANGLE_180, LARA_RADIUS + 4)) { + if (input & IN_WALK) { + s_STATE_BACK(); + } else { + goalState = STATE_BACK_FAST; + } + } + } + + + S_HANDLER( STATE_JUMP ) + { + if (goalState == STATE_SWAN_DIVE || + goalState == STATE_REACH) + { + goalState = STATE_JUMP; + } + + if (goalState != STATE_DEATH && + goalState != STATE_STOP && + goalState != STATE_RUN) + { + if (extraL->weaponState == WEAPON_STATE_FREE) + { + if (input & IN_ACTION) + { + goalState = STATE_REACH; + } + + if (input & IN_WALK) + { + goalState = STATE_SWAN_DIVE; + } + } + + s_checkRoll(); + s_checkFall(); + } + + s_rotate(LARA_TURN_JUMP, 0); + } + + S_HANDLER( STATE_POSE ) + { + // empty + } + + S_HANDLER( STATE_BACK_FAST ) + { + s_rotate(LARA_TURN_MED, 0); + goalState = STATE_STOP; + } + + S_HANDLER( STATE_TURN_RIGHT ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if (input & IN_LOOK) + { + goalState = STATE_STOP; + return; + } + + turnSpeed += LARA_TURN_ACCEL; + + if ((turnSpeed > LARA_TURN_SLOW || extraL->weaponState == WEAPON_STATE_READY) && (waterState != WATER_STATE_WADE) && !(input & IN_WALK)) + { + goalState = STATE_TURN_FAST; + } + + if (goalState == state) { + turnSpeed = X_MIN(turnSpeed, LARA_TURN_SLOW); + } + + s_checkWalk((input & IN_RIGHT) ? goalState : STATE_STOP); + } + + S_HANDLER( STATE_TURN_LEFT ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if (input & IN_LOOK) + { + goalState = STATE_STOP; + return; + } + + turnSpeed -= LARA_TURN_ACCEL; + + if ((turnSpeed < -LARA_TURN_SLOW || extraL->weaponState == WEAPON_STATE_READY) && (waterState != WATER_STATE_WADE) && !(input & IN_WALK)) + { + goalState = STATE_TURN_FAST; + } + + if (goalState == state) { + turnSpeed = X_MAX(turnSpeed, -LARA_TURN_SLOW); + } + + s_checkWalk((input & IN_LEFT) ? goalState : STATE_STOP); + } + + S_HANDLER( STATE_DEATH ) + { + s_ignoreEnemy(); + } + + S_HANDLER( STATE_FALL ) + { + hSpeed = (hSpeed * 95) / 100; + + if (vSpeed >= 154) { + startScreaming(); + } + } + + S_HANDLER( STATE_HANG ) + { + extraL->camera.targetAngle.x = ANGLE(-60); + + s_ignoreEnemy(); + if (input & IN_LEFT) { + goalState = STATE_HANG_LEFT; + } else if (input & IN_RIGHT) { + goalState = STATE_HANG_RIGHT; + } + } + + S_HANDLER( STATE_REACH ) + { + extraL->camera.targetAngle.y = ANGLE(85); + + s_checkFall(); + } + + S_HANDLER( STATE_SPLAT ) + { + // empty + } + + S_HANDLER( STATE_UW_TREAD ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + if (s_checkRoll()) + return; + + s_turnUW(); + + if (input & IN_JUMP) { + goalState = STATE_UW_SWIM; + } + + vSpeed = X_MAX(vSpeed - LARA_SWIM_FRICTION, 0); + } + + S_HANDLER( STATE_LAND ) + { + // empty + } + + S_HANDLER( STATE_COMPRESS ) + { + if ((input & IN_UP) && s_getFront(ANGLE_0)) { + goalState = STATE_JUMP; + } else if ((input & IN_LEFT) && s_getFront(-ANGLE_90)) { + goalState = STATE_JUMP_LEFT; + } else if ((input & IN_RIGHT) && s_getFront(ANGLE_90)) { + goalState = STATE_JUMP_RIGHT; + } else if ((input & IN_DOWN) && s_getFront(ANGLE_180)) { + goalState = STATE_JUMP_BACK; + } + s_checkFall(); + } + + S_HANDLER( STATE_BACK ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if ((input & (IN_WALK | IN_DOWN)) != (IN_WALK | IN_DOWN)) { + goalState = STATE_STOP; + } else { + goalState = STATE_BACK; + } + + s_rotate(LARA_TURN_SLOW, 0); + } + + S_HANDLER( STATE_UW_SWIM ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + if (s_checkRoll()) + return; + + s_turnUW(); + + vSpeed = X_MIN(vSpeed + LARA_SWIM_ACCEL, LARA_SWIM_SPEED_MAX); + + if (!(input & IN_JUMP)) { + goalState = STATE_UW_GLIDE; + } + } + + S_HANDLER( STATE_UW_GLIDE ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + if (s_checkRoll()) + return; + + s_turnUW(); + + if (input & IN_JUMP) { + goalState = STATE_UW_SWIM; + } + + vSpeed = X_MAX(vSpeed - LARA_SWIM_FRICTION, 0); + + if (vSpeed <= LARA_SWIM_SPEED_MIN) { + goalState = STATE_UW_TREAD; + } + } + + S_HANDLER( STATE_HANG_UP ) + { + s_ignoreEnemy(); + } + + S_HANDLER( STATE_TURN_FAST ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if (input & IN_LOOK) + { + goalState = STATE_STOP; + return; + } + + if (turnSpeed < 0) { + turnSpeed = -LARA_TURN_FAST; + if (!(input & IN_LEFT)) { + goalState = STATE_STOP; + } + } else { + turnSpeed = LARA_TURN_FAST; + if (!(input & IN_RIGHT)) { + goalState = STATE_STOP; + } + } + } + + S_HANDLER( STATE_STEP_RIGHT ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if ((input & (IN_WALK | IN_RIGHT)) != (IN_WALK | IN_RIGHT)) + { + goalState = STATE_STOP; + } + } + + S_HANDLER( STATE_STEP_LEFT ) + { + if (s_checkDeath(STATE_STOP)) + return; + + if ((input & (IN_WALK | IN_LEFT)) != (IN_WALK | IN_LEFT)) + { + goalState = STATE_STOP; + } + } + + S_HANDLER( STATE_ROLL_END ) + { + // empty + } + + S_HANDLER( STATE_SLIDE ) + { + extraL->camera.targetAngle.x = ANGLE(-45); + + if (input & IN_JUMP) { + goalState = STATE_JUMP; + } + } + + S_HANDLER( STATE_JUMP_BACK ) + { + extraL->camera.targetAngle.y = ANGLE(135); + + if (s_checkFall()) + return; + + if (goalState == STATE_RUN) { + goalState = STATE_STOP; + } + } + + S_HANDLER( STATE_JUMP_RIGHT ) + { + s_checkFall(); + } + + S_HANDLER( STATE_JUMP_LEFT ) + { + s_checkFall(); + } + + S_HANDLER( STATE_JUMP_UP ) + { + s_checkFall(); + } + + S_HANDLER( STATE_FALL_BACK ) + { + s_checkFall(); + + if ((input & IN_ACTION) && (extraL->weaponState == WEAPON_STATE_FREE)) { + goalState = STATE_REACH; + } + } + + S_HANDLER( STATE_HANG_LEFT ) + { + extraL->camera.targetAngle.x = ANGLE(-60); + + s_ignoreEnemy(); + + if (!(input & IN_LEFT)) { + goalState = STATE_HANG; + } + } + + S_HANDLER( STATE_HANG_RIGHT ) + { + extraL->camera.targetAngle.x = ANGLE(-60); + + s_ignoreEnemy(); + + if (!(input & IN_RIGHT)) { + goalState = STATE_HANG; + } + } + + S_HANDLER( STATE_SLIDE_BACK ) + { + if (input & IN_JUMP) { + goalState = STATE_JUMP_BACK; + } + } + + S_HANDLER( STATE_SURF_TREAD ) + { + vSpeed = X_MAX(vSpeed - LARA_SURF_FRICTION, 0); + + if (s_checkDeath(STATE_DEATH_UW)) + return; + + if (s_checkLook()) + return; + + if (input & IN_LEFT) { + angle.y -= LARA_TURN_SLOW; + } else if (input & IN_RIGHT) { + angle.y += LARA_TURN_SLOW; + } + + if (input & IN_UP) { + goalState = STATE_SURF_SWIM; + } else if (input & IN_DOWN) { + goalState = STATE_SURF_BACK; + } else if ((input & (IN_WALK | IN_LEFT)) == (IN_WALK | IN_LEFT)) { + goalState = STATE_SURF_LEFT; + } else if ((input & (IN_WALK | IN_RIGHT)) == (IN_WALK | IN_RIGHT)) { + goalState = STATE_SURF_RIGHT; + } + + if (input & IN_JUMP) { + extraL->swimTimer++; + if (extraL->swimTimer == LARA_SWIM_TIMER) { + s_dive(); + } + } else { + extraL->swimTimer = 0; + } + } + + S_HANDLER( STATE_SURF_SWIM ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + extraL->swimTimer = 0; + + if (input & IN_LEFT) { + angle.y -= LARA_TURN_SLOW; + } else if (input & IN_RIGHT) { + angle.y += LARA_TURN_SLOW; + } + + if (!(input & IN_UP) || (input & IN_JUMP)) { + goalState = STATE_SURF_TREAD; + } + + vSpeed = X_MIN(vSpeed + LARA_SURF_ACCEL, LARA_SURF_SPEED_MAX); + } + + S_HANDLER( STATE_UW_DIVE ) + { + if (input & IN_UP) { + angle.x -= ANGLE_1; + } + } + + S_HANDLER( STATE_BLOCK_PUSH ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(35); + extraL->camera.center = true; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_BLOCK_PULL ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(35); + extraL->camera.center = true; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_BLOCK_READY ) + { + extraL->camera.targetAngle.y = ANGLE(75); + + s_ignoreEnemy(); + + if (!(input & IN_ACTION)) { + goalState = STATE_STOP; + } + } + + S_HANDLER( STATE_PICKUP ) + { + extraL->camera.targetAngle.x = ANGLE(-15); + extraL->camera.targetAngle.y = ANGLE(-130); + extraL->camera.targetDist = 1024; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_SWITCH_DOWN ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(80); + extraL->camera.targetDist = 1024; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_SWITCH_UP ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(80); + extraL->camera.targetDist = 1024; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_USE_KEY ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(-80); + extraL->camera.targetDist = 1024; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_USE_PUZZLE ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(-80); + extraL->camera.targetDist = 1024; + + s_ignoreEnemy(); + } + + S_HANDLER( STATE_DEATH_UW ) + { + vSpeed = X_MAX(vSpeed - LARA_SWIM_ACCEL, 0); + angle.x = angleDec(angle.x, ANGLE(2)); + } + + S_HANDLER( STATE_ROLL_START ) + { + // empty + } + + S_HANDLER( STATE_SPECIAL ) + { + extraL->camera.targetAngle.x = ANGLE(-25); + extraL->camera.targetAngle.y = ANGLE(170); + extraL->camera.center = true; + } + + S_HANDLER( STATE_SURF_BACK ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + extraL->swimTimer = 0; + + if (input & IN_LEFT) { + angle.y -= LARA_TURN_VERY_SLOW; + } else if (input & IN_RIGHT) { + angle.y += LARA_TURN_VERY_SLOW; + } + + if (!(input & IN_DOWN)) { + goalState = STATE_SURF_TREAD; + } + + vSpeed = X_MIN(vSpeed + LARA_SURF_ACCEL, LARA_SURF_SPEED_MAX); + } + + S_HANDLER( STATE_SURF_LEFT ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + extraL->swimTimer = 0; + + if ((input & (IN_WALK | IN_LEFT)) != (IN_WALK | IN_LEFT)) { + goalState = STATE_SURF_TREAD; + } + + vSpeed = X_MIN(vSpeed + LARA_SURF_ACCEL, LARA_SURF_SPEED_MAX); + } + + S_HANDLER( STATE_SURF_RIGHT ) + { + if (s_checkDeath(STATE_DEATH_UW)) + return; + + extraL->swimTimer = 0; + + if ((input & (IN_WALK | IN_RIGHT)) != (IN_WALK | IN_RIGHT)) { + goalState = STATE_SURF_TREAD; + } + + vSpeed = X_MIN(vSpeed + LARA_SURF_ACCEL, LARA_SURF_SPEED_MAX); + } + + S_HANDLER( STATE_USE_MIDAS ) + { + s_ignoreEnemy(); + } + + S_HANDLER( STATE_DEATH_MIDAS ) + { + s_ignoreEnemy(); + flags &= ~ITEM_FLAG_GRAVITY; + } + + S_HANDLER( STATE_SWAN_DIVE ) + { + cinfo.enemyPush = true; + cinfo.enemyHit = false; + + s_checkFall(); + } + + S_HANDLER( STATE_FAST_DIVE ) + { + cinfo.enemyPush = true; + cinfo.enemyHit = false; + hSpeed = (hSpeed * 95) / 100; + + s_checkRoll(); + } + + S_HANDLER( STATE_HANDSTAND ) + { + s_ignoreEnemy(); + } + + S_HANDLER( STATE_WATER_OUT ) + { + s_ignoreEnemy(); + extraL->camera.center = true; + } + + S_HANDLER( STATE_CLIMB_START ) {} + S_HANDLER( STATE_CLIMB_UP ) {} + S_HANDLER( STATE_CLIMB_LEFT ) {} + S_HANDLER( STATE_CLIMB_END ) {} + S_HANDLER( STATE_CLIMB_RIGHT ) {} + S_HANDLER( STATE_CLIMB_DOWN ) {} + S_HANDLER( STATE_UNUSED_1 ) {} + S_HANDLER( STATE_UNUSED_2 ) {} + S_HANDLER( STATE_UNUSED_3 ) {} + S_HANDLER( STATE_WADE ) {} + S_HANDLER( STATE_ROLL_UW ) {} + S_HANDLER( STATE_PICKUP_FLARE ) {} + S_HANDLER( STATE_ROLL_AIR ) {} + S_HANDLER( STATE_UNUSED_4 ) {} + S_HANDLER( STATE_ZIPLINE ) {} + + +// collision control + void c_applyOffset() + { + pos += cinfo.offset; + cinfo.offset = _vec3i(0, 0, 0); + } + + void c_angle(int16 angleDelta) + { + angleDelta += angle.y; + + extraL->moveAngle = angleDelta; + cinfo.setAngle(angleDelta); + } + + bool c_checkCeiling() + { + if (cinfo.type != CT_CEILING && cinfo.type != CT_FLOOR_CEILING) { + return false; + } + + animSet(ANIM_STAND, true); + goalState = state; + hSpeed = 0; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + pos = cinfo.pos; + + return true; + } + + bool c_checkWall() + { + if (cinfo.type == CT_FRONT || cinfo.type == CT_FRONT_CEILING) + { + c_applyOffset(); + goalState = STATE_STOP; + hSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + return true; + } + + if (cinfo.type == CT_LEFT) { + c_applyOffset(); + angle.y += ANGLE(5); + angle.z = angleDec(angle.z, ANGLE(2)); + } else if (cinfo.type == CT_RIGHT) { + c_applyOffset(); + angle.y -= ANGLE(5); + angle.z = angleDec(angle.z, ANGLE(2)); + } + + return false; + } + + bool c_checkWallUW() + { + if (cinfo.type == CT_FRONT) { + if (angle.x > ANGLE(35)) { + angle.x += ANGLE(2); + } else if (angle.x < ANGLE(-35)) { + angle.x -= ANGLE(2); + } else { + vSpeed = 0; + } + } else if (cinfo.type == CT_CEILING) { + if (angle.x >= ANGLE(-45)) { + angle.x -= ANGLE(2); + } + } else if (cinfo.type == CT_FRONT_CEILING) { + vSpeed = 0; + } else if (cinfo.type == CT_LEFT) { + angle.y += ANGLE(5); + } else if (cinfo.type == CT_RIGHT) { + angle.y -= ANGLE(5); + } else if (cinfo.type == CT_FLOOR_CEILING) { + pos = cinfo.pos; + vSpeed = 0; + return true; + } + + if (cinfo.m.floor < 0) { + pos.y += cinfo.m.floor; + angle.x += ANGLE(2); + } + + int32 waterDepth = getWaterDepth(); + + if (waterDepth == WALL) { + vSpeed = 0; + pos = cinfo.pos; + } else if (waterDepth <= 512) { + waterState = WATER_STATE_WADE; + + animSet(ANIM_SWIM_STAND, true); + goalState = STATE_STOP; + + angle.x = 0; + angle.z = 0; + hSpeed = 0; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + } + + return false; + } + + bool c_checkWallSurf() + { + if ((cinfo.m.floor < 0 && cinfo.m.slantType == SLANT_HIGH) || (cinfo.type & (CT_FRONT | CT_CEILING | CT_FRONT_CEILING | CT_FLOOR_CEILING))) { + pos = cinfo.pos; + vSpeed = 0; + } else if (cinfo.type == CT_LEFT) { + angle.y += ANGLE(5); + } else if (cinfo.type == CT_RIGHT) { + angle.y -= ANGLE(5); + } + + return true; + } + + bool c_checkSlide() + { + if (waterState == WATER_STATE_WADE) + return false; + + if (cinfo.m.slantType != SLANT_HIGH) + return false; + + c_applyOffset(); + + int16 realAngle; + + if (cinfo.slantX > 2) { + realAngle = -ANGLE_90; + } else if (cinfo.slantX < -2) { + realAngle = ANGLE_90; + } else if (cinfo.slantZ > 2) { + realAngle = ANGLE_180; + } else { + realAngle = 0; + } + + if (abs(realAngle - angle.y) <= ANGLE_90) { + if (state != STATE_SLIDE) { + animSet(ANIM_SLIDE_FORTH, true); + } + extraL->moveAngle = realAngle; + angle.y = realAngle; + } else { + if (state != STATE_SLIDE_BACK) { + animSet(ANIM_SLIDE_BACK, true); + } + extraL->moveAngle = realAngle; + angle.y = realAngle + ANGLE_180; + } + + return true; + } + + bool c_checkFall(int32 height, int32 fallAnimIndex = ANIM_FALL_FORTH) + { + if (waterState == WATER_STATE_WADE) + return false; + + if (cinfo.m.floor <= height) + return false; + + animSet(fallAnimIndex, true); + + vSpeed = 0; + flags |= ITEM_FLAG_GRAVITY; + + return true; + } + + bool c_checkLanding() + { + if ((state == STATE_FAST_DIVE || state == STATE_ROLL_AIR) && vSpeed > 133) + { + hit(LARA_MAX_HEALTH, pos, 0); + return true; + } + + int32 y = pos.y; + pos.y += cinfo.m.floor; + roomFloor = pos.y; + + checkTrigger(cinfo.trigger, this); + + pos.y = y; + + if (vSpeed <= 140) + return false; + + if (vSpeed > 154) { + hit(LARA_MAX_HEALTH, pos, 0); + } else { + hit((X_SQR(vSpeed - 140) * LARA_MAX_HEALTH) / 196, pos, 0); + } + + return health <= 0; + } + + bool c_checkSwing() + { + int32 x = pos.x; + int32 y = pos.y; + int32 z = pos.z; + + switch (angle.y) { + case ANGLE_0 : z += 256; break; + case ANGLE_90 : x += 256; break; + case -ANGLE_90 : x -= 256; break; + case ANGLE_180 : z -= 256; break; + } + + Room* roomBelow = room->getRoom(x, y, z); + const Sector* sector = roomBelow->getSector(x, z); + int32 floor = sector->getFloor(x, y, z); + + if (floor != WALL) + { + int32 ceiling = sector->getCeiling(x, y, z); + + floor -= y; + ceiling -= y; + + if (floor > 0 && ceiling < -400) + return true; + } + + return false; + } + + bool c_checkGrab() + { + return (extraL->weaponState != WEAPON_STATE_FREE) || !(input & IN_ACTION) || (cinfo.type != CT_FRONT) || (abs(cinfo.r.floor - cinfo.l.floor) >= LARA_HANG_SLANT); + } + + bool c_checkSpace() + { + return (cinfo.f.floor < cinfo.f.ceiling || + cinfo.l.floor < cinfo.l.ceiling || + cinfo.r.floor < cinfo.r.ceiling); + } + + bool c_checkClimbStart() + { + return false; + } + + bool c_checkClimbUp() + { + if (cinfo.f.floor == WALL) + return false; + + if (c_checkGrab()) + return false; + + int16 realAngle = angle.y; + if (alignAngle(realAngle, ANGLE(30))) + return false; + + if (cinfo.f.floor >= -640 && cinfo.f.floor <= -384) { + if (c_checkSpace()) + return false; + + setWeaponState(WEAPON_STATE_BUSY); + animSet(ANIM_CLIMB_2, true); + state = STATE_HANG_UP; + + pos.y += 512 + cinfo.f.floor; + } else if (cinfo.f.floor >= -896 && cinfo.f.floor <= -640) { + if (c_checkSpace()) + return false; + + setWeaponState(WEAPON_STATE_BUSY); + animSet(ANIM_CLIMB_3, true); + state = STATE_HANG_UP; + + pos.y += 768 + cinfo.f.floor; + } else if (cinfo.f.floor >= -1920 && cinfo.f.floor <= -896) { + animSet(ANIM_STAND, true); + goalState = STATE_JUMP_UP; + extraL->vSpeedHack = int32(phd_sqrt(-2 * GRAVITY * (cinfo.f.floor + 800)) + 3); + animProcess(); + /*} TODO climb + else if ((waterState != WATER_STATE_WADE) && (cinfo.f.floor <= -1920) && (cinfo.l.floor <= -1920) && (cinfo.r.floor <= -1920) && (cinfo.m.ceiling <= -1158)) { + animSet(ANIM_STAND, true); + goalState = STATE_JUMP_UP; + vSpeedHack = 116; + animProcess(); + } else if (((cinfo.f.floor < -1024) && (cinfo.f.ceiling >= 506)) || ((cinfo.m.ceiling <= -518) && c_checkClimbStart())) { + animSet(ANIM_STAND, true); + goalState = STATE_CLIMB_START; + animProcess();*/ + } else { + return false; + } + + angle.y = realAngle; + c_applyOffset(); + + return true; + } + + bool c_checkHang() + { + if (c_checkGrab()) + return false; + + if ((cinfo.f.ceiling > 0) || + (cinfo.m.ceiling > -LARA_STEP_HEIGHT) || + (cinfo.m.floor < 200 && state == STATE_REACH)) + { + return false; + } + + int32 h = cinfo.f.floor - getBoundingBox(true).minY; + int32 v = h + vSpeed; + + if ((h < 0 && v < 0) || (h > 0 && v > 0)) + return false; + + if (alignAngle(angle.y, ANGLE(35))) + return false; + + if (state == STATE_REACH) + { + if (c_checkSwing()) { + animSet(ANIM_HANG_SWING, true); + } else { + animSet(ANIM_HANG, true); + } + } else { + animSet(ANIM_HANG, true, 12); + } + + setWeaponState(WEAPON_STATE_BUSY); + cinfo.offset.y = cinfo.f.floor - getBoundingBox(true).minY; + + c_applyOffset(); + + flags &= ~ITEM_FLAG_GRAVITY; + hSpeed = 0; + vSpeed = 0; + + return true; + } + + bool c_checkDrop() + { + // TODO getTrigger here + + if ((health > 0) && (input & IN_ACTION)) + { + flags &= ~ITEM_FLAG_GRAVITY; + vSpeed = 0; + return false; + } + + flags |= ITEM_FLAG_GRAVITY; + hSpeed = 2; + vSpeed = 1; + + animSet(ANIM_FALL_FORTH, true); + + return true; + } + + bool c_checkWaterOut() + { + if (!(input & IN_ACTION) || + (cinfo.type != CT_FRONT) || + (cinfo.f.ceiling > 0) || + (cinfo.m.ceiling > -LARA_STEP_HEIGHT) || + (abs(cinfo.r.floor - cinfo.l.floor) >= LARA_HANG_SLANT)) + { + return false; + } + + int32 h = cinfo.f.floor + LARA_HEIGHT_SURF; + + if (h <= -512 || h > 316) + return false; + + if (alignAngle(angle.y, ANGLE(35))) + return false; + + pos.y += h - 5; + + updateRoom(-LARA_HEIGHT / 2); + + alignWall(-LARA_RADIUS); + + if ((h < -128)) { // TODO || (level->version & TR::VER_TR1)) { + animSet(ANIM_WATER_OUT, true); + // specular = LARA_WET_SPECULAR; + } else if (h < 128) { + animSet(ANIM_SURF_OUT, true); + } else { + animSet(ANIM_SURF_STAND, true); + } + + //game->waterDrop(pos, 128.0f, 0.2f); + + animSet(ANIM_WATER_OUT, true); + setWeaponState(WEAPON_STATE_BUSY); + + waterState = WATER_STATE_ABOVE; + goalState = STATE_STOP; + angle.x = 0; + angle.z = 0; + hSpeed = 0; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + return true; + } + + void c_default() + { + cinfo.gapPos = LARA_STEP_HEIGHT; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + } + + void c_step() + { + cinfo.gapPos = (waterState == WATER_STATE_WADE) ? -WALL : 128; + cinfo.gapNeg = -128; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + if (c_checkWall()) { + animSet(ANIM_STAND, true); + } + + if (c_checkSlide()) + return; + + pos.y += cinfo.m.floor; + } + + void c_fall() + { + if (vSpeed <= 0 || cinfo.m.floor > 0) + return; + + if (c_checkLanding()) { + goalState = STATE_DEATH; + } else if (state == STATE_JUMP && (input & IN_UP) && !(input & IN_WALK)) { + goalState = STATE_RUN; + } else if (state == STATE_FALL) { + animSet(ANIM_LANDING, true); + } else { + goalState = STATE_STOP; + } + + stopScreaming(); + + pos.y += cinfo.m.floor; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + if (state == STATE_JUMP) { + animProcess(); + } + } + + void c_jump() + { + cinfo.gapPos = -WALL; + cinfo.gapNeg = (state == STATE_REACH) ? 0 : -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 192; + + collideRoom(state == STATE_JUMP_UP ? LARA_HEIGHT_JUMP : LARA_HEIGHT, 0); + + if ((state == STATE_REACH || state == STATE_JUMP_UP) && c_checkHang()) + return; + + c_applyOffset(); + + // TODO long up jump + // TODO can't side jump near walls + bool slide = (state == STATE_FALL) || (state == STATE_REACH) || (state == STATE_JUMP_UP); + + if ((cinfo.type == CT_CEILING) || (slide && (cinfo.type == CT_FRONT_CEILING))) { + if (vSpeed <= 0) { + vSpeed = 1; + } + } else if (!slide && ((cinfo.type == CT_FRONT) || (cinfo.type == CT_FRONT_CEILING))) { + osJoyVibrate(0, 0xFF, 0xFF); + animSet(ANIM_SMASH_JUMP, true, 1); + extraL->moveAngle += ANGLE_180; + hSpeed >>= 2; + if (vSpeed <= 0) { + vSpeed = 1; + } + } else if (cinfo.type == CT_FLOOR_CEILING) { + int32 s, c; + sincos(cinfo.angle, s, c); + pos.x -= (s * LARA_RADIUS) >> FIXED_SHIFT; + pos.z -= (c * LARA_RADIUS) >> FIXED_SHIFT; + cinfo.m.floor = 0; + hSpeed = 0; + if (vSpeed <= 0) { + vSpeed = 16; + } + } else if (cinfo.type == CT_LEFT) { + angle.y += ANGLE(5); + } else if (cinfo.type == CT_RIGHT) { + angle.y -= ANGLE(5); + } + + c_fall(); + } + + void c_slide() + { + cinfo.gapPos = -WALL; + cinfo.gapNeg = -512; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + c_checkWall(); + + if (c_checkFall(200, state == STATE_SLIDE ? ANIM_FALL_FORTH : ANIM_FALL_BACK)) + return; + + c_checkSlide(); + + pos.y += cinfo.m.floor; + + if (cinfo.m.slantType != SLANT_HIGH) { + goalState = STATE_STOP; + } + } + + void c_roll() + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + if (c_checkSlide()) + return; + + if (c_checkFall(200, state == STATE_ROLL_START ? ANIM_FALL_FORTH : ANIM_FALL_BACK)) + return; + + c_applyOffset(); + + pos.y += cinfo.m.floor; + } + + void c_hang(int32 angleDelta) + { + c_angle(angleDelta); + cinfo.gapPos = -WALL; + cinfo.gapNeg = WALL; + cinfo.gapCeiling = 0; + collideRoom(LARA_HEIGHT, 0); + + bool noFloor = cinfo.f.floor < 200; + + c_angle(ANGLE_0); + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + + switch (cinfo.quadrant) + { + case 0 : pos.z += 2; break; + case 1 : pos.x += 2; break; + case 2 : pos.z -= 2; break; + case 3 : pos.x -= 2; break; + } + + collideRoom(LARA_HEIGHT, 0); + + extraL->moveAngle = angle.y + angleDelta; + + if (health <= 0 || !(input & IN_ACTION)) + { + animSet(ANIM_FALL_HANG, true, 9); + + cinfo.offset.y = cinfo.f.floor - getBoundingBox(true).minY + 2; + c_applyOffset(); + + hSpeed = 2; + vSpeed = 1; + flags |= ITEM_FLAG_GRAVITY; + setWeaponState(WEAPON_STATE_FREE); + return; + } + + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + if (noFloor || (cinfo.type != CT_FRONT) || (cinfo.m.ceiling >= 0) || abs(cinfo.r.floor - cinfo.l.floor) >= LARA_HANG_SLANT) + { + if (state != STATE_HANG) { + animSet(ANIM_HANG, true, 21); + } + pos = cinfo.pos; + return; + } + + if (cinfo.quadrant & 1) { + pos.x += cinfo.offset.x; + } else { + pos.z += cinfo.offset.z; + } + + int32 h = cinfo.f.floor - getBoundingBox(true).minY; + if (abs(h) <= 256) { + pos.y += h; + } + } + + enum ClimbState { + CLIMB_HANG, + CLIMB_COLLIDE, + CLIMB_OK + }; + + ClimbState c_climbCollide(int32 width) + { + /* TODO + int32 dx = 0, dz = 0; + + int32 x = pos.x; + int32 y = pos.y - 512; + int32 z = pos.z; + + switch (cinfo.quadrant) { + case 0 : + x += width; + z += cinfo.radius; + dz = 4; + break; + case 1 : + x += cinfo.radius; + z -= width; + dx = 4; + break; + case 2 : + x -= width; + z -= cinfo.radius; + dz = -4; + break; + case 3 : + x -= cinfo.radius; + z += width; + dx = -4; + break; + } + + // TODO + cinfo.offset.y = 0; + */ + return CLIMB_OK; + } + + void c_climbSide(int32 width) + { + if (c_checkDrop()) + return; + + switch (c_climbCollide(width)) + { + case CLIMB_HANG: + { + pos.x = cinfo.pos.x; + pos.z = cinfo.pos.z; + goalState = STATE_HANG; + break; + } + + case CLIMB_COLLIDE: + { + pos.x = cinfo.pos.x; + pos.z = cinfo.pos.z; + animSet(ANIM_CLIMB_START, true); + break; + } + + case CLIMB_OK: + { + if (input & IN_LEFT) { + goalState = STATE_CLIMB_LEFT; + } else if (input & IN_RIGHT) { + goalState = STATE_CLIMB_RIGHT; + } else { + goalState = STATE_CLIMB_START; + } + pos.y += cinfo.offset.y; + break; + } + } + } + + void c_swim() + { + c_angle(ANGLE_0); + + collideRoom(LARA_HEIGHT_UW, LARA_HEIGHT_UW / 2); + + c_applyOffset(); + + if (c_checkWallUW()) + return; + } + + void c_surf() + { + collideRoom(LARA_HEIGHT_SURF + 100, LARA_HEIGHT_SURF); + + c_applyOffset(); + + c_checkWallSurf(); + + if (state == STATE_SURF_TREAD) { + if (frameIndex == 0) { + //game->waterDrop(getJoint(jointHead).pos, 96.0f, 0.03f); + } + } else { + if (frameIndex % 4 == 0) { + //game->waterDrop(getJoint(jointHead).pos, 96.0f, 0.02f); + } + } + + int32 waterLevel = getWaterLevel(); + if (waterLevel - pos.y <= -100) { + s_dive(); + return; + } + + /* TODO + if (level->version & TR::VER_TR1) { + return; + } + + if ((cinfo.type == CT_FRONT) || (cinfo.m.slantType == TR::SLANT_HIGH) || (cinfo.m.floor >= 0)) { + return; + } + + if (cinfo.m.floor >= -128) { + if (targetState == STATE_SURF_LEFT) { + targetState = STATE_STEP_LEFT; + } else if (targetState == STATE_SURF_RIGHT) { + targetState = STATE_STEP_RIGHT; + } else { + setAnimV2(ANIM_WADE, true); + } + } else { + setAnimV2(ANIM_WADE_ASCEND, true); + targetState = STATE_STOP; + } + + v2pos.y += cinfo.f.floor + LARA_HEIGHT - 5; + updateRoomV2(-LARA_HEIGHT / 2); + + gravity = false; + v2rot.x = 0; + v2rot.z = 0; + hSpeed = 0; + vSpeed = 0; + waterState = WATER_STATE_WADE; + */ + } + + C_HANDLER( STATE_WALK ) + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + cinfo.stopOnLava = true; + + c_angle(ANGLE_0); + c_default(); + + if (c_checkCeiling()) + return; + + if (c_checkClimbUp()) + return; + + if (c_checkWall()) + { + if (frameIndex >= 29 && frameIndex <= 47) { + animSet(ANIM_STAND_RIGHT, false); + } else if ((frameIndex >= 22 && frameIndex <= 28) || (frameIndex >= 48 && frameIndex <= 57)) { + animSet(ANIM_STAND_LEFT, false); + } else { + animSet(ANIM_STAND, false); + } + } + + if (c_checkFall(LARA_STEP_HEIGHT)) + return; + + // descend + if (cinfo.m.floor > 128) + { + if (frameIndex >= 28 && frameIndex <= 45) { + animSet(ANIM_WALK_DESCEND_RIGHT, false); + } else { + animSet(ANIM_WALK_DESCEND_LEFT, false); + } + } + + // ascend + if (cinfo.m.floor >= -LARA_STEP_HEIGHT && cinfo.m.floor < -128) + { + if (frameIndex >= 27 && frameIndex <= 44) { + animSet(ANIM_WALK_ASCEND_RIGHT, false); + } else { + animSet(ANIM_WALK_ASCEND_LEFT, false); + } + } + + if (c_checkSlide()) + return; + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_RUN ) + { + c_angle(ANGLE_0); + + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + if (c_checkClimbUp()) + return; + + if (c_checkWall()) { + angle.z = 0; + + if (cinfo.f.slantType == SLANT_NONE && cinfo.f.floor < -LARA_SMASH_HEIGHT && frameIndex < 22) + { + animSet(frameIndex < 10 ? ANIM_SMASH_RUN_LEFT : ANIM_SMASH_RUN_RIGHT, false); + state = STATE_SPLAT; + return; + } + + animSet(ANIM_STAND, true); + } + + if (c_checkFall(LARA_STEP_HEIGHT)) + return; + + // ascend + if (cinfo.m.floor >= -LARA_STEP_HEIGHT && cinfo.m.floor < -128) + { + if (frameIndex >= 3 && frameIndex <= 14) { + animSet(ANIM_RUN_ASCEND_RIGHT, false); + } else { + animSet(ANIM_RUN_ASCEND_LEFT, false); + } + } + + if (c_checkSlide()) + return; + + if (cinfo.m.floor >= 50) + { + pos.y += 50; + return; + } + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_STOP ) + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + c_angle(ANGLE_0); + + if (input == (IN_UP | IN_ACTION)) // to check front climb up from STOP state + { + int32 s, c; + sincos(cinfo.angle, s, c); + pos.x += (s * 4) >> FIXED_SHIFT; + pos.z += (c * 4) >> FIXED_SHIFT; + } + + c_default(); + + if (c_checkClimbUp()) + return; + + if (c_checkFall(100)) + return; + + if (c_checkSlide()) + return; + + c_applyOffset(); + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_JUMP ) + { + c_angle(ANGLE_0); + c_jump(); + } + + C_HANDLER( STATE_POSE ) + { + c_STATE_STOP(); + } + + C_HANDLER( STATE_BACK_FAST ) + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + c_angle(ANGLE_180); + + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + if (c_checkFall(200, ANIM_FALL_BACK)) + return; + + if (c_checkWall()) { + animSet(ANIM_STAND, false); + } + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_TURN_RIGHT ) + { + c_angle(ANGLE_0); + c_default(); + + if (c_checkFall(100)) + return; + + if (c_checkSlide()) + return; + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_TURN_LEFT ) + { + c_STATE_TURN_RIGHT(); + } + + C_HANDLER( STATE_DEATH ) + { + cinfo.radius = LARA_RADIUS * 4; + + c_angle(ANGLE_0); + c_default(); + + c_applyOffset(); + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_FALL ) + { + flags |= ITEM_FLAG_GRAVITY; + c_jump(); + } + + C_HANDLER( STATE_HANG ) + { + c_hang(0); + + if ((input & IN_UP) && goalState == STATE_HANG) + { + if (abs(cinfo.f.floor) >= 850) + return; + + if (c_checkSpace() || cinfo.staticHit) + return; + + if (input & IN_WALK) { + goalState = STATE_HANDSTAND; + } else { + goalState = STATE_HANG_UP; + } + } + } + + C_HANDLER( STATE_REACH ) + { + flags |= ITEM_FLAG_GRAVITY; + c_angle(ANGLE_0); + c_jump(); + } + + C_HANDLER( STATE_SPLAT ) + { + c_angle(ANGLE_0); + c_default(); + c_applyOffset(); + } + + C_HANDLER( STATE_UW_TREAD ) + { + c_swim(); + } + + C_HANDLER( STATE_LAND ) + { + c_STATE_STOP(); + } + + C_HANDLER( STATE_COMPRESS ) + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + cinfo.gapPos = -WALL; + cinfo.gapNeg = WALL; + cinfo.gapCeiling = 0; + + collideRoom(LARA_HEIGHT, 0); + + if (cinfo.m.ceiling > -100) + { + animSet(ANIM_STAND, true); + pos = cinfo.pos; + hSpeed = 0; + vSpeed = 0; + } + } + + C_HANDLER( STATE_BACK ) + { + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + + c_angle(ANGLE_180); + + cinfo.gapPos = (waterState == WATER_STATE_WADE) ? -WALL : LARA_STEP_HEIGHT; + cinfo.gapNeg = -LARA_STEP_HEIGHT; + cinfo.gapCeiling = 0; + cinfo.stopOnSlant = true; + + collideRoom(LARA_HEIGHT, 0); + + if (c_checkCeiling()) + return; + + if (c_checkWall()) + { + animSet(ANIM_STAND, true); + } + + if (cinfo.m.floor > 128 && cinfo.m.floor < LARA_STEP_HEIGHT) + { + if (frameIndex < 568) { + animSet(ANIM_BACK_DESCEND_LEFT, false); + } else { + animSet(ANIM_BACK_DESCEND_RIGHT, false); + } + } + + if (c_checkSlide()) + return; + + pos.y += cinfo.m.floor; + } + + C_HANDLER( STATE_UW_SWIM ) + { + c_swim(); + } + + C_HANDLER( STATE_UW_GLIDE ) + { + c_swim(); + } + + C_HANDLER( STATE_HANG_UP ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_TURN_FAST ) + { + c_STATE_STOP(); + } + + C_HANDLER( STATE_STEP_RIGHT ) + { + c_angle(+ANGLE_90); + c_step(); + } + + C_HANDLER( STATE_STEP_LEFT ) + { + c_angle(-ANGLE_90); + c_step(); + } + + C_HANDLER( STATE_ROLL_END ) + { + c_angle(ANGLE_180); + c_roll(); + } + + C_HANDLER( STATE_SLIDE ) + { + c_angle(ANGLE_0); + c_slide(); + } + + C_HANDLER( STATE_JUMP_BACK ) + { + c_angle(ANGLE_180); + c_jump(); + } + + C_HANDLER( STATE_JUMP_RIGHT ) + { + c_angle(ANGLE_90); + c_jump(); + } + + C_HANDLER( STATE_JUMP_LEFT ) + { + c_angle(-ANGLE_90); + c_jump(); + } + + C_HANDLER( STATE_JUMP_UP ) + { + c_angle(ANGLE_0); + c_jump(); + } + + C_HANDLER( STATE_FALL_BACK ) + { + c_angle(ANGLE_180); + c_jump(); + } + + C_HANDLER( STATE_HANG_LEFT ) + { + c_hang(-ANGLE_90); + } + + C_HANDLER( STATE_HANG_RIGHT ) + { + c_hang(ANGLE_90); + } + + C_HANDLER( STATE_SLIDE_BACK ) + { + c_angle(ANGLE_180); + c_slide(); + } + + C_HANDLER( STATE_SURF_TREAD ) + { + c_angle(ANGLE_0); + c_surf(); + } + + C_HANDLER( STATE_SURF_SWIM ) + { + cinfo.gapNeg = -LARA_STEP_HEIGHT; + + c_angle(ANGLE_0); + c_surf(); + c_checkWaterOut(); + } + + C_HANDLER( STATE_UW_DIVE ) + { + c_swim(); + } + + C_HANDLER( STATE_BLOCK_PUSH ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_BLOCK_PULL ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_BLOCK_READY ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_PICKUP ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_SWITCH_DOWN ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_SWITCH_UP ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_USE_KEY ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_USE_PUZZLE ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_DEATH_UW ) + { + health = 0; + oxygen = 0; + + int16 waterLevel = getWaterLevel(); + if (waterLevel != WALL && waterLevel < pos.y - LARA_RADIUS) { + pos.y -= LARA_FLOAT_UP_SPEED; + } + + c_swim(); + } + + C_HANDLER( STATE_ROLL_START ) + { + c_angle(ANGLE_0); + c_roll(); + } + + C_HANDLER( STATE_SPECIAL ) + { + // empty + } + + C_HANDLER( STATE_SURF_BACK ) + { + c_angle(ANGLE_180); + c_surf(); + } + + C_HANDLER( STATE_SURF_LEFT ) + { + c_angle(-ANGLE_90); + c_surf(); + } + + C_HANDLER( STATE_SURF_RIGHT ) + { + c_angle(ANGLE_90); + c_surf(); + } + + C_HANDLER( STATE_USE_MIDAS ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_DEATH_MIDAS ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_SWAN_DIVE ) + { + c_angle(ANGLE_0); + c_jump(); + } + + C_HANDLER( STATE_FAST_DIVE ) + { + c_angle(ANGLE_0); + c_jump(); + } + + C_HANDLER( STATE_HANDSTAND ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_WATER_OUT ) + { + c_angle(ANGLE_0); + c_default(); + } + + C_HANDLER( STATE_CLIMB_START ) {} + C_HANDLER( STATE_CLIMB_UP ) {} + C_HANDLER( STATE_CLIMB_LEFT ) {} + C_HANDLER( STATE_CLIMB_END ) {} + C_HANDLER( STATE_CLIMB_RIGHT ) {} + C_HANDLER( STATE_CLIMB_DOWN ) {} + C_HANDLER( STATE_UNUSED_1 ) {} + C_HANDLER( STATE_UNUSED_2 ) {} + C_HANDLER( STATE_UNUSED_3 ) {} + C_HANDLER( STATE_WADE ) {} + C_HANDLER( STATE_ROLL_UW ) {} + C_HANDLER( STATE_PICKUP_FLARE ) {} + C_HANDLER( STATE_ROLL_AIR ) {} + C_HANDLER( STATE_UNUSED_4 ) {} + C_HANDLER( STATE_ZIPLINE ) {} + + Lara(Room* room) : ItemObj(room) + { + int32 playerIndex = -1; + + for (int32 i = 0; i < X_COUNT(players); i++) + { + if (players[i] == this) { + playerIndex = i; + break; + } + } + + ASSERT(playerIndex != -1); + + extraL = &playersExtra[playerIndex]; + memset(extraL, 0, sizeof(*extraL)); + extraL->hitQuadrant = -1; + + extraL->weapon = extraL->goalWeapon = WEAPON_PISTOLS; // TODO LEVEL10A + setWeaponState(WEAPON_STATE_FREE); + meshSwap(ITEM_LARA, 0xFFFFFFFF); + + bool isHome = gLevelID == LVL_TR1_GYM; + + if (isHome) { + meshSwap(ITEM_LARA_SPEC, JOINT_MASK_UPPER | JOINT_MASK_LOWER); + extraL->ammo[WEAPON_PISTOLS] = 0; + } else { + extraL->ammo[WEAPON_PISTOLS] = -1; + extraL->ammo[WEAPON_MAGNUMS] = -1; + extraL->ammo[WEAPON_UZIS] = -1; + extraL->ammo[WEAPON_SHOTGUN] = -1; + + if (extraL->weapon != WEAPON_MAX) + { + meshSwapPistols(JOINT_MASK_LEG_R1 | JOINT_MASK_LEG_L1, JOINT_MASK_ARM_R3 | JOINT_MASK_ARM_L3); + // TODO check if shotgun on back + meshSwapShotgun(false); + } + + //extraL->weapon = extraL->goalWeapon = WEAPON_SHOTGUN; + } + + animSet(ANIM_STAND, true, 0); + + health = LARA_MAX_HEALTH; + oxygen = LARA_MAX_OXYGEN; + flags |= ITEM_FLAG_SHADOW; + + extraL->camera.init(this); + extraL->healthTimer = 100; + } + +// update control + void updateInput() + { + extraL->lastInput = input; + + input = 0; + + #if defined(__3DO__) + if (keys & IK_A) input |= IN_JUMP; + if (keys & IK_B) input |= IN_ACTION; + if (keys & IK_C) input |= IN_WEAPON; + + if ((keys & (IK_L | IK_R)) == (IK_L | IK_R)) { + input |= IN_UP | IN_DOWN; + } else { + if (keys & IK_L) input |= IN_LOOK; + if (keys & IK_R) input |= IN_WALK; + } + #elif defined(__32X__) + // 6 buttons + if (keys & IK_A) input |= IN_ACTION; + if (keys & IK_B) input |= IN_JUMP; + if (keys & IK_C) input |= IN_WEAPON; + if (keys & IK_X) input |= IN_WALK; + if (keys & IK_Y) input |= IN_UP | IN_DOWN; + if (keys & IK_Z) input |= IN_LOOK; + #elif defined(__GBA__) || defined(__GBA_WIN__) + int32 ikA, ikB; + + if (gSettings.controls_swap) { + ikA = IK_B; + ikB = IK_A; + } else { + ikA = IK_A; + ikB = IK_B; + } + + if (keys & ikA) + { + if (keys & IK_L) { + if (extraL->weaponState != WEAPON_STATE_BUSY) { + input |= IN_WEAPON; + } else { + input |= IN_ACTION; + } + } else { + input |= IN_ACTION; + } + } + + if (keys & ikB) + { + if (keys & IK_L) { + input |= IN_UP | IN_DOWN; + } else { + input |= IN_JUMP; + } + } + + if (keys & IK_R) + { + if (keys & IK_L) { + input |= IN_LOOK; + } else { + input |= IN_WALK; + } + } + #elif defined(__NDS__) + if (keys & IK_A) input |= IN_UP | IN_DOWN; + if (keys & IK_B) input |= IN_ACTION; + if (keys & IK_X) input |= IN_WEAPON; + if (keys & IK_Y) input |= IN_JUMP; + if (keys & IK_L) input |= IN_LOOK; + if (keys & IK_R) input |= IN_WALK; + #elif defined(__WIN32__) + if (keys & IK_A) input |= IN_ACTION; + if (keys & IK_B) input |= IN_UP | IN_DOWN; + if (keys & IK_Y) input |= IN_WEAPON; + if (keys & IK_X) input |= IN_JUMP; + if (keys & IK_L) input |= IN_LOOK; + if (keys & IK_R) input |= IN_WALK; + #endif + + if (keys & IK_LEFT) input |= IN_LEFT; + if (keys & IK_RIGHT) input |= IN_RIGHT; + if (keys & IK_UP) input |= IN_UP; + if (keys & IK_DOWN) input |= IN_DOWN; + if (keys & IK_SELECT) input |= IN_SELECT; + + if (extraL->camera.mode == CAMERA_MODE_FREE) { + input = 0; + } + + if (keys & IK_START) input |= IN_START; + + if (isKeyHit(IN_START) && (inventory.state == INV_STATE_NONE)) + { + if (extraL->camera.mode != CAMERA_MODE_FREE) { + extraL->camera.mode = CAMERA_MODE_FREE; + } else { + extraL->camera.mode = CAMERA_MODE_FOLLOW; + } + } + } + + void updateLook() + { + ExtraInfoLara::Arm &R = extraL->armR; + ExtraInfoLara::Arm &L = extraL->armL; + vec3s &H = extraL->head.angle; + vec3s &T = extraL->torso.angle; + + if (health <= 0) { + H = T = _vec3s(0, 0, 0); + return; + } + + if (R.target || L.target) + { + if (extraL->weapon < WEAPON_SHOTGUN) + { + int32 aX = R.angle.x + L.angle.x; + int32 aY = R.angle.y + L.angle.y; + + if (R.aim && L.aim) { + H.x = T.x = aX >> 2; + H.y = T.y = aY >> 2; + } else { + H.x = T.x = aX >> 1; + H.y = T.y = aY >> 1; + } + } else { + T.x = R.angle.x; + T.y = R.angle.y; + H.x = H.y = 0; + } + return; + } + + if ((input & IN_LOOK) && extraL->camera.mode != CAMERA_MODE_FIXED) + { + extraL->camera.lookAtItem = NULL; + + if (input & IN_UP) { + H.x -= LARA_LOOK_TURN_SPEED; + } + + if (input & IN_DOWN) { + H.x += LARA_LOOK_TURN_SPEED; + } + + if (input & IN_LEFT) { + H.y -= LARA_LOOK_TURN_SPEED; + } + + if (input & IN_RIGHT) { + H.y += LARA_LOOK_TURN_SPEED; + } + + H.x = T.x = X_CLAMP(H.x, LARA_LOOK_ANGLE_MIN, LARA_LOOK_ANGLE_MAX); + H.y = T.y = X_CLAMP(H.y, -LARA_LOOK_ANGLE_Y, LARA_LOOK_ANGLE_Y); + + input &= ~(IN_RIGHT | IN_LEFT | IN_UP | IN_DOWN); + return; + } + + if (extraL->camera.lastItem != NULL) + return; + + H.x = T.x = angleDec(H.x, abs(H.x) >> 3); + H.y = T.y = angleDec(H.y, abs(H.y) >> 3); + } + + void updateWaterState() + { + int32 waterLevel = getWaterLevel(); + int32 waterDist = WALL; + + if (waterLevel != WALL) { + waterDist = pos.y - waterLevel; + } + + // change water state + switch (waterState) + { + case WATER_STATE_ABOVE: + { + if (waterDist == WALL || waterDist < LARA_WADE_MIN_DEPTH) { + break; + } + + int32 waterDepth = getWaterDepth(); + if (waterDepth > LARA_WADE_MAX_DEPTH - 256) + { + if (!ROOM_FLAG_WATER(room->info->flags)) // go dive + break; + + waterState = WATER_STATE_UNDER; + flags &= ~ITEM_FLAG_GRAVITY; + oxygen = LARA_MAX_OXYGEN; + + pos.y += 100; + updateRoom(0); + stopScreaming(); + + if (state == STATE_SWAN_DIVE) { + angle.x = ANGLE(-45); + goalState = STATE_UW_DIVE; + animProcess(); + vSpeed *= 2; + //game->waterDrop(pos, 128.0f, 0.2f); + } else if (state == STATE_FAST_DIVE) { + angle.x = ANGLE(-85); + goalState = STATE_UW_DIVE; + animProcess(); + vSpeed *= 2; + //game->waterDrop(pos, 128.0f, 0.2f); + } else { + angle.x = ANGLE(-45); + animSet(ANIM_WATER_FALL, true); + state = STATE_UW_DIVE; // TODO check necessary + goalState = STATE_UW_SWIM; + vSpeed = vSpeed * 3 / 2; + //game->waterDrop(pos, 256.0f, 0.2f); + } + + fxSplash(); + } else if (waterDist > LARA_WADE_MIN_DEPTH) { + waterState = WATER_STATE_WADE; + if (!(flags & ITEM_FLAG_GRAVITY)) { + goalState = STATE_STOP; + } + } + break; + } + + case WATER_STATE_SURFACE: + { + if (ROOM_FLAG_WATER(room->info->flags)) + break; + + if (waterDist > LARA_WADE_MIN_DEPTH) { + waterState = WATER_STATE_WADE; + animSet(ANIM_STAND_NORMAL, true); + goalState = STATE_WADE; + animProcess(); + } else { + waterState = WATER_STATE_ABOVE; + animSet(ANIM_FALL_FORTH, true); + hSpeed = vSpeed / 4; + flags |= ITEM_FLAG_GRAVITY; + } + + vSpeed = 0; + angle.x = angle.z = 0; + break; + } + + case WATER_STATE_UNDER: + { + if (ROOM_FLAG_WATER(room->info->flags) || extraL->dozy) + break; + + if ((getWaterDepth() != WALL) && abs(waterDist) < 256) { + waterState = WATER_STATE_SURFACE; + pos.y -= (waterDist - 1); + animSet(ANIM_SURF, true); + vSpeed = 0; + extraL->swimTimer = LARA_SWIM_TIMER + 1; // block dive before we press jump button again + updateRoom(-LARA_HEIGHT / 2); + //game->playSound(TR::SND_BREATH, pos, Sound::PAN | Sound::UNIQUE); + } else { + waterState = WATER_STATE_ABOVE; + animSet(ANIM_FALL_FORTH, true); + hSpeed = vSpeed / 4; + vSpeed = 0; + flags |= ITEM_FLAG_GRAVITY; + } + + angle.x = angle.z = 0; + break; + } + + case WATER_STATE_WADE: + { + if (waterDist < LARA_WADE_MIN_DEPTH) + { + waterState = WATER_STATE_ABOVE; + if (state == STATE_WADE) { + goalState = STATE_RUN; + } + } else if (waterDist > LARA_WADE_MAX_DEPTH) { + waterState = WATER_STATE_SURFACE; + pos.y -= (waterDist - 1); + + if (state == STATE_BACK) { + animSet(ANIM_SURF_BACK, true); + } else if (state == STATE_STEP_RIGHT) { + animSet(ANIM_SURF_RIGHT, true); + } else if (state == STATE_STEP_LEFT) { + animSet(ANIM_SURF_LEFT, true); + } else { + animSet(ANIM_SURF_SWIM, true); + } + + extraL->swimTimer = 0; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + angle.x = angle.z = 0; + updateRoom(0); + } + break; + } + } + } + + void updateAbove() + { + cinfo.trigger = NULL; + cinfo.radius = LARA_RADIUS; + cinfo.pos = pos; + cinfo.enemyPush = true; + cinfo.enemyHit = true; + cinfo.stopOnSlant = false; + cinfo.stopOnLava = false; + + updateState(); + + angle.z = angleDec(angle.z, ANGLE(1)); + turnSpeed = angleDec(turnSpeed, ANGLE(2)); + angle.y += turnSpeed; + } + + void updateSurface() + { + cinfo.trigger = NULL; + cinfo.radius = LARA_RADIUS; + cinfo.gapPos = -WALL; + cinfo.gapNeg = -128; + cinfo.gapCeiling = 100; + cinfo.pos = pos; + cinfo.enemyPush = false; + cinfo.enemyHit = false; + cinfo.stopOnSlant = false; + cinfo.stopOnLava = false; + + updateState(); + + angle.z = angleDec(angle.z, ANGLE(2)); + + int32 s, c; + sincos(extraL->moveAngle, s, c); + + pos.x += (s * vSpeed) >> 16; + pos.z += (c * vSpeed) >> 16; + + extraL->camera.targetAngle.x = ANGLE(-22); + } + + void updateUnder() + { + cinfo.trigger = NULL; + cinfo.radius = LARA_RADIUS_WATER; + cinfo.gapPos = -WALL; + cinfo.gapNeg = -LARA_HEIGHT_UW; + cinfo.gapCeiling = LARA_HEIGHT_UW; + cinfo.pos = pos; + cinfo.enemyPush = false; + cinfo.enemyHit = false; + cinfo.stopOnSlant = false; + cinfo.stopOnLava = false; + + updateState(); + + angle.z = angleDec(angle.z, ANGLE(2)); + turnSpeed = angleDec(turnSpeed, ANGLE(2)); + angle.y += turnSpeed; + + angle.x = X_CLAMP(angle.x, ANGLE(-85), ANGLE(85)); + angle.z = X_CLAMP(angle.z, ANGLE(-22), ANGLE(22)); + + int32 sx, cx; + int32 sy, cy; + sincos(angle.x, sx, cx); + sincos(angle.y, sy, cy); + + pos.y -= (sx * vSpeed) >> 16; + pos.x += (cx * ((sy * vSpeed) >> 16)) >> FIXED_SHIFT; + pos.z += (cx * ((cy * vSpeed) >> 16)) >> FIXED_SHIFT; + } + + bool weaponFire(const ExtraInfoLara::Arm* arm) + { + int16 ammo = extraL->ammo[extraL->weapon]; + + if (!ammo) { + soundPlay(SND_EMPTY, &pos); + extraL->goalWeapon = WEAPON_PISTOLS; + return false; + } + + if (ammo > 0) { + ammo--; + } + + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + Location from; + from.pos.x = pos.x; + from.pos.y = pos.y - params.height; + from.pos.z = pos.z; + from.room = room; + + int32 count = (extraL->weapon == WEAPON_SHOTGUN) ? 6 : 1; + + for (int32 i = 0; i < count; i++) + { + int32 aimX = int32(rand_logic() - 0x4000) * params.spread >> 16; + int32 aimY = int32(rand_logic() - 0x4000) * params.spread >> 16; + + aimX += arm->angle.x; + aimY += arm->angle.y; + aimY += angle.y; + + matrixSetView(from.pos, aimX, aimY); + + int32 minDist = INT_MAX; + + if (arm->target && arm->target->health > 0) + { + Sphere* spheres = gSpheres[0]; + int32 spheresCount = arm->target->getSpheres(spheres, false); + + for (int32 i = 0; i < spheresCount; i++) + { + const Sphere &s = spheres[i]; + + if (abs(s.center.x) >= s.radius) + continue; + + if (abs(s.center.y) >= s.radius) + continue; + + if (s.center.z <= s.radius) + continue; + + if (fastLength(s.center.x, s.center.y) > s.radius) + continue; + + int32 dist = s.center.z - s.radius; + + if (dist < minDist) { + minDist = dist; + } + } + } + + vec3i dir = matrixGetDir(matrixGet()); + + Location to = from; + + if (minDist != INT_MAX) + { + dir *= minDist; + to.pos.x += dir.x >> FIXED_SHIFT; + to.pos.y += dir.y >> FIXED_SHIFT; + to.pos.z += dir.z >> FIXED_SHIFT; + + arm->target->hit(params.damage, to.pos, 0); + } else { + to.pos += dir; + + trace(from, to, true); + fxRicochet(to.room, to.pos, true); + } + } + + soundPlay(params.soundId, &pos); + + return true; + } + + void setWeaponState(WeaponState weaponState) + { + if (weaponState == extraL->weaponState) + return; + extraL->weaponState = weaponState; + + ExtraInfoLara::Arm &R = extraL->armR; + ExtraInfoLara::Arm &L = extraL->armL; + + if (weaponState == WEAPON_STATE_DRAW) + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + int32 anim = (extraL->weapon == WEAPON_SHOTGUN) ? ANIM_SHOTGUN_DRAW : ANIM_PISTOLS_PICK; + R.animIndex = L.animIndex = level.models[params.animType].animIndex + anim; + R.frameIndex = L.frameIndex = 0; + } + + if (weaponState == WEAPON_STATE_HOLSTER) + { + R.target = L.target = NULL; + } + + if (weaponState == WEAPON_STATE_FREE) + { + R.useBasis = L.useBasis = false; + R.animIndex = L.animIndex = 0; + R.frameIndex = L.frameIndex = 0; + #ifdef __3DO__ + extraL->goalWeapon = extraL->weapon = (extraL->weapon + 1) % WEAPON_MAX; + #endif + } + } + + void weaponAim(ExtraInfoLara::Arm &arm) + { + if (arm.aim) { + arm.angle.x = angleLerp(arm.angle.x, arm.angleAim.x, ANGLE(10)); + arm.angle.y = angleLerp(arm.angle.y, arm.angleAim.y, ANGLE(10)); + } else { + arm.angle.x = angleLerp(arm.angle.x, 0, ANGLE(10)); + arm.angle.y = angleLerp(arm.angle.y, 0, ANGLE(10)); + } + } + + void weaponDrawPistols() + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + ExtraInfoLara::Arm* arm = &extraL->armR; + + const Anim* animPtr = level.anims + arm->animIndex; + int32 animLength = animPtr->frameEnd - animPtr->frameBegin; + int32 frame = arm->frameIndex + 1; + int32 anim = arm->animIndex - level.models[params.animType].animIndex; + + if (frame > animLength) + { + anim++; + + if (anim == ANIM_PISTOLS_DRAW) { + meshSwapPistols(JOINT_MASK_ARM_R3 | JOINT_MASK_ARM_L3, JOINT_MASK_LEG_R1 | JOINT_MASK_LEG_L1); + soundPlay(SND_DRAW, &pos); + } else if (anim == ANIM_PISTOLS_FIRE) { + anim = ANIM_PISTOLS_AIM; + setWeaponState(WEAPON_STATE_READY); + } + + frame = 0; + } + + extraL->armR.angle = extraL->armL.angle = _vec3s(0, 0, 0); + extraL->armR.animIndex = extraL->armL.animIndex = anim + level.models[params.animType].animIndex; + extraL->armR.frameIndex = extraL->armL.frameIndex = frame; + } + + void weaponHolsterPistols() + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + for (int32 i = 0; i < LARA_ARM_MAX; i++) + { + ExtraInfoLara::Arm* arm = &extraL->armR + i; + + if (!arm->animIndex) + continue; + + int32 frame = arm->frameIndex; + int32 anim = arm->animIndex - level.models[params.animType].animIndex; + + if (frame) + { + if (anim == ANIM_PISTOLS_AIM) { + arm->angle.x -= arm->angle.x / frame; // @DIV + arm->angle.y -= arm->angle.y / frame; // @DIV + } + + if (anim == ANIM_PISTOLS_FIRE) { + frame = 0; + } else { + frame--; + } + } else { + if (anim == ANIM_PISTOLS_AIM) { + anim = ANIM_PISTOLS_DRAW; + } else if (anim == ANIM_PISTOLS_PICK) { + arm->animIndex = 0; + continue; + } else if (anim == ANIM_PISTOLS_DRAW) { + anim = ANIM_PISTOLS_PICK; + if (i == LARA_ARM_R) { + meshSwapPistols(JOINT_MASK_LEG_R1, JOINT_MASK_ARM_R3); + } else { + meshSwapPistols(JOINT_MASK_LEG_L1, JOINT_MASK_ARM_L3); + } + soundPlay(SND_HOLSTER, &pos); + } else if (anim == ANIM_PISTOLS_FIRE) { + anim = ANIM_PISTOLS_AIM; + } + + arm->animIndex = anim + level.models[params.animType].animIndex; + frame = level.anims[arm->animIndex].frameEnd - level.anims[arm->animIndex].frameBegin; + } + + arm->frameIndex = frame; + } + + if (!extraL->armR.animIndex && !extraL->armL.animIndex) { + setWeaponState(WEAPON_STATE_FREE); + } + } + + void weaponDrawShotgun() + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + ExtraInfoLara::Arm &arm = extraL->armR; + + const Anim* animPtr = level.anims + arm.animIndex; + int32 animLength = animPtr->frameEnd - animPtr->frameBegin; + int32 frame = arm.frameIndex + 1; + int32 anim = arm.animIndex - level.models[params.animType].animIndex; + + ASSERT(anim == ANIM_SHOTGUN_DRAW); + + if (frame == 10) { + meshSwapShotgun(true); + soundPlay(SND_DRAW, &pos); + } + + if (frame == animLength) { + setWeaponState(WEAPON_STATE_READY); + } + + extraL->armR.angle = extraL->armL.angle = _vec3s(0, 0, 0); + extraL->armR.animIndex = extraL->armL.animIndex = anim + level.models[params.animType].animIndex; + extraL->armR.frameIndex = extraL->armL.frameIndex = frame; + } + + void weaponHolsterShotgun() + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + ExtraInfoLara::Arm &arm = extraL->armR; + + int32 frame = arm.frameIndex; + int32 anim = arm.animIndex - level.models[params.animType].animIndex; + + if (anim == ANIM_SHOTGUN_AIM) { + if (frame == 0) { + anim = ANIM_SHOTGUN_DRAW; + const Anim* animPtr = level.anims + level.models[params.animType].animIndex + anim; + frame = animPtr->frameEnd - animPtr->frameBegin; + } else { + frame--; + } + } else if (anim == ANIM_SHOTGUN_FIRE) { + frame++; + if (frame > 12) { + anim = ANIM_SHOTGUN_DRAW; + const Anim* animPtr = level.anims + level.models[params.animType].animIndex + anim; + frame = animPtr->frameEnd - animPtr->frameBegin; + } + } else if (anim == ANIM_SHOTGUN_DRAW) { + if (frame == 0) { + setWeaponState(WEAPON_STATE_FREE); + return; + } else { + if (frame == 10) { + meshSwapShotgun(false); + soundPlay(SND_HOLSTER, &pos); + } + frame--; + } + } + + extraL->armR.angle = extraL->armL.angle = _vec3s(0, 0, 0); + extraL->armR.animIndex = extraL->armL.animIndex = anim + level.models[params.animType].animIndex; + extraL->armR.frameIndex = extraL->armL.frameIndex = frame; + } + + void weaponDraw() + { + switch (extraL->weapon) + { + case WEAPON_PISTOLS: + case WEAPON_MAGNUMS: + case WEAPON_UZIS: + weaponDrawPistols(); + break; + case WEAPON_SHOTGUN: + weaponDrawShotgun(); + break; + default: ASSERT(false); + } + } + + void weaponHolster() + { + meshSwap(ITEM_LARA, JOINT_MASK_HEAD); + + switch (extraL->weapon) + { + case WEAPON_PISTOLS: + case WEAPON_MAGNUMS: + case WEAPON_UZIS: + weaponHolsterPistols(); + break; + case WEAPON_SHOTGUN: + weaponHolsterShotgun(); + break; + default: ASSERT(false); + } + } + + void weaponUpdatePistols() + { + ExtraInfoLara::Arm &R = extraL->armR; + ExtraInfoLara::Arm &L = extraL->armL; + + weaponAim(R); + weaponAim(L); + + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + for (int32 i = 0; i < LARA_ARM_MAX; i++) + { + ExtraInfoLara::Arm* arm = &extraL->armR + i; + + const Anim* animPtr = level.anims + arm->animIndex; + int32 animLength = animPtr->frameEnd - animPtr->frameBegin; + int32 frame = arm->frameIndex; + int32 anim = arm->animIndex - level.models[params.animType].animIndex; + + if (((input & IN_ACTION) && !arm->target) || arm->aim) + { + if (anim == ANIM_PISTOLS_AIM) + { + if (frame == animLength) + { + if ((input & IN_ACTION) && weaponFire(arm)) + { + anim = ANIM_PISTOLS_FIRE; + frame = 0; + + arm->flash.timer = params.flashTimer; + arm->flash.angle = int16(rand_draw() << 1); + arm->flash.offset = params.flashOffset; + arm->flash.intensity = params.flashIntensity << 8; + } + } else { + frame++; + } + } else { // ANIM_DUAL_FIRE + frame++; + if (frame == params.reloadTimer) + { + anim = ANIM_PISTOLS_AIM; + const Anim* animPtr = level.anims + anim + level.models[params.animType].animIndex; + frame = animPtr->frameEnd - animPtr->frameBegin; + } + } + } else { + if (anim == ANIM_PISTOLS_FIRE) + { + anim = ANIM_PISTOLS_AIM; + const Anim* animPtr = level.anims + anim + level.models[params.animType].animIndex; + frame = animPtr->frameEnd - animPtr->frameBegin; + } else if (frame) { + frame--; + }; + } + + arm->animIndex = anim + level.models[params.animType].animIndex; + arm->frameIndex = frame; + arm->useBasis = (anim == ANIM_PISTOLS_AIM && frame) || (anim == ANIM_PISTOLS_FIRE); + } + } + + void weaponUpdateShotgun() + { + ExtraInfoLara::Arm &R = extraL->armR; + ExtraInfoLara::Arm &L = extraL->armL; + + weaponAim(R); + + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + ExtraInfoLara::Arm* arm = &extraL->armR; + + const Anim* animPtr = level.anims + arm->animIndex; + int32 animLength = animPtr->frameEnd - animPtr->frameBegin; + int32 frame = arm->frameIndex; + int32 anim = arm->animIndex - level.models[params.animType].animIndex; + + bool aim = ((input & IN_ACTION) && !arm->target) || arm->aim; + + switch (anim) + { + case ANIM_SHOTGUN_FIRE: + { + frame++; + if (frame == 10) { + soundPlay(SND_SHOTGUN_RELOAD, &pos); + } else if (frame == params.reloadTimer) { + anim = ANIM_SHOTGUN_AIM; + animPtr = level.anims + level.models[params.animType].animIndex + anim; + frame = animPtr->frameEnd - animPtr->frameBegin; + } else if ((animLength - frame < 10) && !aim) { + anim = ANIM_SHOTGUN_AIM; + frame = animLength - frame; // how many frames left for fire animation + animPtr = level.anims + level.models[params.animType].animIndex + anim; + frame = animPtr->frameEnd - animPtr->frameBegin - frame; // offset aim frames from the end + } + break; + } + case ANIM_SHOTGUN_DRAW: + { + if (aim) + { + anim = ANIM_SHOTGUN_AIM; + frame = 1; + } + break; + } + case ANIM_SHOTGUN_AIM: + { + if (aim) + { + if (frame == animLength) + { + if ((input & IN_ACTION) && weaponFire(arm)) + { + frame = 1; + anim = ANIM_SHOTGUN_FIRE; + } + } else { + frame++; + } + } else { + if (frame == 0) { + anim = ANIM_SHOTGUN_DRAW; + animPtr = level.anims + level.models[params.animType].animIndex + anim; + animLength = animPtr->frameEnd - animPtr->frameBegin; + frame = animLength; + } else { + frame--; + } + } + break; + } + } + + R.useBasis = L.useBasis = false; + R.animIndex = L.animIndex = anim + level.models[params.animType].animIndex; + R.frameIndex = L.frameIndex = frame; + } + + void weaponUpdateState() + { + bool change = false; + if (waterState == WATER_STATE_ABOVE || waterState == WATER_STATE_WADE) + { + if (extraL->weapon != extraL->goalWeapon) + { + if (extraL->weaponState == WEAPON_STATE_FREE) { + extraL->weapon = extraL->goalWeapon; + change = true; + } else if (extraL->weaponState == WEAPON_STATE_READY) { + change = true; + } + } else if (input & IN_WEAPON) { + change = true; + } + } else if (extraL->weaponState == WEAPON_STATE_READY) { + change = true; + } + + if (!change) + return; + + if (extraL->weaponState == WEAPON_STATE_FREE) + { + if (extraL->ammo[WEAPON_PISTOLS] != 0) + { + setWeaponState(WEAPON_STATE_DRAW); + } + } + + if (extraL->weaponState == WEAPON_STATE_READY) + { + setWeaponState(WEAPON_STATE_HOLSTER); + } + } + + void weaponGetAimPoint(ItemObj* target, Location &point) + { + const AABBs &box = target->getBoundingBox(false); + vec3i p; + p.x = (box.minX + box.maxX) >> 1; + p.y = box.minY + (box.maxY - box.minY) / 3; // @DIV + p.z = (box.minZ + box.maxZ) >> 1; + int32 s, c; + sincos(target->angle.y, s, c); + X_ROTXY(p.x, p.z, -s, c); + + point.pos = target->pos + p; + point.room = target->room; + } + + void weaponTrackTargets() + { + ExtraInfoLara::Arm &arm = extraL->armR; + + if (arm.target && arm.target->health <= 0) + { + arm.target = NULL; + } + + if (!arm.target) + { + extraL->armR.aim = extraL->armL.aim = false; + return; + } + + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + Location from; + from.pos.x = pos.x; + from.pos.y = pos.y - params.height; + from.pos.z = pos.z; + from.room = room; + + Location to; + weaponGetAimPoint(arm.target, to); + + vec3i dir = to.pos - from.pos; + vec3s angleAim; + + anglesFromVector(dir.x, dir.y, dir.z, angleAim.x, angleAim.y); + + angleAim.x -= angle.x; + angleAim.y -= angle.y; + + if (trace(from, to, false)) + { + if (abs(angleAim.x) <= params.aimX && abs(angleAim.y) <= params.aimY) { + extraL->armR.aim = extraL->armL.aim = true; + } else { + extraL->armR.aim = extraL->armR.aim && (abs(angleAim.x) <= params.armX) && (angleAim.y >= params.armMinY) && (angleAim.y <= params.armMaxY); + extraL->armL.aim = extraL->armL.aim && (abs(angleAim.x) <= params.armX) && (angleAim.y >= -params.armMaxY) && (angleAim.y <= -params.armMinY); + } + } else { + extraL->armR.aim = extraL->armL.aim = false; + } + + extraL->armR.angleAim = extraL->armL.angleAim = angleAim; + } + + void weaponFindTargets() + { + if (!ItemObj::sFirstActive) + return; + + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + int32 range = params.range; + int32 rangeQ = X_SQR(range); + int32 minAimY = params.aimY; + + Location from; + from.pos.x = pos.x; + from.pos.y = pos.y - params.height; + from.pos.z = pos.z; + from.room = room; + + ItemObj* item = ItemObj::sFirstActive; + do + { + if (item->health <= 0) + continue; + + if ((item->flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_ACTIVE) + continue; + + vec3i d = item->pos - pos; + int32 distQ = X_SQR(d.x) + X_SQR(d.y) + X_SQR(d.z); + + if (distQ > rangeQ) + continue; + + Location to; + weaponGetAimPoint(item, to); + + if (!trace(from, to, false)) + continue; + + vec3i dir = to.pos - from.pos; + vec3s angleAim; + + anglesFromVector(dir.x, dir.y, dir.z, angleAim.x, angleAim.y); + + angleAim.x -= angle.x + extraL->torso.angle.x; + angleAim.y -= angle.y + extraL->torso.angle.y; + + angleAim.x = abs(angleAim.x); + angleAim.y = abs(angleAim.y); + + if (angleAim.x > params.aimX || angleAim.y > params.aimY || angleAim.y > minAimY) + continue; + + minAimY = angleAim.y; + extraL->armR.target = item; + } while ((item = item->nextActive) != NULL); + } + + void weaponUpdateTargets() + { + if (input & IN_ACTION) { + meshSwap(ITEM_LARA_UZIS, JOINT_MASK_HEAD); + } else { + meshSwap(ITEM_LARA, JOINT_MASK_HEAD); + extraL->armR.target = NULL; + } + + if (extraL->armR.target == NULL) { + weaponFindTargets(); + } + + weaponTrackTargets(); + + extraL->armL.target = extraL->armR.target; + } + + void updateWeapon() + { + if (extraL->armR.flash.timer) { + extraL->armR.flash.timer--; + } + + if (extraL->armL.flash.timer) { + extraL->armL.flash.timer--; + } + + if (extraL->weapon == WEAPON_MAX) + return; + + if (health <= 0) + { + extraL->armR.animIndex = extraL->armL.animIndex = 0; + extraL->armR.useBasis = extraL->armL.useBasis = false; + return; + } + + weaponUpdateState(); + + switch (extraL->weaponState) + { + case WEAPON_STATE_DRAW: + { + extraL->camera.toCombat(); + weaponDraw(); + break; + } + + case WEAPON_STATE_HOLSTER: + { + weaponHolster(); + break; + } + + case WEAPON_STATE_READY: + { + extraL->camera.toCombat(); + weaponUpdateTargets(); + + if (extraL->weapon < WEAPON_SHOTGUN) { + weaponUpdatePistols(); + } else { + weaponUpdateShotgun(); + } + } + + default: ; + } + } + + void changeWeapon(Weapon weapon) + { + extraL->goalWeapon = weapon; + if ((extraL->weaponState == WEAPON_STATE_FREE) && (extraL->goalWeapon == extraL->weapon)) + { + extraL->weapon = WEAPON_NONE; + } + } + + bool useItem(InvSlot slot) + { + switch (slot) + { + case SLOT_PISTOLS: + changeWeapon(WEAPON_PISTOLS); + break; + case SLOT_SHOTGUN: + changeWeapon(WEAPON_SHOTGUN); + break; + case SLOT_MAGNUMS: + changeWeapon(WEAPON_MAGNUMS); + break; + case SLOT_UZIS: + changeWeapon(WEAPON_UZIS); + break; + case SLOT_MEDIKIT_BIG: + case SLOT_MEDIKIT_SMALL: + if (health < LARA_MAX_HEALTH) + { + health += (slot == SLOT_MEDIKIT_BIG) ? LARA_MAX_HEALTH : (LARA_MAX_HEALTH >> 1); + if (health > LARA_MAX_HEALTH) { + health = LARA_MAX_HEALTH; + } + inventory.remove(slot, 1); + extraL->healthTimer = 40; + soundPlay(SND_HEALTH, &pos); + } + break; + default: return false; + } + return true; + } + + virtual void hit(int32 damage, const vec3i &point, int32 soundId) + { + if (health <= 0 || damage <= 0) + return; + + osJoyVibrate(0, 0xFF, 0xFF); + extraL->healthTimer = 40; + health = X_MAX(0, health - damage); + } + + virtual void update() + { + vec3i oldPos = pos; + + updateInput(); + + if ((input & (IN_JUMP | IN_WEAPON)) == (IN_JUMP | IN_WEAPON)) + { + restore(); + } + + if (isKeyHit(IN_SELECT) && (gBrightness == 0)) + { + inventory.open(this, (health > 0) ? INV_PAGE_MAIN : INV_PAGE_DEATH); + } + + updateLook(); + + updateWaterState(); + + if (health > 0) + { + if (waterState == WATER_STATE_UNDER) + { + if (oxygen > 0) { + oxygen--; + } else { + hit(5, pos, 0); + } + } else { + oxygen = X_MIN(oxygen + 10, LARA_MAX_OXYGEN); + } + } + + switch (waterState) + { + case WATER_STATE_ABOVE : + case WATER_STATE_WADE : updateAbove(); break; + case WATER_STATE_SURFACE : updateSurface(); break; + case WATER_STATE_UNDER : updateUnder(); break; + } + + animProcess(); + + updateCollision(); + + int32 offset; + if (waterState == WATER_STATE_SURFACE) { + offset = LARA_RADIUS; + } else if (waterState == WATER_STATE_UNDER) { + offset = 0; + } else { + offset = -LARA_HEIGHT / 2; + } + updateRoom(offset); + + const Sector* sector = room->getSector(pos.x, pos.z); + bool badPos = (sector->floor == NO_FLOOR); + + //if (!badPos) { + // int32 h = pos.y - roomFloor; + // badPos = (h > cinfo.gapPos) || (h < cinfo.gapNeg); + //} + + if (badPos) + { + pos = oldPos; + updateRoom(offset); + } + + updateWeapon(); + + checkTrigger(cinfo.trigger, this); + + extraL->camera.update(); + + if (health > 0 && extraL->healthTimer > 0) { + extraL->healthTimer--; + } + } + + void meshSwapPistols(uint32 weaponMask, uint32 bodyMask) + { + const WeaponParams ¶ms = weaponParams[extraL->weapon]; + + meshSwap(ITEM_LARA, bodyMask); + meshSwap(params.modelType, weaponMask); + } + + void meshSwapShotgun(bool armed) + { + const WeaponParams ¶ms = weaponParams[WEAPON_SHOTGUN]; + + if (armed) { + meshSwap(ITEM_LARA, JOINT_MASK_TORSO); + meshSwap(params.modelType, JOINT_MASK_ARM_R3 | JOINT_MASK_ARM_L3); + } else { + meshSwap(ITEM_LARA, JOINT_MASK_ARM_R3 | JOINT_MASK_ARM_L3); + meshSwap(params.modelType, JOINT_MASK_TORSO); + } + } + + virtual void draw() + { + int32 tmpAnimIndex = animIndex; + int32 tmpFrameIndex = frameIndex; + + if (extraL->hitQuadrant != -1) + { + switch (extraL->hitQuadrant) + { + case 0 : animIndex = ANIM_HIT_FRONT; break; + case 1 : animIndex = ANIM_HIT_LEFT; break; + case 2 : animIndex = ANIM_HIT_BACK; break; + case 3 : animIndex = ANIM_HIT_RIGHT; break; + default : ASSERT(false); + } + frameIndex = level.anims[animIndex].frameBegin + extraL->hitFrame; + } + + drawModel(this); + + animIndex = tmpAnimIndex; + frameIndex = tmpFrameIndex; + } + + struct LaraSave { + int16 vSpeed; + int16 hSpeed; + int16 health; // oxygen already saved as alias of ItemObj::timer + + uint8 weaponState; + uint8 weapon; + uint8 goalWeapon; + uint8 waterState; + + struct Arm { + uint16 animIndex; + uint16 frameIndex; + }; + + Arm armR; + Arm armL; + + uint8 cameraRoom; + uint8 cameraLastIndex; + + int16 cameraViewX; + int16 cameraViewY; + int16 cameraViewZ; + + uint16 meshes[JOINT_MAX]; + }; + + virtual uint8* save(uint8* data) + { + data = ItemObj::save(data); + + LaraSave* sg = (LaraSave*)data; + + sg->vSpeed = vSpeed; + sg->hSpeed = hSpeed; + sg->health = health; + sg->weaponState = extraL->weaponState; + sg->weapon = extraL->weapon; + sg->goalWeapon = extraL->goalWeapon; + sg->waterState = waterState; + + sg->armR.animIndex = extraL->armR.animIndex; + sg->armR.frameIndex = extraL->armR.frameIndex; + sg->armL.animIndex = extraL->armL.animIndex; + sg->armL.frameIndex = extraL->armL.frameIndex; + + const Room* camRoom = extraL->camera.view.room; + sg->cameraRoom = camRoom - rooms; + sg->cameraLastIndex = extraL->camera.lastIndex; + sg->cameraViewX = extraL->camera.view.pos.x - (camRoom->info->x << 8); + sg->cameraViewY = extraL->camera.view.pos.y - (camRoom->info->yTop); + sg->cameraViewZ = extraL->camera.view.pos.z - (camRoom->info->z << 8); + + ASSERT(sizeof(sg->meshes) == sizeof(extraL->meshes)); + memcpy(sg->meshes, extraL->meshes, sizeof(extraL->meshes)); + + return data + sizeof(LaraSave); + } + + virtual uint8* load(uint8* data) + { + data = ItemObj::load(data); + + LaraSave* sg = (LaraSave*)data; + + vSpeed = sg->vSpeed; + hSpeed = sg->hSpeed; + health = sg->health; + extraL->weaponState = sg->weaponState; + extraL->weapon = sg->weapon; + extraL->goalWeapon = sg->goalWeapon; + waterState = sg->waterState; + + extraL->armR.animIndex = sg->armR.animIndex; + extraL->armR.frameIndex = sg->armR.frameIndex; + extraL->armL.animIndex = sg->armL.animIndex; + extraL->armL.frameIndex = sg->armL.frameIndex; + + extraL->camera.init(this); + + Room* camRoom = rooms + sg->cameraRoom; + extraL->camera.view.room = camRoom; + extraL->camera.lastIndex = sg->cameraLastIndex; + extraL->camera.view.pos.x = sg->cameraViewX + (camRoom->info->x << 8); + extraL->camera.view.pos.y = sg->cameraViewY + (camRoom->info->yTop); + extraL->camera.view.pos.z = sg->cameraViewZ + (camRoom->info->z << 8); + + ASSERT(sizeof(sg->meshes) == sizeof(extraL->meshes)); + memcpy(extraL->meshes, sg->meshes, sizeof(extraL->meshes)); + + return data + sizeof(LaraSave); + } +}; + +const Lara::Handler Lara::sHandlers[X_MAX] = { LARA_STATES(DECL_S_HANDLER) }; +const Lara::Handler Lara::cHandlers[X_MAX] = { LARA_STATES(DECL_C_HANDLER) }; + +#undef DECL_ENUM +#undef DECL_S_HANDLER +#undef DECL_C_HANDLER +#undef S_HANDLER +#undef C_HANDLER + +int32 doTutorial(ItemObj* lara, int32 track) +{ + if (!lara) + return track; + + switch (track) + { + case 28 : + if ((gSaveGame.tracks[track] & TRACK_FLAG_ONCE) && lara->state == Lara::STATE_JUMP_UP) { + track = 29; + } + break; + + case 37 : + case 41 : + if (lara->state != Lara::STATE_HANG) { + track = 0; + } + break; + + case 42 : + if ((gSaveGame.tracks[track] & TRACK_FLAG_ONCE) && lara->state == Lara::STATE_HANG) { + track = 43; + } + break; + + case 49 : + if (lara->state != Lara::STATE_SURF_TREAD) { + track = 0; + } + break; + + case 50 : // end of GYM + if (gSaveGame.tracks[track] & TRACK_FLAG_ONCE) { + lara->gymTimer++; + if (lara->gymTimer > 90) + { + nextLevel(LVL_TR1_TITLE); + } + } else { + if (lara->state != Lara::STATE_WATER_OUT) + track = 0; + lara->gymTimer = 0; + } + break; + } + + return track; +} + +Lara* getLara(const vec3i &pos) +{ + return players[0]; // TODO find nearest player +} + +#endif diff --git a/src/fixed/level.h b/src/fixed/level.h new file mode 100644 index 00000000..19af0e52 --- /dev/null +++ b/src/fixed/level.h @@ -0,0 +1,287 @@ +#ifndef H_LEVEL +#define H_LEVEL + +#include "common.h" +#include "stream.h" + +Level level; + +#ifdef __32X__ + extern uint8 gLightmap[256 * 32]; // SDRAM 8k at 0x6000000 +#else + #ifndef MODEHW + IWRAM_DATA uint8 gLightmap[256 * 32]; // IWRAM 8k + #endif +#endif + +EWRAM_DATA ItemObj items[MAX_ITEMS]; + +#ifdef ROM_READ +EWRAM_DATA Texture textures[MAX_TEXTURES]; // animated textures require memory swap +EWRAM_DATA Sprite sprites[MAX_SPRITES]; +EWRAM_DATA FixedCamera cameras[MAX_CAMERAS]; +EWRAM_DATA Box boxes[MAX_BOXES]; +#endif + +EWRAM_DATA Room rooms[MAX_ROOMS]; +EWRAM_DATA Model models[MAX_MODELS]; +EWRAM_DATA const Mesh* meshes[MAX_MESHES]; +EWRAM_DATA StaticMesh staticMeshes[MAX_STATIC_MESHES]; + +EWRAM_DATA ItemObj* ItemObj::sFirstActive; +EWRAM_DATA ItemObj* ItemObj::sFirstFree; + +EWRAM_DATA int32 gBrightness; + +#if (USE_FMT & (LVL_FMT_PHD | LVL_FMT_PSX)) + uint8 gLevelData[2 * 1024 * 1024]; +#endif + +#if (USE_FMT & LVL_FMT_PKD) + #include "fmt/pkd.h" +#endif + +#if (USE_FMT & LVL_FMT_PHD) + #include "fmt/phd.h" +#endif + +#if (USE_FMT & LVL_FMT_PSX) + #include "fmt/psx.h" +#endif + +bool readLevelStream(DataStream& f) +{ +#ifdef CPU_BIG_ENDIAN + f.bigEndian = true; +#endif + +#if (USE_FMT & LVL_FMT_PKD) + if (read_PKD(f)) + return true; +#endif + +#if (USE_FMT & LVL_FMT_PHD) + if (read_PHD(f)) + return true; +#endif + +#if (USE_FMT & LVL_FMT_PSX) + if (read_PSX(f)) + return true; +#endif + + //LOG("Unsupported level format\n"); + ASSERT(false); + + return false; +} + +#ifdef USE_VRAM_MESH +struct MeshVRAM +{ + const Mesh* meshROM; + const Mesh* meshVRAM; +}; + +MeshVRAM* vramMeshes = (MeshVRAM*)gSpheres; // use temporary memory +int32 vramMeshesCount; + +uint8* pushToVRAM(uint8* ptr, Model* model) +{ + for (int32 i = 0; i < model->count; i++) + { + const Mesh* mesh = meshes[model->start + i]; + + int32 vramMeshIndex = -1; + + for (int32 i = 0; i < vramMeshesCount; i++) + { + if (vramMeshes[i].meshROM == mesh) + { + vramMeshIndex = i; + break; + } + } + + if (vramMeshIndex == -1) + { + int32 meshSize = sizeof(Mesh) + + mesh->vCount * sizeof(MeshVertex) + + mesh->rCount * sizeof(MeshQuad) + + mesh->tCount * sizeof(MeshTriangle); + + if (meshSize & 3) + { + meshSize += 2; + } + + vramMeshes[vramMeshesCount].meshROM = mesh; + vramMeshes[vramMeshesCount].meshVRAM = (Mesh*)ptr; + vramMeshIndex = vramMeshesCount++; + + memcpy(ptr, mesh, meshSize); + + ptr += meshSize; + } + + meshes[level.meshesCount + i] = vramMeshes[vramMeshIndex].meshVRAM; + } + model->start = level.meshesCount; + level.meshesCount += model->count; + + return ptr; +} +#endif + +void readLevel(const uint8* data) +{ +//#ifdef ROM_READ + dynSectorsCount = 0; +//#endif + + memset(&level, 0, sizeof(level)); + + gAnimTexFrame = 0; + + DataStream f(data, 0); + readLevelStream(f); + + // prepare models // TODO prerocess + memset(models, 0, sizeof(models)); + for (int32 i = 0; i < level.modelsCount; i++) + { + const Model* model = level.models + i; + ASSERT(model->type < MAX_MODELS); + models[model->type] = *model; + } + level.models = models; + + // prepare meshes + for (int32 i = 0; i < level.meshesCount; i++) + { + meshes[i] = (Mesh*)((uint8*)level.meshes + level.meshOffsets[i]); + } + level.meshes = meshes; + + // prepare static meshes // TODO preprocess + memset(staticMeshes, 0, sizeof(staticMeshes)); + for (int32 i = 0; i < level.staticMeshesCount; i++) + { + const StaticMesh* staticMesh = level.staticMeshes + i; + + ASSERT(staticMesh->id < MAX_STATIC_MESHES); + staticMeshes[staticMesh->id] = *staticMesh; + } + level.staticMeshes = staticMeshes; + + // prepare sprites // TODO preprocess + for (int32 i = 0; i < level.spriteSequencesCount; i++) + { + const SpriteSeq* spriteSeq = level.spriteSequences + i; + + if (spriteSeq->type >= TR1_ITEM_MAX) // WTF? + continue; + + Model* m = models + spriteSeq->type; + m->count = int8(spriteSeq->count); + m->start = spriteSeq->start; + } + +// experimental +#if defined(USE_VRAM_MESH) || defined(USE_VRAM_ROOM) + vramPtr = (uint8*)0x06014000; +#endif + +#ifdef USE_VRAM_MESH // should be per level or dynamic + vramMeshesCount = 0; + vramPtr = pushToVRAM(vramPtr, models + ITEM_LARA); + vramPtr = pushToVRAM(vramPtr, models + ITEM_LARA_PISTOLS); + vramPtr = pushToVRAM(vramPtr, models + ITEM_LARA_SHOTGUN); + //vramPtr = pushToVRAM(vramPtr, models + ITEM_LARA_MAGNUMS); + //vramPtr = pushToVRAM(vramPtr, models + ITEM_LARA_UZIS); + vramPtr = pushToVRAM(vramPtr, models + ITEM_WOLF); + vramPtr = pushToVRAM(vramPtr, models + ITEM_BAT); + vramPtr = pushToVRAM(vramPtr, models + ITEM_BRIDGE_FLAT); + vramPtr = pushToVRAM(vramPtr, models + ITEM_BRIDGE_TILT_1); + vramPtr = pushToVRAM(vramPtr, models + ITEM_BRIDGE_TILT_2); + //printf("%d\n", vramPtr - (uint8*)0x06014000); +#endif +} + +void animTexturesShift() +{ + const uint16* data = level.animTexData; + + int32 texRangesCount = *data++; + + for (int32 i = 0; i < texRangesCount; i++) + { + int32 count = *data++; + + Texture tmp = level.textures[*data]; + while (count > 0) + { + level.textures[data[0]] = level.textures[data[1]]; + data++; + count--; + } + level.textures[*data++] = tmp; + } +} + +#define FADING_RATE_SHIFT 4 + +void updateFading(int32 frames) +{ + if (gBrightness == 0) + return; + + frames <<= FADING_RATE_SHIFT; + + if (gBrightness < 0) + { + gBrightness += frames; + if (gBrightness > 0) { + gBrightness = 0; + } + } + + if (gBrightness > 0) + { + gBrightness -= frames; + if (gBrightness < 0) { + gBrightness = 0; + } + } + + palSet(level.palette, gSettings.video_gamma << 4, gBrightness); +} + +void updateLevel(int32 frames) +{ + updateFading(frames); + + gCausticsFrame += frames; + + gAnimTexFrame += frames; + while (gAnimTexFrame > 5) + { + animTexturesShift(); + gAnimTexFrame -= 5; + } +} + +int32 getAmbientTrack() +{ + return gLevelInfo[gLevelID].track; +} + +bool isCutsceneLevel() +{ + return (gLevelID == LVL_TR1_CUT_1) || + (gLevelID == LVL_TR1_CUT_2) || + (gLevelID == LVL_TR1_CUT_3) || + (gLevelID == LVL_TR1_CUT_4); +} + +#endif diff --git a/src/fixed/nav.h b/src/fixed/nav.h new file mode 100644 index 00000000..136c7cff --- /dev/null +++ b/src/fixed/nav.h @@ -0,0 +1,227 @@ +#ifndef H_NAV +#define H_NAV + +#include "common.h" + +#define NAV_INDEX 0x3FFF +#define NAV_WEIGHT 0x7FFF +#define NAV_BLOCKED 0x8000 + +void Nav::init(uint32 boxIndex) +{ + switch (stepHeight) + { + case 256 : zoneType = ZONE_GROUND_1; break; + case 512 : zoneType = ZONE_GROUND_2; break; + default : zoneType = ZONE_FLY; + } + + weight = 0; + endBox = NO_BOX; + nextBox = NO_BOX; + + headBox = NO_BOX; + tailBox = NO_BOX; + + mask = 0x400; + + for (int32 i = 0; i < level.boxesCount; i++) + { + cells[i].end = NO_BOX; + cells[i].next = NO_BOX; + cells[i].weight = 0; + } + + const uint16* defZones = level.zones[0][zoneType]; + const uint16* altZones = level.zones[1][zoneType]; + + uint16 defZone = defZones[boxIndex]; + uint16 altZone = altZones[boxIndex]; + + cellsCount = 0; + Nav::Cell* cell = cells; + + for (int32 i = 0; i < level.boxesCount; i++) + { + if ((defZone == defZones[i]) || (altZone == altZones[i])) + { + (*cell++).boxIndex = i; + cellsCount++; + } + } + + ASSERT(cellsCount > 0); +} + +vec3i Nav::getWaypoint(uint32 boxIndex, const vec3i &from) +{ + if (nextBox != NO_BOX && nextBox != endBox) + { + endBox = nextBox; + + Nav::Cell &cell = cells[endBox]; + + if (cell.next == NO_BOX && tailBox != endBox) + { + cell.next = headBox; + + if (headBox == NO_BOX) { + tailBox = endBox; + } + + headBox = endBox; + } + + weight++; + cell.weight = weight; + cell.end = NO_BOX; + } + + if (headBox != NO_BOX) + { + const uint16* zones = level.zones[gSaveGame.flipped][zoneType]; + uint16 zone = zones[headBox]; + + for (int32 i = 0; (i < NAV_STEPS) && (headBox != NO_BOX); i++) + { + search(zone, zones); + } + } + + if (boxIndex == endBox) + return pos; + + vec3i wp = from; + + if (boxIndex == NO_BOX) + return wp; + + const Box* box = level.boxes + boxIndex; + + int32 bMinX = (box->minX << 10); + int32 bMaxX = (box->maxX << 10) - 1; + int32 bMinZ = (box->minZ << 10); + int32 bMaxZ = (box->maxZ << 10) - 1; + + int32 minX = bMinX; + int32 maxX = bMaxX; + int32 minZ = bMinZ; + int32 maxZ = bMaxZ; + + while ((boxIndex != NO_BOX) && !(level.boxes[boxIndex].overlap & mask)) + { + box = level.boxes + boxIndex; + + bMinX = (box->minX << 10); + bMaxX = (box->maxX << 10) - 1; + bMinZ = (box->minZ << 10); + bMaxZ = (box->maxZ << 10) - 1; + + if (from.x >= bMinX && from.x <= bMaxX && from.z >= bMinZ && from.z <= bMaxZ) + { + minX = bMinX; + maxX = bMaxX; + minZ = bMinZ; + maxZ = bMaxZ; + } else { + if ((wp.x < bMinX) || (wp.x > bMaxX)) + { + if ((wp.z < minZ) || (wp.z > maxZ)) + break; + wp.x = X_CLAMP(wp.x, bMinX + 512, bMaxX - 512); + minZ = X_MAX(minZ, bMinZ); + maxZ = X_MIN(maxZ, bMaxZ); + } + + if ((wp.z < bMinZ) || (wp.z > bMaxZ)) + { + if ((wp.x < minX) || (wp.x > maxX)) + break; + wp.z = X_CLAMP(wp.z, bMinZ + 512, bMaxZ - 512); + minX = X_MAX(minX, bMinX); + maxX = X_MIN(maxX, bMaxX); + } + } + + if (boxIndex == endBox) + { + wp.x = X_CLAMP(wp.x, bMinX + 512, bMaxX - 512); + wp.z = X_CLAMP(wp.z, bMinZ + 512, bMaxZ - 512); + break; + } + + boxIndex = cells[boxIndex].end; + } + + wp.y = box->floor - ((zoneType == ZONE_FLY) ? 384 : 0); // TODO check for 320 + + return wp; +} + +void Nav::search(uint16 zone, const uint16* zones) +{ + Nav::Cell &curr = cells[headBox]; + const Box &b = level.boxes[headBox]; + + uint16 overlapIndex = b.overlap & NAV_INDEX; + + bool end = false; + + do { + uint16 boxIndex = level.overlaps[overlapIndex++]; + + end = boxIndex & NAV_BLOCKED; + if (end) { + boxIndex &= NAV_INDEX; + } + + if (zone != zones[boxIndex]) + continue; + + int32 diff = level.boxes[boxIndex].floor - b.floor; + if (diff > stepHeight || diff < dropHeight) + continue; + + Nav::Cell &next = cells[boxIndex]; + + uint16 cWeight = curr.weight & NAV_WEIGHT; + uint16 nWeight = next.weight & NAV_WEIGHT; + + if (cWeight < nWeight) + continue; + + if (curr.weight & NAV_BLOCKED) + { + if (cWeight == nWeight) + continue; + + next.weight = curr.weight; + } + else + { + if ((cWeight == nWeight) && !(next.weight & NAV_BLOCKED)) + continue; + + if (level.boxes[boxIndex].overlap & mask) + { + next.weight = curr.weight | NAV_BLOCKED; + } + else + { + next.weight = curr.weight; + next.end = headBox; + } + } + + if (next.next == NO_BOX && boxIndex != tailBox) + { + cells[tailBox].next = boxIndex; + tailBox = boxIndex; + } + } while (!end); + + headBox = curr.next; + curr.next = NO_BOX; +} + +#endif diff --git a/src/fixed/object.h b/src/fixed/object.h new file mode 100644 index 00000000..0945879a --- /dev/null +++ b/src/fixed/object.h @@ -0,0 +1,1128 @@ +#ifndef H_OBJECT +#define H_OBJECT + +#include "item.h" +#include "lara.h" +#include "inventory.h" + +vec3i getBlockOffset(int16 angleY, int32 offset) +{ + if (angleY == ANGLE_0) + return _vec3i(0, 0, -offset); + if (angleY == ANGLE_180) + return _vec3i(0, 0, offset); + if (angleY == ANGLE_90) + return _vec3i(-offset, 0, 0); + return _vec3i(offset, 0, 0); +} + +struct Limit +{ + AABBs box; + vec3s angle; +}; + +// armcpp won't initialize structs + +const int16 LIMIT_SWITCH[] = { + -200, 200, 0, 0, 312, 512, + ANGLE(10), ANGLE(30), ANGLE(10) +}; + +const int16 LIMIT_SWITCH_UW[] = { + -1024, 1024, -1024, 1024, -1024, 1024, + ANGLE(80), ANGLE(80), ANGLE(80) +}; + +const int16 LIMIT_BLOCK[] = { + -300, 300, 0, 0, -692, -512, + ANGLE(10), ANGLE(30), ANGLE(10) +}; + +const int16 LIMIT_PICKUP[] = { + -256, 256, -100, 100, -256, 100, + ANGLE(10), 0, 0 +}; + +const int16 LIMIT_PICKUP_UW[] = { + -512, 512, -512, 512, -512, 512, + ANGLE(45), ANGLE(45), ANGLE(45) +}; + +const int16 LIMIT_HOLE[] = { + -200, 200, 0, 0, 312, 512, + ANGLE(10), ANGLE(30), ANGLE(10) +}; + + +struct Object : ItemObj +{ + Object(Room* room) : ItemObj(room) {} + + virtual void update() + { + animProcess(); + } + + bool isActive() + { + if (((flags & ITEM_FLAG_MASK) != ITEM_FLAG_MASK) || (timer == -1)) + return (flags & ITEM_FLAG_REVERSE) != 0; + + if (timer == 0) + return (flags & ITEM_FLAG_REVERSE) == 0; + + timer--; + + if (timer == 0) + timer = -1; + + return (flags & ITEM_FLAG_REVERSE) == 0; + } + + bool checkLimit(Lara* lara, const int16* limitData) + { + Limit* limit = (Limit*)limitData; + + int16 ax = abs(lara->angle.x - angle.x); + int16 ay = abs(lara->angle.y - angle.y); + int16 az = abs(lara->angle.z - angle.z); + + if (ax > limit->angle.x || ay > limit->angle.y || az > limit->angle.z) + return false; + + vec3i d = lara->pos - pos; + + matrixSetIdentity(); + matrixRotateZ(-angle.z); + matrixRotateX(-angle.x); + matrixRotateY(-angle.y); + + const Matrix &m = matrixGet(); + + vec3i p; + p.x = DP33(m.e00, m.e01, m.e02, d.x, d.y, d.z) >> FIXED_SHIFT; + p.y = DP33(m.e10, m.e11, m.e12, d.x, d.y, d.z) >> FIXED_SHIFT; + p.z = DP33(m.e20, m.e21, m.e22, d.x, d.y, d.z) >> FIXED_SHIFT; + + return boxContains(limit->box, p); + } + + void collideDefault(Lara* lara, CollisionInfo* cinfo) + { + if (!updateHitMask(lara, cinfo)) + return; + + if (!cinfo->enemyPush) + return; + + collidePush(lara, cinfo, false); + } +}; + + +struct SpriteEffect : ItemObj +{ + SpriteEffect(Room* room) : ItemObj(room) + { + tick = 0; + timer = 0; + hSpeed = 0; + frameIndex = 0; + activate(); + } + + virtual void update() + { + tick++; + if (tick >= timer) + { + tick = 0; + + if (flags & ITEM_FLAG_ANIMATED) + { + frameIndex++; + if (frameIndex >= -level.models[type].count) + { + remove(); + return; + } + } else { + remove(); + return; + } + } + + if (hSpeed) + { + int32 s, c; + sincos(angle.y, s, c); + pos.x += s * hSpeed >> FIXED_SHIFT; + pos.z += c * hSpeed >> FIXED_SHIFT; + } + } +}; + + +struct Bubble : ItemObj +{ + Bubble(Room* room) : ItemObj(room) + { + soundPlay(SND_BUBBLE, &pos); + frameIndex = rand_draw() % (-level.models[type].count); + vSpeed = -(10 + (rand_draw() % 6)); + angle = _vec3s(0, 0, ANGLE_90); + activate(); + + roomFloor = getWaterLevel(); + } + + virtual void update() + { + pos.y += vSpeed; + if (roomFloor > pos.y) + { + remove(); + return; + } + + angle.x += ANGLE(9); + angle.z += ANGLE(13); + + int32 dx = sin(angle.x); + int32 dz = sin(angle.z); + + pos.x += dx * 11 >> FIXED_SHIFT; + pos.z += dz * 8 >> FIXED_SHIFT; + + Room* nextRoom = room->getRoom(pos.x, pos.y, pos.z); + if (nextRoom != room) + { + room->remove(this); + nextRoom->add(this); + } + } +}; + + +struct ViewTarget : Object +{ + ViewTarget(Room* room) : Object(room) {} + + virtual void draw() {} +}; + + +struct Waterfall : Object +{ + Waterfall(Room* room) : Object(room) {} + + virtual void draw() {} +}; + + +struct LavaEmitter : Object +{ + LavaEmitter(Room* room) : Object(room) {} + + virtual void draw() {} +}; + + +struct Door : Object +{ + enum { + STATE_CLOSE, + STATE_OPEN + }; + + Door(Room* room) : Object(room) + { + flags |= ITEM_FLAG_COLLISION; + action(true); + } + + virtual void update() + { + if (isActive()) { + if (state == STATE_CLOSE) { + goalState = STATE_OPEN; + } else { + action(false); + } + } else { + if (state == STATE_OPEN) { + goalState = STATE_CLOSE; + } else { + action(true); + } + } + + animProcess(); + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + // TODO door collision + } + + void action(bool close) + { + vec3i nextPos = getBlockOffset(angle.y, 1); + nextPos.x = pos.x + (nextPos.x << 10); + nextPos.z = pos.z + (nextPos.z << 10); + + setDoorState(close, false, room, nextPos.x, nextPos.z); // use the sector behind the door + + // TODO flip rooms + } + + void setDoorState(bool close, bool behind, Room* room, int32 x, int32 z) + { + room->modify(); // make room->sectors dynamic (non ROM) + + Sector* sector = (Sector*)room->getSector(x, z); // now we can modify room sectors + + Room* nextRoom; + + if (close) { + nextRoom = sector->getNextRoom(); + + sector->floorIndex = 0; + sector->boxIndex = NO_BOX; + sector->roomBelow = NO_ROOM; + sector->floor = NO_FLOOR; + sector->roomAbove = NO_ROOM; + sector->ceiling = NO_FLOOR; + } else { + *sector = room->data.sectors[sector - room->sectors]; + + nextRoom = sector->getNextRoom(); + } + + // TODO modify level.boxes + + if (!behind && nextRoom) { + setDoorState(close, true, nextRoom, pos.x, pos.z); // use sector from item pos + } + } +}; + + +struct TrapDoor : Object +{ + enum { + STATE_CLOSE, + STATE_OPEN + }; + + TrapDoor(Room* room) : Object(room) {} + + virtual void update() + { + if (isActive()) { + if (state == STATE_CLOSE) { + goalState = STATE_OPEN; + } + } else { + if (state == STATE_OPEN) { + goalState = STATE_CLOSE; + } + } + + animProcess(); + } +}; + + +struct Gears : Object +{ + enum { + STATE_STATIC, + STATE_ROTATE + }; + + Gears(Room* room) : Object(room) {} + + virtual void update() + { + goalState = isActive() ? STATE_ROTATE : STATE_STATIC; + animProcess(); + } +}; + + +struct CinematicObject : Object +{ + CinematicObject(Room* room) : Object(room) + { + angle.y = 0; + + if (type == ITEM_CUT_1) + { + gCinematicCamera.view.pos = pos; + gCinematicCamera.view.room = room; + } + + flags |= ITEM_FLAG_SHADOW; + + activate(); + } + + virtual void update() + { + if (type == ITEM_CUT_1 || type == ITEM_CUT_2 || type == ITEM_CUT_3) + { + pos = playersExtra[0].camera.view.pos; + angle.y = playersExtra[0].camera.targetAngle.y; + } + animProcess(); + } +}; + + +struct Crystal : Object +{ + Crystal(Room* room) : Object(room) + { + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INVISIBLE; // disable crystals for now + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + // TODO + } +}; + + +struct Switch : Object +{ + enum { + STATE_UP, + STATE_DOWN + }; + + Switch(Room* room) : Object(room) {} + + virtual void update() + { + flags |= ITEM_FLAG_MASK; + if (!isActive()) + { + goalState = STATE_DOWN; + timer = 0; + } + Object::update(); + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (lara->extraL->weaponState != WEAPON_STATE_FREE) + return; + + if (!(lara->input & IN_ACTION)) + return; + + if (lara->state != Lara::STATE_STOP) + return; + + if (flags & ITEM_FLAG_STATUS) + return; + + if (!checkLimit(lara, LIMIT_SWITCH)) + return; + + lara->angle.y = angle.y; + + ASSERT(state == STATE_DOWN || state == STATE_UP); + + bool isDown = (state == STATE_DOWN); + + goalState = isDown ? STATE_UP : STATE_DOWN; + lara->animSkip(isDown ? Lara::STATE_SWITCH_DOWN : Lara::STATE_SWITCH_UP, Lara::STATE_STOP, true); + activate(); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_ACTIVE; + lara->extraL->weaponState = WEAPON_STATE_BUSY; + } + + bool use(int32 t) + { + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INACTIVE) + { + flags &= ~ITEM_FLAG_STATUS; + + if (t > 0 && state == Switch::STATE_UP) + { + if (t != 1) { + t *= 30; + } + timer = t; + flags |= ITEM_FLAG_STATUS_ACTIVE; + } else { + deactivate(); + } + return true; + } + + return false; + } +}; + + +struct SwitchWater : Switch +{ + SwitchWater(Room* room) : Switch(room) {} + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (lara->extraL->weaponState != WEAPON_STATE_FREE) + return; + + if (!(lara->input & IN_ACTION)) + return; + + if (lara->state != Lara::STATE_UW_TREAD) + return; + + if (!checkLimit(lara, LIMIT_SWITCH_UW)) + return; + + if (!lara->moveTo(_vec3i(0, 0, 108), this, true)) + return; + + lara->vSpeed = 0; // underwater speed + goalState = (state == STATE_UP) ? STATE_DOWN : STATE_UP; + + lara->animSkip(Lara::STATE_SWITCH_DOWN, Lara::STATE_UW_TREAD, true); + activate(); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_ACTIVE; + + //TODO TR2+ + //lara->weaponState = WEAPON_STATE_BUSY; + } +}; + + +struct Key : Object +{ + Key(Room* room) : Object(room) {} + + bool use(ItemObj* lara) + { + if (((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_ACTIVE) && (lara->extraL->weaponState == WEAPON_STATE_FREE)) // TODO check weapons + { + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INACTIVE; + return true; + } + return false; + } +}; + + +struct Pickup : Object +{ + Pickup(Room* room) : Object(room) + { + frameIndex = 0; + } + + bool use() + { + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INVISIBLE) + { + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INACTIVE; + return true; + } + return false; + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + angle.y = lara->angle.y; + angle.z = 0; + + if (lara->waterState == WATER_STATE_ABOVE || lara->waterState == WATER_STATE_WADE) + { + angle.x = 0; + + if (!checkLimit(lara, LIMIT_PICKUP)) + return; + + if (lara->state == Lara::STATE_PICKUP) + { + if (!lara->animIsEnd(23)) + return; + + inventory.add((ItemType)type); + gSaveGame.pickups++; + room->remove(this); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INVISIBLE; + } + else if (lara->state == Lara::STATE_STOP) + { + if (lara->extraL->weaponState != WEAPON_STATE_FREE) + return; + + if (!(lara->input & IN_ACTION)) + return; + + if (!lara->moveTo(_vec3i(0, 0, -100), this, false)) + return; + + lara->animSkip(Lara::STATE_PICKUP, Lara::STATE_STOP); + lara->extraL->weaponState = WEAPON_STATE_BUSY; + } + } + + if (lara->waterState == WATER_STATE_UNDER) + { + angle.x = ANGLE(-25); + + if (!checkLimit(lara, LIMIT_PICKUP_UW)) + return; + + if (lara->state == Lara::STATE_PICKUP) + { + if (!lara->animIsEnd(14)) + return; + + inventory.add((ItemType)type); + gSaveGame.pickups++; + room->remove(this); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_INVISIBLE; + } + else if (lara->state == Lara::STATE_UW_TREAD) + { + // TODO TR2+ + //if (lara->weaponState != WEAPON_STATE_FREE) + // return; + + if (!(lara->input & IN_ACTION)) + return; + + if (!lara->moveTo(_vec3i(0, -200, -350), this, true)) + return; + + lara->animSkip(Lara::STATE_PICKUP, Lara::STATE_UW_TREAD); + + // TODO TR2+ + //lara->weaponState = WEAPON_STATE_BUSY; // TODO check CMD_EMPTY event + } + } + } +}; + + +bool useSwitch(ItemObj* item, int32 timer) +{ + return ((Switch*)item)->use(timer); +} + +bool useKey(ItemObj* item, ItemObj* lara) +{ + return ((Key*)item)->use(lara); +} + +bool usePickup(ItemObj* item) +{ + return ((Pickup*)item)->use(); +} + +struct Hole : Object // parent class for KeyHole and PuzzleHole +{ + Hole(Room* room) : Object(room) {} + + void apply(int32 offset, Lara* lara, Lara::State stateUse) + { + if (lara->extraL->weaponState != WEAPON_STATE_FREE) + return; + + if (flags & ITEM_FLAG_STATUS) + return; + + if (lara->state != Lara::STATE_STOP || lara->animIndex != Lara::ANIM_STAND_NORMAL) + return; + + if (!(lara->input & IN_ACTION) && (inventory.useSlot == SLOT_MAX)) + return; + + if (!checkLimit(lara, LIMIT_HOLE)) + return; + + if (inventory.useSlot == SLOT_MAX) + { + if (inventory.numKeys > 0) { + inventory.open(lara, INV_PAGE_USE, type); + return; + } + } else { + if (inventory.applyItem(this)) + { + lara->moveTo(_vec3i(0, 0, offset), this, false); + lara->animSkip(stateUse, Lara::STATE_STOP); + lara->extraL->weaponState = WEAPON_STATE_BUSY; + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_ACTIVE; + return; + } + inventory.useSlot = SLOT_MAX; + } + soundPlay(SND_NO, &lara->pos); + } +}; + + +struct KeyHole : Hole +{ + KeyHole(Room* room) : Hole(room) {} + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + apply(362, lara, Lara::STATE_USE_KEY); + } +}; + + +struct PuzzleHole : Hole +{ + PuzzleHole(Room* room) : Hole(room) {} + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (lara->state == Lara::STATE_USE_PUZZLE) + { + if (!checkLimit(lara, LIMIT_HOLE)) + return; + + if (!lara->animIsEnd(28)) + return; + + switch (type) { + case ITEM_PUZZLEHOLE_1 : type = ITEM_PUZZLEHOLE_DONE_1; break; + case ITEM_PUZZLEHOLE_2 : type = ITEM_PUZZLEHOLE_DONE_2; break; + case ITEM_PUZZLEHOLE_3 : type = ITEM_PUZZLEHOLE_DONE_3; break; + case ITEM_PUZZLEHOLE_4 : type = ITEM_PUZZLEHOLE_DONE_4; break; + } + + return; + } + + apply(327, lara, Lara::STATE_USE_PUZZLE); + } +}; + + +struct TrapFloor : Object +{ + enum { + STATE_STATIC, + STATE_SHAKE, + STATE_FALL, + STATE_DOWN + }; + + TrapFloor(Room* room) : Object(room) {} + + virtual void update() + { + switch (state) + { + case STATE_STATIC: + if (getLara(pos)->pos.y != pos.y - 512) + { + flags &= ~ITEM_FLAG_STATUS; + deactivate(); + return; + } + goalState = STATE_SHAKE; + break; + case STATE_SHAKE: + goalState = STATE_FALL; + break; + case STATE_FALL: + if (goalState != STATE_DOWN) + { + flags |= ITEM_FLAG_GRAVITY; + } + break; + } + + animProcess(); + + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INACTIVE) + { + deactivate(); + return; + } + + if (state == STATE_FALL) { + updateRoom(); + } + + if (state == STATE_FALL && pos.y >= roomFloor) + { + pos.y = roomFloor; + vSpeed = 0; + flags &= ~ITEM_FLAG_GRAVITY; + goalState = STATE_DOWN; + } + } + +#ifdef LOD_TRAP_FLOOR + virtual void draw() + { + int32 oldAnimIndex = animIndex; + if ((state == STATE_STATIC) && level.models[ITEM_TRAP_FLOOR_LOD].type) { + type = ITEM_TRAP_FLOOR_LOD; + animIndex = level.models[type].animIndex; + } + Object::draw(); + type = ITEM_TRAP_FLOOR; + animIndex = oldAnimIndex; + } +#endif +}; + + +struct TrapSwingBlade : Object +{ + enum { + STATE_STATIC, + STATE_BEGIN, + STATE_SWING, + STATE_END + }; + + TrapSwingBlade(Room* room) : Object(room) + { + flags |= ITEM_FLAG_SHADOW; + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if ((flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_ACTIVE) + return; + + if (state != STATE_SWING) + return; + + if (!updateHitMask(lara, cinfo)) + return; + + vec3i offsetPos = _vec3i((rand_logic() - 0x4000) >> 8, -256 - (rand_logic() >> 6), (rand_logic() - 0x4000) >> 8); + int32 offsetAngle = (rand_logic() - 0x4000) >> 3; + lara->fxBlood(lara->pos + offsetPos, lara->angle.y + offsetAngle, lara->hSpeed); + lara->hit(100, pos, 0); // TODO TR2 50? + } + + virtual void update() + { + if (isActive()) { + if (state == STATE_STATIC) { + goalState = STATE_SWING; + } + } else { + if (state == STATE_SWING) { + goalState = STATE_STATIC; + } + } + + animProcess(); + } +}; + + +struct Dart : Object +{ + Dart(Room* room) : Object(room) + { + flags |= ITEM_FLAG_SHADOW; + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (!updateHitMask(lara, cinfo)) + return; + + if (hitMask) + { + lara->fxBlood(pos, lara->angle.y, lara->hSpeed); + lara->hit(50, pos, 0); + } + } + + virtual void update() + { + animProcess(); + updateRoom(); + + if (pos.y < roomFloor) + return; + + remove(); + + fxRicochet(room, pos, false); + } +}; + + +struct TrapDartEmitter : Object +{ + enum { + STATE_IDLE, + STATE_FIRE + }; + + TrapDartEmitter(Room* room) : Object(room) {} + + virtual void update() + { + goalState = isActive() ? STATE_FIRE : STATE_IDLE; + + if (state == STATE_IDLE && state == goalState) + { + deactivate(); + return; + } + + if (state == STATE_FIRE && frameIndex == level.anims[animIndex].frameBegin) + { + vec3i p = getBlockOffset(angle.y, 412); + p.y = -512; + p += pos; + + ItemObj* dart = ItemObj::add(ITEM_DART, room, p, angle.y); + + if (dart) + { + soundPlay(SND_DART, &pos); + + dart->intensity = 0; + dart->flags &= ~ITEM_FLAG_STATUS; + dart->flags |= ITEM_FLAG_STATUS_ACTIVE; + dart->activate(); + + fxSmoke(p); + } + } + + animProcess(); + } +}; + + +struct Block : Object +{ + enum { + STATE_NONE, + STATE_READY, + STATE_PUSH, + STATE_PULL + }; + + Block(Room* room) : Object(room) + { + if ((flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_INVISIBLE) { + updateFloor(-1024); + } + } + + void updateFloor(int32 offset) + { + room->modify(); + + Sector* sector = (Sector*)room->getSector(pos.x, pos.z); + + if (sector->floor == NO_FLOOR) { + sector->floor = sector->ceiling + (offset >> 8); + } else { + sector->floor += (offset >> 8); + if (sector->floor == sector->ceiling) { + sector->floor = NO_FLOOR; + } + } + + // TODO modify level.boxes + } + + bool checkBlocking() + { + const Sector* sector = room->getSector(pos.x, pos.z); + + return (sector->floor == NO_FLOOR) || ((sector->floor << 8) + 1024 == pos.y); + } + + bool checkObstacles(int32 x, int32 z, int32 height) + { + Room* nextRoom = room->getRoom(x, pos.y, z); + const Sector* sector = nextRoom->getSector(x, z); + + int32 floor = pos.y; + int32 ceiling = pos.y - height; + + if ((sector->floor << 8) != floor) + return false; + + nextRoom = nextRoom->getRoom(x, ceiling, z); + sector = nextRoom->getSector(x, z); + + if ((sector->ceiling << 8) > ceiling) + return false; + + return true; + } + + bool checkPush() + { + if (!checkBlocking()) + return false; + + vec3i offset = getBlockOffset(angle.y, -1024); + + return checkObstacles(pos.x + offset.x, pos.z + offset.z, 1024); + } + + bool checkPull(ItemObj* lara) + { + if (!checkBlocking()) + return false; + + vec3i offset = getBlockOffset(angle.y, 1024); + + if (!checkObstacles(pos.x + offset.x, pos.z + offset.z, 1024)) + return false; + + return checkObstacles(lara->pos.x + offset.x, lara->pos.z + offset.z, LARA_HEIGHT); + } + + virtual void collide(Lara* lara, CollisionInfo* cinfo) + { + if (!(lara->input & IN_ACTION)) + return; + + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_ACTIVE) + return; + + if (lara->pos.y != pos.y) + return; + + uint16 quadrant = uint16(lara->angle.y + ANGLE_45) >> ANGLE_SHIFT_90; + + if ((lara->animIndex == Lara::ANIM_BLOCK_READY) && (lara->input & (IN_UP | IN_DOWN))) + { + if (!lara->animIsEnd(0)) + return; + + if (!checkLimit(lara, LIMIT_BLOCK)) + return; + + if (lara->input & IN_UP) + { + if (!checkPush()) + return; + + lara->goalState = Lara::STATE_BLOCK_PUSH; + goalState = STATE_PUSH; + } + else + { + if (!checkPull(lara)) + return; + + lara->goalState = Lara::STATE_BLOCK_PULL; + goalState = STATE_PULL; + } + + updateFloor(1024); + + activate(); + flags &= ~ITEM_FLAG_STATUS; + flags |= ITEM_FLAG_STATUS_ACTIVE; + + animProcess(); + lara->animProcess(); + } + + if (lara->state == Lara::STATE_STOP) + { + if (lara->extraL->weaponState != WEAPON_STATE_FREE) + return; + + if (lara->input & (IN_UP | IN_DOWN)) + return; + + angle.y = quadrant * ANGLE_90; + + if (!checkLimit(lara, LIMIT_BLOCK)) + return; + + lara->goalState = Lara::STATE_BLOCK_READY; + lara->angle.y = angle.y; + lara->alignWall(LARA_RADIUS); + lara->animProcess(); + if (lara->state == Lara::STATE_BLOCK_READY) { + lara->setWeaponState(WEAPON_STATE_BUSY); + } + } + } + + virtual void update() + { + if (flags & ITEM_FLAG_ONCE) + { + updateFloor(1024); + remove(); + return; + } + + animProcess(); + + updateRoom(); // it'll get roomFloor and gLastFloorData + + if (pos.y > roomFloor) + { + flags |= ITEM_FLAG_GRAVITY; + } + else if (flags & ITEM_FLAG_GRAVITY) + { + flags &= ~(ITEM_FLAG_GRAVITY | ITEM_FLAG_STATUS); + flags |= ITEM_FLAG_STATUS_INACTIVE; + pos.y = roomFloor; + // TODO EarthQuake + playSound 70 (Thor room) + } + + if ((flags & ITEM_FLAG_STATUS) == ITEM_FLAG_STATUS_INACTIVE) + { + deactivate(); + flags &= ~ITEM_FLAG_STATUS; + + updateFloor(-1024); + + checkTrigger(gLastFloorData, NULL); + } + } + + virtual uint8* load(uint8* data) + { + if ((flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_INVISIBLE) { + updateFloor(1024); + } + + data = ItemObj::load(data); + + if ((flags & ITEM_FLAG_STATUS) != ITEM_FLAG_STATUS_INVISIBLE) { + updateFloor(-1024); + } + + return data; + } +}; + +#endif diff --git a/src/fixed/render/gl1.cpp b/src/fixed/render/gl1.cpp new file mode 100644 index 00000000..8068dac7 --- /dev/null +++ b/src/fixed/render/gl1.cpp @@ -0,0 +1,486 @@ +#ifndef H_GL1 +#define H_GL1 + +#include +#include +#include + +#define FIX2FLT (1.0f / 0x4000) + +#ifdef __WIN32__ +extern HWND hWnd; +extern HDC hDC; +HGLRC hRC; + +float FRAME_PERSP; + +#define FACE_TEXTURE 0x07FF + +#define MAX_TEX_TILES 16 + +GLuint texTiles[MAX_TEX_TILES]; +GLuint texBackground; +/* +struct RoomBufVertex +{ + uint8 x, y, z, _pad1; + uint8 r, g, b, _pad2; + int8 nx, ny, nz, _pad3; + uint16 u, v; +}; + +struct RoomInst +{ + struct Part + { + int32 tile; + // + }; + + RoomInst(Room* room) + { + RoomBufVertex vertices[0xFFFF]; + uint16 indices[1024]; + } +}; +*/ +void renderInit() +{ + PIXELFORMATDESCRIPTOR pfd; + memset(&pfd, 0, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.cColorBits = 32; + pfd.cRedBits = 8; + pfd.cGreenBits = 8; + pfd.cBlueBits = 8; + pfd.cAlphaBits = 8; + pfd.cDepthBits = 24; + + int format = ChoosePixelFormat(hDC, &pfd); + SetPixelFormat(hDC, format, &pfd); + hRC = wglCreateContext(hDC); + + wglMakeCurrent(hDC, hRC); + + glClearColor(0, 0, 0, 1); + + glEnable(GL_CULL_FACE); + //glEnable(GL_SCISSOR_TEST); + glEnable(GL_DEPTH_TEST); + glEnable(GL_ALPHA_TEST); + + glFrontFace(GL_CW); + glCullFace(GL_BACK); + glDepthMask(GL_TRUE); + glAlphaFunc(GL_GREATER, 0.25f); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glScalef(1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f); + + glMatrixMode(GL_MODELVIEW); +} + +void renderFree() +{ + wglMakeCurrent(0, 0); + wglDeleteContext(hRC); + ReleaseDC(hWnd, hDC); +} + +void renderSwap() +{ + SwapBuffers(hDC); + + float aspect = float(FRAME_WIDTH) / float(FRAME_HEIGHT); + FRAME_PERSP = aspect / tanf(60.0f * 0.5f * 3.1495f / 180.0f); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0f, aspect, 0.1f, 1024 * 16); + glScalef(1, -1, 1); + + glMatrixMode(GL_MODELVIEW); + + glViewport(0, 0, FRAME_WIDTH, FRAME_HEIGHT); +} +#endif + +void renderLevelInit() +{ + uint8 data[256 * 256 * 4]; + + glGenTextures(MAX_TEX_TILES, texTiles); + + for (int32 i = 0; i < level.tilesCount; i++) + { + const uint8* idx = level.tiles + i * 256 * 256; + + for (int32 j = 0; j < 256 * 256 * 4; j += 4) + { + int32 index = *idx++; + const uint8* c = (uint8*)level.palette + index * 3; + data[j + 0] = c[0]; + data[j + 1] = c[1]; + data[j + 2] = c[2]; + data[j + 3] = index ? 255 : 0; + } + + glBindTexture(GL_TEXTURE_2D, texTiles[i]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + } +} + +void renderLevelFree() +{ + // +} + +void setViewport(const RectMinMax &vp) +{ + //glScissor(vp.x0, FRAME_HEIGHT - vp.y1, vp.x1 - vp.x0, vp.y1 - vp.y0); + viewport = vp; +} + +void setPaletteIndex(int32 index) +{ + +} + +void clear() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + +void updateProjMatrix() +{ + glMatrixMode(GL_PROJECTION); + // + glMatrixMode(GL_MODELVIEW); +} + +void updateViewMatrix() +{ + const Matrix &m = matrixGet(); + float f[4][4]; + f[0][0] = m.e00 * FIX2FLT; + f[0][1] = m.e10 * FIX2FLT; + f[0][2] = -m.e20 * FIX2FLT; + f[0][3] = 0.0f; + + f[1][0] = m.e01 * FIX2FLT; + f[1][1] = m.e11 * FIX2FLT; + f[1][2] = -m.e21 * FIX2FLT; + f[1][3] = 0.0f; + + f[2][0] = m.e02 * FIX2FLT; + f[2][1] = m.e12 * FIX2FLT; + f[2][2] = -m.e22 * FIX2FLT; + f[2][3] = 0.0f; + + f[3][0] = m.e03 * FIX2FLT; + f[3][1] = m.e13 * FIX2FLT; + f[3][2] = -m.e23 * FIX2FLT; + f[3][3] = 1.0f; + + glLoadMatrixf(&f[0][0]); +} + +void renderRoom(const Room* room) +{ + updateViewMatrix(); + + const RoomVertex* vertices = room->data.vertices; + + int32 tileIndex = -1; + int16 uv[4][2]; + + glEnable(GL_TEXTURE_2D); + + for (int32 i = 0; i < room->info->quadsCount; i++) + { + const RoomQuad* f = room->data.quads + i; + const Texture* tex = level.textures + (f->flags & FACE_TEXTURE); + + uint32 uv01 = tex->uv01; + uint32 uv23 = tex->uv23; + + uv[0][0] = (uv01 >> 8) & 0xFF; + uv[0][1] = (uv01 >> 24) & 0xFF; + uv[1][0] = (uv01) & 0xFF; + uv[1][1] = (uv01 >> 16) & 0xFF; + uv[2][0] = (uv23 >> 8) & 0xFF; + uv[2][1] = (uv23 >> 24) & 0xFF; + uv[3][0] = (uv23) & 0xFF; + uv[3][1] = (uv23 >> 16) & 0xFF; + + if (tileIndex != tex->tile) + { + if (tileIndex != -1) { + glEnd(); + } + + tileIndex = tex->tile; + + + glBindTexture(GL_TEXTURE_2D, texTiles[tileIndex]); + glBegin(GL_QUADS); + } + + for (int32 j = 0; j < 4; j++) + { + const RoomVertex* v = vertices + f->indices[j]; + glColor3ub(v->g, v->g, v->g); + glTexCoord2sv(uv[j]); + glVertex3s(v->x << 8, v->y << 8, v->z << 8); + } + } + + if (tileIndex != -1) + { + glEnd(); + tileIndex = -1; + } + + for (int32 i = 0; i < room->info->trianglesCount; i++) + { + const RoomTriangle* f = room->data.triangles + i; + + const Texture* tex = level.textures + (f->flags & FACE_TEXTURE); + uint32 uv01 = tex->uv01; + uint32 uv23 = tex->uv23; + + uv[0][0] = (uv01 >> 8) & 0xFF; + uv[0][1] = (uv01 >> 24) & 0xFF; + uv[1][0] = (uv01) & 0xFF; + uv[1][1] = (uv01 >> 16) & 0xFF; + uv[2][0] = (uv23 >> 8) & 0xFF; + uv[2][1] = (uv23 >> 24) & 0xFF; + + if (tileIndex != tex->tile) + { + if (tileIndex != -1) { + glEnd(); + } + tileIndex = tex->tile; + + glBindTexture(GL_TEXTURE_2D, texTiles[tileIndex]); + glBegin(GL_TRIANGLES); + } + + for (int32 j = 0; j < 3; j++) + { + const RoomVertex* v = vertices + f->indices[j]; + glColor3ub(v->g, v->g, v->g); + glTexCoord2sv(uv[j]); + glVertex3s(v->x << 8, v->y << 8, v->z << 8); + } + } + + if (tileIndex != -1) + { + glEnd(); + } +} + +void renderMesh(const Mesh* mesh) +{ + updateViewMatrix(); + + const uint8* ptr = (uint8*)mesh + sizeof(Mesh); + + const MeshVertex* vertices = (MeshVertex*)ptr; + ptr += mesh->vCount * sizeof(MeshVertex); + ptr += mesh->vCount * (mesh->hasNormals ? sizeof(vec3s) : sizeof(uint16)); + + MeshQuad* r = (MeshQuad*)ptr; + ptr += mesh->rCount * sizeof(MeshQuad); + MeshTriangle* t = (MeshTriangle*)ptr; + ptr += mesh->tCount * sizeof(MeshTriangle); + MeshQuad* cr = (MeshQuad*)ptr; + ptr += mesh->crCount * sizeof(MeshQuad); + MeshTriangle* ct = (MeshTriangle*)ptr; + + glEnable(GL_TEXTURE_2D); + glColor3ub(255, 255, 255); + + int32 tileIndex = -1; + int16 uv[4][2]; + + for (int32 i = 0; i < mesh->rCount; i++) + { + const MeshQuad* f = r + i; + + const Texture* tex = level.textures + (f->flags & FACE_TEXTURE); + + uint32 uv01 = tex->uv01; + uint32 uv23 = tex->uv23; + + uv[0][0] = (uv01 >> 8) & 0xFF; + uv[0][1] = (uv01 >> 24) & 0xFF; + uv[1][0] = (uv01) & 0xFF; + uv[1][1] = (uv01 >> 16) & 0xFF; + uv[2][0] = (uv23 >> 8) & 0xFF; + uv[2][1] = (uv23 >> 24) & 0xFF; + uv[3][0] = (uv23) & 0xFF; + uv[3][1] = (uv23 >> 16) & 0xFF; + + if (tileIndex != tex->tile) + { + if (tileIndex != -1) { + glEnd(); + } + + tileIndex = tex->tile; + + glBindTexture(GL_TEXTURE_2D, texTiles[tileIndex]); + glBegin(GL_QUADS); + } + + for (int32 j = 0; j < 4; j++) + { + const MeshVertex* v = vertices + f->indices[j]; + ASSERT(f->indices[j] < mesh->vCount); + glTexCoord2sv(uv[j]); + glVertex3s(v->x, v->y, v->z); + } + } + + if (tileIndex != -1) + { + glEnd(); + tileIndex = -1; + } + + for (int32 i = 0; i < mesh->tCount; i++) + { + const MeshTriangle* f = t + i; + + const Texture* tex = level.textures + (f->flags & FACE_TEXTURE); + + uint32 uv01 = tex->uv01; + uint32 uv23 = tex->uv23; + + uv[0][0] = (uv01 >> 8) & 0xFF; + uv[0][1] = (uv01 >> 24) & 0xFF; + uv[1][0] = (uv01) & 0xFF; + uv[1][1] = (uv01 >> 16) & 0xFF; + uv[2][0] = (uv23 >> 8) & 0xFF; + uv[2][1] = (uv23 >> 24) & 0xFF; + + if (tileIndex != tex->tile) + { + if (tileIndex != -1) { + glEnd(); + } + + tileIndex = tex->tile; + + glBindTexture(GL_TEXTURE_2D, texTiles[tileIndex]); + glBegin(GL_TRIANGLES); + } + + for (int32 j = 0; j < 3; j++) + { + const MeshVertex* v = vertices + f->indices[j]; + ASSERT(f->indices[j] < mesh->vCount); + glTexCoord2sv(uv[j]); + glVertex3s(v->x, v->y, v->z); + } + } + + if (tileIndex != -1) + { + glEnd(); + } + + glDisable(GL_TEXTURE_2D); + + glBegin(GL_QUADS); + for (int32 i = 0; i < mesh->crCount; i++) + { + const MeshQuad* f = cr + i; + uint8* c = (uint8*)level.palette + f->flags * 3; + for (int32 j = 0; j < 4; j++) + { + const MeshVertex* v = vertices + f->indices[j]; + ASSERT(f->indices[j] < mesh->vCount); + glColor3ub(c[0], c[1], c[2]); + glVertex3s(v->x, v->y, v->z); + } + } + glEnd(); + + glBegin(GL_TRIANGLES); + for (int32 i = 0; i < mesh->ctCount; i++) + { + const MeshTriangle* f = ct + i; + uint8* c = (uint8*)level.palette + f->flags * 3; + for (int32 j = 0; j < 3; j++) + { + const MeshVertex* v = vertices + f->indices[j]; + ASSERT(f->indices[j] < mesh->vCount); + glColor3ub(c[0], c[1], c[2]); + glVertex3s(v->x, v->y, v->z); + } + } + glEnd(); +} + +void renderShadow(int32 x, int32 z, int32 sx, int32 sz) +{ + +} + +void renderSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index) +{ + +} + +void renderGlyph(int32 vx, int32 vy, int32 index) +{ + +} + +void renderBorder(int32 x, int32 y, int32 width, int32 height, int32 shade, int32 color1, int32 color2, int32 z) +{ + +} + +void renderBar(int32 x, int32 y, int32 width, int32 value, BarType type) +{ + +} + +void renderBackground(const void* background) +{ + +} + +void* copyBackground() +{ + return &texBackground; +} + +int32 boxIsVisible_c(const AABBs* box) +{ + return 1; +} + +int32 sphereIsVisible_c(int32 x, int32 y, int32 z, int32 r) +{ + return 1; +} + +void flush_c() +{ + +} + +#endif diff --git a/src/fixed/room.h b/src/fixed/room.h new file mode 100644 index 00000000..5b0a79ab --- /dev/null +++ b/src/fixed/room.h @@ -0,0 +1,1142 @@ +#ifndef H_ROOM +#define H_ROOM + +#include "common.h" + +EWRAM_DATA Room* roomsList[MAX_ROOM_LIST]; + +//#ifdef ROM_READ +EWRAM_DATA int32 dynSectorsCount; +EWRAM_DATA Sector dynSectors[MAX_DYN_SECTORS]; // EWRAM 8k +//#endif + +const Sector* Sector::getSectorBelow(int32 posX, int32 posZ) const +{ + if (roomBelow == NO_ROOM) + return this; + return rooms[roomBelow].getSector(posX, posZ)->getSectorBelow(posX, posZ); +} + +const Sector* Sector::getSectorAbove(int32 posX, int32 posZ) const +{ + if (roomAbove == NO_ROOM) + return this; + return rooms[roomAbove].getSector(posX, posZ)->getSectorAbove(posX, posZ); +} + +int32 Sector::getFloor(int32 x, int32 y, int32 z) const +{ + gLastFloorData = NULL; + + const Sector* lowerSector = getSectorBelow(x, z); + + int32 floor = lowerSector->floor << 8; + + gLastFloorSlant = 0; + + if (lowerSector->floorIndex) + { + const FloorData* fd = level.floors + lowerSector->floorIndex; + uint16 cmd = *fd++; + + if (FD_FLOOR_TYPE(cmd) == FLOOR_TYPE_FLOOR) // found floor + { + gLastFloorSlant = *fd; + int32 sx = FD_SLANT_X(gLastFloorSlant); + int32 sz = FD_SLANT_Z(gLastFloorSlant); + int32 dx = x & 1023; + int32 dz = z & 1023; + floor -= sx * (sx < 0 ? dx : (dx - 1023)) >> 2; + floor -= sz * (sz < 0 ? dz : (dz - 1023)) >> 2; + } + + lowerSector->getTriggerFloorCeiling(x, y, z, &floor, NULL); + } + + return floor; +} + +int32 Sector::getCeiling(int32 x, int32 y, int32 z) const +{ + const Sector* upperSector = getSectorAbove(x, z); + + int32 ceiling = upperSector->ceiling << 8; + + if (upperSector->floorIndex) + { + const FloorData* fd = level.floors + upperSector->floorIndex; + uint16 cmd = *fd++; + + if (FD_FLOOR_TYPE(cmd) == FLOOR_TYPE_FLOOR) // skip floor + { + fd++; + cmd = *fd++; + } + + if (FD_FLOOR_TYPE(cmd) == FLOOR_TYPE_CEILING) // found ceiling + { + int32 sx = FD_SLANT_X(*fd); + int32 sz = FD_SLANT_Z(*fd); + int32 dx = x & 1023; + int32 dz = z & 1023; + ceiling -= sx * (sx < 0 ? (dx - 1023) : dx) >> 2; + ceiling += sz * (sz < 0 ? dz : (dz - 1023)) >> 2; + } + } + + const Sector* lowerSector = getSectorBelow(x, z); + + if (lowerSector->floorIndex) + { + lowerSector->getTriggerFloorCeiling(x, y, z, NULL, &ceiling); + } + + return ceiling; +} + +Room* Sector::getNextRoom() const +{ + if (!floorIndex) + return NULL; + + // always in this order + // - floor + // - ceiling + // - portal + // - other + + const FloorData* fd = level.floors + floorIndex; + uint16 cmd = *fd++; + + if (FD_FLOOR_TYPE(cmd) == FLOOR_TYPE_FLOOR) // skip floor + { + if (FD_END(cmd)) return NULL; + fd++; + cmd = *fd++; + } + + if (FD_FLOOR_TYPE(cmd) == FLOOR_TYPE_CEILING) // skip ceiling + { + if (FD_END(cmd)) return NULL; + fd++; + cmd = *fd++; + } + + if (FD_FLOOR_TYPE(cmd) != FLOOR_TYPE_PORTAL) // no portal + return NULL; + + ASSERT(*fd != NO_ROOM); + + return rooms + *fd; +} + +void Sector::getTriggerFloorCeiling(int32 x, int32 y, int32 z, int32* floor, int32* ceiling) const +{ + if (!floorIndex) + return; + + uint16 cmd; + const FloorData* fd = level.floors + floorIndex; + + do { + cmd = *fd++; + + switch (FD_FLOOR_TYPE(cmd)) + { + case FLOOR_TYPE_PORTAL: + case FLOOR_TYPE_FLOOR: + case FLOOR_TYPE_CEILING: + { + fd++; + break; + } + + case FLOOR_TYPE_TRIGGER: + { + if (floor && !gLastFloorData) { + gLastFloorData = fd - 1; + } + + fd++; + uint16 trigger; + + do { + trigger = *fd++; + + if (FD_ACTION(trigger) == TRIGGER_ACTION_ACTIVATE_OBJECT) + { + items[FD_ARGS(trigger)].getItemFloorCeiling(x, y, z, floor, ceiling); + } + + if (FD_ACTION(trigger) == TRIGGER_ACTION_ACTIVATE_CAMERA) + { + trigger = *fd++; // skip camera index + } + + } while (!FD_END(trigger)); + + break; + } + + case FLOOR_TYPE_LAVA: + if (floor) { + gLastFloorData = fd - 1; + } + break; + } + + } while (!FD_END(cmd)); +} + +#ifndef __32X__ +#if !defined(USE_ASM) || defined(__3DO__) // TODO for 3DO +const Sector* Room::getSector(int32 x, int32 z) const +{ + // TODO remove clamp? + int32 sx = X_CLAMP((x - (info->x << 8)) >> 10, 0, info->xSectors - 1); + int32 sz = X_CLAMP((z - (info->z << 8)) >> 10, 0, info->zSectors - 1); + + return sectors + sx * info->zSectors + sz; +} +#endif +#endif + +const Sector* Room::getWaterSector(int32 x, int32 z) const +{ + const Room* room = this; + const Sector* sector = room->getSector(x, z); + + // go up to the air + if (ROOM_FLAG_WATER(room->info->flags)) + { + while (sector->roomAbove != NO_ROOM) + { + room = rooms + sector->roomAbove; + + if (!ROOM_FLAG_WATER(room->info->flags)) { + return sector; + } + + sector = room->getSector(x, z); + } + return sector; + } + + // go down to the water + while (sector->roomBelow != NO_ROOM) + { + room = rooms + sector->roomBelow; + sector = room->getSector(x, z); + + if (ROOM_FLAG_WATER(room->info->flags)) { + return sector; + } + } + + return NULL; +} + +Room* Room::getRoom(int32 x, int32 y, int32 z) +{ + const Sector* sector = getSector(x, z); + + Room* room = this; + + while (1) + { + Room* nextRoom = sector->getNextRoom(); + if (!nextRoom) + break; + room = nextRoom; + sector = room->getSector(x, z); + }; + + while (sector->roomAbove != NO_ROOM && y < (sector->ceiling << 8)) + { + room = rooms + sector->roomAbove; + sector = room->getSector(x, z); + } + + while (sector->roomBelow != NO_ROOM && y >= (sector->floor << 8)) + { + room = rooms + sector->roomBelow; + sector = room->getSector(x, z); + } + + return room; +} + +bool Room::collideStatic(CollisionInfo &cinfo, const vec3i &p, int32 height) +{ + cinfo.staticHit = false; + cinfo.offset = _vec3i(0, 0, 0); + + AABBi objBox; + objBox.minX = -cinfo.radius; + objBox.maxX = cinfo.radius; + objBox.minZ = -cinfo.radius; + objBox.maxZ = cinfo.radius; + objBox.minY = -height; + objBox.maxY = 0; + + Room** nearRoom = getNearRooms(p, cinfo.radius, height); + + while (*nearRoom) + { + const Room* room = *nearRoom++; + + int32 rx = p.x - (room->info->x << 8); + int32 ry = p.y; + int32 rz = p.z - (room->info->z << 8); + + for (int i = 0; i < room->info->meshesCount; i++) + { + const RoomMesh* mesh = room->data.meshes + i; + + #ifdef NO_STATIC_MESH_PLANTS + if (STATIC_MESH_ID(mesh->zf) < 10) + continue; + #endif + + const StaticMesh* staticMesh = level.staticMeshes + STATIC_MESH_ID(mesh->zf); + + if (staticMesh->flags & STATIC_MESH_FLAG_NO_COLLISION) + continue; + + int32 x = (int32(mesh->xy) >> 16) - rx; + int32 y = (int32(mesh->xy) << 16 >> 16) - ry; + int32 z = (int32(mesh->zf) >> 16) - rz; + + if (abs(x) > MAX_STATIC_MESH_RADIUS || abs(z) > MAX_STATIC_MESH_RADIUS || abs(y) > MAX_STATIC_MESH_RADIUS) + continue; + + AABBi meshBox(staticMesh->cbox); + boxRotateYQ(meshBox, STATIC_MESH_QUADRANT(mesh->zf)); + boxTranslate(meshBox, x, y, z); + + if (!boxIntersect(meshBox, objBox)) + continue; + + cinfo.offset = boxPushOut(meshBox, objBox); + + bool flip = (cinfo.quadrant > 1); + + if (cinfo.quadrant & 1) { + if (abs(cinfo.offset.z) > cinfo.radius) { + cinfo.offset.z = cinfo.pos.z - p.z; + if ((cinfo.offset.x < 0 && cinfo.quadrant == 1) || (cinfo.offset.x > 0 && cinfo.quadrant == 3)) { + cinfo.type = CT_FRONT; + } + } else if (cinfo.offset.z != 0) { + cinfo.offset.x = 0; + cinfo.type = ((cinfo.offset.z > 0) ^ flip) ? CT_RIGHT : CT_LEFT; + } else { + cinfo.offset = _vec3i(0, 0, 0); + } + } else { + if (abs(cinfo.offset.x) > cinfo.radius) { + cinfo.offset.x = cinfo.pos.x - p.x; + if ((cinfo.offset.z < 0 && cinfo.quadrant == 0) || (cinfo.offset.z > 0 && cinfo.quadrant == 2)) { + cinfo.type = CT_FRONT; + } + } else if (cinfo.offset.x != 0) { + cinfo.offset.z = 0; + cinfo.type = ((cinfo.offset.x > 0) ^ flip) ? CT_LEFT : CT_RIGHT; + } else { + cinfo.offset = _vec3i(0, 0, 0); + } + } + + cinfo.staticHit = (cinfo.offset.x != 0 || cinfo.offset.z != 0); + + return true; + } + } + + return false; +} + +bool Room::checkPortal(const Portal* portal) +{ + vec3i d; + d.x = portal->v[0].x - gCameraViewPos.x + (info->x << 8); + d.y = portal->v[0].y - gCameraViewPos.y; + d.z = portal->v[0].z - gCameraViewPos.z + (info->z << 8); + + Matrix &m = matrixGet(); + + vec3i pv[4]; +/* +#ifdef __3DO__ + int32 axis = 0; + if (d.x >= 0) axis |= (2 << 0); + if (d.x < 0) axis |= (1 << 0); + if (d.y >= 0) axis |= (2 << 2); + if (d.y < 0) axis |= (1 << 2); + if (d.z >= 0) axis |= (2 << 4); + if (d.z < 0) axis |= (1 << 4); + + if (!(portal->normalMask & axis)) + return false; +#else*/ + if (DP33(portal->n.x, portal->n.y, portal->n.z, d.x, d.y, d.z) >= 0) + return false; +//#endif + + int32 x0 = clip.x1 - (FRAME_WIDTH >> 1); + int32 y0 = clip.y1 - (FRAME_HEIGHT >> 1); + int32 x1 = clip.x0 - (FRAME_WIDTH >> 1); + int32 y1 = clip.y0 - (FRAME_HEIGHT >> 1); + + int32 znear = 0, zfar = 0; + + for (int32 i = 0; i < 4; i++) + { + int32 px = portal->v[i].x; + int32 py = portal->v[i].y; + int32 pz = portal->v[i].z; + + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, px, py, pz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, px, py, pz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, px, py, pz); + + pv[i].x = x; + pv[i].y = y; + pv[i].z = z; + + if (z <= 0) { + znear++; + continue; + } + + if (z > VIEW_MAX_F) + { + z = VIEW_MAX_F; + zfar++; + } + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + PERSPECTIVE(x, y, z); + + if (x < x0) x0 = x; + if (x > x1) x1 = x; + if (y < y0) y0 = y; + if (y > y1) y1 = y; + } + + if (znear == 4 || zfar == 4) + return false; + + x0 += (FRAME_WIDTH >> 1); + y0 += (FRAME_HEIGHT >> 1); + x1 += (FRAME_WIDTH >> 1); + y1 += (FRAME_HEIGHT >> 1); + + if (znear) + { + vec3i *a = pv; + vec3i *b = pv + 3; + for (int32 i = 0; i < 4; i++) + { + if ((a->z < 0) ^ (b->z < 0)) + { + if (a->x < 0 && b->x < 0) { + x0 = 0; + } else if (a->x > 0 && b->x > 0) { + x1 = FRAME_WIDTH; + } else { + x0 = 0; + x1 = FRAME_WIDTH; + } + + if (a->y < 0 && b->y < 0) { + y0 = 0; + } else if (a->y > 0 && b->y > 0) { + y1 = FRAME_HEIGHT; + } else { + y0 = 0; + y1 = FRAME_HEIGHT; + } + } + b = a; + a++; + } + } + + if (x0 < clip.x0) x0 = clip.x0; + if (x1 > clip.x1) x1 = clip.x1; + if (y0 < clip.y0) y0 = clip.y0; + if (y1 > clip.y1) y1 = clip.y1; + + if (x0 >= x1 || y0 >= y1) + return false; + + Room* nextRoom = rooms + portal->roomIndex; + + if (x0 < nextRoom->clip.x0) nextRoom->clip.x0 = x0; + if (x1 > nextRoom->clip.x1) nextRoom->clip.x1 = x1; + if (y0 < nextRoom->clip.y0) nextRoom->clip.y0 = y0; + if (y1 > nextRoom->clip.y1) nextRoom->clip.y1 = y1; + + return true; +} + +Room** Room::addVisibleRoom(Room** list) +{ + matrixPush(); + matrixTranslateAbs(info->x << 8, 0, info->z << 8); + + for (int32 i = 0; i < info->portalsCount; i++) + { + const Portal* portal = data.portals + i; + + if (checkPortal(portal)) + { + Room* nextRoom = rooms + portal->roomIndex; + + list = nextRoom->addVisibleRoom(list); + + if (!nextRoom->visible) + { + nextRoom->visible = true; + *list++ = nextRoom; + } + } + } + + matrixPop(); + + return list; +} + +Room** Room::getVisibleRooms() +{ + Room** list = addVisibleRoom(roomsList); + *list++ = this; + *list++ = NULL; + + ASSERT(list - roomsList <= MAX_ROOM_LIST); + + return roomsList; +} + +void Room::reset() +{ + visible = false; + clip = RectMinMax( FRAME_WIDTH, FRAME_HEIGHT, 0, 0 ); +} + +Room** Room::addNearRoom(Room** list, int32 x, int32 y, int32 z) +{ + Room* nearRoom = getRoom(x, y, z); + + int32 count = list - roomsList; + for (int32 i = 0; i < count; i++) + { + if (roomsList[i] == nearRoom) + return list; + } + + *list++ = nearRoom; + return list; +} + +Room** Room::getNearRooms(const vec3i &pos, int32 radius, int32 height) +{ + Room** list = roomsList; + + *list++ = this; + + list = addNearRoom(list, pos.x - radius, pos.y, pos.z - radius); + list = addNearRoom(list, pos.x + radius, pos.y, pos.z - radius); + list = addNearRoom(list, pos.x + radius, pos.y, pos.z + radius); + list = addNearRoom(list, pos.x - radius, pos.y, pos.z + radius); + + list = addNearRoom(list, pos.x - radius, pos.y - height, pos.z - radius); + list = addNearRoom(list, pos.x + radius, pos.y - height, pos.z - radius); + list = addNearRoom(list, pos.x + radius, pos.y - height, pos.z + radius); + list = addNearRoom(list, pos.x - radius, pos.y - height, pos.z + radius); + + *list++ = NULL; + + return roomsList; +} + +Room** Room::getAdjRooms() +{ + Room** list = roomsList; + + *list++ = this; + for (int32 i = 0; i < info->portalsCount; i++) + { + *list++ = rooms + data.portals[i].roomIndex; + } + *list++ = NULL; + + return roomsList; +} + +void Room::modify() +{ +//#ifdef ROM_READ + if (sectors == data.sectors) + { + // convert room->sectors to mutable (non-ROM) data + sectors = dynSectors + dynSectorsCount; + memcpy((Sector*)sectors, data.sectors, info->xSectors * info->zSectors * sizeof(Sector)); + + dynSectorsCount += info->xSectors * info->zSectors; + //printf("dynSectors: %d\n", dynSectorsCount); + ASSERT(dynSectorsCount <= MAX_DYN_SECTORS); + } +//#endif +} + +void Room::add(ItemObj* item) +{ + ASSERT(item && item->nextItem == NULL); + + item->room = this; + item->nextItem = firstItem; + firstItem = item; +} + +void Room::remove(ItemObj* item) +{ + ASSERT(item && item->room == this); + + ItemObj* prev = NULL; + ItemObj* curr = firstItem; + + while (curr) + { + ItemObj* next = curr->nextItem; + + if (curr == item) + { + item->nextItem = NULL; + + if (prev) { + prev->nextItem = next; + } else { + firstItem = next; + } + + break; + } + + prev = curr; + curr = next; + } +} + +#define TRACE_SHIFT 10 // trace precision + +#define TRACE_CHECK(r, x, y, z) \ +{ \ + const Sector* sector = r->getSector(x, z); \ + if (accurate) { \ + if (y > sector->getFloor(x, y, z) || y < sector->getCeiling(x, y, z)) \ + { \ + to.pos = p; \ + to.room = room; \ + return false; \ + } \ + } else { \ + if (y > (sector->floor << 8) || y < (sector->ceiling << 8)) \ + { \ + to.pos = p; \ + to.room = room; \ + return false; \ + } \ + } \ +} + +bool traceX(const Location &from, Location &to, bool accurate) +{ + vec3i d = to.pos - from.pos; + + if (!d.x) + return true; + + d.y = (d.y << TRACE_SHIFT) / d.x; + d.z = (d.z << TRACE_SHIFT) / d.x; + + vec3i p = from.pos; + + Room* room = from.room; + + if (d.x < 0) + { + d.x = 1024; + p.x &= ~1023; + p.y += d.y * (p.x - from.pos.x) >> TRACE_SHIFT; + p.z += d.z * (p.x - from.pos.x) >> TRACE_SHIFT; + + while (p.x > to.pos.x) + { + room = room->getRoom(p.x, p.y, p.z); + TRACE_CHECK(room, p.x, p.y, p.z); + + Room* nextRoom = room->getRoom(p.x - 1, p.y, p.z); + TRACE_CHECK(nextRoom, p.x - 1, p.y, p.z); + + room = nextRoom; + p -= d; + } + } + else + { + d.x = 1024; + p.x |= 1023; + p.y += d.y * (p.x - from.pos.x) >> TRACE_SHIFT; + p.z += d.z * (p.x - from.pos.x) >> TRACE_SHIFT; + + while (p.x < to.pos.x) + { + room = room->getRoom(p.x, p.y, p.z); + TRACE_CHECK(room, p.x, p.y, p.z); + + Room* nextRoom = room->getRoom(p.x + 1, p.y, p.z); + TRACE_CHECK(nextRoom, p.x + 1, p.y, p.z); + + room = nextRoom; + p += d; + } + } + + to.room = room; + + return true; +} + +bool traceZ(const Location &from, Location &to, bool accurate) +{ + vec3i d = to.pos - from.pos; + + if (!d.z) + return true; + + d.x = (d.x << TRACE_SHIFT) / d.z; + d.y = (d.y << TRACE_SHIFT) / d.z; + + vec3i p = from.pos; + + Room* room = from.room; + + if (d.z < 0) + { + d.z = 1024; + p.z &= ~1023; + p.x += d.x * (p.z - from.pos.z) >> TRACE_SHIFT; + p.y += d.y * (p.z - from.pos.z) >> TRACE_SHIFT; + + while (p.z > to.pos.z) + { + room = room->getRoom(p.x, p.y, p.z); + TRACE_CHECK(room, p.x, p.y, p.z); + + Room* nextRoom = room->getRoom(p.x, p.y, p.z - 1); + TRACE_CHECK(nextRoom, p.x, p.y, p.z - 1); + + room = nextRoom; + p -= d; + } + } + else + { + d.z = 1024; + p.z |= 1023; + p.x += d.x * (p.z - from.pos.z) >> TRACE_SHIFT; + p.y += d.y * (p.z - from.pos.z) >> TRACE_SHIFT; + + while (p.z < to.pos.z) + { + room = room->getRoom(p.x, p.y, p.z); + TRACE_CHECK(room, p.x, p.y, p.z); + + Room* nextRoom = room->getRoom(p.x, p.y, p.z + 1); + TRACE_CHECK(nextRoom, p.x, p.y, p.z + 1); + + room = nextRoom; + p += d; + } + } + + to.room = room; + + return true; +} + +#undef TRACE_CHECK + +bool trace(const Location &from, Location &to, bool accurate) +{ + int32 dx = abs(to.pos.x - from.pos.x); + int32 dz = abs(to.pos.z - from.pos.z); + int32 dy; + + bool res; + + if (dz > dx) { + res = traceX(from, to, accurate); + if (!traceZ(from, to, accurate)) + return false; + } else { + res = traceZ(from, to, accurate); + if (!traceX(from, to, accurate)) + return false; + } + + dy = to.pos.y - from.pos.y; + + if (dy) + { + const Sector* sector = to.room->getSector(to.pos.x, to.pos.z); + + int32 h = sector->getFloor(to.pos.x, to.pos.y, to.pos.z); + if (to.pos.y <= h || from.pos.y >= h) + { + h = sector->getCeiling(to.pos.x, to.pos.y, to.pos.z); + if (to.pos.y >= h || from.pos.y <= h) + { + h = WALL; + } + } + + if (h != WALL) + { + to.pos.y = h; + h -= from.pos.y; + to.pos.x = from.pos.x + (to.pos.x - from.pos.x) * h / dy; // @DIV + to.pos.z = from.pos.z + (to.pos.z - from.pos.z) * h / dy; // @DIV + return false; + } + } + + return res; +} + +void checkCamera(const FloorData* fd, Camera* camera) +{ + bool lookAt = false; + + while (1) + { + uint16 triggerCmd = *fd++; + + switch (FD_ACTION(triggerCmd)) + { + case TRIGGER_ACTION_ACTIVATE_CAMERA: + { + FD_SET_END(triggerCmd, FD_END(*fd++)); + + if (FD_ARGS(triggerCmd) != camera->lastIndex) + { + camera->lookAtItem = NULL; + return; + } + + camera->index = FD_ARGS(triggerCmd); + + if (camera->timer < 0 || camera->mode == CAMERA_MODE_LOOK || camera->mode == CAMERA_MODE_COMBAT) + { + camera->timer = -1; + camera->lookAtItem = NULL; + return; + } + + camera->mode = CAMERA_MODE_FIXED; + lookAt = true; + break; + } + + case TRIGGER_ACTION_CAMERA_TARGET: + { + if (camera->mode == CAMERA_MODE_LOOK || camera->mode == CAMERA_MODE_COMBAT) + break; + + ASSERT(FD_ARGS(triggerCmd) < level.itemsCount); + camera->lookAtItem = items + FD_ARGS(triggerCmd); + break; + } + + case TRIGGER_ACTION_FLYBY: + { + FD_SET_END(triggerCmd, FD_END(*fd++)); + break; + } + } + + if (FD_END(triggerCmd)) + break; + }; + + if (!lookAt && camera->lookAtItem && camera->lookAtItem != camera->lastItem && (camera->lookAtItem->flags & ITEM_FLAG_ANIMATED)) { + camera->lookAtItem = NULL; + } +} + +void checkTrigger(const FloorData* fd, ItemObj* lara) +{ + if (!fd) + return; + + if (FD_FLOOR_TYPE(*fd) == FLOOR_TYPE_LAVA) + { + // TODO lava + + if (FD_END(*fd)) + return; + + fd++; + } + + uint16 cmd = *fd++; + uint16 data = *fd++; + + ItemObj* switchItem = NULL; + ItemObj* cameraItem = NULL; + + Camera* camera = lara ? &lara->extraL->camera : &playersExtra[0].camera; + + if (camera->mode != CAMERA_MODE_OBJECT) { + checkCamera(fd, camera); + } + + if (!lara && FD_TRIGGER_TYPE(cmd) != TRIGGER_TYPE_OBJECT) + return; + + if (lara) + { + switch (FD_TRIGGER_TYPE(cmd)) + { + case TRIGGER_TYPE_ACTIVATE: + break; + + case TRIGGER_TYPE_PAD: + case TRIGGER_TYPE_ANTIPAD: + { + if (lara->pos.y != lara->roomFloor) + return; + break; + } + + case TRIGGER_TYPE_SWITCH: + { + switchItem = items + FD_ARGS(*fd); + if (!useSwitch(switchItem, FD_TIMER(data))) + return; + fd++; + break; + } + + case TRIGGER_TYPE_KEY: + { + ItemObj* keyItem = items + FD_ARGS(*fd); + if (!useKey(keyItem, lara)) + return; + fd++; + break; + } + + case TRIGGER_TYPE_PICKUP: + { + ItemObj* pickupItem = items + FD_ARGS(*fd); + if (!usePickup(pickupItem)) + return; + fd++; + break; + } + + case TRIGGER_TYPE_OBJECT: + return; + + case TRIGGER_TYPE_COMBAT: + { + if (lara->extraL->weaponState != WEAPON_STATE_READY) + return; + break; + } + + case TRIGGER_TYPE_DUMMY: + return; + } + } + + while (1) + { + uint16 triggerCmd = *fd++; + + switch (FD_ACTION(triggerCmd)) + { + case TRIGGER_ACTION_ACTIVATE_OBJECT: + { + ASSERT(FD_ARGS(triggerCmd) < level.itemsCount); + ItemObj* item = items + FD_ARGS(triggerCmd); + + if (item->flags & ITEM_FLAG_ONCE) + break; + + item->timer = FD_TIMER(data); + if (item->timer != 1) { + item->timer *= 30; + } + + if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_SWITCH) { + item->flags ^= (FD_MASK(data) << ITEM_FLAGS_MASK_SHIFT); + } else if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_ANTIPAD) { + item->flags &= ~(FD_MASK(data) << ITEM_FLAGS_MASK_SHIFT); + } else { + item->flags |= (FD_MASK(data) << ITEM_FLAGS_MASK_SHIFT); + } + + if ((item->flags & ITEM_FLAG_MASK) != ITEM_FLAG_MASK) + break; + + if (FD_ONCE(data)) { + item->flags |= ITEM_FLAG_ONCE; + } + + if (item->flags & ITEM_FLAG_ACTIVE) + break; + + item->activate(); + + if (!(item->flags & ITEM_FLAG_STATUS) && (item->flags & ITEM_FLAG_ACTIVE)) { + item->flags |= ITEM_FLAG_STATUS_ACTIVE; + } + + break; + } + + case TRIGGER_ACTION_ACTIVATE_CAMERA: + { + uint16 cam = *fd++; + FD_SET_END(triggerCmd, FD_END(cam)); + + if (level.cameras[FD_ARGS(triggerCmd)].flags & FIXED_CAMERA_FLAG_ONCE) + break; + + camera->index = FD_ARGS(triggerCmd); + + if (camera->mode == CAMERA_MODE_LOOK || camera->mode == CAMERA_MODE_COMBAT) + break; + + if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_COMBAT) + break; + + if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_SWITCH && (switchItem->state == 1) && (FD_TIMER(data) != 0)) + break; + + if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_SWITCH || camera->index != camera->lastIndex) + { + camera->timer = FD_TIMER(cam); + if (camera->timer != 1) { + camera->timer *= 30; + } + + if (FD_ONCE(cam)) { + level.cameras[camera->index].flags |= FIXED_CAMERA_FLAG_ONCE; + } + + camera->speed = (FD_SPEED(cam) << 3) + 1; + camera->mode = lara ? CAMERA_MODE_FIXED : CAMERA_MODE_OBJECT; + } + break; + } + + case TRIGGER_ACTION_FLOW: + // TODO flow + break; + + case TRIGGER_ACTION_FLIP: + // TODO flipmap + break; + + case TRIGGER_ACTION_FLIP_ON: + // TODO flipmap + break; + + case TRIGGER_ACTION_FLIP_OFF: + // TODO flipmap + break; + + case TRIGGER_ACTION_CAMERA_TARGET: + { + cameraItem = items + FD_ARGS(triggerCmd); + break; + } + + case TRIGGER_ACTION_END: + nextLevel(LevelID(gLevelID + 1)); + break; + + case TRIGGER_ACTION_SOUNDTRACK: + { + int32 track = doTutorial(lara, FD_ARGS(triggerCmd)); + + if (track == 0) break; + + uint8 &flags = gSaveGame.tracks[track]; + + if (flags & TRACK_FLAG_ONCE) + break; + + if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_SWITCH) + flags ^= FD_MASK(data); + else if (FD_TRIGGER_TYPE(cmd) == TRIGGER_TYPE_ANTIPAD) + flags &= ~FD_MASK(data); + else + flags |= FD_MASK(data); + + if ((flags & TRACK_FLAG_MASK) == TRACK_FLAG_MASK) + { + if (FD_ONCE(data)) { + flags |= TRACK_FLAG_ONCE; + } + sndPlayTrack(track); + } else { + sndStopTrack(); + } + break; + } + + case TRIGGER_ACTION_EFFECT: + // TODO effect + break; + + case TRIGGER_ACTION_SECRET: + { + if (gSaveGame.secrets & (1 << FD_ARGS(triggerCmd))) + break; + gSaveGame.secrets |= (1 << FD_ARGS(triggerCmd)); + sndPlayTrack(13); + break; + } + + case TRIGGER_ACTION_CLEAR_BODIES: + break; + + case TRIGGER_ACTION_FLYBY: + FD_SET_END(triggerCmd, FD_END(*fd++)); + break; + + case TRIGGER_ACTION_CUTSCENE: + break; + } + + if (FD_END(triggerCmd)) + break; + }; + + if (cameraItem && (camera->mode == CAMERA_MODE_FIXED || camera->mode == CAMERA_MODE_OBJECT)) + { + camera->lookAtItem = cameraItem; + } +} + +#endif diff --git a/src/fixed/stream.h b/src/fixed/stream.h new file mode 100644 index 00000000..ebfdd813 --- /dev/null +++ b/src/fixed/stream.h @@ -0,0 +1,89 @@ +#ifndef H_STREAM +#define H_STREAM + +#include "common.h" + +struct DataStream +{ + const uint8* data; + int32 size; + int32 pos; + bool bigEndian; + + DataStream(const uint8* data, int32 size) : data(data), size(size), pos(0), bigEndian(false) + { + // + } + + const uint8* getPtr() + { + return data + pos; + } + + int32 getPos() + { + return pos; + } + + void setPos(int32 newPos) + { + pos = newPos; + } + + void seek(int32 offset) + { + pos += offset; + } + + X_INLINE uint8 read8u() + { + return data[pos++]; + } + + X_INLINE int8 read8s() + { + return (int8)read8u(); + } + + uint16 read16u() + { + const uint8* ptr = data + pos; + pos += 2; + + uint16 n; + if (intptr_t(ptr) & 1) { + n = ptr[0] | (ptr[1] << 8); + } else { + n = *(uint16*)ptr; + } + + return bigEndian ? swap16(n) : n; + } + + X_INLINE int16 read16s() + { + return (int16)read16u(); + } + + uint32 read32u() + { + const uint8* ptr = data + pos; + pos += 4; + + uint32 n; + if (intptr_t(ptr) & 3) { + n = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); + } else { + n = *(uint32*)ptr; + } + + return bigEndian ? swap32(n) : n; + } + + X_INLINE int32 read32s() + { + return (int32)read32u(); + } +}; + +#endif diff --git a/src/format.h b/src/format.h index 793cf62d..70ab2c06 100644 --- a/src/format.h +++ b/src/format.h @@ -7,8 +7,9 @@ #define MAX_RESERVED_ENTITIES 128 #define MAX_TRIGGER_COMMANDS 32 -#define MAX_MESHES 512 +#define MAX_MESHES 1024 #define MAX_WEAPONS 4 +#define MAX_JOINTS 32 // Lara's height in units / height in meters #define ONE_METER (768.0f / 1.8f) @@ -16,6 +17,8 @@ #define TR1_TYPES_START 0 #define TR2_TYPES_START 1000 #define TR3_TYPES_START 2000 +#define TR4_TYPES_START 3000 + #define TR_TYPES(E) \ E( LARA = TR1_TYPES_START) \ @@ -850,7 +853,528 @@ E( UNUSED_TR3_371 ) \ E( UNUSED_TR3_372 ) \ E( ELECTRIC_SWITCH ) \ - E( TR3_TYPE_MAX ) + E( TR3_TYPE_MAX ) \ + E( ___LARA = TR4_TYPES_START ) \ + E( ___LARA_PISTOLS ) \ + E( ___LARA_UZIS ) \ + E( ___LARA_SHOTGUN ) \ + E( LARA_CROSSBOW ) \ + E( ___LARA_GRENADE ) \ + E( LARA_REVOLVER ) \ + E( ___LARA_FLARE ) \ + E( ___LARA_SKIN ) \ + E( LARA_SKIN_JOINTS ) \ + E( LARA_SCREAM ) \ + E( LARA_CROSSBOW_LASER ) \ + E( LARA_REVOLVER_LASER ) \ + E( LARA_HOLSTERS ) \ + E( LARA_HOLSTERS_PISTOLS ) \ + E( LARA_HOLSTERS_UZIS ) \ + E( LARA_HOLSTERS_REVOLVER ) \ + E( LARA_HEAD1 ) \ + E( LARA_HEAD2 ) \ + E( LARA_HEAD3 ) \ + E( LARA_HEAD4 ) \ + E( ACTOR1_HEAD1 ) \ + E( ACTOR1_HEAD2 ) \ + E( ACTOR2_HEAD1 ) \ + E( ACTOR2_HEAD2 ) \ + E( LARA_WATER_MESH ) \ + E( LARA_PETROL_MESH ) \ + E( LARA_DIRT_MESH ) \ + E( CROWBAR_ANIM ) \ + E( TORCH_ANIM ) \ + E( ___LARA_BRAID ) \ + E( MOTORBIKE ) \ + E( JEEP ) \ + E( VEHICLE_EXTRA ) \ + E( ENEMY_JEEP ) \ + E( SKELETON ) \ + E( SKELETON_MIP ) \ + E( GUIDE ) \ + E( GUIDE_MIP ) \ + E( VON_CROY ) \ + E( VON_CROY_MIP ) \ + E( BADDY_1 ) \ + E( BADDY_1_MIP ) \ + E( BADDY_2 ) \ + E( BADDY_2_MIP ) \ + E( SETHA ) \ + E( SETHA_MIP ) \ + E( MUMMY ) \ + E( MUMMY_MIP ) \ + E( SPHINX ) \ + E( SPHINX_MIP ) \ + E( CROCODILE ) \ + E( CROCODILE_MIP ) \ + E( HORSEMAN ) \ + E( HORSEMAN_MIP ) \ + E( SCORPION ) \ + E( SCORPION_MIP ) \ + E( JEAN_YVES ) \ + E( JEAN_YVES_MIP ) \ + E( TROOPS ) \ + E( TROOPS_MIP ) \ + E( KNIGHTS_TEMPLAR ) \ + E( KNIGHTS_TEMPLAR_MIP ) \ + E( MUTANT ) \ + E( MUTANT_MIP ) \ + E( HORSE ) \ + E( HORSE_MIP ) \ + E( BABOON_NORMAL ) \ + E( BABOON_NORMAL_MIP ) \ + E( BABOON_INV ) \ + E( BABOON_INV_MIP ) \ + E( BABOON_SILENT ) \ + E( BABOON_SILENT_MIP ) \ + E( WILD_BOAR ) \ + E( WILD_BOAR_MIP ) \ + E( HARPY ) \ + E( HARPY_MIP ) \ + E( DEMIGOD1 ) \ + E( DEMIGOD1_MIP ) \ + E( DEMIGOD2 ) \ + E( DEMIGOD2_MIP ) \ + E( DEMIGOD3 ) \ + E( DEMIGOD3_MIP ) \ + E( LITTLE_BEETLE ) \ + E( BIG_BEETLE ) \ + E( BIG_BEETLE_MIP ) \ + E( WRAITH1 ) \ + E( WRAITH2 ) \ + E( WRAITH3 ) \ + E( WRAITH4 ) \ + E( BAT ) \ + E( DOG ) \ + E( DOG_MIP ) \ + E( HAMMERHEAD ) \ + E( HAMMERHEAD_MIP ) \ + E( SAS ) \ + E( SAS_MIP ) \ + E( SAS_DYING ) \ + E( SAS_DYING_MIP ) \ + E( SAS_CAPTAIN ) \ + E( SAS_CAPTAIN_MIP ) \ + E( SAS_DRAG_BLOKE ) \ + E( AHMET ) \ + E( AHMET_MIP ) \ + E( LARA_DOUBLE ) \ + E( LARA_DOUBLE_MIP ) \ + E( SMALL_SCORPION ) \ + E( LOCUST_EMITTER ) \ + E( GAME_PIECE1 ) \ + E( GAME_PIECE2 ) \ + E( GAME_PIECE3 ) \ + E( ENEMY_PIECE ) \ + E( WHEEL_OF_FORTUNE ) \ + E( SCALES ) \ + E( DARTS ) \ + E( DART_EMITTER ) \ + E( HOMING_DART_EMITTER ) \ + E( FALLING_CEILING ) \ + E( FALLING_BLOCK ) \ + E( FALLING_BLOCK2 ) \ + E( SMASHABLE_BIKE_WALL ) \ + E( SMASHABLE_BIKE_FLOOR ) \ + E( TRAPDOOR1 ) \ + E( TRAPDOOR2 ) \ + E( TRAPDOOR3 ) \ + E( FLOOR_TRAPDOOR1 ) \ + E( FLOOR_TRAPDOOR2 ) \ + E( CEILING_TRAPDOOR1 ) \ + E( CEILING_TRAPDOOR2 ) \ + E( SCALING_TRAPDOOR ) \ + E( ROLLINGBALL ) \ + E( SPIKEY_FLOOR ) \ + E( TEETH_SPIKES ) \ + E( JOBY_SPIKES ) \ + E( SLICER_DICER ) \ + E( CHAIN ) \ + E( PLOUGH ) \ + E( STARGATE ) \ + E( HAMMER ) \ + E( BURNING_FLOOR ) \ + E( COG ) \ + E( SPIKEBALL ) \ + E( ___FLAME ) \ + E( ___TRAP_FLAME_EMITTER ) \ + E( TRAP_FLAME_EMITTER2 ) \ + E( TRAP_FLAME_EMITTER3 ) \ + E( ROPE ) \ + E( FIREROPE ) \ + E( POLEROPE ) \ + E( ONEBLOCK_PLATFORM ) \ + E( TWOBLOCK_PLATFORM ) \ + E( RAISING_BLOCK1 ) \ + E( RAISING_BLOCK2 ) \ + E( EXPANDING_PLATFORM ) \ + E( SQUISHY_BLOCK1 ) \ + E( SQUISHY_BLOCK2 ) \ + E( ___BLOCK_1 ) \ + E( ___BLOCK_2 ) \ + E( ___BLOCK_3 ) \ + E( ___BLOCK_4 ) \ + E( BLOCK_5 ) \ + E( ___TRIPWIRE ) \ + E( SENTRY_GUN ) \ + E( MINE ) \ + E( MAPPER ) \ + E( OBELISK ) \ + E( FLOOR_4BLADE ) \ + E( ROOF_4BLADE ) \ + E( BIRD_BLADE ) \ + E( CATWALK_BLADE ) \ + E( MOVING_BLADE ) \ + E( PLINTH_BLADE ) \ + E( SETH_BLADE ) \ + E( LIGHTNING_CONDUCTOR ) \ + E( ELEMENT_PUZZLE ) \ + E( PUZZLE_ITEM1 ) \ + E( PUZZLE_ITEM2 ) \ + E( PUZZLE_ITEM3 ) \ + E( PUZZLE_ITEM4 ) \ + E( PUZZLE_ITEM5 ) \ + E( PUZZLE_ITEM6 ) \ + E( PUZZLE_ITEM7 ) \ + E( PUZZLE_ITEM8 ) \ + E( PUZZLE_ITEM9 ) \ + E( PUZZLE_ITEM10 ) \ + E( PUZZLE_ITEM11 ) \ + E( PUZZLE_ITEM12 ) \ + E( PUZZLE_ITEM1_COMBO1 ) \ + E( PUZZLE_ITEM1_COMBO2 ) \ + E( PUZZLE_ITEM2_COMBO1 ) \ + E( PUZZLE_ITEM2_COMBO2 ) \ + E( PUZZLE_ITEM3_COMBO1 ) \ + E( PUZZLE_ITEM3_COMBO2 ) \ + E( PUZZLE_ITEM4_COMBO1 ) \ + E( PUZZLE_ITEM4_COMBO2 ) \ + E( PUZZLE_ITEM5_COMBO1 ) \ + E( PUZZLE_ITEM5_COMBO2 ) \ + E( PUZZLE_ITEM6_COMBO1 ) \ + E( PUZZLE_ITEM6_COMBO2 ) \ + E( PUZZLE_ITEM7_COMBO1 ) \ + E( PUZZLE_ITEM7_COMBO2 ) \ + E( PUZZLE_ITEM8_COMBO1 ) \ + E( PUZZLE_ITEM8_COMBO2 ) \ + E( KEY_ITEM1 ) \ + E( KEY_ITEM2 ) \ + E( KEY_ITEM3 ) \ + E( KEY_ITEM4 ) \ + E( KEY_ITEM5 ) \ + E( KEY_ITEM6 ) \ + E( KEY_ITEM7 ) \ + E( KEY_ITEM8 ) \ + E( KEY_ITEM9 ) \ + E( KEY_ITEM10 ) \ + E( KEY_ITEM11 ) \ + E( KEY_ITEM12 ) \ + E( KEY_ITEM1_COMBO1 ) \ + E( KEY_ITEM1_COMBO2 ) \ + E( KEY_ITEM2_COMBO1 ) \ + E( KEY_ITEM2_COMBO2 ) \ + E( KEY_ITEM3_COMBO1 ) \ + E( KEY_ITEM3_COMBO2 ) \ + E( KEY_ITEM4_COMBO1 ) \ + E( KEY_ITEM4_COMBO2 ) \ + E( KEY_ITEM5_COMBO1 ) \ + E( KEY_ITEM5_COMBO2 ) \ + E( KEY_ITEM6_COMBO1 ) \ + E( KEY_ITEM6_COMBO2 ) \ + E( KEY_ITEM7_COMBO1 ) \ + E( KEY_ITEM7_COMBO2 ) \ + E( KEY_ITEM8_COMBO1 ) \ + E( KEY_ITEM8_COMBO2 ) \ + E( PICKUP_ITEM1 ) \ + E( PICKUP_ITEM2 ) \ + E( PICKUP_ITEM3 ) \ + E( PICKUP_ITEM4 ) \ + E( PICKUP_ITEM1_COMBO1 ) \ + E( PICKUP_ITEM1_COMBO2 ) \ + E( PICKUP_ITEM2_COMBO1 ) \ + E( PICKUP_ITEM2_COMBO2 ) \ + E( PICKUP_ITEM3_COMBO1 ) \ + E( PICKUP_ITEM3_COMBO2 ) \ + E( PICKUP_ITEM4_COMBO1 ) \ + E( PICKUP_ITEM4_COMBO2 ) \ + E( EXAMINE1 ) \ + E( EXAMINE2 ) \ + E( EXAMINE3 ) \ + E( CROWBAR_ITEM ) \ + E( BURNING_TORCH_ITEM ) \ + E( CLOCKWORK_BEETLE ) \ + E( CLOCKWORK_BEETLE_COMBO1 ) \ + E( CLOCKWORK_BEETLE_COMBO2 ) \ + E( MINE_DETECTOR ) \ + E( QUEST_ITEM1 ) \ + E( QUEST_ITEM2 ) \ + E( QUEST_ITEM3 ) \ + E( QUEST_ITEM4 ) \ + E( QUEST_ITEM5 ) \ + E( QUEST_ITEM6 ) \ + E( MAP ) \ + E( SECRET_MAP ) \ + E( PUZZLE_HOLE1 ) \ + E( PUZZLE_HOLE2 ) \ + E( PUZZLE_HOLE3 ) \ + E( PUZZLE_HOLE4 ) \ + E( PUZZLE_HOLE5 ) \ + E( PUZZLE_HOLE6 ) \ + E( PUZZLE_HOLE7 ) \ + E( PUZZLE_HOLE8 ) \ + E( PUZZLE_HOLE9 ) \ + E( PUZZLE_HOLE10 ) \ + E( PUZZLE_HOLE11 ) \ + E( PUZZLE_HOLE12 ) \ + E( PUZZLE_DONE1 ) \ + E( PUZZLE_DONE2 ) \ + E( PUZZLE_DONE3 ) \ + E( PUZZLE_DONE4 ) \ + E( PUZZLE_DONE5 ) \ + E( PUZZLE_DONE6 ) \ + E( PUZZLE_DONE7 ) \ + E( PUZZLE_DONE8 ) \ + E( PUZZLE_DONE9 ) \ + E( PUZZLE_DONE10 ) \ + E( PUZZLE_DONE11 ) \ + E( PUZZLE_DONE12 ) \ + E( KEY_HOLE1 ) \ + E( KEY_HOLE2 ) \ + E( KEY_HOLE3 ) \ + E( KEY_HOLE4 ) \ + E( KEY_HOLE5 ) \ + E( KEY_HOLE6 ) \ + E( KEY_HOLE7 ) \ + E( KEY_HOLE8 ) \ + E( KEY_HOLE9 ) \ + E( KEY_HOLE10 ) \ + E( KEY_HOLE11 ) \ + E( KEY_HOLE12 ) \ + E( WATERSKIN1_EMPTY ) \ + E( WATERSKIN1_1 ) \ + E( WATERSKIN1_2 ) \ + E( WATERSKIN1_3 ) \ + E( WATERSKIN2_EMPTY ) \ + E( WATERSKIN2_1 ) \ + E( WATERSKIN2_2 ) \ + E( WATERSKIN2_3 ) \ + E( WATERSKIN2_4 ) \ + E( WATERSKIN2_5 ) \ + E( SWITCH_TYPE1 ) \ + E( SWITCH_TYPE2 ) \ + E( SWITCH_TYPE3 ) \ + E( SWITCH_TYPE4 ) \ + E( SWITCH_TYPE5 ) \ + E( SWITCH_TYPE6 ) \ + E( SWITCH_TYPE7 ) \ + E( SWITCH_TYPE8 ) \ + E( UNDERWATER_SWITCH1 ) \ + E( UNDERWATER_SWITCH2 ) \ + E( TURN_SWITCH ) \ + E( COG_SWITCH ) \ + E( LEVER_SWITCH ) \ + E( JUMP_SWITCH ) \ + E( CROWBAR_SWITCH ) \ + E( PULLEY ) \ + E( DOOR_TYPE1 ) \ + E( DOOR_TYPE2 ) \ + E( DOOR_TYPE3 ) \ + E( DOOR_TYPE4 ) \ + E( DOOR_TYPE5 ) \ + E( DOOR_TYPE6 ) \ + E( DOOR_TYPE7 ) \ + E( DOOR_TYPE8 ) \ + E( PUSHPULL_DOOR1 ) \ + E( PUSHPULL_DOOR2 ) \ + E( KICK_DOOR1 ) \ + E( KICK_DOOR2 ) \ + E( UNDERWATER_DOOR ) \ + E( DOUBLE_DOORS ) \ + E( BRIDGE_FLAT ) \ + E( BRIDGE_TILT1 ) \ + E( BRIDGE_TILT2 ) \ + E( SARCOPHAGUS ) \ + E( SEQUENCE_DOOR1 ) \ + E( SEQUENCE_SWITCH1 ) \ + E( SEQUENCE_SWITCH2 ) \ + E( SEQUENCE_SWITCH3 ) \ + E( SARCOPHAGUS_CUT ) \ + E( HORUS_STATUE ) \ + E( GOD_HEAD ) \ + E( SETH_DOOR ) \ + E( STATUE_PLINTH ) \ + E( PISTOLS_ITEM ) \ + E( PISTOLS_AMMO_ITEM ) \ + E( UZI_ITEM ) \ + E( UZI_AMMO_ITEM ) \ + E( SHOTGUN_ITEM ) \ + E( SHOTGUN_AMMO1_ITEM ) \ + E( SHOTGUN_AMMO2_ITEM ) \ + E( CROSSBOW_ITEM ) \ + E( CROSSBOW_AMMO1_ITEM ) \ + E( CROSSBOW_AMMO2_ITEM ) \ + E( CROSSBOW_AMMO3_ITEM ) \ + E( CROSSBOW_BOLT ) \ + E( GRENADE_GUN_ITEM ) \ + E( GRENADE_GUN_AMMO1_ITEM ) \ + E( GRENADE_GUN_AMMO2_ITEM ) \ + E( GRENADE_GUN_AMMO3_ITEM ) \ + E( ___GRENADE ) \ + E( REVOLVER_ITEM ) \ + E( REVOLVER_AMMO_ITEM ) \ + E( ___INV_MEDIKIT_BIG ) \ + E( ___INV_MEDIKIT_SMALL ) \ + E( LASERSIGHT_ITEM ) \ + E( BINOCULARS_ITEM ) \ + E( ___FLARES ) \ + E( ___INV_FLARES ) \ + E( ___INV_PASSPORT ) \ + E( ___INV_COMPASS ) \ + E( MEMCARD_LOAD_INV_ITEM ) \ + E( MEMCARD_SAVE_INV_ITEM ) \ + E( PC_LOAD_INV_ITEM ) \ + E( PC_SAVE_INV_ITEM ) \ + E( SMOKE_EMITTER_WHITE ) \ + E( SMOKE_EMITTER_BLACK ) \ + E( STEAM_EMITTER ) \ + E( ___EARTHQUAKE ) \ + E( BUBBLES ) \ + E( WATERFALLMIST ) \ + E( GUNSHELL ) \ + E( SHOTGUNSHELL ) \ + E( ___MUZZLE_FLASH ) \ + E( BUTTERFLY ) \ + E( SPRINKLER ) \ + E( RED_LIGHT ) \ + E( GREEN_LIGHT ) \ + E( BLUE_LIGHT ) \ + E( AMBER_LIGHT ) \ + E( WHITE_LIGHT ) \ + E( BLINKING_LIGHT ) \ + E( LENS_FLARE ) \ + E( ___AI_GUARD ) \ + E( ___AI_AMBUSH ) \ + E( AI_PATROL1 ) \ + E( ___AI_MODIFY ) \ + E( ___AI_FOLLOW ) \ + E( AI_PATROL2 ) \ + E( AI_X1 ) \ + E( AI_X2 ) \ + E( LARA_START_POS ) \ + E( ___KILL_ALL_TRIGGERS ) \ + E( TRIGGER_TRIGGERER ) \ + E( SMASH_OBJECT1 ) \ + E( SMASH_OBJECT2 ) \ + E( SMASH_OBJECT3 ) \ + E( SMASH_OBJECT4 ) \ + E( SMASH_OBJECT5 ) \ + E( SMASH_OBJECT6 ) \ + E( SMASH_OBJECT7 ) \ + E( SMASH_OBJECT8 ) \ + E( MESHSWAP1 ) \ + E( MESHSWAP2 ) \ + E( MESHSWAP3 ) \ + E( DEATH_SLIDE ) \ + E( BODY_PART ) \ + E( CAMERA_TARGET ) \ + E( WATERFALL1 ) \ + E( WATERFALL2 ) \ + E( WATERFALL3 ) \ + E( PLANET_EFFECT ) \ + E( ANIMATING1 ) \ + E( ANIMATING1_MIP ) \ + E( ANIMATING2 ) \ + E( ANIMATING2_MIP ) \ + E( ANIMATING3 ) \ + E( ANIMATING3_MIP ) \ + E( ANIMATING4 ) \ + E( ANIMATING4_MIP ) \ + E( ANIMATING5 ) \ + E( ANIMATING5_MIP ) \ + E( ANIMATING6 ) \ + E( ANIMATING6_MIP ) \ + E( ANIMATING7 ) \ + E( ANIMATING7_MIP ) \ + E( ANIMATING8 ) \ + E( ANIMATING8_MIP ) \ + E( ANIMATING9 ) \ + E( ANIMATING9_MIP ) \ + E( ANIMATING10 ) \ + E( ANIMATING10_MIP ) \ + E( ANIMATING11 ) \ + E( ANIMATING11_MIP ) \ + E( ANIMATING12 ) \ + E( ANIMATING12_MIP ) \ + E( ANIMATING13 ) \ + E( ANIMATING13_MIP ) \ + E( ANIMATING14 ) \ + E( ANIMATING14_MIP ) \ + E( ANIMATING15 ) \ + E( ANIMATING15_MIP ) \ + E( ANIMATING16 ) \ + E( ANIMATING16_MIP ) \ + E( ___SKY ) \ + E( SKY_GRAPHICS ) \ + E( BINOCULAR_GRAPHICS ) \ + E( TARGET_GRAPHICS ) \ + E( ___GLYPHS ) \ + E( ___MISC_SPRITES ) \ + E( MOTOR_BOAT ) \ + E( MOTOR_BOAT_LARA ) \ + E( RUBBER_BOAT ) \ + E( RUBBER_BOAT_LARA ) \ + E( MOTORBIKE_LARA ) \ + E( FONT_GRAPHICS ) \ + E( PARALLEL_BARS ) \ + E( PANEL_BORDER ) \ + E( PANEL_MIDDLE ) \ + E( PANEL_CORNER ) \ + E( PANEL_DIAGONAL ) \ + E( PANEL_STRIP ) \ + E( PANEL_HALF_BORDER1 ) \ + E( PANEL_HALF_BORDER2 ) \ + E( PANEL_MIDDLE_CORNER ) \ + E( TIGHT_ROPE ) \ + E( LASER_HEAD ) \ + E( LASER_HEAD_BASE ) \ + E( LASER_HEAD_TENTACLE ) \ + E( HYDRA ) \ + E( HYDRA_MISSILE ) \ + E( ENEMY_SUB_MARINE ) \ + E( ENEMY_SUB_MARINE_MIP ) \ + E( SUB_MARINE_MISSILE ) \ + E( FROG_MAN ) \ + E( FROG_MAN_HARPOON ) \ + E( FISH_EMITTER ) \ + E( KAYAK ) \ + E( KAYAK_LARA ) \ + E( CUSTOM_SPRITES ) \ + E( BRIDGE_TILT3 ) \ + E( BRIDGE_TILT4 ) \ + E( BRIDGE_CUSTOM ) \ + E( ROBOT_CLEANER ) \ + E( ROBOT_STAR_WARS ) \ + E( MECH_WARRIOR ) \ + E( MECH_WARRIOR_LARA ) \ + E( UW_PROPULSOR ) \ + E( UW_PROPULSOR_LARA ) \ + E( MINE_CART ) \ + E( MINE_CART_LARA ) \ + E( NEW_SLOT5 ) \ + E( NEW_SLOT6 ) \ + E( NEW_SLOT7 ) \ + E( NEW_SLOT8 ) \ + E( NEW_SLOT9 ) \ + E( NEW_SLOT10 ) \ + E( NEW_SLOT11 ) \ + E( NEW_SLOT12 ) \ + E( NEW_SLOT13 ) \ + E( NEW_SLOT14 ) \ + E( NEW_SLOT15 ) \ + E( NEW_SLOT16 ) \ + E( NEW_SLOT17 ) \ + E( NEW_SLOT18 ) \ + E( TR4_TYPE_MAX ) namespace TR { @@ -895,7 +1419,6 @@ namespace TR { DRAW_LEFTGUN , SHOT_RIGHTGUN , SHOT_LEFTGUN , - UNKNOWN , MESH_SWAP_1 , MESH_SWAP_2 , MESH_SWAP_3 , @@ -985,6 +1508,13 @@ namespace TR { SND_TNT = 170, SND_MUTANT_DEATH = 171, SND_SECRET = 173, + + SND_HELICOPTER = 297, + + SND_WINSTON_SCARED = 344, + SND_WINSTON_WALK = 345, + SND_WINSTON_PUSH = 346, + SND_WINSTON_TRAY = 347, }; enum { @@ -1025,6 +1555,9 @@ namespace TR { SOUNDTRACK , // play soundtrack EFFECT , // special effect trigger SECRET , // secret found + CLEAR_BODIES , // clear all dead bodies + FLYBY , // play flyby camera sequence + CUTSCENE , // play cutscene }; }; @@ -1082,9 +1615,13 @@ namespace TR { }; } - struct fixed { - uint16 L; - int16 H; + union fixed { + uint32 value; + struct { + uint16 L; + int16 H; + }; + operator float() const { return H + L / 65535.0f; } @@ -1107,7 +1644,8 @@ namespace TR { }; struct TextureInfo { - TextureType type; + TextureType type; // determines in which atlas this texture will be stored + TextureType dataType; // original texture type from file uint16 index; uint16 clut; uint16 tile; @@ -1118,8 +1656,15 @@ namespace TR { uint16 sub[4], i5; + TextureInfo() {} + + TextureInfo(TextureType type, int16 l, int16 t, int16 r, int16 b, uint8 tx, uint8 ty, uint8 tw, uint8 th) : type(type), dataType(type), attribute(1), l(l), t(t), r(r), b(b) { + texCoord[0] = texCoordAtlas[0] = short2( tx, ty ); + texCoord[1] = texCoordAtlas[1] = short2( tx + tw - 1, ty + th - 1 ); + } + short4 getMinMax() const { - if (type == TEX_TYPE_SPRITE) + if (dataType == TEX_TYPE_SPRITE) return short4( texCoord[0].x, texCoord[0].y, texCoord[1].x, texCoord[1].y ); return short4( @@ -1131,7 +1676,7 @@ namespace TR { } short4 getMinMaxAtlas() const { - if (type == TEX_TYPE_SPRITE) + if (dataType == TEX_TYPE_SPRITE) return short4( texCoordAtlas[0].x, texCoordAtlas[0].y, texCoordAtlas[1].x, texCoordAtlas[1].y ); return short4( @@ -1155,10 +1700,20 @@ namespace TR { uint16 value; } flags; + union { + struct { uint16 additive:1, env:1, shininess:6; }; + uint16 value; + } effects; + short3 normal; uint16 vertices[4]; uint8 triangle:1, colored:1, water:1, flip:5; + Face() : triangle(0), colored(0), water(0), flip(0) { + flags.value = 0; + effects.value = 0; + } + static int cmp(const Face &a, const Face &b) { int aIndex = a.flags.texture; int bIndex = b.flags.texture; @@ -1197,30 +1752,6 @@ namespace TR { #define FACE4_SIZE (sizeof(uint16) + sizeof(uint16) * 4) // flags + vertices[4] #define FACE3_SIZE (FACE4_SIZE - sizeof(uint16)) - struct ColorIndex4 { - uint8 a:4, b:4; - }; - - struct Tile4 { - ColorIndex4 index[256 * 256 / 2]; - }; - - struct Tile8 { - uint8 index[256 * 256]; - }; - - struct Tile16 { - Color16 color[256 * 256]; - }; - - struct Tile32 { - Color32 color[256 * 256]; // + 128 for mips data - }; - - struct CLUT { - Color16 color[16]; - }; - struct Room { struct Info { @@ -1295,8 +1826,8 @@ namespace TR { }; uint16 value; } flags; - uint16 reverbType; uint8 waterScheme; + uint8 reverbType; uint8 filter; uint8 align; int32 waterLevel[2]; // water level for normal and flipped level state @@ -1339,9 +1870,19 @@ namespace TR { } *sectors; struct Light { + + enum Type { + DIRECT, POINT, SPOT, SHADOW, FOG + }; + int32 x, y, z; uint32 radius; - Color32 color; + int32 intensity; + Color24 color; + float in, out; + float length, cutoff; + vec3 dir; + uint8 type; } *lights; struct Mesh { @@ -1352,10 +1893,18 @@ namespace TR { uint32 meshIndex; // index into static meshes array } *meshes; + bool contains(const vec3 &p) const { + return p.x >= info.x && p.x <= info.x + xSectors * 1024 && p.z >= info.z && p.z <= info.z + zSectors * 1024 && p.y >= info.yTop && p.y <= info.yBottom; + } + vec3 getOffset() const { return vec3(float(info.x), 0.0f, float(info.z)); } + vec3 getCenter() const { + return vec3(info.x + xSectors * 512.0f, (info.yBottom + info.yTop) * 0.5f, info.z + zSectors * 512.0f); + } + Sector* getSector(int sx, int sz) { if (sz <= 0 || sz >= zSectors - 1) { sz = clamp(sz, 0, zSectors - 1); @@ -1401,6 +1950,40 @@ namespace TR { break; } } + + int getAmbient(int x, int y, int z, Light **nearLight = NULL) const { + if (!lightsCount) { + return ambient; + } + + int ambientInv = 0x1FFF - ambient; + int maxValue = 0; + + for (int i = 0; i < lightsCount; i++) { + Light &light = lights[i]; + if (light.intensity > 8192) + continue; + + int dx = x - light.x; + int dy = y - light.y; + int dz = z - light.z; + + int D = (SQR(dx) + SQR(dy) + SQR(dz)) >> 12; + int R = SQR(light.radius >> 1) >> 12; + int M = max(1, D + R); // TODO TR4 + + int value = min(0x1FFF, (light.intensity * R) / M + ambientInv); + + if (maxValue < value) { + if (nearLight) { + *nearLight = &light; + } + maxValue = value; + } + } + + return 0x1FFF - (maxValue + ambientInv) / 2; + } }; union FloorData { @@ -1507,7 +2090,10 @@ namespace TR { int32 x, y, z; angle rotation; int16 intensity; - int16 intensity2; + union { + int16 intensity2; + int16 OCB; + }; union Flags { struct { uint16 state:2, unused:3, smooth:1, :1, invisible:1, once:1, active:5, reverse:1, rendered:1; @@ -1528,8 +2114,12 @@ namespace TR { if (version & VER_TR3) type = Type(type + TR3_TYPES_START); - #define REMAP_2(TYPE) case _##TYPE : return TYPE - #define REMAP_3(TYPE) case __##TYPE : return TYPE + if (version & VER_TR4) + type = Type(type + TR4_TYPES_START); + + #define REMAP_2(TYPE) case _##TYPE : return TYPE + #define REMAP_3(TYPE) case __##TYPE : return TYPE + #define REMAP_4(TYPE) case ___##TYPE : return TYPE switch (type) { // TR2 @@ -1779,6 +2369,39 @@ namespace TR { REMAP_3( SOUND_DOOR_BELL ); REMAP_3( ENEMY_WINSTON ); REMAP_3( EARTHQUAKE ); + // TR4 + REMAP_4( LARA ); + REMAP_4( LARA_PISTOLS ); + REMAP_4( LARA_UZIS ); + REMAP_4( LARA_SHOTGUN ); + REMAP_4( LARA_GRENADE ); + REMAP_4( LARA_FLARE ); + REMAP_4( LARA_SKIN ); + REMAP_4( LARA_BRAID ); + REMAP_4( FLAME ); + REMAP_4( TRAP_FLAME_EMITTER ); + REMAP_4( TRIPWIRE ); + REMAP_4( BLOCK_1 ); + REMAP_4( BLOCK_2 ); + REMAP_4( BLOCK_3 ); + REMAP_4( BLOCK_4 ); + REMAP_4( GRENADE ); + REMAP_4( INV_MEDIKIT_BIG ); + REMAP_4( INV_MEDIKIT_SMALL ); + REMAP_4( FLARES ); + REMAP_4( INV_FLARES ); + REMAP_4( INV_PASSPORT ); + REMAP_4( INV_COMPASS ); + REMAP_4( EARTHQUAKE ); + REMAP_4( MUZZLE_FLASH ); + REMAP_4( AI_GUARD ); + REMAP_4( AI_AMBUSH ); + REMAP_4( AI_MODIFY ); + REMAP_4( AI_FOLLOW ); + REMAP_4( KILL_ALL_TRIGGERS ); + REMAP_4( SKY ); + //REMAP_4( GLYPHS ); + REMAP_4( MISC_SPRITES ); default : return type; } @@ -1887,7 +2510,7 @@ namespace TR { } bool isBlock() const { - return type >= BLOCK_1 && type <= BLOCK_4; + return type == BLOCK_1 || type == BLOCK_2 || type == BLOCK_3 || type == BLOCK_4 || type == BLOCK_5; } bool isLara() const { @@ -1901,7 +2524,7 @@ namespace TR { } bool castShadow() const { - return isLara() || isEnemy() || isVehicle() || isActor() || type == DART || type == TRAP_SWORD; + return isLara() || isEnemy() || isVehicle() || isActor() || type == DART || type == TRAP_SWORD || type == ENEMY_WINSTON || type == ENEMY_WINSTON_CAMO; } void getAxis(int &dx, int &dz) { @@ -1941,7 +2564,7 @@ namespace TR { && type != ENEMY_MUMMY && type != ENEMY_NATLA) opaque = true; - if (type == SWITCH || type == SWITCH_WATER) + if (type == SWITCH || type == SWITCH_WATER || type == CUT_1) opaque = true; if ((type >= PUZZLE_HOLE_1 && type <= PUZZLE_HOLE_4) || type == LIGHTNING) opaque = false; @@ -2005,6 +2628,9 @@ namespace TR { fixed speed; fixed accel; + fixed speedLateral; + fixed accelLateral; + uint16 frameStart; uint16 frameEnd; uint16 nextAnimation; @@ -2042,7 +2668,7 @@ namespace TR { short3 pos; uint16 angles[1]; // angle frames in YXZ order, first angle must be skipped in TR1 - #define ANGLE_SCALE (2.0f * PI / 1024.0f) + #define ANGLE_SCALE (PI2 / 1024.0f) vec3 unpack(uint16 a, uint16 b) { return vec3(float((a & 0x3FF0) >> 4), float( ((a & 0x000F) << 6) | ((b & 0xFC00) >> 10)), float(b & 0x03FF)) * ANGLE_SCALE; @@ -2055,21 +2681,26 @@ namespace TR { index = joint * 2 + 1; uint16 b = angles[index++]; uint16 a = angles[index++]; - if (version & VER_SAT) + if (version & VER_SAT) { swap(a, b); + } return unpack(a, b); - } - - if (version & (VER_TR2 | VER_TR3)) { - - // TODO: remove this !!! - for (int i = 0; i < joint; i++) - if (!(angles[index++] & 0xC000)) + } else { + // TODO: optimize this !!! + for (int i = 0; i < joint; i++) { + if (!(angles[index++] & 0xC000)) { index++; + } + } uint16 a = angles[index++]; - float rot = float(a & 0x03FF) * ANGLE_SCALE; + float rot; + if (((version & VER_VERSION) >= VER_TR4)) { + rot = float(a & 0x0FFF) * (PI2 / 4096.0f); + } else { + rot = float(a & 0x03FF) * (PI2 / 1024.0f); + } switch (a & 0xC000) { case 0x4000 : return vec3(rot, 0, 0); @@ -2147,6 +2778,19 @@ namespace TR { } flags; }; + struct FlybyCamera { + int32 x, y, z; + int32 dx, dy, dz; + uint8 sequence; + uint8 index; + uint16 fov; + int16 roll; + uint16 timer; + uint16 speed; + uint16 flags; + uint32 room; + }; + struct CameraFrame { short3 target; short3 pos; @@ -2154,6 +2798,15 @@ namespace TR { int16 roll; }; + struct AIObject { + uint16 type; + uint16 room; + int32 x, y, z; + uint16 OCB; + uint16 flags; + int32 angle; + }; + struct SoundSource { int32 x, y, z; // absolute position of sound source (world coordinates) uint16 id; // internal sample index @@ -2228,8 +2881,6 @@ namespace TR { int32 tilesCount; - uint32 unused; - uint16 roomsCount; Room *rooms; @@ -2301,6 +2952,9 @@ namespace TR { int32 camerasCount; Camera *cameras; + int32 flybyCamerasCount; + FlybyCamera *flybyCameras; + int32 soundSourcesCount; SoundSource *soundSources; @@ -2317,19 +2971,27 @@ namespace TR { int32 entitiesCount; Entity *entities; + uint8 lightmap[32 * 256]; // color indices table for 32 shades Color24 *palette; Color32 *palette32; + uint16 kanjiSprite; int32 clutsCount; CLUT *cluts; Tile4 *tiles4; Tile8 *tiles8; Tile16 *tiles16; + Tile32 *tiles32; + Tile32 *tilesMisc; + uint16 cameraFramesCount; CameraFrame *cameraFrames; + AIObject *AIObjects; + uint32 AIObjectsCount; + uint16 demoDataSize; uint8 *demoData; @@ -2338,6 +3000,7 @@ namespace TR { int32 soundsInfoCount; SoundInfo *soundsInfo; + int32 soundsCount; int32 soundDataSize; uint8 *soundData; @@ -2441,20 +3104,21 @@ namespace TR { int16 braid; int16 laraSpec; int16 laraSkin; + int16 laraJoints; int16 meshSwap[3]; int16 sky; int16 smoke; int16 waterSplash; int16 glyphs; - struct { + struct Weapon { int16 items[MAX_WEAPONS]; int16& operator[] (Entity::Type type) { return items[getWeaponIndex(type)]; }; } weapons; - struct { + struct Inventory { int16 passport; int16 passport_closed; int16 map; @@ -2467,14 +3131,14 @@ namespace TR { int16 gamma; int16 explosive; - struct { + struct Weapon { int16 items[MAX_WEAPONS]; int16& operator[] (Entity::Type type) { return items[getWeaponIndex(type)]; }; } weapons; - struct { + struct Ammo { int16 items[MAX_WEAPONS]; int16& operator[] (Entity::Type type) { return items[getWeaponIndex(type)]; @@ -2495,10 +3159,10 @@ namespace TR { Level(Stream &stream) { memset(this, 0, sizeof(*this)); - version = VER_UNKNOWN; - cutEntity = -1; + version = VER_UNKNOWN; + cutEntity = -1; + meshesCount = 0; - int startPos = stream.pos; uint32 magic; #define MAGIC_TR1_PC 0x00000020 @@ -2509,87 +3173,34 @@ namespace TR { #define MAGIC_TR3_PC2 0xFF180038 #define MAGIC_TR3_PC3 0xFF180034 #define MAGIC_TR3_PSX 0xFFFFFFC8 + #define MAGIC_TR4_PC 0x00345254 id = TR::getLevelID(stream.size, stream.name, version, isDemoLevel); - if (version == VER_UNKNOWN || version == VER_TR1_PSX) { + if (version == VER_UNKNOWN || version == VER_TR1_PC || version == VER_TR1_PSX || version == VER_TR1_SAT || version == VER_TR3_PSX) { stream.read(magic); - if (magic == MAGIC_TR1_SAT) { - version = VER_TR1_SAT; - - stream.seek(-4); - // get file name without extension - int len = strlen(stream.name); - char *name = new char[len + 1]; - memcpy(name, stream.name, len); - for (int i = len - 1; i >= 0; i--) { - if (name[i] == '/' || name[i] == '\\') - break; - if (name[i] == '.') { - len = i; - break; - } - } - name[len] = 0; - LOG("load Sega Saturn level: %s\n", name); - - strcat(name, ".SAD"); - Stream sad(name); - name[len] = '\0'; - strcat(name, ".SPR"); - Stream spr(name); - name[len] = '\0'; - strcat(name, ".SND"); - Stream snd(name); - name[len] = '\0'; - strcat(name, ".CIN"); - - Stream *cin = NULL; - if (Stream::existsContent(name)) { - cin = new Stream(name); - } else { - len = strlen(name); - for (int i = len - 1; i >= 0; i--) - if (name[i] == '/' || name[i] == '\\') { - char *newName = new char[len + 11 + 1]; - name[i] = 0; - strcpy(newName, name); - strcat(newName, "/../CINDATA/"); - strcat(newName, name + i + 1); - delete[] name; - name = newName; - break; - } - - if (Stream::existsContent(name)) - cin = new Stream(name); - } - - delete[] name; - - readSAT(sad); - readSAT(spr); - readSAT(snd); - if (cin) { - readCIN(*cin); - delete cin; - } - readSAT(stream); // sat - return; - } - if (magic != MAGIC_TR1_PC && magic != MAGIC_TR2_PC && magic != MAGIC_TR3_PC1 && magic != MAGIC_TR3_PC2 && magic != MAGIC_TR3_PC3 && magic != MAGIC_TR3_PSX) { + if (magic != MAGIC_TR1_PC && + magic != MAGIC_TR1_SAT && + magic != MAGIC_TR2_PC && + magic != MAGIC_TR3_PC1 && + magic != MAGIC_TR3_PC2 && + magic != MAGIC_TR3_PC3 && + magic != MAGIC_TR3_PSX && + magic != MAGIC_TR4_PC) { stream.read(magic); } switch (magic) { case MAGIC_TR1_PC : version = VER_TR1_PC; break; case MAGIC_TR1_PSX : version = VER_TR1_PSX; break; + case MAGIC_TR1_SAT : version = VER_TR1_SAT; break; case MAGIC_TR2_PC : version = VER_TR2_PC; break; case MAGIC_TR3_PC1 : case MAGIC_TR3_PC2 : case MAGIC_TR3_PC3 : version = VER_TR3_PC; break; case MAGIC_TR3_PSX : version = VER_TR3_PSX; break; + case MAGIC_TR4_PC : version = VER_TR4_PC; break; default : ; } } @@ -2600,64 +3211,151 @@ namespace TR { return; } - if (version == VER_TR2_PSX) { - stream.read(soundOffsets, stream.read(soundOffsetsCount) + 1); - soundSize = new uint32[soundOffsetsCount]; - soundDataSize = 0; - for (int i = 0; i < soundOffsetsCount; i++) { - ASSERT(soundOffsets[i] < soundOffsets[i + 1]); - soundSize[i] = soundOffsets[i + 1] - soundOffsets[i]; - soundOffsets[i] = soundDataSize; - soundDataSize += soundSize[i]; - } - stream.read(soundData, soundDataSize); + #ifdef _GAPI_SW + ASSERT((version & VER_TR1_PC) == VER_TR1_PC); + if ((version & VER_TR1_PC) != VER_TR1_PC) { + return; } + #endif - if (version == VER_TR3_PSX) { - stream.read(soundOffsets, stream.read(soundOffsetsCount)); - if (soundOffsetsCount) { - stream.read(soundDataSize); - stream.read(soundData, soundDataSize); - soundSize = new uint32[soundOffsetsCount]; - int size = 0; - for (int i = 0; i < soundOffsetsCount - 1; i++) { - ASSERT(soundOffsets[i] < soundOffsets[i + 1]); - size += soundSize[i] = soundOffsets[i + 1] - soundOffsets[i]; - } + #ifdef _GAPI_GU + ASSERT((version & VER_TR1_PSX) == VER_TR1_PSX); + if ((version & VER_TR1_PSX) != VER_TR1_PSX) { + return; + } + #endif - if (soundOffsetsCount) { - soundSize[soundOffsetsCount - 1] = soundDataSize; - if (soundOffsetsCount > 1) - soundSize[soundOffsetsCount - 1] -= soundSize[soundOffsetsCount - 2]; - } - } + switch (version) { + case VER_TR1_PC : loadTR1_PC (stream); break; + case VER_TR1_PSX : loadTR1_PSX (stream); break; + case VER_TR1_SAT : loadTR1_SAT (stream); break; + case VER_TR2_PC : loadTR2_PC (stream); break; + case VER_TR2_PSX : loadTR2_PSX (stream); break; + case VER_TR3_PC : loadTR3_PC (stream); break; + case VER_TR3_PSX : loadTR3_PSX (stream); break; + #ifdef USE_INFLATE + case VER_TR4_PC : loadTR4_PC (stream); break; + #endif + case VER_TR4_PSX : loadTR4_PSX (stream); break; + case VER_TR4_SDC : loadTR4_SDC (stream); break; + case VER_TR5_PC : loadTR5_PC (stream); break; + case VER_TR5_PSX : loadTR5_PSX (stream); break; + case VER_TR5_SDC : loadTR5_SDC (stream); break; + default : ASSERT(false); + } - // skip code modules - int size; - for (int i = 0; i < 13; i++) { - stream.read(size); - if (size) { - stream.seek(size); - stream.read(size); - stream.seek(size); - } - } + prepare(); + } + + ~Level() { + // rooms + for (int i = 0; i < roomsCount; i++) { + Room &r = rooms[i]; + delete[] r.data.vertices; + delete[] r.data.faces; + delete[] r.data.sprites; + delete[] r.portals; + delete[] r.sectors; + delete[] r.lights; + delete[] r.meshes; } + delete[] rooms; + delete[] floors; + delete[] meshOffsets; + delete[] anims; + delete[] states; + delete[] ranges; + delete[] commands; + delete[] nodesData; + delete[] frameData; + delete[] models; + delete[] staticMeshes; + delete[] objectTextures; + delete[] objectTexturesData; + delete[] roomTextures; + delete[] roomTexturesData; + delete[] itemTextures; + delete[] itemTexturesData; + delete[] spriteTextures; + delete[] spriteSequences; + delete[] spriteTexturesData; + delete[] cameras; + delete[] flybyCameras; + delete[] soundSources; + delete[] boxes; + delete[] overlaps; + for (int i = 0; i < 2; i++) { + delete[] zones[i].ground1; + delete[] zones[i].ground2; + delete[] zones[i].ground3; + delete[] zones[i].ground4; + delete[] zones[i].fly; + } + for (int i = 0; i < animTexturesCount; i++) + delete[] animTextures[i].textures; + delete[] animTextures; + delete[] entities; + delete[] palette; + delete[] palette32; + delete[] cluts; + delete[] tiles4; + delete[] tiles8; + delete[] tiles16; + delete[] tiles32; + delete[] tilesMisc; + delete[] cameraFrames; + delete[] AIObjects; + delete[] demoData; + delete[] soundsMap; + delete[] soundsInfo; + delete[] soundData; + delete[] soundOffsets; + delete[] soundSize; - if (version == VER_TR2_PC || version == VER_TR3_PC) { - stream.read(palette, 256); - stream.read(palette32, 256); + delete[] tsub; + } + + void loadTR1_PC (Stream &stream) { + stream.read(tiles8, stream.read(tilesCount)); + + readDataArrays(stream); + readObjectTex(stream); + readSpriteTex(stream); + + if (isDemoLevel) { + stream.read(palette, 256); + } + + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readEntities(stream); + readLightMap(stream); + + if (!isDemoLevel) { + stream.read(palette, 256); } - if (version == VER_TR1_PSX && !isCutsceneLevel()) { + readCameraFrames(stream); + readDemoData(stream); + readSoundMap(stream); + readSoundData(stream); + readSoundOffsets(stream); + } + + void loadTR1_PSX (Stream &stream) { + if (!isCutsceneLevel()) { uint32 offsetTexTiles; stream.seek(8); stream.read(offsetTexTiles); // sound offsets uint16 numSounds; - stream.setPos(startPos + 22); + stream.setPos(22); stream.read(numSounds); - stream.setPos(startPos + 2086 + numSounds * 512); + stream.setPos(2086 + numSounds * 512); soundOffsetsCount = numSounds; soundOffsets = new uint32[soundOffsetsCount]; soundSize = new uint32[soundOffsetsCount]; @@ -2669,113 +3367,463 @@ namespace TR { soundDataSize += soundSize[i] = size * 8; } // sound data - stream.setPos(startPos + 2600 + numSounds * 512); + stream.setPos(2600 + numSounds * 512); stream.read(soundData, soundDataSize); - stream.setPos(startPos + offsetTexTiles + 8); + stream.setPos(offsetTexTiles + 8); + } + + stream.read(tiles4, tilesCount = 13); + stream.read(cluts, clutsCount = 1024); + + readDataArrays(stream); + readObjectTex(stream); + readSpriteTex(stream); + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readEntities(stream); + readSoundMap(stream); + stream.seek(4); + readCameraFrames(stream); + } + + void loadTR1_SAT (Stream &stream) { + stream.seek(-4); // no magic header + + // get file name without extension + size_t len = strlen(stream.name); + char *name = new char[len + 1]; + memcpy(name, stream.name, len); + for (int i = int(len) - 1; i >= 0; i--) { + if (name[i] == '/' || name[i] == '\\') + break; + if (name[i] == '.') { + len = i; + break; + } } + name[len] = 0; + + LOG("load Sega Saturn level: %s\n", name); + + strcat(name, ".SAD"); + Stream sad(name); + name[len] = '\0'; + strcat(name, ".SPR"); + Stream spr(name); + name[len] = '\0'; + strcat(name, ".SND"); + Stream snd(name); + name[len] = '\0'; + strcat(name, ".CIN"); + + Stream *cin = NULL; + if (Stream::existsContent(name)) { + cin = new Stream(name); + } else { + len = strlen(name); + for (int i = int(len) - 1; i >= 0; i--) + if (name[i] == '/' || name[i] == '\\') { + char *newName = new char[len + 11 + 1]; + name[i] = 0; + strcpy(newName, name); + strcat(newName, "/../CINDATA/"); + strcat(newName, name + i + 1); + delete[] name; + name = newName; + break; + } - // tiles - if (version & VER_PC) { - stream.read(tiles8, stream.read(tilesCount)); + if (Stream::existsContent(name)) + cin = new Stream(name); } - if (version == VER_TR2_PC || version == VER_TR3_PC) - stream.read(tiles16, tilesCount); + delete[] name; - if (version == VER_TR1_PSX) { - stream.read(tiles4, tilesCount = 13); - stream.read(cluts, clutsCount = 1024); + readSAT(sad); + readSAT(spr); + readSAT(snd); + if (cin) { + readCIN(*cin); + delete cin; } + readSAT(stream); // sat + } - if (version != VER_TR3_PSX) - stream.read(unused); + void loadTR2_PC (Stream &stream) { + stream.read(palette, 256); + stream.read(palette32, 256); + stream.read(tiles8, stream.read(tilesCount)); + stream.read(tiles16, tilesCount); - // rooms - rooms = stream.read(roomsCount) ? new Room[roomsCount] : NULL; - for (int i = 0; i < roomsCount; i++) - readRoom(stream, i); + readDataArrays(stream); + readObjectTex(stream); + readSpriteTex(stream); + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readEntities(stream); + readLightMap(stream); + readCameraFrames(stream); + readDemoData(stream); + readSoundMap(stream); + readSoundOffsets(stream); - // floors - stream.read(floors, stream.read(floorsCount)); + new Stream(getGameSoundsFile(version), sfxLoadAsync, this); + } - if (version == VER_TR3_PSX) { - // outside room offsets - stream.seek(27 * 27 * 2); - // outside rooms table - int size; - stream.read(size); - stream.seek(size); - // room mesh bbox - stream.read(size); - stream.seek(8 * size); + void loadTR2_PSX (Stream &stream) { + stream.read(soundOffsets, stream.read(soundOffsetsCount) + 1); + soundSize = new uint32[soundOffsetsCount]; + soundDataSize = 0; + for (int i = 0; i < soundOffsetsCount; i++) { + ASSERT(soundOffsets[i] < soundOffsets[i + 1]); + soundSize[i] = soundOffsets[i + 1] - soundOffsets[i]; + soundOffsets[i] = soundDataSize; + soundDataSize += soundSize[i]; } + stream.read(soundData, soundDataSize); - // meshes - meshesCount = 0; - stream.read(meshData, stream.read(meshDataSize)); - stream.read(meshOffsets, stream.read(meshOffsetsCount)); - // animations - - stream.read(anims, stream.read(animsCount)); - stream.read(states, stream.read(statesCount)); - stream.read(ranges, stream.read(rangesCount)); - stream.read(commands, stream.read(commandsCount)); - stream.read(nodesData, stream.read(nodesDataSize)); - stream.read(frameData, stream.read(frameDataSize)); - // models - models = stream.read(modelsCount) ? new Model[modelsCount] : NULL; - for (int i = 0; i < modelsCount; i++) { - Model &m = models[i]; - uint16 type; - m.type = Entity::Type(stream.read(type)); - stream.seek(sizeof(m.index)); - m.index = i; - stream.read(m.mCount); - stream.read(m.mStart); - stream.read(m.node); - stream.read(m.frame); - stream.read(m.animation); - if (version & VER_PSX) - stream.seek(2); - } - stream.read(staticMeshes, stream.read(staticMeshesCount)); + readDataArrays(stream); - if (version == VER_TR2_PSX || version == VER_TR3_PSX) { - stream.read(tiles4, stream.read(tilesCount)); + stream.read(tiles4, stream.read(tilesCount)); + stream.read(clutsCount); + if (clutsCount > 1024) { // check for japanese version (read kanji CLUT index) + kanjiSprite = clutsCount & 0xFFFF; + stream.seek(-2); stream.read(clutsCount); - if (clutsCount > 1024) { // check for japanese version (skip 2 bytes after tiles data) - stream.seek(-2); - stream.read(clutsCount); - } - if (version == VER_TR3_PSX) - clutsCount *= 2; // read underwater cluts too - stream.read(cluts, clutsCount); - if (version != VER_TR3_PSX) - stream.seek(4); } + stream.read(cluts, clutsCount); + stream.seek(4); + readObjectTex(stream); + readSpriteTex(stream); + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readEntities(stream); + stream.seek(4); + readSoundMap(stream); + stream.seek(4); + readCameraFrames(stream); + } - // textures & UV - if (version != VER_TR3_PC) - readObjectTex(stream); + void loadTR3_PC (Stream &stream) { + stream.read(palette, 256); + stream.read(palette32, 256); + stream.read(tiles8, stream.read(tilesCount)); + stream.read(tiles16, tilesCount); + + readDataArrays(stream); readSpriteTex(stream); - // palette for demo levels - if (version == VER_TR1_PC && isDemoLevel) stream.read(palette, 256); - // cameras - stream.read(cameras, stream.read(camerasCount)); - // sound sources - stream.read(soundSources, stream.read(soundSourcesCount)); - // AI - boxes = stream.read(boxesCount) ? new Box[boxesCount] : NULL; - for (int i = 0; i < boxesCount; i++) { - Box &b = boxes[i]; - if (version & VER_TR1) { - stream.read(b.minZ); + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readObjectTex(stream); + readEntities(stream); + readLightMap(stream); + readCameraFrames(stream); + readDemoData(stream); + readSoundMap(stream); + readSoundOffsets(stream); + new Stream(getGameSoundsFile(version), sfxLoadAsync, this); + } + + void loadTR3_PSX (Stream &stream) { + readSoundOffsets(stream); + if (soundOffsetsCount) { + readSoundData(stream); + soundSize = new uint32[soundOffsetsCount]; + int size = 0; + for (int i = 0; i < soundOffsetsCount - 1; i++) { + ASSERT(soundOffsets[i] < soundOffsets[i + 1]); + size += soundSize[i] = soundOffsets[i + 1] - soundOffsets[i]; + } + + if (soundOffsetsCount) { + soundSize[soundOffsetsCount - 1] = soundDataSize; + if (soundOffsetsCount > 1) { + soundSize[soundOffsetsCount - 1] -= soundSize[soundOffsetsCount - 2]; + } + } + } + + // skip code modules + int size; + for (int i = 0; i < 13; i++) { + stream.read(size); + if (size) { + stream.seek(size); + stream.read(size); + stream.seek(size); + } + } + + readDataArrays(stream); + + stream.read(tiles4, stream.read(tilesCount)); + stream.read(clutsCount); + if (clutsCount > 1024) { // check for japanese version (read kanji CLUT index) + kanjiSprite = clutsCount & 0xFFFF; + stream.seek(-2); + stream.read(clutsCount); + } + clutsCount *= 2; // read underwater cluts too + stream.read(cluts, clutsCount); + + readObjectTex(stream); + readSpriteTex(stream); + readCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + readEntities(stream); + + stream.read(skyColor); + + roomTexturesCount = stream.readLE32(); + + if (roomTexturesCount) { + roomTextures = new TextureInfo[roomTexturesCount]; + + // load room textures + for (int i = 0; i < roomTexturesCount; i++) { + readObjectTex(stream, roomTextures[i], TEX_TYPE_ROOM); + stream.seek(2 * 16); // skip 2 mipmap levels + } + } + + readSoundMap(stream); + stream.seek(4); + readCameraFrames(stream); + } + + #ifdef USE_INFLATE + void loadTR4_PC (Stream &stream) { + uint16 roomTilesCount, objTilesCount, bumpTilesCount; + uint32 sizeD, sizeC, sizeR; + uint8 *dataC, *dataD; + + stream.read(roomTilesCount); + stream.read(objTilesCount); + stream.read(bumpTilesCount); + + // tiles32 + stream.read(sizeD); + stream.read(dataC, stream.read(sizeC)); + ASSERT(sizeD == sizeof(Tile32) * (roomTilesCount + objTilesCount + bumpTilesCount)); + tiles32 = new Tile32[roomTilesCount + objTilesCount + bumpTilesCount]; + tinf_uncompress(tiles32, &sizeR, dataC + 2, 0); + ASSERT(sizeD == sizeR); + delete[] dataC; + + // tiles16 + stream.read(sizeD); + stream.read(sizeC); + stream.seek(sizeC); // skip compressed 16-bit tiles + + // tiles16 + stream.read(sizeD); + stream.read(dataC, stream.read(sizeC)); + ASSERT(sizeD == sizeof(Tile32) * 2); + tilesMisc = new Tile32[2]; + tinf_uncompress(tilesMisc, &sizeR, dataC + 2, 0); + ASSERT(sizeD == sizeR); + delete[] dataC; + + stream.read(sizeD); + stream.read(dataC, stream.read(sizeC)); + dataD = new uint8[sizeD]; + tinf_uncompress(dataD, &sizeR, dataC + 2, 0); + ASSERT(sizeD == sizeR); + delete[] dataC; + + { + Stream stream(NULL, dataD, sizeD); + readDataArrays(stream); + stream.seek(3); // SPR + readSpriteTex(stream); + readCameras(stream); + readFlybyCameras(stream); + readSoundSources(stream); + readBoxes(stream); + readOverlaps(stream); + readZones(stream); + readAnimTex(stream); + stream.seek(3); // TEX + readObjectTex(stream); + readEntities(stream); + readAIObjects(stream); + readDemoData(stream); + readSoundMap(stream); + readSoundOffsets(stream); + } + delete[] dataD; + + stream.read(soundsCount); + if (soundOffsetsCount <= 0 && soundsCount > 0) { + soundOffsetsCount = soundsCount; + soundOffsets = new uint32[soundOffsetsCount]; + } + soundDataSize = stream.size - stream.pos; + soundData = new uint8[soundDataSize]; + soundDataSize = 0; + for (int i = 0; i < soundsCount; i++) { + stream.read(sizeD); + stream.read(sizeC); + soundOffsets[i] = soundDataSize; + stream.raw(soundData + soundDataSize, sizeC); + soundDataSize += sizeC; + } + } + #endif + + void loadTR4_PSX (Stream &stream) { + + } + + void loadTR4_SDC (Stream &stream) { + + } + + void loadTR5_PC (Stream &stream) { + + } + + void loadTR5_PSX (Stream &stream) { + + } + + void loadTR5_SDC (Stream &stream) { + + } + + void readDataArrays(Stream &stream) { + if (version != VER_TR3_PSX) { + stream.seek(4); + } + + rooms = stream.read(roomsCount) ? new Room[roomsCount] : NULL; + for (int i = 0; i < roomsCount; i++) { + readRoom(stream, i); + } + + stream.read(floors, stream.read(floorsCount)); + + if (version == VER_TR3_PSX) { + // outside room offsets + stream.seek(27 * 27 * 2); + // outside rooms table + int size; + stream.read(size); + stream.seek(size); + // room mesh bbox + stream.read(size); + stream.seek(8 * size); + } + + stream.read(meshData, stream.read(meshDataSize)); + stream.read(meshOffsets, stream.read(meshOffsetsCount)); + + readAnims(stream); + + stream.read(states, stream.read(statesCount)); + stream.read(ranges, stream.read(rangesCount)); + stream.read(commands, stream.read(commandsCount)); + stream.read(nodesData, stream.read(nodesDataSize)); + stream.read(frameData, stream.read(frameDataSize)); + + readModels(stream); + + stream.read(staticMeshes, stream.read(staticMeshesCount)); + } + + void readAnims(Stream &stream) { + stream.read(animsCount); + anims = animsCount ? new Animation[animsCount] : NULL; + for (int i = 0; i < animsCount; i++) { + Animation &anim = anims[i]; + stream.read(anim.frameOffset); + stream.read(anim.frameRate); + stream.read(anim.frameSize); + stream.read(anim.state); + stream.read(anim.speed); + stream.read(anim.accel); + if (version & (VER_TR4 | VER_TR5)) { + stream.read(anim.speedLateral); + stream.read(anim.accelLateral); + } else { + anim.speedLateral.value = 0; + anim.accelLateral.value = 0; + } + stream.read(anim.frameStart); + stream.read(anim.frameEnd); + stream.read(anim.nextAnimation); + stream.read(anim.nextFrame); + stream.read(anim.scCount); + stream.read(anim.scOffset); + stream.read(anim.acCount); + stream.read(anim.animCommand); + } + + } + + void readModels(Stream &stream) { + models = stream.read(modelsCount) ? new Model[modelsCount] : NULL; + for (int i = 0; i < modelsCount; i++) { + Model &m = models[i]; + uint16 type; + m.type = Entity::Type(stream.read(type)); + stream.seek(sizeof(m.index)); + m.index = i; + stream.read(m.mCount); + stream.read(m.mStart); + stream.read(m.node); + stream.read(m.frame); + stream.read(m.animation); + if (version & VER_PSX) { + stream.seek(2); + } + } + } + + void readCameras(Stream &stream) { + stream.read(cameras, stream.read(camerasCount)); + } + + void readFlybyCameras(Stream &stream) { + stream.read(flybyCameras, stream.read(flybyCamerasCount)); + } + + void readSoundSources(Stream &stream) { + stream.read(soundSources, stream.read(soundSourcesCount)); + } + + void readBoxes(Stream &stream) { + boxes = stream.read(boxesCount) ? new Box[boxesCount] : NULL; + for (int i = 0; i < boxesCount; i++) { + Box &b = boxes[i]; + if (version & VER_TR1) { + stream.read(b.minZ); stream.read(b.maxZ); stream.read(b.minX); stream.read(b.maxX); } - if (version & (VER_TR2 | VER_TR3)) { + if (version & (VER_TR2 | VER_TR3 | VER_TR4 | VER_TR5)) { uint8 value; b.minZ = stream.read(value) * 1024; b.maxZ = stream.read(value) * 1024; @@ -2786,8 +3834,13 @@ namespace TR { stream.read(b.floor); stream.read(b.overlap.value); } + } + void readOverlaps(Stream &stream) { stream.read(overlaps, stream.read(overlapsCount)); + } + + void readZones(Stream &stream) { for (int i = 0; i < 2; i++) { stream.read(zones[i].ground1, boxesCount); stream.read(zones[i].ground2, boxesCount); @@ -2800,49 +3853,31 @@ namespace TR { } stream.read(zones[i].fly, boxesCount); } + } - // animated textures - readAnimTex(stream); - - if (version == VER_TR3_PC) - readObjectTex(stream); - - // entities (enemies, items, lara etc.) - readEntities(stream); - - if (version & VER_PC) { - stream.seek(32 * 256); - // palette for release levels - if ((version == VER_TR1_PC) && !isDemoLevel) - stream.read(palette, 256); - // cinematic frames for cameras (PC) - stream.read(cameraFrames, stream.read(cameraFramesCount)); - // demo data - stream.read(demoData, stream.read(demoDataSize)); + void readLightMap(Stream &stream) { + stream.raw(lightmap, 32 * 256); + for (int i = 0; i < 32; i++) { + lightmap[i * 256] = 0; } + } - if (version == VER_TR2_PSX) - stream.seek(4); - - if (version == VER_TR3_PSX) { - stream.read(skyColor); - - roomTexturesCount = stream.readLE32(); + void readCameraFrames(Stream &stream) { + stream.read(cameraFrames, stream.read(cameraFramesCount)); + } - if (roomTexturesCount) { - roomTextures = new TextureInfo[roomTexturesCount]; + void readAIObjects(Stream &stream) { + stream.read(AIObjects, stream.read(AIObjectsCount)); + } - // load room textures - for (int i = 0; i < roomTexturesCount; i++) { - readObjectTex(stream, roomTextures[i], TEX_TYPE_ROOM); - stream.seek(2 * 16); // skip 2 mipmap levels - } - } - } + void readDemoData(Stream &stream) { + stream.read(demoData, stream.read(demoDataSize)); + } - // sounds - stream.read(soundsMap, (version & VER_TR1) ? 256 : 370); - soundsInfo = stream.read(soundsInfoCount) ? new SoundInfo[soundsInfoCount] : NULL; + void readSoundMap(Stream &stream) { + soundsCount = (version & VER_TR1) ? 256 : 370; + stream.read(soundsMap, soundsCount); + soundsInfo = (stream.read(soundsInfoCount) > 0) ? new SoundInfo[soundsInfoCount] : NULL; for (int i = 0; i < soundsInfoCount; i++) { SoundInfo &s = soundsInfo[i]; @@ -2865,99 +3900,75 @@ namespace TR { ASSERT(s.volume <= 1.0f); } - - if (version == VER_TR3_PSX) - stream.seek(4); - - if (version == VER_TR1_PC) { - stream.read(soundData, stream.read(soundDataSize)); - stream.read(soundOffsets, stream.read(soundOffsetsCount)); - } - - if (version == VER_TR2_PC || version == VER_TR3_PC) { - stream.read(soundOffsets, stream.read(soundOffsetsCount)); - new Stream(getGameSoundsFile(version), sfxLoadAsync, this); - } - - // cinematic frames for cameras (PSX) - if (version & VER_PSX) { - if (version != VER_TR3_PSX) - stream.seek(4); - stream.read(cameraFrames, stream.read(cameraFramesCount)); - } - - prepare(); } - ~Level() { - // rooms - for (int i = 0; i < roomsCount; i++) { - Room &r = rooms[i]; - delete[] r.data.vertices; - delete[] r.data.faces; - delete[] r.data.sprites; - delete[] r.portals; - delete[] r.sectors; - delete[] r.lights; - delete[] r.meshes; - } - delete[] rooms; - delete[] floors; - delete[] meshOffsets; - delete[] anims; - delete[] states; - delete[] ranges; - delete[] commands; - delete[] nodesData; - delete[] frameData; - delete[] models; - delete[] staticMeshes; - delete[] objectTextures; - delete[] objectTexturesData; - delete[] roomTextures; - delete[] roomTexturesData; - delete[] itemTextures; - delete[] itemTexturesData; - delete[] spriteTextures; - delete[] spriteSequences; - delete[] spriteTexturesData; - delete[] cameras; - delete[] soundSources; - delete[] boxes; - delete[] overlaps; - for (int i = 0; i < 2; i++) { - delete[] zones[i].ground1; - delete[] zones[i].ground2; - delete[] zones[i].ground3; - delete[] zones[i].ground4; - delete[] zones[i].fly; - } - for (int i = 0; i < animTexturesCount; i++) - delete[] animTextures[i].textures; - delete[] animTextures; - delete[] entities; - delete[] palette; - delete[] palette32; - delete[] cluts; - delete[] tiles4; - delete[] tiles8; - delete[] tiles16; - delete[] cameraFrames; - delete[] demoData; - delete[] soundsMap; - delete[] soundsInfo; - delete[] soundData; - delete[] soundOffsets; - delete[] soundSize; + void readSoundData(Stream &stream) { + stream.read(soundDataSize) > 0 ? stream.read(soundData, soundDataSize) : NULL; + } - delete[] tsub; + void readSoundOffsets(Stream &stream) { + stream.read(soundOffsetsCount) > 0 ? stream.read(soundOffsets, soundOffsetsCount) : NULL; } #define CHUNK(str) ((uint64)((const char*)(str))[0] | ((uint64)((const char*)(str))[1] << 8) | ((uint64)((const char*)(str))[2] << 16) | ((uint64)((const char*)(str))[3] << 24) | \ ((uint64)((const char*)(str))[4] << 32) | ((uint64)((const char*)(str))[5] << 40) | ((uint64)((const char*)(str))[6] << 48) | ((uint64)((const char*)(str))[7] << 56)) + #define SAT_ROOMFILE 0x454C49464D4F4F52ULL /* CHUNK("ROOMFILE") */ + #define SAT_ROOMTINF 0x464E49544D4F4F52ULL /* CHUNK("ROOMTINF") */ + #define SAT_ROOMTQTR 0x525451544D4F4F52ULL /* CHUNK("ROOMTQTR") */ + #define SAT_ROOMTSUB 0x425553544D4F4F52ULL /* CHUNK("ROOMTSUB") */ + #define SAT_ROOMTPAL 0x4C4150544D4F4F52ULL /* CHUNK("ROOMTPAL") */ + #define SAT_ROOMSPAL 0x4C4150534D4F4F52ULL /* CHUNK("ROOMSPAL") */ + #define SAT_ROOMDATA 0x415441444D4F4F52ULL /* CHUNK("ROOMDATA") */ + #define SAT_ROOMNUMB 0x424D554E4D4F4F52ULL /* CHUNK("ROOMNUMB") */ + #define SAT_MESHPOS_ 0x20534F504853454DULL /* CHUNK("MESHPOS ") */ + #define SAT_MESHSIZE 0x455A49534853454DULL /* CHUNK("MESHSIZE") */ + #define SAT_DOORDATA 0x41544144524F4F44ULL /* CHUNK("DOORDATA") */ + #define SAT_FLOORDAT 0x544144524F4F4C46ULL /* CHUNK("FLOORDAT") */ + #define SAT_FLOORSIZ 0x5A4953524F4F4C46ULL /* CHUNK("FLOORSIZ") */ + #define SAT_FLORDATA 0x41544144524F4C46ULL /* CHUNK("FLORDATA") */ + #define SAT_LIGHTAMB 0x424D41544847494CULL /* CHUNK("LIGHTAMB") */ + #define SAT_RM_FLIP_ 0x2050494C465F4D52ULL /* CHUNK("RM_FLIP ") */ + #define SAT_RM_FLAGS 0x5347414C465F4D52ULL /* CHUNK("RM_FLAGS") */ + #define SAT_LIGHTSIZ 0x5A4953544847494CULL /* CHUNK("LIGHTSIZ") */ + #define SAT_CAMERAS_ 0x20534152454D4143ULL /* CHUNK("CAMERAS ") */ + #define SAT_SOUNDFX_ 0x205846444E554F53ULL /* CHUNK("SOUNDFX ") */ + #define SAT_BOXES___ 0x2020205345584F42ULL /* CHUNK("BOXES ") */ + #define SAT_OVERLAPS 0x5350414C5245564FULL /* CHUNK("OVERLAPS") */ + #define SAT_GND_ZONE 0x454E4F5A5F444E47ULL /* CHUNK("GND_ZONE") */ + #define SAT_GND_ZON2 0x324E4F5A5F444E47ULL /* CHUNK("GND_ZON2") */ + #define SAT_FLY_ZONE 0x454E4F5A5F594C46ULL /* CHUNK("FLY_ZONE") */ + #define SAT_ARANGES_ 0x205345474E415241ULL /* CHUNK("ARANGES ") */ + #define SAT_ITEMDATA 0x415441444D455449ULL /* CHUNK("ITEMDATA") */ + #define SAT_ROOMEND_ 0x20444E454D4F4F52ULL /* CHUNK("ROOMEND ") */ + #define SAD_OBJFILE_ 0x20454C49464A424FULL /* CHUNK("OBJFILE ") */ + #define SAD_ANIMS___ 0x202020534D494E41ULL /* CHUNK("ANIMS ") */ + #define SAD_CHANGES_ 0x205345474E414843ULL /* CHUNK("CHANGES ") */ + #define SAD_RANGES_z 0x00205345474E4152ULL /* CHUNK("RANGES \0") */ + #define SAD_COMMANDS 0x53444E414D4D4F43ULL /* CHUNK("COMMANDS") */ + #define SAD_ANIBONES 0x53454E4F42494E41ULL /* CHUNK("ANIBONES") */ + #define SAD_ANIMOBJ_ 0x204A424F4D494E41ULL /* CHUNK("ANIMOBJ ") */ + #define SAD_STATOBJ_ 0x204A424F54415453ULL /* CHUNK("STATOBJ ") */ + #define SAD_FRAMES__ 0x202053454D415246ULL /* CHUNK("FRAMES ") */ + #define SAD_MESHPTRS 0x535254504853454DULL /* CHUNK("MESHPTRS") */ + #define SAD_MESHDATA 0x415441444853454DULL /* CHUNK("MESHDATA") */ + #define SAD_OTEXTINF 0x464E49545845544FULL /* CHUNK("OTEXTINF") */ + #define SAD_OTEXTDAT 0x544144545845544FULL /* CHUNK("OTEXTDAT") */ + #define SAD_ITEXTINF 0x464E495458455449ULL /* CHUNK("ITEXTINF") */ + #define SAD_ITEXTDAT 0x5441445458455449ULL /* CHUNK("ITEXTDAT") */ + #define SAD_OBJEND__ 0x2020444E454A424FULL /* CHUNK("OBJEND ") */ + #define SPR_SPRFILE_ 0x20454C4946525053ULL /* CHUNK("SPRFILE ") */ + #define SPR_SPRITINF 0x464E495449525053ULL /* CHUNK("SPRITINF") */ + #define SPR_SPRITDAT 0x5441445449525053ULL /* CHUNK("SPRITDAT") */ + #define SPR_OBJECTS_ 0x20535443454A424FULL /* CHUNK("OBJECTS ") */ + #define SPR_SPRITEND 0x444E455449525053ULL /* CHUNK("SPRITEND") */ + #define SND_SAMPLUT_ 0x2054554C504D4153ULL /* CHUNK("SAMPLUT ") */ + #define SND_SAMPINFS 0x53464E49504D4153ULL /* CHUNK("SAMPINFS") */ + #define SND_SAMPLE__ 0x2020454C504D4153ULL /* CHUNK("SAMPLE ") */ + #define SND_ENDFILEz 0x00454C4946444E45ULL /* CHUNK("ENDFILE\0") */ + void readSAT(Stream &stream) { - #ifndef _OS_PSP + #if !defined(_OS_PSP) Room *room = NULL; while (stream.pos < stream.size) { @@ -2973,18 +3984,18 @@ namespace TR { switch (chunkType) { // SAT - case CHUNK("ROOMFILE") : + case SAT_ROOMFILE : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000020); break; - case CHUNK("ROOMTINF") : + case SAT_ROOMTINF : ASSERTV(stream.readBE32() == 0x00000010); roomTexturesCount = stream.readBE32(); roomTextures = roomTexturesCount ? new TextureInfo[roomTexturesCount] : NULL; for (int i = 0; i < roomTexturesCount; i++) readObjectTex(stream, roomTextures[i], TEX_TYPE_ROOM); break; - case CHUNK("ROOMTQTR") : { + case SAT_ROOMTQTR : { ASSERTV(stream.readBE32() == 0x00000001); roomTexturesDataSize = stream.readBE32(); roomTexturesData = roomTexturesDataSize ? new uint8[roomTexturesDataSize] : NULL; @@ -2995,7 +4006,7 @@ namespace TR { */ break; } - case CHUNK("ROOMTSUB") : + case SAT_ROOMTSUB : ASSERTV(stream.readBE32() == 0x00000001); /* roomTexturesDataSize = stream.readBE32(); @@ -3008,34 +4019,34 @@ namespace TR { stream.raw(tsub, sizeof(uint8) * tsubCount); break; - case CHUNK("ROOMTPAL") : { + case SAT_ROOMTPAL : { ASSERTV(stream.readBE32() == 0x00000003); stream.seek(stream.readBE32() * 3); break; } - case CHUNK("ROOMSPAL") : { + case SAT_ROOMSPAL : { ASSERTV(stream.readLE32() == 0x02000000); stream.seek(stream.readBE32() * 2); break; } - case CHUNK("ROOMDATA") : + case SAT_ROOMDATA : ASSERTV(stream.readBE32() == 0x00000044); roomsCount = stream.readBE32(); rooms = new Room[roomsCount]; memset(rooms, 0, sizeof(Room) * roomsCount); break; - case CHUNK("ROOMNUMB") : + case SAT_ROOMNUMB : ASSERTV(stream.readBE32() == 0x00000000); room = &rooms[stream.readBE32()]; break; - case CHUNK("MESHPOS ") : + case SAT_MESHPOS_ : ASSERT(room); room->info.x = stream.readBE32(); room->info.z = stream.readBE32(); room->info.yBottom = stream.readBE32(); room->info.yTop = stream.readBE32(); break; - case CHUNK("MESHSIZE") : { + case SAT_MESHSIZE : { ASSERT(room); uint32 flag = stream.readBE32(); if (flag == 0x00000014) { @@ -3099,7 +4110,6 @@ namespace TR { ASSERT(fIndex < data.fCount); Face &f = data.faces[fIndex++]; - f.flags.value = 0; switch (type) { case TYPE_SPRITE : { Room::Data::Sprite &sprite = data.sprites[data.sCount++]; @@ -3126,7 +4136,6 @@ namespace TR { case TYPE_R_INVISIBLE : case TYPE_R_TRANSP : case TYPE_R_SOLID : - f.triangle = false; f.vertices[0] = (stream.readBE16() >> 4); f.vertices[1] = (stream.readBE16() >> 4); f.vertices[2] = (stream.readBE16() >> 4); @@ -3143,21 +4152,22 @@ namespace TR { LOG("! unknown face type: %d\n", type); ASSERT(false); } - ASSERT(f.flags.value % 16 == 0); - ASSERT(f.flags.value / 16 < roomTexturesCount); - f.flags.value /= 16; - f.water = false; - f.colored = false; - f.flip = false; - - if (type == TYPE_R_TRANSP) + + if (type != TYPE_SPRITE) { + ASSERT(f.flags.value % 16 == 0); + ASSERT(f.flags.value / 16 < roomTexturesCount); + f.flags.value /= 16; + } + + if (type == TYPE_R_TRANSP) { roomTextures[f.flags.texture].attribute = 1; + } } } data.fCount = fIndex; break; } - case CHUNK("DOORDATA") : { + case SAT_DOORDATA : { int32 roomIndex = stream.readBE32(); ASSERT(roomIndex < roomsCount); Room *room = &rooms[roomIndex]; @@ -3180,12 +4190,12 @@ namespace TR { } break; } - case CHUNK("FLOORDAT") : + case SAT_FLOORDAT : ASSERT(room); room->zSectors = stream.readBE32(); room->xSectors = stream.readBE32(); break; - case CHUNK("FLOORSIZ") : { + case SAT_FLOORSIZ : { ASSERTV(stream.readBE32() == 0x00000008); ASSERT(room && room->sectors == NULL); @@ -3206,7 +4216,7 @@ namespace TR { } break; } - case CHUNK("FLORDATA") : + case SAT_FLORDATA : ASSERTV(stream.readBE32() == 0x00000002); ASSERT(floors == NULL); floorsCount = stream.readBE32(); @@ -3214,25 +4224,25 @@ namespace TR { for (int i = 0; i < floorsCount; i++) floors[i].value = stream.readBE16(); break; - case CHUNK("LIGHTAMB") : + case SAT_LIGHTAMB : ASSERT(room); room->ambient = stream.readBE32(); room->ambient2 = stream.readBE32(); break; - case CHUNK("RM_FLIP ") : { + case SAT_RM_FLIP_ : { ASSERTV(stream.readBE32() == 0x00000002); uint32 value = stream.readBE32(); room->alternateRoom = value == 0xFFFFFFFF ? -1 : value; break; } - case CHUNK("RM_FLAGS") : { + case SAT_RM_FLAGS : { ASSERT(room); ASSERTV(stream.readBE32() == 0x00000002); uint32 value = stream.readBE32(); room->flags.water = (value & 0x01) != 0; break; } - case CHUNK("LIGHTSIZ") : { + case SAT_LIGHTSIZ : { ASSERTV(stream.readBE32() == 0x00000014); ASSERT(room && room->lights == NULL); room->lightsCount = stream.readBE32(); @@ -3248,13 +4258,13 @@ namespace TR { ASSERTV(intensity == intensity2); int value = clamp((intensity > 0x1FFF) ? 0 : (intensity >> 5), 0, 255); light.color.r = light.color.g = light.color.b = value; - light.color.a = 0; + light.intensity = intensity; light.radius = stream.readBE32() * 2; } break; } - case CHUNK("CAMERAS ") : + case SAT_CAMERAS_ : ASSERTV(stream.readBE32() == 0x00000010); ASSERT(cameras == NULL); camerasCount = stream.readBE32(); @@ -3268,7 +4278,7 @@ namespace TR { cam.flags.boxIndex = stream.readBE16(); } break; - case CHUNK("SOUNDFX ") : { + case SAT_SOUNDFX_ : { uint32 flag = stream.readBE32(); if (flag == 0x00000000) { // SND ASSERTV(stream.readBE32() == 0x00000000); @@ -3302,7 +4312,7 @@ namespace TR { } break; } - case CHUNK("BOXES ") : + case SAT_BOXES___ : ASSERTV(stream.readBE32() == 0x00000014); ASSERT(boxes == NULL); boxesCount = stream.readBE32(); @@ -3317,7 +4327,7 @@ namespace TR { b.overlap.value = stream.readBE16(); } break; - case CHUNK("OVERLAPS") : + case SAT_OVERLAPS : ASSERTV(stream.readBE32() == 0x00000002); ASSERT(overlaps == NULL); overlapsCount = stream.readBE32(); @@ -3325,16 +4335,16 @@ namespace TR { for (int i = 0; i < overlapsCount; i++) overlaps[i].value = stream.readBE16(); break; - case CHUNK("GND_ZONE") : - case CHUNK("GND_ZON2") : - case CHUNK("FLY_ZONE") : { + case SAT_GND_ZONE : + case SAT_GND_ZON2 : + case SAT_FLY_ZONE : { ASSERTV(stream.readBE32() == 0x00000002); uint16 **ptr; switch (chunkType) { - case CHUNK("GND_ZONE") : ptr = zones[0].ground1 ? &zones[1].ground1 : &zones[0].ground1; break; - case CHUNK("GND_ZON2") : ptr = zones[0].ground2 ? &zones[1].ground2 : &zones[0].ground2; break; - case CHUNK("FLY_ZONE") : ptr = zones[0].fly ? &zones[1].fly : &zones[0].fly; break; + case SAT_GND_ZONE : ptr = zones[0].ground1 ? &zones[1].ground1 : &zones[0].ground1; break; + case SAT_GND_ZON2 : ptr = zones[0].ground2 ? &zones[1].ground2 : &zones[0].ground2; break; + case SAT_FLY_ZONE : ptr = zones[0].fly ? &zones[1].fly : &zones[0].fly; break; default : ptr = NULL; } @@ -3347,7 +4357,7 @@ namespace TR { (*ptr)[i] = stream.readBE16(); break; } - case CHUNK("ARANGES ") : { + case SAT_ARANGES_ : { ASSERTV(stream.readBE32() == 0x00000008); animTexturesCount = stream.readBE32(); animTextures = new AnimTexture[animTexturesCount]; @@ -3362,7 +4372,7 @@ namespace TR { } break; } - case CHUNK("ITEMDATA") : { + case SAT_ITEMDATA : { ASSERTV(stream.readBE32() == 0x00000014); entitiesBaseCount = stream.readBE32(); entitiesCount = entitiesBaseCount + MAX_RESERVED_ENTITIES; @@ -3381,17 +4391,16 @@ namespace TR { } break; } - case CHUNK("ROOMEND ") : + case SAT_ROOMEND_ : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000000); - prepare(); break; // SAD - case CHUNK("OBJFILE ") : + case SAD_OBJFILE_ : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000020); break; - case CHUNK("ANIMS ") : + case SAD_ANIMS___ : ASSERTV(stream.readBE32() == 0x00000022); ASSERT(anims == NULL); animsCount = stream.readBE32(); @@ -3416,7 +4425,7 @@ namespace TR { anim.animCommand = stream.readBE16(); } break; - case CHUNK("CHANGES ") : + case SAD_CHANGES_ : ASSERTV(stream.readBE32() == 0x00000008); ASSERT(states == NULL); statesCount = stream.readBE32(); @@ -3429,7 +4438,7 @@ namespace TR { ASSERTV(stream.readBE16() == state.rangesOffset); // dummy } break; - case CHUNK("RANGES \0") : + case SAD_RANGES_z : ASSERTV(stream.readBE32() == 0x00000008); ASSERT(ranges == NULL); rangesCount = stream.readBE32(); @@ -3442,7 +4451,7 @@ namespace TR { range.nextFrame = stream.readBE16(); } break; - case CHUNK("COMMANDS") : + case SAD_COMMANDS : ASSERTV(stream.readBE32() == 0x00000002); ASSERT(commands == NULL); commandsCount = stream.readBE32(); @@ -3450,7 +4459,7 @@ namespace TR { for (int i = 0; i < commandsCount; i++) commands[i] = stream.readBE16(); break; - case CHUNK("ANIBONES") : + case SAD_ANIBONES : ASSERTV(stream.readBE32() == 0x00000004); ASSERT(nodesData == NULL); nodesDataSize = stream.readBE32(); @@ -3458,7 +4467,7 @@ namespace TR { for (int i = 0; i < nodesDataSize; i++) nodesData[i] = stream.readBE32(); break; - case CHUNK("ANIMOBJ ") : + case SAD_ANIMOBJ_ : ASSERTV(stream.readBE32() == 0x00000038); ASSERT(models == NULL); modelsCount = stream.readBE32(); @@ -3476,7 +4485,7 @@ namespace TR { ASSERTV(stream.readBE16() == model.animation); } break; - case CHUNK("STATOBJ ") : + case SAD_STATOBJ_ : ASSERTV(stream.readBE32() == 0x00000020); ASSERT(staticMeshes == NULL); staticMeshesCount = stream.readBE32(); @@ -3500,7 +4509,7 @@ namespace TR { mesh.flags = stream.readBE16(); } break; - case CHUNK("FRAMES ") : + case SAD_FRAMES__ : ASSERTV(stream.readBE32() == 0x00000002); ASSERT(frameData == NULL); frameDataSize = stream.readBE32(); @@ -3508,7 +4517,7 @@ namespace TR { for (int i = 0; i < frameDataSize; i++) frameData[i] = stream.readBE16(); break; - case CHUNK("MESHPTRS") : + case SAD_MESHPTRS : ASSERTV(stream.readBE32() == 0x00000004); ASSERT(meshOffsets == NULL); meshOffsetsCount = stream.readBE32(); @@ -3516,14 +4525,14 @@ namespace TR { for (int i = 0; i < meshOffsetsCount; i++) meshOffsets[i] = stream.readBE32(); break; - case CHUNK("MESHDATA") : + case SAD_MESHDATA : ASSERTV(stream.readBE32() == 0x00000002); ASSERT(meshData == NULL); meshDataSize = stream.readBE32(); meshData = meshDataSize ? new uint16[meshDataSize] : NULL; stream.raw(meshData, sizeof(uint16) * meshDataSize); break; - case CHUNK("OTEXTINF") : + case SAD_OTEXTINF : ASSERTV(stream.readBE32() == 0x00000010); ASSERT(objectTextures == NULL); objectTexturesCount = stream.readBE32(); @@ -3533,14 +4542,14 @@ namespace TR { objectTexturesBaseCount = objectTexturesCount; expandObjectTex(objectTextures, objectTexturesCount); break; - case CHUNK("OTEXTDAT") : { + case SAD_OTEXTDAT : { ASSERTV(stream.readBE32() == 0x00000001); objectTexturesDataSize = stream.readBE32(); objectTexturesData = objectTexturesDataSize ? new uint8[objectTexturesDataSize] : NULL; stream.raw(objectTexturesData, objectTexturesDataSize); break; } - case CHUNK("ITEXTINF") : { + case SAD_ITEXTINF : { ASSERTV(stream.readBE32() == 0x00000014); itemTexturesCount = stream.readBE32(); itemTextures = itemTexturesCount ? new TextureInfo[itemTexturesCount * 5] : NULL; @@ -3550,23 +4559,23 @@ namespace TR { expandObjectTex(itemTextures, itemTexturesCount); break; } - case CHUNK("ITEXTDAT") : { + case SAD_ITEXTDAT : { ASSERTV(stream.readBE32() == 0x00000001); itemTexturesDataSize = stream.readBE32(); itemTexturesData = itemTexturesDataSize ? new uint8[itemTexturesDataSize] : NULL; stream.raw(itemTexturesData, itemTexturesDataSize); break; } - case CHUNK("OBJEND ") : + case SAD_OBJEND__ : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000000); break; // SPR - case CHUNK("SPRFILE ") : + case SPR_SPRFILE_ : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000020); break; - case CHUNK("SPRITINF") : { + case SPR_SPRITINF : { ASSERTV(stream.readBE32() == 0x00000010); spriteTexturesCount = stream.readBE32(); spriteTextures = spriteTexturesCount ? new TextureInfo[spriteTexturesCount] : NULL; @@ -3574,14 +4583,14 @@ namespace TR { readSpriteTex(stream, spriteTextures[i]); break; } - case CHUNK("SPRITDAT") : { + case SPR_SPRITDAT : { ASSERTV(stream.readBE32() == 0x00000001); spriteTexturesDataSize = stream.readBE32(); spriteTexturesData = spriteTexturesDataSize ? new uint8[spriteTexturesDataSize] : NULL; stream.raw(spriteTexturesData, spriteTexturesDataSize); break; } - case CHUNK("OBJECTS ") : { + case SPR_OBJECTS_ : { ASSERTV(stream.readBE32() == 0x00000000); spriteSequencesCount = stream.readBE32(); spriteSequences = spriteSequencesCount ? new SpriteSequence[spriteSequencesCount] : NULL; @@ -3595,12 +4604,12 @@ namespace TR { } break; } - case CHUNK("SPRITEND") : + case SPR_SPRITEND : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000000); break; // SND - case CHUNK("SAMPLUT ") : { + case SND_SAMPLUT_ : { ASSERTV(stream.readBE32() == 0x00000002); int count = stream.readBE32(); soundsMap = new int16[count]; @@ -3608,7 +4617,7 @@ namespace TR { soundsMap[i] = stream.readBE16(); break; } - case CHUNK("SAMPINFS") : { + case SND_SAMPINFS : { ASSERTV(stream.readBE32() == 0x00000008); soundsInfoCount = stream.readBE32(); soundsInfo = soundsInfoCount ? new SoundInfo[soundsInfoCount] : NULL; @@ -3623,7 +4632,7 @@ namespace TR { } break; } - case CHUNK("SAMPLE ") : { + case SND_SAMPLE__ : { int32 index = stream.readBE32(); int32 size = stream.readBE32(); ASSERT(index < soundOffsetsCount); @@ -3633,7 +4642,7 @@ namespace TR { stream.seek(size); break; } - case CHUNK("ENDFILE\0") : + case SND_ENDFILEz : ASSERTV(stream.readBE32() == 0x00000000); ASSERTV(stream.readBE32() == 0x00000000); break; @@ -3658,6 +4667,7 @@ namespace TR { } void appendObjectTex(TextureInfo *&objTex, int32 &count) { + if (!objTex) return; TextureInfo *newObjectTextures = new TextureInfo[objectTexturesCount + count]; memcpy(newObjectTextures, objectTextures, sizeof(TextureInfo) * objectTexturesCount); memcpy(newObjectTextures + objectTexturesCount, objTex, sizeof(TextureInfo) * count); @@ -3690,7 +4700,7 @@ namespace TR { void prepare() { if (version == VER_TR1_PC) { - // Amiga -> PC color palette for TR1 PC + // DOS 6-bit -> 8-bit per component ASSERT(palette); Color24 *c = palette; for (int i = 0; i < 256; i++) { @@ -3705,12 +4715,14 @@ namespace TR { Model &model = models[i]; model.type = Entity::remap(version, model.type); - for (int j = 0; j < model.mCount; j++) + for (int j = 0; j < model.mCount; j++) { initMesh(model.mStart + j, model.type); + } } - for (int i = 0; i < staticMeshesCount; i++) + for (int i = 0; i < staticMeshesCount; i++) { initMesh(staticMeshes[i].mesh); + } remapMeshOffsetsToIndices(); @@ -3737,7 +4749,7 @@ namespace TR { if (isCutsceneLevel()) { for (int i = 0; i < entitiesBaseCount; i++) { Entity &e = entities[i]; - if ((((version & VER_TR1)) && e.isActor()) || + if ((((version & VER_TR1)) && e.type == Entity::CUT_1) || (((version & (VER_TR2 | VER_TR3))) && e.isLara())) { cutEntity = i; break; @@ -3789,6 +4801,7 @@ namespace TR { initAnimTex(); initExtra(); initCutscene(); + initTextureTypes(); gObjectTextures = objectTextures; gSpriteTextures = spriteTextures; @@ -3809,8 +4822,9 @@ namespace TR { dataOffset += FOURCC(soundData + dataOffset + 4) + 8; // add chunk size } - for (int i = 0; i < soundOffsetsCount; i++) + for (int i = 0; i < soundOffsetsCount; i++) { soundOffsets[i] = dataOffsets[soundOffsets[i]]; + } } static void sfxLoadAsync(Stream *stream, void *userData) { @@ -3839,6 +4853,7 @@ namespace TR { case Entity::LARA_BRAID : extra.braid = i; break; case Entity::LARA_SPEC : extra.laraSpec = i; break; case Entity::LARA_SKIN : extra.laraSkin = i; break; + case Entity::LARA_SKIN_JOINTS : extra.laraJoints = i; break; case Entity::CUT_1 : extra.meshSwap[0] = i; break; case Entity::CUT_2 : extra.meshSwap[1] = i; break; case Entity::CUT_3 : extra.meshSwap[2] = i; break; @@ -3900,7 +4915,7 @@ namespace TR { default : ; } - ASSERT(extra.glyphs != -1); + //ASSERT(extra.glyphs != -1); } void initCutscene() { @@ -3932,6 +4947,93 @@ namespace TR { } } + void initTextureTypes() { + // rooms geometry + for (int roomIndex = 0; roomIndex < roomsCount; roomIndex++) { + Room &room = rooms[roomIndex]; + Room::Data &data = room.data; + for (int i = 0; i < data.fCount; i++) { + Face &f = data.faces[i]; + ASSERT(!f.colored); + ASSERT(f.flags.texture < objectTexturesCount); + TextureInfo &t = objectTextures[f.flags.texture]; + t.type = TEX_TYPE_ROOM; + } + } + + // rooms static meshes + for (int staticMeshIndex = 0; staticMeshIndex < staticMeshesCount; staticMeshIndex++) { + StaticMesh *staticMesh = &staticMeshes[staticMeshIndex]; + if (!meshOffsets[staticMesh->mesh]) continue; + Mesh &mesh = meshes[meshOffsets[staticMesh->mesh]]; + + for (int i = 0; i < mesh.fCount; i++) { + Face &f = mesh.faces[i]; + ASSERT(f.colored || f.flags.texture < objectTexturesCount); + if (f.colored) continue; + TextureInfo &t = objectTextures[f.flags.texture]; + t.type = TEX_TYPE_ROOM; + } + } + + // animated textures + for (int animTextureIndex = 0; animTextureIndex < animTexturesCount; animTextureIndex++) { + AnimTexture &animTex = animTextures[animTextureIndex]; + + for (int j = 0; j < animTex.count; j++) { + TextureInfo &t = objectTextures[animTex.textures[j]]; + t.type = TEX_TYPE_ROOM; + } + } + + // objects (duplicate all textures that are simultaneously used for static meshes) + TextureInfo *dupObjTex = NULL; + int dupObjTexCount = 0; + + for (int modelIndex = 0; modelIndex < modelsCount; modelIndex++) { + Model &model = models[modelIndex]; + for (int meshIndex = model.mStart; meshIndex < model.mStart + model.mCount; meshIndex++) { + Mesh &mesh = meshes[meshOffsets[meshIndex]]; + + for (int i = 0; i < mesh.fCount; i++) { + Face &f = mesh.faces[i]; +// ASSERT(f.colored || f.flags.texture < objectTexturesCount); + + if (f.flags.texture >= objectTexturesCount) { + f.colored = true; + } + + if (f.colored) continue; + TextureInfo &t = objectTextures[f.flags.texture]; + if (t.type != TEX_TYPE_OBJECT) { + if (!dupObjTex) { + dupObjTex = new TextureInfo[256]; + } + + int index = 0; + while (index < dupObjTexCount) { + TextureInfo &ot = dupObjTex[index]; + if (ot.tile == t.tile && ot.clut == t.clut && ot.texCoord[0] == t.texCoord[0] && ot.texCoord[1] == t.texCoord[1]) + break; + index++; + } + + if (index == dupObjTexCount) { + ASSERT(index <= 256); + dupObjTex[dupObjTexCount] = t; + dupObjTex[dupObjTexCount].type = TEX_TYPE_OBJECT; + dupObjTexCount++; + } + + f.flags.texture = objectTexturesCount + index; + } + } + } + } + + appendObjectTex(dupObjTex, dupObjTexCount); + } + static Entity::Type convToInv(Entity::Type type) { for (int j = 0; j < COUNT(ITEM_TO_INV); j++) if (type == ITEM_TO_INV[j].src) { @@ -3987,20 +5089,24 @@ namespace TR { return TR::isCutsceneLevel(id); } - void readFace(Stream &stream, Face &f, bool colored, bool triangle) { + void readFace(Stream &stream, Face &f, bool colored, bool triangle, bool isRoomMesh) { f.triangle = triangle; - for (int i = 0; i < (triangle ? 3 : 4); i++) + for (int i = 0; i < (triangle ? 3 : 4); i++) { stream.read(f.vertices[i]); + } - if (triangle) + if (triangle) { f.vertices[3] = 0; + } stream.read(f.flags.value); + if (!isRoomMesh && (version & (VER_TR4 | VER_TR5))) { + stream.read(f.effects.value); + } + f.colored = colored; - f.water = false; - f.flip = false; } void readRoom(Stream &stream, int roomIndex) { @@ -4011,7 +5117,9 @@ namespace TR { // room data stream.read(d.size); int startOffset = stream.pos; - if (version == VER_TR1_PSX) stream.seek(2); + if (version == VER_TR1_PSX) { + stream.seek(2); + } // only for TR3 PSX int32 partsCount; @@ -4057,8 +5165,9 @@ namespace TR { d.vertices = d.vCount ? new Room::Data::Vertex[d.vCount] : NULL; d.vCount = d.fCount = 0; - } else + } else { d.vertices = stream.read(d.vCount) ? new Room::Data::Vertex[d.vCount] : NULL; + } if (version == VER_TR3_PSX) { for (int pIndex = 0; pIndex < partsCount; pIndex++) { @@ -4104,16 +5213,12 @@ namespace TR { ASSERT(t.unknown == 0); Face &f = d.faces[d.fCount++]; - f.flags.texture = t.texture; - f.flags.doubleSided = false; - f.triangle = true; - f.colored = false; - f.water = false; - f.flip = false; - f.vertices[0] = vStart + t.i0; - f.vertices[1] = vStart + t.i1; - f.vertices[2] = vStart + t.i2; - f.vertices[3] = 0; + f.flags.texture = t.texture; + f.triangle = true; + f.vertices[0] = vStart + t.i0; + f.vertices[1] = vStart + t.i1; + f.vertices[2] = vStart + t.i2; + f.vertices[3] = 0; ASSERT(f.vertices[0] < d.vCount); ASSERT(f.vertices[1] < d.vCount); ASSERT(f.vertices[2] < d.vCount); @@ -4140,16 +5245,11 @@ namespace TR { ASSERT(r.unknown == 0); Face &f = d.faces[d.fCount++]; - f.flags.texture = texture; - f.flags.doubleSided = false; - f.triangle = false; - f.colored = false; - f.water = false; - f.flip = false; - f.vertices[0] = vStart + r.i0; - f.vertices[1] = vStart + r.i1; - f.vertices[2] = vStart + r.i2; - f.vertices[3] = vStart + r.i3; + f.flags.texture = texture; + f.vertices[0] = vStart + r.i0; + f.vertices[1] = vStart + r.i1; + f.vertices[2] = vStart + r.i2; + f.vertices[3] = vStart + r.i3; ASSERT(f.vertices[0] < d.vCount); ASSERT(f.vertices[1] < d.vCount); @@ -4185,21 +5285,24 @@ namespace TR { stream.read(v.pos.z); stream.read(lighting); - if (version == VER_TR2_PC || version == VER_TR3_PC) + if (version == VER_TR2_PC || version == VER_TR3_PC || version == VER_TR4_PC) { stream.read(v.attributes); - - if (version == VER_TR2_PC) + } + + if (version == VER_TR2_PC) { stream.read(lighting); // real lighting value + } - if (version == VER_TR3_PC) { + if (version == VER_TR3_PC || version == VER_TR4_PC) { Color16 color; stream.read(color.value); - v.color = color.getBGR(); + v.color = color; } } - if (version == VER_TR1_PSX || version == VER_TR3_PSX) + if (version == VER_TR1_PSX || version == VER_TR3_PSX) { lighting = 0x1FFF - (lighting << 5); // convert vertex luminance from PSX to PC format + } if ((version & VER_VERSION) < VER_TR3) { // lighting to color conversion int value = clamp((lighting > 0x1FFF) ? 255 : (255 - (lighting >> 5)), 0, 255); @@ -4208,8 +5311,9 @@ namespace TR { } } - if (version == VER_TR2_PSX) + if (version == VER_TR2_PSX) { stream.seek(2); + } int tmp = stream.pos; if (version == VER_TR2_PSX) { @@ -4217,8 +5321,9 @@ namespace TR { stream.seek(sizeof(uint16) * d.rCount); if ((stream.pos - startOffset) % 4) stream.seek(2); stream.seek(sizeof(uint16) * 4 * d.rCount); - } else + } else { stream.seek(stream.read(d.rCount) * FACE4_SIZE); // uint32 colored (not existing in file) + } stream.read(d.tCount); stream.setPos(tmp); @@ -4234,7 +5339,11 @@ namespace TR { if (version == VER_TR2_PSX) { for (int i = 0; i < d.rCount; i++) stream.raw(&d.faces[i].flags.value, sizeof(uint16)); - if ((stream.pos - startOffset) % 4) stream.seek(2); + + if ((stream.pos - startOffset) % 4) { + stream.seek(2); + } + for (int i = 0; i < d.rCount; i++) { Face &f = d.faces[i]; stream.raw(f.vertices, sizeof(uint16) * 4); @@ -4242,13 +5351,12 @@ namespace TR { f.vertices[1] >>= 2; f.vertices[2] >>= 2; f.vertices[3] >>= 2; - f.triangle = false; - f.colored = false; - f.water = false; - f.flip = false; } - } else - for (int i = 0; i < d.rCount; i++) readFace(stream, d.faces[idx++], false, false); + } else { + for (int i = 0; i < d.rCount; i++) { + readFace(stream, d.faces[idx++], false, false, true); + } + } stream.read(tmpCount); ASSERT(tmpCount == d.tCount); @@ -4263,33 +5371,34 @@ namespace TR { f.vertices[1] >>= 2; f.vertices[2] >>= 2; f.vertices[3] = 0; - f.triangle = true; - f.colored = false; - f.water = false; - f.flip = false; + f.triangle = true; } } else { - for (int i = 0; i < d.tCount; i++) - readFace(stream, d.faces[idx++], false, true); + for (int i = 0; i < d.tCount; i++) { + readFace(stream, d.faces[idx++], false, true, true); + } } } if (version & VER_PSX) { // swap indices (quad strip -> quad list) only for PSX version - for (int j = 0; j < d.fCount; j++) - if (!d.faces[j].triangle) + for (int j = 0; j < d.fCount; j++) { + if (!d.faces[j].triangle) { swap(d.faces[j].vertices[2], d.faces[j].vertices[3]); + } + } } // room sprites if (version == VER_TR2_PSX || version == VER_TR3_PSX) { // there is no room sprites d.sprites = NULL; d.sCount = 0; - } else + } else { stream.read(d.sprites, stream.read(d.sCount)); + } - if (version == VER_TR3_PSX) - if (partsCount != 0) - stream.seek(4); // skip unknown shit + if (version == VER_TR3_PSX && partsCount != 0) { + stream.seek(4); // skip unknown shit + } ASSERT(int(d.size * 2) >= stream.pos - startOffset); stream.setPos(startOffset + d.size * 2); @@ -4326,15 +5435,17 @@ namespace TR { } else { s.material = s.boxIndex & 0x0F; s.boxIndex = s.boxIndex >> 4; - if (s.boxIndex == 2047) + if (s.boxIndex == 2047) { s.boxIndex = 0; // TODO TR3 slide box indices + } } } + // ambient light luminance stream.read(r.ambient); if (version != VER_TR3_PSX) { - if (version & (VER_TR2 | VER_TR3)) + if (version & (VER_TR2 | VER_TR3 | VER_TR4)) stream.read(r.ambient2); if (version & VER_TR2) @@ -4354,30 +5465,53 @@ namespace TR { uint16 intensity; - if (version & VER_TR3) + if (version & (VER_TR3 | VER_TR4)) { stream.read(light.color); + stream.read(light.type); + } - stream.read(intensity); + if (version & VER_TR4) { + uint8 unknown; + stream.read(unknown); + //ASSERT(unknown == 0x00 || unknown == 0xFF); + uint8 byteIntensity; + intensity = stream.read(byteIntensity); + stream.read(light.in); + stream.read(light.out); + stream.read(light.length); + stream.read(light.cutoff); + stream.read(light.dir); + light.radius = uint32(light.length); + } else { + stream.read(intensity); + } - if (version == VER_TR1_PSX) + if (version == VER_TR1_PSX) { stream.seek(2); + } - if (version & (VER_TR2 | VER_TR3)) + if (version & (VER_TR2 | VER_TR3)) { stream.seek(2); // intensity2 + } - stream.read(light.radius); + if (version != VER_TR4_PC) { + stream.read(light.radius); + } - if (version & VER_TR2) + if (version & VER_TR2) { stream.seek(4); // radius2 + } if ((version & VER_VERSION) < VER_TR3) { int value = clamp((intensity > 0x1FFF) ? 0 : (intensity >> 5), 0, 255); light.color.r = light.color.g = light.color.b = value; - light.color.a = 0; } - if (version == VER_TR3_PSX) + light.intensity = intensity; + + if (version == VER_TR3_PSX) { light.radius >>= 2; + } light.radius *= 2; } @@ -4389,15 +5523,16 @@ namespace TR { stream.read(m.x); stream.read(m.y); stream.read(m.z); - stream.read(m.rotation); - if (version & VER_TR3) { + stream.read(m.rotation.value); + if (version & (VER_TR3 | VER_TR4)) { Color16 color; stream.read(color.value); m.color = color; stream.seek(2); } else { - if (version & VER_TR2) + if (version & VER_TR2) { stream.seek(2); + } uint16 intensity; stream.read(intensity); @@ -4409,16 +5544,18 @@ namespace TR { } stream.read(m.meshID); - if (version == VER_TR1_PSX) + if (version == VER_TR1_PSX) { stream.seek(2); // skip padding + } } // misc flags stream.read(r.alternateRoom); stream.read(r.flags.value); - if (version & VER_TR3) { + if (version & (VER_TR3 | VER_TR4)) { stream.read(r.waterScheme); stream.read(r.reverbType); + stream.read(r.filter); } r.dynLightsCount = 0; @@ -4426,9 +5563,11 @@ namespace TR { void initMesh(int mIndex, Entity::Type type = Entity::NONE) { int offset = meshOffsets[mIndex]; - for (int i = 0; i < meshesCount; i++) - if (meshes[i].offset == offset) + for (int i = 0; i < meshesCount; i++) { + if (meshes[i].offset == offset) { return; + } + } Stream stream(NULL, &meshData[offset / 2], 1024 * 1024); @@ -4536,9 +5675,6 @@ namespace TR { for (int k = 0; k < count; k++) { ASSERT(fIndex < mesh.fCount); Face &f = mesh.faces[fIndex++]; - f.water = false; - f.colored = false; - f.flip = 0; switch (type) { case TYPE_T_COLOR : f.colored = true; case TYPE_T_TEX_UNK : @@ -4594,7 +5730,6 @@ namespace TR { case TYPE_R_FLIP_TRANSP : f.flip = 1; case TYPE_R_TEX : case TYPE_R_TRANSP : - f.triangle = false; f.vertices[0] = (stream.readBE16() >> 5); f.vertices[1] = (stream.readBE16() >> 5); f.vertices[2] = (stream.readBE16() >> 5); @@ -4631,24 +5766,9 @@ namespace TR { } case VER_TR1_PC : case VER_TR2_PC : - case VER_TR3_PC : { - /* struct { - short3 center; - short2 collider; - short vCount; - short3 vertices[vCount]; - short nCount; - short3 normals[max(0, nCount)]; - ushort luminance[-min(0, nCount)]; - short rCount; - Rectangle rectangles[rCount]; - short tCount; - Triangle triangles[tCount]; - short crCount; - Rectangle crectangles[crCount]; - short ctCount; - Triangle ctriangles[ctCount]; - }; */ + case VER_TR3_PC : + case VER_TR4_PC : + case VER_TR5_PC : { mesh.vertices = new Mesh::Vertex[mesh.vCount]; for (int i = 0; i < mesh.vCount; i++) { short4 &c = mesh.vertices[i].coord; @@ -4674,13 +5794,22 @@ namespace TR { } } - uint16 rCount, tCount, crCount, ctCount; + uint16 rCount, tCount, crCount = 0, ctCount = 0; + + int faceSize4 = FACE4_SIZE; + int faceSize3 = FACE3_SIZE; + if (version & (VER_TR4 | VER_TR5)) { + faceSize4 += 2; + faceSize3 += 2; + } int tmp = stream.pos; - stream.seek(stream.read(rCount) * FACE4_SIZE); // uint32 colored (not existing in file) - stream.seek(stream.read(tCount) * FACE3_SIZE); - stream.seek(stream.read(crCount) * FACE4_SIZE); - stream.seek(stream.read(ctCount) * FACE3_SIZE); + stream.seek(stream.read(rCount) * faceSize4); // uint32 colored (not existing in file) + stream.seek(stream.read(tCount) * faceSize3); + if (!(version & (VER_TR4 | VER_TR5))) { + stream.seek(stream.read(crCount) * faceSize4); + stream.seek(stream.read(ctCount) * faceSize3); + } stream.setPos(tmp); mesh.rCount = rCount + crCount; @@ -4689,26 +5818,26 @@ namespace TR { mesh.faces = mesh.fCount ? new Face[mesh.fCount] : NULL; int idx = 0; - stream.seek(sizeof(rCount)); for (int i = 0; i < rCount; i++) readFace(stream, mesh.faces[idx++], false, false); - stream.seek(sizeof(tCount)); for (int i = 0; i < tCount; i++) readFace(stream, mesh.faces[idx++], false, true); - stream.seek(sizeof(crCount)); for (int i = 0; i < crCount; i++) readFace(stream, mesh.faces[idx++], true, false); - stream.seek(sizeof(ctCount)); for (int i = 0; i < ctCount; i++) readFace(stream, mesh.faces[idx++], true, true); + stream.seek(sizeof(rCount)); for (int i = 0; i < rCount; i++) readFace(stream, mesh.faces[idx++], false, false, false); + stream.seek(sizeof(tCount)); for (int i = 0; i < tCount; i++) readFace(stream, mesh.faces[idx++], false, true, false); + if (!(version & (VER_TR4 | VER_TR5))) { + stream.seek(sizeof(crCount)); for (int i = 0; i < crCount; i++) readFace(stream, mesh.faces[idx++], true, false, false); + stream.seek(sizeof(ctCount)); for (int i = 0; i < ctCount; i++) readFace(stream, mesh.faces[idx++], true, true, false); + } + + #ifdef _DEBUG + for (int i = 0; i < mesh.fCount; i++) { + Face &f = mesh.faces[i]; + for (int j = 0; j < (f.triangle ? 3 : 4); j++) { + ASSERT(f.vertices[j] < mesh.vCount); + } + } + #endif + break; } case VER_TR1_PSX : case VER_TR2_PSX : { - /* struct { - short3 center; - short2 collider; - short vCount; - short4 vertices[abs(vCount)]; - short4 normals[max(0, vCount)]; - ushort luminance[-min(0, vCount)]; - short rCount; - Rectangle rectangles[rCount]; - short tCount; - Triangle triangles[tCount]; - }; */ int nCount = mesh.vCount; mesh.vCount = abs(mesh.vCount); mesh.vertices = new Mesh::Vertex[mesh.vCount]; @@ -4746,8 +5875,8 @@ namespace TR { mesh.faces = mesh.fCount ? new Face[mesh.fCount] : NULL; int idx = 0; - stream.seek(sizeof(mesh.rCount)); for (int i = 0; i < mesh.rCount; i++) readFace(stream, mesh.faces[idx++], false, false); - stream.seek(sizeof(mesh.tCount)); for (int i = 0; i < mesh.tCount; i++) readFace(stream, mesh.faces[idx++], false, true); + stream.seek(sizeof(mesh.rCount)); for (int i = 0; i < mesh.rCount; i++) readFace(stream, mesh.faces[idx++], false, false, false); + stream.seek(sizeof(mesh.tCount)); for (int i = 0; i < mesh.tCount; i++) readFace(stream, mesh.faces[idx++], false, true, false); if (!mesh.fCount) LOG("! warning: mesh %d has no geometry with %d vertices\n", meshesCount - 1, mesh.vCount); @@ -4770,10 +5899,13 @@ namespace TR { break; } case VER_TR3_PSX : { + mesh.tCount = 0; + mesh.rCount = 0; + mesh.fCount = 0; + if (!mesh.vCount) { mesh.vertices = NULL; mesh.faces = NULL; - mesh.tCount = mesh.rCount = mesh.fCount = 0; break; } @@ -4814,12 +5946,8 @@ namespace TR { stream.raw(&r, sizeof(r)); Face &f = mesh.faces[idx++]; - f.flags.doubleSided = false; f.flags.texture = (info & 0xFF) | (r.tex << 8); - f.triangle = true; - f.colored = false; - f.water = false; - f.flip = false; + f.triangle = true; f.vertices[0] = r.i0; f.vertices[1] = r.i1; @@ -4835,12 +5963,7 @@ namespace TR { stream.read(info); Face &f = mesh.faces[idx++]; - f.flags.doubleSided = false; - f.flags.texture = info & 0xFFFF; - f.triangle = false; - f.colored = false; - f.water = false; - f.flip = false; + f.flags.texture = info & 0xFFFF; struct { uint32 i0:8, i1:8, i2:8, i3:8; @@ -4870,7 +5993,7 @@ namespace TR { n = mesh.vertices[face.vertices[fn]].normal;\ continue;\ }\ - vec3 o(mesh.vertices[face.vertices[0]].coord);\ + vec3 o = mesh.vertices[face.vertices[0]].coord;\ vec3 a = o - mesh.vertices[face.vertices[1]].coord;\ vec3 b = o - mesh.vertices[face.vertices[2]].coord;\ o = b.cross(a).normal() * 16300.0f;\ @@ -4914,7 +6037,7 @@ namespace TR { t.texCoord[3] = t.texCoordAtlas[3] = short2( d.x3, d.y3 );\ } - t.type = type; + t.type = t.dataType = type; switch (version) { case VER_TR1_SAT : { @@ -4975,10 +6098,32 @@ namespace TR { uint8 xh2, x2, yh2, y2; uint8 xh3, x3, yh3, y3; } d; + stream.raw(&d, sizeof(d)); SET_PARAMS(t, d, 0); break; } + case VER_TR4_PC : + case VER_TR5_PC : { + struct { + uint16 attribute; + uint16 tile:14, :2; + uint16 flags; + uint8 xh0, x0, yh0, y0; + uint8 xh1, x1, yh1, y1; + uint8 xh2, x2, yh2, y2; + uint8 xh3, x3, yh3, y3; + } d; + + struct { + uint32 U, V, W, H; + } duv; + + stream.raw(&d, sizeof(d)); + stream.raw(&duv, sizeof(duv)); + SET_PARAMS(t, d, 0); + break; + } case VER_TR1_PSX : case VER_TR2_PSX : case VER_TR3_PSX : { @@ -5016,8 +6161,9 @@ namespace TR { void readObjectTex(Stream &stream) { objectTextures = stream.read(objectTexturesCount) ? new TextureInfo[objectTexturesCount] : NULL; - for (int i = 0; i < objectTexturesCount; i++) + for (int i = 0; i < objectTexturesCount; i++) { readObjectTex(stream, objectTextures[i]); + } } void readSpriteTex(Stream &stream, TextureInfo &t) { @@ -5031,6 +6177,7 @@ namespace TR { } t.type = TEX_TYPE_SPRITE; + t.dataType = TEX_TYPE_SPRITE; t.attribute = 1; switch (version) { @@ -5057,7 +6204,9 @@ namespace TR { } case VER_TR1_PC : case VER_TR2_PC : - case VER_TR3_PC : { + case VER_TR3_PC : + case VER_TR4_PC : + case VER_TR5_PC : { struct { uint16 tile; uint8 u, v; @@ -5131,20 +6280,33 @@ namespace TR { } void readAnimTex(Stream &stream) { - uint32 size; - stream.read(size); + uint32 animTexBlockSize; + stream.read(animTexBlockSize); + + if (animTexBlockSize) { + uint16 *animTexBlock = new uint16[animTexBlockSize]; + for (uint32 i = 0; i < animTexBlockSize; i++) { + animTexBlock[i] = stream.readLE16(); + } - if (!size) return; + uint16 *ptr = animTexBlock; - stream.read(animTexturesCount); - animTextures = animTexturesCount ? new AnimTexture[animTexturesCount] : NULL; + animTexturesCount = *(ptr++); + animTextures = animTexturesCount ? new AnimTexture[animTexturesCount] : NULL; - for (int i = 0; i < animTexturesCount; i++) { - AnimTexture &animTex = animTextures[i]; - animTex.count = stream.readLE16() + 1; - animTex.textures = new uint16[animTex.count]; - for (int j = 0; j < animTex.count; j++) - animTex.textures[j] = stream.readLE16(); + for (int i = 0; i < animTexturesCount; i++) { + AnimTexture &animTex = animTextures[i]; + animTex.count = *(ptr++) + 1; + animTex.textures = new uint16[animTex.count]; + for (int j = 0; j < animTex.count; j++) + animTex.textures[j] = *(ptr++); + } + delete[] animTexBlock; + } + + if (version & (VER_TR4 | VER_TR5)) { + uint8 animTexUVs; + stream.read(animTexUVs); } } @@ -5159,10 +6321,14 @@ namespace TR { stream.read(e.x); stream.read(e.y); stream.read(e.z); - stream.read(e.rotation); + stream.read(e.rotation.value); stream.read(e.intensity); - if (version & (VER_TR2 | VER_TR3)) + if (version & (VER_TR2 | VER_TR3)) { stream.read(e.intensity2); + } + if (version & (VER_TR4 | VER_TR5)) { + stream.read(e.OCB); + } stream.read(e.flags.value); } } @@ -5204,7 +6370,18 @@ namespace TR { } } - void fillObjectTexture(Tile32 *dst, const short4 &uv, TextureInfo *t) { + void fillObjectTexture32(AtlasTile *dst, const Color32 *data, const short4 &uv, TextureInfo *t) { + AtlasColor *ptr = &dst->color[uv.y * 256]; + for (int y = uv.y; y < uv.w; y++) { + for (int x = uv.x; x < uv.z; x++) { + ptr[x] = data[y * 256 + x]; + } + ptr += 256; + } + premultiplyAlpha(dst->color, uv); + } + + void fillObjectTexture(AtlasTile *dst, const short4 &uv, TextureInfo *t) { // convert to RGBA switch (version) { case VER_TR1_SAT : { @@ -5212,7 +6389,7 @@ namespace TR { uint32 cOffset = uint32(uint16(t->clut + t->tile)) << 3; uint8 *data = NULL; - switch (t->type) { + switch (t->dataType) { case TEX_TYPE_ROOM : data = roomTexturesData; break; case TEX_TYPE_ITEM : data = itemTexturesData; break; case TEX_TYPE_OBJECT : data = objectTexturesData; break; @@ -5228,22 +6405,11 @@ namespace TR { int w = uv.z - uv.x; ASSERT(w <= 256 && h <= 256); - /* - if (t->type == TEX_TYPE_OBJECT) { - for (int y = 0; y < h; y++) - for (int x = 0; x < h; x++) { - ColorIndex4 *index = indices + (y * w + x) / 2; - uint8 p = uint8((x % 2) ? index->a : index->b) << 4; - dst->color[y * 256 + x] = Color32(p, p, p, 255); - } - return; - } - */ for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { ColorIndex4 *index; - if (t->type == TEX_TYPE_ROOM) { + if (t->dataType == TEX_TYPE_ROOM) { int iw = w / 2; int ih = h / 2; int ix = x % iw; @@ -5257,12 +6423,12 @@ namespace TR { index = indices + (y * w + x) / 2; int idx = (x % 2) ? index->a : index->b; - Color16 &c = clut->color[idx]; + ColorCLUT &c = clut->color[idx]; if (t->attribute == 1 && idx == 0) - dst->color[y * 256 + x] = Color32(0, 0, 0, 0); + dst->color[y * 256 + x].value = 0; else - dst->color[y * 256 + x] = Color16(swap16(c.value)); + dst->color[y * 256 + x] = ColorCLUT(swap16(c.value)); } break; @@ -5271,19 +6437,15 @@ namespace TR { ASSERT(tiles8); ASSERT(palette); - Color32 *ptr = &dst->color[uv.y * 256]; + AtlasColor *ptr = &dst->color[uv.y * 256]; for (int y = uv.y; y < uv.w; y++) { for (int x = uv.x; x < uv.z; x++) { ASSERT(x >= 0 && y >= 0 && x < 256 && y < 256); uint8 index = tiles8[t->tile].index[y * 256 + x]; - Color24 &p = palette[index]; if (index != 0) { - ptr[x].r = p.r; - ptr[x].g = p.g; - ptr[x].b = p.b; - ptr[x].a = 255; + ptr[x] = palette[index]; } else - ptr[x].r = ptr[x].g = ptr[x].b = ptr[x].a = 0; + ptr[x].value = 0; } ptr += 256; } @@ -5293,14 +6455,25 @@ namespace TR { case VER_TR3_PC : { ASSERT(tiles16); - Color32 *ptr = &dst->color[uv.y * 256]; + AtlasColor *ptr = &dst->color[uv.y * 256]; + for (int y = uv.y; y < uv.w; y++) { + for (int x = uv.x; x < uv.z; x++) { + ptr[x] = tiles16[t->tile].color[y * 256 + x]; + } + ptr += 256; + } + break; + } + case VER_TR4_PC : + case VER_TR5_PC : { + ASSERT(tiles32); + + AtlasColor *ptr = &dst->color[uv.y * 256]; for (int y = uv.y; y < uv.w; y++) { for (int x = uv.x; x < uv.z; x++) { - Color32 c = tiles16[t->tile].color[y * 256 + x]; - ptr[x].r = c.b; - ptr[x].g = c.g; - ptr[x].b = c.r; - ptr[x].a = c.a; + Color32 c = tiles32[t->tile].color[y * 256 + x]; + swap(c.r, c.b); + ptr[x] = c; } ptr += 256; } @@ -5314,31 +6487,46 @@ namespace TR { CLUT &clut = cluts[t->clut]; Tile4 &src = tiles4[t->tile]; - - for (int y = uv.y; y < uv.w; y++) - for (int x = uv.x; x < uv.z; x++) + for (int y = uv.y; y < uv.w; y++) { + for (int x = uv.x; x < uv.z; x++) { dst->color[y * 256 + x] = clut.color[(x % 2) ? src.index[(y * 256 + x) / 2].b : src.index[(y * 256 + x) / 2].a]; - + } + } break; } default : ASSERT(false); } + premultiplyAlpha(dst->color, uv); + } + + void premultiplyAlpha(AtlasColor *data, const short4 &uv) { // pre-multiple alpha for (int y = uv.y; y < uv.w; y++) for (int x = uv.x; x < uv.z; x++) { - Color32 &c = dst->color[y * 256 + x]; + AtlasColor &c = data[y * 256 + x]; + #ifdef USE_ATLAS_RGBA16 + if (c.a == 0) { + c.value = 0; + } + #else c.r = uint8((uint16(c.r) * c.a) / 255); c.g = uint8((uint16(c.g) * c.a) / 255); c.b = uint8((uint16(c.b) * c.a) / 255); + #endif } } // common methods Color32 getColor(int texture) const { switch (version) { - case VER_TR1_SAT : return Color16((uint16)texture); - case VER_TR1_PC : return palette[texture & 0xFF]; + case VER_TR1_SAT : return ColorCLUT((uint16)texture); + case VER_TR1_PC : + #ifdef _GAPI_SW + return Color32(texture & 0xFF, 0, 0, 142); + #else + return palette[texture & 0xFF]; + #endif case VER_TR2_PC : case VER_TR3_PC : return palette32[(texture >> 8) & 0xFF]; case VER_TR1_PSX : @@ -5352,6 +6540,7 @@ namespace TR { CLUT &clut = cluts[t.clut]; return clut.color[part ? tile.index[idx].b : tile.index[idx].a]; } + case VER_TR4_PC : break; default : ASSERT(false); } return Color32(255, 0, 255, 255); @@ -5359,13 +6548,14 @@ namespace TR { Stream* getSampleStream(int index) const { if (!soundOffsets || !soundData) return NULL; - uint8 *data = &soundData[soundOffsets[index]]; + uint8 *data = soundData + soundOffsets[index]; uint32 size = 0; switch (version) { case VER_TR1_SAT : size = soundSize[index]; break; - case VER_TR1_PC : + case VER_TR1_PC : case VER_TR2_PC : - case VER_TR3_PC : size = FOURCC(data + 4) + 8; break; // read size from wave header + case VER_TR3_PC : + case VER_TR4_PC : size = FOURCC(data + 4) + 8; break; // read size from wave header case VER_TR1_PSX : case VER_TR2_PSX : case VER_TR3_PSX : size = soundSize[index]; break; diff --git a/src/game.h b/src/game.h index 32c12902..a8a8f5e0 100644 --- a/src/game.h +++ b/src/game.h @@ -14,25 +14,47 @@ namespace Game { Level *level; Stream *nextLevel; - ControlKey cheatSeq[MAX_CHEAT_SEQUENCE]; + ControlKey cheatSeq[MAX_PLAYERS][MAX_CHEAT_SEQUENCE]; + + void cheatControl(int32 playerIndex) { + ControlKey key = Input::lastState[playerIndex]; - void cheatControl(ControlKey key) { if (key == cMAX || !level || level->level.isTitle() || level->level.isCutsceneLevel()) return; - const ControlKey CHEAT_ALL_WEAPONS[] = { cLook, cWeapon, cDash, cDuck, cDuck, cDash, cRoll, cLook }; - const ControlKey CHEAT_SKIP_LEVEL[] = { cDuck, cDash, cLook, cRoll, cWeapon, cLook, cDash, cDuck }; + const ControlKey CHEAT_ALL_WEAPONS_1[] = { cLook, cWeapon, cDash, cDuck, cDuck, cDash, cRoll, cLook }; + const ControlKey CHEAT_ALL_WEAPONS_2[] = { cWeapon, cLook, cWeapon, cLook, cWeapon, cLook, cWeapon, cLook }; + + const ControlKey CHEAT_SKIP_LEVEL_1[] = { cDuck, cDash, cLook, cRoll, cWeapon, cLook, cDash, cDuck }; + const ControlKey CHEAT_SKIP_LEVEL_2[] = { cJump, cLook, cJump, cLook, cJump, cLook, cJump, cLook }; + + const ControlKey CHEAT_DOZY_MODE[] = { cWalk, cLook, cWalk, cLook, cWalk, cLook, cWalk, cLook }; for (int i = 0; i < MAX_CHEAT_SEQUENCE - 1; i++) - cheatSeq[i] = cheatSeq[i + 1]; - cheatSeq[MAX_CHEAT_SEQUENCE - 1] = key; + cheatSeq[playerIndex][i] = cheatSeq[playerIndex][i + 1]; + cheatSeq[playerIndex][MAX_CHEAT_SEQUENCE - 1] = key; + + #define CHECK_CHEAT(seq) (!memcmp(&cheatSeq[playerIndex][MAX_CHEAT_SEQUENCE - COUNT(seq)], seq, sizeof(seq))) // add all weapons - if (!memcmp(&cheatSeq[MAX_CHEAT_SEQUENCE - COUNT(CHEAT_ALL_WEAPONS)], CHEAT_ALL_WEAPONS, sizeof(CHEAT_ALL_WEAPONS))) { + if (CHECK_CHEAT(CHEAT_ALL_WEAPONS_1) || CHECK_CHEAT(CHEAT_ALL_WEAPONS_2)) + { inventory->addWeapons(); level->playSound(TR::SND_SCREAM); } + // skip level - if (!memcmp(&cheatSeq[MAX_CHEAT_SEQUENCE - COUNT(CHEAT_SKIP_LEVEL)], CHEAT_SKIP_LEVEL, sizeof(CHEAT_SKIP_LEVEL))) + if (CHECK_CHEAT(CHEAT_SKIP_LEVEL_1) || CHECK_CHEAT(CHEAT_SKIP_LEVEL_2)) + { level->loadNextLevel(); + } + + // dozy mode + if (CHECK_CHEAT(CHEAT_DOZY_MODE)) + { + Lara *lara = (Lara*)level->getLara(playerIndex); + if (lara) { + lara->setDozy(true); + } + } } void startLevel(Stream *lvl) { @@ -52,13 +74,13 @@ namespace Game { bool playLogo = level->level.isTitle() && id == TR::LVL_MAX; playVideo = playVideo && (id != level->level.id); - if (level->level.isTitle() && id != TR::LVL_MAX) + if (level->level.isTitle() && id != TR::LVL_MAX && !TR::isGameEnded) playVideo = false; level->init(playLogo, playVideo); UI::game = level; - #if !defined(_OS_PSP) && !defined(_OS_CLOVER) + #if !defined(INV_GAMEPAD_ONLY) UI::helpTipTime = 5.0f; #endif delete lvl; @@ -81,18 +103,23 @@ void loadSettings(Stream *stream, void *userData) { stream->raw((char*)&Core::settings + 1, stream->size - 1); // read settings data right after version number delete stream; } - - #ifdef _OS_ANDROID - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) - osToggleVR(true); - #endif + + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { + osToggleVR(true); + } Core::settings.version = SETTINGS_VERSION; Core::setVSync(Core::settings.detail.vsync != 0); + #if defined(_GAPI_SW) || defined(_GAPI_GU) + Core::settings.detail.filter = Core::Settings::LOW; + Core::settings.detail.lighting = Core::Settings::LOW; + Core::settings.detail.shadows = Core::Settings::LOW; + Core::settings.detail.water = Core::Settings::LOW; + #endif + shaderCache = new ShaderCache(); Game::startLevel((Stream*)userData); - UI::init(Game::level); } static void readSlotAsync(Stream *stream, void *userData) { @@ -153,6 +180,8 @@ namespace Game { #endif char fileName[255]; + TR::isGameEnded = false; + TR::Version version = TR::getGameVersion(); if (!lvlName) TR::getGameLevelFile(fileName, version, TR::getTitleId(version)); @@ -181,9 +210,16 @@ namespace Game { Input::update(); Network::update(); - cheatControl(Input::lastState[0]); + for (int32 i = 0; i < MAX_PLAYERS; i++) + { + if (level->players[i]) { + cheatControl(i); + } + } - if (!level->level.isTitle()) { + // Only check for cStart if the inventory is not active. + // Otherwise if cStart was binded to item selection key in inventory it would reset the player. + if (!level->level.isTitle() && !inventory->isActive()) { if (Input::lastState[0] == cStart) level->addPlayer(0); if (Input::lastState[1] == cStart) level->addPlayer(1); } @@ -201,6 +237,37 @@ namespace Game { Core::deltaTime = dt; } + void quickSave() { + if (!level || TR::isTitleLevel(level->level.id) || TR::isCutsceneLevel(level->level.id)) { + return; + } + level->saveGame(level->level.id, true, false); + } + + void quickLoad(bool forced = false) { + if (!level) return; + + int slot = getSaveSlot(level->level.id, true); + + if (slot == -1) { + slot = getSaveSlot(level->level.id, false); + } + + if (slot > -1) { + level->loadGame(slot); + if (forced) { + level->loadGame(slot); + level->loadLevel(saveSlots[slot].getLevelID()); + level->loadNextLevelData(); + if (nextLevel) { + startLevel(nextLevel); + nextLevel = NULL; + inventory->titleTimer = 0.0f; + } + } + } + } + bool update() { // async load for settings if (Core::settings.version == SETTINGS_READING) @@ -238,16 +305,12 @@ namespace Game { if (Input::down[ik5] && !inventory->isActive()) { if (level->players[0]->canSaveGame()) - level->saveGame(level->level.id, true, false); + quickSave(); Input::down[ik5] = false; } if (Input::down[ik9] && !inventory->isActive()) { - int slot = getSaveSlot(level->level.id, true); - if (slot == -1) - slot = getSaveSlot(level->level.id, false); - if (slot > -1) - level->loadGame(slot); + quickLoad(); Input::down[ik9] = false; } diff --git a/src/gameflow.h b/src/gameflow.h index 7c5f6132..d3243979 100644 --- a/src/gameflow.h +++ b/src/gameflow.h @@ -2,12 +2,14 @@ #define H_GAMEFLOW #include "utils.h" +#include "lang.h" #define CHECK_FILE(name) if (Stream::existsContent(name)) return name namespace TR { bool useEasyStart; + bool isGameEnded; enum { NO_TRACK = 0xFF, @@ -16,18 +18,19 @@ namespace TR { enum Version { VER_UNKNOWN = 0, - VER_PC = 256, - VER_PSX = 512, - VER_SAT = 1024, + VER_PC = 0x1000, + VER_PSX = 0x2000, + VER_SAT = 0x4000, + VER_SDC = 0x8000, - VER_TR1 = 1, - VER_TR2 = 2, - VER_TR3 = 4, - VER_TR4 = 8, - VER_TR5 = 16, + VER_TR1 = 0x01, + VER_TR2 = 0x02, + VER_TR3 = 0x04, + VER_TR4 = 0x08, + VER_TR5 = 0x10, VER_VERSION = VER_TR1 | VER_TR2 | VER_TR3 | VER_TR4 | VER_TR5, - VER_PLATFORM = VER_PC | VER_PSX | VER_SAT, + VER_PLATFORM = VER_PC | VER_PSX | VER_SAT | VER_SDC, VER_TR1_PC = VER_TR1 | VER_PC, VER_TR1_PSX = VER_TR1 | VER_PSX, @@ -39,6 +42,14 @@ namespace TR { VER_TR3_PC = VER_TR3 | VER_PC, VER_TR3_PSX = VER_TR3 | VER_PSX, + VER_TR4_PC = VER_TR4 | VER_PC, + VER_TR4_PSX = VER_TR4 | VER_PSX, + VER_TR4_SDC = VER_TR4 | VER_SDC, + + VER_TR5_PC = VER_TR5 | VER_PC, + VER_TR5_PSX = VER_TR5 | VER_PSX, + VER_TR5_SDC = VER_TR5 | VER_SDC, + VER_MAX = 0xFFFFFFFF, }; @@ -129,6 +140,45 @@ namespace TR { LVL_TR3_CUT_12, LVL_TR3_CHAMBER, LVL_TR3_STPAUL, + // TR4 + LVL_TR4_TITLE, + LVL_TR4_ANGKOR1, + LVL_TR4_ANG_RACE, + LVL_TR4_SETTOMB1, + LVL_TR4_SETTOMB2, + LVL_TR4_JEEPCHAS, + LVL_TR4_JEEPCHS2, + LVL_TR4_KARNAK1, + LVL_TR4_HALL, + LVL_TR4_LAKE, + LVL_TR4_SEMER, + LVL_TR4_SEMER2, + LVL_TR4_TRAIN, + LVL_TR4_ALEXHUB, + LVL_TR4_ALEXHUB2, + LVL_TR4_PALACES, + LVL_TR4_PALACES2, + LVL_TR4_CSPLIT1, + LVL_TR4_CSPLIT2, + LVL_TR4_LIBRARY, + LVL_TR4_LIBEND, + LVL_TR4_BIKEBIT, + LVL_TR4_NUTRENCH, + LVL_TR4_CORTYARD, + LVL_TR4_LOWSTRT, + LVL_TR4_HIGHSTRT, + LVL_TR4_CITNEW, + LVL_TR4_JOBY1A, + LVL_TR4_JOBY1B, + LVL_TR4_JOBY2, + LVL_TR4_JOBY3A, + LVL_TR4_JOBY3B, + LVL_TR4_JOBY4A, + LVL_TR4_JOBY4B, + LVL_TR4_JOBY4C, + LVL_TR4_JOBY5A, + LVL_TR4_JOBY5B, + LVL_TR4_JOBY5C, LVL_MAX, }; @@ -139,8 +189,8 @@ namespace TR { TRACK_TR1_CAVES = 5, TRACK_TR1_SECRET = 13, TRACK_TR1_CISTERN = 57, - TRACK_TR1_EGYPT = 58, - TRACK_TR1_MINE = 59, + TRACK_TR1_WIND = 58, + TRACK_TR1_PYRAMID = 59, TRACK_TR1_CUT_1 = 23, TRACK_TR1_CUT_2 = 25, TRACK_TR1_CUT_3 = 24, @@ -188,101 +238,280 @@ namespace TR { TRACK_TR3_CUT_9 = 69, TRACK_TR3_CUT_11 = 71, TRACK_TR3_CUT_12 = 66, + // TR4 + TRACK_TR4_BOSS = 97, + TRACK_TR4_JEEP = 98, + TRACK_TR4_BATTLE = 102, + TRACK_TR4_TITLE = 104, + TRACK_TR4_COASTAL = 105, + TRACK_TR4_TRAIN = 106, + TRACK_TR4_IN_DARK = 107, + TRACK_TR4_IN_DRIPS = 108, + TRACK_TR4_WEIRD1 = 109, + TRACK_TR4_OUT_DAY = 110, + TRACK_TR4_OUT_NIGHT = 111, }; struct LevelInfo { const char *name; - const char *title; - int track; + StringID title; + uint8 track; + uint8 secrets; } LEVEL_INFO[LVL_MAX] = { + { "" , STR_EMPTY , TRACK_TR1_CAVES , 0 }, // TR1 - { "" , "Custom Level", TRACK_TR1_CAVES }, - { "TITLE" , "", TRACK_TR1_TITLE }, - { "GYM" , "Lara's Home", NO_TRACK }, - { "LEVEL1" , "Caves", TRACK_TR1_CAVES }, - { "LEVEL2" , "City of Vilcabamba", TRACK_TR1_CAVES }, - { "LEVEL3A" , "Lost Valley", TRACK_TR1_CAVES }, - { "LEVEL3B" , "Tomb of Qualopec", TRACK_TR1_CAVES }, - { "CUT1" , "", TRACK_TR1_CUT_1 }, - { "LEVEL4" , "St. Francis' Folly", TRACK_TR1_CAVES }, - { "LEVEL5" , "Colosseum", TRACK_TR1_CAVES }, - { "LEVEL6" , "Palace Midas", TRACK_TR1_CAVES }, - { "LEVEL7A" , "The Cistern", TRACK_TR1_CISTERN }, - { "LEVEL7B" , "Tomb of Tihocan", TRACK_TR1_CISTERN }, - { "CUT2" , "", TRACK_TR1_CUT_2 }, - { "LEVEL8A" , "City of Khamoon", TRACK_TR1_EGYPT }, - { "LEVEL8B" , "Obelisk of Khamoon", TRACK_TR1_EGYPT }, - { "LEVEL8C" , "Sanctuary of the Scion", TRACK_TR1_EGYPT }, - { "LEVEL10A" , "Natla's Mines", TRACK_TR1_MINE }, - { "CUT3" , "", TRACK_TR1_CUT_3 }, - { "LEVEL10B" , "Atlantis", TRACK_TR1_MINE }, - { "CUT4" , "", TRACK_TR1_CUT_4 }, - { "LEVEL10C" , "The Great Pyramid", TRACK_TR1_MINE }, - { "EGYPT" , "Return to Egypt", TRACK_TR1_EGYPT }, - { "CAT" , "Temple of the Cat", TRACK_TR1_EGYPT }, - { "END" , "Atlantean Stronghold", TRACK_TR1_EGYPT }, - { "END2" , "The Hive", TRACK_TR1_EGYPT }, + { "TITLE" , STR_EMPTY , TRACK_TR1_TITLE , 0 }, + { "GYM" , STR_TR1_GYM , NO_TRACK , 0 }, + { "LEVEL1" , STR_TR1_LEVEL1 , TRACK_TR1_CAVES , 3 }, + { "LEVEL2" , STR_TR1_LEVEL2 , TRACK_TR1_CAVES , 3 }, + { "LEVEL3A" , STR_TR1_LEVEL3A , TRACK_TR1_CAVES , 5 }, + { "LEVEL3B" , STR_TR1_LEVEL3B , TRACK_TR1_CAVES , 3 }, + { "CUT1" , STR_EMPTY , TRACK_TR1_CUT_1 , 0 }, + { "LEVEL4" , STR_TR1_LEVEL4 , TRACK_TR1_WIND , 4 }, + { "LEVEL5" , STR_TR1_LEVEL5 , TRACK_TR1_WIND , 3 }, + { "LEVEL6" , STR_TR1_LEVEL6 , TRACK_TR1_WIND , 3 }, + { "LEVEL7A" , STR_TR1_LEVEL7A , TRACK_TR1_CISTERN , 3 }, + { "LEVEL7B" , STR_TR1_LEVEL7B , TRACK_TR1_CISTERN , 2 }, + { "CUT2" , STR_EMPTY , TRACK_TR1_CUT_2 , 0 }, + { "LEVEL8A" , STR_TR1_LEVEL8A , TRACK_TR1_WIND , 3 }, + { "LEVEL8B" , STR_TR1_LEVEL8B , TRACK_TR1_WIND , 3 }, + { "LEVEL8C" , STR_TR1_LEVEL8C , TRACK_TR1_WIND , 1 }, + { "LEVEL10A" , STR_TR1_LEVEL10A , TRACK_TR1_CISTERN , 3 }, + { "CUT3" , STR_EMPTY , TRACK_TR1_CUT_3 , 0 }, + { "LEVEL10B" , STR_TR1_LEVEL10B , TRACK_TR1_PYRAMID , 3 }, + { "CUT4" , STR_EMPTY , TRACK_TR1_CUT_4 , 0 }, + { "LEVEL10C" , STR_TR1_LEVEL10C , TRACK_TR1_PYRAMID , 3 }, + { "EGYPT" , STR_TR1_EGYPT , TRACK_TR1_WIND , 3 }, + { "CAT" , STR_TR1_CAT , TRACK_TR1_WIND , 4 }, + { "END" , STR_TR1_END , TRACK_TR1_WIND , 2 }, + { "END2" , STR_TR1_END2 , TRACK_TR1_WIND , 1 }, // TR2 - { "TITLE" , "", TRACK_TR2_TITLE }, - { "ASSAULT" , "Lara's Home", NO_TRACK }, - { "WALL" , "The Great Wall", TRACK_TR2_CHINA_1 }, - { "CUT1" , "", TRACK_TR2_CUT_1 }, - { "BOAT" , "Venice", NO_TRACK }, - { "VENICE" , "Bartoli's Hideout", NO_TRACK }, - { "OPERA" , "Opera House", TRACK_TR2_ITALY }, - { "CUT2" , "", TRACK_TR2_CUT_2 }, - { "RIG" , "Offshore Rig", TRACK_TR2_RIG }, - { "PLATFORM" , "Diving Area", TRACK_TR2_RIG }, - { "CUT3" , "", TRACK_TR2_CUT_3 }, - { "UNWATER" , "40 Fathoms", TRACK_TR2_UNWATER_1 }, - { "KEEL" , "Wreck of the Maria Doria", TRACK_TR2_UNWATER_2 }, - { "LIVING" , "Living Quarters", TRACK_TR2_UNWATER_1 }, - { "DECK" , "The Deck", TRACK_TR2_UNWATER_2 }, - { "SKIDOO" , "Tibetan Foothills", TRACK_TR2_TIBET_1 }, - { "MONASTRY" , "Barkhang Monastery", NO_TRACK }, - { "CATACOMB" , "Catacombs of the Talion", TRACK_TR2_TIBET_2 }, - { "ICECAVE" , "Ice Palace", TRACK_TR2_TIBET_2 }, - { "EMPRTOMB" , "Temple of Xian", TRACK_TR2_CHINA_2 }, - { "CUT4" , "", TRACK_TR2_CUT_4 }, - { "FLOATING" , "Floating Islands", TRACK_TR2_CHINA_2 }, - { "XIAN" , "The Dragon's Lair", TRACK_TR2_CHINA_2 }, - { "HOUSE" , "Home Sweet Home", NO_TRACK }, + { "TITLE" , STR_EMPTY , TRACK_TR2_TITLE , 0 }, + { "ASSAULT" , STR_TR2_ASSAULT , NO_TRACK , 0 }, + { "WALL" , STR_TR2_WALL , TRACK_TR2_CHINA_1 , 3 }, + { "CUT1" , STR_EMPTY , TRACK_TR2_CUT_1 , 0 }, + { "BOAT" , STR_TR2_BOAT , NO_TRACK , 3 }, + { "VENICE" , STR_TR2_VENICE , NO_TRACK , 3 }, + { "OPERA" , STR_TR2_OPERA , TRACK_TR2_ITALY , 3 }, + { "CUT2" , STR_EMPTY , TRACK_TR2_CUT_2 , 0 }, + { "RIG" , STR_TR2_RIG , TRACK_TR2_RIG , 3 }, + { "PLATFORM" , STR_TR2_PLATFORM , TRACK_TR2_RIG , 3 }, + { "CUT3" , STR_EMPTY , TRACK_TR2_CUT_3 , 0 }, + { "UNWATER" , STR_TR2_UNWATER , TRACK_TR2_UNWATER_1 , 3 }, + { "KEEL" , STR_TR2_KEEL , TRACK_TR2_UNWATER_2 , 3 }, + { "LIVING" , STR_TR2_LIVING , TRACK_TR2_UNWATER_1 , 3 }, + { "DECK" , STR_TR2_DECK , TRACK_TR2_UNWATER_2 , 3 }, + { "SKIDOO" , STR_TR2_SKIDOO , TRACK_TR2_TIBET_1 , 3 }, + { "MONASTRY" , STR_TR2_MONASTRY , NO_TRACK , 3 }, + { "CATACOMB" , STR_TR2_CATACOMB , TRACK_TR2_TIBET_2 , 3 }, + { "ICECAVE" , STR_TR2_ICECAVE , TRACK_TR2_TIBET_2 , 3 }, + { "EMPRTOMB" , STR_TR2_EMPRTOMB , TRACK_TR2_CHINA_2 , 3 }, + { "CUT4" , STR_EMPTY , TRACK_TR2_CUT_4 , 0 }, + { "FLOATING" , STR_TR2_FLOATING , TRACK_TR2_CHINA_2 , 3 }, + { "XIAN" , STR_TR2_XIAN , TRACK_TR2_CHINA_2 , 3 }, + { "HOUSE" , STR_TR2_HOUSE , NO_TRACK , 3 }, // TR3 - { "TITLE", "", TRACK_TR3_TITLE }, - { "HOUSE", "Lara's House", NO_TRACK }, - { "JUNGLE", "Jungle", TRACK_TR3_INDIA_1 }, - { "CUT6", "", TRACK_TR3_CUT_6 }, - { "TEMPLE", "Temple Ruins", TRACK_TR3_INDIA_1 }, - { "CUT9", "", TRACK_TR3_CUT_9 }, - { "QUADCHAS", "The River Ganges", TRACK_TR3_INDIA_1 }, - { "TONYBOSS", "Caves Of Kaliya", TRACK_TR3_INDIA_2 }, - { "SHORE", "Coastal Village", TRACK_TR3_SOUTH_1 }, - { "CUT1", "", TRACK_TR3_CUT_1 }, - { "CRASH", "Crash Site", TRACK_TR3_SOUTH_2 }, - { "CUT4", "", TRACK_TR3_CUT_4 }, - { "RAPIDS", "Madubu Gorge", TRACK_TR3_SOUTH_3 }, - { "TRIBOSS", "Temple Of Puna", TRACK_TR3_CAVES }, - { "ROOFS", "Thames Wharf", TRACK_TR3_LONDON_1 }, - { "CUT2", "", TRACK_TR3_CUT_2 }, - { "SEWER", "Aldwych", TRACK_TR3_LONDON_2 }, - { "CUT5", "", TRACK_TR3_CUT_5 }, - { "TOWER", "Lud's Gate", TRACK_TR3_LONDON_3 }, - { "CUT11", "", TRACK_TR3_CUT_11 }, - { "OFFICE", "City", TRACK_TR3_LONDON_4 }, - { "NEVADA", "Nevada Desert", TRACK_TR3_NEVADA_1 }, - { "CUT7", "", TRACK_TR3_CUT_7 }, - { "COMPOUND", "High Security Compound", TRACK_TR3_NEVADA_2 }, - { "CUT8", "", TRACK_TR3_CUT_8 }, - { "AREA51", "Area 51", TRACK_TR3_NEVADA_2 }, - { "ANTARC", "Antarctica", TRACK_TR3_ANTARC_1 }, - { "CUT3", "", TRACK_TR3_CUT_3 }, - { "MINES", "RX-Tech Mines", TRACK_TR3_ANTARC_2 }, - { "CITY", "Lost City Of Tinnos", TRACK_TR3_ANTARC_3 }, - { "CUT12", "", TRACK_TR3_CUT_12 }, - { "CHAMBER", "Meteorite Cavern", TRACK_TR3_ANTARC_3 }, - { "STPAUL", "All Hallows", TRACK_TR3_CAVES }, + { "TITLE" , STR_EMPTY , TRACK_TR3_TITLE , 0 }, + { "HOUSE" , STR_TR3_HOUSE , NO_TRACK , 3 }, + { "JUNGLE" , STR_TR3_JUNGLE , TRACK_TR3_INDIA_1 , 3 }, + { "CUT6" , STR_EMPTY , TRACK_TR3_CUT_6 , 0 }, + { "TEMPLE" , STR_TR3_TEMPLE , TRACK_TR3_INDIA_1 , 3 }, + { "CUT9" , STR_EMPTY , TRACK_TR3_CUT_9 , 0 }, + { "QUADCHAS" , STR_TR3_QUADCHAS , TRACK_TR3_INDIA_1 , 3 }, + { "TONYBOSS" , STR_TR3_TONYBOSS , TRACK_TR3_INDIA_2 , 3 }, + { "SHORE" , STR_TR3_SHORE , TRACK_TR3_SOUTH_1 , 3 }, + { "CUT1" , STR_EMPTY , TRACK_TR3_CUT_1 , 0 }, + { "CRASH" , STR_TR3_CRASH , TRACK_TR3_SOUTH_2 , 3 }, + { "CUT4" , STR_EMPTY , TRACK_TR3_CUT_4 , 0 }, + { "RAPIDS" , STR_TR3_RAPIDS , TRACK_TR3_SOUTH_3 , 3 }, + { "TRIBOSS" , STR_TR3_TRIBOSS , TRACK_TR3_CAVES , 3 }, + { "ROOFS" , STR_TR3_ROOFS , TRACK_TR3_LONDON_1 , 3 }, + { "CUT2" , STR_EMPTY , TRACK_TR3_CUT_2 , 0 }, + { "SEWER" , STR_TR3_SEWER , TRACK_TR3_LONDON_2 , 3 }, + { "CUT5" , STR_EMPTY , TRACK_TR3_CUT_5 , 0 }, + { "TOWER" , STR_TR3_TOWER , TRACK_TR3_LONDON_3 , 3 }, + { "CUT11" , STR_EMPTY , TRACK_TR3_CUT_11 , 0 }, + { "OFFICE" , STR_TR3_OFFICE , TRACK_TR3_LONDON_4 , 3 }, + { "NEVADA" , STR_TR3_NEVADA , TRACK_TR3_NEVADA_1 , 3 }, + { "CUT7" , STR_EMPTY , TRACK_TR3_CUT_7 , 0 }, + { "COMPOUND" , STR_TR3_COMPOUND , TRACK_TR3_NEVADA_2 , 3 }, + { "CUT8" , STR_EMPTY , TRACK_TR3_CUT_8 , 0 }, + { "AREA51" , STR_TR3_AREA51 , TRACK_TR3_NEVADA_2 , 3 }, + { "ANTARC" , STR_TR3_ANTARC , TRACK_TR3_ANTARC_1 , 3 }, + { "CUT3" , STR_EMPTY , TRACK_TR3_CUT_3 , 0 }, + { "MINES" , STR_TR3_MINES , TRACK_TR3_ANTARC_2 , 3 }, + { "CITY" , STR_TR3_CITY , TRACK_TR3_ANTARC_3 , 3 }, + { "CUT12" , STR_EMPTY , TRACK_TR3_CUT_12 , 0 }, + { "CHAMBER" , STR_TR3_CHAMBER , TRACK_TR3_ANTARC_3 , 3 }, + { "STPAUL" , STR_TR3_STPAUL , TRACK_TR3_CAVES , 3 }, + // TR4 + { "title" , STR_UNKNOWN , TRACK_TR4_TITLE , 0 }, + { "angkor1" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "ang_race" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "settomb1" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "settomb2" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "jeepchas" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "jeepchs2" , STR_UNKNOWN , TRACK_TR4_JEEP , 0 }, + { "karnak1" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "hall" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "lake" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "semer" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "semer2" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "train" , STR_UNKNOWN , TRACK_TR4_TRAIN , 0 }, + { "alexhub" , STR_UNKNOWN , TRACK_TR4_OUT_DAY , 0 }, + { "alexhub2" , STR_UNKNOWN , TRACK_TR4_COASTAL , 0 }, + { "palaces" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "palaces2" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "csplit1" , STR_UNKNOWN , TRACK_TR4_IN_DRIPS , 0 }, + { "csplit2" , STR_UNKNOWN , TRACK_TR4_IN_DRIPS , 0 }, + { "library" , STR_UNKNOWN , TRACK_TR4_IN_DRIPS , 0 }, + { "libend" , STR_UNKNOWN , TRACK_TR4_WEIRD1 , 0 }, + { "bikebit" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "nutrench" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "cortyard" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "lowstrt" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "highstrt" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "citnew" , STR_UNKNOWN , TRACK_TR4_BATTLE , 0 }, + { "joby1a" , STR_UNKNOWN , TRACK_TR4_OUT_NIGHT , 0 }, + { "joby1b" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "joby2" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "joby3a" , STR_UNKNOWN , TRACK_TR4_OUT_NIGHT , 0 }, + { "joby3b" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "joby4a" , STR_UNKNOWN , TRACK_TR4_OUT_NIGHT , 0 }, + { "joby4b" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "joby4c" , STR_UNKNOWN , TRACK_TR4_OUT_NIGHT , 0 }, + { "joby5a" , STR_UNKNOWN , TRACK_TR4_IN_DARK , 0 }, + { "joby5b" , STR_UNKNOWN , TRACK_TR4_BOSS , 0 }, + { "joby5c" , STR_UNKNOWN , TRACK_TR4_IN_DRIPS , 0 }, }; + static const char* TRACK_LIST_TR4[] = { + "044_Attack_part_i" + , "008_VonCroy9a" + , "100_Attack_part_ii" + , "010_VonCroy10" + , "015_VonCroy14" + , "073_Secret" + , "109_Lyre_01" + , "042_Action_Part_iv" + , "043_Action_Part_v" + , "030_VonCroy30" + , "012_VonCroy11b" + , "011_VonCroy11a" + , "063_Misc_Inc_01" + , "014_VonCroy13b" + , "111_charmer" + , "025_VonCroy24b" + , "023_VonCroy23" + , "006_VonCroy7" + , "024_VonCroy24a" + , "110_Lyre_02" + , "020_VonCroy19" + , "034_VonCroy34" + , "054_General_Part_ii" + , "036_VonCroy36" + , "004_VonCroy5" + , "035_VonCroy35" + , "027_VonCroy27" + , "053_General_Part_i" + , "022_VonCroy22b" + , "028_VonCroy28_L11" + , "003_VonCroy4" + , "001_VonCroy2" + , "041_Action_Part_iii" + , "057_General_Part_v" + , "018_VonCroy17" + , "064_Misc_Inc_02" + , "033_VonCroy33" + , "031_VonCroy31_L12" + , "032_VonCroy32_L13" + , "016_VonCroy15" + , "065_Misc_Inc_03" + , "040_Action_Part_ii" + , "112_Gods_part_iv" + , "029_VonCroy29" + , "007_VonCroy8" + , "013_VonCroy12_13a_Lara4" + , "009_VonCroy9b_Lara3" + , "081_dig" + , "085_intro" + , "071_Ominous_Part_i" + , "095_phildoor" + , "061_In_The_Pyramid_Part_i" + , "050_Underwater_Find_part_i" + , "058_Gods_Part_i" + , "005_VonCroy6_Lara2" + , "045_Authentic_TR" + , "060_Gods_Part_iii" + , "055_General_Part_iii" + , "059_Gods_Part_ii" + , "068_Mystery_Part_ii" + , "076_captain2" + , "019_Lara6_VonCroy18" + , "002_VonCroy3" + , "066_Misc_Inc_04" + , "067_Mystery_Part_i" + , "038_A_Short_01" + , "088_key" + , "017_VonCroy16_lara5" + , "026_VC25_L9_VC26_L10" + , "056_General_Part_iv" + , "021_VC20_L7_VC21_L8_VC22a" + , "096_sarcoph" + , "087_jeepB" + , "091_minilib1" + , "086_jeepA" + , "051_Egyptian_Mood_Part_i" + , "078_croywon" + , "092_minilib2" + , "083_horus" + , "049_Close_to_the_End_part_ii" + , "037_VC37_L15_VC38" + , "097_scorpion" + , "089_larawon" + , "094_minilib4" + , "098_throne" + , "048_Close_to_the_End" + , "070_Mystery_Part_iv" + , "093_minilib3" + , "072_Puzzle_part_i" + , "074_backpack" + , "069_Mystery_Part_iii" + , "052_Egyptian_Mood_Part_ii" + , "084_inscrip" + , "099_whouse" + , "047_Boss_02" + , "080_crypt2" + , "090_libend" + , "046_Boss_01" + , "062_Jeep_Thrills_max" + , "079_crypt1" + , "082_finale" + , "075_captain1" + , "105_A5_Battle" + , "077_crocgod" + , "039_TR4_Title_Q10" + , "108_A8_Coastal" + , "107_A7_Train+" + , "101_A1_In_Dark" + , "102_A2_In_Drips" + , "104_A4_Weird1" + , "106_A6_Out_Day" + , "103_A3_Out_Night" + }; + + Version getGameVersionByLevel(LevelID id) { + if (id >= LVL_TR1_TITLE && id <= LVL_TR1_END2) + return VER_TR1; + if (id >= LVL_TR2_TITLE && id <= LVL_TR2_HOUSE) + return VER_TR2; + if (id >= LVL_TR3_TITLE && id <= LVL_TR3_STPAUL) + return VER_TR3; + if (id >= LVL_TR4_TITLE && id <= LVL_TR4_JOBY5C) + return VER_TR4; + return VER_UNKNOWN; + } + LevelID getLevelID(int size, const char *name, Version &version, bool &isDemoLevel) { isDemoLevel = false; switch (size) { @@ -294,6 +523,7 @@ namespace TR { case 320412 : // PC JAP case 334874 : case 316138 : + case 316518 : // PC G case 316460 : return LVL_TR1_TITLE; // GYM case 1234800 : // PSX JAP @@ -301,6 +531,7 @@ namespace TR { case 343854 : // SAT case 3377974 : // PC JAP case 3236806 : + case 3282970 : // PC G case 3237128 : return LVL_TR1_GYM; // LEVEL1 case 1667568 : // PSX JAP @@ -369,6 +600,7 @@ namespace TR { case 596416 : // SAT case 3603912 : // PC JAP case 3388774 : + case 3395618 : // PC G case 3389096 : return LVL_TR1_7B; // CUT2 case 542960 : version = VER_TR1_PSX; @@ -394,6 +626,7 @@ namespace TR { case 536950 : // SAT case 3072066 : // PC JAP case 3105128 : + case 3025380 : // PC G case 3105450 : return LVL_TR1_8C; // LEVEL10A case 1680146 : // PSX JAP @@ -401,6 +634,7 @@ namespace TR { case 569856 : // SAT case 3270372 : // PC JAP case 3223816 : + case 3154346 : // PC G case 3224138 : return LVL_TR1_10A; // CUT3 case 636660 : version = VER_TR1_PSX; @@ -423,6 +657,7 @@ namespace TR { case 418170 : // SAT case 3533814 : // PC JAP case 3531702 : + case 3496692 : // PC G case 3532024 : return LVL_TR1_10C; // EGYPT case 3278614 : version = VER_TR1_PSX; @@ -665,12 +900,51 @@ namespace TR { case 1080128 : // PSX JAP case 1080046 : case 2321393 : return LVL_TR3_CUT_12; + // TR4 + case 3007155 : return LVL_TR4_TITLE; + case 4034313 : return LVL_TR4_ANGKOR1; + case 4343019 : return LVL_TR4_ANG_RACE; + case 3715110 : return LVL_TR4_SETTOMB1; + case 3868566 : return LVL_TR4_SETTOMB2; + case 3600478 : return LVL_TR4_JEEPCHAS; + case 4826055 : return LVL_TR4_JEEPCHS2; + case 4773596 : return LVL_TR4_KARNAK1; + case 4882065 : return LVL_TR4_HALL; + case 5021843 : return LVL_TR4_LAKE; + case 4409367 : return LVL_TR4_SEMER; + case 4294398 : return LVL_TR4_SEMER2; + case 3246177 : return LVL_TR4_TRAIN; + case 4007946 : return LVL_TR4_ALEXHUB; + case 4735043 : return LVL_TR4_ALEXHUB2; + case 4549992 : return LVL_TR4_PALACES; + case 4779709 : return LVL_TR4_PALACES2; + case 4570232 : return LVL_TR4_CSPLIT1; + case 4838007 : return LVL_TR4_CSPLIT2; + case 4606099 : return LVL_TR4_LIBRARY; + case 3240517 : return LVL_TR4_LIBEND; + case 5013974 : return LVL_TR4_BIKEBIT; + case 4260336 : return LVL_TR4_NUTRENCH; + case 4989001 : return LVL_TR4_CORTYARD; + case 3970465 : return LVL_TR4_LOWSTRT; + case 4725022 : return LVL_TR4_HIGHSTRT; + case 4776907 : return LVL_TR4_CITNEW; + case 5011064 : return LVL_TR4_JOBY1A; + case 4544163 : return LVL_TR4_JOBY1B; + case 4839409 : return LVL_TR4_JOBY2; + case 4433722 : return LVL_TR4_JOBY3A; + case 5141026 : return LVL_TR4_JOBY3B; + case 4786641 : return LVL_TR4_JOBY4A; + case 4401690 : return LVL_TR4_JOBY4B; + case 4999677 : return LVL_TR4_JOBY4C; + case 3741579 : return LVL_TR4_JOBY5A; + case 4623726 : return LVL_TR4_JOBY5B; + case 4398142 : return LVL_TR4_JOBY5C; } if (name) { // skip directory path int start = 0; - for (int i = strlen(name) - 1; i >= 0; i--) + for (int i = int(strlen(name)) - 1; i >= 0; i--) if (name[i] == '/' || name[i] == '\\') { start = i + 1; break; @@ -678,16 +952,30 @@ namespace TR { // skip file extension char buf[255]; strcpy(buf, name + start); + char *ext = NULL; for (int i = 0; i < int(strlen(buf)); i++) if (buf[i] == '.') { buf[i] = 0; + ext = buf + i + 1; break; } // compare with standard levels // TODO: fix TITLE (2-3), HOUSE (3), CUTx (2-3) for (int i = 0; i < LVL_MAX; i++) - if (!strcmp(buf, LEVEL_INFO[i].name)) - return LevelID(i); + if (!strcmp(buf, LEVEL_INFO[i].name)) { + LevelID id = LevelID(i); + if (ext) { + version = getGameVersionByLevel(id); + if (!strcmp("PSX", ext)) { + version = Version(version | VER_PSX); + } else if (!strcmp("SAT", ext)) { + version = Version(version | VER_SAT); + } else { + version = Version(version | VER_PC); + } + } + return id; + } } return LVL_CUSTOM; @@ -698,6 +986,7 @@ namespace TR { case VER_TR1 : return LVL_TR1_TITLE; case VER_TR2 : return LVL_TR2_TITLE; case VER_TR3 : return LVL_TR3_TITLE; + case VER_TR4 : return LVL_TR4_TITLE; } return LVL_TR1_TITLE; ASSERT(false); @@ -708,6 +997,7 @@ namespace TR { case VER_TR1 : return LVL_TR1_GYM; case VER_TR2 : return LVL_TR2_ASSAULT; case VER_TR3 : return LVL_TR3_HOUSE; + case VER_TR4 : return LVL_MAX; } ASSERT(false); return LVL_MAX; @@ -718,6 +1008,7 @@ namespace TR { case VER_TR1 : return LVL_TR1_1; case VER_TR2 : return LVL_TR2_WALL; case VER_TR3 : return LVL_TR3_JUNGLE; + case VER_TR4 : return LVL_TR4_ANGKOR1; } ASSERT(false); return LVL_MAX; @@ -725,9 +1016,10 @@ namespace TR { LevelID getEndId(Version version) { switch (version & VER_VERSION) { - case VER_TR1 : return LVL_TR1_END2; + case VER_TR1 : return LVL_TR1_10C; case VER_TR2 : return LVL_TR2_HOUSE; case VER_TR3 : return LVL_TR3_CHAMBER; + case VER_TR4 : return LVL_TR4_JOBY5C; } ASSERT(false); return LVL_MAX; @@ -735,14 +1027,17 @@ namespace TR { bool isCutsceneLevel(LevelID id) { return id == LVL_TR1_CUT_1 || id == LVL_TR1_CUT_2 || id == LVL_TR1_CUT_3 || id == LVL_TR1_CUT_4 || - id == LVL_TR2_CUT_1 || id == LVL_TR2_CUT_2 || id == LVL_TR2_CUT_3 || id == LVL_TR2_CUT_4 || + id == LVL_TR2_CUT_1 || id == LVL_TR2_CUT_2 || id == LVL_TR2_CUT_3 || id == LVL_TR2_CUT_4 || id == LVL_TR3_CUT_1 || id == LVL_TR3_CUT_2 || id == LVL_TR3_CUT_3 || id == LVL_TR3_CUT_4 || id == LVL_TR3_CUT_5 || id == LVL_TR3_CUT_6 || id == LVL_TR3_CUT_7 || id == LVL_TR3_CUT_8 || id == LVL_TR3_CUT_9 || id == LVL_TR3_CUT_11 || id == LVL_TR3_CUT_12; } bool isTitleLevel(LevelID id) { - return id == LVL_TR1_TITLE || id == LVL_TR2_TITLE || id == LVL_TR3_TITLE; + return id == LVL_TR1_TITLE || + id == LVL_TR2_TITLE || + id == LVL_TR3_TITLE || + id == LVL_TR4_TITLE; } bool isEmptyLevel(LevelID id) { @@ -769,17 +1064,10 @@ namespace TR { if (Stream::existsContent("DATA/JUNGLE.PSX")) return VER_TR3_PSX; - useEasyStart = false; - return VER_UNKNOWN; - } + if (Stream::existsContent("data/angkor1.tr4")) + return VER_TR4_PC; - Version getGameVersionByLevel(LevelID id) { - if (id >= LVL_TR1_TITLE && id <= LVL_TR1_END2) - return VER_TR1; - if (id >= LVL_TR2_TITLE && id <= LVL_TR2_HOUSE) - return VER_TR2; - if (id >= LVL_TR3_TITLE && id <= LVL_TR3_STPAUL) - return VER_TR3; + useEasyStart = false; return VER_UNKNOWN; } @@ -793,30 +1081,18 @@ namespace TR { break; case VER_TR1_PSX : sprintf(dst, "PSXDATA/%s.PSX", LEVEL_INFO[id].name); break; case VER_TR1_SAT : sprintf(dst, "DATA/%s.SAT", LEVEL_INFO[id].name); break; - case VER_TR2_PC : { // oh FFFFUUUUUUCKing CaTaComB.Tr2! - if (id == LVL_TR2_VENICE || id == LVL_TR2_CUT_2 || id == LVL_TR2_PLATFORM || id == LVL_TR2_CUT_3 || id == LVL_TR2_UNWATER || - id == LVL_TR2_KEEL || id == LVL_TR2_LIVING || id == LVL_TR2_DECK || id == LVL_TR2_CATACOMB || id == LVL_TR2_ICECAVE || - id == LVL_TR2_CUT_4 || id == LVL_TR2_XIAN || id == LVL_TR2_HOUSE) { - char buf[64]; - strcpy(buf, LEVEL_INFO[id].name); - String::toLower(buf); - sprintf(dst, "DATA/%s.TR2", buf); - } else if (id == LVL_TR2_TITLE) { - sprintf(dst, "DATA/%s.tr2", LEVEL_INFO[id].name); - } else if (id == LVL_TR2_EMPRTOMB) { - strcpy(dst, "DATA/Emprtomb.tr2"); - } else { - sprintf(dst, "DATA/%s.TR2", LEVEL_INFO[id].name); - } + case VER_TR2_PC : { + sprintf(dst, "DATA/%s.TR2", LEVEL_INFO[id].name); if (Stream::existsContent(dst)) break; strcpy(dst, LEVEL_INFO[id].name); - String::toLower(dst); + StrUtils::toLower(dst); strcat(dst, ".TR2"); break; } case VER_TR2_PSX : sprintf(dst, "DATA/%s.PSX", LEVEL_INFO[id].name); break; case VER_TR3_PC : sprintf(dst, isCutsceneLevel(id) ? "cuts/%s.TR2" : "data/%s.TR2", LEVEL_INFO[id].name); break; case VER_TR3_PSX : sprintf(dst, isCutsceneLevel(id) ? "CUTS/%s.PSX" : "DATA/%s.PSX", LEVEL_INFO[id].name); break; + case VER_TR4_PC : sprintf(dst, "DATA/%s.tr4", LEVEL_INFO[id].name); break; default : ASSERT(false); } } else { @@ -831,12 +1107,13 @@ namespace TR { #else switch (version) { case VER_TR1_PC : strcat(dst, ".PHD"); break; - case VER_TR2_PC : + case VER_TR2_PC : case VER_TR3_PC : strcat(dst, ".TR2"); break; case VER_TR1_PSX : - case VER_TR2_PSX : + case VER_TR2_PSX : case VER_TR3_PSX : strcat(dst, ".PSX"); break; - case VER_UNKNOWN : + case VER_TR1_SAT : strcat(dst, ".SAT"); break; + case VER_UNKNOWN : if (Stream::existsContent("level/1/TITLE.PSX")) { strcpy(dst, "level/1/TITLE.PSX"); return; @@ -845,6 +1122,10 @@ namespace TR { strcpy(dst, "level/1/TITLE.PHD"); return; } + if (Stream::existsContent("level/1/TITLE.SAT")) { + strcpy(dst, "level/1/TITLE.SAT"); + return; + } if (Stream::existsContent("level/2/TITLE.TR2")) { strcpy(dst, "level/2/TITLE.TR2"); return; @@ -892,8 +1173,8 @@ namespace TR { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 28, 4, 5, 6 }; - static const uint8 TR2_TRACK_MAPPING[] = { - 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 19, 20, + static const uint8 TR2_TRACK_MAPPING[] = { + 2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61 }; @@ -913,11 +1194,17 @@ namespace TR { bool checkTrack(const char *pre, char *name) { static const char *fmt[] = { ".ogg", ".mp3", ".wav" }; - static const char *lng[] = { "", "_EN", "_DE", "_FR", "_IT", "_JA", "_RU" }; + const char *lng[] = { "", "", LANG_PREFIXES }; - char buf[32]; + int start = 1; + if (Core::settings.audio.language != 0) { + start = 0; + lng[start] = lng[Core::settings.audio.language + 2]; + } + + char buf[64]; for (int f = 0; f < COUNT(fmt); f++) - for (int l = 0; l < COUNT(lng); l++) { + for (int l = start; l < COUNT(lng); l++) { strcpy(buf, pre); strcat(buf, name); strcat(buf, lng[l]); @@ -931,9 +1218,59 @@ namespace TR { return false; } - void getGameTrack(Version version, int track, Stream::Callback callback, void *userData) { + StringID getVideoSubs(LevelID id) { + switch (id) { + // TR1 + case LVL_TR1_TITLE : return isGameEnded ? STR_EMPTY : STR_TR1_SUB_CAFE; + case LVL_TR1_4 : return STR_TR1_SUB_LIFT; + case LVL_TR1_10A : return STR_TR1_SUB_CANYON; + case LVL_TR1_CUT_4 : return STR_TR1_SUB_PRISON; + default : return STR_EMPTY; + } + } + bool getVideoTrack(LevelID id, Stream::Callback callback, void *userData) { char title[32]; + + const char *str = NULL; + switch (id) { + // TR1 + case LVL_TR1_TITLE : str = isGameEnded ? NULL : "CAFE"; break; + case LVL_TR1_4 : str = "LIFT"; break; + case LVL_TR1_10A : str = "CANYON"; break; + case LVL_TR1_CUT_4 : str = "PRISON"; break; + // TR2 TODO + // TR3 TODO + default : return false; + } + + sprintf(title, "track_%s", str); + if (!checkTrack("", title) && !checkTrack("audio/1/", title) && !checkTrack("audio/", title)) { + return false; + } + + new Stream(title, callback, userData); + return true; + } + + StringID getSubs(Version version, int track) { + if ((version & VER_TR1) && (track >= 22 && track <= 56 && track != 24)) { + return StringID(STR_TR1_SUB_22 + (track - 22)); + } + // TR2, TR3 TODO + return STR_EMPTY; + } + + bool checkWebDub(Version version, int track) { + if (getSubs(version, track) != STR_EMPTY) { + int lang = Core::settings.audio.language + STR_LANG_EN; + return lang == STR_LANG_EN || lang == STR_LANG_DE || lang == STR_LANG_FR || lang == STR_LANG_RU || lang == STR_LANG_JA; + } + return false; + } + + void getGameTrack(Version version, int track, Stream::Callback callback, void *userData) { + char title[64]; if (useEasyStart) { switch (version) { case VER_TR1_SAT : @@ -966,14 +1303,29 @@ namespace TR { case VER_TR3_PSX : callback(Sound::openCDAudioWAD("audio/cdaudio.wad", track), userData); return; + case VER_TR4_PC : + strcpy(title, TRACK_LIST_TR4[track]); + if (!checkTrack("audio/", title)) { + callback(NULL, userData); + } + break; default : return; } } else { switch (version) { case VER_TR1_SAT : case VER_TR1_PC : - case VER_TR1_PSX : - sprintf(title, "audio/1/track_%02d.ogg", track); + case VER_TR1_PSX : { + if (TR::checkWebDub(version, track)) { + const char *lng[] = { LANG_PREFIXES }; + sprintf(title, "audio/1/track_%02d%s.ogg", track, lng[Core::settings.audio.language]); + } else { + if (TR::getSubs(version, track) != STR_EMPTY) { + sprintf(title, "audio/1/track_%02d_EN.ogg", track); + } else { + sprintf(title, "audio/1/track_%02d.ogg", track); + } + } #ifndef _OS_WEB if (Stream::existsContent(title)) break; @@ -981,6 +1333,7 @@ namespace TR { sprintf(title, "audio/1/%03d.ogg", track); #endif break; + } case VER_TR2_PC : case VER_TR2_PSX : track = remapTrack(version, track); @@ -1011,10 +1364,12 @@ namespace TR { CHECK_FILE("DELDATA/AMERTIT.RAW"); // PSX CHECK_FILE("DELDATA/JAPTIT.RAW"); // PSX JAP CHECK_FILE("BINDATA/USATIT.BIN"); // SEGA + CHECK_FILE("BINDATA/TITLE1.BIN"); // SEGA return "level/1/AMERTIT.PNG"; // WEB case LVL_TR1_GYM : CHECK_FILE("DELDATA/GYMLOAD.RAW"); CHECK_FILE("BINDATA/GYM224.BIN"); + CHECK_FILE("BINDATA/GYM.BIN"); return "level/1/GYMLOAD.PNG"; case LVL_TR1_1 : case LVL_TR1_2 : @@ -1022,6 +1377,7 @@ namespace TR { case LVL_TR1_3B : CHECK_FILE("DELDATA/AZTECLOA.RAW"); CHECK_FILE("BINDATA/AZTEC224.BIN"); + CHECK_FILE("BINDATA/AZTEC.BIN"); return "level/1/AZTECLOA.PNG"; case LVL_TR1_4 : case LVL_TR1_5 : @@ -1030,18 +1386,21 @@ namespace TR { case LVL_TR1_7B : CHECK_FILE("DELDATA/GREEKLOA.RAW"); CHECK_FILE("BINDATA/GREEK224.BIN"); + CHECK_FILE("BINDATA/GREEK.BIN"); return "level/1/GREEKLOA.PNG"; case LVL_TR1_8A : case LVL_TR1_8B : case LVL_TR1_8C : CHECK_FILE("DELDATA/EGYPTLOA.RAW"); CHECK_FILE("BINDATA/EGYPT224.BIN"); + CHECK_FILE("BINDATA/EGYPT.BIN"); return "level/1/EGYPTLOA.PNG"; case LVL_TR1_10A : case LVL_TR1_10B : case LVL_TR1_10C : CHECK_FILE("DELDATA/ATLANLOA.RAW"); CHECK_FILE("BINDATA/ATLAN224.BIN"); + CHECK_FILE("BINDATA/ATLAN.BIN"); return "level/1/ATLANLOA.PNG"; // TR2 case LVL_TR2_TITLE : @@ -1053,28 +1412,28 @@ namespace TR { return "level/2/TITLEUS.PNG"; // WEB case LVL_TR2_ASSAULT : case LVL_TR2_HOUSE : - CHECK_FILE("PIX/MANSION.RAW"); + CHECK_FILE("PIX/MANSION.RAW"); return "level/2/MANSION.PNG"; case LVL_TR2_WALL : case LVL_TR2_EMPRTOMB : case LVL_TR2_FLOATING : case LVL_TR2_XIAN : - CHECK_FILE("PIX/CHINA.RAW"); + CHECK_FILE("PIX/CHINA.RAW"); return "level/2/CHINA.PNG"; case LVL_TR2_BOAT : case LVL_TR2_VENICE : case LVL_TR2_OPERA : - CHECK_FILE("PIX/VENICE.RAW"); + CHECK_FILE("PIX/VENICE.RAW"); return "level/2/VENICE.PNG"; case LVL_TR2_RIG : case LVL_TR2_PLATFORM : - CHECK_FILE("PIX/RIG.RAW"); + CHECK_FILE("PIX/RIG.RAW"); return "level/2/RIG.PNG"; case LVL_TR2_UNWATER : case LVL_TR2_KEEL : case LVL_TR2_LIVING : case LVL_TR2_DECK : - CHECK_FILE("PIX/TITAN.RAW"); + CHECK_FILE("PIX/TITAN.RAW"); return "level/2/TITAN.PNG"; case LVL_TR2_SKIDOO : case LVL_TR2_MONASTRY : @@ -1089,43 +1448,43 @@ namespace TR { CHECK_FILE("PIXJAP/TITLEJAP.RAW"); // PSX return "level/3/TITLEUK.PNG"; // WEB case LVL_TR3_HOUSE : - CHECK_FILE("pix/HOUSE.BMP"); - CHECK_FILE("PIX/HOUSE.RAW"); + CHECK_FILE("pix/HOUSE.BMP"); + CHECK_FILE("PIX/HOUSE.RAW"); return "level/3/HOUSE.PNG"; case LVL_TR3_JUNGLE : case LVL_TR3_TEMPLE : case LVL_TR3_QUADCHAS : case LVL_TR3_TONYBOSS : - CHECK_FILE("pix/INDIA.BMP"); - CHECK_FILE("PIX/INDIA.RAW"); + CHECK_FILE("pix/INDIA.BMP"); + CHECK_FILE("PIX/INDIA.RAW"); return "level/3/INDIA.PNG"; case LVL_TR3_SHORE : case LVL_TR3_CRASH : case LVL_TR3_RAPIDS : case LVL_TR3_TRIBOSS : - CHECK_FILE("pix/SOUTHPAC.BMP"); - CHECK_FILE("PIX/SOUTHPAC.RAW"); + CHECK_FILE("pix/SOUTHPAC.BMP"); + CHECK_FILE("PIX/SOUTHPAC.RAW"); return "level/3/SOUTHPAC.PNG"; case LVL_TR3_ROOFS : case LVL_TR3_SEWER : case LVL_TR3_TOWER : case LVL_TR3_OFFICE : case LVL_TR3_STPAUL : - CHECK_FILE("pix/LONDON.BMP"); - CHECK_FILE("PIX/LONDON.RAW"); + CHECK_FILE("pix/LONDON.BMP"); + CHECK_FILE("PIX/LONDON.RAW"); return "level/3/LONDON.PNG"; case LVL_TR3_NEVADA : case LVL_TR3_COMPOUND : case LVL_TR3_AREA51 : - CHECK_FILE("pix/NEVADA.BMP"); - CHECK_FILE("PIX/NEVADA.RAW"); + CHECK_FILE("pix/NEVADA.BMP"); + CHECK_FILE("PIX/NEVADA.RAW"); return "level/3/NEVADA.PNG"; case LVL_TR3_ANTARC : case LVL_TR3_MINES : case LVL_TR3_CITY : case LVL_TR3_CHAMBER : - CHECK_FILE("pix/ANTARC.BMP"); - CHECK_FILE("PIX/ANTARC.RAW"); + CHECK_FILE("pix/ANTARC.BMP"); + CHECK_FILE("PIX/ANTARC.RAW"); return "level/3/ANTARC.PNG"; default : return NULL; @@ -1162,12 +1521,21 @@ namespace TR { switch (id) { // TR1 case LVL_TR1_TITLE : - CHECK_FILE("FMV/CAFE.FMV"); - CHECK_FILE("FMV/CAFE.RPL"); - CHECK_FILE("FMV/CAFE.CPK"); - CHECK_FILE("video/1/CAFE.FMV"); - CHECK_FILE("video/1/CAFE.RPL"); - CHECK_FILE("video/1/CAFE.CPK"); + if (isGameEnded) { + CHECK_FILE("FMV/END.FMV"); + CHECK_FILE("FMV/END.RPL"); + CHECK_FILE("FMV/END.CPK"); + CHECK_FILE("video/1/END.FMV"); + CHECK_FILE("video/1/END.RPL"); + CHECK_FILE("video/1/END.CPK"); + } else { + CHECK_FILE("FMV/CAFE.FMV"); + CHECK_FILE("FMV/CAFE.RPL"); + CHECK_FILE("FMV/CAFE.CPK"); + CHECK_FILE("video/1/CAFE.FMV"); + CHECK_FILE("video/1/CAFE.RPL"); + CHECK_FILE("video/1/CAFE.CPK"); + } break; case LVL_TR1_GYM : CHECK_FILE("FMV/MANSION.FMV"); @@ -1278,10 +1646,17 @@ namespace TR { break; // TR3 case LVL_TR3_TITLE : - CHECK_FILE("FMV/INTRO.FMV"); - CHECK_FILE("fmv/Intr_Eng.rpl"); - CHECK_FILE("video/3/INTRO.FMV"); - CHECK_FILE("video/3/Intr_Eng.rpl"); + if (isGameEnded) { + CHECK_FILE("FMV/END.FMV"); + CHECK_FILE("fmv/Endgame.rpl"); + CHECK_FILE("video/3/END.FMV"); + CHECK_FILE("video/3/Endgame.rpl"); + } else { + CHECK_FILE("FMV/INTRO.FMV"); + CHECK_FILE("fmv/Intr_Eng.rpl"); + CHECK_FILE("video/3/INTRO.FMV"); + CHECK_FILE("video/3/Intr_Eng.rpl"); + } break; case LVL_TR3_SHORE : CHECK_FILE("FMV/LAGOON.FMV"); @@ -1307,16 +1682,18 @@ namespace TR { } #define FOG_DIST (1.0f / (18 * 1024)) - #define FOG_BLACK vec4(0.0f, 0.0f, 0.0f, FOG_DIST) - #define FOG_SANDY vec4(0.2f, 0.1f, 0.0f, FOG_DIST) - #define FOG_GREEN vec4(0.0f, 0.1f, 0.0f, FOG_DIST) - #define FOG_RED vec4(0.2f, 0.0f, 0.0f, FOG_DIST) + #define FOG_NONE vec4(0.0f, 0.0f, 0.0f, 0.0f) + #define FOG_BLACK vec4(0.0f, 0.0f, 0.0f, FOG_DIST) + #define FOG_SANDY vec4(0.2f, 0.1f, 0.0f, FOG_DIST) + #define FOG_GREEN vec4(0.0f, 0.1f, 0.0f, FOG_DIST) + #define FOG_RED vec4(0.2f, 0.0f, 0.0f, FOG_DIST) + #define FOG_MIST vec4(0.25f, 0.2f, 0.15f, FOG_DIST) vec4 getFogParams(LevelID id) { switch (id) { case LVL_TR1_1 : - case LVL_TR1_2 : - case LVL_TR1_3A : + case LVL_TR1_2 : return FOG_BLACK; + case LVL_TR1_3A : return FOG_MIST; case LVL_TR1_3B : case LVL_TR1_CUT_1 : return FOG_BLACK; case LVL_TR1_4 : @@ -1340,8 +1717,55 @@ namespace TR { default : return FOG_BLACK; } } + + struct SkyParams { + vec4 skyDownColor; + vec4 skyUpColor; + vec4 sunDirSize; + vec4 sunColorGlare; + vec4 cloudDownColor; + vec4 cloudUpColor; + vec3 wind; + }; + + #define CLOUD_UP vec3() + #define CLOUD_DOWN vec3() + + bool getSkyParams(LevelID id, SkyParams ¶ms) { + switch (id) { + case LVL_TR1_3A : + params.skyDownColor = vec4(0.8f, 0.8f, 0.7f, 1.0f); + params.skyUpColor = vec4(0.3f, 0.4f, 0.5f, 1.0f); + params.sunDirSize = vec4(vec3(1.0f, 0.75f, -1.0f).normal(), 0.0025f); + params.sunColorGlare = vec4(0.8f, 0.4f, 0.1f, 4.0f); + params.cloudDownColor = vec4(0.35f, 0.4f, 0.45f, 1.0f); + params.cloudUpColor = vec4(1.1f, 1.045f, 0.88f, 1.0f); + params.wind = vec3(0.01f, -0.005f, 0.005f); + break; + case LVL_TR1_5 : + params.skyDownColor = vec4(0.15f, 0.05f, 0.0f, 1.0f); + params.skyUpColor = vec4(0.3f, 0.2f, 0.1f, 1.0f); + params.sunDirSize = vec4(vec3(-1.0f, 0.8f, -1.0f).normal(), 0.0015f); + params.sunColorGlare = vec4(0.7f, 0.7f, 0.6f, 256.0f); + params.cloudDownColor = vec4(0.2f, 0.1f, 0.0f, 1.0f); + params.cloudUpColor = vec4(0.5f, 0.5f, 0.4f, 1.0f); + params.wind = vec3(0.01f, -0.005f, 0.005f); + break; + case LVL_TR3_HOUSE : // test + params.skyDownColor = vec4(0.8f, 0.8f, 0.7f, 1.0f); + params.skyUpColor = vec4(0.3f, 0.4f, 0.5f, 1.0f); + params.sunDirSize = vec4(vec3(1.0f, 0.75f, -1.0f).normal(), 0.0025f); + params.sunColorGlare = vec4(0.8f, 0.4f, 0.1f, 4.0f); + params.cloudDownColor = vec4(0.35f, 0.4f, 0.45f, 1.0f); + params.cloudUpColor = vec4(1.1f, 1.045f, 0.88f, 1.0f); + params.wind = vec3(0.01f, -0.005f, 0.005f); + break; + default : return false; + } + return true; + } } #undef CHECK_FILE -#endif \ No newline at end of file +#endif diff --git a/src/gapi/c3d.h b/src/gapi/c3d.h new file mode 100644 index 00000000..c0daea5d --- /dev/null +++ b/src/gapi/c3d.h @@ -0,0 +1,1088 @@ +#ifndef H_GAPI_C3D +#define H_GAPI_C3D + +#include +#include "core.h" + +#define PROFILE_MARKER(title) +#define PROFILE_LABEL(id, name, label) +#define PROFILE_TIMING(time) + +#define DISPLAY_WIDTH 240 +#define DISPLAY_HEIGHT 400 +#define DISPLAY_BUFFER_COUNT 2 + +#define DISPLAY_TRANSFER_FLAGS (\ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO) \ + | GX_TRANSFER_FLIP_VERT(0) \ + | GX_TRANSFER_OUT_TILED(0) \ + | GX_TRANSFER_RAW_COPY(0) \ + | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) \ + | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) ) + +namespace GAPI { + + using namespace Core; + + struct Vertex { + short4 coord; + ubyte4 normal; + short4 texCoord; + ubyte4 color; + ubyte4 light; + }; + + int VRAM_TOTAL = 0; + + void mmLogVRAM() { + LOG("VRAM: %d / %d kb\n", (VRAM_TOTAL - vramSpaceFree()) / 1024, VRAM_TOTAL / 1024); + } + + bool mmIsVRAM(void *addr) { + uint32 vaddr = (uint32)addr; + return vaddr >= 0x1F000000 && vaddr < 0x1F600000; + } + + void* mmAlloc(size_t size) { + void *addr = vramAlloc(size); + if (!addr) { + LOG("! OUT OF VRAM %d < %d\n", vramSpaceFree() / 1024, size / 1024); + addr = linearAlloc(size); + ASSERT(addr); + } else { + mmLogVRAM(); + } + return addr; + } + + void mmFree(void *addr) { + if (!addr) return; + if (mmIsVRAM(addr)) { + vramFree(addr); + mmLogVRAM(); + } else { + linearFree(addr); + } + } + + void mmCopy(void *dst, void *src, size_t size) { + if (mmIsVRAM(dst)) { + GSPGPU_FlushDataCache(src, size); + GX_RequestDma((u32*)src, (u32*)dst, size); + gspWaitForDMA(); + } else { + memcpy(dst, src, size); + GSPGPU_FlushDataCache(dst, size); + } + } + + +// Shader + extern "C" { + #include "compose_sprite_shbin.h" + #include "compose_flash_shbin.h" + #include "compose_room_shbin.h" + #include "compose_entity_shbin.h" + #include "compose_mirror_shbin.h" + #include "compose_sprite_u_shbin.h" + #include "compose_room_u_shbin.h" + #include "compose_entity_u_shbin.h" + #include "ambient_sprite_shbin.h" + #include "ambient_room_shbin.h" + #include "shadow_entity_shbin.h" + #include "filter_upscale_shbin.h" + #include "gui_shbin.h" + #include "dummy_shbin.h" + } + + #define SHADERS_LIST(E) \ + E( compose_sprite ) \ + E( compose_flash ) \ + E( compose_room ) \ + E( compose_entity ) \ + E( compose_mirror ) \ + E( compose_sprite_u ) \ + E( compose_room_u ) \ + E( compose_entity_u ) \ + E( ambient_sprite ) \ + E( ambient_room ) \ + E( shadow_entity ) \ + E( filter_upscale ) \ + E( gui ) \ + E( dummy ) + + #define SHADER_DECL(v) DVLB_s* v; + #define SHADER_INIT(v) v = DVLB_ParseFile((u32*)v##_shbin, v##_shbin_size); + #define SHADER_FREE(v) DVLB_Free(v); + + static const int bindings[uMAX] = { + 0, // uParam + 1, // uTexParam + 2, // uViewProj + 6, // uBasis + 70, // uLightProj + 74, // uMaterial + 75, // uAmbient + 81, // uFogParams + 82, // uViewPos + 83, // uLightPos + 87, // uLightColor + 91, // uRoomSize + 92, // uPosScale + 0, // uContacts (unused) + }; + + SHADERS_LIST(SHADER_DECL); + + struct FogLUT { + vec4 params; + uint32 color; + C3D_FogLut table; + } fogLUT[3]; + + vec4 fogParams; + + struct Shader { + shaderProgram_s program; + C3D_TexEnv env[4]; + int envCount; + + int32 uID[uMAX]; + + vec4 cbMem[98 + MAX_CONTACTS]; + int cbCount[uMAX]; + + bool rebind; + + void init(Pass pass, int type, int *def, int defCount) { + shaderProgramInit(&program); + + DVLB_s* src = NULL; + + bool underwater = false; + bool grayscale = false; + + for (int i = 0; i < defCount; i++) { + if (def[i] == SD_UNDERWATER) { + underwater = true; + } + if (def[i] == SD_FILTER_GRAYSCALE) { + grayscale = true; + } + } + + switch (pass) { + case Core::passCompose : + if (underwater) { + switch (type) { + case 0 : src = compose_sprite_u; break; + case 1 : src = compose_flash; break; + case 2 : src = compose_room_u; break; + case 3 : src = compose_entity_u; break; + case 4 : src = compose_mirror; break; + default : src = dummy; + } + } else { + switch (type) { + case 0 : src = compose_sprite; break; + case 1 : src = compose_flash; break; + case 2 : src = compose_room; break; + case 3 : src = compose_entity; break; + case 4 : src = compose_mirror; break; + default : src = dummy; + } + } + break; + case Core::passAmbient : + switch (type) { + case 0 : src = ambient_sprite; break; + case 1 : src = ambient_room; break; + case 2 : src = ambient_room; break; + default : src = dummy; + } + break; + case Core::passShadow : src = shadow_entity; break; + case Core::passFilter : src = filter_upscale; break; + case Core::passGUI : src = gui; break; + default : src = dummy; + } + + shaderProgramSetVsh(&program, &src->DVLE[0]); + + for (int ut = 0; ut < uMAX; ut++) { + uID[ut] = shaderInstanceGetUniformLocation(program.vertexShader, UniformName[ut]); + } + + rebind = true; + envCount = 0; + + for (int i = 0; i < COUNT(env); i++) { + C3D_TexEnvInit(env + i); + } + + C3D_TexEnv *e = env; + + { // texture * vertex color + C3D_TexEnvSrc(e, C3D_Both, GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(e, C3D_Both, GPU_MODULATE); + if (pass == Core::passCompose || pass == Core::passAmbient) { + C3D_TexEnvScale(e, C3D_Both, GPU_TEVSCALE_4); + } + e++; + } + + if (pass == Core::passAmbient && underwater) { // multiply by underwater color only for ambient pass + C3D_TexEnvSrc(e, C3D_Both, GPU_PREVIOUS, GPU_CONSTANT, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(e, C3D_Both, GPU_MODULATE); + C3D_TexEnvColor(e, 0xFFE5E599); + e++; + } + + if (grayscale) { // grayscale * blue tint + C3D_TexEnvSrc(e, C3D_RGB, GPU_PREVIOUS, GPU_CONSTANT, GPU_CONSTANT); + C3D_TexEnvFunc(e, C3D_RGB, GPU_MULTIPLY_ADD); + C3D_TexEnvColor(e, 0x00808080); + e++; + + C3D_TexEnvSrc(e, C3D_RGB, GPU_PREVIOUS, GPU_CONSTANT, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(e, C3D_RGB, GPU_DOT3_RGB); + C3D_TexEnvColor(e, 0x008ECAA6); + e++; + + C3D_TexEnvSrc(e, C3D_RGB, GPU_PREVIOUS, GPU_CONSTANT, GPU_PRIMARY_COLOR); + C3D_TexEnvFunc(e, C3D_RGB, GPU_MODULATE); + C3D_TexEnvColor(e, 0x00FFC0C0); + e++; + } + + envCount = e - env; + } + + void deinit() { + shaderProgramFree(&program); + } + + void bind() { + if (active.shader != this) { + active.shader = this; + memset(cbCount, 0, sizeof(cbCount)); + rebind = true; + } + } + + void validate() { + if (rebind) { + C3D_BindProgram(&program); + for (int i = 0; i < COUNT(env); i++) { + C3D_SetTexEnv(i, env + i); + } + rebind = false; + } + + for (int uType = 0; uType < uMAX; uType++) { + if (!cbCount[uType]) continue; + + vec4 *src = cbMem + bindings[uType]; + vec4 *dst = (vec4*)C3D_FVUnifWritePtr(GPU_VERTEX_SHADER, uID[uType], cbCount[uType]); + + for (int i = 0; i < cbCount[uType]; i++) { + dst->x = src->w; + dst->y = src->z; + dst->z = src->y; + dst->w = src->x; + dst++; + src++; + } + + cbCount[uType] = 0; + Core::stats.cb++; + } + } + + void setParam(UniformType uType, const vec4 &value, int count = 1) { + if (uID[uType] == -1) return; + cbCount[uType] = max(cbCount[uType], count); + memcpy(cbMem + bindings[uType], &value, count * sizeof(value)); + } + + void setParam(UniformType uType, const mat4 &value, int count = 1) { + if (uID[uType] == -1) return; + cbCount[uType] = max(cbCount[uType], count * 4); + + ASSERT(count == 1); + memcpy(cbMem + bindings[uType], &value, count * sizeof(value)); + } + }; + +// Texture + static const struct FormatDesc { + uint8 bpp; + GPU_TEXCOLOR format; + } formats[FMT_MAX] = { + { 8 , GPU_L8 }, // LUMINANCE + { 32 , GPU_RGBA8 }, // RGBA + { 16 , GPU_RGB565 }, // RGB16 + { 16 , GPU_RGBA5551 }, // RGBA16 + { 32 , GPU_RGBA8 }, // RG_FLOAT // not supported + { 32 , GPU_RGBA8 }, // RG_HALF // not supported + { 16 , GPU_RGBA8 }, // DEPTH + { 16 , GPU_RGBA8 }, // SHADOW + }; + + #define TILE_SIZE 8 + + static const uint8 tileSwizzle[TILE_SIZE * TILE_SIZE] = { + 0, 1, 8, 9, 2, 3, 10, 11, + 16, 17, 24, 25, 18, 19, 26, 27, + 4, 5, 12, 13, 6, 7, 14, 15, + 20, 21, 28, 29, 22, 23, 30, 31, + 32, 33, 40, 41, 34, 35, 42, 43, + 48, 49, 56, 57, 50, 51, 58, 59, + 36, 37, 44, 45, 38, 39, 46, 47, + 52, 53, 60, 61, 54, 55, 62, 63 + }; + + struct Texture { + int width, height, origWidth, origHeight; + TexFormat fmt; + uint32 opt; + int mipCount; + + C3D_Tex tex; + C3D_TexCube texCube; + C3D_RenderTarget *target; + + void convertImage32(uint32 *dst, uint32 *src, int dstWidth, int dstHeight, int srcWidth, int srcHeight) { + // 8x8 tiles swizzling + // vertical flip + // swap RGBA channels to ABGR + dst += dstWidth * (dstHeight - srcHeight); + for (int y = 0; y < srcHeight; y += TILE_SIZE) { + for (int x = 0; x < srcWidth; x += TILE_SIZE) { + for (int i = 0; i < COUNT(tileSwizzle); i++) { + int sx = tileSwizzle[i] % TILE_SIZE; + int sy = (tileSwizzle[i] - sx) / TILE_SIZE; + int index = (srcHeight - (y + sy) - 1) * srcWidth + (x + sx); + + *dst++ = swap32(src[index]); + } + } + dst += (dstWidth - srcWidth) * TILE_SIZE; + } + } + + void convertImage16(uint16 *dst, uint16 *src, int dstWidth, int dstHeight, int srcWidth, int srcHeight) { + // 8x8 tiles swizzling + // vertical flip + // swap RGBA channels to ABGR + dst += dstWidth * (dstHeight - srcHeight); + for (int y = 0; y < srcHeight; y += TILE_SIZE) { + for (int x = 0; x < srcWidth; x += TILE_SIZE) { + + for (int i = 0; i < COUNT(tileSwizzle); i++) { + int sx = tileSwizzle[i] % TILE_SIZE; + int sy = (tileSwizzle[i] - sx) / TILE_SIZE; + int index = (srcHeight - (y + sy) - 1) * srcWidth + (x + sx); + + *dst++ = src[index]; + } + } + dst += (dstWidth - srcWidth) * TILE_SIZE; + } + } + + void downsampleImage32(uint32 *dst, uint32 *src, int width, int height) { + for (int y = 0; y < height; y += 2) { + for (int x = 0; x < width; x += 2) { + Color32 a(src[0]); + Color32 b(src[1]); + Color32 c(src[width]); + Color32 d(src[width + 1]); + Color32 &p = *(Color32*)dst; + p.r = (uint16(a.r) + uint16(b.r) + uint16(c.r) + uint16(d.r)) >> 2; + p.g = (uint16(a.g) + uint16(b.g) + uint16(c.g) + uint16(d.g)) >> 2; + p.b = (uint16(a.b) + uint16(b.b) + uint16(c.b) + uint16(d.b)) >> 2; + p.a = (uint16(a.a) + uint16(b.a) + uint16(c.a) + uint16(d.a)) >> 2; + dst++; + src += 2; + } + src += width; + } + } + + void downsampleImage16(uint16 *dst, uint16 *src, int width, int height) { + for (int y = 0; y < height; y += 2) { + for (int x = 0; x < width; x += 2) { + AtlasColor a(src[0]); + AtlasColor b(src[1]); + AtlasColor c(src[width]); + AtlasColor d(src[width + 1]); + AtlasColor &p = *(AtlasColor*)dst; + p.r = (uint16(a.r) + uint16(b.r) + uint16(c.r) + uint16(d.r)) >> 2; + p.g = (uint16(a.g) + uint16(b.g) + uint16(c.g) + uint16(d.g)) >> 2; + p.b = (uint16(a.b) + uint16(b.b) + uint16(c.b) + uint16(d.b)) >> 2; + p.a = (uint16(a.a) + uint16(b.a) + uint16(c.a) + uint16(d.a)) >> 2; + dst++; + src += 2; + } + src += width; + } + } + + void convertImage(void *dst, void *src, int dstWidth, int dstHeight, int srcWidth, int srcHeight) { + FormatDesc desc = formats[fmt]; + + if (fmt == FMT_RGBA) { + convertImage32((uint32*)dst, (uint32*)src, dstWidth, dstHeight, srcWidth, srcHeight); + } else { + convertImage16((uint16*)dst, (uint16*)src, dstWidth, dstHeight, srcWidth, srcHeight); + } + } + + void downsampleImage(void *dst, void *src, int width, int height) { + FormatDesc desc = formats[fmt]; + + if (fmt == FMT_RGBA) { + downsampleImage32((uint32*)dst, (uint32*)src, width, height); + } else { + downsampleImage16((uint16*)dst, (uint16*)src, width, height); + } + } + + Texture(int width, int height, int depth, uint32 opt) : width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) { + opt |= OPT_NEAREST; + target = (C3D_RenderTarget*)malloc(sizeof(C3D_RenderTarget) * 6); + memset(target, 0, sizeof(C3D_RenderTarget) * 6); + } + + void init(void *data) { + ASSERT((opt & OPT_PROXY) == 0); + + FormatDesc desc = formats[fmt]; + + if (width < 8 || height < 8) { + LOG("\ntexture too small %dx%d [%d %d]!\n\n", width, height, fmt, opt); + width = 8; + height = 8; + data = NULL; + } + + void* tmpData = NULL; + + if (width > 1024 || height > 1024) { + LOG("\ntexture too large %dx%d [%d %d]!\n", width, height, fmt, opt); + + origWidth >>= 1; + origHeight >>= 1; + width >>= 1; + height >>= 1; + + LOG("downsample to %dx%d\n\n", width, height); + + tmpData = linearAlloc(width * height * desc.bpp / 8); + downsampleImage(tmpData, data, width << 1, height << 1); + + data = tmpData; + } + + bool isCube = (opt & OPT_CUBEMAP) != 0; + bool isShadow = fmt == FMT_SHADOW; + + C3D_TexInitParams params; + memset(¶ms, 0, sizeof(params)); + params.width = width; + params.height = height; + params.maxLevel = ((opt & OPT_MIPMAPS) != 0) ? min(3, C3D_TexCalcMaxLevel(width, height)) : 0; + params.format = desc.format; + params.onVram = (opt & OPT_VRAM_3DS) != 0; + + if (isCube && isShadow) + params.type = GPU_TEX_SHADOW_CUBE; + else if (isCube) + params.type = GPU_TEX_CUBE_MAP; + else if (isShadow) + params.type = GPU_TEX_SHADOW_2D; + else + params.type = GPU_TEX_2D; + + bool ret = C3D_TexInitWithParams(&tex, &texCube, params); + if (!ret && params.onVram) { + params.onVram = false; + ret = C3D_TexInitWithParams(&tex, &texCube, params); + } + + if (width != origWidth || height != origHeight) { + uint32 texSize = C3D_TexCalcTotalSize(tex.size, tex.maxLevel); + memset(tex.data, 0, texSize); + } + + ASSERT(ret); + + mmLogVRAM(); + + if (data && !isCube) { + update(data); + } + + if (tmpData) { + linearFree(tmpData); + } + + GPU_TEXTURE_FILTER_PARAM filter = (opt & OPT_NEAREST) ? GPU_NEAREST : GPU_LINEAR; + C3D_TexSetFilter(&tex, filter, filter); + C3D_TexSetFilterMipmap(&tex, filter); + } + + void deinit() { + C3D_TexDelete(&tex); + mmLogVRAM(); + + free(target); + } + + void generateMipMap() { + /* + if (opt & OPT_MIPMAPS) { + for (int i = 0; i < 6; i++) { + C3D_TexGenerateMipmap(&tex, GPU_TEXFACE(i)); + if (!(opt & OPT_CUBEMAP)) { + break; + } + } + } + */ + } + + void update(void *data) { + if (!data) return; + + FormatDesc desc = formats[fmt]; + + bool isVRAM = mmIsVRAM(tex.data); + + uint32 texSize = C3D_TexCalcTotalSize(tex.size, tex.maxLevel); + void* texData = isVRAM ? linearAlloc(texSize) : tex.data; + void* mipData = tex.maxLevel ? linearAlloc(texSize >> 2) : NULL; + + uint8* ptr = (uint8*)mipData; + uint8* mip = (uint8*)data; + uint32 w = width; + uint32 h = height; + + for (int i = 1; i <= tex.maxLevel; i++) { + downsampleImage(ptr, mip, w, h); + + mip = ptr; + w >>= 1; + h >>= 1; + ptr += w * h * desc.bpp / 8; + } + + convertImage(texData, data, width, height, origWidth, origHeight); + + ptr = (uint8*)texData; + mip = (uint8*)mipData; + w = width; + h = height; + + for (int i = 1; i <= tex.maxLevel; i++) { + ptr += w * h * desc.bpp / 8; + w >>= 1; + h >>= 1; + + convertImage(ptr, mip, w, h, w, h); + + mip += w * h * desc.bpp / 8; + } + + GSPGPU_FlushDataCache(texData, texSize); + + if (isVRAM) { + C3D_SyncTextureCopy((u32*)texData, 0, (u32*)tex.data, 0, texSize, 8); + linearFree(texData); + } + + if (mipData) { + linearFree(mipData); + } + } + + void bind(int sampler) { + if (opt & OPT_PROXY) return; + + if (sampler > 3) { + return; + } + + if (active.textures[sampler] != this) { + active.textures[sampler] = this; + C3D_TexBind(sampler, &tex); + } + } + + void unbind(int sampler) { + active.textures[sampler] = NULL; + } + + void setFilterQuality(int value) { + GPU_TEXTURE_FILTER_PARAM filter = ((opt & OPT_NEAREST) == 0 && (value > Settings::LOW)) ? GPU_LINEAR : GPU_NEAREST; + + C3D_TexSetFilter(&tex, filter, filter); + C3D_TexSetFilterMipmap(&tex, filter); + } + }; + + #undef TILE_SIZE + +// Mesh + struct Mesh { + C3D_BufInfo *VAO; + + Index *iBuffer; + Vertex *vBuffer; + + int aCount; + bool dynamic; + + struct Chunk { + int frameIndex; + int iBase, iStart, iCount; + int vBase, vStart, vCount; + } chunks[DISPLAY_BUFFER_COUNT]; + + Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {} + + void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) { + ASSERT(Core::support.VAO && aCount); + + this->aCount = aCount; + + memset(chunks, 0, sizeof(chunks)); + + for (int i = 0; i < COUNT(chunks); i++) { + chunks[i].frameIndex = -1; + chunks[i].iBase = i * iCount; + chunks[i].vBase = i * vCount; + } + + if (dynamic) { + iCount *= COUNT(chunks); + vCount *= COUNT(chunks); + } + + VAO = new C3D_BufInfo[aCount]; + + iBuffer = (Index*) (dynamic ? linearAlloc(iCount * sizeof(Index)) : mmAlloc(iCount * sizeof(Index))); + vBuffer = (Vertex*) (dynamic ? linearAlloc(vCount * sizeof(Vertex)) : mmAlloc(vCount * sizeof(Vertex))); + + if (!dynamic) { + update(indices, iCount, vertices, vCount); + } + } + + void deinit() { + delete[] VAO; + mmFree(iBuffer); + mmFree(vBuffer); + } + + Chunk& getChunk() { + return dynamic ? chunks[Core::stats.frameIndex % COUNT(chunks)] : chunks[0]; + } + + void update(Index *indices, int iCount, ::Vertex *vertices, int vCount) { + Chunk &chunk = getChunk(); + if (chunk.frameIndex != Core::stats.frameIndex) { + chunk.frameIndex = Core::stats.frameIndex; + chunk.iStart = chunk.iCount = chunk.iBase; + chunk.vStart = chunk.vCount = chunk.vBase; + } + + if (indices && iCount) { + chunk.iStart = chunk.iCount; + chunk.iCount += iCount; + mmCopy(iBuffer + chunk.iStart, indices, iCount * sizeof(Index)); + } + + if (vertices && vCount) { + chunk.vStart = chunk.vCount; + chunk.vCount += vCount; + + Vertex *vert = (Vertex*)linearAlloc(sizeof(Vertex) * vCount); + + for (int i = 0; i < vCount; i++) { + ::Vertex &vIn = vertices[i]; + Vertex &vOut = vert[i]; + + vOut.coord = vIn.coord; + vOut.normal = ubyte4(127 + vIn.normal.x / 256, 127 + vIn.normal.y / 256, 127 + vIn.normal.z / 256, 0); + vOut.texCoord = vIn.texCoord; + vOut.color = vIn.color; + vOut.light = vIn.light; + } + + mmCopy(vBuffer + chunk.vStart, vert, vCount * sizeof(Vertex)); + + linearFree(vert); + } + } + + void initVAO(C3D_BufInfo *vao, Vertex *offset) { + BufInfo_Init(vao); + BufInfo_Add(vao, offset, sizeof(Vertex), 5, 0x43210); + } + + void initNextRange(MeshRange &range, int &aIndex) { + range.aIndex = aIndex++; + initVAO(VAO + range.aIndex, vBuffer + range.vStart); + } + + void bind(const MeshRange &range) { + ASSERT(range.aIndex > -1); + C3D_BufInfo *vao = VAO + range.aIndex; + + if (dynamic) { + initVAO(vao, vBuffer + getChunk().vStart + range.vStart); + } else { + if (Core::active.VAO == vao) { + return; + } + } + + C3D_SetBufInfo(vao); + Core::active.VAO = vao; + } + }; + + bool rotate90; + bool depthTest; + uint32 colorMask, depthMask; + uint32 clearColor; + + C3D_RenderTarget *curTarget; + C3D_RenderTarget *defTarget[2]; + C3D_AttrInfo vertexAttribs; + + // depth buffer memory aliasing + #define MAX_DEPTH_ALIAS_GROUPS 1 + + struct DepthBuffer { + void *data; + int size; + } depthBuffers[MAX_DEPTH_ALIAS_GROUPS]; + + void* getDepthBuffer(int width, int height, int group, GPU_DEPTHBUF format) { + ASSERT(group < MAX_DEPTH_ALIAS_GROUPS); + + DepthBuffer &db = depthBuffers[group]; + + int size = C3D_CalcDepthBufSize(width, height, format); + + if (!db.data) { + LOG("alloc depth alias group %d (size: %d %dx%d)\n", group, size / 1024, width, height); + + db.data = mmAlloc(size); + db.size = size; + return db.data; + } + + if (db.size >= size) { + return db.data; + } + + LOG("! can't fit depth %dx%d %d ([%d] = %d)\n", width, height, size / 1024, group, db.size / 1024); + + ASSERT(false); + return NULL; + } + + C3D_RenderTarget* checkRenderTarget(Texture *texture, int face, int group, GPU_DEPTHBUF depthFmt) { + if (!texture->target[face].frameBuf.colorBuf) { + C3D_FrameBuf &fb = texture->target[face].frameBuf; + fb.colorBuf = (texture->opt & OPT_CUBEMAP) ? texture->tex.cube->data[face] : texture->tex.data; + fb.depthBuf = getDepthBuffer(texture->width, texture->height, group, depthFmt); + fb.colorFmt = GPU_COLORBUF(formats[texture->fmt].format); + fb.depthFmt = depthFmt; + fb.colorMask = 0x0F; + fb.depthMask = 0x02; // no stencil + fb.width = texture->width; + fb.height = texture->height; + fb.block32 = false; + } + + return &texture->target[face]; + } + + void init() { + memset(depthBuffers, 0, sizeof(depthBuffers)); + + for (int i = 0; i < COUNT(fogLUT); i++) { + fogLUT[i].params = vec4(-2.0f); // initialize with some unique value + } + + gfxInitDefault(); + + vramFree(vramAlloc(0)); // vramInit() + VRAM_TOTAL = vramSpaceFree(); + + consoleInit(GFX_BOTTOM, NULL); + + LOG("Vendor : %s\n", "DMP"); + LOG("Renderer : %s\n", "PICA200 citro3D"); + + C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); + + support.shaderBinary = true; + support.VAO = true; + support.texMinSize = 8; + + // rotated + Core::width = DISPLAY_HEIGHT; + Core::height = DISPLAY_WIDTH; + + // init default vertex declaration + AttrInfo_Init(&vertexAttribs); + AttrInfo_AddLoader(&vertexAttribs, aCoord , GPU_SHORT , 4); + AttrInfo_AddLoader(&vertexAttribs, aNormal , GPU_UNSIGNED_BYTE , 4); + AttrInfo_AddLoader(&vertexAttribs, aTexCoord , GPU_SHORT , 4); + AttrInfo_AddLoader(&vertexAttribs, aColor , GPU_UNSIGNED_BYTE , 4); + AttrInfo_AddLoader(&vertexAttribs, aLight , GPU_UNSIGNED_BYTE , 4); + + rotate90 = true; + depthTest = false; + clearColor = 0; //0x68B0D8FF; + colorMask = GPU_WRITE_COLOR; + depthMask = GPU_WRITE_DEPTH; + + // init shaders + SHADERS_LIST(SHADER_INIT); + } + + void deinit() { + SHADERS_LIST(SHADER_FREE); + + C3D_Fini(); + gfxExit(); + } + + void initOutput(Texture **outputTex) { + // VRAM +562k (2 x Color) +192k (1 x Depth) + for (int i = 0; i < COUNT(GAPI::defTarget); i++) { + Texture *tex = outputTex[i]; + tex->width = tex->origWidth; + tex->height = tex->origHeight; + + // output target has portrait orientation (rotate90) + int width = tex->height; + int height = tex->width; + + C3D_RenderTarget *target = C3D_RenderTargetCreate(width, height, GPU_RB_RGB8, C3D_DEPTHTYPE(-1)); + mmLogVRAM(); + void *depthBuf = getDepthBuffer(width, height, 0, GPU_RB_DEPTH16); + C3D_FrameBufDepth(&target->frameBuf, depthBuf, GPU_RB_DEPTH16); + + tex->target[0] = *target; + + GAPI::defTarget[i] = &tex->target[0]; + } + + C3D_RenderTargetSetOutput(defTarget[0], GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS); + C3D_RenderTargetSetOutput(defTarget[1], GFX_TOP, GFX_RIGHT, DISPLAY_TRANSFER_FLAGS); + + active.target = outputTex[1]; // ???? + curTarget = defTarget[0]; + C3D_FrameDrawOn(curTarget); // ???? + } + + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_NEG_ZERO; + } + + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar, rotate90); + return m; + } + + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye, rotate90); + return m; + } + + bool beginFrame() { + C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + return true; + } + + void endFrame() { + C3D_FrameEnd(0); + } + + void resetState() { + fogParams = vec4(-1.0f); + C3D_SetAttrInfo(&vertexAttribs); + } + + void bindTarget(Texture *target, int face) { + if (target) { + curTarget = checkRenderTarget(target, face, 0, GPU_RB_DEPTH16); + } else { + curTarget = defTarget[0]; + } + + C3D_FrameDrawOn(curTarget); + } + + void discardTarget(bool color, bool depth) {} + + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { + // + } + + void setVSync(bool enable) {} + + void present() {} + + bool isRotate90() { + return (curTarget == defTarget[0]) || (curTarget == defTarget[1]); + } + + void setViewport(const short4 &v) { + if (isRotate90()) { + C3D_SetViewport(v.y, Core::viewportDef.z - (v.x + v.z), v.w, v.z); + } else { + C3D_SetViewport(v.x, v.y, v.z, v.w); + } + } + + void setScissor(const short4 &s) { + if (isRotate90()) { + C3D_SetScissor(GPU_SCISSOR_NORMAL, s.y, Core::viewportDef.z - (s.x + s.z), s.y + s.w, Core::viewportDef.z - s.x); + } else { + C3D_SetScissor(GPU_SCISSOR_NORMAL, s.x, s.y, s.x + s.z, s.y + s.w); + } + } + + void updateWriteMask() { + C3D_DepthTest(depthTest, GPU_GREATER, GPU_WRITEMASK(colorMask | depthMask)); + //C3D_EarlyDepthTest(depthTest, GPU_EARLYDEPTH_GREATER, 0); // TODO block32 256x416 input -> 240x400 output + } + + void setDepthTest(bool enable) { + depthTest = enable; + updateWriteMask(); + } + + void setDepthWrite(bool enable) { + depthMask = enable ? GPU_WRITE_DEPTH : 0; + updateWriteMask(); + } + + void setColorWrite(bool r, bool g, bool b, bool a) { + colorMask = 0; + if (r) colorMask |= GPU_WRITE_RED; + if (g) colorMask |= GPU_WRITE_GREEN; + if (b) colorMask |= GPU_WRITE_BLUE; + if (a) colorMask |= GPU_WRITE_ALPHA; + updateWriteMask(); + } + + void setAlphaTest(bool enable) { + C3D_AlphaTest(enable, GPU_GREATER, 128); + } + + void setCullMode(int rsMask) { + switch (rsMask) { + case RS_CULL_BACK : C3D_CullFace(GPU_CULL_BACK_CCW); break; + case RS_CULL_FRONT : C3D_CullFace(GPU_CULL_FRONT_CCW); break; + default : C3D_CullFace(GPU_CULL_NONE); + } + } + + void setBlendMode(int rsMask) { + switch (rsMask) { + case RS_BLEND_ALPHA : C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); break; + case RS_BLEND_ADD : C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_ONE, GPU_ONE, GPU_ONE, GPU_ONE); break; + case RS_BLEND_MULT : C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_DST_COLOR, GPU_ZERO, GPU_DST_COLOR, GPU_ZERO); break; + case RS_BLEND_PREMULT : C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); break; + default : C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_ONE, GPU_ZERO, GPU_ONE, GPU_ZERO); break; + } + } + + void setViewProj(const mat4 &mView, const mat4 &mProj) {} + + void DIP(Mesh *mesh, const MeshRange &range) { + if (!active.shader) return; + + active.shader->validate(); + + C3D_DrawElements(GPU_TRIANGLES, range.iCount, C3D_UNSIGNED_SHORT, mesh->iBuffer + mesh->getChunk().iStart + range.iStart); + } + + void updateLights(vec4 *lightPos, vec4 *lightColor, int count) { + if (active.shader) { + active.shader->setParam(uLightColor, lightColor[0], count); + active.shader->setParam(uLightPos, lightPos[0], count); + } + } + + void setFog(const vec4 ¶ms) { + if (fogParams == params) return; + + fogParams = params; + + int32 index; + + if (fogLUT[0].params == params) { + index = 0; + } else if (fogLUT[1].params == params) { + index = 1; + } else if (fogLUT[2].params == params) { + index = 2; + } else { + index = 2; + fogLUT[0] = fogLUT[1]; + fogLUT[1] = fogLUT[2]; + + // for some reason GPU_NO_FOG breaks depth, blend or texEnv states in some cases, so we use low density fog table (0.0f) as NO_FOG + FogLut_Exp(&fogLUT[index].table, params.w, 1.0f, 32.0f, 45.0f * 1024.0f); + fogLUT[index].params = params; + fogLUT[index].color = 0xFF000000 + | (uint32(clamp(params.x * 255.0f, 0.0f, 255.0f)) << 0) + | (uint32(clamp(params.y * 255.0f, 0.0f, 255.0f)) << 8) + | (uint32(clamp(params.z * 255.0f, 0.0f, 255.0f)) << 16); + } + + + C3D_FogGasMode(GPU_FOG, GPU_PLAIN_DENSITY, false); + C3D_FogColor(fogLUT[index].color); + C3D_FogLutBind(&fogLUT[index].table); + } + + void clear(bool color, bool depth) { + uint32 mask = 0; + if (color) mask |= C3D_CLEAR_COLOR; + if (depth) mask |= C3D_CLEAR_DEPTH; + if (!mask) return; + + C3D_FrameSplit(0); + C3D_FrameBufClear(&curTarget->frameBuf, C3D_ClearBits(mask), clearColor, 0); + } + + void setClearColor(const vec4 &color) { + clearColor = (uint32(color.w * 255)) + | (uint32(color.z * 255) << 8) + | (uint32(color.y * 255) << 16) + | (uint32(color.x * 255) << 24); + } + + vec4 copyPixel(int x, int y) { +// GAPI::Texture *t = Core::active.target; +// Color32 *color = (Color32*)t->data; +// return vec4(color->r, color->g, color->b, 255.0f) * (1.0f / 255.0f); + return vec4(0.0f); // TODO: read from framebuffer + } +} + +#endif \ No newline at end of file diff --git a/src/gapi/d3d11.h b/src/gapi/d3d11.h new file mode 100644 index 00000000..e8bd627c --- /dev/null +++ b/src/gapi/d3d11.h @@ -0,0 +1,1120 @@ +#ifndef H_GAPI_D3D11 +#define H_GAPI_D3D11 + +#include "core.h" +#include + +#define SAFE_RELEASE(P) if(P){P->Release(); P = NULL;} + +#if 0 //defined(_DEBUG) || defined(PROFILE) + #include + + struct Marker { + Marker(const char *title) { + wchar_t ws[128]; + swprintf(ws, sizeof(ws), L"%hs", title); + D3DPERF_BeginEvent(0xFFFFFFFF, ws); + } + + ~Marker() { + D3DPERF_EndEvent(); + } + + static void setLabel(ID3D11DeviceChild *child, const char *label) { + // TODO: use Windows 10 SDK + //child->SetPrivateData(WKPDID_D3DDebugObjectName, strlen(label), label); + } + }; + + #define PROFILE_MARKER(title) Marker marker(title) + #define PROFILE_LABEL(id, child, label) Marker::setLabel(child, label) + #define PROFILE_TIMING(time) +#else + #define PROFILE_MARKER(title) + #define PROFILE_LABEL(id, child, label) + #define PROFILE_TIMING(time) +#endif + +#ifdef _OS_WP8 + extern Microsoft::WRL::ComPtr osDevice; + extern Microsoft::WRL::ComPtr osContext; + extern Microsoft::WRL::ComPtr osSwapChain; +#else + extern ID3D11Device *osDevice; + extern ID3D11DeviceContext *osContext; + #ifdef _OS_XB1 + extern IDXGISwapChain1 *osSwapChain; + #else + extern IDXGISwapChain *osSwapChain; + #endif +#endif + +namespace GAPI { + using namespace Core; + + typedef ::Vertex Vertex; + + CullMode cullMode; + BlendMode blendMode; + vec4 clearColor; + + bool depthTest, depthWrite, colorWrite; + bool dirtyDepthState; + bool dirtyBlendState; + + ID3D11RenderTargetView *defRTV; + ID3D11DepthStencilView *defDSV; + + ID3D11BlendState *BS[2][bmMAX]; // [colorWrite][blendMode] ONLY two colorWrite modes are supported (A and RGBA) + ID3D11RasterizerState *RS[cmMAX]; // [cullMode] + ID3D11DepthStencilState *DS[2][2]; // [depthTest][depthWrite] + + enum { + smpDefault, + smpPoint, + smpPointWrap, + smpLinear, + smpLinearWrap, + smpCmp, + smpMAX + }; + + ID3D11SamplerState *samplers[smpMAX]; + + ID3D11Texture2D *stagingPixel; + +// Shader + #include "shaders/d3d11/shaders.h" + + enum { + USAGE_VS, + USAGE_PS, + }; + + static const struct Binding { + int reg; + int usage; + } bindings[uMAX] = { + { 0, USAGE_VS | USAGE_PS }, // uParam + { 1, USAGE_VS | USAGE_PS }, // uTexParam + { 2, USAGE_VS | USAGE_PS }, // uViewProj + { 6, USAGE_VS | USAGE_PS }, // uBasis + { 70, USAGE_VS | USAGE_PS }, // uLightProj + { 74, USAGE_VS | USAGE_PS }, // uMaterial + { 75, USAGE_VS | USAGE_PS }, // uAmbient + { 81, USAGE_VS | USAGE_PS }, // uFogParams + { 82, USAGE_VS | USAGE_PS }, // uViewPos + { 83, USAGE_VS | USAGE_PS }, // uLightPos + { 87, USAGE_VS | USAGE_PS }, // uLightColor + { 91, USAGE_VS | USAGE_PS }, // uRoomSize + { 92, USAGE_VS | USAGE_PS }, // uPosScale + { 98, USAGE_VS | USAGE_PS }, // uContacts + }; + + struct Shader { + ID3D11VertexShader *VS; + ID3D11PixelShader *PS; + ID3D11InputLayout *IL; + ID3D11Buffer *CB; + + vec4 cbMem[98 + MAX_CONTACTS]; + int cbCount[uMAX]; + + bool rebind; + + Shader() : VS(NULL), PS(NULL) {} + + void init(Core::Pass pass, int type, int *def, int defCount) { + memset(cbMem, 0, sizeof(cbMem)); + + bool underwater = false; + bool alphatest = false; + + for (int i = 0; i < defCount; i++) { + switch (def[i]) { + case SD_UNDERWATER : underwater = true; break; + case SD_ALPHA_TEST : alphatest = true; break; + } + } + + int vSize, fSize; + + #define SHADER(S,P) (P##Src = S##_##P, P##Size = sizeof(S##_##P)) + #define SHADER_A(S,P) (alphatest ? SHADER(S##_a,P) : SHADER(S,P)) + #define SHADER_U(S,P) (underwater ? SHADER(S##_u,P) : SHADER(S,P)) + #define SHADER_AU(S,P) ((underwater && alphatest) ? SHADER(S##_au,P) : (alphatest ? SHADER(S##_a,P) : SHADER_U(S,P))) + + const uint8 *vSrc = NULL, *fSrc = NULL; + switch (pass) { + case passCompose : + switch (type) { + case 0 : SHADER_U ( compose_sprite, v ); SHADER_AU ( compose_sprite, f ); break; + case 1 : SHADER ( compose_flash, v ); SHADER ( compose_flash, f ); break; + case 2 : SHADER_U ( compose_room, v ); SHADER_AU ( compose_room, f ); break; + case 3 : SHADER_U ( compose_entity, v ); SHADER_AU ( compose_entity, f ); break; + case 4 : SHADER ( compose_mirror, v ); SHADER ( compose_mirror, f ); break; + default : ASSERT(false); + } + break; + case passShadow : + switch (type) { + case 3 : + case 4 : SHADER ( shadow_entity, v ); SHADER ( shadow_entity, f ); break; + default : ASSERT(false); + } + break; + case passAmbient : + switch (type) { + case 0 : SHADER ( ambient_sprite, v ); SHADER_A ( ambient_sprite, f ); break; + case 1 : SHADER ( ambient_room, v ); SHADER ( ambient_room, f ); break; // TYPE_FLASH (sky) + case 2 : SHADER ( ambient_room, v ); SHADER_A ( ambient_room, f ); break; + default : ASSERT(false); + } + break; + case passSky : + switch (type) { + case 0 : SHADER ( sky, v ); SHADER ( sky, f ); break; + case 1 : SHADER ( sky_clouds, v ); SHADER ( sky_clouds, f ); break; + case 2 : SHADER ( sky_azure, v ); SHADER ( sky_azure, f ); break; + default : ASSERT(false); + } + break; + case passWater : + switch (type) { + case 0 : SHADER ( water_drop, v ); SHADER ( water_drop, f ); break; + case 1 : SHADER ( water_simulate, v ); SHADER ( water_simulate, f ); break; + case 2 : SHADER ( water_caustics, v ); SHADER ( water_caustics, f ); break; + case 3 : SHADER ( water_rays, v ); SHADER ( water_rays, f ); break; + case 4 : SHADER ( water_mask, v ); SHADER ( water_mask, f ); break; + case 5 : SHADER ( water_compose, v ); SHADER ( water_compose, f ); break; + default : ASSERT(false); + } + break; + case passFilter : + switch (type) { + case 0 : SHADER ( filter_upscale, v ); SHADER ( filter_upscale, f ); break; + case 1 : SHADER ( filter_downsample, v ); SHADER ( filter_downsample, f ); break; + case 3 : SHADER ( filter_grayscale, v ); SHADER ( filter_grayscale, f ); break; + case 4 : SHADER ( filter_blur, v ); SHADER ( filter_blur, f ); break; + case 5 : SHADER ( filter_anaglyph, v ); SHADER ( filter_anaglyph, f ); break; + default : ASSERT(false); + } + break; + case passGUI : SHADER ( gui, v ); SHADER ( gui, f ); break; + default : ASSERT(false); LOG("! wrong pass id\n"); return; + } + + #undef SHADER_A + #undef SHADER_U + #undef SHADER_AU + + HRESULT ret; + ret = osDevice->CreateVertexShader ((DWORD*)vSrc, vSize, NULL, &VS); ASSERT(ret == S_OK); + ret = osDevice->CreatePixelShader ((DWORD*)fSrc, fSize, NULL, &PS); ASSERT(ret == S_OK); + + const D3D11_INPUT_ELEMENT_DESC vertexDecl[] = { + { "POSITION", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aCoord + { "NORMAL", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aNormal + { "TEXCOORD", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aTexCoord + { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aColor + { "COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // aLight + }; + + ret = osDevice->CreateInputLayout(vertexDecl, COUNT(vertexDecl), vSrc, vSize, &IL); + ASSERT(ret == S_OK); + + rebind = true; + + D3D11_BUFFER_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + desc.ByteWidth = sizeof(cbMem); + osDevice->CreateBuffer(&desc, NULL, &CB); + } + + void deinit() { + SAFE_RELEASE(CB); + SAFE_RELEASE(IL); + SAFE_RELEASE(VS); + SAFE_RELEASE(PS); + } + + void bind() { + if (Core::active.shader != this) { + Core::active.shader = this; + memset(cbCount, 0, sizeof(cbCount)); + rebind = true; + } + } + + void validate() { + if (rebind) { + osContext->IASetInputLayout(IL); + osContext->VSSetShader(VS, NULL, 0); + osContext->PSSetShader(PS, NULL, 0); + rebind = false; + } + + D3D11_MAPPED_SUBRESOURCE mapped; + osContext->Map(CB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); + memcpy(mapped.pData, cbMem, sizeof(cbMem)); + osContext->Unmap(CB, 0); + + osContext->VSSetConstantBuffers(0, 1, &CB); + osContext->PSSetConstantBuffers(0, 1, &CB); + Core::stats.cb++; + } + + void setParam(UniformType uType, float *value, int count) { + cbCount[uType] = count; + memcpy(cbMem + bindings[uType].reg, value, count * 16); + } + + void setParam(UniformType uType, const vec4 &value, int count = 1) { + setParam(uType, (float*)&value, count); + } + + void setParam(UniformType uType, const mat4 &value, int count = 1) { + setParam(uType, (float*)&value, count * 4); + } + }; + +// Texture + struct Texture { + union { + ID3D11Resource *ID; + ID3D11Texture2D *tex2D; + ID3D11Texture3D *tex3D; + }; + ID3D11ShaderResourceView *SRV; + ID3D11RenderTargetView *RTV[6]; + ID3D11DepthStencilView *DSV; + + int width, height, depth, origWidth, origHeight, origDepth; + TexFormat fmt; + uint32 opt; + + Texture(int width, int height, int depth, uint32 opt) : ID(NULL), SRV(NULL), DSV(NULL), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) { + memset(RTV, 0, sizeof(RTV)); + } + + void init(void *data) { + ASSERT((opt & OPT_PROXY) == 0); + + bool mipmaps = (opt & OPT_MIPMAPS) != 0; + bool isDepth = fmt == FMT_DEPTH || fmt == FMT_SHADOW; + bool isCube = (opt & OPT_CUBEMAP) != 0; + bool isVolume = (opt & OPT_VOLUME) != 0; + bool isTarget = (opt & OPT_TARGET) != 0; + bool isDynamic = (opt & OPT_DYNAMIC) != 0; + + static const struct FormatDesc { + int bpp; + DXGI_FORMAT format; + } formats[FMT_MAX] = { + { 8, DXGI_FORMAT_R8_UNORM }, + { 32, DXGI_FORMAT_R8G8B8A8_UNORM }, + { 16, DXGI_FORMAT_B5G6R5_UNORM }, + { 16, DXGI_FORMAT_B5G5R5A1_UNORM }, + { 64, DXGI_FORMAT_R32G32_FLOAT }, + { 32, DXGI_FORMAT_R16G16_FLOAT }, + { 16, DXGI_FORMAT_R16_TYPELESS }, + { 16, DXGI_FORMAT_R16_TYPELESS }, + }; + + D3D11_SUBRESOURCE_DATA initialData[6]; + initialData[0].pSysMem = data; + initialData[0].SysMemPitch = origWidth * formats[fmt].bpp / 8; + initialData[0].SysMemSlicePitch = origHeight * initialData[0].SysMemPitch; + + if (isCube && data) { + for (int i = 1; i < 6; i++) { + initialData[i] = initialData[i - 1]; + *(uint8*)initialData[i].pSysMem += initialData[i].SysMemSlicePitch; + } + } + + D3D11_SHADER_RESOURCE_VIEW_DESC descSRV; + memset(&descSRV, 0, sizeof(descSRV)); + descSRV.Format = isDepth ? DXGI_FORMAT_R16_UNORM : formats[fmt].format; + descSRV.Texture2D.MipLevels = 1; // for cube, 3d and 2d + + if (isVolume) { + D3D11_TEXTURE3D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = width; + desc.Height = height; + desc.Depth = origDepth; + desc.MipLevels = 1; + desc.Format = formats[fmt].format; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + osDevice->CreateTexture3D(&desc, data ? initialData : NULL, &tex3D); + ASSERT(tex3D); + + descSRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + osDevice->CreateShaderResourceView(tex3D, &descSRV, &SRV); + } else { + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = width; + desc.Height = height; + desc.MipLevels = 1;//mipmaps ? 0 : 1; + desc.ArraySize = isCube ? 6 : 1; + desc.Format = formats[fmt].format; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.MiscFlags = (isCube ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0); + + if (isTarget) { + if (isDepth) { + desc.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + } else { + desc.BindFlags |= D3D11_BIND_RENDER_TARGET; + } + } + + if (isDynamic) { + desc.Usage = D3D11_USAGE_DYNAMIC; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } + + if (mipmaps) { + desc.BindFlags |= D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; + desc.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; + } + + osDevice->CreateTexture2D(&desc, data ? initialData : NULL, &tex2D); + ASSERT(tex2D); + + if (isTarget) { + if (isDepth) { + D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; + memset(&descDSV, 0, sizeof(descDSV)); + descDSV.Format = DXGI_FORMAT_D16_UNORM; + descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + osDevice->CreateDepthStencilView(tex2D, &descDSV, &DSV); + ASSERT(DSV); + } else { + D3D11_RENDER_TARGET_VIEW_DESC descRTV; + memset(&descRTV, 0, sizeof(descRTV)); + descRTV.Format = desc.Format; + descRTV.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; + descRTV.Texture2DArray.ArraySize = 1; + + for (int i = 0; i < 6; i++) { + descRTV.Texture2DArray.FirstArraySlice = i; + osDevice->CreateRenderTargetView(tex2D, &descRTV, &RTV[i]); + ASSERT(RTV[i]); + if (!isCube) break; + } + } + } + + descSRV.ViewDimension = isCube ? D3D11_SRV_DIMENSION_TEXTURECUBE : D3D11_SRV_DIMENSION_TEXTURE2D; + osDevice->CreateShaderResourceView(tex2D, &descSRV, &SRV); + } + + ASSERT(SRV); + } + + void deinit() { + SAFE_RELEASE(tex2D); + SAFE_RELEASE(tex3D); + SAFE_RELEASE(SRV); + for (int i = 0; i < 6; i++) { + SAFE_RELEASE(RTV[i]); + } + SAFE_RELEASE(DSV); + } + + void generateMipMap() { + ASSERT(SRV && tex2D); + osContext->GenerateMips(SRV); + } + + void update(void *data) { + ASSERT(tex2D); + ASSERT(opt & OPT_DYNAMIC); + D3D11_MAPPED_SUBRESOURCE mapped; + osContext->Map(tex2D, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); + memcpy(mapped.pData, data, mapped.RowPitch * height); + osContext->Unmap(tex2D, 0); + } + + void bind(int sampler) { + if (opt & OPT_PROXY) return; + ASSERT(tex2D || tex3D); + + if (Core::active.textures[sampler] != this) { + Core::active.textures[sampler] = this; + + #ifndef _OS_WP8 + if (opt & OPT_VERTEX) { + osContext->VSSetShaderResources(sampler, 1, &SRV); + } + #endif + + osContext->PSSetShaderResources(sampler, 1, &SRV); + } + } + + void unbind(int sampler) { + if (Core::active.textures[sampler]) { + Core::active.textures[sampler] = NULL; + + ID3D11ShaderResourceView *none = NULL; + + if (opt & OPT_VERTEX) { + osContext->VSSetShaderResources(sampler, 1, &none); + } + osContext->PSSetShaderResources(sampler, 1, &none); + } + } + + void setFilterQuality(int value) {} + }; + +// Mesh + struct Mesh { + ID3D11Buffer *ID[2]; + + int iCount; + int vCount; + bool dynamic; + + Mesh(bool dynamic) : dynamic(dynamic) { + ID[0] = ID[1] = NULL; + } + + void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) { + this->iCount = iCount; + this->vCount = vCount; + ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); + + D3D11_BUFFER_DESC desc; + D3D11_SUBRESOURCE_DATA initData; + + memset(&desc, 0, sizeof(desc)); + memset(&initData, 0, sizeof(initData)); + desc.Usage = dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT; + desc.CPUAccessFlags = dynamic ? D3D11_CPU_ACCESS_WRITE : 0; + + desc.BindFlags = D3D11_BIND_INDEX_BUFFER; + desc.ByteWidth = iCount * sizeof(Index); + initData.pSysMem = indices; + osDevice->CreateBuffer(&desc, dynamic ? NULL : &initData, &ID[0]); + + desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + desc.ByteWidth = vCount * sizeof(Vertex); + initData.pSysMem = vertices; + osDevice->CreateBuffer(&desc, dynamic ? NULL : &initData, &ID[1]); + } + + void deinit() { + SAFE_RELEASE(ID[0]); + SAFE_RELEASE(ID[1]); + } + + void update(Index *indices, int iCount, ::Vertex *vertices, int vCount) { + ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); + + D3D11_MAPPED_SUBRESOURCE mapped; + + if (indices && iCount) { + osContext->Map(ID[0], 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); + memcpy(mapped.pData, indices, iCount * sizeof(indices[0])); + osContext->Unmap(ID[0], 0); + } + + if (vertices && vCount) { + osContext->Map(ID[1], 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); + memcpy(mapped.pData, vertices, vCount * sizeof(vertices[0])); + osContext->Unmap(ID[1], 0); + } + } + + void bind(const MeshRange &range) const { + UINT stride = sizeof(Vertex); + UINT offset = 0;//range.vStart * stride; + osContext->IASetIndexBuffer(ID[0], sizeof(Index) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0); + osContext->IASetVertexBuffers(0, 1, &ID[1], &stride, &offset); + } + + void initNextRange(MeshRange &range, int &aIndex) const { + range.aIndex = -1; + } + }; + +// GLuint FBO, defaultFBO; + struct RenderTargetCache { + int count; + struct Item { + ID3D11RenderTargetView *RTV; + ID3D11DepthStencilView *DSV; + int width; + int height; + } items[MAX_RENDER_BUFFERS]; + } rtCache; + + void deinitSamplers() { + for (int i = 0; i < COUNT(samplers); i++) { + SAFE_RELEASE(samplers[i]); + } + } + + ID3D11SamplerState* initSampler(bool filter, bool aniso, bool wrap, bool cmp) { + D3D11_SAMPLER_DESC desc; + memset(&desc, 0, sizeof(desc)); + + if (aniso && (Core::support.maxAniso > 0)) { + desc.MaxAnisotropy = min(int(Core::support.maxAniso), 8); + } else { + desc.MaxAnisotropy = 1; + } + + if (desc.MaxAnisotropy > 1) { + desc.Filter = D3D11_FILTER_ANISOTROPIC; + } else { + if (filter) { + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + } else { + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + } + } + + if (cmp) { + desc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR; + desc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL; + desc.BorderColor[0] = + desc.BorderColor[1] = + desc.BorderColor[2] = + desc.BorderColor[3] = 1.0f; + } else { + desc.ComparisonFunc = D3D11_COMPARISON_NEVER; + } + + desc.AddressU = + desc.AddressV = + desc.AddressW = cmp ? D3D11_TEXTURE_ADDRESS_BORDER : (wrap ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP); + desc.MinLOD = 0; + desc.MaxLOD = D3D11_FLOAT32_MAX; + + ID3D11SamplerState *sampler; + osDevice->CreateSamplerState(&desc, &sampler); + return sampler; + } + + void initSamplers() { + deinitSamplers(); + samplers[smpDefault] = initSampler(true, true, false, false); // TODO settings dependent + samplers[smpPoint] = initSampler(false, false, false, false); + samplers[smpPointWrap] = initSampler(false, false, true, false); + samplers[smpLinear] = initSampler(true, false, false, false); + samplers[smpLinearWrap] = initSampler(true, false, true, false); + samplers[smpCmp] = initSampler(true, false, false, true); + } + + void init() { + memset(&rtCache, 0, sizeof(rtCache)); + + /* TODO + D3DADAPTER_IDENTIFIER9 adapterInfo; + D3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &adapterInfo); + LOG("Vendor : %s\n", adapterInfo.Description); + LOG("Renderer : Direct3D 9.0c\n"); + */ + + support.maxAniso = 8; + support.maxVectors = 16; + support.shaderBinary = true; + support.VAO = false; // SHADOW_COLOR + support.depthTexture = true; + support.shadowSampler = true; + support.discardFrame = false; + support.texNPOT = true; + support.texRG = true; + support.texBorder = true; + support.colorFloat = true; + support.colorHalf = true; + support.texFloatLinear = true; + support.texFloat = true; + support.texHalfLinear = true; + support.texHalf = true; + support.tex3D = true; + + #ifdef _OS_WP8 + support.depthTexture = false; + support.shadowSampler = false; + support.colorFloat = true; + support.colorHalf = true; + support.texFloatLinear = true; + support.texFloat = true; + support.texHalfLinear = true; + support.texHalf = true; + support.tex3D = false; + #endif + + #ifdef PROFILE + support.profMarker = false; + support.profTiming = false; + #endif + + defRTV = NULL; + defDSV = NULL; + + // init blend modes + { + #define BLEND_FUNC(B,S,D)\ + desc.RenderTarget[0].SrcBlend = S;\ + desc.RenderTarget[0].DestBlend = D;\ + osDevice->CreateBlendState(&desc, &BS[i][B]) + + D3D11_BLEND_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.IndependentBlendEnable = FALSE; + desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; + + for (int i = 0; i < 2; i++) { + desc.RenderTarget[0].RenderTargetWriteMask = i ? D3D11_COLOR_WRITE_ENABLE_ALL : D3D11_COLOR_WRITE_ENABLE_ALPHA; + desc.RenderTarget[0].BlendEnable = FALSE; + BLEND_FUNC(bmNone, D3D11_BLEND_ONE, D3D11_BLEND_ZERO); + desc.RenderTarget[0].BlendEnable = TRUE; + BLEND_FUNC(bmAlpha, D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA); + BLEND_FUNC(bmAdd, D3D11_BLEND_ONE, D3D11_BLEND_ONE); + BLEND_FUNC(bmMult, D3D11_BLEND_DEST_COLOR, D3D11_BLEND_ZERO); + BLEND_FUNC(bmPremult, D3D11_BLEND_ONE, D3D11_BLEND_INV_SRC_ALPHA); + } + + #undef BLEND_FUNC + } + + // init raster state + { + D3D11_RASTERIZER_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.ScissorEnable = TRUE; + desc.FrontCounterClockwise = TRUE; + desc.DepthClipEnable = TRUE; + desc.FillMode = D3D11_FILL_SOLID; + desc.CullMode = D3D11_CULL_NONE; + osDevice->CreateRasterizerState(&desc, &RS[cmNone]); + desc.CullMode = D3D11_CULL_BACK; + osDevice->CreateRasterizerState(&desc, &RS[cmBack]); + desc.CullMode = D3D11_CULL_FRONT; + osDevice->CreateRasterizerState(&desc, &RS[cmFront]); + } + + // init depth stencil states + { + D3D11_DEPTH_STENCIL_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.StencilEnable = FALSE; + desc.DepthEnable = TRUE; + desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + + for (int i = 0; i < 2; i++) { + desc.DepthEnable = i ? TRUE : FALSE; + for (int j = 0; j < 2; j++) { + desc.DepthWriteMask = j ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + osDevice->CreateDepthStencilState(&desc, &DS[i][j]); + } + } + } + + // init samplers + memset(samplers, 0, sizeof(samplers)); + initSamplers(); + + // init staging texture for copyPixel + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = 1; + desc.Height = 1; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_STAGING; + desc.MiscFlags = 0; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + osDevice->CreateTexture2D(&desc, NULL, &stagingPixel); + } + + void resetDevice() { + SAFE_RELEASE(defRTV); + SAFE_RELEASE(defDSV); + + for (int i = 0; i < rtCache.count; i++) { + SAFE_RELEASE(rtCache.items[i].RTV); + SAFE_RELEASE(rtCache.items[i].DSV); + } + + rtCache.count = 0; + } + + void deinit() { + resetDevice(); + + deinitSamplers(); + + SAFE_RELEASE(stagingPixel); + + for (int i = 0; i < COUNT(RS); i++) { + SAFE_RELEASE(RS[i]); + } + + for (int j = 0; j < COUNT(DS); j++) { + for (int i = 0; i < COUNT(DS[0]); i++) { + SAFE_RELEASE(DS[j][i]); + } + } + + for (int j = 0; j < COUNT(BS); j++) { + for (int i = 0; i < COUNT(BS[0]); i++) { + SAFE_RELEASE(BS[j][i]); + } + } + } + + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_ZERO_POS; + } + + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + + #ifdef _OS_WP8 + m.rot90(); + #endif + + return m; + } + + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + + #ifdef _OS_WP8 + aspect = 1.0f / aspect; + #endif + + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + + #ifdef _OS_WP8 + m.rot90(); + #endif + + return m; + } + + bool beginFrame() { + if (!defRTV) { + ID3D11Texture2D *pBackBuffer = NULL; + osSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); + osDevice->CreateRenderTargetView(pBackBuffer, NULL, &defRTV); + SAFE_RELEASE(pBackBuffer); + } + + if (!defDSV) { + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = Core::width; + desc.Height = Core::height; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; + + ID3D11Texture2D *dsTex; + osDevice->CreateTexture2D(&desc, NULL, &dsTex); + + D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; + memset(&descDSV, 0, sizeof(descDSV)); + descDSV.Format = desc.Format; + descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + descDSV.Texture2D.MipSlice = 0; + osDevice->CreateDepthStencilView(dsTex, &descDSV, &defDSV); + + SAFE_RELEASE(dsTex); + } + + osContext->OMSetRenderTargets(1, &defRTV, defDSV); + + return true; + } + + void endFrame() { + // + } + + void resetState() { + osContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + osContext->RSSetState(RS[cmNone]); + depthTest = depthWrite = dirtyDepthState = true; + colorWrite = dirtyBlendState = true; + + #ifndef _OS_WP8 + osContext->VSSetSamplers(0, COUNT(samplers), samplers); + #endif + + osContext->PSSetSamplers(0, COUNT(samplers), samplers); + } + + void cacheRenderTarget(ID3D11RenderTargetView **RTV, ID3D11DepthStencilView **DSV, int width, int height) { + ASSERT((RTV != NULL) ^ (DSV != NULL)); + + int index = -1; + for (int i = 0; i < rtCache.count; i++) + if (rtCache.items[i].width == width && rtCache.items[i].height == height) { + index = i; + break; + } + + ASSERT(rtCache.count < MAX_RENDER_BUFFERS); + + if (index == -1) { + index = rtCache.count++; + rtCache.items[index].width = width; + rtCache.items[index].height = height; + } + + if (RTV) { + if (!rtCache.items[index].RTV) { + ID3D11Texture2D *tex2D = NULL; + + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = width; + desc.Height = height; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_RENDER_TARGET; + osDevice->CreateTexture2D(&desc, NULL, &tex2D); + osDevice->CreateRenderTargetView(tex2D, NULL, &rtCache.items[index].RTV); + SAFE_RELEASE(tex2D); + } + *RTV = rtCache.items[index].RTV; + ASSERT(*RTV); + } + + if (DSV) { + if (!rtCache.items[index].DSV) { + ID3D11Texture2D *tex2D = NULL; + + D3D11_TEXTURE2D_DESC desc; + memset(&desc, 0, sizeof(desc)); + desc.Width = width; + desc.Height = height; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_R16_TYPELESS; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_DEPTH_STENCIL; + osDevice->CreateTexture2D(&desc, NULL, &tex2D); + + D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; + memset(&descDSV, 0, sizeof(descDSV)); + descDSV.Format = DXGI_FORMAT_D16_UNORM; + descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + osDevice->CreateDepthStencilView(tex2D, &descDSV, &rtCache.items[index].DSV); + SAFE_RELEASE(tex2D); + } + *DSV = rtCache.items[index].DSV; + ASSERT(*DSV); + } + } + + void bindTarget(Texture *target, int face) { + ID3D11RenderTargetView *RTV = defRTV; + ID3D11DepthStencilView *DSV = defDSV; + + if (target) { + ASSERT(target->opt & OPT_TARGET); + + if (target->RTV[face]) { + RTV = target->RTV[face]; + cacheRenderTarget(NULL, &DSV, target->width, target->height); + } else if (target->DSV) { + DSV = target->DSV; + cacheRenderTarget(&RTV, NULL, target->width, target->height); + } else { + ASSERT(false); + } + } + + osContext->OMSetRenderTargets(1, &RTV, DSV); + + Core::active.viewport = short4(0, 0, 0, 0); // forcing viewport reset + } + + void discardTarget(bool color, bool depth) {} + + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { + D3D11_BOX box; + + box.left = x; + box.top = y; + box.right = x + width; + box.bottom = y + height; + box.front = 0; + box.back = 1; + + ID3D11RenderTargetView *RTV; + ID3D11Resource *res; + + osContext->OMGetRenderTargets(1, &RTV, NULL); + RTV->GetResource(&res); + + osContext->CopySubresourceRegion(dst->tex2D, 0, xOffset, yOffset, 0, res, 0, &box); + + SAFE_RELEASE(RTV); + SAFE_RELEASE(res); + } + + void setVSync(bool enable) {} + void waitVBlank() {} + + void clear(bool color, bool depth) { + ID3D11RenderTargetView *RTV = NULL; + ID3D11DepthStencilView *DSV = NULL; + + osContext->OMGetRenderTargets(1, &RTV, &DSV); + + if (color && RTV) { + osContext->ClearRenderTargetView(RTV, (FLOAT*)&clearColor); + } + + if (depth && DSV) { + osContext->ClearDepthStencilView(DSV, D3D11_CLEAR_DEPTH, 1.0, 0); + } + + SAFE_RELEASE(RTV); + SAFE_RELEASE(DSV); + } + + void setClearColor(const vec4 &color) { + clearColor = color; + } + + void setViewport(const short4 &v) { + D3D11_VIEWPORT viewport; + viewport.TopLeftX = (FLOAT)v.x; + viewport.TopLeftY = (FLOAT)v.y; + viewport.Width = (FLOAT)v.z; + viewport.Height = (FLOAT)v.w; + viewport.MinDepth = 0.0f; + viewport.MaxDepth = 1.0f; + + osContext->RSSetViewports(1, &viewport); + } + + void setScissor(const short4 &s) { + D3D11_RECT scissor; + scissor.left = s.x; + scissor.top = active.viewport.w - (s.y + s.w); + scissor.right = s.x + s.z; + scissor.bottom = active.viewport.w - s.y; + + osContext->RSSetScissorRects(1, &scissor); + } + + void setDepthTest(bool enable) { + depthTest = enable; + dirtyDepthState = true; + } + + void setDepthWrite(bool enable) { + depthWrite = enable; + dirtyDepthState = true; + } + + void setColorWrite(bool r, bool g, bool b, bool a) { + colorWrite = r && g && b && a; + dirtyBlendState = true; + } + + void setAlphaTest(bool enable) {} + + void setCullMode(int rsMask) { + cullMode = cmNone; + switch (rsMask) { + case RS_CULL_BACK : cullMode = cmBack; break; + case RS_CULL_FRONT : cullMode = cmFront; break; + } + osContext->RSSetState(RS[cullMode]); + } + + void setBlendMode(int rsMask) { + blendMode = bmNone; + switch (rsMask) { + case RS_BLEND_ALPHA : blendMode = bmAlpha; break; + case RS_BLEND_ADD : blendMode = bmAdd; break; + case RS_BLEND_MULT : blendMode = bmMult; break; + case RS_BLEND_PREMULT : blendMode = bmPremult; break; + } + dirtyBlendState = true; + } + + void setViewProj(const mat4 &mView, const mat4 &mProj) {} + + void updateLights(vec4 *lightPos, vec4 *lightColor, int count) { + if (active.shader) { + active.shader->setParam(uLightColor, lightColor[0], count); + active.shader->setParam(uLightPos, lightPos[0], count); + } + } + + void DIP(Mesh *mesh, const MeshRange &range) { + if (Core::active.shader) { + Core::active.shader->validate(); + } + + if (dirtyDepthState) { + osContext->OMSetDepthStencilState(DS[depthTest][depthWrite], 0); + dirtyDepthState = false; + } + + if (dirtyBlendState) { + osContext->OMSetBlendState(BS[colorWrite][blendMode], NULL, 0xFFFFFFFF); + dirtyBlendState = false; + } + + osContext->DrawIndexed(range.iCount, range.iStart, range.vStart); + } + + vec4 copyPixel(int x, int y) { + D3D11_BOX srcBox; + srcBox.left = x; + srcBox.top = y; + srcBox.right = x + 1; + srcBox.bottom = y + 1; + srcBox.front = 0; + srcBox.back = 1; + + ASSERT(Core::active.target); + osContext->CopySubresourceRegion(stagingPixel, 0, 0, 0, 0, Core::active.target->tex2D, 0, &srcBox); + + D3D11_MAPPED_SUBRESOURCE res; + osContext->Map(stagingPixel, 0, D3D11_MAP_READ, 0, &res); + ASSERT(res.pData); + Color32 c = *((Color32*)res.pData); + osContext->Unmap(stagingPixel, 0); + + return vec4(float(c.r), float(c.g), float(c.b), float(c.a)) * (1.0f / 255.0f); + } +} + +#endif \ No newline at end of file diff --git a/src/gapi/d3d8.h b/src/gapi/d3d8.h new file mode 100644 index 00000000..6295733e --- /dev/null +++ b/src/gapi/d3d8.h @@ -0,0 +1,859 @@ +#ifndef H_GAPI_D3D8 +#define H_GAPI_D3D8 + +#include "core.h" + +#define PROFILE_MARKER(title) +#define PROFILE_LABEL(id, name, label) +#define PROFILE_TIMING(time) + +extern LPDIRECT3D8 D3D; +extern LPDIRECT3DDEVICE8 device; +extern D3DPRESENT_PARAMETERS d3dpp; + +#ifdef _DEBUG +void D3DCHECK(HRESULT res) { + if (!FAILED(res)) return; + + LOG("! "); + switch (res) { + case D3DERR_WRONGTEXTUREFORMAT : LOG("D3DERR_WRONGTEXTUREFORMAT"); break; + case D3DERR_UNSUPPORTEDCOLOROPERATION : LOG("D3DERR_UNSUPPORTEDCOLOROPERATION"); break; + case D3DERR_UNSUPPORTEDCOLORARG : LOG("D3DERR_UNSUPPORTEDCOLORARG"); break; + case D3DERR_UNSUPPORTEDALPHAOPERATION : LOG("D3DERR_UNSUPPORTEDALPHAOPERATION"); break; + case D3DERR_UNSUPPORTEDALPHAARG : LOG("D3DERR_UNSUPPORTEDALPHAARG"); break; + case D3DERR_TOOMANYOPERATIONS : LOG("D3DERR_TOOMANYOPERATIONS"); break; + case D3DERR_CONFLICTINGTEXTUREFILTER : LOG("D3DERR_CONFLICTINGTEXTUREFILTER"); break; + case D3DERR_UNSUPPORTEDFACTORVALUE : LOG("D3DERR_UNSUPPORTEDFACTORVALUE"); break; + case D3DERR_CONFLICTINGRENDERSTATE : LOG("D3DERR_CONFLICTINGRENDERSTATE"); break; + case D3DERR_UNSUPPORTEDTEXTUREFILTER : LOG("D3DERR_UNSUPPORTEDTEXTUREFILTER"); break; + case D3DERR_CONFLICTINGTEXTUREPALETTE : LOG("D3DERR_CONFLICTINGTEXTUREPALETTE"); break; + case D3DERR_DRIVERINTERNALERROR : LOG("D3DERR_DRIVERINTERNALERROR"); break; + case D3DERR_NOTFOUND : LOG("D3DERR_NOTFOUND"); break; + case D3DERR_MOREDATA : LOG("D3DERR_MOREDATA"); break; + case D3DERR_DEVICELOST : LOG("D3DERR_DEVICELOST"); break; + case D3DERR_DEVICENOTRESET : LOG("D3DERR_DEVICENOTRESET"); break; + case D3DERR_NOTAVAILABLE : LOG("D3DERR_NOTAVAILABLE"); break; + case D3DERR_OUTOFVIDEOMEMORY : LOG("D3DERR_OUTOFVIDEOMEMORY"); break; + case D3DERR_INVALIDDEVICE : LOG("D3DERR_INVALIDDEVICE"); break; + case D3DERR_INVALIDCALL : LOG("D3DERR_INVALIDCALL"); break; + default : LOG("D3DERR_UNKNOWN"); break; + } + LOG("\n"); + ASSERT(false); +} +#else + #define D3DCHECK(res) res +#endif + +namespace GAPI { + using namespace Core; + + typedef ::Vertex Vertex; + + int cullMode, blendMode; + uint32 clearColor; + bool isFrontCW; + + LPDIRECT3DSURFACE8 defRT, defDS; + + const DWORD vertexDecl[] = + { + D3DVSD_STREAM(0), + D3DVSD_REG( aCoord, D3DVSDT_SHORT4 ), + D3DVSD_REG( aNormal, D3DVSDT_NORMSHORT4 ), + D3DVSD_REG( aTexCoord, D3DVSDT_NORMSHORT4 ), + D3DVSD_REG( aColor, D3DVSDT_PBYTE4 ), + D3DVSD_REG( aLight, D3DVSDT_PBYTE4 ), + D3DVSD_END() + }; + + struct Texture; + struct Mesh; + + struct Resource { + Texture *texture; + Mesh *mesh; + } resList[256]; + int resCount; + + void registerResource(Mesh *mesh) { + resList[resCount].mesh = mesh; + resList[resCount].texture = NULL; + resCount++; + } + + void registerResource(Texture *texture) { + resList[resCount].mesh = NULL; + resList[resCount].texture = texture; + resCount++; + } + + void unregisterResource(void *res) { + for (int i = 0; i < resCount; i++) + if (resList[i].mesh == res || resList[i].texture == res) { + resList[i] = resList[--resCount]; + break; + } + } + +// Shader + #include "shaders/d3d8/shaders.h" + + enum { + USAGE_VS, + USAGE_PS, + }; + + static const struct Binding { + int reg; + int usage; + } bindings[uMAX] = { + { 0, USAGE_VS | USAGE_PS }, // uParam + { 1, USAGE_VS | USAGE_PS }, // uTexParam + { 2, USAGE_VS | USAGE_PS }, // uViewProj + { 6, USAGE_VS | USAGE_PS }, // uBasis + { 70, USAGE_VS | USAGE_PS }, // uLightProj + { 74, USAGE_VS | USAGE_PS }, // uMaterial + { 75, USAGE_VS | USAGE_PS }, // uAmbient + { 81, USAGE_VS | USAGE_PS }, // uFogParams + { 82, USAGE_VS | USAGE_PS }, // uViewPos + { 83, USAGE_VS | USAGE_PS }, // uLightPos + { 87, USAGE_VS | USAGE_PS }, // uLightColor + { 91, USAGE_VS | USAGE_PS }, // uRoomSize + { 92, USAGE_VS | USAGE_PS }, // uPosScale + { 98, USAGE_VS | USAGE_PS }, // uContacts + }; + + struct Shader { + DWORD VS; + DWORD PS; + + Shader() : VS(NULL), PS(NULL) {} + + void init(Core::Pass pass, int type, int *def, int defCount) { + bool underwater = false; + + for (int i = 0; i < defCount; i++) { + if (def[i] == SD_UNDERWATER) { + underwater = true; + } + } + + #define SHADER(S,P) S##_##P + #define SHADER_U(S,P) (underwater ? SHADER(S##_u,P) : SHADER(S,P)) + + const uint8 *vSrc, *fSrc; + switch (pass) { + case passCompose : + switch (type) { + case 0 : vSrc = SHADER_U ( compose_sprite, v ); fSrc = SHADER_U ( compose_sprite, f ); break; + case 1 : vSrc = SHADER ( compose_flash, v ); fSrc = SHADER ( compose_flash, f ); break; + case 2 : vSrc = SHADER_U ( compose_room, v ); fSrc = SHADER_U ( compose_room, f ); break; + case 3 : vSrc = SHADER_U ( compose_entity, v ); fSrc = SHADER_U ( compose_entity, f ); break; + case 4 : vSrc = SHADER ( compose_mirror, v ); fSrc = SHADER ( compose_mirror, f ); break; + default : ASSERT(false); + } + break; + case passShadow : + switch (type) { + case 3 : + case 4 : vSrc = SHADER ( shadow_entity, v ); fSrc = SHADER ( shadow_entity, f ); break; + default : ASSERT(false); + } + break; + case passAmbient : + switch (type) { + case 0 : vSrc = SHADER ( ambient_sprite, v ); fSrc = SHADER ( ambient_sprite, f ); break; + case 1 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER ( ambient_room, f ); break; // TYPE_FLASH (sky) + case 2 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER ( ambient_room, f ); break; + default : ASSERT(false); + } + break; + case passSky : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; // TODO + /* + case passWater : + switch (type) { + case 0 : vSrc = SHADER ( water_drop, v ); fSrc = SHADER ( water_drop, f ); break; + case 1 : vSrc = SHADER ( water_simulate, v ); fSrc = SHADER ( water_simulate, f ); break; + case 2 : vSrc = SHADER ( water_caustics, v ); fSrc = SHADER ( water_caustics, f ); break; + case 3 : vSrc = SHADER ( water_rays, v ); fSrc = SHADER ( water_rays, f ); break; + case 4 : vSrc = SHADER ( water_mask, v ); fSrc = SHADER ( water_mask, f ); break; + case 5 : vSrc = SHADER ( water_compose, v ); fSrc = SHADER ( water_compose, f ); break; + default : ASSERT(false); + } + break; + */ + case passFilter : + switch (type) { + case 0 : vSrc = SHADER ( filter_upscale, v ); fSrc = SHADER ( filter_upscale, f ); break; + case 1 : vSrc = SHADER ( filter_downsample, v ); fSrc = SHADER ( filter_downsample, f ); break; + case 3 : vSrc = SHADER ( filter_grayscale, v ); fSrc = SHADER ( filter_grayscale, f ); break; + case 4 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; + case 5 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; // TODO anaglyph + default : ASSERT(false); + } + break; + case passGUI : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; + default : ASSERT(false); LOG("! wrong pass id\n"); return; + } + + #undef SHADER + #undef SHADER_U + + device->CreateVertexShader(vertexDecl, (DWORD*)vSrc, &VS, 0); + device->CreatePixelShader(&((D3DPIXELSHADERDEF_FILE*)fSrc)->Psd, &PS); + } + + void deinit() { + device->SetVertexShader(0); + device->SetPixelShader(0); + if (VS) device->DeleteVertexShader(VS); + if (PS) device->DeletePixelShader(PS); + } + + void bind() { + if (Core::active.shader != this) { + Core::active.shader = this; + device->SetVertexShader(VS); + device->SetPixelShader(PS); + } + } + + void setConstant(UniformType uType, const float *value, int vectors) { + const Binding &b = bindings[uType]; + if (b.usage | USAGE_VS) device->SetVertexShaderConstant (b.reg, value, vectors); + } + + void setParam(UniformType uType, const vec4 &value, int count = 1) { + setConstant(uType, (float*)&value, count); + } + + void setParam(UniformType uType, const mat4 &value, int count = 1) { + setConstant(uType, (float*)&value, count * 4); + } + }; + +// Texture + struct Texture { + LPDIRECT3DTEXTURE8 tex2D; + LPDIRECT3DCUBETEXTURE8 texCube; + + int width, height, depth, origWidth, origHeight, origDepth; + TexFormat fmt; + uint32 opt; + D3DFORMAT d3dformat; + + Texture(int width, int height, int depth, uint32 opt) : tex2D(NULL), texCube(NULL), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {} + + void init(void *data) { + ASSERT((opt & OPT_PROXY) == 0); + + if (origWidth < 8 || origHeight < 8) { + opt &= ~OPT_MIPMAPS; + } + + bool isDepth = fmt == FMT_DEPTH || fmt == FMT_SHADOW; + bool mipmaps = (opt & OPT_MIPMAPS) != 0; + bool cube = (opt & OPT_CUBEMAP) != 0; + bool dynamic = (opt & OPT_DYNAMIC) != 0; + bool isTarget = (opt & OPT_TARGET) != 0 && !isDepth; + + static const struct FormatDesc { + int bpp; + D3DFORMAT format; + } formats[FMT_MAX] = { + { 8, D3DFMT_L8 }, + { 32, D3DFMT_A8R8G8B8 }, + { 16, D3DFMT_R5G6B5 }, + { 16, D3DFMT_A1R5G5B5 }, + { 64, D3DFMT_A8R8G8B8 }, // TODO + { 32, D3DFMT_A8R8G8B8 }, // TODO + { 16, D3DFMT_LIN_D16 }, + { 16, D3DFMT_LIN_D16 }, + }; + + FormatDesc desc = formats[fmt]; + + uint32 usage = 0; + if (isDepth) usage |= D3DUSAGE_DEPTHSTENCIL; + if (isTarget) usage |= D3DUSAGE_RENDERTARGET; + + D3DPOOL pool = (isTarget || isDepth) ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; + + d3dformat = desc.format; + + if (cube) { + D3DCHECK(device->CreateCubeTexture(width, 1, usage, desc.format, pool, &texCube)); + } else { + D3DCHECK(device->CreateTexture(width, height, mipmaps ? 4 : 1, usage, desc.format, pool, &tex2D)); + if (data && !isTarget) { + update(data); + } + } + + if (pool != D3DPOOL_MANAGED) + registerResource(this); + } + + void deinit() { + unregisterResource(this); + if (tex2D) tex2D->Release(); + if (texCube) texCube->Release(); + } + + void updateLevel(int32 level, void *data) { + int32 bpp; + switch (fmt) { + case FMT_LUMINANCE : bpp = 1; break; + case FMT_RGBA : bpp = 4; break; + default : ASSERT(false); + } + + int32 w = width >> level; + int32 h = height >> level; + int32 ow = origWidth >> level; + int32 oh = origHeight >> level; + + uint8 *buffer = new uint8[w * h * bpp]; + + if (fmt == FMT_RGBA) { + uint8 *src = (uint8*)data; + uint8 *dst = buffer; + + for (int y = 0; y < oh; y++) { + uint8 *ptr = dst; + for (int x = 0; x < ow; x++) { + ptr[0] = src[2]; + ptr[1] = src[1]; + ptr[2] = src[0]; + ptr[3] = src[3]; + ptr += 4; + src += 4; + } + dst += w * 4; + } + } else { + if (w == ow && h == oh) { + memcpy(buffer, data, w * h * bpp); + } else { + uint8 *src = (uint8*)data; + uint8 *dst = buffer; + for (int y = 0; y < oh; y++) { + memcpy(dst, src, ow * bpp); + src += ow * bpp; + dst += w * bpp; + } + } + } + + D3DLOCKED_RECT rect; + D3DCHECK(tex2D->LockRect(level, &rect, NULL, 0)); + XGSwizzleRect(buffer, 0, NULL, rect.pBits, w, h, NULL, 4); + D3DCHECK(tex2D->UnlockRect(level)); + + delete[] buffer; + + if ((opt & OPT_MIPMAPS) && (level < 3)) { + ASSERT(fmt == FMT_RGBA); + + uint8 *mip = new uint8[(ow >> 1) * (oh >> 1) * 4]; + uint8 *dst = mip; + uint8 *src = (uint8*)data; + + for (int32 y = 0; y < oh; y += 2) { + for (int32 x = 0; x < ow; x += 2) { + *dst++ = (src[0] + src[4] + src[ow * 4] + src[ow * 4 + 4]) >> 2; src++; // R + *dst++ = (src[0] + src[4] + src[ow * 4] + src[ow * 4 + 4]) >> 2; src++; // G + *dst++ = (src[0] + src[4] + src[ow * 4] + src[ow * 4 + 4]) >> 2; src++; // B + *dst++ = (src[0] + src[4] + src[ow * 4] + src[ow * 4 + 4]) >> 2; src++; // A + src += 4; + } + src += ow * 4; + } + + updateLevel(level + 1, mip); + + delete[] mip; + } + } + + void update(void *data) { + updateLevel(0, data); + } + + void bind(int sampler) { + if (sampler > 3) return; // TODO + + if (opt & OPT_PROXY) return; + ASSERT(tex2D || texCube); + + if (Core::active.textures[sampler] != this) { + Core::active.textures[sampler] = this; + if (tex2D) { + device->SetTexture(sampler, tex2D); + /* TODO unsupported + if (opt & OPT_VERTEX) { + device->SetTexture(D3DVERTEXTEXTURESAMPLER0 + sampler, tex2D); + }*/ + } else if (texCube) { + device->SetTexture(sampler, texCube); + } + + bool filter = (Core::settings.detail.filter > Core::Settings::LOW) && !(opt & OPT_NEAREST); + bool mipmaps = (Core::settings.detail.filter > Core::Settings::LOW) && (opt & OPT_MIPMAPS); + bool aniso = (Core::settings.detail.filter > Core::Settings::MEDIUM) && mipmaps && (Core::support.maxAniso > 0); + + device->SetTextureStageState(sampler, D3DTSS_ADDRESSU, (opt & OPT_REPEAT) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); + device->SetTextureStageState(sampler, D3DTSS_ADDRESSV, (opt & OPT_REPEAT) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); + + if (aniso) { + device->SetTextureStageState(sampler, D3DTSS_MINFILTER, D3DTEXF_ANISOTROPIC); + device->SetTextureStageState(sampler, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); + device->SetTextureStageState(sampler, D3DTSS_MIPFILTER, D3DTEXF_NONE); + device->SetTextureStageState(sampler, D3DTSS_MAXANISOTROPY, support.maxAniso); + } else { + device->SetTextureStageState(sampler, D3DTSS_MINFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); + device->SetTextureStageState(sampler, D3DTSS_MAGFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); + device->SetTextureStageState(sampler, D3DTSS_MIPFILTER, mipmaps ? (filter ? D3DTEXF_LINEAR : D3DTEXF_POINT) : D3DTEXF_NONE); + device->SetTextureStageState(sampler, D3DTSS_MAXANISOTROPY, 1); + } + } + } + + void unbind(int sampler) { + if (Core::active.textures[sampler]) { + Core::active.textures[sampler] = NULL; + device->SetTexture(sampler, NULL); + } + } + + void generateMipMap() {} + + void setFilterQuality(int value) {} + }; + +// Mesh + struct Mesh { + LPDIRECT3DINDEXBUFFER8 IB; + LPDIRECT3DVERTEXBUFFER8 VB; + + int iCount; + int vCount; + bool dynamic; + + Mesh(bool dynamic) : IB(NULL), VB(NULL), dynamic(dynamic) {} + + void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) { + this->iCount = iCount; + this->vCount = vCount; + ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); + + uint32 usage = D3DUSAGE_WRITEONLY | (dynamic ? D3DUSAGE_DYNAMIC : 0); + D3DPOOL pool = dynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; + + D3DCHECK(device->CreateIndexBuffer (iCount * sizeof(Index), usage, D3DFMT_INDEX16, pool, &IB)); + D3DCHECK(device->CreateVertexBuffer (vCount * sizeof(Vertex), usage, D3DFMT_UNKNOWN, pool, &VB)); + + update(indices, iCount, vertices, vCount); + + if (pool != D3DPOOL_MANAGED) + registerResource(this); + } + + void deinit() { + unregisterResource(this); + IB->Release(); + VB->Release(); + } + + void update(Index *indices, int iCount, ::Vertex *vertices, int vCount) { + ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); + + void* ptr; + int size; + + if (indices && iCount) { + size = iCount * sizeof(indices[0]); + D3DCHECK(IB->Lock(0, 0, (BYTE**)&ptr, 0)); + memcpy(ptr, indices, size); + D3DCHECK(IB->Unlock()); + } + + if (vertices && vCount) { + size = vCount * sizeof(vertices[0]); + D3DCHECK(VB->Lock(0, 0, (BYTE**)&ptr, 0)); + memcpy(ptr, vertices, size); + D3DCHECK(VB->Unlock()); + } + } + + void bind(const MeshRange &range) const { + device->SetIndices(IB, range.vStart); + device->SetStreamSource(0, VB, sizeof(Vertex)); + } + + void initNextRange(MeshRange &range, int &aIndex) const { + range.aIndex = -1; + } + }; + +// GLuint FBO, defaultFBO; + struct RenderTargetCache { + int count; + struct Item { + LPDIRECT3DSURFACE8 surface; + int width; + int height; + } items[MAX_RENDER_BUFFERS]; + } rtCache[2]; + + void init() { + memset(rtCache, 0, sizeof(rtCache)); + isFrontCW = true; + + D3DADAPTER_IDENTIFIER8 adapterInfo; + D3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &adapterInfo); + LOG("Vendor : %s\n", adapterInfo.Description); + LOG("Renderer : Direct3D 8\n"); + + support.maxAniso = 4; + support.maxVectors = 16; + support.shaderBinary = false; + support.VAO = false; // SHADOW_COLOR + support.depthTexture = false; // SHADOW_DEPTH + support.shadowSampler = false; + support.discardFrame = false; + support.texNPOT = false; + support.texRG = false; + support.texBorder = false; + support.colorFloat = false; + support.colorHalf = false; + support.texFloatLinear = false; + support.texFloat = false; + support.texHalfLinear = false; + support.texHalf = false; + + #ifdef PROFILE + support.profMarker = false; + support.profTiming = false; + #endif + + defRT = defDS = NULL; + + const float factors[] = { + 1.0f, -19.555555555556f, 60.444444444444f, -56.888888888889f, // uCosCoeff + 0.5f, 0.5f/PI, 0.75f, 1.0f/1024.0f, // uAngles + 0.0f, 0.5f, 1.0f, 2.0f, + 0.6f, 0.9f, 0.9f, 32767.0f + }; + device->SetVertexShaderConstant(92, factors, 4); + + device->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_EXP); + } + + void deinit() { + if (defRT) defRT->Release(); + if (defDS) defDS->Release(); + } + + void resetDevice() { + // release dummy RTs + for (int i = 0; i < 2; i++) { + RenderTargetCache &cache = rtCache[i]; + for (int j = 0; j < cache.count; j++) + cache.items[j].surface->Release(); + cache.count = 0; + } + + // release texture RTs + int tmpCount = resCount; + Resource tmpList[256]; + memcpy(tmpList, resList, sizeof(Resource) * tmpCount); + + for (int i = 0; i < tmpCount; i++) { + Resource &res = tmpList[i]; + if (res.mesh) + res.mesh->deinit(); + else + res.texture->deinit(); + } + + if (defRT) defRT->Release(); + if (defDS) defDS->Release(); + + D3DCHECK(device->Reset(&d3dpp)); + device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &defRT); + device->GetDepthStencilSurface(&defDS); + + // reinit texture RTs + for (int i = 0; i < tmpCount; i++) { + Resource &res = tmpList[i]; + if (res.mesh) + res.mesh->init(NULL, res.mesh->iCount, NULL, res.mesh->vCount, 0); + else + res.texture->init(NULL); + } + } + + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_ZERO_POS; + } + + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; + } + + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; + } + + bool beginFrame() { + if (defRT == NULL) device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &defRT); + if (defDS == NULL) device->GetDepthStencilSurface(&defDS); + + device->BeginScene(); + return true; + } + + void endFrame() { + device->EndScene(); + } + + void resetState() { + device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); + device->SetRenderState(D3DRS_LIGHTING, FALSE); + } + + int cacheRenderTarget(bool depth, int width, int height) { + RenderTargetCache &cache = rtCache[depth]; + + for (int i = 0; i < cache.count; i++) + if (cache.items[i].width == width && cache.items[i].height == height) + return i; + + ASSERT(cache.count < MAX_RENDER_BUFFERS); + + RenderTargetCache::Item &item = cache.items[cache.count]; + item.width = width; + item.height = height; + + if (depth) + device->CreateDepthStencilSurface(width, height, D3DFMT_LIN_D16, D3DMULTISAMPLE_NONE, &item.surface); + else + device->CreateRenderTarget(width, height, D3DFMT_LIN_R5G6B5, D3DMULTISAMPLE_NONE, false, &item.surface); + + return cache.count++; + } + + void bindTarget(Texture *target, int face) { + if (!target) { // may be a null + D3DCHECK(device->SetRenderTarget(defRT, defDS)); + } else { + ASSERT(target->opt & OPT_TARGET); + + LPDIRECT3DSURFACE8 surface; + + bool depth = target->fmt == FMT_DEPTH || target->fmt == FMT_SHADOW; + + if (target->tex2D) { + D3DCHECK(target->tex2D->GetSurfaceLevel(0, &surface)); + } else if (target->texCube) { + D3DCHECK(target->texCube->GetCubeMapSurface(D3DCUBEMAP_FACES(D3DCUBEMAP_FACE_POSITIVE_X + face), 0, &surface)); + } + + int rtIndex = cacheRenderTarget(!depth, target->width, target->height); + + if (depth) { + D3DCHECK(device->SetRenderTarget(rtCache[false].items[rtIndex].surface, surface)); + } else { + D3DCHECK(device->SetRenderTarget(surface, rtCache[true].items[rtIndex].surface)); + } + + surface->Release(); + } + + Core::active.viewport = short4(0, 0, 0, 0); // forcing viewport reset + Core::active.scissor = short4(0, 0, 0, 0); + } + + void discardTarget(bool color, bool depth) {} + + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { + ASSERT(dst && dst->tex2D); + + LPDIRECT3DSURFACE8 surface; + dst->tex2D->GetSurfaceLevel(0, &surface); + + RECT srcRect = { x, y, x + width, y + height }, + dstRect = { xOffset, yOffset, xOffset + width, yOffset + height }; + + //device->StretchRect(defRT, &srcRect, surface, &dstRect, D3DTEXF_POINT); TODO + + surface->Release(); + } + + void setVSync(bool enable) { + // d3dpp.FullScreen_PresentationInterval = enable ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + // GAPI::resetDevice(); + } + + void waitVBlank() {} + + void clear(bool color, bool depth) { + uint32 flags = (color ? D3DCLEAR_TARGET : 0) | (depth ? (D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL) : 0); + if (flags) { + device->Clear(0, NULL, flags, clearColor, 1.0f, 0); + } + } + + void setClearColor(const vec4 &color) { + clearColor = (int(color.x * 255) << 16) | + (int(color.y * 255) << 8 ) | + (int(color.z * 255) ) | + (int(color.w * 255) << 24); + } + + void setViewport(const short4 &v) { + D3DVIEWPORT8 viewport; + viewport.X = v.x; + viewport.Y = v.y; + viewport.Width = v.z; + viewport.Height = v.w; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + device->SetViewport(&viewport); + } + + void setScissor(const short4 &s) { + D3DRECT scissor; + scissor.x1 = s.x; + scissor.y1 = active.viewport.w - (s.y + s.w); + scissor.x2 = s.x + s.z; + scissor.y2 = active.viewport.w - s.y; + + device->SetScissors(1, FALSE, &scissor); + } + + void setDepthTest(bool enable) { + device->SetRenderState(D3DRS_ZENABLE, enable ? D3DZB_TRUE : D3DZB_FALSE); + } + + void setDepthWrite(bool enable) { + device->SetRenderState(D3DRS_ZWRITEENABLE, enable ? TRUE : FALSE); + } + + void setColorWrite(bool r, bool g, bool b, bool a) { + device->SetRenderState(D3DRS_COLORWRITEENABLE, + (r ? D3DCOLORWRITEENABLE_RED : 0) | + (g ? D3DCOLORWRITEENABLE_GREEN : 0) | + (b ? D3DCOLORWRITEENABLE_BLUE : 0) | + (a ? D3DCOLORWRITEENABLE_ALPHA : 0)); + } + + void setAlphaTest(bool enable) { + device->SetTextureStageState(0, D3DTSS_ALPHAKILL, enable ? D3DTALPHAKILL_ENABLE : D3DTALPHAKILL_DISABLE); + } + + void setCullMode(int rsMask) { + cullMode = rsMask; + switch (rsMask) { + case RS_CULL_BACK : device->SetRenderState(D3DRS_CULLMODE, isFrontCW ? D3DCULL_CW : D3DCULL_CCW); break; + case RS_CULL_FRONT : device->SetRenderState(D3DRS_CULLMODE, isFrontCW ? D3DCULL_CCW : D3DCULL_CW); break; + default : device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + } + } + + void setFrontFace(bool cw) { + isFrontCW = cw; + setCullMode(cullMode); + } + + void setBlendMode(int rsMask) { + blendMode = rsMask; + switch (rsMask) { + case RS_BLEND_ALPHA : + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + break; + case RS_BLEND_ADD : + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); + break; + case RS_BLEND_MULT : + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR); + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO); + break; + case RS_BLEND_PREMULT : + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + break; + default : + device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + return; + } + device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + } + + void setViewProj(const mat4 &mView, const mat4 &mProj) { + device->SetTransform(D3DTS_PROJECTION, (D3DXMATRIX*)&mProj); + } + + void updateLights(vec4 *lightPos, vec4 *lightColor, int count) { + if (active.shader) { + active.shader->setParam(uLightColor, lightColor[0], count); + active.shader->setParam(uLightPos, lightPos[0], count); + } + } + + void setFog(const vec4 ¶ms) { + if (params.w > 0.0f) { + device->SetRenderState(D3DRS_FOGENABLE, TRUE); + + DWORD fogColor = 0xFF000000 + | (DWORD(clamp(params.z * 255.0f, 0.0f, 255.0f)) << 0) + | (DWORD(clamp(params.y * 255.0f, 0.0f, 255.0f)) << 8) + | (DWORD(clamp(params.x * 255.0f, 0.0f, 255.0f)) << 16); + device->SetRenderState(D3DRS_FOGCOLOR, fogColor); + + ASSERT(Core::active.shader); + Core::active.shader->setParam(uFogParams, params); // color.rgb, factor + } else { + device->SetRenderState(D3DRS_FOGENABLE, FALSE); + } + } + + void DIP(Mesh *mesh, const MeshRange &range) { + device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, mesh->vCount, range.iStart, range.iCount / 3); + } + + vec4 copyPixel(int x, int y) { + GAPI::Texture *t = Core::active.target; + ASSERT(t && t->tex2D); +/* + LPDIRECT3DSURFACE8 surface, texSurface; + D3DCHECK(t->tex2D->GetSurfaceLevel(0, &texSurface)); + D3DCHECK(device->CreateOffscreenPlainSurface(t->width, t->height, t->d3dformat, D3DPOOL_SYSTEMMEM, &surface, NULL)); + D3DCHECK(device->GetRenderTargetData(texSurface, surface)); + + RECT r = { x, y, x + 1, y + 1 }; + D3DLOCKED_RECT rect; + surface->LockRect(&rect, &r, D3DLOCK_READONLY); + ubyte4 c = *((ubyte4*)rect.pBits); + surface->UnlockRect(); + + texSurface->Release(); + surface->Release(); + + return vec4(float(c.z), float(c.y), float(c.x), float(c.w)) * (1.0f / 255.0f); + */ + return vec4(1.0f); + } +} + +#endif \ No newline at end of file diff --git a/src/gapi_d3d9.h b/src/gapi/d3d9.h similarity index 75% rename from src/gapi_d3d9.h rename to src/gapi/d3d9.h index 70e6cfb6..16816118 100644 --- a/src/gapi_d3d9.h +++ b/src/gapi/d3d9.h @@ -50,19 +50,6 @@ void D3DCHECK(HRESULT res) { #endif namespace GAPI { - #include "shaders/d3d9/compose_vs.h" - #include "shaders/d3d9/compose_ps.h" - #include "shaders/d3d9/shadow_vs.h" - #include "shaders/d3d9/shadow_ps.h" - #include "shaders/d3d9/ambient_vs.h" - #include "shaders/d3d9/ambient_ps.h" - #include "shaders/d3d9/water_vs.h" - #include "shaders/d3d9/water_ps.h" - #include "shaders/d3d9/filter_vs.h" - #include "shaders/d3d9/filter_ps.h" - #include "shaders/d3d9/gui_vs.h" - #include "shaders/d3d9/gui_ps.h" - using namespace Core; typedef ::Vertex Vertex; @@ -104,6 +91,8 @@ namespace GAPI { } // Shader + #include "shaders/d3d9/shaders.h" + enum { USAGE_VS, USAGE_PS, @@ -113,7 +102,6 @@ namespace GAPI { int reg; int usage; } bindings[uMAX] = { - { 0, USAGE_VS | USAGE_PS }, // uFlags { 0, USAGE_VS | USAGE_PS }, // uParam { 1, USAGE_VS | USAGE_PS }, // uTexParam { 2, USAGE_VS | USAGE_PS }, // uViewProj @@ -139,34 +127,87 @@ namespace GAPI { Shader() : VS(NULL), PS(NULL) {} void init(Core::Pass pass, int type, int *def, int defCount) { - const BYTE *vSrc, *pSrc; - switch (pass) { - case Core::passCompose : vSrc = COMPOSE_VS; pSrc = COMPOSE_PS; break; - case Core::passShadow : vSrc = SHADOW_VS; pSrc = SHADOW_PS; break; - case Core::passAmbient : vSrc = AMBIENT_VS; pSrc = AMBIENT_PS; break; - case Core::passWater : vSrc = WATER_VS; pSrc = WATER_PS; break; - case Core::passFilter : vSrc = FILTER_VS; pSrc = FILTER_PS; break; - case Core::passGUI : vSrc = GUI_VS; pSrc = GUI_PS; break; - default : ASSERT(false); LOG("! wrong pass id\n"); return; - } - memset(flags, 0, sizeof(flags)); flags[type] = TRUE; + bool underwater = false; + bool alphatest = false; + for (int i = 0; i < defCount; i++) { switch (def[i]) { - case SD_UNDERWATER : flags[ 5] = TRUE; break; - case SD_ALPHA_TEST : flags[ 6] = TRUE; break; - case SD_CLIP_PLANE : flags[ 7] = TRUE; break; - case SD_OPT_AMBIENT : flags[ 8] = TRUE; break; - case SD_OPT_SHADOW : flags[ 9] = TRUE; break; - case SD_OPT_CONTACT : flags[10] = TRUE; break; - case SD_OPT_CAUSTICS : flags[11] = TRUE; break; + case SD_UNDERWATER : underwater = true; break; + case SD_ALPHA_TEST : alphatest = true; break; + case SD_OPT_AMBIENT : flags[0] = TRUE; break; + case SD_OPT_SHADOW : flags[1] = TRUE; break; + case SD_OPT_CONTACT : flags[2] = TRUE; break; + case SD_OPT_CAUSTICS : flags[3] = TRUE; break; } } + + #define SHADER(S,P) S##_##P + #define SHADER_A(S,P) (alphatest ? SHADER(S##_a,P) : SHADER(S,P)) + #define SHADER_U(S,P) (underwater ? SHADER(S##_u,P) : SHADER(S,P)) + #define SHADER_AU(S,P) ((underwater && alphatest) ? SHADER(S##_au,P) : (alphatest ? SHADER(S##_a,P) : SHADER_U(S,P))) + + const uint8 *vSrc, *fSrc; + switch (pass) { + case passCompose : + switch (type) { + case 0 : vSrc = SHADER_U ( compose_sprite, v ); fSrc = SHADER_AU ( compose_sprite, f ); break; + case 1 : vSrc = SHADER ( compose_flash, v ); fSrc = SHADER ( compose_flash, f ); break; + case 2 : vSrc = SHADER_U ( compose_room, v ); fSrc = SHADER_AU ( compose_room, f ); break; + case 3 : vSrc = SHADER_U ( compose_entity, v ); fSrc = SHADER_AU ( compose_entity, f ); break; + case 4 : vSrc = SHADER ( compose_mirror, v ); fSrc = SHADER ( compose_mirror, f ); break; + default : ASSERT(false); + } + break; + case passShadow : + switch (type) { + case 3 : + case 4 : vSrc = SHADER ( shadow_entity, v ); fSrc = SHADER ( shadow_entity, f ); break; + default : ASSERT(false); + } + break; + case passAmbient : + switch (type) { + case 0 : vSrc = SHADER ( ambient_sprite, v ); fSrc = SHADER_A ( ambient_sprite, f ); break; + case 1 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER ( ambient_room, f ); break; // TYPE_FLASH (sky) + case 2 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER_A ( ambient_room, f ); break; + default : ASSERT(false); + } + break; + case passSky : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; // TODO + case passWater : + switch (type) { + case 0 : vSrc = SHADER ( water_drop, v ); fSrc = SHADER ( water_drop, f ); break; + case 1 : vSrc = SHADER ( water_simulate, v ); fSrc = SHADER ( water_simulate, f ); break; + case 2 : vSrc = SHADER ( water_caustics, v ); fSrc = SHADER ( water_caustics, f ); break; + case 3 : vSrc = SHADER ( water_rays, v ); fSrc = SHADER ( water_rays, f ); break; + case 4 : vSrc = SHADER ( water_mask, v ); fSrc = SHADER ( water_mask, f ); break; + case 5 : vSrc = SHADER ( water_compose, v ); fSrc = SHADER ( water_compose, f ); break; + default : ASSERT(false); + } + break; + case passFilter : + switch (type) { + case 0 : vSrc = SHADER ( filter_upscale, v ); fSrc = SHADER ( filter_upscale, f ); break; + case 1 : vSrc = SHADER ( filter_downsample, v ); fSrc = SHADER ( filter_downsample, f ); break; + case 3 : vSrc = SHADER ( filter_grayscale, v ); fSrc = SHADER ( filter_grayscale, f ); break; + case 4 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; + case 5 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; // TODO anaglyph + default : ASSERT(false); + } + break; + case passGUI : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; + default : ASSERT(false); LOG("! wrong pass id\n"); return; + } + + #undef SHADER_A + #undef SHADER_U + #undef SHADER_AU device->CreateVertexShader ((DWORD*)vSrc, &VS); - device->CreatePixelShader ((DWORD*)pSrc, &PS); + device->CreatePixelShader ((DWORD*)fSrc, &PS); } void deinit() { @@ -198,10 +239,6 @@ namespace GAPI { void setParam(UniformType uType, const mat4 &value, int count = 1) { setConstant(uType, (float*)&value, count * 4); } - - void setParam(UniformType uType, const Basis &value, int count = 1) { - setConstant(uType, (float*)&value, count * 2); - } }; // Texture @@ -209,11 +246,12 @@ namespace GAPI { LPDIRECT3DTEXTURE9 tex2D; LPDIRECT3DCUBETEXTURE9 texCube; - int width, height, origWidth, origHeight; + int width, height, depth, origWidth, origHeight, origDepth; TexFormat fmt; uint32 opt; + D3DFORMAT d3dformat; - Texture(int width, int height, uint32 opt) : tex2D(NULL), texCube(NULL), width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {} + Texture(int width, int height, int depth, uint32 opt) : tex2D(NULL), texCube(NULL), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {} void init(void *data) { ASSERT((opt & OPT_PROXY) == 0); @@ -227,14 +265,14 @@ namespace GAPI { int bpp; D3DFORMAT format; } formats[FMT_MAX] = { - { 8, D3DFMT_L8 }, - { 32, D3DFMT_A8R8G8B8 }, - { 16, D3DFMT_R5G6B5 }, - { 16, D3DFMT_A1R5G5B5 }, - { 128, D3DFMT_A32B32G32R32F }, - { 64, D3DFMT_A16B16G16R16F }, - { 16, D3DFMT_D16 }, - { 16, D3DFMT_D24X8 }, + { 8, D3DFMT_L8 }, + { 32, D3DFMT_A8R8G8B8 }, + { 16, D3DFMT_R5G6B5 }, + { 16, D3DFMT_A1R5G5B5 }, + { 64, D3DFMT_G32R32F }, + { 32, D3DFMT_G16R16F }, + { 16, D3DFMT_D16 }, + { 16, D3DFMT_D24X8 }, }; FormatDesc desc = formats[fmt]; @@ -246,6 +284,8 @@ namespace GAPI { D3DPOOL pool = (isTarget || isDepth) ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; + d3dformat = desc.format; + if (cube) { D3DCHECK(device->CreateCubeTexture(width, 1, usage, desc.format, pool, &texCube, NULL)); } else { @@ -253,7 +293,22 @@ namespace GAPI { if (data && !isTarget) { D3DLOCKED_RECT rect; D3DCHECK(tex2D->LockRect(0, &rect, NULL, 0)); - memcpy(rect.pBits, data, width * height * (desc.bpp / 8)); + if (fmt == FMT_RGBA) { + uint8 *dst = (uint8*)rect.pBits; + uint8 *src = (uint8*)data; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + dst[0] = src[2]; + dst[1] = src[1]; + dst[2] = src[0]; + dst[3] = src[3]; + dst += 4; + src += 4; + } + } + } else { + memcpy(rect.pBits, data, width * height * (desc.bpp / 8)); + } D3DCHECK(tex2D->UnlockRect(0)); } } @@ -291,8 +346,9 @@ namespace GAPI { if (opt & OPT_VERTEX) { device->SetTexture(D3DVERTEXTEXTURESAMPLER0 + sampler, tex2D); } - } else if (texCube) + } else if (texCube) { device->SetTexture(sampler, texCube); + } bool filter = (Core::settings.detail.filter > Core::Settings::LOW) && !(opt & OPT_NEAREST); bool mipmaps = (Core::settings.detail.filter > Core::Settings::MEDIUM) && (opt & OPT_MIPMAPS); @@ -344,7 +400,7 @@ namespace GAPI { uint32 usage = D3DUSAGE_WRITEONLY | (dynamic ? D3DUSAGE_DYNAMIC : 0); D3DPOOL pool = dynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; - D3DCHECK(device->CreateIndexBuffer (iCount * sizeof(Index), usage, D3DFMT_INDEX16, pool, &IB, NULL)); + D3DCHECK(device->CreateIndexBuffer (iCount * sizeof(Index), usage, sizeof(Index) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, pool, &IB, NULL)); D3DCHECK(device->CreateVertexBuffer (vCount * sizeof(Vertex), usage, D3DFMT_UNKNOWN, pool, &VB, NULL)); update(indices, iCount, vertices, vCount); @@ -424,7 +480,6 @@ namespace GAPI { support.texFloat = true; support.texHalfLinear = true; support.texHalf = true; - support.clipDist = false; #ifdef PROFILE support.profMarker = false; @@ -435,8 +490,8 @@ namespace GAPI { {0, OFFSETOF(Vertex, coord), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, // aCoord {0, OFFSETOF(Vertex, normal), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, // aNormal {0, OFFSETOF(Vertex, texCoord), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, // aTexCoord - {0, OFFSETOF(Vertex, color), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, // aColor - {0, OFFSETOF(Vertex, light), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, // aLight + {0, OFFSETOF(Vertex, color), D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, // aColor + {0, OFFSETOF(Vertex, light), D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, // aLight D3DDECL_END() }; @@ -477,7 +532,6 @@ namespace GAPI { if (defDS) defDS->Release(); D3DCHECK(device->Reset(&d3dpp)); - device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &defRT); device->GetDepthStencilSurface(&defDS); @@ -491,12 +545,20 @@ namespace GAPI { } } + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_ZERO_POS; + } + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { - return mat4(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar); + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; } - mat4 perspective(float fov, float aspect, float znear, float zfar) { - return mat4(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar); + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; } bool beginFrame() { @@ -583,7 +645,8 @@ namespace GAPI { surface->Release(); } - Core::active.viewport = Viewport(0, 0, 0, 0); // forcing viewport reset + Core::active.viewport = short4(0, 0, 0, 0); // forcing viewport reset + Core::active.scissor = short4(0, 0, 0, 0); } void discardTarget(bool color, bool depth) {} @@ -621,23 +684,26 @@ namespace GAPI { (int(color.w * 255) << 24); } - void setViewport(const Viewport &vp) { - D3DVIEWPORT9 dv; - dv.X = vp.x; - dv.Y = vp.y; - dv.Width = vp.width; - dv.Height = vp.height; - dv.MinZ = 0.0f; - dv.MaxZ = 1.0f; - - RECT ds; - ds.left = vp.x; - ds.top = vp.y; - ds.right = vp.x + vp.width; - ds.bottom = vp.y + vp.height; - - device->SetViewport(&dv); - device->SetScissorRect(&ds); + void setViewport(const short4 &v) { + D3DVIEWPORT9 viewport; + viewport.X = v.x; + viewport.Y = v.y; + viewport.Width = v.z; + viewport.Height = v.w; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + device->SetViewport(&viewport); + } + + void setScissor(const short4 &s) { + RECT scissor; + scissor.left = s.x; + scissor.top = active.viewport.w - (s.y + s.w); + scissor.right = s.x + s.z; + scissor.bottom = active.viewport.w - s.y; + + device->SetScissorRect(&scissor); } void setDepthTest(bool enable) { @@ -712,7 +778,7 @@ namespace GAPI { LPDIRECT3DSURFACE9 surface, texSurface; D3DCHECK(t->tex2D->GetSurfaceLevel(0, &texSurface)); - D3DCHECK(device->CreateOffscreenPlainSurface(t->width, t->height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL)); + D3DCHECK(device->CreateOffscreenPlainSurface(t->width, t->height, t->d3dformat, D3DPOOL_SYSTEMMEM, &surface, NULL)); D3DCHECK(device->GetRenderTargetData(texSurface, surface)); RECT r = { x, y, x + 1, y + 1 }; @@ -726,22 +792,6 @@ namespace GAPI { return vec4(float(c.z), float(c.y), float(c.x), float(c.w)) * (1.0f / 255.0f); } - - void initPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso && pso->data == NULL); - pso->data = &pso; - } - - void deinitPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso->data != NULL); - pso->data = NULL; - } - - void bindPSO(const PSO *pso) { - // - } } #endif \ No newline at end of file diff --git a/src/gapi_gl.h b/src/gapi/gl.h similarity index 55% rename from src/gapi_gl.h rename to src/gapi/gl.h index d7036809..a3e5e9cb 100644 --- a/src/gapi_gl.h +++ b/src/gapi/gl.h @@ -3,43 +3,184 @@ #include "core.h" -//#define _DEBUG_SHADERS +#if defined(_DEBUG) || defined(PROFILE) + //#define _DEBUG_SHADERS "../../OpenLara/src/shaders/" +#endif #ifdef _OS_WIN #include #include + #include #elif _OS_ANDROID #include +// #define _GAPI_GLES2 // for old devices + + #ifdef _GAPI_GLES2 + #include + #include + + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE_BORDER_COLOR 0x1004 + + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + + #undef GL_RG + #undef GL_RG32F + #undef GL_RG16F + #undef GL_RGBA32F + #undef GL_RGBA16F + #undef GL_HALF_FLOAT + + #define GL_RG GL_RGBA + #define GL_RGBA32F GL_RGBA + #define GL_RGBA16F GL_RGBA + #define GL_RG32F GL_RGBA + #define GL_RG16F GL_RGBA + #define GL_HALF_FLOAT GL_HALF_FLOAT_OES + + #define GL_TEXTURE_3D 0 + #define GL_TEXTURE_WRAP_R 0 + #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES + #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES + + #define glTexImage3D(...) 0 + + #define glGenVertexArrays(...) + #define glDeleteVertexArrays(...) + #define glBindVertexArray(...) + + #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES + #define glGetProgramBinary(...) + #define glProgramBinary(...) + + #define glInvalidateFramebuffer(...) + #else + #include + #include + #include + #endif + +#elif defined(__SDL2__) + #include + + #if defined(_GAPI_GLES) // Default in SDL2 is GLES3. If we want GLES2, pass -D_GAPI_GLES2. + #if defined (_GAPI_GLES2) // We want GLES2 on SDL2 + #include + #include + + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE_BORDER_COLOR 0x1004 + + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + + #define GL_NUM_EXTENSIONS 0x821D + + #undef GL_RG + #undef GL_RG32F + #undef GL_RG16F + #undef GL_RGBA32F + #undef GL_RGBA16F + #undef GL_HALF_FLOAT + + #define GL_RG GL_RGBA + #define GL_RGBA32F GL_RGBA + #define GL_RGBA16F GL_RGBA + #define GL_RG32F GL_RGBA + #define GL_RG16F GL_RGBA + #define GL_HALF_FLOAT GL_HALF_FLOAT_OES + + #define GL_R8 GL_R8_EXT + #define GL_RED GL_RED_EXT + + #define GL_TEXTURE_WRAP_R 0 + #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES + #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES + //We need this on GLES2, too. + #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE + + #define glTexImage3D(...) 0 + #ifndef GL_TEXTURE_3D // WUUUUUT!? + #define GL_TEXTURE_3D GL_TEXTURE_3D_OES + #endif + + #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES + #else // We want GLES3 on SDL2 + #include + #include + #include + #endif //GAPI_GLES2 + + // These are needed for both GLES2 and GLES3 on SDL2 + #define glGenVertexArrays(...) + #define glDeleteVertexArrays(...) + #define glBindVertexArray(...) + #define glGetProgramBinary(...) + #define glProgramBinary(...) + + #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC + #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC + #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC + #define PFNGLGETPROGRAMBINARYPROC PFNGLGETPROGRAMBINARYOESPROC + #define PFNGLPROGRAMBINARYPROC PFNGLPROGRAMBINARYOESPROC + + #else // We want OpenGL on SDL2, not GLES + #include + #include + #endif + +#elif defined(_OS_PSC) + #include + #include + extern EGLDisplay display; +#elif defined(_OS_GCW0) #include #include - #define GL_CLAMP_TO_BORDER 0x812D - #define GL_TEXTURE_BORDER_COLOR 0x1004 + #include + #include + #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE + #define GL_TEXTURE_3D 0 + #define GL_TEXTURE_WRAP_R 0 #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_REF_TO_TEXTURE 0x884E - #define GL_RGBA16F 0x881A - #define GL_RGBA32F 0x8814 - #define GL_HALF_FLOAT 0x140B - - #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES - #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES + #undef GL_RG + #undef GL_RG32F + #undef GL_RG16F + #undef GL_RGBA32F + #undef GL_RGBA16F + #undef GL_HALF_FLOAT - #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC - #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC - #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC - #define glGenVertexArrays glGenVertexArraysOES - #define glDeleteVertexArrays glDeleteVertexArraysOES - #define glBindVertexArray glBindVertexArrayOES + #define GL_RG GL_RGBA + #define GL_RGBA32F GL_RGBA + #define GL_RGBA16F GL_RGBA + #define GL_RG32F GL_RGBA + #define GL_RG16F GL_RGBA + #define GL_HALF_FLOAT GL_HALF_FLOAT_OES - #define PFNGLGETPROGRAMBINARYPROC PFNGLGETPROGRAMBINARYOESPROC - #define PFNGLPROGRAMBINARYPROC PFNGLPROGRAMBINARYOESPROC - #define glGetProgramBinary glGetProgramBinaryOES - #define glProgramBinary glProgramBinaryOES + #define glTexImage3D(...) 0 #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES + + #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC + #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC + #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC + #define PFNGLGETPROGRAMBINARYPROC PFNGLGETPROGRAMBINARYOESPROC + #define PFNGLPROGRAMBINARYPROC PFNGLPROGRAMBINARYOESPROC + + #define glGenVertexArrays glGenVertexArraysOES + #define glDeleteVertexArrays glDeleteVertexArraysOES + #define glBindVertexArray glBindVertexArrayOES + #define glGetProgramBinary glGetProgramBinaryOES + #define glProgramBinary glProgramBinaryOES + + extern EGLDisplay display; #elif defined(_OS_RPI) || defined(_OS_CLOVER) #include #include @@ -48,22 +189,32 @@ #define GL_CLAMP_TO_BORDER 0x812D #define GL_TEXTURE_BORDER_COLOR 0x1004 - + #define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_REF_TO_TEXTURE 0x884E + #undef GL_RG + #undef GL_RG32F + #undef GL_RG16F #undef GL_RGBA32F #undef GL_RGBA16F #undef GL_HALF_FLOAT + #define GL_RG GL_RGBA #define GL_RGBA32F GL_RGBA #define GL_RGBA16F GL_RGBA + #define GL_RG32F GL_RGBA + #define GL_RG16F GL_RGBA #define GL_HALF_FLOAT GL_HALF_FLOAT_OES + #define GL_TEXTURE_3D 0 + #define GL_TEXTURE_WRAP_R 0 #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES - + + #define glTexImage3D(...) 0 + #define glGenVertexArrays(...) #define glDeleteVertexArrays(...) #define glBindVertexArray(...) @@ -71,9 +222,9 @@ #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES #define glGetProgramBinary(...) #define glProgramBinary(...) - + extern EGLDisplay display; -#elif _OS_NX +#elif _OS_SWITCH #define GL_GLEXT_PROTOTYPES #include #include @@ -101,10 +252,17 @@ #define GL_CLAMP_TO_BORDER 0x812D #define GL_TEXTURE_BORDER_COLOR 0x1004 + // TODO: WTF? + #undef GL_RG #undef GL_RGBA32F #undef GL_RGBA16F + #undef GL_RG32F + #undef GL_RG16F #undef GL_HALF_FLOAT + #define GL_RG GL_RGBA + #define GL_RG16F GL_RGBA + #define GL_RG32F GL_RGBA #define GL_RGBA32F GL_RGBA #define GL_RGBA16F GL_RGBA #define GL_HALF_FLOAT GL_HALF_FLOAT_OES @@ -113,29 +271,25 @@ //#define GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC_EXT //#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_REF_TO_TEXTURE_EXT #else - #include #include - #include - #include + #include + #include #include - #include - - #define GL_RGBA16F 0x881A - #define GL_RGBA32F 0x8814 - #define GL_HALF_FLOAT 0x140B - #define GL_RGB565 GL_RGBA - #define GL_TEXTURE_COMPARE_MODE 0x884C - #define GL_TEXTURE_COMPARE_FUNC 0x884D - #define GL_COMPARE_REF_TO_TEXTURE 0x884E + // In OpenGL 2.1, the 16-bit RGB565 sized internal format is unavailable + // (because macOS doesn't provide the GL_ARB_ES2_compatibility extension), + // so use a 32-bit format for renderbuffer storage on macOS. See issue 360. + #undef GL_RGB565 + #define GL_RGB565 GL_RGBA + // In compatibility mode, macOS only provides OpenGL 2.1 (no VAO), but it does + // support the Apple-specific VAO extension which is older and in all relevant + // parts 100% compatible. So use those functions instead. #define glGenVertexArrays glGenVertexArraysAPPLE #define glDeleteVertexArrays glDeleteVertexArraysAPPLE #define glBindVertexArray glBindVertexArrayAPPLE - #define GL_PROGRAM_BINARY_LENGTH 0 - #define glGetProgramBinary(...) 0 - #define glProgramBinary(...) 0 + #define GL_LUMINANCE 0x1909 #endif #elif _OS_WEB #include @@ -151,23 +305,23 @@ #define glProgramBinary(...) #endif -#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_ANDROID) +#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_GCW0) || (defined(__SDL2__) && (defined(_GAPI_GLES2) || defined(_SDL2_OPENGL))) - #ifdef _OS_ANDROID - #define GetProc(x) dlsym(libGL, x); - #else - void* GetProc(const char *name) { - #ifdef _OS_WIN - return (void*)wglGetProcAddress(name); - #elif _OS_LINUX - return (void*)glXGetProcAddress((GLubyte*)name); - #else // EGL - return (void*)eglGetProcAddress(name); - #endif - } - #endif + void* GetProc(const char *name) { + #ifdef _OS_WIN + return (void*)wglGetProcAddress(name); + #elif _OS_LINUX + return (void*)glXGetProcAddress((GLubyte*)name); + #elif __SDL2__ + return (void*)SDL_GL_GetProcAddress(name); + #else // EGL + return (void*)eglGetProcAddress(name); + #endif + } - #define GetProcOGL(x) x=(decltype(x))GetProc(#x); + #define GetProcOGL(x) x=(decltype(x))GetProc(#x) + + // TODO: different systems, different headers, different extension suffixes... fuck this shit and make your own OGL header! // Texture #ifdef _OS_WIN @@ -183,8 +337,12 @@ PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; #endif - #if defined(_OS_WIN) || defined(_OS_LINUX) + #if defined(_OS_WIN) || defined(_OS_LINUX) || (defined(__SDL2__) && !defined(_GAPI_GLES2)) PFNGLGENERATEMIPMAPPROC glGenerateMipmap; + #ifdef _OS_WIN + PFNGLTEXIMAGE3DPROC glTexImage3D; + #endif + PFNGLGETSTRINGIPROC glGetStringi; // Profiling #ifdef PROFILE PFNGLOBJECTLABELPROC glObjectLabel; @@ -221,16 +379,17 @@ PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; PFNGLGETPROGRAMIVPROC glGetProgramiv; // Render to texture - PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; - PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; - PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; - PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; - PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; - PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; - PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; - PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; - PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; - PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; + PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; + PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; + PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; + PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; + PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; + PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; + PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; + PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; + PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; + PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; // Mesh PFNGLGENBUFFERSARBPROC glGenBuffers; PFNGLDELETEBUFFERSARBPROC glDeleteBuffers; @@ -239,18 +398,19 @@ PFNGLBUFFERSUBDATAARBPROC glBufferSubData; #endif +// Vertex Arrays PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +// Binary shaders PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; PFNGLPROGRAMBINARYPROC glProgramBinary; -#endif -#if defined(_GAPI_GLES) && !defined(_OS_RPI) && !defined(_OS_CLOVER) && !defined(_OS_IOS) - PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT; + #if defined(_GAPI_GLES) + PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT; + #endif #endif - #ifdef PROFILE //#define USE_CV_MARKERS @@ -329,23 +489,41 @@ namespace GAPI { typedef ::Vertex Vertex; int cullMode, blendMode; + bool depthWrite; + + char GLSL_HEADER_VERT[512]; + char GLSL_HEADER_FRAG[512]; + + bool GL_VER_3 = false; // Shader #ifndef FFP - const char SHADER_BASE[] = - #include "shaders/shader.glsl" + const char SHADER_COMPOSE[] = + #include "../shaders/compose.glsl" + ; + + const char SHADER_SHADOW[] = + #include "../shaders/shadow.glsl" + ; + + const char SHADER_AMBIENT[] = + #include "../shaders/ambient.glsl" + ; + + const char SHADER_SKY[] = + #include "../shaders/sky.glsl" ; const char SHADER_WATER[] = - #include "shaders/water.glsl" + #include "../shaders/water.glsl" ; const char SHADER_FILTER[] = - #include "shaders/filter.glsl" + #include "../shaders/filter.glsl" ; const char SHADER_GUI[] = - #include "shaders/gui.glsl" + #include "../shaders/gui.glsl" ; const char *DefineName[SD_MAX] = { SHADER_DEFINES(DECL_STR) }; @@ -355,7 +533,6 @@ namespace GAPI { bool vec; // true - vec4, false - mat4 int reg; } bindings[uMAX] = { - { true, 94 }, // uFlags { true, 0 }, // uParam { true, 1 }, // uTexParam { false, 2 }, // uViewProj @@ -377,9 +554,9 @@ namespace GAPI { void init(Core::Pass pass, int type, int *def, int defCount) {} void deinit() {} void bind() {} + void validate() {} void setParam(UniformType uType, const vec4 &value, int count = 1) {} void setParam(UniformType uType, const mat4 &value, int count = 1) {} - void setParam(UniformType uType, const Basis &value, int count = 1) {} #else GLuint ID; int32 uID[uMAX]; @@ -392,24 +569,26 @@ namespace GAPI { void init(Pass pass, int type, int *def, int defCount) { const char *source; switch (pass) { - case Core::passCompose : - case Core::passShadow : - case Core::passAmbient : source = SHADER_BASE; break; - case Core::passWater : source = SHADER_WATER; break; - case Core::passFilter : source = SHADER_FILTER; break; - case Core::passGUI : source = SHADER_GUI; break; + case Core::passCompose : source = SHADER_COMPOSE; break; + case Core::passShadow : source = SHADER_SHADOW; break; + case Core::passAmbient : source = SHADER_AMBIENT; break; + case Core::passSky : source = SHADER_SKY; break; + case Core::passWater : source = SHADER_WATER; break; + case Core::passFilter : source = SHADER_FILTER; break; + case Core::passGUI : source = SHADER_GUI; break; default : ASSERT(false); LOG("! wrong pass id\n"); return; } #ifdef _DEBUG_SHADERS Stream *stream = NULL; switch (pass) { - case Core::passCompose : - case Core::passShadow : - case Core::passAmbient : stream = new Stream("../../src/shaders/shader.glsl"); break; - case Core::passWater : stream = new Stream("../../src/shaders/water.glsl"); break; - case Core::passFilter : stream = new Stream("../../src/shaders/filter.glsl"); break; - case Core::passGUI : stream = new Stream("../../src/shaders/gui.glsl"); break; + case Core::passCompose : stream = new Stream(_DEBUG_SHADERS "compose.glsl"); break; + case Core::passShadow : stream = new Stream(_DEBUG_SHADERS "shadow.glsl"); break; + case Core::passAmbient : stream = new Stream(_DEBUG_SHADERS "ambient.glsl"); break; + case Core::passSky : stream = new Stream(_DEBUG_SHADERS "sky.glsl"); break; + case Core::passWater : stream = new Stream(_DEBUG_SHADERS "water.glsl"); break; + case Core::passFilter : stream = new Stream(_DEBUG_SHADERS "filter.glsl"); break; + case Core::passGUI : stream = new Stream(_DEBUG_SHADERS "gui.glsl"); break; default : ASSERT(false); return; } @@ -435,22 +614,33 @@ namespace GAPI { char defines[1024]; defines[0] = 0; + strcat(defines, "#define VER3\n"); for (int i = 0; i < defCount; i++) { - #ifdef _GAPI_GLES - if (def[i] == SD_SHADOW_SAMPLER) - strcat(defines, "#extension GL_EXT_shadow_samplers : require\n"); // ACHTUNG! must be first in the list - #endif sprintf(defines + strlen(defines), "#define %s\n", DefineName[def[i]]); } - sprintf(defines + strlen(defines), "#define PASS_%s\n", passNames[pass]); - #if defined(_OS_RPI) || defined(_OS_CLOVER) + sprintf(defines + strlen(defines), "#define SHADOW_SIZE %d.0\n", SHADOW_TEX_SIZE); + + #ifdef MERGE_MODELS + strcat(defines, "#define MESH_SKINNING\n"); + #endif + + // etnaviv driver has no sin/cos/abs implementation + #if !defined(_OS_GCW0) + strcat(defines, "#define VERT_CAUSTICS\n"); + #endif + + #if defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_GCW0) || (defined (__SDL2__) && defined(_GAPI_GLES)) strcat(defines, "#define OPT_VLIGHTPROJ\n"); strcat(defines, "#define OPT_VLIGHTVEC\n"); strcat(defines, "#define OPT_SHADOW_ONETAP\n"); #endif + if (support.tex3D) { + strcat(defines, "#define OPT_TEXTURE_3D\n"); + } + #ifndef _OS_CLOVER // TODO: only for non Mali-400? strcat(defines, "#define OPT_TRAPEZOID\n"); @@ -506,20 +696,10 @@ namespace GAPI { } bool linkSource(const char *text, const char *defines = "") { - #ifdef _GAPI_GLES - #define GLSL_DEFINE "" - #define GLSL_VERT "" - #define GLSL_FRAG "#extension GL_OES_standard_derivatives : enable\n" - #else - #define GLSL_DEFINE "#version 120\n" - #define GLSL_VERT "" - #define GLSL_FRAG "" - #endif - const int type[2] = { GL_VERTEX_SHADER, GL_FRAGMENT_SHADER }; const char *code[2][4] = { - { GLSL_DEFINE GLSL_VERT "#define VERTEX\n", defines, "#line 0\n", text }, - { GLSL_DEFINE GLSL_FRAG "#define FRAGMENT\n", defines, "#line 0\n", text } + { GLSL_HEADER_VERT, defines, "#line 0\n", text }, + { GLSL_HEADER_FRAG, defines, "#line 0\n", text } }; GLchar info[1024]; @@ -586,7 +766,7 @@ namespace GAPI { } } - void setup() { + void validate() { if (rebind) { glUseProgram(ID); rebind = false; @@ -598,148 +778,174 @@ namespace GAPI { const Binding &b = bindings[uType]; if (b.vec) - glUniform4fv(uID[uType], cbCount[uType] / 4, (GLfloat*)(cbMem + b.reg)); + glUniform4fv(uID[uType], cbCount[uType], (GLfloat*)(cbMem + b.reg)); else - glUniformMatrix4fv(uID[uType], cbCount[uType] / 16, false, (GLfloat*)(cbMem + b.reg)); + glUniformMatrix4fv(uID[uType], cbCount[uType] / 4, false, (GLfloat*)(cbMem + b.reg)); + cbCount[uType] = 0; Core::stats.cb++; } - - memset(cbCount, 0, sizeof(cbCount)); } void setParam(UniformType uType, float *value, int count) { cbCount[uType] = count; - memcpy(cbMem + bindings[uType].reg, value, count * 4); + memcpy(cbMem + bindings[uType].reg, value, count * 16); } void setParam(UniformType uType, const vec4 &value, int count = 1) { - if (uID[uType] != -1) setParam(uType, (float*)&value, count * 4); + if (uID[uType] != -1) setParam(uType, (float*)&value, count); } void setParam(UniformType uType, const mat4 &value, int count = 1) { - if (uID[uType] != -1) setParam(uType, (float*)&value, count * 16); - } - - void setParam(UniformType uType, const Basis &value, int count = 1) { - if (uID[uType] != -1) setParam(uType, (float*)&value, count * 8); + if (uID[uType] != -1) setParam(uType, (float*)&value, count * 4); } #endif }; // Texture + static const struct FormatDesc { + GLuint ifmt, fmt; + GLenum type; + } formats[FMT_MAX] = { + { GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE }, // LUMINANCE + { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE }, // RGBA + { GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, // RGB16 + { GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 }, // RGBA16 + { GL_RG32F, GL_RG, GL_FLOAT }, // RG_FLOAT + { GL_RG16F, GL_RG, GL_HALF_FLOAT }, // RG_HALF + { GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, // DEPTH + { GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, // SHADOW + }; + struct Texture { uint32 ID; - int width, height, origWidth, origHeight; + int width, height, depth, origWidth, origHeight, origDepth; TexFormat fmt; uint32 opt; + GLenum target; - Texture(int width, int height, uint32 opt) : ID(0), width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {} + Texture(int width, int height, int depth, uint32 opt) : ID(0), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {} void init(void *data) { ASSERT((opt & OPT_PROXY) == 0); bool filter = (opt & OPT_NEAREST) == 0; bool mipmaps = (opt & OPT_MIPMAPS) != 0; - bool cube = (opt & OPT_CUBEMAP) != 0; + bool isCube = (opt & OPT_CUBEMAP) != 0; + bool isVolume = (opt & OPT_VOLUME) != 0; bool isShadow = fmt == FMT_SHADOW; + target = isVolume ? GL_TEXTURE_3D : (isCube ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D); + glGenTextures(1, &ID); Core::active.textures[0] = NULL; bind(0); - GLenum target = cube ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - - if (fmt == FMT_SHADOW) { + if (isShadow) { glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } - bool border = isShadow && Core::support.texBorder; - glTexParameteri(target, GL_TEXTURE_WRAP_S, (opt & OPT_REPEAT) ? GL_REPEAT : (border ? GL_CLAMP_TO_BORDER : GL_CLAMP_TO_EDGE)); - glTexParameteri(target, GL_TEXTURE_WRAP_T, (opt & OPT_REPEAT) ? GL_REPEAT : (border ? GL_CLAMP_TO_BORDER : GL_CLAMP_TO_EDGE)); - if (border) { - float color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color); + glTexParameteri(target, GL_TEXTURE_WRAP_S, (opt & OPT_REPEAT) ? GL_REPEAT : GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_T, (opt & OPT_REPEAT) ? GL_REPEAT : GL_CLAMP_TO_EDGE); + if (isVolume) { + glTexParameteri(target, GL_TEXTURE_WRAP_R, (opt & OPT_REPEAT) ? GL_REPEAT : GL_CLAMP_TO_EDGE); } glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter ? (mipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) : (mipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST)); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter ? GL_LINEAR : GL_NEAREST); - static const struct FormatDesc { - GLuint ifmt, fmt; - GLenum type; - } formats[FMT_MAX] = { - { GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE }, // LUMINANCE - { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE }, // RGBA - { GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, // RGB16 - { GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 }, // RGBA16 - { GL_RGBA32F, GL_RGBA, GL_FLOAT }, // RGBA_FLOAT - { GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT }, // RGBA_HALF - { GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, // DEPTH - { GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, // SHADOW - }; + FormatDesc desc = getFormat(); + + void *pix = (width == origWidth && height == origHeight && depth == origDepth) ? data : NULL; + + if (isVolume) { + glTexImage3D(target, 0, desc.ifmt, width, height, depth, 0, desc.fmt, desc.type, pix); + } else if (isCube) { + for (int i = 0; i < 6; i++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, desc.ifmt, width, height, 0, desc.fmt, desc.type, pix); + } + } else { + glTexImage2D(target, 0, desc.ifmt, width, height, 0, desc.fmt, desc.type, pix); + } + + if (pix != data) { + update(data); + } + } + void deinit() { + if (ID) { + glDeleteTextures(1, &ID); + } + } + + FormatDesc getFormat() { FormatDesc desc = formats[fmt]; + if ((fmt == FMT_RG_FLOAT || fmt == FMT_RG_HALF) && !Core::support.texRG) { + desc.ifmt = (fmt == FMT_RG_FLOAT) ? GL_RGBA32F : GL_RGBA16F; + desc.fmt = GL_RGBA; + } + + if (fmt == FMT_LUMINANCE && Core::support.texRG) { + desc.ifmt = GL_R8; + desc.fmt = GL_RED; + } + #ifdef _OS_WEB // fucking firefox! - if (fmt == FMT_RGBA_FLOAT) { - if (Core::support.texFloat) { - desc.ifmt = GL_RGBA; - desc.type = GL_FLOAT; + if (WEBGL_VERSION == 1) { + if (fmt == FMT_RG_FLOAT) { + if (Core::support.texFloat) { + desc.ifmt = GL_RGBA; + desc.type = GL_FLOAT; + } } - } - if (fmt == FMT_RGBA_HALF) { - if (Core::support.texHalf) { - desc.ifmt = GL_RGBA; - desc.type = GL_HALF_FLOAT_OES; + if (fmt == FMT_RG_HALF) { + if (Core::support.texHalf) { + desc.ifmt = GL_RGBA; + desc.type = GL_HALF_FLOAT_OES; + } + } + } else { + if (fmt == FMT_DEPTH || fmt == FMT_SHADOW) { + desc.ifmt = GL_DEPTH_COMPONENT16; } } #else - if ((fmt == FMT_RGBA_FLOAT && !Core::support.colorFloat) || (fmt == FMT_RGBA_HALF && !Core::support.colorHalf)) { + if ((fmt == FMT_RG_FLOAT && !Core::support.colorFloat) || (fmt == FMT_RG_HALF && !Core::support.colorHalf)) { desc.ifmt = GL_RGBA; #ifdef _GAPI_GLES - if (fmt == FMT_RGBA_HALF) + if (fmt == FMT_RG_HALF) { desc.type = GL_HALF_FLOAT_OES; + } #endif } #endif - - - void *pix = data; - if (data && !Core::support.texNPOT && (width != origWidth || height != origHeight)) - pix = NULL; - - for (int i = 0; i < 6; i++) { - glTexImage2D(cube ? (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i) : GL_TEXTURE_2D, 0, desc.ifmt, width, height, 0, desc.fmt, desc.type, pix); - if (!cube) break; - } - - if (pix != data) - update(data); - } - - void deinit() { - if (ID) - glDeleteTextures(1, &ID); + return desc; } void generateMipMap() { bind(0); - GLenum target = (opt & OPT_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - - glGenerateMipmap(target); - if (!(opt & OPT_CUBEMAP) && !(opt & OPT_NEAREST) && (Core::support.maxAniso > 0)) + if (glGenerateMipmap) { + glGenerateMipmap(target); + } + if ((opt & (OPT_VOLUME | OPT_CUBEMAP | OPT_NEAREST)) == 0 && (Core::support.maxAniso > 0)) { glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, min(int(Core::support.maxAniso), 8)); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); + if (Core::support.texMaxLevel) { + glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 3); + } + } } void update(void *data) { + ASSERT((opt & (OPT_VOLUME | OPT_CUBEMAP)) == 0); bind(0); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, origWidth, origHeight, GL_RGBA, GL_UNSIGNED_BYTE, data); + FormatDesc desc = getFormat(); + glTexSubImage2D(target, 0, 0, 0, origWidth, origHeight, desc.fmt, desc.type, data); } void bind(int sampler) { @@ -748,16 +954,28 @@ namespace GAPI { if (Core::active.textures[sampler] != this) { Core::active.textures[sampler] = this; + #ifdef FFP + if (sampler != sDiffuse) { + return; + } + #else glActiveTexture(GL_TEXTURE0 + sampler); - glBindTexture((opt & OPT_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, ID); + #endif + glBindTexture(target, ID); } } void unbind(int sampler) { if (Core::active.textures[sampler]) { Core::active.textures[sampler] = NULL; + #ifdef FFP + if (sampler != sDiffuse) { + return; + } + #else glActiveTexture(GL_TEXTURE0 + sampler); - glBindTexture((opt & OPT_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, 0); + #endif + glBindTexture(target, 0); } } @@ -767,10 +985,11 @@ namespace GAPI { Core::active.textures[0] = NULL; bind(0); - if (Core::support.maxAniso > 0) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value > Core::Settings::MEDIUM ? min(int(Core::support.maxAniso), 8) : 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter ? (mipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR ) : ( mipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST )); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter ? GL_LINEAR : GL_NEAREST); + if (Core::support.maxAniso > 0) { + glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, value > Core::Settings::MEDIUM ? min(int(Core::support.maxAniso), 8) : 1); + } + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter ? (mipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR ) : ( mipmaps ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST )); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filter ? GL_LINEAR : GL_NEAREST); } }; @@ -798,21 +1017,27 @@ namespace GAPI { if (Core::support.VAO) glBindVertexArray(Core::active.VAO = 0); + bool useVBO = Core::support.VBO; + #ifdef DYNGEOM_NO_VBO if (!vertices && !indices) { - iBuffer = new Index[iCount]; - vBuffer = new GAPI::Vertex[vCount]; - return; + useVBO = false; } - #endif + #endif ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); - glGenBuffers(2, ID); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID[0]); - glBindBuffer(GL_ARRAY_BUFFER, ID[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, iCount * sizeof(Index), indices, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); - glBufferData(GL_ARRAY_BUFFER, vCount * sizeof(Vertex), vertices, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); + if (useVBO) { + glGenBuffers(2, ID); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID[0]); + glBindBuffer(GL_ARRAY_BUFFER, ID[1]); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, iCount * sizeof(Index), indices, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, vCount * sizeof(Vertex), vertices, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); + } else { + iBuffer = new Index[iCount]; + vBuffer = new GAPI::Vertex[vCount]; + update(indices, iCount, vertices, vCount); + } if (Core::support.VAO && aCount) { VAO = new GLuint[aCount]; @@ -880,9 +1105,9 @@ namespace GAPI { void bind(const MeshRange &range) const { if (range.aIndex == -1) { - if (Core::active.iBuffer != ID[0]) + if (Core::support.VBO && Core::active.iBuffer != ID[0]) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Core::active.iBuffer = ID[0]); - if (Core::active.vBuffer != ID[1]) + if (Core::support.VBO && Core::active.vBuffer != ID[1]) glBindBuffer(GL_ARRAY_BUFFER, Core::active.vBuffer = ID[1]); setupFVF(vBuffer + range.vStart); } else { @@ -915,28 +1140,49 @@ namespace GAPI { GLuint FBO, defaultFBO; - struct RenderTargetCache { - int count; - struct Item { - GLuint ID; - int width; - int height; - } items[MAX_RENDER_BUFFERS]; - } rtCache[2]; - - bool extSupport(const char *str, const char *ext) { - if (!str) return false; - return strstr(str, ext) != NULL; + struct RenderTargetCacheItem { + GLuint ID; + int width; + int height; + }; + Array rtCache[2]; + + + bool extSupport(const char *str) { + #if !defined(_GAPI_GLES2) && !_OS_MAC + if (glGetStringi != NULL) { + GLint count = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &count); + for (int i = 0; i < count; i++) { + const char *ext = (const char*)glGetStringi(GL_EXTENSIONS, i); + if (strstr(ext, str) != NULL) { + return true; + } + } + } else + #endif + { + const char *ext = (const char*)glGetString(GL_EXTENSIONS); + if (!ext) { + return false; + } + return strstr(ext, str) != NULL; + } + + return false; } void init() { - memset(rtCache, 0, sizeof(rtCache)); #ifdef _OS_ANDROID - void *libGL = dlopen("libGLESv2.so", RTLD_LAZY); + //void *libGL = dlopen("libGLESv2.so", RTLD_LAZY); + #endif + + #if (defined(__SDL2__) && defined(_GAPI_GLES2)) + GetProcOGL(glDiscardFramebufferEXT); #endif - #if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_ANDROID) + #if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_GCW0) || (defined(__SDL2__) && !defined(_GAPI_GLES)) #ifdef _OS_WIN GetProcOGL(glActiveTexture); #endif @@ -947,8 +1193,13 @@ namespace GAPI { GetProcOGL(glXSwapIntervalSGI); #endif - #if defined(_OS_WIN) || defined(_OS_LINUX) + #if defined(_OS_WIN) || defined(_OS_LINUX) || (defined(__SDL2__) && (defined(_GAPI_GLES2) || defined(_SDL2_OPENGL))) GetProcOGL(glGenerateMipmap); + #ifdef _OS_WIN + GetProcOGL(glTexImage3D); + #endif + + GetProcOGL(glGetStringi); #ifdef PROFILE GetProcOGL(glObjectLabel); @@ -995,6 +1246,7 @@ namespace GAPI { GetProcOGL(glCheckFramebufferStatus); GetProcOGL(glDeleteFramebuffers); GetProcOGL(glDeleteRenderbuffers); + GetProcOGL(glGetFramebufferAttachmentParameteriv); GetProcOGL(glGenBuffers); GetProcOGL(glDeleteBuffers); @@ -1003,76 +1255,88 @@ namespace GAPI { GetProcOGL(glBufferSubData); #endif - #ifdef _GAPI_GLES - GetProcOGL(glDiscardFramebufferEXT); - #endif - GetProcOGL(glGenVertexArrays); GetProcOGL(glDeleteVertexArrays); GetProcOGL(glBindVertexArray); + GetProcOGL(glGetProgramBinary); GetProcOGL(glProgramBinary); + + #if defined(_GAPI_GLES) + GetProcOGL(glDiscardFramebufferEXT); + #endif #endif LOG("Vendor : %s\n", (char*)glGetString(GL_VENDOR)); LOG("Renderer : %s\n", (char*)glGetString(GL_RENDERER)); LOG("Version : %s\n", (char*)glGetString(GL_VERSION)); - char *ext = (char*)glGetString(GL_EXTENSIONS); -/* - if (ext != NULL) { - char buf[255]; - int len = strlen(ext); - int start = 0; - for (int i = 0; i < len; i++) - if (ext[i] == ' ' || (i == len - 1)) { - memcpy(buf, &ext[start], i - start); - buf[i - start] = 0; - LOG("%s\n", buf); - start = i + 1; - } - } -*/ + #ifndef FFP + bool GLES3 = false; + #ifdef _OS_WEB + GLES3 = WEBGL_VERSION != 1; + #else + #if defined(_GAPI_GLES) && !defined(_GAPI_GLES2) + int GLES_VERSION = 1; + #if defined(__SDL2__) + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &GLES_VERSION); + #else + #if defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_GCW0) + GLES_VERSION = 2; + #else + glGetIntegerv(GL_MAJOR_VERSION, &GLES_VERSION); + #endif + #endif + GLES3 = GLES_VERSION > 2; + #endif + #endif - #ifdef FFP - support.maxAniso = 0; - support.maxVectors = 0; - support.shaderBinary = false; - support.VAO = false; - support.depthTexture = false; - support.shadowSampler = false; - support.discardFrame = false; - support.texNPOT = false; - support.texRG = false; - support.texBorder = false; - support.colorFloat = false; - support.colorHalf = false; - support.texFloatLinear = false; - support.texFloat = false; - support.texHalfLinear = false; - support.texHalf = false; - support.clipDist = false; - #else - support.shaderBinary = extSupport(ext, "_program_binary"); - support.VAO = extSupport(ext, "_vertex_array_object"); - support.depthTexture = extSupport(ext, "_depth_texture"); - support.shadowSampler = support.depthTexture && (extSupport(ext, "_shadow_samplers") || extSupport(ext, "GL_ARB_shadow")); - support.discardFrame = extSupport(ext, "_discard_framebuffer"); - support.texNPOT = extSupport(ext, "_texture_npot") || extSupport(ext, "_texture_non_power_of_two"); - support.texRG = extSupport(ext, "_texture_rg "); // hope that isn't last extension in string ;) - support.texBorder = extSupport(ext, "_texture_border_clamp"); - support.maxAniso = extSupport(ext, "_texture_filter_anisotropic"); - support.colorFloat = extSupport(ext, "_color_buffer_float"); - support.colorHalf = extSupport(ext, "_color_buffer_half_float") || extSupport(ext, "GL_ARB_half_float_pixel"); - support.texFloatLinear = support.colorFloat || extSupport(ext, "GL_ARB_texture_float") || extSupport(ext, "_texture_float_linear"); - support.texFloat = support.texFloatLinear || extSupport(ext, "_texture_float"); - support.texHalfLinear = support.colorHalf || extSupport(ext, "GL_ARB_texture_float") || extSupport(ext, "_texture_half_float_linear") || extSupport(ext, "_color_buffer_half_float"); - support.texHalf = support.texHalfLinear || extSupport(ext, "_texture_half_float"); - support.clipDist = false; // TODO + bool _GL_EXT_shadow_samplers = extSupport("GL_EXT_shadow_samplers"); + bool _GL_ARB_shadow = extSupport("GL_ARB_shadow"); + bool _GL_OES_standard_derivatives = extSupport("GL_OES_standard_derivatives"); + + support.shaderBinary = extSupport("_program_binary"); + support.VAO = GLES3 || extSupport("_vertex_array_object"); + support.VBO = glGenBuffers != NULL; + support.depthTexture = GLES3 || extSupport("_depth_texture"); + support.shadowSampler = _GL_EXT_shadow_samplers || _GL_ARB_shadow; + support.discardFrame = extSupport("_discard_framebuffer"); + support.texNPOT = GLES3 || extSupport("_texture_npot") || extSupport("_texture_non_power_of_two"); + support.texRG = GLES3 || extSupport("_texture_rg"); + support.texMaxLevel = GLES3 || extSupport("_texture_max_level"); + + #ifdef _GAPI_GLES2 // TODO + support.shaderBinary = false; + support.VAO = false; + support.texRG = false; + support.discardFrame = false; + #endif + #ifdef _GAPI_GLES + support.derivatives = GLES3 || _GL_OES_standard_derivatives; + support.tex3D = GLES3; + #else + support.derivatives = true; + support.tex3D = glTexImage3D != NULL; + #endif + support.texBorder = extSupport("_texture_border_clamp"); + support.maxAniso = extSupport("_texture_filter_anisotropic"); + support.colorFloat = extSupport("_color_buffer_float"); + support.colorHalf = extSupport("_color_buffer_half_float") || extSupport("GL_ARB_half_float_pixel"); + support.texFloatLinear = support.colorFloat || extSupport("GL_ARB_texture_float") || extSupport("_texture_float_linear"); + support.texFloat = support.texFloatLinear || extSupport("_texture_float"); + support.texHalfLinear = support.colorHalf || extSupport("GL_ARB_texture_float") || extSupport("_texture_half_float_linear") || extSupport("_color_buffer_half_float"); + + support.texHalf = support.texHalfLinear || extSupport("_texture_half_float"); + + #ifdef SDL2_GLES + support.shaderBinary = false; // TODO + support.VAO = false; // TODO + support.shadowSampler = false; // TODO + #endif #ifdef PROFILE - support.profMarker = extSupport(ext, "_KHR_debug"); - support.profTiming = extSupport(ext, "_timer_query"); + support.profMarker = extSupport("_KHR_debug"); + support.profTiming = extSupport("_timer_query"); #endif if (support.maxAniso) @@ -1087,8 +1351,6 @@ namespace GAPI { glEnable(GL_SCISSOR_TEST); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&defaultFBO); - glGenFramebuffers(1, &FBO); glDepthFunc(GL_LEQUAL); #ifdef FFP @@ -1105,25 +1367,130 @@ namespace GAPI { glScalef(1.0f / 32767.0f, 1.0f / 32767.0f, 1.0f / 32767.0f); glClearColor(0, 0, 0, 0); + #else + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&defaultFBO); + glGenFramebuffers(1, &FBO); + + char extHeader[256]; + GLSL_HEADER_VERT[0] = GLSL_HEADER_FRAG[0] = extHeader[0] = 0; + if (_GL_OES_standard_derivatives) { + if (!GLES3) { + strcat(extHeader, "#extension GL_OES_standard_derivatives : enable\n"); + } + } + + if (_GL_EXT_shadow_samplers && !_GL_ARB_shadow) { + if (!GLES3) { + strcat(extHeader, "#extension GL_EXT_shadow_samplers : enable\n"); + } + } + + #ifdef _GAPI_GLES + if (GLES3) { + // vertex + strcat(GLSL_HEADER_VERT, "#version 300 es\n" + "precision lowp int;\n" + "precision highp float;\n" + "#define VERTEX\n" + "#define varying out\n" + "#define attribute in\n" + "#define texture2D texture\n"); + // fragment + strcat(GLSL_HEADER_FRAG, "#version 300 es\n"); + strcat(GLSL_HEADER_FRAG, extHeader); + strcat(GLSL_HEADER_FRAG, "precision lowp int;\n" + "precision highp float;\n" + "precision lowp sampler3D;\n" + "#define FRAGMENT\n" + "#define varying in\n" + "#define texture2D texture\n" + "#define texture3D texture\n" + "#define textureCube texture\n" + "#define FETCH_SHADOW2D(a,b) texture(a,b)\n" + "out vec4 fragColor;\n"); + } else { + // vertex + strcat(GLSL_HEADER_VERT, "#version 100\n" + "precision lowp int;\n" + "precision highp float;\n" + "#define VERTEX\n"); + // fragment + strcat(GLSL_HEADER_FRAG, "#version 100\n"); + strcat(GLSL_HEADER_FRAG, extHeader); + strcat(GLSL_HEADER_FRAG, "precision lowp int;\n" + "precision highp float;\n" + "#define FRAGMENT\n" + "#define FETCH_SHADOW2D(a,b) shadow2DEXT(a,b)\n" + "#define fragColor gl_FragColor\n"); + } + + if (support.shadowSampler) { + strcat(GLSL_HEADER_FRAG, "#define sampler2DShadow lowp sampler2DShadow\n"); + } + #else + if (GL_VER_3) { + strcat(GLSL_HEADER_VERT, "#version 150\n" + "#define VERTEX\n" + "#define varying out\n" + "#define attribute in\n" + "#define texture2D texture\n"); + // fragment + strcat(GLSL_HEADER_FRAG, "#version 150\n"); + strcat(GLSL_HEADER_FRAG, extHeader); + strcat(GLSL_HEADER_FRAG, "#define FRAGMENT\n" + "#define varying in\n" + "#define texture2D texture\n" + "#define texture3D texture\n" + "#define textureCube texture\n" + "#define FETCH_SHADOW2D(a,b) texture(a,b)\n" + "out vec4 fragColor;\n"); + } else { + // vertex + strcat(GLSL_HEADER_VERT, "#version 110\n" + "#define VERTEX\n"); + // fragment + strcat(GLSL_HEADER_FRAG, "#version 110\n"); + strcat(GLSL_HEADER_FRAG, extHeader); + strcat(GLSL_HEADER_FRAG, "#define FRAGMENT\n" + "#define FETCH_SHADOW2D(a,b) shadow2D(a,b).x\n" + "#define fragColor gl_FragColor\n"); + } #endif + ASSERT(strlen(GLSL_HEADER_VERT) < COUNT(GLSL_HEADER_VERT)); + ASSERT(strlen(GLSL_HEADER_FRAG) < COUNT(GLSL_HEADER_FRAG)); + #endif // FFP } void deinit() { + #ifdef FFP + return; + #endif glBindFramebuffer(GL_FRAMEBUFFER, 0); glDeleteFramebuffers(1, &FBO); glBindRenderbuffer(GL_RENDERBUFFER, 0); - for (int b = 0; b < 2; b++) - for (int i = 0; i < rtCache[b].count; i++) - glDeleteRenderbuffers(1, &rtCache[b].items[i].ID); + for (int b = 0; b < 2; b++) { + for (int i = 0; i < rtCache[b].length; i++) { + glDeleteRenderbuffers(1, &rtCache[b][i].ID); + } + rtCache[b].clear(); + } + } + + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_NEG_POS; } mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { - return mat4(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar); + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; } - mat4 perspective(float fov, float aspect, float znear, float zfar) { - return mat4(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar); + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; } bool beginFrame() { @@ -1135,22 +1502,34 @@ namespace GAPI { void resetState() { if (Core::support.VAO) glBindVertexArray(0); - glActiveTexture(GL_TEXTURE0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glUseProgram(0); + + #ifndef FFP + glActiveTexture(GL_TEXTURE0); + glUseProgram(0); + #endif + + if (Core::support.VBO) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } } int cacheRenderTarget(bool depth, int width, int height) { - RenderTargetCache &cache = rtCache[depth]; + Array &items = rtCache[depth]; - for (int i = 0; i < cache.count; i++) - if (cache.items[i].width == width && cache.items[i].height == height) - return i; + for (int i = 0; i < items.length; i++) + if (items[i].width == width && items[i].height == height) { + RenderTargetCacheItem item = items[i]; + items.remove(i); + return items.push(item); + } - ASSERT(cache.count < MAX_RENDER_BUFFERS); + if (items.length >= MAX_RENDER_BUFFERS) { + glDeleteRenderbuffers(1, &items[0].ID); + items.remove(0); + } - RenderTargetCache::Item &item = cache.items[cache.count]; + RenderTargetCacheItem item; item.width = width; item.height = height; @@ -1158,7 +1537,7 @@ namespace GAPI { glBindRenderbuffer(GL_RENDERBUFFER, item.ID); glRenderbufferStorage(GL_RENDERBUFFER, depth ? GL_DEPTH_COMPONENT16 : GL_RGB565, width, height); glBindRenderbuffer(GL_RENDERBUFFER, 0); - return cache.count++; + return items.push(item); } void bindTarget(Texture *target, int face) { @@ -1166,8 +1545,9 @@ namespace GAPI { glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); } else { GLenum texTarget = GL_TEXTURE_2D; - if (target->opt & OPT_CUBEMAP) + if (target->opt & OPT_CUBEMAP) { texTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; + } bool depth = target->fmt == FMT_DEPTH || target->fmt == FMT_SHADOW; @@ -1176,6 +1556,10 @@ namespace GAPI { glBindFramebuffer(GL_FRAMEBUFFER, FBO); glFramebufferTexture2D (GL_FRAMEBUFFER, depth ? GL_DEPTH_ATTACHMENT : GL_COLOR_ATTACHMENT0, texTarget, target->ID, 0); glFramebufferRenderbuffer (GL_FRAMEBUFFER, depth ? GL_COLOR_ATTACHMENT0 : GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rtCache[!depth].items[rtIndex].ID); + GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + LOG("status: 0x%04X\n", (int)status); + } } } @@ -1186,8 +1570,18 @@ namespace GAPI { GLenum discard[2]; if (color) discard[count++] = Core::active.target ? GL_COLOR_ATTACHMENT0 : GL_COLOR_EXT; if (depth) discard[count++] = Core::active.target ? GL_DEPTH_ATTACHMENT : GL_DEPTH_EXT; - if (count) - glDiscardFramebufferEXT(GL_FRAMEBUFFER, count, discard); + if (count) { + #if defined(_OS_ANDROID) || (defined(__SDL2__) && !defined(_GAPI_GLES2)) + /* glInvalidateBuffer() is the GLES3 version of glDiscardFramebufferEXT(), also + available on Android. Not available in any GLES2 implementation, this is GLES3 stuff.*/ + glInvalidateFramebuffer(GL_FRAMEBUFFER, count, discard); + #elif !defined(_OS_WEB) || (defined(__SDL2__) && defined(_GAPI_GLES2)) + /* glDiscardFramebufferEXT() is available even in GLES2 MESA implementations, + but we have to get the extension function pointer address to use it. + Not available in GLES3, which is SDL2 default GLES version. */ + glDiscardFramebufferEXT(GL_FRAMEBUFFER, count, discard); + #endif + } } #endif } @@ -1205,7 +1599,9 @@ namespace GAPI { if (wglSwapIntervalEXT) wglSwapIntervalEXT(enable ? 1 : 0); #elif _OS_LINUX if (glXSwapIntervalSGI) glXSwapIntervalSGI(enable ? 1 : 0); - #elif defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_NX) + #elif defined(__SDL2__) + SDL_GL_SetSwapInterval(enable ? 1 : 0); + #elif defined(_OS_RPI) || defined(_OS_CLOVER) || defined(_OS_SWITCH) eglSwapInterval(display, enable ? 1 : 0); #endif } @@ -1214,16 +1610,27 @@ namespace GAPI { void clear(bool color, bool depth) { uint32 mask = (color ? GL_COLOR_BUFFER_BIT : 0) | (depth ? GL_DEPTH_BUFFER_BIT : 0); - if (mask) glClear(mask); + if (mask) { + if (depth && !depthWrite) { + glDepthMask(GL_TRUE); + glClear(mask); + glDepthMask(GL_FALSE); + } else { + glClear(mask); + } + } } void setClearColor(const vec4 &color) { glClearColor(color.x, color.y, color.z, color.w); } - void setViewport(const Viewport &vp) { - glViewport(vp.x, vp.y, vp.width, vp.height); - glScissor(vp.x, vp.y, vp.width, vp.height); + void setViewport(const short4 &v) { + glViewport(v.x, v.y, v.z, v.w); + } + + void setScissor(const short4 &s) { + glScissor(s.x, s.y, s.z, s.w); } void setDepthTest(bool enable) { @@ -1234,6 +1641,7 @@ namespace GAPI { } void setDepthWrite(bool enable) { + depthWrite = enable; glDepthMask(enable ? GL_TRUE : GL_FALSE); } @@ -1327,6 +1735,10 @@ namespace GAPI { #endif } + void setFog(const vec4 ¶ms) { + // FFP TODO + } + void DIP(Mesh *mesh, const MeshRange &range) { #ifdef FFP mat4 m = mView * mModel; @@ -1334,10 +1746,10 @@ namespace GAPI { glLoadMatrixf((GLfloat*)&m); #endif if (Core::active.shader) { - Core::active.shader->setup(); + Core::active.shader->validate(); } - glDrawElements(GL_TRIANGLES, range.iCount, GL_UNSIGNED_SHORT, mesh->iBuffer + range.iStart); + glDrawElements(GL_TRIANGLES, range.iCount, sizeof(Index) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, mesh->iBuffer + range.iStart); } vec4 copyPixel(int x, int y) { @@ -1345,50 +1757,6 @@ namespace GAPI { glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &c); return vec4(float(c.x), float(c.y), float(c.z), float(c.w)) * (1.0f / 255.0f); } - - void initPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso && pso->data == NULL); - pso->data = &pso; - } - - void deinitPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso->data != NULL); - pso->data = NULL; - } - - void bindPSO(const PSO *pso) { - ASSERT(pso); - ASSERT(pso->data != NULL); - - uint32 state = pso->renderState; - uint32 mask = 0;//mask; - - if (Core::active.pso) - mask ^= Core::active.pso->renderState; - - if (!Core::active.pso || Core::active.pso->clearColor != pso->clearColor) - setClearColor(pso->clearColor); - - if (mask & RS_DEPTH_TEST) - setDepthTest((state & RS_DEPTH_TEST) != 0); - - if (mask & RS_DEPTH_WRITE) - setDepthWrite((state & RS_DEPTH_WRITE) != 0); - - if (mask & RS_COLOR_WRITE) - setColorWrite((state & RS_COLOR_WRITE_R) != 0, (state & RS_COLOR_WRITE_G) != 0, (state & RS_COLOR_WRITE_B) != 0, (state & RS_COLOR_WRITE_A) != 0); - - if (mask & RS_CULL) - setCullMode(state & RS_CULL); - - if (mask & RS_BLEND) - setBlendMode(state & RS_BLEND); - - if (mask & RS_DISCARD) - setAlphaTest((state & RS_DISCARD) != 0); - } } #endif diff --git a/src/gapi_gu.h b/src/gapi/gu.h similarity index 87% rename from src/gapi_gu.h rename to src/gapi/gu.h index fa262ded..713c3077 100644 --- a/src/gapi_gu.h +++ b/src/gapi/gu.h @@ -28,17 +28,17 @@ namespace GAPI { void bind() {} void setParam(UniformType uType, const vec4 &value, int count = 1) {} void setParam(UniformType uType, const mat4 &value, int count = 1) {} - void setParam(UniformType uType, const Basis &value, int count = 1) {} }; // Texture struct Texture { uint8 *memory; - int width, height, origWidth, origHeight; + int width, height, depth, origWidth, origHeight, origDepth;//todo: depth TexFormat fmt; uint32 opt; - Texture(int width, int height, uint32 opt) : memory(0), width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {} + /*depth*/ + Texture(int width, int height, int depth, uint32 opt) : memory(0), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {} void init(void *data) { ASSERT((opt & OPT_PROXY) == 0); @@ -57,7 +57,7 @@ namespace GAPI { delete[] memory; } - void swizzle(uint8* out, const uint8* in, uint32 width, uint32 height) { + void swizzle(uint8 *out, const uint8 *in, uint32 width, uint32 height) { int rowblocks = width / 16; for (int j = 0; j < height; j++) @@ -239,19 +239,22 @@ namespace GAPI { support.maxVectors = 0; support.shaderBinary = false; support.VAO = false; + support.VBO = false; support.depthTexture = false; support.shadowSampler = false; support.discardFrame = false; support.texNPOT = false; + support.tex3D = false; support.texRG = false; support.texBorder = false; + support.texMaxLevel = false; support.colorFloat = false; support.colorHalf = false; support.texFloatLinear = false; support.texFloat = false; support.texHalfLinear = false; support.texHalf = false; - support.clipDist = false; + //support.clipDist = false; Core::width = 480; Core::height = 272; @@ -296,12 +299,20 @@ namespace GAPI { delete[] cmdBuf; } + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_NEG_POS; + } + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { - return mat4(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar); + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; } - mat4 perspective(float fov, float aspect, float znear, float zfar) { - return mat4(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar); + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; } bool beginFrame() { @@ -323,6 +334,8 @@ namespace GAPI { void discardTarget(bool color, bool depth) {} + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) {} + void setVSync(bool enable) {} void waitVBlank() { @@ -342,9 +355,33 @@ namespace GAPI { sceGuClearColor(*((uint32*)&c)); } - void setViewport(const Viewport &vp) { - sceGuOffset(2048 - vp.width / 2, 2048 - vp.height / 2); - sceGuViewport(2048 + vp.x, 2048 + vp.y, vp.width, vp.height); + // Previous: struct Viewport + void setViewport(const short4 &vp) { + sceGuOffset(2048 - vp.z / 2, 2048 - vp.w / 2); + sceGuViewport(2048 + vp.x, 2048 + vp.y, vp.z, vp.w); + } + + /*this was giving errors on menu rendering when method was empty, see RT_ flags too*/ + void setFog(const vec4 ¶ms) { + uint32 color; + if(params.w > 0.0f){ + sceGuEnable(GU_FOG); + // FFP TODO + color = 0xFF000000 + | (uint32(clamp(params.x * 255.0f, 0.0f, 255.0f)) << 0) + | (uint32(clamp(params.y * 255.0f, 0.0f, 255.0f)) << 8) + | (uint32(clamp(params.z * 255.0f, 0.0f, 255.0f)) << 16); + // from 3DS + sceGuFog(24.0f, 32.0f * 1024.0f, color); + } + else{ + sceGuDisable(GU_FOG); + } + } + + // from other gapi, could be improved?? + void setScissor(const short4 &s) { + sceGuScissor(s.x, Core::viewportDef.w - (s.y + s.w), s.x + s.z, Core::viewportDef.w - s.y); } void setDepthTest(bool enable) { @@ -449,24 +486,9 @@ namespace GAPI { } vec4 copyPixel(int x, int y) { + //pspgu.h, pspdisplay.h ?? return vec4(0.0f); // TODO: read from framebuffer } - - void initPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso && pso->data == NULL); - pso->data = &pso; - } - - void deinitPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso->data != NULL); - pso->data = NULL; - } - - void bindPSO(const PSO *pso) { - // - } } -#endif \ No newline at end of file +#endif diff --git a/src/gapi_gxm.h b/src/gapi/gxm.h similarity index 60% rename from src/gapi_gxm.h rename to src/gapi/gxm.h index 70936ec7..519c4381 100644 --- a/src/gapi_gxm.h +++ b/src/gapi/gxm.h @@ -11,8 +11,6 @@ #define PROFILE_LABEL(id, name, label) #define PROFILE_TIMING(time) -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) - #define DISPLAY_WIDTH 960 #define DISPLAY_HEIGHT 544 #define DISPLAY_STRIDE 1024 @@ -21,21 +19,6 @@ #define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 namespace GAPI { - #include "shaders/gxm/compose_vp.h" - #include "shaders/gxm/compose_fp.h" - #include "shaders/gxm/shadow_vp.h" - #include "shaders/gxm/shadow_fp.h" - #include "shaders/gxm/ambient_vp.h" - #include "shaders/gxm/ambient_fp.h" - #include "shaders/gxm/water_vp.h" - #include "shaders/gxm/water_fp.h" - #include "shaders/gxm/filter_vp.h" - #include "shaders/gxm/filter_fp.h" - #include "shaders/gxm/gui_vp.h" - #include "shaders/gxm/gui_fp.h" - #include "shaders/gxm/clear_vp.h" - #include "shaders/gxm/clear_fp.h" - #define SHADER_BUFF_SIZE (64 * 1024) #define SHADER_VERT_SIZE (64 * 1024) #define SHADER_FRAG_SIZE (64 * 1024) @@ -54,7 +37,7 @@ namespace GAPI { void *addr; }; - void display_queue_callback(const void *callbackData) { + void displayCallback(const void *callbackData) { SceDisplayFrameBuf display_fb; const DisplayData *cb_data = (DisplayData*)callbackData; @@ -105,9 +88,9 @@ namespace GAPI { void *mem; if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { - size = ALIGN(size, 256 * 1024); + size = ALIGNADDR(size, 256 * 1024); } else { - size = ALIGN(size, 4 * 1024); + size = ALIGNADDR(size, 4 * 1024); } *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); @@ -144,7 +127,7 @@ namespace GAPI { void* allocVertexUSSE(unsigned int size, SceUID *uid, unsigned int *usse_offset) { void *mem = NULL; - size = ALIGN(size, 4096); + size = ALIGNADDR(size, 4096); *uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL); @@ -172,7 +155,7 @@ namespace GAPI { void* allocFragmentUSSE(unsigned int size, SceUID *uid, unsigned int *usse_offset) { void *mem = NULL; - size = ALIGN(size, 4096); + size = ALIGNADDR(size, 4096); *uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL); @@ -197,6 +180,23 @@ namespace GAPI { sceKernelFreeMemBlock(uid); } + uint32 *SWIZZE_TABLE = NULL; + #define SWIZZLE(x, y) ((SWIZZE_TABLE[(x)] << 1) | (SWIZZE_TABLE[(y)])) + + void initSwizzleTable() { + SWIZZE_TABLE = new uint32[4096]; + uint32 value = 0; + for (int i = 0; i < 4096; i++) { + SWIZZE_TABLE[i] = value; + value += 0x2AAAAAAB; + value &= 0x55555555; + } + } + + void freeSwizzleTable() { + delete[] SWIZZE_TABLE; + } + void init() { void *vdmRingBuffer = allocGPU( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE, @@ -229,6 +229,8 @@ namespace GAPI { params.fragmentUsseRingBufferOffset = offset; sceGxmCreateContext(¶ms, &gxmContext); + + initSwizzleTable(); } void deinit() { @@ -240,17 +242,80 @@ namespace GAPI { freeGPU(fragmentRingBufferUID); freeFragmentUSSE(fragmentUsseRingBufferUID); sceGxmDestroyContext(gxmContext); + freeSwizzleTable(); } void checkPendings() { int i = 0; while (i < pendings.length) { - if (pendings[i].frameIndex + DISPLAY_BUFFER_COUNT <= Core::stats.frameIndex) + if (pendings[i].frameIndex + DISPLAY_BUFFER_COUNT <= Core::stats.frameIndex) { pendings.removeFast(i); - else + } else { i++; + } + } + } + + template + void swizzleTiles(T *dst, T *src, int width, int tilesX, int tilesY) { + int tileSize = width / tilesX; + int tileArea = SQR(tileSize); + + for (int j = 0; j < tilesY; j++) { + for (int i = 0; i < tilesX; i++) { + T *tilePtr = dst + ((tileArea * tilesX) * j) + (tileArea * i); + + for (int y = 0; y < tileSize; y++) { + T *ptr = src + (width * (tileSize * j)) + (tileSize * i) + width * y; + + for (int x = 0; x < tileSize; x++) + *(tilePtr + SWIZZLE(x, y)) = *ptr++; + } + } + } + } + + void swizzleImage(void *dst, void *src, int width, int height, int bpp) { + ASSERT(SWIZZLE_TABLE); + + int tilesX, tilesY; + + if (width > height) { + tilesX = width / height; + tilesY = 1; + } else { + tilesX = 1; + tilesY = height / width; + } + + switch (bpp) { + case 8 : swizzleTiles( (uint8*) dst, (uint8*) src, width, tilesX, tilesY ); break; + case 16 : swizzleTiles( (uint16*) dst, (uint16*) src, width, tilesX, tilesY ); break; + case 32 : swizzleTiles( (uint32*) dst, (uint32*) src, width, tilesX, tilesY ); break; } } + + #define TILE_SIZE 32 + + void tileImage(void *dst, void *src, int width, int height, int bpp) { + int tilesX = width / TILE_SIZE; + int tilesY = height / TILE_SIZE; + + uint8 *tilePtr = (uint8*)dst; + for (int y = 0; y < tilesY; y++) { + for (int x = 0; x < tilesX; x++) { + uint8 *ptr = (uint8*)src + (width * y + x) * TILE_SIZE * bpp / 8; + + for (int i = 0; i < TILE_SIZE; i++) { + memcpy(tilePtr, ptr, TILE_SIZE * bpp / 8); + ptr += width * bpp / 8; + tilePtr += TILE_SIZE * bpp / 8; + } + } + } + } + + #undef TILE_SIZE }; namespace SwapChain { @@ -306,8 +371,8 @@ namespace GAPI { sceGxmSyncObjectCreate(&color.syncObj); } - uint32 dsWidth = ALIGN(DISPLAY_WIDTH, SCE_GXM_TILE_SIZEX); - uint32 dsHeight = ALIGN(DISPLAY_HEIGHT, SCE_GXM_TILE_SIZEY); + uint32 dsWidth = ALIGNADDR(DISPLAY_WIDTH, SCE_GXM_TILE_SIZEX); + uint32 dsHeight = ALIGNADDR(DISPLAY_HEIGHT, SCE_GXM_TILE_SIZEY); depthBuffer.data = Context::allocGPU( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -364,8 +429,9 @@ namespace GAPI { }; // Shader + #include "shaders/gxm/shaders.h" + static const int bindings[uMAX] = { - 94, // uFlags 0, // uParam 1, // uTexParam 2, // uViewProj @@ -384,9 +450,13 @@ namespace GAPI { struct Shader { SceGxmVertexProgram *vp; - SceGxmFragmentProgram *fp; + SceGxmShaderPatcherId vpUID; SceGxmProgram *vpPtr, *fpPtr; - SceGxmShaderPatcherId vpUID, fpUID; + + struct PSO { + SceGxmFragmentProgram *fp; + SceGxmShaderPatcherId fpUID; + } pso[2 * bmMAX]; const SceGxmProgramParameter *vParams[uMAX]; const SceGxmProgramParameter *fParams[uMAX]; @@ -394,43 +464,99 @@ namespace GAPI { vec4 cbMem[98 + MAX_CONTACTS]; int cbCount[uMAX]; + SceGxmOutputRegisterFormat outputFmt; + int colorMask, blendMode; + int psoIndex; bool rebind; void init(Pass pass, int type, int *def, int defCount) { - const uint8 *vpSrc, *fpSrc; - switch (pass) { - case passCompose : vpSrc = COMPOSE_VP; fpSrc = COMPOSE_FP; break; - case passShadow : vpSrc = SHADOW_VP; fpSrc = SHADOW_FP; break; - case passAmbient : vpSrc = AMBIENT_VP; fpSrc = AMBIENT_FP; break; - case passWater : vpSrc = WATER_VP; fpSrc = WATER_FP; break; - case passFilter : vpSrc = FILTER_VP; fpSrc = FILTER_FP; break; - case passGUI : vpSrc = GUI_VP; fpSrc = GUI_FP; break; - case PASS_CLEAR : vpSrc = CLEAR_VP; fpSrc = CLEAR_FP; break; - default : ASSERT(false); LOG("! wrong pass id\n"); return; - } + memset(pso, 0, sizeof(pso)); - float *flags = (float*)(cbMem + bindings[uFlags]); - flags[type] = 1.0f; + outputFmt = SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4; + + bool underwater = false; + bool alphatest = false; for (int i = 0; i < defCount; i++) { switch (def[i]) { - case SD_UNDERWATER : flags[ 5] = 1.0f; break; - case SD_ALPHA_TEST : flags[ 6] = 1.0f; break; - case SD_CLIP_PLANE : flags[ 7] = 1.0f; break; - case SD_OPT_AMBIENT : flags[ 8] = 1.0f; break; - case SD_OPT_SHADOW : flags[ 9] = 1.0f; break; - case SD_OPT_CONTACT : flags[10] = 1.0f; break; - case SD_OPT_CAUSTICS : flags[11] = 1.0f; break; + case SD_UNDERWATER : underwater = true; break; + case SD_ALPHA_TEST : alphatest = true; break; } } - vpPtr = (SceGxmProgram*)vpSrc; - fpPtr = (SceGxmProgram*)fpSrc; + #define SHADER(S,P) S##_##P + #define SHADER_A(S,P) (alphatest ? SHADER(S##_a,P) : SHADER(S,P)) + #define SHADER_U(S,P) (underwater ? SHADER(S##_u,P) : SHADER(S,P)) + #define SHADER_AU(S,P) ((underwater && alphatest) ? SHADER(S##_au,P) : (alphatest ? SHADER(S##_a,P) : SHADER_U(S,P))) + + const uint8 *vSrc = NULL, *fSrc = NULL; + switch (pass) { + case passCompose : + switch (type) { + case 0 : vSrc = SHADER_U ( compose_sprite, v ); fSrc = SHADER_AU ( compose_sprite, f ); break; + case 1 : vSrc = SHADER ( compose_flash, v ); fSrc = SHADER ( compose_flash, f ); break; + case 2 : vSrc = SHADER_U ( compose_room, v ); fSrc = SHADER_AU ( compose_room, f ); break; + case 3 : vSrc = SHADER_U ( compose_entity, v ); fSrc = SHADER_AU ( compose_entity, f ); break; + case 4 : vSrc = SHADER ( compose_mirror, v ); fSrc = SHADER ( compose_mirror, f ); break; + default : ASSERT(false); + } + break; + case passShadow : + switch (type) { + case 3 : + case 4 : vSrc = SHADER ( shadow_entity, v ); fSrc = SHADER ( shadow_entity, f ); break; + default : ASSERT(false); + } + break; + case passAmbient : + switch (type) { + case 0 : vSrc = SHADER ( ambient_sprite, v ); fSrc = SHADER_A ( ambient_sprite, f ); break; + case 1 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER ( ambient_room, f ); break; // TYPE_FLASH (sky) + case 2 : vSrc = SHADER ( ambient_room, v ); fSrc = SHADER_A ( ambient_room, f ); break; + default : ASSERT(false); + } + break; + case passWater : + switch (type) { + case 0 : vSrc = SHADER ( water_drop, v ); fSrc = SHADER ( water_drop, f ); break; + case 1 : vSrc = SHADER ( water_simulate, v ); fSrc = SHADER ( water_simulate, f ); break; + case 2 : vSrc = SHADER ( water_caustics, v ); fSrc = SHADER ( water_caustics, f ); break; + case 3 : vSrc = SHADER ( water_rays, v ); fSrc = SHADER ( water_rays, f ); break; + case 4 : vSrc = SHADER ( water_mask, v ); fSrc = SHADER ( water_mask, f ); break; + case 5 : vSrc = SHADER ( water_compose, v ); fSrc = SHADER ( water_compose, f ); break; + default : ASSERT(false); + } + break; + case passFilter : + switch (type) { + case 0 : vSrc = SHADER ( filter_upscale, v ); fSrc = SHADER ( filter_upscale, f ); break; + case 1 : vSrc = SHADER ( filter_downsample, v ); fSrc = SHADER ( filter_downsample, f ); break; + case 3 : vSrc = SHADER ( filter_grayscale, v ); fSrc = SHADER ( filter_grayscale, f ); break; + case 4 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; + case 5 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; + default : ASSERT(false); + } + break; + case passGUI : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; + case passSky : vSrc = SHADER ( gui, v ); fSrc = SHADER ( gui, f ); break; + case PASS_CLEAR : vSrc = SHADER ( clear, v ); fSrc = SHADER ( clear, f ); break; + default : ASSERT(false); LOG("! wrong pass id\n"); return; + } + + #undef SHADER_A + #undef SHADER_U + #undef SHADER_AU + + if (pass == passWater && (type == 0 || type == 1)) { // water_simulate & water_drop use half2 render target + outputFmt = SCE_GXM_OUTPUT_REGISTER_FORMAT_HALF2; + } + + vpPtr = (SceGxmProgram*)vSrc; + fpPtr = (SceGxmProgram*)fSrc; sceGxmShaderPatcherRegisterProgram(shaderPatcher, vpPtr, &vpUID); - sceGxmShaderPatcherRegisterProgram(shaderPatcher, fpPtr, &fpUID); SceGxmVertexStream vStream; vStream.stride = sizeof(Vertex); @@ -467,20 +593,27 @@ namespace GAPI { } sceGxmShaderPatcherCreateVertexProgram(shaderPatcher, vpUID, vAttrib, vAttribCount, &vStream, 1, &vp); - sceGxmShaderPatcherCreateFragmentProgram(shaderPatcher, fpUID, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, SCE_GXM_MULTISAMPLE_NONE, NULL, vpPtr, &fp); for (int ut = 0; ut < uMAX; ut++) { vParams[ut] = sceGxmProgramFindParameterByName(vpPtr, UniformName[ut]); fParams[ut] = sceGxmProgramFindParameterByName(fpPtr, UniformName[ut]); } - colorMask = SCE_GXM_COLOR_MASK_ALL; - blendMode = 0; + colorMask = blendMode = -1; } void deinit() { + sceGxmDisplayQueueFinish(); + + sceGxmShaderPatcherReleaseVertexProgram(shaderPatcher, vp); sceGxmShaderPatcherUnregisterProgram(shaderPatcher, vpUID); - sceGxmShaderPatcherUnregisterProgram(shaderPatcher, fpUID); + + for (int i = 0; i < COUNT(pso); i++) { + if (pso[i].fp) { + sceGxmShaderPatcherReleaseFragmentProgram(shaderPatcher, pso[i].fp); + sceGxmShaderPatcherUnregisterProgram(shaderPatcher, pso[i].fpUID); + } + } } void setBlendInfo(int colorMask, int blendMode) { @@ -489,53 +622,79 @@ namespace GAPI { this->colorMask = colorMask; this->blendMode = blendMode; - SceGxmBlendInfo blendInfo; - blendInfo.colorMask = SceGxmColorMask(colorMask); - blendInfo.colorFunc = SCE_GXM_BLEND_FUNC_ADD; - blendInfo.alphaFunc = SCE_GXM_BLEND_FUNC_ADD; - + psoIndex = 0; switch (blendMode) { - case RS_BLEND_ALPHA : - blendInfo.colorSrc = blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - blendInfo.colorDst = blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case RS_BLEND_ADD : - blendInfo.colorSrc = blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE; - blendInfo.colorDst = blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ONE; - break; - case RS_BLEND_MULT : - blendInfo.colorSrc = blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR; - blendInfo.colorDst = blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case RS_BLEND_PREMULT : - blendInfo.colorSrc = blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE; - blendInfo.colorDst = blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - default : - blendInfo.colorSrc = blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE; - blendInfo.colorDst = blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO; + case RS_BLEND_ALPHA : psoIndex = bmAlpha; break; + case RS_BLEND_ADD : psoIndex = bmAdd; break; + case RS_BLEND_MULT : psoIndex = bmMult; break; + case RS_BLEND_PREMULT : psoIndex = bmPremult; break; + default : psoIndex = bmNone; + } + + if (outputFmt != SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4) { + psoIndex = 0; } - sceGxmShaderPatcherCreateFragmentProgram(shaderPatcher, fpUID, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, SCE_GXM_MULTISAMPLE_NONE, &blendInfo, vpPtr, &fp); + if (colorMask != SCE_GXM_COLOR_MASK_ALL) { + psoIndex += bmMAX; + } + + PSO &p = pso[psoIndex]; + + if (!p.fp) { + SceGxmBlendInfo blendInfo; + blendInfo.colorMask = SceGxmColorMask(colorMask); + blendInfo.colorFunc = SCE_GXM_BLEND_FUNC_ADD; + blendInfo.alphaFunc = SCE_GXM_BLEND_FUNC_ADD; + blendInfo.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE; + blendInfo.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO; + + switch (blendMode) { + case RS_BLEND_ALPHA : + blendInfo.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; + blendInfo.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + break; + case RS_BLEND_ADD : + blendInfo.colorSrc = SCE_GXM_BLEND_FACTOR_ONE; + blendInfo.colorDst = SCE_GXM_BLEND_FACTOR_ONE; + break; + case RS_BLEND_MULT : + blendInfo.colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR; + blendInfo.colorDst = SCE_GXM_BLEND_FACTOR_ZERO; + break; + case RS_BLEND_PREMULT : + blendInfo.colorSrc = SCE_GXM_BLEND_FACTOR_ONE; + blendInfo.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + break; + default : + blendInfo.colorSrc = SCE_GXM_BLEND_FACTOR_ONE; + blendInfo.colorDst = SCE_GXM_BLEND_FACTOR_ZERO; + } + createFP(p, &blendInfo); + } rebind = true; } + void createFP(PSO &p, SceGxmBlendInfo *blendInfo) { + sceGxmShaderPatcherRegisterProgram(shaderPatcher, fpPtr, &p.fpUID); + sceGxmShaderPatcherCreateFragmentProgram(shaderPatcher, p.fpUID, outputFmt, SCE_GXM_MULTISAMPLE_NONE, blendInfo, vpPtr, &p.fp); + } + void bind() { if (active.shader != this) { active.shader = this; memset(cbCount, 0, sizeof(cbCount)); - cbCount[uFlags] = 16; rebind = true; } } - void setup() { + void validate() { if (rebind) { sceGxmSetVertexProgram(Context::gxmContext, vp); - sceGxmSetFragmentProgram(Context::gxmContext, fp); + sceGxmSetFragmentProgram(Context::gxmContext, pso[psoIndex].fp); rebind = false; } @@ -544,116 +703,163 @@ namespace GAPI { void *buff; if (vParams[uType]) { sceGxmReserveVertexDefaultUniformBuffer(Context::gxmContext, &buff); - sceGxmSetUniformDataF(buff, vParams[uType], 0, cbCount[uType], (float*)(cbMem + bindings[uType])); + sceGxmSetUniformDataF(buff, vParams[uType], 0, cbCount[uType] * 4, (float*)(cbMem + bindings[uType])); } if (fParams[uType]) { sceGxmReserveFragmentDefaultUniformBuffer(Context::gxmContext, &buff); - sceGxmSetUniformDataF(buff, fParams[uType], 0, cbCount[uType], (float*)(cbMem + bindings[uType])); + sceGxmSetUniformDataF(buff, fParams[uType], 0, cbCount[uType] * 4, (float*)(cbMem + bindings[uType])); } } } void setParam(UniformType uType, float *value, int count) { cbCount[uType] = count; - memcpy(cbMem + bindings[uType], value, count * 4); + memcpy(cbMem + bindings[uType], value, count * 16); } void setParam(UniformType uType, const vec4 &value, int count = 1) { - setParam(uType, (float*)&value, count * 4); + setParam(uType, (float*)&value, count); } void setParam(UniformType uType, const mat4 &value, int count = 1) { - setParam(uType, (float*)&value, count * 16); - } - - void setParam(UniformType uType, const Basis &value, int count = 1) { - setParam(uType, (float*)&value, count * 8); + setParam(uType, (float*)&value, count * 4); } }; // Texture + static const struct FormatDesc { + uint32 bpp, textureFormat, targetFormat; + } formats[FMT_MAX] = { + { 8, SCE_GXM_TEXTURE_FORMAT_U8_1RRR , SCE_GXM_COLOR_FORMAT_U8_R }, // LUMINANCE + { 32, SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR , SCE_GXM_COLOR_FORMAT_A8B8G8R8 }, // RGBA + { 16, SCE_GXM_TEXTURE_FORMAT_U5U6U5_BGR , SCE_GXM_COLOR_FORMAT_U5U6U5_BGR }, // RGB16 + { 16, SCE_GXM_TEXTURE_FORMAT_U1U5U5U5_ABGR , SCE_GXM_COLOR_FORMAT_U1U5U5U5_ABGR }, // RGBA16 + { 64, SCE_GXM_TEXTURE_FORMAT_F32F32_GR , SCE_GXM_COLOR_FORMAT_F32F32_GR }, // RG_FLOAT // not supported + { 32, SCE_GXM_TEXTURE_FORMAT_F16F16_GR , SCE_GXM_COLOR_FORMAT_F16F16_GR }, // RG_HALF + { 32, SCE_GXM_TEXTURE_FORMAT_F32M_R , SCE_GXM_DEPTH_STENCIL_FORMAT_DF32 }, // DEPTH + { 32, SCE_GXM_TEXTURE_FORMAT_F32M_R , SCE_GXM_DEPTH_STENCIL_FORMAT_DF32 }, // SHADOW + }; + struct Texture { SceGxmTexture ID; - void *data; + uint8 *data; SceUID uid; - int size; - int width, height, origWidth, origHeight; + int width, height, depth, origWidth, origHeight, origDepth, aWidth, aHeight; TexFormat fmt; uint32 opt; + int mipCount; SceGxmColorSurface colorSurface; SceGxmRenderTarget *renderTarget; - SceUID depthBufferUID; - SceGxmDepthStencilSurface depthSurface; - void *depthBufferData; - + SceUID depthBufferUID; + SceGxmDepthStencilSurface depthSurface; + void *depthBufferData; - Texture(int width, int height, uint32 opt) : width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {} + Texture(int width, int height, int depth, uint32 opt) : width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) { opt |= OPT_NEAREST; } void init(void *data) { ASSERT((opt & OPT_PROXY) == 0); - bool filter = (opt & OPT_NEAREST) == 0; - bool mipmaps = (opt & OPT_MIPMAPS) != 0; - bool cube = (opt & OPT_CUBEMAP) != 0; - bool isTarget = (opt & OPT_TARGET) != 0; - bool isShadow = fmt == FMT_SHADOW; - - static const struct FormatDesc { - uint32 bpp, textureFormat, targetFormat; - } formats[FMT_MAX] = { - { 8, SCE_GXM_TEXTURE_FORMAT_U8_1RRR , SCE_GXM_COLOR_FORMAT_U8_R }, // LUMINANCE - { 32, SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB , SCE_GXM_COLOR_FORMAT_A8R8G8B8 }, // RGBA - { 16, SCE_GXM_TEXTURE_FORMAT_U5U6U5_RGB , SCE_GXM_COLOR_FORMAT_U5U6U5_RGB }, // RGB16 - { 16, SCE_GXM_TEXTURE_FORMAT_U1U5U5U5_ARGB , SCE_GXM_COLOR_FORMAT_U1U5U5U5_ARGB }, // RGBA16 - { 32, SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB , SCE_GXM_COLOR_FORMAT_A8R8G8B8 }, // RGBA - { 32, SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB , SCE_GXM_COLOR_FORMAT_A8R8G8B8 }, // RGBA -// { 64, SCE_GXM_TEXTURE_FORMAT_F16F16F16F16_ARGB , SCE_GXM_COLOR_FORMAT_F16F16F16F16_RGBA }, // RGBA_FLOAT // not supported -// { 64, SCE_GXM_TEXTURE_FORMAT_F16F16F16F16_ARGB , SCE_GXM_COLOR_FORMAT_F16F16F16F16_RGBA }, // RGBA_HALF - { 32, SCE_GXM_TEXTURE_FORMAT_F32M_R , SCE_GXM_DEPTH_STENCIL_FORMAT_DF32 }, // DEPTH - { 32, SCE_GXM_TEXTURE_FORMAT_F32M_R , SCE_GXM_DEPTH_STENCIL_FORMAT_DF32 }, // SHADOW - }; + bool filter = (opt & OPT_NEAREST) == 0; + bool mipmaps = (opt & OPT_MIPMAPS) != 0; + bool isCube = (opt & OPT_CUBEMAP) != 0; + bool isTarget = (opt & OPT_TARGET) != 0; + bool isDynamic = (opt & OPT_DYNAMIC) != 0; + bool isTiled = isTarget; + bool isSwizzled = !isDynamic && !isTiled && filter; FormatDesc desc = formats[fmt]; - if (data && !support.texNPOT && (width != origWidth || height != origHeight)) - data = NULL; + if (isSwizzled) { + aWidth = width = nextPow2(width); + aHeight = height = nextPow2(height); + } else if (isTiled) { + aWidth = ALIGNADDR(width, SCE_GXM_TILE_SIZEX); + aHeight = ALIGNADDR(height, SCE_GXM_TILE_SIZEY); + } else { + aWidth = ALIGNADDR(width, 8); + aHeight = height; + } - uint32 aWidth = width; - uint32 aHeight = height; + int size = 0; - if (fmt == FMT_DEPTH || fmt == FMT_SHADOW) { - aWidth = ALIGN(aWidth, SCE_GXM_TILE_SIZEX); - aHeight = ALIGN(aHeight, SCE_GXM_TILE_SIZEY); + if (isCube || isTiled || fmt != FMT_RGBA) { + mipmaps = false; } - size = aWidth * aHeight * desc.bpp / 8 * (cube ? 6 : 1); + mipCount = 0; + if (mipmaps) { + int w = width; + int h = height; + while (w > 15 && h > 15 && mipCount < 4) { + size += ALIGNADDR(w, 8) * h; + w /= 2; + h /= 2; + mipCount++; + } + } else { + size += aWidth * aHeight; + } - SceGxmMemoryAttribFlags flags = isTarget ? SCE_GXM_MEMORY_ATTRIB_RW : SCE_GXM_MEMORY_ATTRIB_READ; - this->data = Context::allocGPU(SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, size, flags, &uid); + if (mipCount > 1) { + isSwizzled = false; + } - if (data && this->data) { - memcpy(this->data, data, size); + size *= desc.bpp / 8; + + if (isCube) { + size *= 6; } - if (fmt == FMT_DEPTH || fmt == FMT_SHADOW) { - sceGxmTextureInitTiled(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, 1); - } else { - if (cube) { - sceGxmTextureInitCube(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, 1); + SceGxmMemoryAttribFlags flags = (isTarget || isDynamic || mipCount > 1) ? SCE_GXM_MEMORY_ATTRIB_RW : SCE_GXM_MEMORY_ATTRIB_READ; + this->data = (uint8*)Context::allocGPU(SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, size, flags, &uid); + + if (data && this->data) { + if (isSwizzled || isTiled) { + if (aWidth != origWidth || aHeight != origHeight) { + uint8 *tmp = new uint8[aWidth * aHeight * desc.bpp / 8]; + swap(this->data, tmp); + updateData(data); + swap(this->data, tmp); + if (isSwizzled) { + Context::swizzleImage(this->data, tmp, aWidth, aHeight, desc.bpp); + } else { + Context::tileImage(this->data, tmp, aWidth, aHeight, desc.bpp); + } + delete[] tmp; + } else { + if (isSwizzled) { + Context::swizzleImage(this->data, data, aWidth, aHeight, desc.bpp); + } else { + Context::tileImage(this->data, data, aWidth, aHeight, desc.bpp); + } + } } else { - sceGxmTextureInitLinear(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, 1); + updateData(data); } } + //generateMipMap(); + + if (isCube) { + sceGxmTextureInitCube(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, mipCount); + } else if (isSwizzled) { + sceGxmTextureInitSwizzled(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, mipCount); + } else if (isTiled) { + sceGxmTextureInitTiled(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, mipCount); + } else { + sceGxmTextureInitLinear(&ID, this->data, SceGxmTextureFormat(desc.textureFormat), width, height, mipCount); + } + SceGxmTextureAddrMode addrMode; if (opt & OPT_REPEAT) { addrMode = SCE_GXM_TEXTURE_ADDR_REPEAT; } else { - addrMode = (isShadow && support.texBorder) ? SCE_GXM_TEXTURE_ADDR_CLAMP_FULL_BORDER : SCE_GXM_TEXTURE_ADDR_CLAMP; + addrMode = SCE_GXM_TEXTURE_ADDR_CLAMP; } + sceGxmTextureSetUAddrMode(&ID, addrMode); sceGxmTextureSetUAddrMode(&ID, addrMode); @@ -674,13 +880,13 @@ namespace GAPI { } else { sceGxmColorSurfaceInit(&colorSurface, SceGxmColorFormat(desc.targetFormat), - SCE_GXM_COLOR_SURFACE_LINEAR, + isSwizzled ? SCE_GXM_COLOR_SURFACE_SWIZZLED : (isTiled ? SCE_GXM_COLOR_SURFACE_TILED : SCE_GXM_COLOR_SURFACE_LINEAR), SCE_GXM_COLOR_SURFACE_SCALE_NONE, - SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, - width, height, width, this->data); + desc.bpp > 32 ? SCE_GXM_OUTPUT_REGISTER_SIZE_64BIT : SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, + aWidth, aHeight, aWidth, this->data); - uint32 dsWidth = ALIGN(width, SCE_GXM_TILE_SIZEX); - uint32 dsHeight = ALIGN(height, SCE_GXM_TILE_SIZEY); + uint32 dsWidth = ALIGNADDR(width, SCE_GXM_TILE_SIZEX); + uint32 dsHeight = ALIGNADDR(height, SCE_GXM_TILE_SIZEY); depthBufferData = Context::allocGPU( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -696,8 +902,8 @@ namespace GAPI { SceGxmRenderTargetParams params; memset(¶ms, 0, sizeof(params)); - params.width = width; - params.height = height; + params.width = aWidth; + params.height = aHeight; params.scenesPerFrame = 1; params.multisampleMode = SCE_GXM_MULTISAMPLE_NONE; params.driverMemBlock = -1; @@ -716,21 +922,69 @@ namespace GAPI { Context::freeGPU(uid, true); } - void generateMipMap() { - /* - bind(0); - GLenum target = (opt & OPT_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; + void generateMipMap() { // TODO: cubemap + if (mipCount <= 1) return; + + int w = width; + int h = height; + + uint8 *src = this->data; + int srcStride = ALIGNADDR(w, 8) * 4; + + for (int i = 0; i < mipCount - 1; i++) { + uint8 *dst = src + srcStride * h; + int dstStride = ALIGNADDR(w / 2, 8) * 4; + + // TODO: check for NPOT + if (w > 1024 || h > 1024) { // sceGxmTransferDownscale supports blocks less than 1024 + int blocksX = max(1, w / 1024); + int blocksY = max(1, h / 1024); + for (int y = 0; y < blocksY; y++) { + for (int x = 0; x < blocksX; x++) { + int blockWidth = min(1024, w - x * 1024); + int blockHeight = min(1024, h - y * 1024); + sceGxmTransferDownscale( + SCE_GXM_TRANSFER_FORMAT_U8U8U8U8_ABGR, src, x * 1024, y * 1024, blockWidth, blockHeight, srcStride, + SCE_GXM_TRANSFER_FORMAT_U8U8U8U8_ABGR, dst, x * 512, y * 512, dstStride, + NULL, SCE_GXM_TRANSFER_FRAGMENT_SYNC, NULL); + } + } + } else { + sceGxmTransferDownscale( + SCE_GXM_TRANSFER_FORMAT_U8U8U8U8_ABGR, src, 0, 0, w, h, srcStride, + SCE_GXM_TRANSFER_FORMAT_U8U8U8U8_ABGR, dst, 0, 0, dstStride, + NULL, SCE_GXM_TRANSFER_FRAGMENT_SYNC, NULL); + } + + w /= 2; + h /= 2; + src = dst; + srcStride = dstStride; + } - glGenerateMipmap(target); - if (!(opt & OPT_CUBEMAP) && !(opt & OPT_NEAREST) && (support.maxAniso > 0)) - glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, min(int(support.maxAniso), 8)); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4); - */ + sceGxmTextureSetMipFilter(&ID, SCE_GXM_TEXTURE_MIP_FILTER_ENABLED); + } + + void updateData(void *data) { + FormatDesc desc = formats[fmt]; + + if (aWidth != origWidth || aHeight != origHeight) { + uint8 *dst = (uint8*)this->data; + uint8 *src = (uint8*)data; + for (int y = 0; y < origHeight; y++) { + memcpy(dst, src, origWidth * desc.bpp / 8); + src += origWidth * desc.bpp / 8; + dst += aWidth * desc.bpp / 8; + } + } else { + memcpy(this->data, data, aWidth * aHeight * desc.bpp / 8); + } } void update(void *data) { - if (!data) return; - memcpy(this->data, data, size); + if (data) { + updateData(data); + } } void bind(int sampler) { @@ -771,30 +1025,38 @@ namespace GAPI { SceUID iBufferUID; SceUID vBufferUID; - int iCount; - int vCount; - bool dynamic; struct Chunk { int frameIndex; - int iStart, iCount; - int vStart, vCount; + int iBase, iStart, iCount; + int vBase, vStart, vCount; } chunks[DISPLAY_BUFFER_COUNT]; Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {} void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) { ASSERT(sizeof(GAPI::Vertex) == sizeof(::Vertex)); + memset(chunks, 0, sizeof(chunks)); - this->iCount = iCount; - this->vCount = vCount; + for (int i = 0; i < COUNT(chunks); i++) { + chunks[i].frameIndex = -1; + chunks[i].iBase = i * iCount; + chunks[i].vBase = i * vCount; + } + + if (dynamic) { + iCount *= COUNT(chunks); + vCount *= COUNT(chunks); + } iBuffer = (Index*) Context::allocGPU(SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, iCount * sizeof(Index), SCE_GXM_MEMORY_ATTRIB_READ, &iBufferUID); vBuffer = (Vertex*) Context::allocGPU(SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, vCount * sizeof(Vertex), SCE_GXM_MEMORY_ATTRIB_READ, &vBufferUID); - update(indices, iCount, vertices, vCount); + if (!dynamic) { + update(indices, iCount, vertices, vCount); + } } void deinit() { @@ -810,8 +1072,8 @@ namespace GAPI { Chunk &chunk = getChunk(); if (chunk.frameIndex != Core::stats.frameIndex) { chunk.frameIndex = Core::stats.frameIndex; - chunk.iStart = chunk.iCount = 0; - chunk.vStart = chunk.vCount = 0; + chunk.iStart = chunk.iCount = chunk.iBase; + chunk.vStart = chunk.vCount = chunk.vBase; } if (indices && iCount) { @@ -853,23 +1115,14 @@ namespace GAPI { // LOG("VRAM : %d\n", EDRAM_SIZE); // freeEDRAM(); - support.maxAniso = 0; - support.maxVectors = 0; - support.shaderBinary = false; - support.VAO = false; + support.shaderBinary = true; support.depthTexture = true; support.shadowSampler = true; - support.discardFrame = false; support.texNPOT = true; support.texRG = true; - support.texBorder = false; - support.colorFloat = false; support.colorHalf = true; - support.texFloatLinear = false; - support.texFloat = false; support.texHalfLinear = true; support.texHalf = true; - support.clipDist = true; Core::width = DISPLAY_WIDTH; Core::height = DISPLAY_HEIGHT; @@ -878,7 +1131,7 @@ namespace GAPI { SceGxmInitializeParams params; memset(¶ms, 0, sizeof(params)); params.displayQueueMaxPendingCount = DISPLAY_BUFFER_COUNT - 1; - params.displayQueueCallback = display_queue_callback; + params.displayQueueCallback = displayCallback; params.displayQueueCallbackDataSize = sizeof(DisplayData); params.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; @@ -920,7 +1173,7 @@ namespace GAPI { vertices[2].coord = short4{-1, 3, 1, 1}; clearMesh.init(indices, 3, vertices, 3, 0); - clearColor = vec4(1.0f, 1.0f, 0.0f, 1.0f); + clearColor = vec4(0.0f); colorMask = SCE_GXM_COLOR_MASK_ALL; blendMode = 0; @@ -939,12 +1192,20 @@ namespace GAPI { sceGxmTerminate(); } + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_NEG_POS; + } + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { - return mat4(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar); + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; } - mat4 perspective(float fov, float aspect, float znear, float zfar) { - return mat4(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar); + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; } bool beginFrame() { @@ -955,7 +1216,7 @@ namespace GAPI { } bool hasScene; - Texture defTarget(DISPLAY_WIDTH, DISPLAY_HEIGHT, OPT_TARGET); + Texture defTarget(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1, OPT_TARGET); void resetState() { hasScene = false; @@ -1000,6 +1261,10 @@ namespace GAPI { } else { ASSERT(target->opt & OPT_TARGET); + uint32 flags = SCE_GXM_SCENE_VERTEX_TRANSFER_SYNC; + if (target->opt & OPT_VERTEX) flags |= SCE_GXM_SCENE_FRAGMENT_SET_DEPENDENCY; + if (target->opt & OPT_DEPEND) flags |= SCE_GXM_SCENE_VERTEX_WAIT_FOR_DEPENDENCY; + SceGxmColorSurface *colorSurface = (target->fmt == FMT_DEPTH || target->fmt == FMT_SHADOW) ? NULL : &target->colorSurface; bool loadDepth = (Core::reqTarget.op & RT_LOAD_DEPTH); @@ -1008,32 +1273,9 @@ namespace GAPI { sceGxmDepthStencilSurfaceSetForceLoadMode ( &target->depthSurface, loadDepth ? SCE_GXM_DEPTH_STENCIL_FORCE_LOAD_ENABLED : SCE_GXM_DEPTH_STENCIL_FORCE_LOAD_DISABLED ); sceGxmDepthStencilSurfaceSetForceStoreMode ( &target->depthSurface, storeDepth ? SCE_GXM_DEPTH_STENCIL_FORCE_STORE_ENABLED : SCE_GXM_DEPTH_STENCIL_FORCE_STORE_DISABLED ); - sceGxmBeginScene(Context::gxmContext, 0, target->renderTarget, NULL, NULL, NULL, colorSurface, &target->depthSurface); - - - - /* - bool depth = target->fmt == FMT_DEPTH || target->fmt == FMT_SHADOW; - - if (target->tex2D) { - D3DCHECK(target->tex2D->GetSurfaceLevel(0, &surface)); - } else if (target->texCube) - D3DCHECK(target->texCube->GetCubeMapSurface(D3DCUBEMAP_FACES(D3DCUBEMAP_FACE_POSITIVE_X + face), 0, &surface)); - - int rtIndex = cacheRenderTarget(!depth, target->width, target->height); - - if (depth) { - D3DCHECK(device->SetRenderTarget(0, rtCache[false].items[rtIndex].surface)); - D3DCHECK(device->SetDepthStencilSurface(surface)); - } else { - D3DCHECK(device->SetRenderTarget(0, surface)); - D3DCHECK(device->SetDepthStencilSurface(rtCache[true].items[rtIndex].surface)); - } - - surface->Release(); - */ + sceGxmBeginScene(Context::gxmContext, flags, target->renderTarget, NULL, NULL, NULL, colorSurface, &target->depthSurface); } - active.viewport = Viewport(0, 0, 0, 0); // forcing viewport reset + active.viewport = short4(0, 0, 0, 0); // forcing viewport reset } void discardTarget(bool color, bool depth) {} @@ -1053,12 +1295,16 @@ namespace GAPI { Context::checkPendings(); } - void setViewport(const Viewport &vp) { + void setViewport(const short4 &v) { int vh = active.target ? active.target->height : Core::height; - int sw = vp.width / 2; - int sh = vp.height / 2; - sceGxmSetViewport(Context::gxmContext, float(vp.x + sw), float(sw), float(vh - vp.y - sh), float(-sh), 0.0f, 1.0f); - sceGxmSetRegionClip(Context::gxmContext, SCE_GXM_REGION_CLIP_OUTSIDE, vp.x, vh - vp.y - vp.height, vp.x + vp.width, vp.y + vp.height); + int sw = v.z / 2; + int sh = v.w / 2; + sceGxmSetViewport(Context::gxmContext, float(v.x + sw), float(sw), float(vh - v.y - sh), float(-sh), 0.0f, 1.0f); + } + + void setScissor(const short4 &s) { + //int vh = active.target ? active.target->height : Core::height; + //sceGxmSetRegionClip(Context::gxmContext, SCE_GXM_REGION_CLIP_OUTSIDE, 0, 0, 256, 256); } void setDepthTest(bool enable) { @@ -1106,7 +1352,7 @@ namespace GAPI { if (!active.shader) return; active.shader->setBlendInfo(colorMask, blendMode); - active.shader->setup(); + active.shader->validate(); sceGxmDraw(Context::gxmContext, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, mesh->iBuffer + mesh->getChunk().iStart + range.iStart, range.iCount); } @@ -1118,6 +1364,7 @@ namespace GAPI { } void clear(bool color, bool depth) { + // TODO save and restore states int oColorMask = colorMask; int oBlendMode = blendMode; bool oDepthTest = depthTest; @@ -1166,22 +1413,6 @@ namespace GAPI { // return vec4(color->r, color->g, color->b, 255.0f) * (1.0f / 255.0f); return vec4(0.0f); // TODO: read from framebuffer } - - void initPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso && pso->data == NULL); - pso->data = &pso; - } - - void deinitPSO(PSO *pso) { - ASSERT(pso); - ASSERT(pso->data != NULL); - pso->data = NULL; - } - - void bindPSO(const PSO *pso) { - // - } } #endif \ No newline at end of file diff --git a/src/gapi/sw.h b/src/gapi/sw.h new file mode 100644 index 00000000..7086699e --- /dev/null +++ b/src/gapi/sw.h @@ -0,0 +1,761 @@ +#ifndef H_GAPI_SW +#define H_GAPI_SW + +#include "core.h" + +#define PROFILE_MARKER(title) +#define PROFILE_LABEL(id, name, label) +#define PROFILE_TIMING(time) + +//#define DITHER_FILTER + +#if defined(_OS_LINUX) || defined(_OS_TNS) + #define COLOR_16 +#endif + +#ifdef COLOR_16 + #if defined(_OS_LINUX) || defined(_OS_TNS) + #define COLOR_FMT_565 + #define CONV_COLOR(r,g,b) (((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)) + #else + #define COLOR_FMT_555 + #define CONV_COLOR(r,g,b) (((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3)) + #endif +#else + #define COLOR_FMT_888 + #define CONV_COLOR(r,g,b) ((r << 16) | (g << 8) | b) +#endif + +#define SW_MAX_DIST (20.0f * 1024.0f) +#define SW_FOG_START (12.0f * 1024.0f) + +namespace GAPI { + + using namespace Core; + + typedef ::Vertex Vertex; + + #ifdef COLOR_16 + typedef uint16 ColorSW; + #else + typedef uint32 ColorSW; + #endif + typedef uint16 DepthSW; + + uint8 *swLightmap; + uint8 swLightmapNone[32 * 256]; + uint8 swLightmapShade[32 * 256]; + ColorSW *swPalette; + ColorSW swPaletteColor[256]; + ColorSW swPaletteWater[256]; + ColorSW swPaletteGray[256]; + uint8 swGradient[256]; + Tile8 *curTile; + + uint8 ambient; + int32 lightsCount; + + struct LightSW { + uint32 intensity; + vec3 pos; + float radius; + } lights[MAX_LIGHTS], lightsRel[MAX_LIGHTS]; + +// Shader + struct Shader { + void init(Pass pass, int type, int *def, int defCount) {} + void deinit() {} + void bind() {} + void setParam(UniformType uType, const vec4 &value, int count = 1) {} + void setParam(UniformType uType, const mat4 &value, int count = 1) {} + }; + +// Texture + struct Texture { + uint8 *memory; + int width, height, origWidth, origHeight; + TexFormat fmt; + uint32 opt; + + Texture(int width, int height, int depth, uint32 opt) : memory(0), width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {} + + void init(void *data) { + ASSERT((opt & OPT_PROXY) == 0); + + opt &= ~(OPT_CUBEMAP | OPT_MIPMAPS); + + memory = new uint8[width * height * 4]; + if (data) { + update(data); + } + } + + void deinit() { + if (memory) { + delete[] memory; + } + } + + void generateMipMap() {} + + void update(void *data) { + memcpy(memory, data, width * height * 4); + } + + void bind(int sampler) { + Core::active.textures[sampler] = this; + + if (!this || (opt & OPT_PROXY)) return; + ASSERT(memory); + + curTile = NULL; + } + + void bindTileIndices(Tile8 *tile) { + curTile = (Tile8*)tile; + } + + void unbind(int sampler) {} + + void setFilterQuality(int value) { + if (value > Settings::LOW) + opt &= ~OPT_NEAREST; + else + opt |= OPT_NEAREST; + } + }; + +// Mesh + struct Mesh { + Index *iBuffer; + GAPI::Vertex *vBuffer; + + int iCount; + int vCount; + bool dynamic; + + Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {} + + void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) { + this->iCount = iCount; + this->vCount = vCount; + + iBuffer = new Index[iCount]; + vBuffer = new Vertex[vCount]; + + update(indices, iCount, vertices, vCount); + } + + void deinit() { + delete[] iBuffer; + delete[] vBuffer; + } + + void update(Index *indices, int iCount, ::Vertex *vertices, int vCount) { + if (indices) { + memcpy(iBuffer, indices, iCount * sizeof(indices[0])); + } + + if (vertices) { + memcpy(vBuffer, vertices, vCount * sizeof(vertices[0])); + } + } + + void bind(const MeshRange &range) const {} + + void initNextRange(MeshRange &range, int &aIndex) const { + range.aIndex = -1; + } + }; + + + int cullMode, blendMode; + + ColorSW *swColor; + DepthSW *swDepth; + short4 swClipRect; + + struct VertexSW { + int32 x, y, z, w; + int32 u, v, l; + + inline VertexSW operator + (const VertexSW &p) const { + VertexSW ret; + ret.x = x + p.x; + ret.y = y; + ret.z = z + p.z; + ret.w = w + p.w; + ret.u = u + p.u; + ret.v = v + p.v; + ret.l = l + p.l; + return ret; + } + + inline VertexSW operator - (const VertexSW &p) const { + VertexSW ret; + ret.x = x - p.x; + ret.y = y; + ret.z = z - p.z; + ret.w = w - p.w; + ret.u = u - p.u; + ret.v = v - p.v; + ret.l = l - p.l; + return ret; + } + + inline VertexSW operator * (const int32 s) const { + VertexSW ret; + ret.x = x * s; + ret.y = y; + ret.z = z * s; + ret.w = w * s; + ret.u = u * s; + ret.v = v * s; + ret.l = l * s; + return ret; + } + + inline VertexSW operator / (const int32 s) const { + VertexSW ret; + ret.x = x / s; + ret.y = y; + ret.z = z / s; + ret.w = w / s; + ret.u = u / s; + ret.v = v / s; + ret.l = l / s; + return ret; + } + }; + + Array swVertices; + Array swIndices; + Array swTriangles; + Array swQuads; + + void init() { + LOG("Renderer : %s\n", "Software"); + LOG("Version : %s\n", "0.1"); + swDepth = NULL; + } + + void deinit() { + delete[] swDepth; + swVertices.clear(); + swIndices.clear(); + swTriangles.clear(); + swQuads.clear(); + } + + void resize() { + delete[] swDepth; + //swDepth = new DepthSW[Core::width * Core::height]; + } + + inline mat4::ProjRange getProjRange() { + return mat4::PROJ_ZERO_POS; + } + + mat4 ortho(float l, float r, float b, float t, float znear, float zfar) { + mat4 m; + m.ortho(getProjRange(), l, r, b, t, znear, zfar); + return m; + } + + mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) { + mat4 m; + m.perspective(getProjRange(), fov, aspect, znear, zfar, eye); + return m; + } + + bool beginFrame() { + return true; + } + + void endFrame() {} + + void resetState() {} + + void bindTarget(Texture *texture, int face) {} + + void discardTarget(bool color, bool depth) {} + + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) {} + + void setVSync(bool enable) {} + + void waitVBlank() {} + + void clear(bool color, bool depth) { + if (color) { + memset(swColor, 0x00, Core::width * Core::height * sizeof(ColorSW)); + } + + if (depth) { + //memset(swDepth, 0xFF, Core::width * Core::height * sizeof(DepthSW)); + } + } + + void setClearColor(const vec4 &color) {} + + void setViewport(const short4 &v) {} + + void setScissor(const short4 &s) { + swClipRect.x = s.x; + swClipRect.y = Core::active.viewport.w - (s.y + s.w); + swClipRect.z = s.x + s.z; + swClipRect.w = Core::active.viewport.w - s.y; + } + + void setDepthTest(bool enable) {} + + void setDepthWrite(bool enable) {} + + void setColorWrite(bool r, bool g, bool b, bool a) {} + + void setAlphaTest(bool enable) {} + + void setCullMode(int rsMask) {} + + void setBlendMode(int rsMask) {} + + void setViewProj(const mat4 &mView, const mat4 &mProj) {} + + void updateLights(vec4 *lightPos, vec4 *lightColor, int count) { + ambient = clamp(int32(active.material.y * 255), 0, 255); + + lightsCount = 0; + for (int i = 0; i < count; i++) { + if (lightColor[i].w >= 1.0f) { + continue; + } + LightSW &light = lights[lightsCount++]; + vec4 &c = lightColor[i]; + light.intensity = uint32(((c.x + c.y + c.z) / 3.0f) * 255.0f); + light.pos = lightPos[i].xyz(); + light.radius = lightColor[i].w; + } + } + + void setFog(const vec4 ¶ms) {} + + bool checkBackface(const VertexSW *a, const VertexSW *b, const VertexSW *c) { + return ((b->x - a->x) >> 16) * (c->y - a->y) - + ((c->x - a->x) >> 16) * (b->y - a->y) <= 0; + } + + inline void sortVertices(VertexSW *&t, VertexSW *&m, VertexSW *&b) { + if (t->y > m->y) swap(t, m); + if (t->y > b->y) swap(t, b); + if (m->y > b->y) swap(m, b); + } + + inline void sortVertices(VertexSW *&t, VertexSW *&m, VertexSW *&b, VertexSW *&o) { + if (t->y > m->y) swap(t, m); + if (o->y > b->y) swap(o, b); + if (t->y > o->y) swap(t, o); + if (m->y > b->y) swap(m, b); + if (m->y > o->y) swap(m, o); + } + + inline void step(VertexSW &v, const VertexSW &d) { + //v.w += d.w; + v.u += d.u; + v.v += d.v; + v.l += d.l; + } + + inline void step(VertexSW &v, const VertexSW &d, int32 count) { + //v.w += d.w * count; + v.u += d.u * count; + v.v += d.v * count; + v.l += d.l * count; + } + + // https://www.flipcode.com/archives/Texturing_As_In_Unreal.shtml + const int uvDither[8] = { + 32768, 16384, 0, 49152, // (xx yy) for (y & 1 == 0) + 49152, 0, 32768, 16384 // (xx yy) for (y & 1 == 1) + }; + + void drawLine(const VertexSW &L, const VertexSW &R, int32 y) { + int32 x1 = L.x >> 16; + int32 x2 = R.x >> 16; + + int32 f = x2 - x1; + if (f == 0) return; + + VertexSW dS = (R - L) / f; + VertexSW S = L; + + if (x1 < swClipRect.x) { + x1 = swClipRect.x - x1; + S.z += dS.z * x1; + step(S, dS, x1); + x1 = swClipRect.x; + } + if (x2 > swClipRect.z) x2 = swClipRect.z; + + int32 i = y * Core::width; + + #ifdef DITHER_FILTER + const int *dithY = uvDither + ((y & 1) * 4); + #endif + + for (int x = i + x1; x < i + x2; x++) { + S.z += dS.z; + + DepthSW z = DepthSW(uint32(S.z) >> 16); + + {//if (swDepth[x] >= z) { + #ifdef DITHER_FILTER + const int *dithX = dithY + (x & 1); + + uint32 u = uint32(S.u + dithX[0]) >> 16; + uint32 v = uint32(S.v + dithX[2]) >> 16; + #else + uint32 u = uint32(S.u) >> 16; + uint32 v = uint32(S.v) >> 16; + #endif + + uint8 index = curTile->index[(v << 8) + u]; + + if (index != 0) { + index = swLightmap[((S.l >> (16 + 3)) << 8) + index]; + + swColor[x] = swPalette[index]; + //swDepth[x] = z; + } + } + + step(S, dS); + } + } + + void drawPart(const VertexSW &a, const VertexSW &b, const VertexSW &c, const VertexSW &d) { + VertexSW L, R, dL, dR; + int32 minY, maxY; + + int32 f = c.y - a.y; + dL = (c - a) / f; + dR = (d - b) / f; + + L = a; + R = b; + + minY = a.y; + maxY = c.y; + + if (maxY < swClipRect.y || minY >= swClipRect.w) return; + + if (minY < swClipRect.y) { + minY = swClipRect.y - minY; + L.x += dL.x * minY; + L.z += dL.z * minY; + R.x += dR.x * minY; + R.z += dR.z * minY; + step(L, dL, minY); + step(R, dR, minY); + minY = swClipRect.y; + } + + if (maxY > swClipRect.w) maxY = swClipRect.w; + + for (int y = minY; y < maxY; y++) { + drawLine(L, R, y); + L.x += dL.x; + L.z += dL.z; + R.x += dR.x; + R.z += dR.z; + step(L, dL); + step(R, dR); + } + } + + void drawTriangle(Index *indices) { + /* + t + /\ <----- top triangle + m /__\/ n + \ /\ + \ \ <-- bottom triangle + \ \ + \\ + \ + b + */ + VertexSW _n; + VertexSW *t = swVertices.items + indices[0]; + VertexSW *m = swVertices.items + indices[1]; + VertexSW *b = swVertices.items + indices[2]; + VertexSW *n = &_n; + + if (checkBackface(t, m, b)) + return; + + int32 cx1 = swClipRect.x << 16; + int32 cx2 = swClipRect.z << 16; + + if (t->x < cx1 && m->x < cx1 && b->x < cx1) + return; + + if (t->x > cx2 && m->x > cx2 && b->x > cx2) + return; + + sortVertices(t, m, b); + + if (b->y < swClipRect.y || t->y > swClipRect.w) + return; + + *n = ((*b - *t) / (b->y - t->y) * (m->y - t->y)) + *t; + n->y = m->y; + + if (m->x > n->x) { + swap(m, n); + } + + if (m->y != t->y) drawPart(*t, *t, *m, *n); + if (m->y != b->y) drawPart(*m, *n, *b, *b); + } + + void drawQuad(Index *indices) { + /* + t + /\ <----- top triangle + m /__\/ n + \ /\ + \ \ <-- quad + p \/__\ o + /\ / + \/ <-- bottom triangle + b + */ + VertexSW _n; + VertexSW _p; + VertexSW *t = swVertices.items + indices[0]; + VertexSW *m = swVertices.items + indices[1]; + VertexSW *b = swVertices.items + indices[2]; + VertexSW *o = swVertices.items + indices[3]; + VertexSW *n = &_n; + VertexSW *p = &_p; + + if (checkBackface(t, m, b)) + return; + + int32 cx1 = swClipRect.x << 16; + int32 cx2 = swClipRect.z << 16; + + if (t->x < cx1 && m->x < cx1 && o->x < cx1 && b->x < cx1) + return; + + if (t->x > cx2 && m->x > cx2 && o->x > cx2 && b->x > cx2) + return; + + sortVertices(t, m, b, o); + + if (b->y < swClipRect.y || t->y > swClipRect.w) + return; + + if (checkBackface(t, b, m) == checkBackface(t, b, o)) { + + VertexSW d = (*b - *t) / (b->y - t->y); + + *n = *t + d * (m->y - t->y); + *p = *t + d * (o->y - t->y); + + n->y = m->y; + p->y = o->y; + + } else { + + if (o->y != t->y) { + *n = *t + ((*o - *t) / (o->y - t->y) * (m->y - t->y)); + n->y = m->y; + } + + if (m->y != b->y) { + *p = *b + ((*m - *b) / (m->y - b->y) * (o->y - b->y)); + p->y = o->y; + } + + } + + if (o->y != t->y && m->x > n->x) swap(m, n); + if (m->y != b->y && p->x > o->x) swap(p, o); + + if (t->y != m->y) drawPart(*t, *t, *m, *n); + if (m->y != o->y) drawPart(*m, *n, *p, *o); + if (o->y != b->y) drawPart(*p, *o, *b, *b); + } + + void applyLighting(VertexSW &result, const Vertex &vertex, float depth) { + vec3 coord = vec3(float(vertex.coord.x), float(vertex.coord.y), float(vertex.coord.z)); + vec3 normal = vec3(float(vertex.normal.x), float(vertex.normal.y), float(vertex.normal.z)).normal(); + float lighting = 0.0f; + for (int i = 0; i < lightsCount; i++) { + LightSW &light = lightsRel[i]; + vec3 dir = (light.pos - coord) * light.radius; + float att = dir.length2(); + float lum = normal.dot(dir / sqrtf(att)); + lighting += (max(0.0f, lum) * max(0.0f, 1.0f - att)) * light.intensity; + } + + lighting += result.l; + + depth -= SW_FOG_START; + if (depth > 0.0f) { + lighting *= clamp(1.0f - depth / (SW_MAX_DIST - SW_FOG_START), 0.0f, 1.0f); + } + + result.l = (255 - min(255, int32(lighting))) << 16; + } + + bool transform(const Index *indices, const Vertex *vertices, int iStart, int iCount, int vStart) { + swVertices.reset(); + swIndices.reset(); + swTriangles.reset(); + swQuads.reset(); + + mat4 swMatrix; + swMatrix.viewport(0.0f, (float)Core::height, (float)Core::width, -(float)Core::height, 0.0f, 1.0f); + swMatrix = swMatrix * mViewProj * mModel; + + const bool colored = vertices[vStart + indices[iStart]].color.w == 142; + int vIndex = 0; + bool isTriangle = false; + + for (int i = 0; i < iCount; i++) { + const Index index = indices[iStart + i]; + const Vertex &vertex = vertices[vStart + index]; + + vIndex++; + + if (vIndex == 1) { + isTriangle = vertex.normal.w == 1; + } else { + if (vIndex == 4) { // loader splits quads to two triangles with indices 012[02]3, we ignore [02] to make it quad again! + vIndex++; + i++; + continue; + } + } + + vec4 c; + c = swMatrix * vec4(vertex.coord.x, vertex.coord.y, vertex.coord.z, 1.0f); + + if (c.w < 0.0f || c.w > SW_MAX_DIST) { // skip primitive + if (isTriangle) { + i += 3 - vIndex; + } else { + i += 6 - vIndex; + } + vIndex = 0; + continue; + } + + c.x /= c.w; + c.y /= c.w; + c.z /= c.w; + c.x = clamp(c.x, -16384.0f, 16384.0f); + c.y = clamp(c.y, -16384.0f, 16384.0f); + + VertexSW result; + result.x = int32(c.x) << 16; + result.y = int32(c.y); + result.z = uint32(clamp(c.z, 0.0f, 1.0f) * 65535.0f) << 16; + result.w = int32(c.w); + + if (colored) { + result.u = vertex.color.x << 16; + result.v = 0; + } else { + result.u = (vertex.texCoord.x << 16);// / result.w; + result.v = (vertex.texCoord.y << 16);// / result.w; + } + result.w = result.w << 16; + result.l = ((vertex.light.x * ambient) >> 8); + + applyLighting(result, vertex, c.w); + + swIndices.push(swVertices.push(result)); + + if (isTriangle && vIndex == 3) { + swTriangles.push(swIndices.length - 3); + vIndex = 0; + } else if (vIndex == 6) { + swQuads.push(swIndices.length - 4); + vIndex = 0; + } + } + + return colored; + } + + void transformLights() { + memcpy(lightsRel, lights, sizeof(LightSW) * lightsCount); + + mat4 mModelInv = mModel.inverseOrtho(); + for (int i = 0; i < lightsCount; i++) { + lightsRel[i].pos = mModelInv * lights[i].pos; + } + } + + void DIP(Mesh *mesh, const MeshRange &range) { + if (curTile == NULL) { + //uint32 *tex = (uint32*)Core::active.textures[0]->memory; // TODO + return; + } + + transformLights(); + + bool colored = transform(mesh->iBuffer, mesh->vBuffer, range.iStart, range.iCount, range.vStart); + + Tile8 *oldTile = curTile; + + if (colored) { + curTile = (Tile8*)swGradient; + } + + for (int i = 0; i < swQuads.length; i++) { + drawQuad(&swIndices[swQuads[i]]); + } + + for (int i = 0; i < swTriangles.length; i++) { + drawTriangle(&swIndices[swTriangles[i]]); + } + + curTile = oldTile; + } + + void initPalette(Color24 *palette, uint8 *lightmap) { + for (uint32 i = 0; i < 256; i++) { + const Color24 &p = palette[i]; + swPaletteColor[i] = CONV_COLOR(p.r, p.g, p.b); + swPaletteWater[i] = CONV_COLOR((uint32(p.r) * 150) >> 8, (uint32(p.g) * 230) >> 8, (uint32(p.b) * 230) >> 8); + swPaletteGray[i] = CONV_COLOR((i * 57) >> 8, (i * 29) >> 8, (i * 112) >> 8); + swGradient[i] = i; + } + + for (uint32 i = 0; i < 256 * 32; i++) { + swLightmapNone[i] = i % 256; + swLightmapShade[i] = lightmap[i]; + } + + swLightmap = swLightmapShade; + swPalette = swPaletteColor; + } + + void setPalette(ColorSW *palette) { + swPalette = palette; + } + + void setShading(bool enabled) { + swLightmap = enabled ? swLightmapShade : swLightmapNone; + } + + vec4 copyPixel(int x, int y) { + return vec4(0.0f); // TODO: read from framebuffer + } +} + +#endif diff --git a/src/gapi_vk.h b/src/gapi/vk.h similarity index 100% rename from src/gapi_vk.h rename to src/gapi/vk.h diff --git a/src/gapi_gx.h b/src/gapi_gx.h deleted file mode 100644 index efbc3e83..00000000 --- a/src/gapi_gx.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef H_GAPI_GX -#define H_GAPI_GX - -// TODO - -#endif \ No newline at end of file diff --git a/src/gltf.h b/src/gltf.h new file mode 100644 index 00000000..b5e7c8e4 --- /dev/null +++ b/src/gltf.h @@ -0,0 +1,339 @@ +#ifndef _H_GLTF +#define _H_GLTF + +#include "json.h" + +#define ACCESSOR_TYPES(E) \ + E( SCALAR ) \ + E( VEC2 ) \ + E( VEC3 ) \ + E( VEC4 ) \ + E( MAT2 ) \ + E( MAT3 ) \ + E( MAT4 ) + +struct GLTF { + enum AccessorType { ACCESSOR_TYPES(DECL_ENUM) ACCESSOR_TYPE_MAX }; + + JSON *root; + JSON *asset; + JSON *buffers; + JSON *bufferViews; + JSON *accessors; + JSON *meshes; + JSON *images; + JSON *samplers; + JSON *textures; + JSON *materials; + JSON *nodes; + JSON *scenes; + JSON *skins; + JSON *animations; + + char *binaryData; + int binarySize; + + GLTF() : binaryData(NULL), binarySize(0) { + root = new JSON(JSON::OBJECT); + + asset = root->add(JSON::OBJECT, "asset"); + images = root->add(JSON::ARRAY, "images"); + samplers = root->add(JSON::ARRAY, "samplers"); + textures = root->add(JSON::ARRAY, "textures"); + materials = root->add(JSON::ARRAY, "materials"); + buffers = root->add(JSON::ARRAY, "buffers"); + bufferViews = root->add(JSON::ARRAY, "bufferViews"); + accessors = root->add(JSON::ARRAY, "accessors"); + meshes = root->add(JSON::ARRAY, "meshes"); + nodes = root->add(JSON::ARRAY, "nodes"); + scenes = root->add(JSON::ARRAY, "scenes"); + skins = NULL;//root->add(JSON::ARRAY, "skins"); + animations = NULL;//root->add(JSON::ARRAY, "animations"); + + asset->add("generator", "OpenLara"); + asset->add("version", "2.0"); + + root->add("scene", 0); + } + + ~GLTF() { + delete[] binaryData; + delete root; + } + + int getBufferSize() { + return 8 * 1024 * 1024 + binarySize; + } + + int save(char *buffer) { + struct Header { + uint32 magic; + uint32 version; + uint32 length; + }; + + struct Chunk { + uint32 length; + uint32 type; + }; + + char *start = buffer; + + Header *header = (Header*)buffer; + buffer += sizeof(Header); + + Chunk *chunk = (Chunk*)buffer; + buffer += sizeof(Chunk); + + root->save(buffer); + + chunk->length = strlen(buffer); + chunk->type = FOURCC("JSON"); + + buffer += chunk->length; + + while (( int(buffer - start) % 4) != 0) { + *buffer++ = ' '; + chunk->length++; + } + + if (binaryData) { + Chunk *chunk = (Chunk*)buffer; + buffer += sizeof(Chunk); + chunk->length = binarySize; + chunk->type = FOURCC("BIN\0"); + + memcpy(buffer, binaryData, binarySize); + + buffer += binarySize; + + while (( (buffer - start) % 4) != 0) { + *buffer++ = 0; + chunk->length++; + } + } + + header->magic = FOURCC("glTF"); + header->version = 2; + header->length = buffer - start; + + return header->length; + } + + JSON* addAccessor(int bufferView, int byteStride, int byteOffset, int count, AccessorType type, int format, bool normalized = false, const vec4 &vMin = vec4(0.0f), const vec4 &vMax = vec4(0.0f)) { + static const char *AccessorTypeName[ACCESSOR_TYPE_MAX] = { ACCESSOR_TYPES(DECL_STR) }; + + JSON *item = accessors->add(JSON::OBJECT); + + item->add("bufferView", bufferView); + + if (byteStride) { + //item->add("byteStride", byteStride); + } + + if (byteOffset) { + item->add("byteOffset", byteOffset); + } + + item->add("count", count); + item->add("type", AccessorTypeName[type]); + item->add("componentType", format); + + if (normalized) { + item->add("normalized", true); + } + + if (vMin != vMax || vMin != vec4(0.0f)) { + JSON *itemMin = item->add(JSON::ARRAY, "min"); + JSON *itemMax = item->add(JSON::ARRAY, "max"); + + int k; + switch (type) { + case SCALAR : k = 1; break; + case VEC2 : k = 2; break; + case VEC3 : k = 3; break; + case VEC4 : k = 4; break; + default : k = 0; + } + + for (int i = 0; i < k; i++) { + itemMin->add(NULL, vMin[i]); + itemMax->add(NULL, vMax[i]); + } + } + + return item; + } + + JSON* addBuffer(void *data, int size) { + JSON *item = buffers->add(JSON::OBJECT); + + item->add("byteLength", size); + + binarySize = size; + binaryData = new char[size]; + memcpy(binaryData, data, size); + + return item; + } + + JSON* addBufferView(int buffer, int byteStride, int byteOffset, int byteLength) { + JSON *item = bufferViews->add(JSON::OBJECT); + + item->add("buffer", buffer); + if (byteStride) { + item->add("byteStride", byteStride); + } + if (byteOffset) { + item->add("byteOffset", byteOffset); + } + item->add("byteLength", byteLength); + + return item; + } + + JSON* addMesh(const char *name, int material, int INDICES, int POSITION = -1, int NORMAL = -1, int TEXCOORD = -1, int COLOR = -1, int JOINTS = -1, int WEIGHTS = -1) { + JSON *item = meshes->add(JSON::OBJECT); + + if (name) item->add("name", name); + JSON *primitives = item->add(JSON::ARRAY, "primitives"); + JSON *part = primitives->add(JSON::OBJECT); + JSON *attributes = part->add(JSON::OBJECT, "attributes"); + if (POSITION >= 0) attributes->add("POSITION", POSITION); + if (NORMAL >= 0) attributes->add("NORMAL", NORMAL); + if (TEXCOORD >= 0) attributes->add("TEXCOORD_0", TEXCOORD); + if (COLOR >= 0) attributes->add("COLOR_0", COLOR); + if (JOINTS >= 0) attributes->add("JOINTS_0", JOINTS); + if (WEIGHTS >= 0) attributes->add("WEIGHTS_0", WEIGHTS); + part->add("indices", INDICES); + part->add("material", material); + + return item; + } + + JSON* addImage(const char *uri) { + JSON *item = images->add(JSON::OBJECT); + + item->add("uri", uri); + + return item; + } + + JSON* addSampler(int magFilter, int minFilter, int wrapS, int wrapT) { + JSON *item = samplers->add(JSON::OBJECT); + + item->add("magFilter", magFilter); + item->add("minFilter", minFilter); + item->add("wrapS", wrapS); + item->add("wrapT", wrapT); + + return item; + } + + JSON* addTexture(const char *name, int sampler, int source) { + JSON *item = textures->add(JSON::OBJECT); + + if (name) item->add("name", name); + item->add("sampler", sampler); + item->add("source", source); + + return item; + } + + JSON* addMaterial(const char *name, int baseColorTextureIndex, int baseColorTextureTexCoord, float roughnessFactor, float metallicFactor) { + JSON *item = materials->add(JSON::OBJECT); + + if (name) item->add("name", name); + + item->add("alphaMode", "MASK"); + + JSON *pbr = item->add(JSON::OBJECT, "pbrMetallicRoughness"); + pbr->add("roughnessFactor", roughnessFactor); + pbr->add("metallicFactor", metallicFactor); + + JSON *baseTex = pbr->add(JSON::OBJECT, "baseColorTexture"); + baseTex->add("index", baseColorTextureIndex); + baseTex->add("texCoord", baseColorTextureTexCoord); + + return item; + } + + JSON* addNode(const char *name, int mesh, int skin, const vec3 &translation, const quat &rotation) { + JSON *item = nodes->add(JSON::OBJECT); + + if (name) item->add("name", name); + if (mesh >= 0) item->add("mesh", mesh); + if (skin >= 0) item->add("skin", skin); + + if (translation != vec3(0.0f)) { + JSON *v = item->add(JSON::ARRAY, "translation"); + v->add(NULL, translation.x); + v->add(NULL, translation.y); + v->add(NULL, translation.z); + } + + if (rotation != quat(0.0f, 0.0f, 0.0f, 1.0f)) { + JSON *v = item->add(JSON::ARRAY, "rotation"); + v->add(NULL, rotation.x); + v->add(NULL, rotation.y); + v->add(NULL, rotation.z); + v->add(NULL, rotation.w); + } + + return item; + } + + JSON *addSkin(const char *name, int inverseBindMatrices, int skeleton, int *joints, int jointsCount) { + if (!skins) { + skins = root->add(JSON::ARRAY, "skins"); + } + + JSON *item = skins->add(JSON::OBJECT); + + if (name) { + item->add("name", name); + } + + if (inverseBindMatrices >= 0) { + item->add("inverseBindMatrices", inverseBindMatrices); + } + + item->add("skeleton", skeleton); + + JSON *v = item->add(JSON::ARRAY, "joints"); + for (int i = 0; i < jointsCount; i++) { + v->add(NULL, joints[i]); + } + + return item; + } + + JSON* addAnimation(const char *name, JSON **samplers, JSON **channels) { + if (!animations) { + animations = root->add(JSON::ARRAY, "animations"); + } + JSON *item = animations->add(JSON::OBJECT); + + if (name) item->add("name", name); + if (samplers) *samplers = item->add(JSON::ARRAY, "samplers"); + if (channels) *channels = item->add(JSON::ARRAY, "channels"); + + return item; + } + + + JSON* addScene(const char *name, JSON **nodes) { + JSON *item = scenes->add(JSON::OBJECT); + + item->add("name", name); + if (nodes) { + *nodes = item->add(JSON::ARRAY, "nodes"); + } + + return item; + } +}; + +#undef ACCESSOR_TYPES + +#endif diff --git a/src/input.h b/src/input.h index ce2970a4..fb019ce4 100644 --- a/src/input.h +++ b/src/input.h @@ -4,8 +4,11 @@ #include "core.h" #include "utils.h" -#define INPUT_JOY_COUNT 4 -#define MAX_PLAYERS COUNT(Core::settings.controls) +#define MAX_PLAYERS COUNT(Core::settings.controls) + +#define INPUT_JOY_COUNT 4 +#define INPUT_JOY_DZ_STICK 0.3f +#define INPUT_JOY_DZ_TRIGGER 0.01f namespace Input { InputKey lastKey; @@ -40,6 +43,7 @@ namespace Input { mat4 controllers[2]; vec3 zero; bool ready; + bool state[cMAX]; void setView(const mat4 &pL, const mat4 &pR, const mat4 &vL, const mat4 &vR) { proj[0] = pL; @@ -87,7 +91,7 @@ namespace Input { } down[key] = value; - if (value && key <= ikZ) { + if (value && key <= ikBack) { lastKey = key; touchTimerVis = 0.0f; } @@ -128,7 +132,7 @@ namespace Input { case jkRT : joy[index].RT = pos.x; break; default : return; } - setJoyDown(index, key, pos.x > 0.0f); // gamepad LT, RT auto-down state + setJoyDown(index, key, pos.x > EPS); // gamepad LT, RT auto-down state } void setJoyVibration(int playerIndex, float L, float R) { @@ -204,6 +208,26 @@ namespace Input { state[playerIndex][key] = down; } + + int32 getTouchWidth() + { + #ifdef _OS_WP8 + return Core::height; + #else + return Core::width; + #endif + } + + int32 getTouchHeight() + { + #ifdef _OS_WP8 + return Core::width; + #else + return Core::height; + #endif + } + + void update() { bool newState[MAX_PLAYERS][cMAX]; @@ -212,7 +236,7 @@ namespace Input { Core::Settings::Controls &ctrl = Core::settings.controls[j]; for (int i = 0; i < cMAX; i++) { KeySet &c = ctrl.keys[i]; - newState[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]); + newState[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]) || hmd.state[i]; } } @@ -227,16 +251,16 @@ namespace Input { touchTimerVis = max(0.0f, touchTimerVis - Core::deltaTime); // update buttons - float offset = Core::height * 0.25f; + float offset = getTouchHeight() * 0.25f; float radius = offset; - vec2 center = vec2(Core::width - offset * 0.7f, Core::height - offset * 0.7f); + vec2 center = vec2(getTouchWidth() - offset * 0.7f, getTouchHeight() - offset * 0.7f); - btnRadius = Core::height * (25.0f / 1080.0f); + btnRadius = getTouchHeight() * (25.0f / 1080.0f); btnPos[bWeapon] = center; btnPos[bJump] = center + vec2(cosf(-PI * 0.5f), sinf(-PI * 0.5f)) * radius; btnPos[bAction] = center + vec2(cosf(-PI * 3.0f / 4.0f), sinf(-PI * 3.0f / 4.0f)) * radius; btnPos[bWalk] = center + vec2(cosf(-PI), sinf(-PI)) * radius; - btnPos[bInventory] = vec2(Core::width - btnRadius * 8.0f, btnRadius * 4.0f); + btnPos[bInventory] = vec2(getTouchWidth() - btnRadius * 8.0f, btnRadius * 4.0f); // touch update Joystick &joy = Input::joy[Core::settings.controls[0].joyIndex]; @@ -244,8 +268,10 @@ namespace Input { if (checkTouchZone(zMove)) joy.L = vec2(0.0f); - if (checkTouchZone(zLook)) + if (checkTouchZone(zLook)) { joy.L = vec2(0.0f); + joy.R = vec2(0.0f); + } if (checkTouchZone(zButton)) btn = bMove; // no active buttons == bNone @@ -253,7 +279,7 @@ namespace Input { if (doubleTap) doubleTap = false; - float zoneSize = Core::width / 3.0f; + float zoneSize = getTouchWidth() / 3.0f; for (int i = 0; i < COUNT(touch); i++) { InputKey key = InputKey(i + ikTouchA); diff --git a/src/inventory.h b/src/inventory.h index ab523567..534d558f 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -6,17 +6,23 @@ #include "ui.h" #include "savegame.h" -#define INVENTORY_MAX_ITEMS 32 -#define INVENTORY_MAX_RADIUS 688.0f -#ifdef _OS_PSP - #define INVENTORY_BG_SIZE 256 +#define INV_MAX_ITEMS 32 +#define INV_MAX_RADIUS 688.0f +#if defined(_OS_PSP) || defined(_OS_3DS) || defined(_OS_GCW0) + #define INV_BG_SIZE 256 #else - #define INVENTORY_BG_SIZE 512 + #define INV_BG_SIZE 512 #endif -#define INVENTORY_HEIGHT 2048.0f -#define TITLE_LOADING 64.0f -#define LINE_HEIGHT 20.0f +#define INV_HEIGHT 2048.0f +#define INV_EYE_SEPARATION 8.0f +#define INV_EYE_FOCAL_LENGTH 512.0f +#define INV_ZNEAR 32.0f +#define INV_ZFAR 2048.0f +#define INV_FOV 70.0f + +#define TITLE_LOADING 64.0f +#define LINE_HEIGHT 20.0f static const struct OptionItem *waitForKey = NULL; @@ -29,16 +35,16 @@ struct OptionItem { TYPE_KEY, } type; StringID title; - intptr_t offset; + int32 offset; uint32 color; uint32 icon; uint8 maxValue; bool bar; - OptionItem(Type type = TYPE_EMPTY, int title = STR_NOT_IMPLEMENTED, intptr_t offset = 0, uint32 color = 0xFFFFFFFF, int icon = 0, uint8 maxValue = 0, bool bar = false) : type(type), title(StringID(title)), offset(offset), color(color), icon(icon), maxValue(maxValue), bar(bar) {} + OptionItem(Type type = TYPE_EMPTY, int title = STR_EMPTY, int32 offset = 0, uint32 color = 0xFFFFFFFF, int icon = 0, uint8 maxValue = 0, bool bar = false) : type(type), title(StringID(title)), offset(offset), color(color), icon(icon), maxValue(maxValue), bar(bar) {} void setValue(uint8 value, Core::Settings *settings) const { - *(uint8*)(intptr_t(settings) + offset) = value; + *((uint8*)settings + offset) = value; } bool checkValue(uint8 value) const { @@ -54,7 +60,7 @@ struct OptionItem { } float drawParam(float x, float y, float w, StringID oStr, bool active, uint8 value) const { - if (oStr != STR_NOT_IMPLEMENTED) { + if (oStr != STR_EMPTY) { UI::textOut(vec2(x + 32.0f, y), oStr); x = x + w * 0.5f; w = w * 0.5f - 32.0f; @@ -76,14 +82,16 @@ struct OptionItem { int maxWidth = UI::getTextSize(STR[color + value]).x; maxWidth = maxWidth / 2 + 8; x += w * 0.5f; - if (checkValue(value - 1)) UI::specOut(vec2(x - maxWidth - 16.0f, y), 108); - if (checkValue(value + 1)) UI::specOut(vec2(x + maxWidth, y), 109); + if (maxValue != 0xFF) { + if (checkValue(value - 1)) UI::specOut(vec2(x - maxWidth - 16.0f, y), 108); + if (checkValue(value + 1)) UI::specOut(vec2(x + maxWidth, y), 109); + } } return y + LINE_HEIGHT; } float drawBar(float x, float y, float w, bool active, uint8 value) const { - UI::renderBar(UI::BAR_WHITE, vec2(x + (32.0f + 2.0f), y - LINE_HEIGHT + 6 + 2), vec2(w - (64.0f + 4.0f), LINE_HEIGHT - 6 - 4), value / float(maxValue), color, 0xFF000000, 0xFFA0A0A0, 0xFFA0A0A0, 0xFF000000); + UI::renderBar(CTEX_WHITE_SPRITE, vec2(x + (32.0f + 2.0f), y - LINE_HEIGHT + 6 + 2), vec2(w - (64.0f + 4.0f), LINE_HEIGHT - 6 - 4), value / float(maxValue), color, 0xFF000000, 0xFFA0A0A0, 0xFFA0A0A0, 0xFF000000); UI::specOut(vec2(x + 16.0f, y), icon); if (active) { if (value > 0) UI::specOut(vec2(x, y), 108); @@ -94,17 +102,17 @@ struct OptionItem { float render(float x, float y, float w, bool active, Core::Settings *settings) const { if (active) - UI::renderBar(UI::BAR_OPTION, vec2(x, y - LINE_HEIGHT + 6), vec2(w, LINE_HEIGHT - 6), 1.0f, 0xFFD8377C, 0); + UI::renderBar(CTEX_OPTION, vec2(x, y - LINE_HEIGHT + 6), vec2(w, LINE_HEIGHT - 6), 1.0f, 0xFFD8377C, 0); - const uint8 &value = *(uint8*)(intptr_t(settings) + offset); + const uint8 &value = *((uint8*)settings + offset); switch (type) { case TYPE_TITLE : - UI::renderBar(UI::BAR_OPTION, vec2(x, y - LINE_HEIGHT + 6), vec2(w, LINE_HEIGHT - 6), 1.0f, 0x802288FF, 0, 0, 0); + UI::renderBar(CTEX_OPTION, vec2(x, y - LINE_HEIGHT + 6), vec2(w, LINE_HEIGHT - 6), 1.0f, 0x802288FF, 0, 0, 0); UI::textOut(vec2(x, y), title, UI::aCenter, w, 255, UI::SHADE_GRAY); case TYPE_EMPTY : break; case TYPE_BUTTON : { - const char *caption = offset ? (char*)offset : STR[title]; + const char *caption = STR[offset ? StringID(offset) : title]; UI::textOut(vec2(x, y), caption, UI::aCenter, w); break; } @@ -117,26 +125,35 @@ struct OptionItem { } }; -#define SETTINGS(x) OFFSETOF(Core::Settings, x) +#define SETTINGS(x) int32(OFFSETOF(Core::Settings, x)) + +#ifdef INV_SINGLE_PLAYER + #define INV_CTRL_START_OPTION 1 +#else + #define INV_CTRL_START_OPTION 2 +#endif static const OptionItem optDetail[] = { OptionItem( OptionItem::TYPE_TITLE, STR_SELECT_DETAIL ), OptionItem( ), - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_FILTER, SETTINGS( detail.filter ), STR_QUALITY_LOW, 0, 2 ), - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ), - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ), - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ), - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_SIMPLE_ITEMS, SETTINGS( detail.simple ), STR_OFF, 0, 1 ), -#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_PSP) || defined(_OS_RPI) || defined(_OS_PSV) - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ), +#ifdef INV_QUALITY + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_FILTER, SETTINGS( detail.filter ), STR_QUALITY_LOW, 0, 2 ), + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ), + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ), + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ), #endif -#ifndef _OS_PSP - OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_STEREO, SETTINGS( detail.stereo ), STR_OFF, 0, -#if /*defined(_OS_WIN) ||*/ defined(_OS_ANDROID) - 3 /* with VR option */ -#else - 2 /* without VR support */ + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_SIMPLE_ITEMS, SETTINGS( detail.simple ), STR_OFF, 0, 1 ), +#ifdef INV_QUALITY + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_RESOLUTION, SETTINGS( detail.scale ), STR_SCALE_100, 0, 3 ), + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ), #endif +#ifdef INV_STEREO + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_STEREO, SETTINGS( detail.stereo ), STR_NO_STEREO, 0, + #if defined(_OS_WIN) || defined(_OS_ANDROID) + 4 /* with VR option */ + #else + 3 /* without VR support */ + #endif ), #endif OptionItem( ), @@ -146,24 +163,32 @@ static const OptionItem optDetail[] = { static const OptionItem optSound[] = { OptionItem( OptionItem::TYPE_TITLE, STR_SET_VOLUMES ), OptionItem( ), - OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED, SETTINGS( audio.music ), 0xFF0080FF, 101, SND_MAX_VOLUME, true ), - OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED, SETTINGS( audio.sound ), 0xFFFF8000, 102, SND_MAX_VOLUME, true ), - OptionItem( OptionItem::TYPE_PARAM, STR_REVERBERATION, SETTINGS( audio.reverb ), STR_OFF, 0, 1 ), + OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY, SETTINGS( audio.music ), 0xFF0080FF, 101, SND_MAX_VOLUME, true ), + OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY, SETTINGS( audio.sound ), 0xFFFF8000, 102, SND_MAX_VOLUME, true ), + OptionItem( OptionItem::TYPE_PARAM, STR_REVERBERATION, SETTINGS( audio.reverb ), STR_OFF, 0, 1 ), + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_SUBTITLES, SETTINGS( audio.subtitles ), STR_OFF, 0, 1 ), +#ifndef FFP + OptionItem( OptionItem::TYPE_PARAM, STR_OPT_LANGUAGE, SETTINGS( audio.language ), STR_LANG_EN, 0, STR_LANG_SV - STR_LANG_EN ), +#endif }; static const OptionItem optControls[] = { OptionItem( OptionItem::TYPE_TITLE, STR_SET_CONTROLS ), OptionItem( ), - OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED , SETTINGS( playerIndex ), STR_PLAYER_1, 0, 1 ), -#ifndef _OS_CLOVER +#ifndef INV_SINGLE_PLAYER + OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( playerIndex ), STR_PLAYER_1, 0, 1 ), OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_GAMEPAD , SETTINGS( controls[0].joyIndex ), STR_GAMEPAD_1, 0, 3 ), #endif -#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_RPI) +#ifdef INV_VIBRATION OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_VIBRATION , SETTINGS( controls[0].vibration ), STR_OFF, 0, 1 ), #endif OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_RETARGET , SETTINGS( controls[0].retarget ), STR_OFF, 0, 1 ), OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_MULTIAIM , SETTINGS( controls[0].multiaim ), STR_OFF, 0, 1 ), - OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED , SETTINGS( ctrlIndex ), STR_OPT_CONTROLS_KEYBOARD, 0, 1 ), +#ifdef INV_GAMEPAD_ONLY + OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( ctrlIndex ), STR_OPT_CONTROLS_KEYBOARD, 0, 0xFF ), +#else + OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( ctrlIndex ), STR_OPT_CONTROLS_KEYBOARD, 0, 1 ), +#endif OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cUp , SETTINGS( controls[0].keys[ cUp ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cDown , SETTINGS( controls[0].keys[ cDown ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cRight , SETTINGS( controls[0].keys[ cRight ] ), STR_KEY_FIRST ), @@ -173,8 +198,10 @@ static const OptionItem optControls[] = { OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cAction , SETTINGS( controls[0].keys[ cAction ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cWeapon , SETTINGS( controls[0].keys[ cWeapon ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cLook , SETTINGS( controls[0].keys[ cLook ] ), STR_KEY_FIRST ), +#if !(defined(INV_GAMEPAD_ONLY) && defined(INV_GAMEPAD_NO_TRIGGER)) OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cDuck , SETTINGS( controls[0].keys[ cDuck ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cDash , SETTINGS( controls[0].keys[ cDash ] ), STR_KEY_FIRST ), +#endif OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cRoll , SETTINGS( controls[0].keys[ cRoll ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cInventory , SETTINGS( controls[0].keys[ cInventory ] ), STR_KEY_FIRST ), OptionItem( OptionItem::TYPE_KEY, STR_CTRL_FIRST + cStart , SETTINGS( controls[0].keys[ cStart ] ), STR_KEY_FIRST ), @@ -194,7 +221,8 @@ struct Inventory { }; IGame *game; - Texture *background[2]; + Texture *title; + Texture *background[3]; // [LEFT EYE or SINGLE, RIGHT EYE, TEMP] Video *video; bool playLogo; @@ -321,7 +349,7 @@ struct Inventory { OptionItem item; item.type = OptionItem::TYPE_BUTTON; - item.offset = slot.isCheckpoint() ? intptr_t(STR[STR_CURRENT_POSITION]) : intptr_t(TR::LEVEL_INFO[id].title); // offset as int pointer to level title string + item.offset = slot.isCheckpoint() ? STR_CURRENT_POSITION : TR::LEVEL_INFO[id].title; item.color = i; // color as slot index optLoadSlots.push(item); } @@ -388,20 +416,19 @@ struct Inventory { case TR::Entity::INV_PASSPORT : if (value != 0) return NULL; optCount = optLoadSlots.length; - return optLoadSlots; + return optLoadSlots.items; case TR::Entity::INV_DETAIL : optCount = COUNT(optDetail); return optDetail; case TR::Entity::INV_SOUND : optCount = COUNT(optSound); return optSound; - case TR::Entity::INV_CONTROLS : - ASSERT(optControls[2].offset == SETTINGS( playerIndex) ); + case TR::Entity::INV_CONTROLS : { for (int i = 0; i < COUNT(optControls); i++) { OptionItem &opt = optControlsPlayer[i]; opt = optControls[i]; - if (i > 2 && opt.offset != SETTINGS( playerIndex ) && opt.offset != SETTINGS( ctrlIndex ) ) + if (i > INV_CTRL_START_OPTION && opt.offset != SETTINGS( playerIndex ) && opt.offset != SETTINGS( ctrlIndex ) ) opt.offset += sizeof(Core::Settings::Controls) * Core::settings.playerIndex; if (opt.type == OptionItem::TYPE_KEY) { @@ -414,6 +441,7 @@ struct Inventory { } optCount = COUNT(optControlsPlayer); return optControlsPlayer; + } default : optCount = 0; return NULL; @@ -450,21 +478,21 @@ struct Inventory { opt = opt + slot; - uint8 &value = *(uint8*)(intptr_t(settings) + opt->offset); + uint8 &value = *((uint8*)settings + opt->offset); switch (key) { case cAction : return (opt->type == OptionItem::TYPE_BUTTON || opt->type == OptionItem::TYPE_KEY) ? opt : NULL; case cUp : nextSlot(slot, -1); break; case cDown : nextSlot(slot, +1); break; case cLeft : - if (opt->type == OptionItem::TYPE_PARAM && opt->checkValue(value - 1)) { + if (opt->type == OptionItem::TYPE_PARAM && (opt->maxValue != 0xFF) && opt->checkValue(value - 1)) { value--; timer = 0.2f; return opt; } break; case cRight : - if (opt->type == OptionItem::TYPE_PARAM && opt->checkValue(value + 1)) { + if (opt->type == OptionItem::TYPE_PARAM && (opt->maxValue != 0xFF) && opt->checkValue(value + 1)) { value++; timer = 0.2f; return opt; @@ -514,11 +542,9 @@ struct Inventory { void render(IGame *game, const Basis &basis) { if (!anim) return; - MeshBuilder *mesh = game->getMesh(); - TR::Level *level = game->getLevel(); TR::Model &m = level->models[desc.model]; - Basis joints[MAX_SPHERES]; + Basis joints[MAX_JOINTS]; mat4 matrix; matrix.identity(); @@ -531,9 +557,7 @@ struct Inventory { joints[1].rotate(quat(vec3(0.0f, 1.0f, 0.0f), -params.x)); } - Core::setBasis(joints, m.mCount); - - mesh->renderModelFull(desc.model); + game->renderModelFull(desc.model, false, joints); } void choose() { @@ -541,7 +565,7 @@ struct Inventory { anim->setAnim(0, 0, false); } - } *items[INVENTORY_MAX_ITEMS]; + } *items[INV_MAX_ITEMS]; static void loadTitleBG(Stream *stream, void *userData) { Inventory *inv = (Inventory*)userData; @@ -555,26 +579,31 @@ struct Inventory { } inv->titleTimer = inv->game->getLevel()->isTitle() ? 0.0f : 3.0f; - inv->background[0] = Texture::Load(*stream); + inv->title = Texture::Load(*stream); + inv->background[0] = inv->title; delete stream; } static void loadVideo(Stream *stream, void *userData) { Inventory *inv = (Inventory*)userData; - if (stream) - inv->video = new Video(stream); - new Stream(TR::getGameScreen(inv->game->getLevel()->id), loadTitleBG, inv); + TR::LevelID id = inv->game->getLevel()->id; + if (stream) { + inv->video = new Video(stream, id); + UI::showSubs(getVideoSubs(id)); + } + new Stream(TR::getGameScreen(id), loadTitleBG, inv); } static void loadLogo(Stream *stream, void *userData) { Inventory *inv = (Inventory*)userData; - if (stream) - inv->video = new Video(stream); - else + if (stream) { + inv->video = new Video(stream, TR::LVL_CUSTOM); + } else { inv->skipVideo(); + } } - Inventory() : game(NULL), itemsCount(0) { + Inventory() : game(NULL), title(NULL), itemsCount(0) { memset(background, 0, sizeof(background)); reset(); } @@ -589,10 +618,17 @@ struct Inventory { delete items[i]; itemsCount = 0; + if (background[0] == title) { + background[0] = NULL; + } + for (int i = 0; i < COUNT(background); i++) { delete background[i]; background[i] = NULL; } + + delete title; + title = NULL; } void reset() { @@ -679,6 +715,9 @@ struct Inventory { } void init(bool playLogo, bool playVideo) { + active = false; + phaseRing = 0.0f; + this->playLogo = playLogo; this->playVideo = playVideo; @@ -754,7 +793,7 @@ struct Inventory { return; } - ASSERT(itemsCount < INVENTORY_MAX_ITEMS); + ASSERT(itemsCount < INV_MAX_ITEMS); count = min(UNLIMITED_AMMO, count); @@ -765,7 +804,7 @@ struct Inventory { } int pos = 0; - for (int pos = 0; pos < itemsCount; pos++) + for (; pos < itemsCount; pos++) if (items[pos]->type > type) break; @@ -956,7 +995,11 @@ struct Inventory { } case TR::Entity::INV_CONTROLS : Core::settings.playerIndex = 0; - Core::settings.ctrlIndex = 0; + #ifdef INV_GAMEPAD_ONLY + Core::settings.ctrlIndex = 1; + #else + Core::settings.ctrlIndex = 0; + #endif break; case TR::Entity::INV_DETAIL : settings = Core::settings; @@ -1073,7 +1116,7 @@ struct Inventory { } } playVideo = false; - + UI::showSubs(STR_EMPTY); game->playTrack(0); if (game->getLevel()->isTitle()) { titleTimer = 0.0f; @@ -1154,7 +1197,7 @@ struct Inventory { else if (Input::down[ikDown] || joy.down[jkDown] || joy.L.y > 0.5f) key = cDown; - #ifdef _OS_NX + #if defined(_OS_SWITCH) || defined(_OS_3DS) || defined(_OS_GCW0) // swap A/B keys for Nintendo (Japanese) UX style if (Input::touchTimerVis == 0.0f) { if (key == cAction) { @@ -1178,7 +1221,7 @@ struct Inventory { if (Input::lastState[playerIndex] == cLeft || Input::lastState[playerIndex] == cRight) slot ^= 1; - if (Input::lastState[playerIndex] == cAction) { + if (key == cAction) { if (slot == 1) { if (index > -1) { TR::Entity &e = game->getLevel()->entities[index]; @@ -1223,8 +1266,11 @@ struct Inventory { newKey = Input::lastKey; } else { JoyKey jk = Input::joy[Core::settings.controls[Core::settings.playerIndex].joyIndex].lastKey; - if (Core::settings.ctrlIndex == 1 && jk != jkNone) + if (Core::settings.ctrlIndex == 1 && jk != jkNone) { newKey = jk; + } else if (Input::lastKey != ikNone) { + waitForKey = NULL; + } } if (newKey != -1) { @@ -1340,70 +1386,103 @@ struct Inventory { return false; } - Texture* getBackgroundTarget() { - if (background[0] && (background[0]->origWidth != INVENTORY_BG_SIZE || background[0]->origHeight != INVENTORY_BG_SIZE)) { - delete background[0]; + Texture* getBackgroundTarget(int view) { + if (background[0] == title) { background[0] = NULL; } - for (int i = 0; i < COUNT(background); i++) - if (!background[i]) - background[i] = new Texture(INVENTORY_BG_SIZE, INVENTORY_BG_SIZE, FMT_RGBA, OPT_TARGET); + for (int i = 0; i < COUNT(background); i++) { + if (!background[i]) { + background[i] = new Texture(INV_BG_SIZE, INV_BG_SIZE, 1, FMT_RGB16, OPT_TARGET); + } + } + + return background[view]; + } - return background[0]; + void blur(Texture *texInOut, Texture *tmp) { + #ifdef _GAPI_C3D + return; // TODO + #endif + #ifdef FFP + return; // TODO + #endif + game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); + float s = 1.0f / INV_BG_SIZE; + // vertical + Core::setTarget(tmp, NULL, RT_STORE_COLOR); + Core::validateRenderState(); + Core::active.shader->setParam(uParam, vec4(0, s, 0, s)); + texInOut->bind(sDiffuse); + game->getMesh()->renderQuad(); + // horizontal + Core::setTarget(texInOut, NULL, RT_STORE_COLOR); + Core::validateRenderState(); + game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); + Core::active.shader->setParam(uParam, vec4(s, 0, 0, s)); + tmp->bind(sDiffuse); + game->getMesh()->renderQuad(); + } + + void grayscale(Texture *texIn, Texture *texOut) { + #ifdef FFP + return; // TODO + #endif + float s = 1.0f / INV_BG_SIZE; + game->setShader(Core::passFilter, Shader::FILTER_GRAYSCALE, false, false); + Core::setTarget(texOut, NULL, RT_STORE_COLOR); + Core::validateRenderState(); + Core::active.shader->setParam(uParam, vec4(0.75f, 0.75f, 1.0f, s)); + texIn->bind(sDiffuse); + game->getMesh()->renderQuad(); } void prepareBackground() { + #ifdef FFP + return; + #endif + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) return; - #ifdef _OS_PSP + #ifdef _GAPI_GU return; #endif - Core::defaultTarget = getBackgroundTarget(); - game->renderGame(false); - Core::defaultTarget = NULL; + + #ifdef _OS_3DS + GAPI::rotate90 = false; + #endif + + game->renderGame(false, true); Core::setDepthTest(false); Core::setBlendMode(bmNone); - #ifdef FFP - mat4 m; - m.identity(); - Core::setViewProj(m, m); - Core::mModel.identity(); - #endif - - #ifdef _OS_PSP - // - #else - // vertical blur - Core::setTarget(background[1], RT_STORE_COLOR); - game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); - Core::active.shader->setParam(uParam, vec4(0, 1.0f / INVENTORY_BG_SIZE, 0, 0)); - background[0]->bind(sDiffuse); - game->getMesh()->renderQuad(); + int viewsCount = (Core::settings.detail.stereo == Core::Settings::STEREO_OFF) ? 1 : 2; - // horizontal blur - Core::setTarget(background[0], RT_STORE_COLOR); - game->setShader(Core::passFilter, Shader::FILTER_BLUR, false, false); - Core::active.shader->setParam(uParam, vec4(1.0f / INVENTORY_BG_SIZE, 0, 0, 0)); - background[1]->bind(sDiffuse); - game->getMesh()->renderQuad(); + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / 32767.0f)); + Core::setViewProj(mView, mProj); - // grayscale - Core::setTarget(background[1], RT_STORE_COLOR); - game->setShader(Core::passFilter, Shader::FILTER_GRAYSCALE, false, false); - Core::active.shader->setParam(uParam, vec4(0.75f, 0.75f, 1.0f, 1.0f)); - background[0]->bind(sDiffuse); - game->getMesh()->renderQuad(); + for (int view = 0; view < viewsCount; view++) { + blur(background[view], background[2]); + grayscale(background[view], background[2]); + swap(background[view], background[2]); + } - swap(background[0], background[1]); - #endif + #ifdef _OS_3DS + GAPI::rotate90 = true; + #endif Core::setDepthTest(true); } + float getEyeOffset() { + return -Core::eye * INV_EYE_SEPARATION * 0.75f; + } + void renderItemCount(const Item *item, const vec2 &pos, float width) { char spec; switch (item->type) { @@ -1435,11 +1514,13 @@ struct Inventory { if (item->value == 2) str = STR_EXIT_TO_TITLE; } - UI::textOut(vec2(0, 480 - 32), str, UI::aCenter, UI::width); + float eye = getEyeOffset(); + + UI::textOut(vec2(eye, 480 - 32), str, UI::aCenter, UI::width); int tw = UI::getTextSize(STR[str]).x; - if (item->value > 0) UI::specOut(vec2((UI::width - tw) * 0.5f - 32.0f, 480 - 32), 108); - if (item->value < 2) UI::specOut(vec2((UI::width + tw) * 0.5f + 16.0f, 480 - 32), 109); + if (item->value > 0) UI::specOut(vec2((UI::width - tw) * 0.5f - 32.0f + eye, 480 - 32), 108); + if (item->value < 2) UI::specOut(vec2((UI::width + tw) * 0.5f + 16.0f + eye, 480 - 32), 109); if (item->value != 0) return; @@ -1459,12 +1540,14 @@ struct Inventory { float width = 320.0f; float height = optionsCount * LINE_HEIGHT + 8; - float eye = UI::width * Core::eye * 0.02f; - float x = ( UI::width - width ) * 0.5f - eye; + if (item->type == TR::Entity::INV_CONTROLS || item->type == TR::Entity::INV_DETAIL) + width += 80; + + float x = ( UI::width - width ) * 0.5f + getEyeOffset(); float y = ( UI::height - height ) * 0.5f + LINE_HEIGHT; // background - UI::renderBar(UI::BAR_OPTION, vec2(x, y - 16.0f), vec2(width, height), 0.0f, 0, 0xC0000000); + UI::renderBar(CTEX_OPTION, vec2(x, y - 16.0f), vec2(width, height), 0.0f, 0, 0xC0000000); x += 8.0f; width -= 16.0f; @@ -1526,15 +1609,17 @@ struct Inventory { return def; } - void renderItemText(float eye, Item *item) { + void renderItemText(Item *item) { + float eye = getEyeOffset() * 0.5f; + if (item->type == TR::Entity::INV_PASSPORT && phaseChoose == 1.0f) { // } else { StringID str = getItemName(item->desc.str, game->getLevel()->id, item->type); - UI::textOut(vec2(-eye, 480 - 32), str, UI::aCenter, UI::width); + UI::textOut(vec2(eye, 480 - 32), str, UI::aCenter, UI::width); } - renderItemCount(item, vec2(UI::width / 2 - 160 - eye, 480 - 96), 320); + renderItemCount(item, vec2(UI::width / 2 - 160, 480 - 96), 320); // show health bar in inventory when selector is over medikit if (item->type == TR::Entity::INV_MEDIKIT_BIG || item->type == TR::Entity::INV_MEDIKIT_SMALL) { @@ -1544,12 +1629,17 @@ struct Inventory { vec2 size = vec2(180, 10); vec2 pos; - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) - pos = vec2((UI::width - size.x) * 0.5f - eye * 4.0f, 96); - else - pos = vec2(UI::width - 32 - size.x - eye, 32); + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { + pos = vec2((UI::width - size.x) * 0.5f, 96); + } else { + if (game->getLara(1) && playerIndex == 0) { + pos = vec2(32, 32); + } else { + pos = vec2(UI::width - 32 - size.x, 32); + } + } - UI::renderBar(UI::BAR_HEALTH, pos, size, health); + UI::renderBar(CTEX_HEALTH, pos, size, health); } } @@ -1566,7 +1656,7 @@ struct Inventory { case TR::Entity::INV_GAMMA : case TR::Entity::INV_STOPWATCH : case TR::Entity::INV_MAP : - UI::textOut(vec2(-eye, 240), STR_NOT_IMPLEMENTED, UI::aCenter, UI::width); + UI::textOut(vec2(0, 240), STR_EMPTY, UI::aCenter, UI::width); break; default : ; } @@ -1585,13 +1675,13 @@ struct Inventory { vec2 cpos(1286, 256 + 1280 * (1.0f - phaseRing)); float ringTilt = cpos.angle(); - float radius = phaseRing * INVENTORY_MAX_RADIUS * phase; + float radius = phaseRing * INV_MAX_RADIUS * phase; float collapseAngle = phaseRing * phase * PI - PI; - float ringHeight = lerp(float(this->page), float(targetPage), hermite(phasePage)) * INVENTORY_HEIGHT; + float ringHeight = lerp(float(this->page), float(targetPage), quintic(phasePage)) * INV_HEIGHT; float angle = getAngle(pageItemIndex[page], count); if (phaseSelect < 1.0f) - angle = lerpAngle(angle, getAngle(targetIndex, count), hermite(phaseSelect)); + angle = lerpAngle(angle, getAngle(targetIndex, count), quintic(phaseSelect)); Basis basis = Basis(quat(vec3(1, 0, 0), ringTilt), vec3(0)); @@ -1613,7 +1703,7 @@ struct Inventory { rd += 296 * phaseChoose; } - Basis b = basis * Basis(quat(vec3(0, 1, 0), PI + ia - a), vec3(sinf(a), 0, -cosf(a)) * rd - vec3(0, item->desc.page * INVENTORY_HEIGHT - rh, 0)); + Basis b = basis * Basis(quat(vec3(0, 1, 0), PI + ia - a), vec3(sinf(a), 0, -cosf(a)) * rd - vec3(0, item->desc.page * INV_HEIGHT - rh, 0)); if (item->type == TR::Entity::INV_COMPASS) { b.rotate(quat(vec3(1.0f, 0.0f, 0.0f), -phaseChoose * PI * 0.1f)); @@ -1625,21 +1715,32 @@ struct Inventory { } } - void renderTitleBG(float sx = 1.0f, float sy = 1.0f, uint8 alpha = 255) { - float aspectSrc, aspectDst, aspectImg, ax, ay; + void renderTitleBG(float sx = 1.0f, float sy = 1.0f, uint8 alpha = 255, float cropW = 1.0f, float cropH = 1.0f) { + float aspectSrc, ax, ay, tx, ty; if (background[0]) { - float ox = sx * background[0]->origWidth; - float oy = sy * background[0]->origHeight; + Texture *tex = background[0]; + float origW = float(tex->origWidth) * cropW; + float origH = float(tex->origHeight) * cropH; + tx = 0.5f * (tex->origWidth - origW) / tex->width; + ty = 0.5f * (tex->origHeight - origH) / tex->height; + float ox = sx * origW; + float oy = sy * origH; aspectSrc = ox / oy; - aspectDst = float(Core::width) / float(Core::height); - ax = background[0]->origWidth / float(background[0]->width); - ay = background[0]->origHeight / float(background[0]->height); + ax = origW / tex->width; + ay = origH / tex->height; } else { + tx = ty = 0.0f; aspectSrc = ax = ay = 1.0f; - aspectDst = float(Core::width) / float(Core::height); } - aspectImg = aspectSrc / aspectDst; + + float aspectDst = float(Core::width) / float(Core::height) * Core::aspectFix; + + #ifdef _OS_WP8 + aspectDst = 1.0f / aspectDst; + #endif + + float aspectImg = aspectSrc / aspectDst; #ifdef FFP mat4 m; @@ -1649,47 +1750,40 @@ struct Inventory { Core::mModel.scale(vec3(1.0f / 32767.0f)); #endif - Core::setBlendMode(alpha < 255 ? bmAlpha : bmNone); + short o_frame = 32767; + short i_frame = 16384; - Index indices[6 * 3] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11 }; - Vertex vertices[4 * 3]; - - short2 size; + short2 size = short2(short(i_frame * aspectImg), i_frame); if (aspectImg < 1.0f) { - size.x = short(32767 * aspectImg); - size.y = 32767; - - vertices[ 4].coord = short4( -32767, size.y, 0, 0); - vertices[ 5].coord = short4(-size.x, size.y, 0, 0); - vertices[ 6].coord = short4(-size.x, -size.y, 0, 0); - vertices[ 7].coord = short4( -32767, -size.y, 0, 0); - - vertices[ 8].coord = short4( size.x, size.y, 0, 0); - vertices[ 9].coord = short4( 32767, size.y, 0, 0); - vertices[10].coord = short4( 32767, -size.y, 0, 0); - vertices[11].coord = short4( size.x, -size.y, 0, 0); + size.x = short(i_frame * aspectImg); + size.y = i_frame; } else { - size.x = 32767; - size.y = short(32767 / aspectImg); - - vertices[ 4].coord = short4(-size.x, 32767, 0, 0); - vertices[ 5].coord = short4( size.x, 32767, 0, 0); - vertices[ 6].coord = short4( size.x, size.y, 0, 0); - vertices[ 7].coord = short4(-size.x, size.y, 0, 0); + size.x = i_frame; + size.y = short(i_frame / aspectImg); + } - vertices[ 8].coord = short4(-size.x, -size.y, 0, 0); - vertices[ 9].coord = short4( size.x, -size.y, 0, 0); - vertices[10].coord = short4( size.x, -32767, 0, 0); - vertices[11].coord = short4(-size.x, -32767, 0, 0); + float eye = -getEyeOffset() * size.x / 320.0f; + if (titleTimer > 0.0f || video) { + eye = 0.0f; } - short tw = short(ax * 32767); - short th = short(ay * 32767); + Index indices[10 * 3] = { 0,1,2, 0,2,3, 8,9,5, 8,5,4, 9,10,6, 9,6,5, 10,11,7, 10,7,6, 11,8,4, 11,4,7 }; + Vertex vertices[4 * 3]; + + vertices[ 0].coord = short4(-size.x, size.y, 0, 1); + vertices[ 1].coord = short4( size.x, size.y, 0, 1); + vertices[ 2].coord = short4( size.x, -size.y, 0, 1); + vertices[ 3].coord = short4(-size.x, -size.y, 0, 1); - vertices[ 0].coord = short4(-size.x, size.y, 0, 0); - vertices[ 1].coord = short4( size.x, size.y, 0, 0); - vertices[ 2].coord = short4( size.x, -size.y, 0, 0); - vertices[ 3].coord = short4(-size.x, -size.y, 0, 0); + vertices[ 4].coord = vertices[0].coord; + vertices[ 5].coord = vertices[1].coord; + vertices[ 6].coord = vertices[2].coord; + vertices[ 7].coord = vertices[3].coord; + + vertices[ 8].coord = short4(-o_frame, o_frame, 0, 1); + vertices[ 9].coord = short4( o_frame, o_frame, 0, 1); + vertices[10].coord = short4( o_frame, -o_frame, 0, 1); + vertices[11].coord = short4(-o_frame, -o_frame, 0, 1); vertices[ 0].light = vertices[ 1].light = @@ -1704,10 +1798,13 @@ struct Inventory { vertices[10].light = vertices[11].light = ubyte4(0, 0, 0, alpha); - vertices[ 0].texCoord = short4( 0, 0, 0, 0); - vertices[ 1].texCoord = short4(tw, 0, 0, 0); - vertices[ 2].texCoord = short4(tw, th, 0, 0); - vertices[ 3].texCoord = short4( 0, th, 0, 0); + short2 t0(short(tx * 32767), short(ty * 32767)); + short2 t1(t0.x + short(ax * 32767), t0.y + short(ay * 32767)); + + vertices[ 0].texCoord = short4(t0.x, t0.y, 0, 0); + vertices[ 1].texCoord = short4(t1.x, t0.y, 0, 0); + vertices[ 2].texCoord = short4(t1.x, t1.y, 0, 0); + vertices[ 3].texCoord = short4(t0.x, t1.y, 0, 0); vertices[ 4].texCoord = vertices[ 5].texCoord = vertices[ 6].texCoord = @@ -1717,23 +1814,33 @@ struct Inventory { vertices[10].texCoord = vertices[11].texCoord = short4(0, 0, 0, 0); - if ((Core::settings.detail.stereo == Core::Settings::STEREO_VR && !video) || !background[0]) + if ((Core::settings.detail.stereo == Core::Settings::STEREO_VR && !video) || !background[0]) { Core::blackTex->bind(sDiffuse); // black background - else + } else { background[0]->bind(sDiffuse); + } + + Core::setBlendMode(alpha < 255 ? bmAlpha : bmNone); + + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / max(size.x, size.y))); + mProj.translate(vec3(eye, 0.0f, 0.0f)); + Core::setViewProj(mView, mProj); game->setShader(Core::passFilter, Shader::FILTER_UPSCALE, false, false); - Core::active.shader->setParam(uParam, vec4(float(Core::active.textures[sDiffuse]->width), float(Core::active.textures[sDiffuse]->height), Core::getTime() * 0.001f, 0.0f)); + Core::active.shader->setParam(uParam, vec4(float(Core::active.textures[sDiffuse]->width), float(Core::active.textures[sDiffuse]->height), 0.0f, 0.0f)); game->getMesh()->renderBuffer(indices, COUNT(indices), vertices, COUNT(vertices)); } - void renderGameBG() { + void renderGameBG(int view) { Index indices[6] = { 0, 1, 2, 0, 2, 3 }; Vertex vertices[4]; - vertices[0].coord = short4(-32767, 32767, 0, 0); - vertices[1].coord = short4( 32767, 32767, 0, 0); - vertices[2].coord = short4( 32767, -32767, 0, 0); - vertices[3].coord = short4(-32767, -32767, 0, 0); + vertices[0].coord = short4(-32767, 32767, 0, 1); + vertices[1].coord = short4( 32767, 32767, 0, 1); + vertices[2].coord = short4( 32767, -32767, 0, 1); + vertices[3].coord = short4(-32767, -32767, 0, 1); vertices[0].light = vertices[1].light = vertices[2].light = @@ -1751,15 +1858,27 @@ struct Inventory { m.identity(); Core::setViewProj(m, m); Core::mModel.identity(); - Core::mModel.scale(vec3(1.0f / 32767.0f)); + #else if (Core::settings.detail.stereo == Core::Settings::STEREO_VR || !background[0]) { backTex = Core::blackTex; // black background - } else - backTex = background[0]; // blured grayscale image + } else { + // blured grayscale image + if (Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT) { + backTex = background[view]; + } else { + backTex = background[Core::eye <= 0.0f ? 0 : 1]; + } + } #endif backTex->bind(sDiffuse); + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / 32767.0f)); + Core::setViewProj(mView, mProj); + game->setShader(Core::passFilter, Shader::FILTER_UPSCALE, false, false); Core::active.shader->setParam(uParam, vec4(float(Core::active.textures[sDiffuse]->width), float(Core::active.textures[sDiffuse]->height), 0.0f, 0.0f)); @@ -1767,11 +1886,12 @@ struct Inventory { game->getMesh()->renderBuffer(indices, COUNT(indices), vertices, COUNT(vertices)); } - void renderBackground() { + void renderBackground(int view) { if (!isActive() && titleTimer == 0.0f) return; Core::setDepthTest(false); + Core::setDepthWrite(false); uint8 alpha; if (!isActive() && titleTimer > 0.0f && titleTimer < 1.0f) @@ -1788,16 +1908,17 @@ struct Inventory { if (game->getLevel()->isTitle()) renderTitleBG(1.0f, sy, alpha); else - renderGameBG(); + renderGameBG(view); } else { if (background[1]) - renderGameBG(); + renderGameBG(view); else renderTitleBG(1.0f, sy, alpha); } Core::setBlendMode(bmPremult); Core::setDepthTest(true); + Core::setDepthWrite(true); } void setupCamera(float aspect, bool ui = false) { @@ -1812,8 +1933,8 @@ struct Inventory { if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) pos.z -= 256.0f; - if (Core::settings.detail.stereo == Core::Settings::STEREO_ON) - pos.x += Core::eye * 8.0f; + if (Core::settings.detail.stereo == Core::Settings::STEREO_SBS || Core::settings.detail.stereo == Core::Settings::STEREO_ANAGLYPH) + pos.x += Core::eye * INV_EYE_SEPARATION; Core::mViewInv = mat4(pos, pos + vec3(0, 0, 1), vec3(0, -1, 0)); @@ -1824,10 +1945,12 @@ struct Inventory { } else head.e00 = INF; - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { Core::mProj = Input::hmd.proj[Core::eye == -1.0f ? 0 : 1]; - else - Core::mProj = GAPI::perspective(70.0f, aspect, 32.0f, 2048.0f); + } else { + float eyeSep = Core::eye * INV_EYE_SEPARATION * INV_ZNEAR / INV_EYE_FOCAL_LENGTH; + Core::mProj = GAPI::perspective(INV_FOV, aspect, INV_ZNEAR, INV_ZFAR, eyeSep); + } Core::mView = Core::mViewInv.inverseOrtho(); Core::viewPos = Core::mViewInv.getPos(); @@ -1843,16 +1966,21 @@ struct Inventory { Texture *tmp = background[0]; float sy = 1.0f; - if ((game->getLevel()->version & TR::VER_TR1) && !playLogo) + float ch = 1.0f; + if ((game->getLevel()->version & TR::VER_TR1) && !playLogo) { sy = 1.2f; + if (video->format == Video::PSX) { + ch = 120.0f / 208.0f; + } + } Core::resetLights(); background[0] = video->frameTex[0]; - renderTitleBG(1.0f, sy, 255); + renderTitleBG(1.0f, sy, 255, 1.0f, ch); background[0] = video->frameTex[1]; - renderTitleBG(1.0f, sy, clamp(int((video->stepTimer / video->step) * 255), 0, 255)); + renderTitleBG(1.0f, sy, clamp(int((video->stepTimer / video->step) * 255), 0, 255), 1.0f, ch); background[0] = tmp; @@ -1867,8 +1995,6 @@ struct Inventory { return; // items - game->setupBinding(); - setupCamera(aspect); UI::setupInventoryShading(vec3(0.0f)); @@ -1882,10 +2008,12 @@ struct Inventory { char buf[256]; char time[16]; - int secretsMax = 3; - int secrets = ((saveStats.secrets & 1) != 0) + - ((saveStats.secrets & 2) != 0) + - ((saveStats.secrets & 4) != 0); + int secretsMax = TR::LEVEL_INFO[saveStats.level].secrets; + int secrets = ((saveStats.secrets & (1 << 0)) != 0) + + ((saveStats.secrets & (1 << 1)) != 0) + + ((saveStats.secrets & (1 << 2)) != 0) + + ((saveStats.secrets & (1 << 3)) != 0) + + ((saveStats.secrets & (1 << 4)) != 0); int s = saveStats.time % 60; int m = saveStats.time / 60 % 60; @@ -1897,7 +2025,7 @@ struct Inventory { sprintf(time, "%d:%02d", m, s); sprintf(buf, STR[STR_LEVEL_STATS], - TR::LEVEL_INFO[saveStats.level].title, + STR[TR::LEVEL_INFO[saveStats.level].title], saveStats.kills, saveStats.pickups, secrets, secretsMax, time); @@ -1912,63 +2040,63 @@ struct Inventory { static const StringID pageTitle[PAGE_MAX] = { STR_OPTION, STR_INVENTORY, STR_ITEMS, STR_SAVEGAME, STR_LEVEL_STATS }; - float eye = UI::width * Core::eye * 0.01f; - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) { setupCamera(1.0f, true); Core::active.shader->setParam(uViewProj, Core::mViewProj); - eye = 0.0f; } + float eye = getEyeOffset() * 0.5f; + if (page == PAGE_SAVEGAME) { - UI::renderBar(UI::BAR_OPTION, vec2(-eye + UI::width / 2 - 120, 240 - 14), vec2(240, LINE_HEIGHT - 6), 1.0f, 0x802288FF, 0, 0, 0); - UI::textOut(vec2(-eye, 240), pageTitle[page], UI::aCenter, UI::width); - UI::renderBar(UI::BAR_OPTION, vec2(-eye - 48 * slot + UI::width / 2, 240 + 24 - 16), vec2(48, 18), 1.0f, 0xFFD8377C, 0); - UI::textOut(vec2(-eye - 48 + UI::width / 2, 240 + 24), STR_YES, UI::aCenter, 48); - UI::textOut(vec2(-eye + UI::width / 2, 240 + 24), STR_NO, UI::aCenter, 48); + UI::renderBar(CTEX_OPTION, vec2(UI::width / 2 - 120, 240 - 14), vec2(240, LINE_HEIGHT - 6), 1.0f, 0x802288FF, 0, 0, 0); + UI::textOut(vec2(0, 240), pageTitle[page], UI::aCenter, UI::width); + UI::renderBar(CTEX_OPTION, vec2(-slot * 48 + UI::width / 2, 240 + 24 - 16), vec2(48, 18), 1.0f, 0xFFD8377C, 0); + UI::textOut(vec2(UI::width / 2 - 48, 240 + 24), STR_YES, UI::aCenter, 48); + UI::textOut(vec2(UI::width / 2, 240 + 24), STR_NO, UI::aCenter, 48); return; } if (page == PAGE_LEVEL_STATS) { - showLevelStats(vec2(-eye, 180)); + showLevelStats(vec2(0, 180)); return; } if (!game->getLevel()->isTitle()) - UI::textOut(vec2(-eye, 32), pageTitle[page], UI::aCenter, UI::width); + UI::textOut(vec2(eye, 32), pageTitle[page], UI::aCenter, UI::width); if (canFlipPage(-1)) { - UI::textOut(vec2(16 - eye, 32), "[", UI::aLeft, UI::width); - UI::textOut(vec2(-eye, 32), "[", UI::aRight, UI::width - 20); + UI::textOut(vec2(16, 32), "[", UI::aLeft, UI::width); + UI::textOut(vec2( 0, 32), "[", UI::aRight, UI::width - 20); } if (canFlipPage(1)) { - UI::textOut(vec2(16 - eye, 480 - 16), "]", UI::aLeft, UI::width); - UI::textOut(vec2(-eye, 480 - 16), "]", UI::aRight, UI::width - 20); + UI::textOut(vec2(16, 480 - 16), "]", UI::aLeft, UI::width); + UI::textOut(vec2( 0, 480 - 16), "]", UI::aRight, UI::width - 20); } - if (index == targetIndex && page == targetPage) - renderItemText(eye, items[getGlobalIndex(page, index)]); - // inventory controls help if (page == targetPage && Input::touchTimerVis <= 0.0f) { - float dx = 32.0f - eye; + float dx = 32.0f; char buf[64]; const char *bSelect = STR[STR_KEY_FIRST + ikEnter]; const char *bBack = STR[STR_KEY_FIRST + Core::settings.controls[playerIndex].keys[cInventory].key]; - #ifdef _OS_NX + #if defined(_OS_SWITCH) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_XBOX) || defined(_OS_XB1) bSelect = "A"; bBack = "B"; #endif sprintf(buf, STR[STR_HELP_SELECT], bSelect); - UI::textOut(vec2(dx, 480 - 64), buf, UI::aLeft, UI::width); + UI::textOut(vec2(eye + dx, 480 - 64), buf, UI::aLeft, UI::width); if (chosen) { sprintf(buf, STR[STR_HELP_BACK], bBack); - UI::textOut(vec2(0, 480 - 64), buf, UI::aRight, UI::width - dx); + UI::textOut(vec2(eye, 480 - 64), buf, UI::aRight, UI::width - dx); } } + + if (index == targetIndex && page == targetPage) { + renderItemText(items[getGlobalIndex(page, index)]); + } } }; diff --git a/src/json.h b/src/json.h new file mode 100644 index 00000000..e569cfcc --- /dev/null +++ b/src/json.h @@ -0,0 +1,135 @@ +#ifndef _H_JSON +#define _H_JSON + +#include "utils.h" + +struct JSON { + + enum Type { EMPTY, OBJECT, ARRAY, STRING, NUMBER, FLOAT, BOOL }; + + JSON *prev; + JSON *next; + + char *name; + + union { + JSON *nodes; + char *sValue; + int iValue; + float fValue; + bool bValue; + }; + + Type type; + + JSON(Type type, const char *name = NULL) : nodes(NULL), prev(NULL), next(NULL), type(type) { + this->name = StrUtils::copy(name); + } + + ~JSON() { + switch (type) { + case OBJECT : + case ARRAY : { + JSON *node = nodes; + while (node) { + JSON *next = node->next; + delete node; + node = next; + } + break; + } + case STRING : { + delete[] sValue; + break; + } + default : ; + } + + delete[] name; + } + + JSON* add(Type type, const char *name = NULL) { + ASSERT(this->type != ARRAY || (name == NULL && (!nodes || nodes->type == type))); + return add(new JSON(type, name)); + } + + JSON* add(JSON *node) { + node->prev = NULL; + node->next = nodes; + if (nodes) { + nodes->prev = node; + } + nodes = node; + + return node; + } + + + void add(const char *name, const char *value) { + add(STRING, name)->sValue = StrUtils::copy(value); + } + + void add(const char *name, int value) { + add(NUMBER, name)->iValue = value; + } + + void add(const char *name, float value) { + add(FLOAT, name)->fValue = value; + } + + void add(const char *name, bool value) { + add(BOOL, name)->bValue = value; + } + + void save(char *buffer) { + *buffer = 0; + + if (name) { + strcat(buffer, "\""); + strcat(buffer, name); + strcat(buffer, "\":"); + } + + if (type == EMPTY) { + strcat(buffer, "null"); + } else if (type == OBJECT || type == ARRAY) { + bool isObject = (type == OBJECT); + strcat(buffer, isObject ? "{" : "["); + + JSON *node = nodes; + while (node && node->next) { + node = node->next; + } + while (node) { + node->save(buffer + strlen(buffer)); + node = node->prev; + if (node) { + strcat(buffer, ","); + } + } + strcat(buffer, isObject ? "}" : "]"); + } else if (type == STRING) { + strcat(buffer, "\""); + if (sValue) { + strcat(buffer, sValue); + } + strcat(buffer, "\""); + } else if (type == NUMBER) { + char buf[64]; + _itoa(iValue, buf, 10); + strcat(buffer, buf); + } else if (type == FLOAT) { + char buf[64]; + sprintf(buf, "%.9g", fValue); + strcat(buffer, buf); + + //_gcvt(fValue, 8, buf); + //strcat(buffer, buf); + //strcat(buffer, "0"); + } else if (type == BOOL) { + strcat(buffer, bValue ? "true" : "false"); + } + } +}; + +#endif diff --git a/src/lang.h b/src/lang.h new file mode 100644 index 00000000..9f813d8b --- /dev/null +++ b/src/lang.h @@ -0,0 +1,370 @@ +#ifndef H_LANG +#define H_LANG + +// Thanks: SuiKaze Raider + +enum StringID { + STR_EMPTY +// common + , STR_LOADING + , STR_HELP_PRESS + , STR_HELP_TEXT + , STR_LEVEL_STATS + , STR_HINT_SAVING + , STR_HINT_SAVING_DONE + , STR_HINT_SAVING_ERROR + , STR_YES + , STR_NO + , STR_OFF + , STR_ON + , STR_NO_STEREO + , STR_SBS + , STR_ANAGLYPH + , STR_SPLIT + , STR_VR + , STR_QUALITY_LOW + , STR_QUALITY_MEDIUM + , STR_QUALITY_HIGH + , STR_LANG_EN + , STR_LANG_FR + , STR_LANG_DE + , STR_LANG_ES + , STR_LANG_IT + , STR_LANG_PL + , STR_LANG_PT + , STR_LANG_RU + , STR_LANG_JA + , STR_LANG_GR + , STR_LANG_FI + , STR_LANG_CZ + , STR_LANG_CN + , STR_LANG_HU + , STR_LANG_SV + , STR_APPLY + , STR_GAMEPAD_1 + , STR_GAMEPAD_2 + , STR_GAMEPAD_3 + , STR_GAMEPAD_4 + , STR_NOT_READY + , STR_PLAYER_1 + , STR_PLAYER_2 + , STR_PRESS_ANY_KEY + , STR_HELP_SELECT + , STR_HELP_BACK +// inventory pages + , STR_OPTION + , STR_INVENTORY + , STR_ITEMS +// save game page + , STR_SAVEGAME + , STR_CURRENT_POSITION +// inventory option + , STR_GAME + , STR_MAP + , STR_COMPASS + , STR_STOPWATCH + , STR_HOME + , STR_DETAIL + , STR_SOUND + , STR_CONTROLS + , STR_GAMMA +// passport menu + , STR_LOAD_GAME + , STR_START_GAME + , STR_RESTART_LEVEL + , STR_EXIT_TO_TITLE + , STR_EXIT_GAME + , STR_SELECT_LEVEL +// detail options + , STR_SELECT_DETAIL + , STR_OPT_DETAIL_FILTER + , STR_OPT_DETAIL_LIGHTING + , STR_OPT_DETAIL_SHADOWS + , STR_OPT_DETAIL_WATER + , STR_OPT_DETAIL_VSYNC + , STR_OPT_DETAIL_STEREO + , STR_OPT_SIMPLE_ITEMS + , STR_OPT_RESOLUTION + , STR_SCALE_100 + , STR_SCALE_75 + , STR_SCALE_50 + , STR_SCALE_25 +// sound options + , STR_SET_VOLUMES + , STR_REVERBERATION + , STR_OPT_SUBTITLES + , STR_OPT_LANGUAGE +// controls options + , STR_SET_CONTROLS + , STR_OPT_CONTROLS_KEYBOARD + , STR_OPT_CONTROLS_GAMEPAD + , STR_OPT_CONTROLS_VIBRATION + , STR_OPT_CONTROLS_RETARGET + , STR_OPT_CONTROLS_MULTIAIM + // controls + , STR_CTRL_FIRST + , STR_CTRL_LAST = STR_CTRL_FIRST + cMAX - 1 + // keys + , STR_KEY_FIRST + , STR_KEY_LAST = STR_KEY_FIRST + ikBack + // gamepad + , STR_JOY_FIRST + , STR_JOY_LAST = STR_JOY_FIRST + jkMAX - 1 +// inventory items + , STR_UNKNOWN + , STR_EXPLOSIVE + , STR_PISTOLS + , STR_SHOTGUN + , STR_MAGNUMS + , STR_UZIS + , STR_AMMO_PISTOLS + , STR_AMMO_SHOTGUN + , STR_AMMO_MAGNUMS + , STR_AMMO_UZIS + , STR_MEDI_SMALL + , STR_MEDI_BIG + , STR_LEAD_BAR + , STR_SCION +// keys + , STR_KEY + , STR_KEY_SILVER + , STR_KEY_RUSTY + , STR_KEY_GOLD + , STR_KEY_SAPPHIRE + , STR_KEY_NEPTUNE + , STR_KEY_ATLAS + , STR_KEY_DAMOCLES + , STR_KEY_THOR + , STR_KEY_ORNATE +// puzzles + , STR_PUZZLE + , STR_PUZZLE_GOLD_IDOL + , STR_PUZZLE_GOLD_BAR + , STR_PUZZLE_COG + , STR_PUZZLE_FUSE + , STR_PUZZLE_ANKH + , STR_PUZZLE_HORUS + , STR_PUZZLE_ANUBIS + , STR_PUZZLE_SCARAB + , STR_PUZZLE_PYRAMID +// TR1 subtitles + , STR_TR1_SUB_CAFE + , STR_TR1_SUB_LIFT + , STR_TR1_SUB_CANYON + , STR_TR1_SUB_PRISON + , STR_TR1_SUB_22 // CUT4 + , STR_TR1_SUB_23 // CUT1 + , STR_TR1_SUB_24 + , STR_TR1_SUB_25 // CUT3 + , STR_TR1_SUB_26 + , STR_TR1_SUB_27 + , STR_TR1_SUB_28 + , STR_TR1_SUB_29 + , STR_TR1_SUB_30 + , STR_TR1_SUB_31 + , STR_TR1_SUB_32 + , STR_TR1_SUB_33 + , STR_TR1_SUB_34 + , STR_TR1_SUB_35 + , STR_TR1_SUB_36 + , STR_TR1_SUB_37 + , STR_TR1_SUB_38 + , STR_TR1_SUB_39 + , STR_TR1_SUB_40 + , STR_TR1_SUB_41 + , STR_TR1_SUB_42 + , STR_TR1_SUB_43 + , STR_TR1_SUB_44 + , STR_TR1_SUB_45 + , STR_TR1_SUB_46 + , STR_TR1_SUB_47 + , STR_TR1_SUB_48 + , STR_TR1_SUB_49 + , STR_TR1_SUB_50 + , STR_TR1_SUB_51 + , STR_TR1_SUB_52 + , STR_TR1_SUB_53 + , STR_TR1_SUB_54 + , STR_TR1_SUB_55 + , STR_TR1_SUB_56 +// TR1 levels + , STR_TR1_GYM + , STR_TR1_LEVEL1 + , STR_TR1_LEVEL2 + , STR_TR1_LEVEL3A + , STR_TR1_LEVEL3B + , STR_TR1_LEVEL4 + , STR_TR1_LEVEL5 + , STR_TR1_LEVEL6 + , STR_TR1_LEVEL7A + , STR_TR1_LEVEL7B + , STR_TR1_LEVEL8A + , STR_TR1_LEVEL8B + , STR_TR1_LEVEL8C + , STR_TR1_LEVEL10A + , STR_TR1_LEVEL10B + , STR_TR1_LEVEL10C + , STR_TR1_EGYPT + , STR_TR1_CAT + , STR_TR1_END + , STR_TR1_END2 +// TR2 levels + , STR_TR2_ASSAULT + , STR_TR2_WALL + , STR_TR2_BOAT + , STR_TR2_VENICE + , STR_TR2_OPERA + , STR_TR2_RIG + , STR_TR2_PLATFORM + , STR_TR2_UNWATER + , STR_TR2_KEEL + , STR_TR2_LIVING + , STR_TR2_DECK + , STR_TR2_SKIDOO + , STR_TR2_MONASTRY + , STR_TR2_CATACOMB + , STR_TR2_ICECAVE + , STR_TR2_EMPRTOMB + , STR_TR2_FLOATING + , STR_TR2_XIAN + , STR_TR2_HOUSE +// TR3 levels + , STR_TR3_HOUSE + , STR_TR3_JUNGLE + , STR_TR3_TEMPLE + , STR_TR3_QUADCHAS + , STR_TR3_TONYBOSS + , STR_TR3_SHORE + , STR_TR3_CRASH + , STR_TR3_RAPIDS + , STR_TR3_TRIBOSS + , STR_TR3_ROOFS + , STR_TR3_SEWER + , STR_TR3_TOWER + , STR_TR3_OFFICE + , STR_TR3_NEVADA + , STR_TR3_COMPOUND + , STR_TR3_AREA51 + , STR_TR3_ANTARC + , STR_TR3_MINES + , STR_TR3_CITY + , STR_TR3_CHAMBER + , STR_TR3_STPAUL + + , STR_MAX +}; + +#ifdef _XBOX // TODO: illegal escape sequence + #define STR_RUSSIAN "Russian" +#else + #define STR_RUSSIAN "Ðóññêè{è" +#endif + +#define STR_LANGUAGES \ + "English" \ + , "Fran|cais" \ + , "Deutsch" \ + , "Espa+nol" \ + , "Italiano" \ + , "Polski" \ + , "Portugu(es" \ + , STR_RUSSIAN \ + , "\x11\x02\x70\x01\x97\x01\xD6\xFF\xFF" \ + , "\x11\x01\x22\x01\x0F\x01\x0F\x01\x0E\x01\x06\x01\x04\x01\x0C\x01\x0B\xFF\xFF" \ + , "Suomi" \ + , "{Cesky" \ + , "\x11\x02\x8A\x02\x6C\x01\x54\x03\x02\xFF\xFF" \ + , "Magyar" \ + , "Svenska" + +#define LANG_PREFIXES "_EN", "_FR", "_DE", "_ES", "_IT", "_PL", "_PT", "_RU", "_JA", "_GR", "_FI", "_CZ", "_CN", "_HU", "_SV" + +#define STR_KEYS \ + "NONE", "LEFT", "RIGHT", "UP", "DOWN", "SPACE", "TAB", "ENTER", "ESCAPE", "SHIFT", "CTRL", "ALT" \ + , "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" \ + , "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" \ + , "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" \ + , "PAD0", "PAD1", "PAD2", "PAD3", "PAD4", "PAD5", "PAD6", "PAD7", "PAD8", "PAD9", "PAD+", "PAD-", "PADx", "PAD/", "PAD." \ + , "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" \ + , "-", "+", "<", ">", "/", "\\", ",", ".", "$", ":", "'", "PGUP", "PGDN", "HOME", "END", "DEL", "INS", "BKSP" \ + , "NONE", "A", "B", "X", "Y", "L BUMPER", "R BUMPER", "SELECT", "START", "L STICK", "R STICK", "L TRIGGER", "R TRIGGER", "D-LEFT", "D-RIGHT", "D-UP", "D-DOWN" + +#define STR_SCALE "25", "50", "75", "100" + +const char *helpText = + "Start - add second player or restore Lara@" + "H - Show or hide this help@" + "ALT and ENTER - Fullscreen@" + "5 - Save Game@" + "9 - Load Game@" + "C - Look@" + "R - Slow motion@" + "T - Fast motion@" + "Roll - Up & Down@" + "Step Left - Walk & Left@" + "Step Right - Walk & Right@" + "Out of water - Up & Action@" + "Handstand - Up & Walk@" + "Swan dive - Up & Walk & Jump@" + "First Person View - Look & Action@" + "DOZY on - Look & Duck & Action & Jump@" + "DOZY off - Walk@" + "Free Camera - hold L & R stick"; + +#include "lang/en.h" +#include "lang/fr.h" +#include "lang/de.h" +#include "lang/es.h" +#include "lang/it.h" +#include "lang/pl.h" +#include "lang/pt.h" +#include "lang/ru.h" +#include "lang/ja.h" +#include "lang/gr.h" +#include "lang/fi.h" +#include "lang/cz.h" +#include "lang/cn.h" +#include "lang/hu.h" +#include "lang/sv.h" + +char **STR = NULL; + +void ensureLanguage(int lang) { + ASSERT(COUNT(STR_EN) == STR_MAX); + ASSERT(COUNT(STR_FR) == STR_MAX); + ASSERT(COUNT(STR_DE) == STR_MAX); + ASSERT(COUNT(STR_ES) == STR_MAX); + ASSERT(COUNT(STR_IT) == STR_MAX); + ASSERT(COUNT(STR_PL) == STR_MAX); + ASSERT(COUNT(STR_PT) == STR_MAX); + ASSERT(COUNT(STR_RU) == STR_MAX); + ASSERT(COUNT(STR_JA) == STR_MAX); + ASSERT(COUNT(STR_GR) == STR_MAX); + ASSERT(COUNT(STR_FI) == STR_MAX); + ASSERT(COUNT(STR_CZ) == STR_MAX); + ASSERT(COUNT(STR_CN) == STR_MAX); + ASSERT(COUNT(STR_HU) == STR_MAX); + ASSERT(COUNT(STR_SV) == STR_MAX); + + lang += STR_LANG_EN; + + switch (lang) { + case STR_LANG_FR : STR = (char**)STR_FR; break; + case STR_LANG_DE : STR = (char**)STR_DE; break; + case STR_LANG_ES : STR = (char**)STR_ES; break; + case STR_LANG_IT : STR = (char**)STR_IT; break; + case STR_LANG_PL : STR = (char**)STR_PL; break; + case STR_LANG_PT : STR = (char**)STR_PT; break; + case STR_LANG_RU : STR = (char**)STR_RU; break; + case STR_LANG_JA : STR = (char**)STR_JA; break; + case STR_LANG_GR : STR = (char**)STR_GR; break; + case STR_LANG_FI : STR = (char**)STR_FI; break; + case STR_LANG_CZ : STR = (char**)STR_CZ; break; + case STR_LANG_CN : STR = (char**)STR_CN; break; + case STR_LANG_HU : STR = (char**)STR_HU; break; + case STR_LANG_SV : STR = (char**)STR_SV; break; + default : STR = (char**)STR_EN; break; + } +} + +#endif diff --git a/src/lang/cn.h b/src/lang/cn.h new file mode 100644 index 00000000..d7a1a130 --- /dev/null +++ b/src/lang/cn.h @@ -0,0 +1,764 @@ +#ifndef H_LANG_CN +#define H_LANG_CN + +// Thanks: Jeff_aod & GMLY.INFO + +#include "glyph_cn.h" + +#if 0 +const char *STR_CN[] = { "简体中文" +// help + , "读å–中..." + , "按 H å¼€å¯å¸®åŠ©èœå•" + , helpText + , "%s@@@" + "æ€æ•Œæ•° %d@@" + "物å“æ•° %d@@" + "秘密地点 %d of %d@@" + "过关时间 %s" + , "正在存档..." + , "存档完æˆï¼" + , "存档错误ï¼" + , "是" + , "å¦" + , "关闭" + , "打开" + , "关闭" + , "å·¦å³3D分å±" + , "åŒè‰²åˆ†å±" + , "å·¦å³åˆ†å±æ¨¡å¼" + , "虚拟现实" + , "低" + , "中" + , "高" + , STR_LANGUAGES + , "应用" + , "手柄 1" + , "手柄 2" + , "手柄 3" + , "手柄 4" + , "未准备好" + , "玩家 1" + , "玩家 2" + , "按任æ„é”®" + , "%s - 选择" + , "%s - åŽé€€" +// inventory pages + , "选项" + , "物å“æ " + , "关键物å“" +// save game page + , "存档å—?" + , "现在ä½ç½®" +// inventory option + , "游æˆ" + , "地图" + , "指å—é’ˆ" + , "统计" + , "劳拉之家" + , "细节等级" + , "声音" + , "æ“作" + , "伽马值" +// passport menu + , "读å–游æˆ" + , "新游æˆ" + , "é‡çŽ©å…³å¡" + , "退至èœå•" + , "退出游æˆ" + , "选择关å¡" +// detail options + , "å¯è°ƒæ•´é€‰é¡¹" + , "æ质过滤" + , "光照" + , "阴影" + , "æ°´é¢" + , "åž‚ç›´åŒæ­¥" + , "3D模å¼" + , "2D化å¯æ‹¾ç‰©" + , "分辨率缩放" + , STR_SCALE +// sound options + , "音é‡è®¾å®š" + , "æ··å“" + , "字幕" + , "语言" +// controls options + , "æ“作设定" + , "键盘" + , "手柄" + , "震动" + , "æ€æ•ŒåŽçž„准其他敌人" + , "åŒæ‰‹çž„准ä¸åŒçš„敌人" + // controls + , "å·¦", "å³", "上", "下", "è·³", "èµ°", "动作", "æŒæžª", "观察", "è¹²", "加速跑", "翻滚", "查看背包", "开始" + , STR_KEYS +// inventory items + , "未知" + , "炸è¯" + , "默认手枪" + , "霰弹枪" + , "马格楠大å¨åŠ›æ‰‹æžª" + , "乌兹冲锋枪" + , "手枪弹匣" + , "霰弹枪弹匣" + , "马格楠弹匣" + , "乌兹枪弹匣" + , "å°è¯åŒ…" + , "大è¯åŒ…" + , "铅棒" + , "å¸ç¥­ç›Ž" +// keys + , "钥匙" + , "银钥匙" + , "生锈的钥匙" + , "金钥匙" + , "è“å®çŸ³é’¥åŒ™" + , "海神之匙" + , "大力神之匙" + , "战神之匙" + , "雷神之匙" + , "奢åŽçš„钥匙" +// puzzles + , "谜题物å“" + , "金åƒ" + , "金æ¡" + , "齿轮" + , "ä¿é™©ä¸" + , "安å¡" + , "è·é²æ–¯ä¹‹çœ¼" + , "阿努比斯图章" + , "圣甲虫å®çŸ³" + , "金字塔钥匙" +// TR1 subtitles + /* CAFE */ , + "[43500]一ä½ç”·å£«è‹¥ä¹Ÿæƒ³åšå¾—你的此等关注,ä¸çŸ¥è¯¥åšäº›ä»€ä¹ˆå‘¢ï¼Ÿ" + "[47500]è¿™å¯å¾ˆéš¾è¯´å¾—准。ä¸è¿‡ï¼Œæ‚¨ä¼¼ä¹Žå°±åšå¾—很ä¸é”™ã€‚" + "[50000]哦,那å¯çœŸå¤ªå¥½äº†â€”—尽管事实上想找您的并ä¸æ˜¯æˆ‘。" + "[54500]ä¸æ˜¯å—?" + "[55000]ä¸æ˜¯ï¼æ˜¯æ°å¥Žç³Â·çº³ç‰¹æ‹‰å°å§ï¼Œæ¥è‡ªçº³ç‰¹æ‹‰ç§‘技公å¸ã€‚" + "[59000]知é“å§ï¼Ÿå°±æ˜¯çœ¼å‰è¿™ä½ã€Žæ™ºæ…§ä¸Žç¾Žè²Œå¹¶å­˜ã€çš„ä¼ä¸šå¥ åŸºäººã€‚" + "[64500]行了,拉森ï¼" + "[66000]好的,女士。" + "[68000]先用这个饱饱眼ç¦å§ï¼ŒåŠ³æ‹‰ï¼" + "[70500]ä¸çŸ¥å®ƒä»¬èƒ½è®©ä½ çš„å°è·åŒ…嚷嚷得有多欢呢?" + "[73500]抱歉,我出游åªæ˜¯ä¸ºäº†é‚£ä»½ä¹è¶£ã€‚" + "[76000]那么你会喜欢这个个大游ä¹åœºçš„," + "[78000]秘é²ï¼ç»µå»¶å å¶‚的山峦ã€æ™¶èŽ¹å‰”é€çš„冰å£ã€@摇摇欲å çš„悬崖ã€å‡›å†½åˆºéª¨çš„寒风……" + "[87500]外带这个å°çŽ©æ„儿:一个蕴å«ç€ç¥žç§˜åŠ›é‡çš„å¤è€å™¨ç‰©ï¼Œ" + "[92500]埋è—在未明踪迹的夸洛佩克å¤å¢“里。" + "[96000]那便是我的兴趣所在ï¼" + "[98000]你明天就能出å‘了,你明天有空å§ï¼Ÿ" + /* LIFT */ , + "[49000]现已è¿å…¥åœ£æ–¹æµŽå„堂,新的诱惑折磨ç€æˆ‘。" + "[53500]我的åŒé“兄弟中有传言,在我们的修é“院之下,埋葬ç€è’‚éœåŽçš„é—体," + "[60000]传说中失è½çš„亚特兰蒂斯大陆的三ä½ç»Ÿæ²»è€…之一……" + "[64500]……他的身边陪葬ç€å±žäºŽä»–çš„é‚£å—亚特兰蒂斯å¸ç¥­ç›Žç¢Žç‰‡ã€‚" + "[68000]这件å é¥°è¢«åˆ†æ‹†å¼€ç”±ä¸‰ä½ç»Ÿæ²»è€…分别享有……" + "[72500]……藉此抑制其巨大的å¨åŠ›ã€‚@这一å¨åŠ›å·²è¿œè¿œè¶…越了其创造者自身。" + "[79000]这些确属å¯èƒ½çš„事物如此逼近我这凡人的çµé­‚,使我总是为此汗æµæµƒèƒŒã€‚" + "[85500]æ¯å¤œæˆ‘都强迫自己驱除掉这些臆想,但一切都åªæ˜¯å¾’劳……" + "[92000]" + "[93500]皮埃尔,你这个乱丢垃圾的家伙。" + /* CANYON */ , + "[13500]你刚好扯到了如愿骨上幸è¿çš„那一端。" + "[16500]你好呀ï¼" + "[17500]åˆå®‰ã€‚" + "[20000]åˆåªå‰©æ‹‰æ£®èººåœ¨é‡Œé¢å–˜äº†ï¼Œå—¯ï¼Ÿ" + "[22500]如果已ç»æ˜¯ä¸ªæ¢—了的è¯ï¼Œæ²¡é”™ã€‚" + "[24000]好了,你短暂的旅行放纵也该到此为止了。" + "[27000]是时候把你抢我的东西还回æ¥äº†ã€‚" + "[30000]让我们æ¥ç¿»ç¿»è¿™ä¸ªå°åˆé¤ç›’å§ã€‚" + "[32000]" + "[42500]“好,æ€äº†å¥¹ï¼" + "[45000]嘿ï¼" + "[48000]" + "[50500]你们这群白痴ï¼" + "[53000]" + "[62500]我们走å§ã€‚" + "[65000]" + "[136000]那是什么鬼?" + "[138000]什么呀?" + "[138500]那边ï¼" + "[140500]å¯èƒ½åªæ˜¯ä¸€æ¡é±¼å§ã€‚" + "[142500]那未å…也太大了å§ï¼" + "[145000]兄弟,你得学ç€æ”¾æ¾ç‚¹å„¿ã€‚我回里é¢åŽ»äº†ï¼Œä½ æ¥å—?" + "[152000]" + "[158000]慢慢æ¥..." + "[160000]下去咯ï¼" + "[161500]准备好了没有?" + /* PRISON */ , + "[00001]你们ä¸èƒ½è¿™ä¹ˆåšï¼" + "[01500]æ ¹æ®ä½ æ‰€çŠ¯ä¸‹çš„罪行,亚特兰蒂斯的纳特拉,我们在此对你åšå‡ºåˆ¤å†³ã€‚" + "[06000]å› ä½ æžç«¯æ»¥ç”¨è‡ªå·±çš„æƒåŠ›ï¼Œä»¥åŠå› ä½ æ”«å–我们的……" + "[11500]你们ä¸èƒ½ï¼æˆ‘…" + "[12500]……你破å了我们基于管辖和ä¿æŠ¤æˆ‘们的人民所达æˆçš„自由盟约," + "[18500]并且驱策我们自己的军队侵袭了蒂éœåŽå’Œæˆ‘本人。" + "[23500]我们自己的战士被你从我们的金字塔里完全清空," + "[27000]以便你å¯ä»¥å½»åº•åˆ©ç”¨é‚£åº§å…·æœ‰é€ ç‰©ä¹‹èƒ½çš„金字塔,@为你个人那盲目的破å欲æœåŠ¡ï¼" + "[33500]盲目?看看你们自己å§ï¼" + "[35500]你俩的脑袋里何曾冒出过哪怕一滴创造之泉?" + "[40500]废物ï¼" + "[41500]我们直接执行å§ã€‚" + "[44000]è’‚éœåŽï¼" + "[45000]你将神圣之所用于满足你个人的ç§æ¬²ï¼Œ" + "[49500]将它å˜æˆäº†ä¸€ä¸ªå¼‚形制造厂ï¼" + "[51000]他们是生存下æ¥çš„适者ï¼æ˜¯ä¸€ä¸ªæ–°çš„世代ï¼" + "[54000]现在åªæ˜¯ä¸€å †æŒ¨å®°çš„生肉罢了。" + "[56000]至于你,我们将把你ç¦é”¢äºŽç‰¢ç¬¼ä¹‹ä¸­ï¼Œ" + "[60000]你的血管ã€å¿ƒè„ã€åŒè¶³" + "[64000]以åŠé‚£ç—…æ€çš„大脑都将éšç€ä½ é‚£è¢«å†»ç»“的血液而固化定格。" + "[70000]准备迎接你那永ä¸å¾—安æ¯çš„长眠å§ï¼Œçº³ç‰¹æ‹‰ï¼" + "[73000]你俩也ä¸ä¼šå¾—善终的ï¼è¿˜æœ‰ä½ ä»¬é‚£è¯¥æ­»çš„亚特兰蒂斯大陆ï¼" + /* 22 */ , + "[04000]ä½ åˆå›žæ¥äº†ï¼Ÿ" + "[05500]ä½ ä¸ä¹Ÿæ˜¯å—?我想你回æ¥æ˜¯ä¸ºäº†å†ä¸€æ¬¡éš†é‡å¼€ä¸šå§ï¼Ÿ" + "[09500]进化陷入了一æˆä¸å˜çš„定å¼ã€‚自然选择的æˆæ•ˆæ€»æ˜¯é‚£æ ·çš„低下。" + "[13500]引入全新的物ç§å°†å†ä¸€æ¬¡æ¿€èµ·åœ°ç›˜æ€§é˜²å«çš„狂暴," + "[17500]进而强化和æå‡æˆ‘们," + "[20500]甚至创造出新的å“ç§ã€‚" + "[22500]用嗑è¯æ¥åŠ å¿«è¿›åŒ–,是å§ï¼Ÿ" + "[24500]è½åŽå°±è¦æŒ¨æ‰“,夸洛佩克和蒂éœåŽé‚£ä¸¤ä¸ªä¾å„’根本什么都ä¸æ‡‚。" + "[29500]亚特兰蒂斯的ç¾éš¾æ‰“击了一个本就软弱无能的ç§æ—," + "[33500]å†ä¸€æ¬¡ä½¿ä»–们骤é™è‡³æ±‚存的最基本水平。" + "[37000]一切都ä¸è¯¥é‚£æ ·ã€‚" + "[39000]也ä¸è¯¥åƒè¿™æ ·ã€‚" + "[40000]孵化在å五秒åŽå¼€å§‹ã€‚" + "[43000]现在æµäº§å·²ç»å¤ªæ™šäº†ã€‚" + "[45000]没了è¿è½¬æ ¸å¿ƒçš„è¯å°±ä¸ç®—晚ï¼" + "[47000]ä¸ï¼" + "[50000]å" + "[54000]五..." + "[55500]å››... 三... 二..." + "[60000]一..." + /* 23 */ , + "[00001]好了,你现在å¯ç®—得到了我全部的注æ„力," + "[02500]ä¸è¿‡æˆ‘ä¸å¤ªç¡®å®šä½ æœ‰æ²¡æœ‰æŠŠæˆ‘放在眼里," + "[05000]我说的è¯ä½ å¬åˆ°äº†å—?" + "[06000]我è¦æŠŠä½ ç»‘èµ·æ¥åŠç€æ‰“," + "[09000]当然了。" + "[10000]è¿žç€ä½ å’Œé‚£ç ´çƒ‚å¸ç¥­ç›Žç¢Žç‰‡ï¼Œ" + "[13000]这么想è¦çš„è¯ï¼Œæˆ‘就把它塞到你的……" + "[17000]ç¨ç­‰ï¼Œä½ åœ¨è¯´è¿™ä»¶å¤å™¨å—?" + "[20000]废è¯ï¼Œæˆ‘è¦æŠŠå®ƒå¡žåˆ°ä½ çš„……" + "[22000]等等,ä¸å¥½æ„æ€ï¼Œ" + "[24000]你刚刚说碎片,那剩下的呢?" + "[26500]纳特拉å°å§æ´¾çš®åŸƒå°”·æœé‚¦åŽ»æ‰¾äº†ã€‚" + "[29500]他人呢?" + "[30500]哈ï¼ä½ åŠ¨ä½œä¸å¤Ÿå¿«ï¼Œèµ¶ä¸ä¸Šä»–çš„ï¼" + "[34000]跟你说说è¯åˆä¸è´¹æ—¶é—´ã€‚" + "[37000]我怎么会知é“é‚£åªåˆ°å¤„乱窜的长腿大兔蛙正往哪里蹦跶呀ï¼" + "[42000]你得去问纳特拉å°å§ã€‚" + "[46000]" + "[51000]谢谢你,我这就去。" + /* 24 */ , "" + /* 25 */ , + "[03500]这里安眠ç€è’‚éœåŽï¼Œ" + "[05000]亚特兰蒂斯两ä½æ­£ç›´çš„统治者之一。" + "[10000]甚至在这å—大陆é­å—ç­é¡¶ä¹‹ç¾åŽï¼Œ" + "[13000]ä»–ä¾ç„¶äºŽæ­¤ç«­åŠ›ç»´æŒç€è´«ç˜ ä»–乡的秩åºã€‚" + "[19000]他终身未有å­å—£ï¼Œä»–的学识亦无人继承。" + "[25500]他满怀ä»æ…ˆåœ°åœ¨å¤©ä¸Šçœ‹æŠ¤ç€æˆ‘们——蒂éœåŽã€‚" + /* 26 */ , "欢迎光临寒èˆï¼Œè¯·è®©æˆ‘带你å‚观一下。" + /* 27 */ , "使用方å‘键,æ¥æŽ§åˆ¶æˆ‘到音ä¹åŽ…。" + /* 28 */ , "好的,开始åšäº›é”»ç‚¼å§ã€‚按下跳跃键。" + /* 29 */ , "å†æŒ‰ä¸€æ¬¡è·³è·ƒé”®ï¼Œå¹¶åŒæ—¶æŒ‰ä¸‹æ–¹å‘键,我就会往那个方å‘跳跃。" + /* 30 */ , "抱歉,箱å­åœ¨å¤§åŽ…堆得一团糟。我有些东西想放到储è—室,但æ¬è¿å·¥è¿˜æ²¡æ¥ã€‚" + /* 31 */ , "跑到箱å­æ—,在按下å‰è¿›çš„åŒæ—¶æŒ‰ä¸‹åŠ¨ä½œé”®ï¼Œæˆ‘就会爬到箱å­ä¸Šã€‚" + /* 32 */ , "这里本æ¥æ˜¯èˆžåŽ…,但我把它改æˆäº†å¥èº«æˆ¿ã€‚@喜欢å—?我们æ¥ç»ƒç»ƒæ‰‹å§ã€‚" + /* 33 */ , "我ä¸ä»…能跑,还能慢走,尤其是我需è¦å°å¿ƒçš„时候。@按ä½è¡Œèµ°é”®ï¼Œå¸¦æˆ‘走到白线那儿。" + /* 34 */ , "按ç€è¡Œèµ°é”®çš„时候,我ä¸ä¼šæŽ‰ä¸‹åŽ»çš„,ä¸ä¿¡ä½ åŽ»è¯•è¯•å§ã€‚" + /* 35 */ , "如果你想仔细观察周围,按ä½è§‚察键,å†åŒæ—¶æŒ‰ä½ä½ æƒ³è§‚察的方å‘å°±å¯ä»¥äº†ã€‚" + /* 36 */ , "如果è·ç¦»å¤ªè¿œè·³ä¸è¿‡åŽ», 我å¯ä»¥æŠ“ä½è¾¹ç¼˜ã€‚@往白线处慢走,我掉ä¸ä¸‹åŽ»çš„。按ä½è·³è·ƒé”®ï¼Œ@å†ç«‹åˆ»æŒ‰ä½å‰æ–¹å‘é”®, 最åŽæŒ‰ä½åŠ¨ä½œé”®ã€‚" + /* 37 */ , "按å‰æ–¹å‘键,我就会爬上去。" + /* 38 */ , "如果助跑一下,我就能跳过去,根本ä¸æ˜¯é—®é¢˜ã€‚" + /* 39 */ , "走到白线æ—,我会åœä¸‹æ¥ã€‚放开行走键,在按一下åŽé€€ç»™æˆ‘助跑的è·ç¦»ã€‚@按下å‰è¿›ï¼Œå†å¾ˆå¿«åœ°åŒæ—¶æŒ‰ä¸‹è·³è·ƒï¼Œæˆ‘就能跳过去了。@我自己会在最åŽä¸€åˆ»èµ·è·³çš„。" + /* 40 */ , "好,这一跳特别远。@跟刚刚一样助跑跳,@但这次è¦åœ¨åŠç©ºä¸­æŒ‰ä¸‹åŠ¨ä½œé”®ä½¿æˆ‘抓ä½è¾¹ç¼˜ã€‚" + /* 41 */ , "好æžäº†ã€‚" + /* 42 */ , "试ç€çˆ¬è¿›åŽ»çœ‹çœ‹ã€‚一起按å‰è¿›å’ŒåŠ¨ä½œé”®ã€‚" + /* 43 */ , "空隙太å°ï¼Œæˆ‘爬ä¸è¿›åŽ»ã€‚@但按下å³æ–¹å‘键我å¯ä»¥æ‘†è¡åˆ°æœ‰ç©ºé—´çš„地方,@å°±å¯ä»¥æŽ¥ç€æŒ‰å‰è¿›è®©æˆ‘爬上去了。" + /* 44 */ , "棒æžäº†ï¼å¦‚果高度太高我åˆä¸æƒ³æ‘”ç€è‡ªå·±ï¼Œæˆ‘å¯ä»¥å°å¿ƒå¾—下去。" + /* 45 */ , "按下åŽé€€ï¼Œæˆ‘会åŽé€€ä¸€å¤§æ­¥ã€‚@立刻按ä½åŠ¨ä½œé”®ï¼Œæˆ‘就能抓ä½è¾¹ç¼˜ã€‚" + /* 46 */ , "æ¾æ‰‹å§ã€‚" + /* 47 */ , "一起去游个泳å§ã€‚" + /* 48 */ , "在水下,按跳跃键和方å‘键能控制我移动。" + /* 49 */ , "å•Šï¼ç©ºæ°”ï¼@用方å‘é”®å¯ä»¥è®©æˆ‘在水é¢ä¸Šæ¸¸åŠ¨ã€‚@按下跳跃键,我们就能å†æ½œä¸€æ¬¡æ°´ã€‚@或者游到岸边,按动作键爬上去。" + /* 50 */ , "好的。我最好把湿衣æœå¿«è„±æŽ‰ã€‚" + /* 51 */ , "茄å­ï¼" + /* 52 */ , "这事儿ä¸é’ˆå¯¹ä½ ä¸ªäººã€‚" + /* 53 */ , "上次你把我脑袋踢得å¯ä¹±ã€‚@它一直在给我出些å主æ„哦。@比如一枪把你干进地狱ï¼" + /* 54 */ , "想干掉我和我的å°å›¢ä¼™å¯æ²¡é‚£ä¹ˆç®€å•ï¼ŒåŠ³æ‹‰ã€‚" + /* 55 */ , "现在æ¥æ‰æ¥é¢å¥–典礼有点儿晚了å§ï¼Ÿ@ä¸è¿‡ï¼Œè¿˜å¾—看你抢ä¸æŠ¢å¾—过我了ï¼" + /* 56 */ , "你在å‘è°å¼€ç«å‘¢ï¼Ÿ@你真的在å‘我开ç«å—?@周围没人啊,那你å¯èƒ½çœŸåœ¨å‘我开ç«äº†å§ï¼" +// TR1 levels + , "劳拉之家" + , "æ´žç©´" + , "比尔å¡ç­å·´åŸŽ" + , "失è½çš„山谷" + , "夸洛佩克å¤å¢“" + , "圣方济å„å ‚" + , "大竞技场" + , "弥达斯宫殿" + , "æ°´æ± " + , "è’‚éœåŽå¤å¢“" + , "哈蒙城" + , "哈蒙方尖碑" + , "å¸ç¥­ç›Žåœ£åŸŸ" + , "纳特拉的矿井" + , "亚特兰蒂斯" + , "大金字塔" + , "é‡è¿”埃åŠ" + , "猫之神庙" + , "亚特兰蒂斯è¦å¡ž" + , "孵化所" +// TR2 levels + , "劳拉之家" + , "长城" + , "å¨å°¼æ–¯" + , "巴托利的è—身处" + , "歌剧院" + , "海上钻塔" + , "潜水区域" + , "水下40英寻" + , "玛利亚å·çš„残骸" + , "ä½å®…区" + , "甲æ¿" + , "西è—丘陵" + , "å°ç»é™¢" + , "塔里昂的陵墓" + , "冰殿" + , "西安庙宇" + , "浮岛" + , "龙之巢穴" + , "家,甜蜜的家" +// TR3 levels + , "劳拉之家" + , "丛林地带" + , "神庙废墟" + , "æ’æ²³" + , "å¡é‡Œäºšæ´žç©´" + , "沿海æ‘庄" + , "å æœºåœ°ç‚¹" + , "马都布峡谷" + , "普纳庙宇" + , "泰晤士河畔" + , "阿尔定地é“ç«™" + , "路德之门" + , "市区" + , "内åŽè¾¾æ²™æ¼ " + , "高度机密地区" + , "51区" + , "å—æžæ´²" + , "RX科技矿石场" + , "失è½çš„天诺城" + , "陨石巨穴" + , "诸圣堂" +}; +#endif + +#define CN_GLYPH_COUNT 832 +#define CN_GLYPH_BASE 0 +const uint8 CN_GLYPH_WIDTH[] = { + 15, 4, 6, 15, 15, 13, 9, 15, 15, 15, 15, 15, 15, 15, 15, 10, + 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 14, 15, 15, 15, 14, 15, 15, 14, 15, 15, 15, + 15, 15, 15, 14, 15, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 4, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 13, 15, + 15, 15, 15, 14, 15, 15, 15, 12, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 12, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 15, 15, 14, 15, 15, 15, 17, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 15, 15, 15, 15, 15, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 12, 15, 15, 15, + 15, 15, 15, 13, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, + 15, 15, 12, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, + 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 12, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 14, 15, 15, 15, 12, 15, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 14, 14, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 15, 15, 15, 6, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 5, 15, 15, 15, 15, 15, + 15, 12, 15, 15, 15, 15, 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, + 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 15, 15, 15, 14, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 4, 15, 15, 15, }; + +const char *STR_CN[] = { "\x11\x02\x8A\x02\x6C\x01\x54\x03\x02\xFF\xFF" +// help + , "\x11\x02\x4F\x01\xDD\x01\x54\xFF\xFF""..." + , "\x11\x01\x0A\xFF\xFF"" H \x11\x01\x33\x03\x3A\x02\xE4\x01\xB4\x02\x39\x02\x22\xFF\xFF" + , helpText + , "%s@@@" + "\x11\x02\x14\x01\xA7\x02\x6F\xFF\xFF"" %d@@" + "\x11\x01\x3E\x01\x9B\x02\x6F\xFF\xFF"" %d@@" + "\x11\x02\x02\x02\x55\x01\x2D\x01\xA1\xFF\xFF"" %d of %d@@" + "\x11\x01\x37\x01\x60\x01\x43\x02\x19\xFF\xFF"" %s" + , "\x11\x02\x16\x01\x0B\x01\x5F\x01\xC2\xFF\xFF""..." + , "\x11\x01\x5F\x01\xC2\x02\x52\x01\x77\x01\x07\xFF\xFF" + , "\x11\x01\x5F\x01\xC2\x01\xD8\x04\x17\x01\x07\xFF\xFF" + , "\x11\x01\x11\xFF\xFF" + , "\x11\x04\x0A\xFF\xFF" + , "\x11\x01\x60\x02\x4E\xFF\xFF" + , "\x11\x01\xB2\x01\x33\xFF\xFF" + , "\x11\x01\x60\x02\x4E\xFF\xFF" + , "\x11\x01\xF5\x01\xAF\xFF\xFF""3D\x11\x01\x72\x01\xF8\xFF\xFF" + , "\x11\x01\xF9\x03\x83\x01\x72\x01\xF8\xFF\xFF" + , "\x11\x01\xF5\x01\xAF\x01\x72\x01\xF8\x02\x44\x01\xFC\xFF\xFF" + , "\x11\x03\x86\x03\x89\x01\x52\x02\x2E\xFF\xFF" + , "\x11\x02\x27\xFF\xFF" + , "\x11\x01\x54\xFF\xFF" + , "\x11\x01\xCE\xFF\xFF" + , STR_LANGUAGES + , "\x11\x03\x82\x01\x4D\xFF\xFF" + , "\x11\x01\x2F\x01\x9E\xFF\xFF"" 1" + , "\x11\x01\x2F\x01\x9E\xFF\xFF"" 2" + , "\x11\x01\x2F\x01\x9E\xFF\xFF"" 3" + , "\x11\x01\x2F\x01\x9E\xFF\xFF"" 4" + , "\x11\x01\x97\x01\x70\x01\xE9\x01\x20\xFF\xFF" + , "\x11\x01\xC1\x01\x44\xFF\xFF"" 1" + , "\x11\x01\xC1\x01\x44\xFF\xFF"" 2" + , "\x11\x01\x0A\x03\x97\x01\x95\x01\x0D\xFF\xFF" + , "%s - \x11\x01\x99\x01\xFA\xFF\xFF" + , "%s - \x11\x01\x36\x01\x78\xFF\xFF" +// inventory pages + , "\x11\x01\x99\x02\xB2\xFF\xFF" + , "\x11\x01\x3E\x01\x9B\x03\x65\xFF\xFF" + , "\x11\x01\x60\x01\x0D\x01\x3E\x01\x9B\xFF\xFF" +// save game page + , "\x11\x01\x5F\x01\xC2\x01\x49\xFF\xFF""?" + , "\x11\x01\x52\x01\x0B\x01\x7A\x03\x64\xFF\xFF" +// inventory option + , "\x11\x01\x40\x01\xBB\xFF\xFF" + , "\x11\x01\x2D\x02\x84\xFF\xFF" + , "\x11\x03\x76\x02\x80\x02\x75\xFF\xFF" + , "\x11\x01\xB0\x03\x7A\xFF\xFF" + , "\x11\x01\x64\x01\x21\x01\x14\x01\x44\xFF\xFF" + , "\x11\x02\x96\x03\xBE\x01\x9A\x03\xBC\xFF\xFF" + , "\x11\x03\xBF\x01\xD6\xFF\xFF" + , "\x11\x02\x8D\x01\x3C\xFF\xFF" + , "\x11\x03\xB6\x01\xBE\x03\xB5\xFF\xFF" +// passport menu + , "\x11\x02\x4F\x01\xDD\x01\x40\x01\xBB\xFF\xFF" + , "\x11\x01\x98\x01\x40\x01\xBB\xFF\xFF" + , "\x11\x02\x17\x01\xC1\x01\x60\x01\x9C\xFF\xFF" + , "\x11\x01\x78\x01\x9D\x02\x39\x02\x22\xFF\xFF" + , "\x11\x01\x78\x01\x57\x01\x40\x01\xBB\xFF\xFF" + , "\x11\x01\x99\x01\xFA\x01\x60\x01\x9C\xFF\xFF" +// detail options + , "\x11\x01\x1A\x03\xBA\x03\xB9\x01\x99\x02\xB2\xFF\xFF" + , "\x11\x03\xCC\x03\xCB\x01\x37\x03\xCA\xFF\xFF" + , "\x11\x02\x7C\x03\xCD\xFF\xFF" + , "\x11\x03\xD0\x03\xCF\xFF\xFF" + , "\x11\x01\x45\x01\xA4\xFF\xFF" + , "\x11\x03\xC5\x01\xBA\x01\x5D\x02\xA4\xFF\xFF" + , "3D\x11\x02\x44\x01\xFC\xFF\xFF" + , "2D\x11\x01\x5E\x01\x1A\x03\xC6\x01\x3E\xFF\xFF" + , "\x11\x01\x72\x03\xC8\x03\xA1\x03\xA0\x01\x69\xFF\xFF" + , STR_SCALE +// sound options + , "\x11\x01\xD6\x02\x86\x02\x89\x01\x68\xFF\xFF" + , "\x11\x03\x9D\x03\xB0\xFF\xFF" + , "\x11\x01\x96\x03\xAE\xFF\xFF" + , "\x11\x03\xB3\x02\xB3\xFF\xFF" +// controls options + , "\x11\x02\x8D\x01\x3C\x02\x89\x01\x68\xFF\xFF" + , "\x11\x01\x0D\x02\xAD\xFF\xFF" + , "\x11\x01\x2F\x01\x9E\xFF\xFF" + , "\x11\x03\xA7\x01\x2C\xFF\xFF" + , "\x11\x02\x14\x01\xA7\x01\x36\x02\x9D\x01\x70\x01\xD2\x01\x29\x01\xA7\x01\x27\xFF\xFF" + , "\x11\x01\xF9\x01\x2F\x02\x9D\x01\x70\x01\x08\x01\x5D\x01\x01\x01\xA7\x01\x27\xFF\xFF" + // controls + , "\x11\x01\xF5\xFF\xFF", "\x11\x01\xAF\xFF\xFF", "\x11\x01\x2B\xFF\xFF", "\x11\x01\x0C\xFF\xFF", "\x11\x01\x24\xFF\xFF", "\x11\x01\x3F\xFF\xFF", "\x11\x01\x2C\x01\x3C\xFF\xFF", "\x11\x02\xA6\x01\x41\xFF\xFF", "\x11\x01\x82\x01\xA9\xFF\xFF", "\x11\x03\xAB\xFF\xFF", "\x11\x02\xA8\x03\xAC\x01\x6A\xFF\xFF", "\x11\x02\x1A\x03\xAD\xFF\xFF", "\x11\x03\xAA\x01\x62\x02\xA0\x01\xC7\xFF\xFF", "\x11\x01\x33\x02\x23\xFF\xFF" + , STR_KEYS +// inventory items + , "\x11\x01\x97\x01\x91\xFF\xFF" + , "\x11\x03\xA8\x01\xC4\xFF\xFF" + , "\x11\x03\xA9\x03\xB2\x01\x2F\x01\x41\xFF\xFF" + , "\x11\x02\xB0\x01\x66\x01\x41\xFF\xFF" + , "\x11\x01\xBE\x02\x03\x02\xB4\x01\x1D\x01\xC5\x01\x4A\x01\x2F\x01\x41\xFF\xFF" + , "\x11\x02\x81\x02\x74\x03\xB4\x03\xB1\x01\x41\xFF\xFF" + , "\x11\x01\x2F\x01\x41\x01\x66\x01\xCF\xFF\xFF" + , "\x11\x02\xB0\x01\x66\x01\x41\x01\x66\x01\xCF\xFF\xFF" + , "\x11\x01\xBE\x02\x03\x02\xB4\x01\x66\x01\xCF\xFF\xFF" + , "\x11\x02\x81\x02\x74\x01\x41\x01\x66\x01\xCF\xFF\xFF" + , "\x11\x01\x34\x01\xC4\x01\xC7\xFF\xFF" + , "\x11\x01\x1D\x01\xC4\x01\xC7\xFF\xFF" + , "\x11\x03\xAF\x02\x76\xFF\xFF" + , "\x11\x01\x93\x01\xD1\x01\xCA\xFF\xFF" +// keys + , "\x11\x01\x58\x01\x32\xFF\xFF" + , "\x11\x03\x9E\x01\x58\x01\x32\xFF\xFF" + , "\x11\x02\x09\x03\x9F\x01\x01\x01\x58\x01\x32\xFF\xFF" + , "\x11\x01\x4F\x01\x58\x01\x32\xFF\xFF" + , "\x11\x03\x9C\x02\x85\x01\xA6\x01\x58\x01\x32\xFF\xFF" + , "\x11\x02\x1D\x01\x4C\x01\x14\x01\x32\xFF\xFF" + , "\x11\x01\x1D\x01\x4A\x01\x4C\x01\x14\x01\x32\xFF\xFF" + , "\x11\x02\x8C\x01\x4C\x01\x14\x01\x32\xFF\xFF" + , "\x11\x03\x99\x01\x4C\x01\x14\x01\x32\xFF\xFF" + , "\x11\x03\x9A\x02\x95\x01\x01\x01\x58\x01\x32\xFF\xFF" +// puzzles + , "\x11\x03\x9B\x02\x94\x01\x3E\x01\x9B\xFF\xFF" + , "\x11\x01\x4F\x02\x98\xFF\xFF" + , "\x11\x01\x4F\x02\x92\xFF\xFF" + , "\x11\x03\xA4\x03\xA5\xFF\xFF" + , "\x11\x02\x79\x03\xA6\x03\xA3\xFF\xFF" + , "\x11\x01\x89\x01\x9C\xFF\xFF" + , "\x11\x02\xB5\x02\xA1\x01\x2A\x01\x14\x01\xB9\xFF\xFF" + , "\x11\x02\xA2\x03\xA2\x02\x13\x01\x2A\x02\x84\x03\xC7\xFF\xFF" + , "\x11\x01\x6C\x02\xA5\x03\xC9\x02\x85\x01\xA6\xFF\xFF" + , "\x11\x01\x4F\x01\x96\x01\x6B\x01\x58\x01\x32\xFF\xFF" +// TR1 subtitles + /* CAFE */ , + "[43500]\x11\x01\x09\x01\x7A\x03\xC3\x01\xB3\x03\xC4\x01\x67\x01\x35\x03\xCE\x01\x23\x01\x05\x01\x01\x01\x55\x01\x9A\x01\x60\x02\xAE\x01\x02\x01\x08\x01\x91\x01\x81\x01\x85\x01\x79\x01\xAB\x01\x42\x01\x7D\x01\x10\xFF\xFF" + "[47500]\x11\x01\x12\x01\x1A\x02\x18\x02\x91\x01\x59\x01\x23\x01\x70\x01\x03\x01\x08\x01\x37\x01\x02\x02\x8F\x03\xBB\x03\xB8\x01\x17\x01\x85\x01\x23\x02\x18\x01\x08\x01\xD8\x01\x03\xFF\xFF" + "[50000]\x11\x02\x8B\x01\x02\x01\x0E\x01\x1A\x02\x1B\x01\x50\x01\x20\x01\x06\x01\xCC\x01\xCC\x03\xB7\x01\xD5\x01\xD3\x02\x2E\x01\x2B\x01\x35\x02\x8E\x02\x8F\x01\x01\x01\xBF\x01\x08\x01\x11\x01\x04\x01\x03\xFF\xFF" + "[54500]\x11\x01\x08\x01\x11\x01\x49\x01\x10\xFF\xFF" + "[55000]\x11\x01\x08\x01\x11\x01\x07\x01\x11\x03\xC0\x03\xC1\x03\xC2\xFF\xFF""·\x11\x01\x46\x01\x1B\x01\x21\x01\x34\x01\xD9\x01\x02\x01\x18\x01\x31\x01\x46\x01\x1B\x01\x21\x02\x88\x01\xD7\x03\xBD\x01\x93\x01\x03\xFF\xFF" + "[59000]\x11\x01\x91\x01\xA2\x01\x15\x01\x10\x01\x17\x01\x11\x01\xB9\x01\x63\x01\x12\x01\x7A\x03\x98\x03\x72\x03\x73\x03\x74\x03\x71\x03\x6E\x01\xBF\x01\x5F\x03\x6F\x01\x01\x03\x70\x02\x78\x03\x79\x01\xF6\x01\x27\x01\x03\xFF\xFF" + "[64500]\x11\x01\x61\x01\x06\x01\x02\x01\x21\x02\x7A\x01\x07\xFF\xFF" + "[66000]\x11\x01\x20\x01\x01\x01\x02\x03\x7B\x01\xB3\x01\x03\xFF\xFF" + "[68000]\x11\x03\x78\x01\x4D\x01\x12\x01\x19\x02\x73\x02\x73\x01\xB9\x03\x75\x01\x15\x01\x02\x01\x64\x01\x21\x01\x07\xFF\xFF" + "[70500]\x11\x01\x08\x01\x91\x01\x7C\x01\x0F\x01\x1C\x01\x8F\x01\x05\x01\x01\x01\x34\x02\xB5\x01\xC7\x02\x83\x02\x83\x01\x23\x01\x25\x03\x77\x01\xB5\x01\x7D\x01\x10\xFF\xFF" + "[73500]\x11\x02\x7B\x02\x7D\x01\x02\x01\x04\x01\x57\x01\x40\x01\x7B\x01\x11\x01\x8B\x01\x06\x01\x0E\x03\x66\x01\xF1\x02\x7E\x01\x03\xFF\xFF" + "[76000]\x11\x01\x0E\x01\x42\x01\x05\x01\x39\x02\xB1\x01\xB5\x01\x12\x01\x19\x01\x19\x01\x1D\x01\x40\x01\xF1\x01\xF3\x01\x01\x01\x02\xFF\xFF" + "[78000]\x11\x02\x02\x02\xA1\x01\x07\x03\x63\x03\x60\x03\x61\x03\x62\x01\x01\x02\xAC\x03\x6B\x01\x8E\x03\x6C\x03\x6D\x03\x6A\x03\x67\x01\x01\x02\x9F\x03\x68\x01\x8E\xFF\xFF""@\x11\x02\x9E\x02\x9E\x01\xF0\x01\xE5\x01\x01\x03\x69\x03\x8E\x01\x8E\x03\x8F\x03\x90\x03\x8D\x02\x9A\x01\x01\x02\x99\x03\x8A\x01\x13\x01\x13\xFF\xFF" + "[87500]\x11\x03\x8B\x01\xD0\x01\x12\x01\x19\x01\x34\x01\xC1\x01\x95\x01\x8C\x03\x8C\x01\x09\x01\x19\x03\x95\x03\x96\x01\x22\x01\x4C\x02\x02\x01\x4A\x02\x86\x01\x01\x01\x8D\x03\x94\x02\xAB\x01\x3E\x01\x02\xFF\xFF" + "[92500]\x11\x02\xAA\x01\xC6\x01\x0B\x01\x97\x01\xE3\x03\x91\x03\x92\x01\x01\x01\xED\x01\xEC\x01\xEF\x01\xEE\x01\x8D\x01\xBD\x01\x30\x01\x03\xFF\xFF" + "[96000]\x11\x01\x0E\x02\xA3\x01\x11\x01\x04\x01\x01\x03\x93\x02\x7E\x01\x8A\x01\x0B\x01\x07\xFF\xFF" + "[98000]\x11\x01\x05\x01\xE3\x01\xCB\x01\x17\x01\x1C\x01\x57\x03\x80\x01\x06\x01\x02\x01\x05\x01\xE3\x01\xCB\x01\x25\x01\x71\x01\x15\x01\x10\xFF\xFF" + /* LIFT */ , + "[49000]\x11\x01\x52\x01\xC8\x03\x81\x01\xEA\x01\x6C\x01\x26\x02\x35\x02\x37\x01\xEB\x01\x02\x01\x98\x01\x01\x03\x7F\x03\x7C\x03\x7D\x03\x7E\x01\x22\x01\x04\x01\x03\xFF\xFF" + "[53500]\x11\x01\x04\x01\x01\x01\x5D\x01\xA2\x02\x3F\x02\x41\x01\x54\x01\x25\x02\x43\x02\xB3\x01\x02\x01\x0B\x01\x04\x01\x0F\x01\x01\x03\x87\x01\xA2\x01\xE1\x01\x14\x01\x0C\x01\x02\x02\xAA\x02\x3C\x01\x22\x01\x1E\x01\x65\x01\x5B\x01\x01\x03\x88\x02\x6C\x01\x02\xFF\xFF" + "[60000]\x11\x02\x43\x01\x59\x01\x54\x01\xE6\x01\xCD\x01\x01\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x1D\x01\xE7\x01\x01\x01\xE4\x01\x7A\x01\xB0\x01\xFB\x01\x6F\x01\x14\x01\x09\x01\x13\x01\x13\xFF\xFF" + "[64500]\x11\x01\x13\x01\x13\x01\x29\x01\x01\x01\x92\x01\x6D\x03\x84\x02\x3C\x01\x22\x02\x60\x01\x6E\x01\x29\x01\x01\x01\x0E\x02\x62\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x93\x01\xD1\x01\xCA\x01\xFF\x02\x01\x01\x03\xFF\xFF" + "[68000]\x11\x01\x12\x02\x5C\x01\xE5\x03\x85\x01\xFE\x01\x72\x04\x1C\x01\x33\x02\x5D\x01\xE4\x01\x7A\x01\xB0\x01\xFB\x01\x6F\x01\x72\x02\x5E\x04\x1D\x01\x25\x01\x13\x01\x13\xFF\xFF" + "[72500]\x11\x01\x13\x01\x13\x04\x1E\x01\x55\x04\x1B\x01\xA3\x01\xD2\x02\x6D\x01\x1D\x01\x01\x01\xC5\x01\x4A\x01\x03\xFF\xFF""@\x11\x01\x12\x01\x09\x01\xC5\x01\x4A\x01\xC8\x01\xB6\x01\xB6\x04\x18\x04\x19\x01\x06\x01\xD2\x01\xF7\x01\x94\x01\x6F\x01\x31\x01\x92\x01\x03\xFF\xFF" + "[79000]\x11\x01\x12\x01\x79\x02\x66\x02\x60\x01\x1A\x01\x1C\x01\x01\x01\xD3\x01\x3E\x01\x4E\x01\x55\x04\x1A\x04\x23\x01\x04\x01\x12\x04\x24\x01\x27\x01\x01\x04\x25\x04\x22\x01\x02\x01\xAE\x01\x04\x02\x6A\x01\x11\x01\x8B\x01\x55\x04\x1F\x02\x69\x04\x20\x02\xA0\x01\x03\xFF\xFF" + "[85500]\x11\x04\x21\x04\x0E\x01\x04\x01\x76\x02\x4B\x04\x0F\x01\x31\x01\x56\x02\x4C\x04\x10\x01\x90\x01\x12\x01\x79\x04\x0D\x01\x35\x01\x02\x01\x88\x01\x09\x02\x46\x01\x76\x01\x7B\x01\x11\x04\x0B\x01\x64\x01\x13\x01\x13\xFF\xFF" + "[92000]" + "[93500]\x11\x02\x47\x01\xD4\x01\xB8\x01\x02\x01\x05\x01\x12\x01\x19\x01\xDE\x04\x0C\x04\x15\x04\x16\x01\x01\x01\x44\x02\x56\x01\x03\xFF\xFF" + /* CANYON */ , + "[13500]\x11\x01\x05\x01\x7E\x01\x20\x04\x14\x01\x1F\x01\x06\x01\x4E\x04\x11\x02\x9A\x01\x2B\x04\x12\x01\xDB\x01\x01\x01\x0E\x01\x09\x02\x50\x01\x03\xFF\xFF" + "[16500]\x11\x01\x05\x01\x20\x01\xDC\x01\x07\xFF\xFF" + "[17500]\x11\x02\x54\x01\x89\x01\x03\xFF\xFF" + "[20000]\x11\x01\xAA\x01\x7B\x02\x53\x01\x21\x02\x7A\x04\x13\x01\x0B\x01\x30\x01\xA4\x04\x38\x01\x06\x01\x02\x04\x39\x01\x10\xFF\xFF" + "[22500]\x11\x01\x4E\x01\x7F\x01\xC8\x02\x1E\x01\x11\x01\x19\x04\x3A\x01\x06\x01\x01\x01\x75\x01\x02\x01\x5C\x01\xD8\x01\x03\xFF\xFF" + "[24000]\x11\x01\x20\x01\x06\x01\x02\x01\x05\x04\x37\x04\x34\x01\x01\x04\x35\x01\x61\x01\x69\x04\x36\x01\x67\x01\x81\x01\x1F\x01\x55\x01\x8B\x04\x3F\x01\x06\x01\x03\xFF\xFF" + "[27000]\x11\x01\x11\x01\x43\x02\x15\x01\x38\x01\x05\x02\x24\x01\x04\x01\x01\x02\x51\x01\xAC\x01\x80\x01\xA0\x01\x18\x01\x06\x01\x03\xFF\xFF" + "[30000]\x11\x01\x8F\x01\x04\x01\x0F\x01\x18\x02\x1A\x02\x1A\x01\x12\x01\x19\x01\x34\x02\x54\x04\x40\x04\x41\x01\x15\x01\x03\xFF\xFF" + "[32000]" + "[42500]\x11\x04\x3E\x01\x20\x01\x02\x02\x14\x01\x06\x04\x3B\x01\x07\xFF\xFF" + "[45000]\x11\x04\x3C\x01\x07\xFF\xFF" + "[48000]" + "[50500]\x11\x01\x05\x01\x0F\x01\x12\x04\x3D\x01\x9F\x04\x2A\x01\x07\xFF\xFF" + "[53000]" + "[62500]\x11\x01\x04\x01\x0F\x01\x3F\x01\x15\x01\x03\xFF\xFF" + "[65000]" + "[136000]\x11\x01\x0E\x01\x11\x01\xAB\x01\x42\x04\x2B\x01\x10\xFF\xFF" + "[138000]\x11\x01\xAB\x01\x42\x01\xDC\x01\x10\xFF\xFF" + "[138500]\x11\x01\x0E\x01\x6D\x01\x07\xFF\xFF" + "[140500]\x11\x01\x1A\x01\x1C\x01\x7B\x01\x11\x01\x09\x02\x92\x04\x2C\x01\x15\x01\x03\xFF\xFF" + "[142500]\x11\x01\x0E\x01\x97\x04\x29\x01\x67\x01\x50\x01\x1D\x01\x06\x01\x15\x01\x07\xFF\xFF" + "[145000]\x11\x02\x3F\x02\x41\x01\x02\x01\x05\x01\x23\x02\x59\x01\x22\x01\x69\x02\x57\x01\xA1\x01\x8C\x01\x03\x01\x04\x01\xA0\x01\x30\x01\xA4\x01\x16\x01\x06\x01\x02\x01\x05\x01\x18\x01\x49\x01\x10\xFF\xFF" + "[152000]" + "[158000]\x11\x01\xA5\x01\xA5\x01\x18\xFF\xFF""..." + "[160000]\x11\x01\x0C\x01\x16\x04\x26\x01\x07\xFF\xFF" + "[161500]\x11\x01\x70\x01\xE9\x01\x20\x01\x06\x01\x5C\x01\x25\x01\x10\xFF\xFF" + /* PRISON */ , + "[00001]\x11\x01\x05\x01\x0F\x01\x08\x01\x1C\x01\x12\x01\x42\x01\x85\x01\x07\xFF\xFF" + "[01500]\x11\x02\x08\x04\x27\x01\x05\x01\x8A\x04\x28\x01\x0C\x01\x01\x04\x31\x01\x61\x01\x02\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x01\x01\x46\x01\x1B\x01\x21\x01\x02\x01\x04\x01\x0F\x01\x0B\x01\x55\x02\x48\x01\x05\x01\x85\x01\x57\x04\x32\x04\x33\x01\x03\xFF\xFF" + "[06000]\x11\x02\x45\x01\x05\x01\xB1\x02\x50\x04\x30\x01\x4D\x01\x31\x01\x56\x01\x01\x04\x2D\x01\x4A\x01\x02\x01\x3A\x02\x04\x02\x45\x01\x05\x04\x2E\x01\xDD\x01\x04\x01\x0F\x01\x01\x01\x13\x01\x13\xFF\xFF" + "[11500]\x11\x01\x05\x01\x0F\x01\x08\x01\x1C\x01\x07\x01\x04\x01\x13\xFF\xFF" + "[12500]\x11\x01\x13\x01\x13\x01\x05\x02\x11\x02\x10\x01\x06\x01\x04\x01\x0F\x01\xF6\x01\x6E\x01\xD5\x04\x2F\x01\x47\x02\x79\x02\x67\x01\x04\x01\x0F\x01\x01\x01\x27\x04\x09\x01\x8A\x02\x0E\x01\x77\x01\x01\x01\x31\x02\x5D\x03\xE3\x03\xE4\x01\x02\xFF\xFF" + "[18500]\x11\x01\xBF\x03\xE5\x02\x4C\x03\xE2\x01\x04\x01\x0F\x01\x31\x01\x56\x01\x01\x03\xDF\x03\xE0\x03\xE1\x03\xEA\x01\x06\x01\x1E\x01\x65\x01\x5B\x01\x47\x01\x04\x01\x73\x01\x27\x01\x03\xFF\xFF" + "[23500]\x11\x01\x04\x01\x0F\x01\x31\x01\x56\x01\x01\x02\x8C\x01\xB3\x01\xFE\x01\x05\x03\xEB\x01\x04\x01\x0F\x01\x01\x01\x4F\x01\x96\x01\x6B\x01\x30\x02\x52\x02\x0B\x03\xEC\x01\x71\x01\x02\xFF\xFF" + "[27000]\x11\x01\x3A\x02\xA3\x01\x05\x01\x1A\x01\x3A\x03\xE9\x03\xE6\x02\x12\x01\x4D\x01\x0E\x03\xE7\x03\xE8\x01\x25\x01\x94\x01\x3E\x01\x14\x01\x1C\x01\x01\x01\x4F\x01\x96\x01\x6B\x01\x02\xFF\xFF""@\x11\x01\x8B\x01\x05\x01\x19\x01\x27\x01\x0E\x02\x6B\x02\x65\x01\x01\x02\x11\x02\x10\x01\xF0\x02\x5F\x03\xD5\x01\x07\xFF\xFF" + "[33500]\x11\x02\x6B\x02\x65\x01\x10\x01\x62\x01\x62\x01\x05\x01\x0F\x01\x31\x01\x56\x01\x15\x01\x07\xFF\xFF" + "[35500]\x11\x01\x05\x02\x5B\x01\x01\x02\x06\x02\x63\x01\x30\x03\xD6\x03\xD7\x03\xD4\x01\x57\x01\x37\x02\x64\x03\xD1\x01\x09\x03\xD2\x01\xF7\x01\x94\x01\x14\x03\xD3\x01\x10\xFF\xFF" + "[40500]\x11\x02\x21\x01\x3E\x01\x07\xFF\xFF" + "[41500]\x11\x01\x04\x01\x0F\x01\xBA\x02\x1C\x03\xDC\x01\x61\x01\x15\x01\x03\xFF\xFF" + "[44000]\x11\x01\x1E\x01\x65\x01\x5B\x01\x07\xFF\xFF" + "[45000]\x11\x01\x05\x01\x86\x01\x4C\x01\x6C\x01\x14\x01\x8A\x01\x4D\x01\x6E\x02\x29\x02\x26\x01\x05\x01\x19\x01\x27\x01\x01\x03\xDD\x01\xF0\x01\x02\xFF\xFF" + "[49500]\x11\x01\x86\x01\x7C\x02\x25\x01\x77\x01\x06\x01\x09\x01\x19\x03\xDE\x03\xDB\x01\xA3\x01\x94\x03\xD8\x01\x07\xFF\xFF" + "[51000]\x11\x01\x29\x01\x0F\x01\x11\x02\x09\x01\x5F\x01\x0C\x01\x18\x01\x01\x03\xD9\x01\x6F\x01\x07\x01\x11\x01\x09\x01\x19\x01\x98\x01\x01\x03\xDA\x03\xFF\x01\x07\xFF\xFF" + "[54000]\x11\x01\x52\x01\x0B\x01\x7B\x01\x11\x01\x09\x02\x2A\x02\x2F\x04\x00\x01\x01\x02\x09\x04\x01\x03\xFE\x01\x06\x01\x03\xFF\xFF" + "[56000]\x11\x01\x9D\x01\x6E\x01\x05\x01\x02\x01\x04\x01\x0F\x01\x86\x01\x38\x01\x05\x03\xFB\x03\xFC\x01\x6E\x03\xFD\x04\x06\x01\x14\x01\x54\x01\x02\xFF\xFF" + "[60000]\x11\x01\x05\x01\x01\x02\x3B\x01\xD5\x01\x8E\x01\xBC\x04\x07\x01\x8E\x01\xF9\x02\x26\xFF\xFF" + "[64000]\x11\x01\x3A\x02\x04\x01\x0E\x04\x08\x04\x05\x01\x01\x01\x1D\x02\x06\x01\x76\x01\x86\x04\x02\x01\x22\x01\x05\x01\x0E\x01\xFE\x04\x03\x04\x04\x01\x01\x02\x3B\x03\xF1\x02\x40\x03\xF2\x01\x5E\x01\x68\x02\x03\x01\x03\xFF\xFF" + "[70000]\x11\x01\x70\x01\xE9\x02\x33\x02\x1C\x01\x05\x01\x0E\x03\xF3\x01\x08\x01\x23\x01\x89\x03\xF0\x01\x01\x02\x0A\x02\x30\x01\x15\x01\x02\x01\x46\x01\x1B\x01\x21\x01\x07\xFF\xFF" + "[73000]\x11\x01\x05\x02\x5B\x01\x67\x01\x08\x01\x39\x01\x23\x03\xED\x02\x31\x01\x01\x01\x07\x01\x80\x01\x25\x01\x05\x01\x0F\x01\x0E\x01\x81\x03\xEE\x01\x01\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x1D\x01\xE7\x01\x07\xFF\xFF" + /* 22 */ , + "[04000]\x11\x01\x05\x01\xAA\x01\xA0\x01\x18\x01\x06\x01\x10\xFF\xFF" + "[05500]\x11\x01\x05\x01\x08\x01\x67\x01\x11\x01\x49\x01\x10\x01\x04\x01\x35\x01\x05\x01\xA0\x01\x18\x01\x11\x01\x8B\x01\x06\x01\x48\x01\x09\x01\x51\x03\xEF\x02\x17\x01\x33\x02\x78\x01\x15\x01\x10\xFF\xFF" + "[09500]\x11\x01\x3D\x01\x5E\x03\xF8\x01\xEA\x01\x06\x01\x09\x01\x77\x01\x08\x02\x25\x01\x01\x01\x68\x01\xFC\x01\x03\x01\x31\x02\x20\x01\x99\x01\xFA\x01\x01\x01\x77\x03\xF9\x02\x6A\x01\x11\x01\x0E\x01\xC9\x01\x01\x02\x27\x01\x0C\x01\x03\xFF\xFF" + "[13500]\x11\x03\xFA\x01\xEA\x02\x0B\x01\x98\x01\x01\x01\x3E\x02\x1F\x01\x86\x01\x48\x01\x09\x01\x51\x03\xF7\x01\x87\x01\x2D\x02\xAD\x03\xF4\x03\xF5\x03\xF6\x01\x01\x03\x5F\x02\xDF\x01\x02\xFF\xFF" + "[17500]\x11\x01\x3D\x02\x40\x02\x4B\x01\x5E\x01\x47\x02\xE0\x02\xDE\x01\x04\x01\x0F\x01\x02\xFF\xFF" + "[20500]\x11\x02\x36\x01\x9D\x01\xF7\x01\x94\x01\x57\x01\x98\x01\x01\x01\x9B\x02\x1F\x01\x03\xFF\xFF" + "[22500]\x11\x01\x4D\x02\xDD\x01\xC4\x01\x18\x02\xA8\x01\xC3\x01\x3D\x01\x5E\x01\x02\x01\x11\x01\x15\x01\x10\xFF\xFF" + "[24500]\x11\x01\xCD\x01\x36\x01\x17\x01\x53\x02\x2F\x01\xB2\x01\x02\x01\xED\x01\xEC\x01\xEF\x01\xEE\x01\x47\x01\x1E\x01\x65\x01\x5B\x01\x0E\x02\x38\x01\x19\x02\xD4\x02\xD3\x02\x08\x01\x73\x01\xAB\x01\x42\x01\x76\x01\x08\x02\xD2\x01\x03\xFF\xFF" + "[29500]\x11\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x01\x02\x32\x02\x91\x01\xB2\x02\xD6\x01\x06\x01\x09\x01\x19\x01\x73\x01\x17\x02\xDA\x02\xDB\x02\x42\x01\x1C\x01\x01\x02\x1F\x02\xD7\x01\x02\xFF\xFF" + "[33500]\x11\x01\x48\x01\x09\x01\x51\x01\xAE\x01\x29\x01\x0F\x02\xD8\x02\xE7\x01\x9D\x02\xF6\x01\x5F\x01\x01\x01\xC0\x01\xF6\x01\x73\x01\x45\x02\xF5\x01\x03\xFF\xFF" + "[37000]\x11\x01\x09\x02\x46\x01\x76\x01\x08\x01\x81\x01\x0E\x01\xC9\x01\x03\xFF\xFF" + "[39000]\x11\x01\x67\x01\x08\x01\x81\x02\x98\x01\x12\x01\xC9\x01\x03\xFF\xFF" + "[40000]\x11\x02\x3A\x01\x5E\x01\x0B\x02\x3E\x02\x3D\x02\xFC\x01\x36\x01\x33\x02\x23\x01\x03\xFF\xFF" + "[43000]\x11\x01\x52\x01\x0B\x02\x69\x02\xFD\x01\xC8\x02\x1E\x01\x50\x02\x05\x01\x06\x01\x03\xFF\xFF" + "[45000]\x11\x01\x5C\x01\x06\x01\xDB\x02\xFA\x02\xEB\x01\xBC\x01\x01\x01\x75\x01\x17\x01\x08\x02\x28\x02\x05\x01\x07\xFF\xFF" + "[47000]\x11\x01\x08\x01\x07\xFF\xFF" + "[50000]\x11\x02\x3E\xFF\xFF" + "[54000]\x11\x02\x3D\xFF\xFF""..." + "[55500]\x11\x02\xEA\xFF\xFF""... \x11\x01\xE4\xFF\xFF""... \x11\x02\xE8\xFF\xFF""..." + "[60000]\x11\x01\x09\xFF\xFF""..." + /* 23 */ , + "[00001]\x11\x01\x20\x01\x06\x01\x02\x01\x05\x01\x52\x01\x0B\x01\x1A\x02\x28\x01\x23\x01\x1F\x01\x06\x01\x04\x02\x0B\x02\xED\x01\x01\x02\xAE\x01\x95\x01\x4A\x01\x02\xFF\xFF" + "[02500]\x11\x01\x08\x01\x37\x01\x04\x01\x08\x01\x50\x02\x66\x01\x68\x01\x05\x01\x25\x01\x5C\x01\x25\x01\x38\x01\x04\x01\x69\x01\x0B\x01\xB9\x01\x30\x01\x02\xFF\xFF" + "[05000]\x11\x01\x04\x01\x59\x01\x01\x01\x75\x01\x05\x02\xF2\x01\x1F\x01\x06\x01\x49\x01\x10\xFF\xFF" + "[06000]\x11\x01\x04\x01\x53\x01\x38\x01\x05\x02\xF0\x01\x87\x01\x18\x02\xEE\x01\x22\x01\xB2\x01\x02\xFF\xFF" + "[09000]\x11\x02\xEF\x02\x20\x01\x06\x01\x03\xFF\xFF" + "[10000]\x11\x02\xBE\x01\x22\x01\x05\x01\x47\x01\x0E\x02\x11\x02\xB9\x01\x93\x01\xD1\x01\xCA\x01\xFF\x02\x01\x01\x02\xFF\xFF" + "[13000]\x11\x01\x12\x01\x42\x01\x35\x01\x53\x01\x01\x01\x75\x01\x02\x01\x04\x01\x17\x01\x38\x01\x7C\x02\x07\x01\x1F\x01\x05\x01\x01\x01\x13\x01\x13\xFF\xFF" + "[17000]\x11\x02\xD0\x01\x9A\x01\x02\x01\x05\x01\x0B\x01\x59\x01\x12\x02\x5C\x01\x8D\x02\xAB\x01\x49\x01\x10\xFF\xFF" + "[20000]\x11\x02\x21\x01\x75\x01\x02\x01\x04\x01\x53\x01\x38\x01\x7C\x02\x07\x01\x1F\x01\x05\x01\x01\x01\x13\x01\x13\xFF\xFF" + "[22000]\x11\x01\x9A\x01\x9A\x01\x02\x01\x08\x01\x20\x01\x95\x02\xC6\x01\x02\xFF\xFF" + "[24000]\x11\x01\x05\x01\x7E\x01\x7E\x01\x59\x01\xFF\x02\x01\x01\x02\x01\x0E\x02\x53\x01\x0C\x01\x01\x01\x7D\x01\x10\xFF\xFF" + "[26500]\x11\x01\x46\x01\x1B\x01\x21\x01\x34\x01\xD9\x02\xCA\x02\x47\x01\xD4\x01\xB8\xFF\xFF""·\x11\x02\xBA\x02\xB7\x01\x16\x02\x8E\x01\x06\x01\x03\xFF\xFF" + "[29500]\x11\x01\x29\x01\x27\x01\x7D\x01\x10\xFF\xFF" + "[30500]\x11\x02\x0C\x01\x07\x01\x05\x01\x2C\x01\x3C\x01\x08\x02\xC4\x01\xC3\x01\x02\x02\xBB\x01\x08\x01\x2B\x01\x29\x01\x01\x01\x07\xFF\xFF" + "[34000]\x11\x02\x6E\x01\x05\x01\x59\x01\x59\x01\x75\x01\xAA\x01\x08\x02\xC1\x01\x43\x02\x19\x01\x03\xFF\xFF" + "[37000]\x11\x01\x04\x02\xB8\x01\x42\x01\x39\x01\x91\x01\xA2\x01\x0E\x01\x7B\x01\x1F\x02\x0D\x01\xDE\x02\xCF\x01\x01\x02\x0A\x02\xBF\x01\x1D\x02\xBD\x02\xC7\x02\x16\x02\x0F\x02\x64\x01\x30\x02\xC3\x03\x3F\x01\xDC\x01\x07\xFF\xFF" + "[42000]\x11\x01\x05\x01\x23\x01\x16\x02\x4A\x01\x46\x01\x1B\x01\x21\x01\x34\x01\xD9\x01\x03\xFF\xFF" + "[46000]" + "[51000]\x11\x02\x49\x02\x49\x01\x05\x01\x02\x01\x04\x01\x12\x01\x17\x01\x16\x01\x03\xFF\xFF" + /* 24 */ , "" + /* 25 */ , + "[03500]\x11\x01\x12\x01\x30\x01\x89\x02\x30\x01\x22\x01\x1E\x01\x65\x01\x5B\x01\x02\xFF\xFF" + "[05000]\x11\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x02\x38\x01\x7A\x02\x16\x01\xBA\x01\x01\x01\xB0\x01\xFB\x01\x6F\x01\x14\x01\x09\x01\x03\xFF\xFF" + "[10000]\x11\x02\x36\x01\x9D\x01\x0B\x01\x12\x02\x62\x01\x1D\x01\xE7\x03\x3D\x03\x44\x03\x45\x03\x46\x01\x14\x02\x32\x01\x36\x01\x02\xFF\xFF" + "[13000]\x11\x01\x29\x03\x42\x02\x20\x01\x6E\x01\x55\x03\x33\x01\x4A\x03\x34\x02\xA6\x01\x22\x03\x2F\x03\x30\x01\x29\x03\x31\x01\x01\x03\x38\x03\x39\x01\x03\xFF\xFF" + "[19000]\x11\x01\x29\x02\x31\x01\x92\x01\x97\x01\x25\x01\x84\x03\x35\x01\x02\x01\x29\x01\x01\x02\x59\x03\x36\x03\x54\x02\x42\x01\x27\x03\x55\x03\x5C\x01\x03\xFF\xFF" + "[25500]\x11\x01\x29\x02\x29\x03\x5D\x03\x5E\x03\x5B\x01\x2D\x01\x0B\x01\xCB\x01\x2B\x01\x62\x02\x67\x01\x22\x01\x04\x01\x0F\x01\xCC\x01\xCC\x01\x1E\x01\x65\x01\x5B\x01\x03\xFF\xFF" + /* 26 */ , "\x11\x01\xB5\x02\x33\x02\x7C\x03\x4B\x02\x99\x03\x4C\x01\x02\x03\x47\x01\x8F\x01\x04\x01\xD0\x01\x05\x03\x51\x01\x82\x01\x09\x01\x0C\x01\x03\xFF\xFF" + /* 27 */ , "\x11\x01\xAE\x01\x4D\x01\x26\x01\x28\x01\x0D\x01\x02\x01\x18\x02\x58\x01\xA3\x01\x04\x01\x1F\x01\xD6\x01\xF1\x01\xDA\x01\x03\xFF\xFF" + /* 28 */ , "\x11\x01\x20\x01\x01\x01\x02\x01\x33\x02\x23\x01\x85\x01\x79\x03\x2E\x03\x0D\x01\x15\x01\x03\x01\x0A\x01\x0C\x01\x24\x01\x5A\x01\x0D\x01\x03\xFF\xFF" + /* 29 */ , "\x11\x01\x48\x01\x0A\x01\x09\x01\x51\x01\x24\x01\x5A\x01\x0D\x01\x02\x01\xBF\x01\x5D\x01\x43\x01\x0A\x01\x0C\x01\x26\x01\x28\x01\x0D\x01\x02\x01\x04\x01\x17\x01\x39\x02\x0F\x01\x0E\x01\x19\x01\x26\x01\x28\x01\x24\x01\x5A\x01\x03\xFF\xFF" + /* 30 */ , "\x11\x02\x7B\x02\x7D\x01\x02\x01\xDF\x01\x84\x01\x0B\x01\x1D\x01\xDA\x02\x2A\x01\x23\x01\x09\x02\x4D\x03\x0C\x01\x03\x01\x04\x01\x25\x01\x79\x02\x51\x01\xAC\x01\x35\x01\x69\x01\x1F\x03\x13\x01\xC6\x03\x15\x01\x02\x01\x88\x03\x11\x01\xDB\x03\x12\x01\x80\x01\x5C\x01\x18\x01\x03\xFF\xFF" + /* 31 */ , "\x11\x01\x6A\x01\x1F\x01\xDF\x01\x84\x02\x5A\x01\x02\x01\x0B\x01\x0A\x01\x0C\x01\x63\x01\x3D\x01\x01\x01\x5D\x01\x43\x01\x0A\x01\x0C\x01\x2C\x01\x3C\x01\x0D\x01\x02\x01\x04\x01\x17\x01\x39\x01\x74\x01\x1F\x01\xDF\x01\x84\x01\x2B\x01\x03\xFF\xFF" + /* 32 */ , "\x11\x01\x12\x01\x30\x01\x73\x01\x18\x01\x11\x03\x03\x01\xDA\x01\x02\x01\x88\x01\x04\x01\x38\x01\x7C\x02\xFE\x01\x77\x01\x06\x02\xFF\x01\x92\x03\x00\x01\x03\xFF\xFF""@\x11\x02\xB1\x01\xB5\x01\x49\x01\x10\x01\x04\x01\x0F\x01\x18\x02\x68\x02\x68\x01\x2F\x01\x15\x01\x03\xFF\xFF" + /* 33 */ , "\x11\x01\x04\x01\x08\x03\x08\x01\x1C\x01\x6A\x01\x02\x01\x80\x01\x1C\x01\xA5\x01\x3F\x01\x02\x03\x09\x01\xD2\x01\x11\x01\x04\x03\x04\x01\x53\x01\x34\x01\xBC\x01\x01\x01\x43\x02\x15\x01\x03\xFF\xFF""@\x11\x01\x0A\x01\x2E\x01\x61\x01\x3F\x01\x0D\x01\x02\x01\xD0\x01\x04\x01\x3F\x01\x1F\x01\x9F\x01\xF4\x01\x0E\x01\x8C\x01\x03\xFF\xFF" + /* 34 */ , "\x11\x01\x0A\x01\x22\x01\x61\x01\x3F\x01\x0D\x01\x01\x01\x43\x02\x15\x01\x02\x01\x04\x01\x08\x01\x39\x01\x90\x01\x0C\x01\x16\x01\x01\x01\x02\x01\x08\x03\x06\x01\x05\x01\x16\x01\xFD\x01\xFD\x01\x15\x01\x03\xFF\xFF" + /* 35 */ , "\x11\x01\x4E\x01\x7F\x01\x05\x01\x35\x03\x2B\x02\x96\x01\x82\x01\xA9\x02\x61\x02\x2C\x01\x02\x01\x0A\x01\x2E\x01\x82\x01\xA9\x01\x0D\x01\x02\x01\x48\x01\x5D\x01\x43\x01\x0A\x01\x2E\x01\x05\x01\x35\x01\x82\x01\xA9\x01\x01\x01\x26\x01\x28\x01\x17\x01\x1A\x01\x3A\x01\x06\x01\x03\xFF\xFF" + /* 36 */ , "\x11\x01\x4E\x01\x7F\x02\x2B\x02\x2D\x01\x50\x01\xB6\x01\x24\x01\x08\x01\x37\x01\x16\xFF\xFF"", \x11\x01\x04\x01\x1A\x01\x3A\x01\xE0\x01\x2E\x01\x6D\x01\xE2\x01\x03\xFF\xFF""@\x11\x02\x0F\x01\x9F\x01\xF4\x02\x0D\x01\xA5\x01\x3F\x01\x02\x01\x04\x01\x90\x01\x08\x01\x0C\x01\x16\x01\x01\x01\x03\x01\x0A\x01\x2E\x01\x24\x01\x5A\x01\x0D\x01\x02\xFF\xFF""@\x11\x01\x48\x02\x34\x01\xE8\x01\x0A\x01\x2E\x01\x63\x01\x26\x01\x28\x01\x0D\xFF\xFF"", \x11\x01\xC0\x01\x36\x01\x0A\x01\x2E\x01\x2C\x01\x3C\x01\x0D\x01\x03\xFF\xFF" + /* 37 */ , "\x11\x01\x0A\x01\x63\x01\x26\x01\x28\x01\x0D\x01\x02\x01\x04\x01\x17\x01\x39\x01\x74\x01\x2B\x01\x16\x01\x03\xFF\xFF" + /* 38 */ , "\x11\x01\x4E\x01\x7F\x01\xB4\x01\x6A\x01\x09\x01\x0C\x01\x02\x01\x04\x01\x17\x01\x1C\x01\x24\x01\x37\x01\x16\x01\x02\x02\x08\x01\x73\x01\x08\x01\x11\x02\x4A\x02\x94\x01\x03\xFF\xFF" + /* 39 */ , "\x11\x01\x3F\x01\x1F\x01\x9F\x01\xF4\x02\x5A\x01\x02\x01\x04\x01\x39\x03\x21\x01\x0C\x01\x18\x01\x03\x01\x69\x01\x33\x01\x61\x01\x3F\x01\x0D\x01\x02\x01\x0B\x01\x0A\x01\x09\x01\x0C\x01\x36\x01\x78\x02\x70\x01\x04\x01\xB4\x01\x6A\x01\x01\x02\x2B\x02\x2D\x01\x03\xFF\xFF""@\x11\x01\x0A\x01\x0C\x01\x63\x01\x3D\x01\x02\x01\x48\x02\x18\x01\xC3\x01\x2D\x01\x5D\x01\x43\x01\x0A\x01\x0C\x01\x24\x01\x5A\x01\x02\x01\x04\x01\x17\x01\x1C\x01\x24\x01\x37\x01\x16\x01\x06\x01\x03\xFF\xFF""@\x11\x01\x04\x01\x31\x01\x56\x01\x39\x01\x0B\x01\xC0\x01\x36\x01\x09\x01\xE8\x01\x87\x01\x24\x01\x01\x01\x03\xFF\xFF" + /* 40 */ , "\x11\x01\x20\x01\x02\x01\x12\x01\x09\x01\x24\x01\x1B\x02\x5E\x01\xB6\x01\x03\xFF\xFF""@\x11\x02\x6E\x01\x7E\x01\x7E\x01\x09\x01\xC9\x01\xB4\x01\x6A\x01\x24\x01\x02\xFF\xFF""@\x11\x01\x88\x01\x12\x01\x51\x01\x53\x01\x0B\x03\x1E\x01\x71\x01\x54\x01\x0A\x01\x0C\x01\x2C\x01\x3C\x01\x0D\x01\xAE\x01\x04\x01\xE0\x01\x2E\x01\x6D\x01\xE2\x01\x03\xFF\xFF" + /* 41 */ , "\x11\x01\x20\x01\xB1\x01\x06\x01\x03\xFF\xFF" + /* 42 */ , "\x11\x01\xFD\x01\x22\x01\x74\x01\x3D\x01\x16\x01\x62\x01\x62\x01\x03\x01\x09\x01\x87\x01\x0A\x01\x63\x01\x3D\x01\x47\x01\x2C\x01\x3C\x01\x0D\x01\x03\xFF\xFF" + /* 43 */ , "\x11\x01\x71\x03\x1D\x01\x50\x01\x34\x01\x02\x01\x04\x01\x74\x01\x08\x01\x3D\x01\x16\x01\x03\xFF\xFF""@\x11\x01\x88\x01\x0A\x01\x0C\x01\xAF\x01\x26\x01\x28\x01\x0D\x01\x04\x01\x1A\x01\x3A\x03\x1C\x03\x20\x01\x1F\x01\x25\x01\x71\x02\x19\x01\x01\x01\x2D\x01\x26\x01\x02\xFF\xFF""@\x11\x01\x17\x01\x1A\x01\x3A\x02\x1C\x01\x22\x01\x0A\x01\x63\x01\x3D\x01\x8F\x01\x04\x01\x74\x01\x2B\x01\x16\x01\x06\x01\x03\xFF\xFF" + /* 44 */ , "\x11\x02\x76\x01\xB1\x01\x06\x01\x07\x01\x4E\x01\x7F\x01\xCE\x02\xA7\x01\x50\x01\xCE\x01\x04\x01\xAA\x01\x08\x01\x35\x03\x1F\x01\x22\x01\x31\x01\x56\x01\x02\x01\x04\x01\x1A\x01\x3A\x01\x34\x01\xBC\x01\x23\x01\x0C\x01\x16\x01\x03\xFF\xFF" + /* 45 */ , "\x11\x01\x0A\x01\x0C\x01\x36\x01\x78\x01\x02\x01\x04\x01\x39\x01\x36\x01\x78\x01\x09\x01\x1D\x02\xA4\x01\x03\xFF\xFF""@\x11\x02\x34\x01\xE8\x01\x0A\x01\x2E\x01\x2C\x01\x3C\x01\x0D\x01\x02\x01\x04\x01\x17\x01\x1C\x01\xE0\x01\x2E\x01\x6D\x01\xE2\x01\x03\xFF\xFF" + /* 46 */ , "\x11\x02\x57\x01\x2F\x01\x15\x01\x03\xFF\xFF" + /* 47 */ , "\x11\x01\x09\x01\x87\x01\x16\x01\x40\x01\x19\x03\x18\x01\x15\x01\x03\xFF\xFF" + /* 48 */ , "\x11\x01\x0B\x01\x45\x01\x0C\x01\x02\x01\x0A\x01\x24\x01\x5A\x01\x0D\x01\x47\x01\x26\x01\x28\x01\x0D\x01\x1C\x02\x58\x01\xA3\x01\x04\x03\x17\x01\x2C\x01\x03\xFF\xFF" + /* 49 */ , "\x11\x02\xA9\x01\x07\x01\x71\x03\x16\x01\x07\xFF\xFF""@\x11\x01\x4D\x01\x26\x01\x28\x01\x0D\x01\x1A\x01\x3A\x01\x8F\x01\x04\x01\x0B\x01\x45\x01\xA4\x01\x2B\x01\x40\x01\x2C\x01\x03\xFF\xFF""@\x11\x01\x0A\x01\x0C\x01\x24\x01\x5A\x01\x0D\x01\x02\x01\x04\x01\x0F\x01\x17\x01\x1C\x01\x48\x02\x9B\x01\x09\x01\x51\x01\x45\x01\x03\xFF\xFF""@\x11\x03\x1B\x01\x6F\x01\x40\x01\x1F\x03\x1A\x01\x6D\x01\x02\x01\x0A\x01\x2C\x01\x3C\x01\x0D\x01\x74\x01\x2B\x01\x16\x01\x03\xFF\xFF" + /* 50 */ , "\x11\x01\x20\x01\x01\x01\x03\x01\x04\x01\xC0\x01\x20\x01\x38\x03\x19\x03\x2A\x02\x5F\x01\xC3\x03\x29\x01\x90\x01\x03\xFF\xFF" + /* 51 */ , "\x11\x03\x28\x01\x84\x01\x07\xFF\xFF" + /* 52 */ , "\x11\x01\x12\x01\xD3\x01\x8C\x01\x08\x02\x75\x02\x48\x01\x05\x01\x19\x01\x27\x01\x03\xFF\xFF" + /* 53 */ , "\x11\x01\x2B\x01\x51\x01\x05\x01\x38\x01\x04\x02\x06\x02\x63\x03\x2D\x01\x23\x01\x1A\x01\xDE\x01\x03\xFF\xFF""@\x11\x01\x7C\x01\x09\x01\xBA\x01\x0B\x02\x70\x01\x04\x01\x57\x01\x79\x02\x10\x03\x2C\x01\x95\x02\x8B\x01\x03\xFF\xFF""@\x11\x02\x13\x01\x4E\x01\x09\x01\x41\x01\x38\x01\x05\x02\xB6\x01\x3D\x01\x2D\x03\x24\x01\x07\xFF\xFF" + /* 54 */ , "\x11\x01\x35\x02\xB6\x01\x90\x01\x04\x01\x47\x01\x04\x01\x01\x01\x34\x02\x4D\x02\x56\x01\x1A\x01\x5C\x01\x0E\x01\x42\x02\x8A\x02\x22\x01\x02\x01\x64\x01\x21\x01\x03\xFF\xFF" + /* 55 */ , "\x11\x01\x52\x01\x0B\x01\x18\x03\x23\x01\x18\x03\x22\x03\x27\x03\x26\x03\x25\x01\x25\x01\xA1\x01\x8C\x02\x05\x01\x06\x01\x15\x01\x10\xFF\xFF""@\x11\x01\x08\x01\x37\x01\x02\x01\x80\x01\x23\x01\x62\x01\x05\x02\x24\x01\x08\x02\x24\x01\x23\x01\x37\x01\x04\x01\x06\x01\x07\xFF\xFF" + /* 56 */ , "\x11\x01\x05\x01\x0B\x01\x28\x03\x05\x01\x33\x01\xF2\x01\x7D\x01\x10\xFF\xFF""@\x11\x01\x05\x02\x1B\x01\x01\x01\x0B\x01\x28\x01\x04\x01\x33\x01\xF2\x01\x49\x01\x10\xFF\xFF""@\x11\x02\x61\x02\x2C\x01\x5C\x01\x27\x02\xA9\x01\x02\x01\x0E\x01\x05\x01\x1A\x01\x1C\x02\x1B\x01\x0B\x01\x28\x01\x04\x01\x33\x01\xF2\x01\x06\x01\x15\x01\x07\xFF\xFF" +// TR1 levels + , "\x11\x01\x64\x01\x21\x01\x14\x01\x44\xFF\xFF" + , "\x11\x02\x7F\x01\xB7\xFF\xFF" + , "\x11\x02\x13\x01\xB8\x01\x9C\x03\x07\x02\x82\x01\xAD\xFF\xFF" + , "\x11\x01\xE6\x01\xCD\x01\x01\x02\xAC\x02\x72\xFF\xFF" + , "\x11\x01\xED\x01\xEC\x01\xEF\x01\xEE\x01\x8D\x01\xBD\xFF\xFF" + , "\x11\x01\x6C\x01\x26\x02\x35\x02\x37\x01\xEB\xFF\xFF" + , "\x11\x01\x1D\x03\x01\x01\xD7\x01\xF3\xFF\xFF" + , "\x11\x03\x10\x02\x0E\x01\x2A\x03\x14\x02\x77\xFF\xFF" + , "\x11\x01\x45\x03\x0B\xFF\xFF" + , "\x11\x01\x1E\x01\x65\x01\x5B\x01\x8D\x01\xBD\xFF\xFF" + , "\x11\x02\x0C\x02\x93\x01\xAD\xFF\xFF" + , "\x11\x02\x0C\x02\x93\x01\x26\x03\x0A\x03\x0F\xFF\xFF" + , "\x11\x01\x93\x01\xD1\x01\xCA\x01\x6C\x02\x90\xFF\xFF" + , "\x11\x01\x46\x01\x1B\x01\x21\x01\x01\x02\x97\x03\x0E\xFF\xFF" + , "\x11\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\xFF\xFF" + , "\x11\x01\x1D\x01\x4F\x01\x96\x01\x6B\xFF\xFF" + , "\x11\x02\x17\x03\x4F\x01\xD4\x02\x04\xFF\xFF" + , "\x11\x03\x4E\x01\x14\x01\x4C\x01\xA8\xFF\xFF" + , "\x11\x01\x3B\x01\x1B\x01\x4B\x01\x1E\x01\x2A\x01\x53\x02\x07\xFF\xFF" + , "\x11\x02\x3A\x01\x5E\x01\x8A\xFF\xFF" +// TR2 levels + , "\x11\x01\x64\x01\x21\x01\x14\x01\x44\xFF\xFF" + , "\x11\x02\x0A\x01\xAD\xFF\xFF" + , "\x11\x01\xC5\x03\x4D\x01\x2A\xFF\xFF" + , "\x11\x02\x82\x03\x52\x02\x12\x01\x01\x01\xC6\x01\x92\x02\x0D\xFF\xFF" + , "\x11\x03\x50\x03\x49\x01\xE1\xFF\xFF" + , "\x11\x02\x1D\x01\x2B\x03\x48\x01\x6B\xFF\xFF" + , "\x11\x02\x9B\x01\x45\x01\x83\x02\x90\xFF\xFF" + , "\x11\x01\x45\x01\x0C\xFF\xFF""40\x11\x03\x4A\x03\x5A\xFF\xFF" + , "\x11\x03\x59\x02\x12\x01\x3B\x03\x53\x01\x01\x03\x58\x03\x57\xFF\xFF" + , "\x11\x01\x2E\x03\x56\x01\x83\xFF\xFF" + , "\x11\x02\xA5\x03\x37\xFF\xFF" + , "\x11\x01\xAC\x01\xC6\x03\x32\x02\xAF\xFF\xFF" + , "\x11\x03\x43\x02\x1E\x01\xE1\xFF\xFF" + , "\x11\x01\x6B\x01\x30\x03\x41\x01\x01\x02\xAF\x01\xBD\xFF\xFF" + , "\x11\x02\x9F\x02\x77\xFF\xFF" + , "\x11\x01\xAC\x01\x89\x01\xA8\x02\x9C\xFF\xFF" + , "\x11\x03\x3C\x03\x3B\xFF\xFF" + , "\x11\x03\x40\x01\x14\x03\x3E\x01\xB7\xFF\xFF" + , "\x11\x01\x44\x01\x02\x02\xC2\x02\xCD\x01\x01\x01\x44\xFF\xFF" +// TR3 levels + , "\x11\x01\x64\x01\x21\x01\x14\x01\x44\xFF\xFF" + , "\x11\x02\xCB\x02\xC9\x01\x2D\x01\xD0\xFF\xFF" + , "\x11\x01\x4C\x01\xA8\x02\x21\x02\xBC\xFF\xFF" + , "\x11\x02\xC5\x02\x71\xFF\xFF" + , "\x11\x01\x9C\x01\x30\x01\x3B\x02\x7F\x01\xB7\xFF\xFF" + , "\x11\x02\xCE\x02\x1D\x02\xC8\x02\xCC\xFF\xFF" + , "\x11\x01\xE5\x02\x87\x01\x2D\x01\xA1\xFF\xFF" + , "\x11\x01\xBE\x01\x76\x02\xC0\x02\xF1\x02\x72\xFF\xFF" + , "\x11\x02\xE9\x01\x46\x01\xA8\x02\x9C\xFF\xFF" + , "\x11\x02\xEC\x02\xF9\x01\xB3\x02\x71\x02\xFB\xFF\xFF" + , "\x11\x02\xA2\x01\xB8\x01\x68\x01\x2D\x02\xF8\x02\xF4\xFF\xFF" + , "\x11\x02\xF3\x02\xF7\x01\x14\x02\xD9\xFF\xFF" + , "\x11\x02\xD1\x01\x83\xFF\xFF" + , "\x11\x02\xD5\x02\x95\x02\x0E\x02\xE3\x02\xE2\xFF\xFF" + , "\x11\x01\xCE\x02\xA7\x02\x87\x02\x55\x01\x2D\x01\x83\xFF\xFF" + , "51\x11\x01\x83\xFF\xFF" + , "\x11\x02\x80\x01\xB1\x02\xE6\xFF\xFF" + , "RX\x11\x02\x88\x01\xD7\x02\x97\x01\xA6\x01\xF3\xFF\xFF" + , "\x11\x01\xE6\x01\xCD\x01\x01\x01\xCB\x02\xE5\x01\xAD\xFF\xFF" + , "\x11\x02\xE1\x01\xA6\x02\x6D\x01\xB7\xFF\xFF" + , "\x11\x02\xDC\x01\x6C\x01\xEB\xFF\xFF" +}; + +#endif diff --git a/src/lang/convert.bat b/src/lang/convert.bat new file mode 100644 index 00000000..28d11900 --- /dev/null +++ b/src/lang/convert.bat @@ -0,0 +1,5 @@ +@echo off +..\shaders\bin2c.exe glyph_ru.png glyph_ru.h GLYPH_RU +..\shaders\bin2c.exe glyph_ja.bmp glyph_ja.h GLYPH_JA +..\shaders\bin2c.exe glyph_gr.bmp glyph_gr.h GLYPH_GR +..\shaders\bin2c.exe glyph_cn.bmp glyph_cn.h GLYPH_CN diff --git a/src/lang/cz.h b/src/lang/cz.h new file mode 100644 index 00000000..a7a31bc9 --- /dev/null +++ b/src/lang/cz.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_CZ +#define H_LANG_CZ + +// Thanks: bax-cz, Hansy995 + +const char *STR_CZ[] = { "" +// help + , "Nahr)av)an)i..." + , "Stiskn{ete H pro n)apov{edu" + , helpText + , "%s@@@" + "ZABITO %d@@" + "SEBR)ANO P{REDM{ET^U %d@@" + "NALEZENO SKR)Y{S)I %d z %d@@" + "STR)AVENO {CASU %s" + , "Ukl)ad)an)i hry..." + , "Hra ulo{zena!" + , "CHYBA P{RI UKL)AD)AN)I!" + , "ANO" + , "NE" + , "Vypnuto" + , "Zapnuto" + , "Vypnout" + , "Vedle sebe" + , "Anaglyf" + , "Rozd{elen)a Obrazovka" + , "VR" + , "N)izk)e" + , "St{redn)i" + , "Vysok)e" + , STR_LANGUAGES + , "Pou{z)it" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Hr)a{c Nep{ripraven" + , "Hr)a{c 1" + , "Hr)a{c 2" + , "Stiskn{ete Kl)avesu" + , "%s - Vybrat" + , "%s - Zp{et" +// inventory pages + , "NASTAVEN)I" + , "INVENT)A{R" + , "P{REDM{ETY" +// save game page + , "Ulo{zit Hru?" + , "Aktu)aln)i Pozice" +// inventory option + , "Hra" + , "Mapa" + , "Kompas" + , "Statistiky" + , "La{rin Domov" + , ")Urove{n Detail^u" + , "Zvuk" + , "Ovl)ad)an)i" + , "Gama Korekce" +// passport menu + , "Nahr)at Hru" + , "Nov)a Hra" + , "Restartovat )Urove{n" + , "Zp{et na )Uvod" + , "Ukon{cit Hru" + , "Vybrat )Urove{n" +// detail options + , "Nastaven)i Detail^u" + , "Filtrov)an)i" + , "Osv{etlen)i" + , "St)iny" + , "Voda" + , "VSync" + , "Stereo" + , "Jednoduch)e objekty" + , "Rozli{sen)i" + , STR_SCALE +// sound options + , "Nastaven)i Zvuku" + , "Dozvuk" + , "Titulky" + , "Jazyk" +// controls options + , "Nastaven)i Ovl)ad)an)i" + , "Kl)avesnice" + , "Gamepad" + , "Vibrace" + , "Auto-zm{ena c)ile" + , "Multi-m)i{ren)i" + // controls + , "Vlevo", "Vpravo", "Vp{red", "Vzad", "Skok", "Ch^uze", "Akce", "Tasit zbra{n", "Rozhl)ednout", "D{rep", "Sprint", "Kotoul", "Invent)a{r", "Start" + , STR_KEYS +// inventory items + , "Nezn)am)y" + , "V)ybu{snina" + , "Pistole" + , "Brokovnice" + , "Magnum" + , "Uzi" + , "Z)asobn)iky Pistole" + , "N)aboje Brokovnice" + , "Z)asobn)iky Magnum" + , "Z)asobn)iky Uzi" + , "Mal)a L)ek)arn)i{cka" + , "Velk)a L)ek)arn)i{cka" + , "Olov{en)a Cihla" + , "Scion" +// keys + , "Kl)i{c" + , "St{r)ibrn)y Kl)i{c" + , "Rezav)y Kl)i{c" + , "Zlat)y Kl)i{c" + , "Saf)irov)y Kl)i{c" + , "Neptunov)y Kl)i{c" + , "Atlasov)y Kl)i{c" + , "Damokl^uv Kl)i{c" + , "Thor^uv Kl)i{c" + , "Zdoben)y Kl)i{c" +// puzzles + , "H)adanka" + , "Zlat)a Modla" + , "Zlat)a Cihla" + , "Ozuben)e Kolo" + , "Pojistka" + , "Anch" + , "Horovo oko" + , "Anupova Pe{ce{t" + , "Skarab" + , "Kl)i{c Pyramidy" +// TR1 subtitles + /* CAFE */ , + "[43500]Co mus)i {clovek ud{elat,@aby se od tebe do{ckal takov)e pozornosti?" + "[47500]T{e{zko {r)ict,@ale zat)im si vede{s docela dob{re." + "[50000]Skv{el)e. I kdy{z, ve skute{cnosti@nejsem ten, kdo t{e chce." + "[54500]Ne?" + "[55000]Ne. Sh)an)i se po tob{e sle{cna Jacqueline Natla,@z firmy Natla Technologies." + "[59000]V)i{s, ta co tvo{r)i v{secky@ty kr)asn)y slun)i{ckov)y v{eci?" + "[64500]Sklapni, Larsone." + "[66000]Madam." + "[68000]Jen se nad t)im pokochejte, Laro." + "[70500]T{ech pen{ez, co by se dalo vyd{elat." + "[73500]Je mi l)ito. Ned{el)am to pro pen)ize." + "[76000]Pak to tedy berte jako v)ylet." + "[78000]Peru. Rozlehl)a poho{r)i.@Strm)e st{eny hol)eho ledu. Skaln)i )utesy. Zu{riv)y v)itr." + "[87500]A pak je tu ta jedna drobnost:@prastar)y artefakt s tajemn)ymi schopnostmi" + "[92500]hluboko poh{rben)y v dosud nenalezen)e hrobce Qualopeca." + "[96000]To je zase m^uj z)ajem." + "[98000]Mohla byste let{et u{z z)itra.@M)ate na z)it{rek n{ejak)e pl)any?" + /* LIFT */ , + "[49000]Ted', kdy{z jsem se p{rem)istil k Monumentu sv. Franti{ska, za{calo m{e tr)iznit nov)e poku{sen)i." + "[53500]Mezi m)ymi bratry se {r)ik)a, {ze je pod t)imto na{s)im kl)a{sterem poh{rbeno t{elo Tihocana," + "[60000]jednoho ze t{r)i legend)arn)ich vl)adc^u ztracen)eho kontinentu Atlantidy." + "[64500]A tak)e, {ze je poh{rben se svou {c)ast)i Atlantsk)eho Scionu." + "[68000]Pendantem, kter)y byl rozd{elen a sd)ilen mezi t{remi zm)in{en)ymi vl)adci," + "[72500]a kter)y dr{z)i ohromnou moc. Moc v{et{s)i, ne{z m)a s)am stvo{ritel." + "[79000]Moje prsty se pot)i p{ri pomy{slen)i na mo{znosti, kter)e le{z)i tak bl)izko m)emu smrteln)emu j)a." + "[85500]Ka{zdou noc se sna{z)im zbavit t{echto fantazi)i, ale je to vskutku zkou{ska." + "[92000]" + "[93500]Pierre. Tss. Ty bordel)a{ri." + /* CANYON */ , + "[13500]Pr)av{e ti do{slo {st{est)i." + "[16500]Zdrav)i{cko." + "[17500]Dobr)e odpoledne." + "[20000]Nechala jste Larsona v z)av{esu, co?" + "[22500]Jestli se to tak d)a {r)ict." + "[24000]Va{se mal)a pr)azdninov)a vzpoura pr)av{e skon{cila." + "[27000]Je {cas vr)atit to, co jste mi ukradla." + "[30000]Pod)iv)ame se do ob{edov)e krabi{cky." + "[32000]" + "[42500]No tak? Zabte ji!" + "[45000]Hej!" + "[48000]" + "[50500]Vy blbci!" + "[53000]" + "[62500]Jedeme." + "[65000]" + "[136000]Co to sakra bylo?" + "[138000]Co?" + "[138500]T)amhle." + "[140500]Nejsp)i{s jenom ryba." + "[142500]To by byla po{r)adn)a ryba, chlap{ce." + "[145000]Chlape, mus)i{s se hodit do klidu. Jdu zp)atky dovnit{r. Jde{s?" + "[152000]" + "[158000]Hezky pomalu..." + "[160000]U{z jde." + "[161500]U{z jste p{ripraveni?" + /* PRISON */ , + "[00001]Tohle nem^u{zete!" + "[01500]Odsuzujme t{e za tv)e zlo{ciny, Natlo z Atlantidy." + "[06000]Za o{cividn)e zneu{zit)i tv)e moci a za okr)ad)an)i na{s)i..." + "[11500]Nem^u{zete! J)a..." + "[12500]Za poru{sen)i svobodn)e )Umluvy, kter)a na{sim lidem vl)adne," + "[18500]a za napaden)i Tihocana a m{e na{s)i vlastn)i amr)adou." + "[23500]Na{si v)ale{cn)ici se odebrali z na{s)i pyramidy," + "[27000]abys potom mohla zneu{z)it jej)i moci tvo{ren)i - pro sv)e vlastn)i, bezduch)e ni{cen)i." + "[33500]Bezduch)e!? Pod)ivejte se na sebe!" + "[35500]Ani jeden z v)as nem)ate v hlav{e ani kapku vynal)ezavosti." + "[40500]Mrha{ci!" + "[41500]Prost{e to ud{elejme." + "[44000]Tihocane!" + "[45000]Vyu{zila jsi posv)atn)e m)isto pro sv)e vlastn)i pot{e{sen)i -" + "[49500]jako n{ejakou tov)arnu na monstra." + "[51000]Jsou to p{re{ziv{s)i. Nov)a generace." + "[54000]Ted' je to vra{zd)ic)i tlupa." + "[56000]A tebe. Tebe zamkneme v zapomn{en)i." + "[60000]Zmrzlou krv)i zatvrd)ime tv)e {z)ily, srdce, chodidla" + "[64000]a ten tv^uj chorobn)y mozek." + "[70000]P{riv)itej sv^uj v{e{cn)y neklid, Natlo." + "[73000]V)am se tak)e nedostane klidu! Ani va{semu zatracen)emu Atlantsk)emu kontinentu!" + /* 22 */ , + "[04000]Zase zp{et?" + "[05500]A vy tak)e. H)ad)am, {ze na slavnostn)i znovuotev{ren)i." + "[09500]Evoluce je v {r)iji - P{r)irodn)i v)yb{er je na tom h^u{r, ne{z kdy d{r)iv..." + "[13500]V)yvoz {cerstv)eho masa znovu vyvol)a teritori)aln)i agresi" + "[17500] - posiln)i a posune n)as..." + "[20500]Dokonce stvo{r)i nov)e rasy." + "[22500]Tak trochu evoluce na steroidech." + "[24500]Nakopnut)i do spr)avn)eho sm{eru... ten nicotn)y Qualopec s Tihocanem nem{eli tu{sen)i" + "[29500] - ta pohroma, kterou je Atlantida, ude{rila rasu stagnuj)ic)ich slaboch^u..." + "[33500]Srazila je zp{et k samotn)ym z)aklad^um p{re{zit)i..." + "[37000]Tak by se to nem{elo st)at." + "[39000]To ani takhle." + "[40000]L)ihnut)i za{cne za 15 sekund." + "[43000]U{z je moc pozd{e na potrat!" + "[45000]Bez srdce t)eto operace to nep^ujde!" + "[47000]Neee!" + "[50000]DESET" + "[54000]P{eT..." + "[55500]4...3...2..." + "[60000]JEDNA..." + /* 23 */ , + "[00001]Tak{ze, te{d m)a{s mou plnou pozornost" + "[02500]- A{ckoli si nejsem a{z tak jist)a jestli m)am tvou." + "[05000]No tak?" + "[06000]Dostanu t{e a st)ahnu t{e z k^u{ze." + "[09000]Samoz{rejm{e." + "[10000]Tebe a tu pitomou {c)ast Scionu." + "[13000]Jestli si ji chce{s tak moc nechat, narvu ti ji rovnou do..." + "[17000]Po{ckat... bav)ime se tady o tom artefaktu?" + "[20000]To si pi{s ... rovnou do ..." + "[22000]Vydr{z - Promi{n" + "[24000]{R)ikal jsi {c)ast. Kde je ten zbytek?" + "[26500]Pan)i Natla za touhle stopou poslala Pierra Duponta." + "[29500]A kde je ta stopa?" + "[30500]Hah. Nejsi na n{ej dost rychl)a." + "[34000]Tak{ze mysl)i{s, {ze v{sechno tohle mluven)i m{e jen zdr{zuje?" + "[37000]Nev)im kam ho ty jeho zaj)ico-{zab)i no{zi{cky vedou." + "[42000]Bude{s se muset poptat pan)i Natly." + "[46000]" + "[51000]D)iky. Zept)am se." + /* 24 */ , "" + /* 25 */ , + "[03500]Zde odpo{c)iv)a Tihocan" + "[05000]...jeden ze dvou spravedliv)ych vl)adc^u Atlantidy..." + "[10000]Ten, kter)y i po proklet)i kontinentu..." + "[13000]...se pokusil udr{zet pr)avo v t{echto pust)ych ciz)ich zem)ich..." + "[19000]Zem{rel bez d)it{ete a jeho v{ed{en)i z^ustalo bez n)asledovn)ika..." + "[25500]Bu{d k n)am milostiv, Tihocane." + /* 26 */ , "V)itejte u m{e doma!@Vezmu V)as na prohl)idku." + /* 27 */ , "Pomoc)i sm{erov)ych kl)aves p{rejd{ete do hudebn)i m)istnosti." + /* 28 */ , "Dobr)a. Poj{dme trochu pocvi{cit akrobacii.@Stiskn{ete kl)avesu pro skok." + /* 29 */ , "Nyn)i ji stiskn{ete je{st{e jednou v kombinaci s n{ekterou ze sm{erov)ych kl)aves@a j)a po{zadovan)ym sm{erem sko{c)im." + /* 30 */ , "Ach, ta hlavn)i hala.@Omlouv)am se za ty bedny, m)am tu p)ar v{eci k uskladn{en)i@a st{ehov)aci je je{st{e nevyzvedli." + /* 31 */ , "P{rib{ehn{ete k bedn{e a za sou{casn)eho dr{zen)i kl)avesy vp{red,@stiskn{ete kl)avesu akce a j)a se na n)i vy{svihnu." + /* 32 */ , "Tohle kdysi b)yval tane{cn)i s)al ne{z jsem si z n{ej ud{elala t{elocvi{cnu.@Co na n)i {r)ik)ate? No, poj{dme zkusit p)ar cvik^u." + /* 33 */ , "Ve skute{cnosti nemus)im v{sude jen b{ehat.@Kdy{z chci b)yt opatrn)a, tak chod)im krokem.@Podr{zte kl)avesu pro ch^uzi a dojd{ete k b)il)e {c)a{re." + /* 34 */ , "P{ri dr{zen)i kl)avesy ch^uze nespadnu dol^u ani pokud se o to pokus)ite.@Schv)aln{e to zkuste." + /* 35 */ , "Jestli{ze se budete cht)it rozhl)ednout, stiskn{ete a podr{zte kl)avesu pro rozhl)ednut)i.@Pot)e stiskn{ete kl)avesu sm{eru, kter)ym se chcete rozhl)ednout." + /* 36 */ , "Pokud je pro m{e skok p{r)ili{s vzd)alen)y, m^u{zu se zachytit okraje@a vyhnout se tak p)adu. B{e{zte a{z k okraji s b)ilou {c)arou@jak to jen p^ujde. Pot)e stiskn{ete kl)avesu pro skok, n)asledovanou@kl)avesou vp{red a zat)imco budu je{st{e ve vzduchu, stiskn{ete a podr{zte kl)avesu akce." + /* 37 */ , "Podr{zte kl)avesu vp{red a j)a na p{rek)a{zku vy{splh)am." + /* 38 */ , "V p{r)ipad{e skoku s rozb{ehem pro m{e takov)a vzd)alenost nep{redstavuje probl)em." + /* 39 */ , "Pomoc)i kl)avesy ch^uze b{e{zte a{z k okraji s b)ilou {c)arou dokud se sama nezastav)im.@Pot)e uvoln{ete kl)avesu ch^uze a stiskn{ete kl)avesu vzad, abych m{ela prostor pro rozb{eh.@Stiskn{ete kl)avesu vp{red a hned na to stiskn{ete a podr{zte kl)avesu pro skok.@Sko{c)im sama a{z v posledn)i chv)ili." + /* 40 */ , "Dob{re. Tenhle je opravdu dost daleko.@Tak{ze stejn{e jako p{redt)im. Skok s rozb{ehem n)asledovan)y podr{zen)im kl)avesy akce,@abych se zachytila okraje." + /* 41 */ , "P{ekn{e." + /* 42 */ , "Zkuste tu vysko{cit nahoru.@Stiskn{ete kl)avesu vp{red a podr{zte kl)avesu akce." + /* 43 */ , "Nahoru nevylezu, proto{ze mezera je p{r)ili{s mal)a.@Av{sak podr{zen)im sm{erov)e kl)avesy vpravo,@odru{ckuji a{z do m)ista kde je prostor, pot)e stiskn{ete kl)avesu vp{red." + /* 44 */ , "V)yborn{e!@Pokud se nechci zranit p{ri seskoku z velk)e v)y{sky,@m^u{zu se opatrn{e spustit dol^u." + /* 45 */ , "Klepn{ete na kl)avesu vzad a sesko{c)im pozp)atku.@Hned na to, podr{zte kl)avesu akce@a j)a se zachyt)im okraje." + /* 46 */ , "Pot)e ji pus{tte." + /* 47 */ , "Poj{dme si zaplavat." + /* 48 */ , "Pro pohyb pod vodou pou{zijte kl)avesu pro skok v kombinaci se sm{erov)ymi kl)avesami." + /* 49 */ , "Ach! Vzduch!@Pro man)evrov)an)i na hladin{e prost{e pou{zijte kl)avesy vp{red a vlevo a vpravo.@Pro dal{s)i potopen)i se, stiskn{ete kl)avesu pro skok.@Nebo doplavte ke kraji a stiskn{ete kl)avesu akce a j)a z vody vylezu." + /* 50 */ , "Dob{re. Te{d bych rad{eji m{ela svl)eknout to prom)a{cen)e oble{cen)i." + /* 51 */ , "{Rekni s)yr!" + /* 52 */ , "Nen)i to nic osobn)iho." + /* 53 */ , "Po{r)ad mi kv^uli tob{e vyst{reluje bolest do mozku. A d)av)a mi to srandovn)i n)apady. T{reba abych t{e rozt{r)ilel na kousky!" + /* 54 */ , "M{e a m)ych potomk^u se tak snadno nezbav)ite, Laro." + /* 55 */ , "Tro{sku pozd{e na ud{elen)i cen - non? Ale )U{cast se i tak po{c)it)a." + /* 56 */ , "To st{r)il)i{s na m{e? To st{r)il)i{s na m{e, co? Nikdo jinej tady nen)i, ur{cit{e st{r)il)i{s na m{e!" +// TR1 levels + , "La{rin Domov" + , "Jeskyn{e" + , "M{esto Vilcabamba" + , "Ztracen)e )Udol)i" + , "Hrobka Qualopeca" + , "Monument Sv. Franti{ska" + , "Koloseum" + , "Pal)ac Midase" + , "N)adr{z" + , "Hrobka Tihocana" + , "M{esto Khamoon" + , "Obelisk Khamoonu" + , "Svatyn{e Scionu" + , "Doly Natly" + , "Atlantida" + , "Velk)a Pyramida" + , "N)avrat do Egypta" + , "Chr)am Ko{cky" + , "Atlantsk)a Pevnost" + , "Hn)izdo" +// TR2 levels + , "La{rin Domov" + , "Velk)a Zed'" + , "Ben)atky" + , "Bartoliho )Ukryt" + , "D^um Opery" + , "Ropn)a plo{sina" + , "Pot)ape{csk)a oblast" + , "40 S)ah^u" + , "Vrak Maria Dorie" + , "Obytn)e m)istnosti" + , "Paluba" + , "Tibetsk)e P{redh^u{r)i" + , "Kl)a{ster Barkhang" + , "Katakomby Talionu" + , "Ledov)y Pal)ac" + , "Chr)am Xian" + , "Vzn)a{sej)ic)i Ostrovy" + , "Dra{c)i Doup{e" + , "Domove, Sladk)y Domove" +// TR3 levels + , "La{rin Domov" + , "D{zungle" + , "Ruiny Chr)amu" + , "{Reka Ganga" + , "Jeskyn{e Kaliya" + , "Pob{re{zn)i Vesnice" + , "M)isto Hav)arie" + , "Sout{eska Madubu" + , "Chr)am Puny" + , "P{rist)avi{st{e Tem{ze" + , "Aldwych" + , "Ludova Br)ana" + , "M{esto" + , "Nevadsk)a Pou{st'" + , "Oblast S Vysok)ym Zabezpe{cen)im" + , "Oblast 51" + , "Antarktida" + , "Doly RX-Tech" + , "Ztracen)e M{esto Tinnos" + , "Meteoritov)a Jeskyn{e" + , "V{sechny Relikvie" +}; + +#endif diff --git a/src/lang/de.h b/src/lang/de.h new file mode 100644 index 00000000..69c08d8d --- /dev/null +++ b/src/lang/de.h @@ -0,0 +1,354 @@ +#ifndef H_LANG_DE +#define H_LANG_DE + +// Thanks: Oktopaps + +const char *STR_DE[] = { "" +// help + , "Wird geladen..." + , "H dr~ucken f~ur Hilfe" + , helpText + , "%s@@@" + "Besiegte Gegner %d@@" + "Gegenst~ande %d@@" + "Geheimnisse %d von %d@@" + "Ben~otigte Zeit %s" + , "Spiel wird gespeichert..." + , "Spielstand gespeichert!" + , "FEHLER beim Speichern!" + , "JA" + , "NEIN" + , "Aus" + , "An" + , "Aus" + , "Side-By-Side" + , "Anaglyph" + , "Geteilter Bildschirm" + , "VR" + , "Niedrig" + , "Mittel" + , "Hoch" + , STR_LANGUAGES + , "Anwenden" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Nicht bereit" + , "Spieler 1" + , "Spieler 2" + , "Beliebige Taste dr~ucken" + , "%s - W~ahlen" + , "%s - Zur~uck" +// inventory pages + , "OPTIONEN" + , "INVENTAR" + , "GEGENST~ANDE" +// save game page + , "Spiel speichern?" + , "Aktuelle Position" +// inventory option + , "Spiel" + , "Karte" + , "Kompass" + , "Statistiken" + , "Laras Haus" + , "Grafik" + , "Ton" + , "Steuerung" + , "Gamma" +// passport menu + , "Spiel laden" + , "Spiel starten" + , "Level neu starten" + , "Zur~uck zum Hauptmen~u" + , "Spiel beenden" + , "Level w~ahlen" +// detail options + , "Grafikeinstellungen" + , "Filterung" + , "Beleuchtung" + , "Schatten" + , "Wasser" + , "VSync" + , "Stereo" + , "Simple Items" + , "Resolution" + , STR_SCALE +// sound options + , "Lautst~arke einstellen" + , "Nachhall" + , "Untertitel" + , "Sprache" +// controls options + , "Steuerung anpassen" + , "Tastatur" + , "Gamepad" + , "Vibration" + , "Retargeting" + , "Multi-aiming" + // controls + , "Links", "Rechts", "Vorw~arts", "R~uckw~arts", "Springen", "Gehen", "Handlung", "Waffe ziehen", "Umsehen", "Ducken", "Sprinten", "Rolle", "Inventar", "Start" + , STR_KEYS +// inventory items + , "Unbekannt" + , "Sprengstoff" + , "Pistolen" + , "Schrotflinte" + , "Magnums" + , "Uzis" + , "Pistolen-Munition" + , "Schrot-Munition" + , "Magnum-Munition" + , "Uzi-Ladestreifen" + , "Kleines Medi-Pack" + , "Gro=es Medi-Pack" + , "Bleibarren" + , "Scion" +// keys + , "Schl~ussel" + , "Silberner Schl~ussel" + , "Rostiger Schl~ussel" + , "Goldener Schl~ussel" + , "Saphir-Schl~ussel" + , "Schl~ussel des Neptun" + , "Schl~ussel des Atlas" + , "Schl~ussel des Damokles" + , "Schl~ussel des Thor" + , "Der antike Schl~ussel" +// puzzles + , "R~atsel" + , "Goldener G~otze" + , "Goldbarren" + , "Zahnrad" + , "Sicherung" + , "Ankh-Kreuz" + , "Auge des Horus" + , "Siegel des Anubis" + , "Skarab~aus" + , "Schl~ussel der Pyramide" +// TR1 subtitles + /* CAFE */ , + "[43500]Was muss ein Mann tun, um solche Aufmerksamkeit von Ihnen zu kriegen?" + "[47500]Schwer zu sagen, aber Sie machen sich bisher ganz gut." + "[50500]Na toll, obwohl ich eigentlich nicht derjenige bin, der Sie will." + "[53500]So?" + "[55000]Leider nein. Miss Jacqueline Natla sucht Sie@von Natla Technologies, wissen Sie?" + "[60500]Die Sch~opfer aller Herrlichkeit. Ha ha ha ha ha." + "[64000]Halt die Klappe, Larson!" + "[65500]Ma'am." + "[68000]Weiden Sie Ihre Augen daran, Lara." + "[70500]Na, werden Sie etwas neugierig?" + "[73000]Wenn Geld alles ist, was Sie zu bieten haben." + "[76000]Dann wird Ihnen vielleicht das hier gefallen." + "[78000]Peru. Majest~atische Bergketten, steile W~ande@aus blankem Eis, wilde Felskl~ufte, heulende Winde" + "[87000]und dann ist da noch das Scion,@ein uraltes Artefakt mit geheimnisvollen Kr~aften," + "[92000]tief im verlorenen Grab des Qualopec verborgen." + "[95500]Dieses Schmuckst~uck will ich haben." + "[98000]Sie k~onnten morgen abreisen.@Haben Sie morgen schon was vor?" + /* LIFT */ , + "[49000]Hier im Prachtbau des heiligen Franziskus@qu~alen mich neue Versuchungen." + "[53000]Meine Br~uder munkeln, dass unter unserer Abtei@der K~orper des Tihocan begraben ruht," + "[60000]einer der drei mythischen Herrscher@des verlorenen Erdteils Atlantis," + "[64000]und dass ein St~uck des atlantischen Erbes bei ihm liegt," + "[68500]ein Anh~anger, der zwischen den drei Herrschern@des untergegangenen Erdteils Atlantis aufgeteilt wurde," + "[73500]um seine unermesslichen Kr~afte im Zaum zu halten,@Kr~afte jenseits derer des Allm~achtigen, des Sch~opfers." + "[79500]Mir wird schwindelig von solchen M~oglichkeiten,@die so dicht an meinem sterblichen Selbst liegen." + "[85000]Jeder Nacht gei=le ich mich, um mir die Vorstellung auszutreiben,@aber es ist wahrlich eine schwere Pr~ufung." + "[92000]" + "[93000]Pierre, du Umweltverschmutzer." + /* CANYON */ , + "[13000]Da haben wir ja endlich das kleine Biest." + "[16500]Howdy!" + "[17000]Guten Tag!" + "[20000]Haben Sie Larson das Licht ausgeblasen?" + "[22000]Wenn man es so ausdr~ucken will." + "[24000]Tja, Ihr kleiner Ferienausflug ist zu Ende." + "[27000]Wird Zeit, dass ich zur~uckbekomme, was Sie mir gestohlen haben." + "[30000]Schauen wir doch mal in die Lunch Box." + "[32000]" + "[42000]Na los, t~otet sie!" + "[45000]Hey!" + "[48000]" + "[50500]Ihr Vollidioten!" + "[53000]" + "[62500]Lasst uns gehen." + "[65000]" + "[135000]Was zum Geier war das?" + "[137500]Was denn?" + "[138500]Da dr~uben." + "[140000]Wahrscheinlich nur ein Fisch." + "[142500]Muss aber ein ziemlich Gro=er gewesen sein." + "[145000]Mann, bist du nerv~os.@Ich geh wieder rein. Kommst du mit?" + "[150000]" + "[157000]Ruhig halten." + "[160000]Da kommt es." + "[161500]Seid ihr fertig?" + /* PRISON */ , + "[00001]Das k~onnt ihr nicht tun!" + "[01500]Wir verurteilen dich, Natla von Atlantis, f~ur deine Verbrechen," + "[06000]wegen krassen Missbrauchs deiner Kr~afte@und wegen Diebstahls unserer Kr~afte." + "[11000]Das k~onnt ihr nicht! Ich habe..." + "[12500]Du hast den Dreifachverbund zerst~ort,@der unser Volk eintr~achtig gef~uhrt und besch~utzt hat." + "[18000]Du hast Tihocan und mich mit unserer eigenen Armee herausgefordert," + "[23000]hast unsere Krieger von der Pyramide fortgelockt," + "[27000]damit du die Sch~opfungskraft der Pyramide@f~ur deine stumpfe Zerst~orungswut missbrauchen konntest." + "[33500]Stumpf? Seht euch doch an!" + "[35500]Keiner von euch hat auch nur einen Funken Erfindungsgeist im Kopf." + "[40000]Verschwender!" + "[41500]Lass es uns einfach tun." + "[44000]Tihocan!" + "[45000]Du hast deine heilige Opferst~atte aus purer Habsucht gesch~andet" + "[49000]und als Brutfabrik missbraucht." + "[51000]Eine neue Generation, zum ~Uberleben geboren." + "[54000]Jetzt sind sie Hackfleisch" + "[56000]und dich, Natla, werden wir in Stasis versetzen," + "[60000]deine Adern und F~u=e, dein Herz und dein krankes Hirn" + "[66000]mit gefrorenem Blut bedecken." + "[70000]Schau deiner ewigen Unruhe in die Augen, Natla." + "[73000]Ihr werdet auch keine Ruhe finden@und euer verdammter Kontinent Atlantis!" + /* 22 */ , + "[04000]Na, wieder da?" + "[05500]Sie auch. Zur feierlichen Wiederer~offnung, nehme ich an." + "[09000]Die Evolution steckt in der Sackgasse.@Kaum noch nat~urliche Auslese." + "[13500]Die Ausbreitung neuer, frischer Wesen@wird neue Gebietsk~ampfe anregen," + "[18500]uns st~arken und voranbringen," + "[20500]sogar neue Rassen erschaffen." + "[22500]Eine Art gedopte Evolution also." + "[24500]Ja, ein Tritt in den Hintern. Die albernen Wichte@Qualopec und Tihocan haben ja keine Ahnung." + "[29500]Der Untergang von Atlantis hat eine Rasse@tr~ager Schw~achlinge getroffen" + "[33500]und sie zu den Urspr~ungen des ~Uberlebens zur~uckgeworfen." + "[36000]Dies ist, was die Welt braucht." + "[38500]Nicht auf diese Art." + "[40000]Ausschl~upfen beginnt in 15 Sekunden." + "[43000]Zu sp~at f~ur eine Abtreibung!" + "[45000]Nicht ohne das Herz der Operation!" + "[47000]Nein!" + "[49500]10..." + "[53500]5..." + "[55000]" + /* 23 */ , + "[00001]Tja, jetzt haben Sie meine volle Aufmerksamkeit," + "[02500]aber ob ich auch Ihre habe?" + "[05000]Hallo?" + "[06000]Wart's ab. Wenn ich dich in die Finger kriege." + "[09000]Nat~urlich." + "[10000]Du und das d~amliche St~uck vom Scion." + "[13000]Wenn du's unbedingt behalten willst,@stopf ich's dir in deinen verdammten..." + "[17000]Moment. Sprechen wir gerade ~uber das Artefakt?" + "[20000]Darauf kannst du Gift nehmen." + "[22000]Moment. Tut mir leid." + "[24000]Sie sagten St~uck. Wo ist dann der Rest?" + "[26500]Miss Natla hat Pierre Dupont darauf angesetzt." + "[29500]Und wo sucht er danach?" + "[30500]Ha! Den erwischst du nie!" + "[34000]Sie meinen also, das Gerede hier h~alt mich nur auf?" + "[37000]~Ah, keine Ahnung, wo seine krummen@Ganovenbeine ihn hingebracht haben." + "[42000]Da muss... m~ussen Sie Miss Natla fragen." + "[46000]" + "[51000]Danke! Das werde ich tun." + /* 24 */ , "" + /* 25 */ , + "[03500]Hier ruht Tihocan," + "[06000]einer der zwei gerechten Herrscher von Atlantis," + "[10000]die selbst nach der Heimsuchung des Erdteils" + "[13000]trachteten, in diesem kargen, fremden Land gut zu regieren." + "[18000]Er starb ohne Kind und sein Wissen wurde nicht weitergegeben." + "[25500]Sei gn~adig mit uns, Tihocan." + /* 26 */ , "Willkommen bei mir daheim!@Lass uns einen kleinen Rundgang machen." + /* 27 */ , "Benutz das Steuerkreuz, um ins Musikzimmer zu gehen." + /* 28 */ , "OK, dann lass uns ein bisschen herumtoben!@Dr~uck die Sprungtaste." + /* 29 */ , "Jetzt dr~uck sie noch mal und dann schnell eine der@Richtungstasten, dann springe ich in diese Richtung." + /* 30 */ , "Ah, die gro=e Halle. Tut mir leid wegen der Kisten.@Ich habe ein paar Sachen eingelagert und wei= nicht, wohin damit." + /* 31 */ , "Lauf auf eine Kiste zu und w~ahrend du das Steuerkreuz hochgedr~uckt@h~altst, dr~uck die Handlungstaste, dann kletter ich rauf." + /* 32 */ , "Das war mal der Ballsaal, aber ich benutze ihn als Turnhalle.@Wie gef~allt sie dir?@Dann lass uns mal ein paar Lockerungs~ubungen machen." + /* 33 */ , "Ich laufe nat~urlich nicht ~uberall hin. Wenn ich besonders@vorsichtig sein m~ochte, gehe ich. Halt die Geh-Taste@gedr~uckt und beweg mich zum wei=en Strich." + /* 34 */ , "W~ahrend du die Geh-Taste gedr~uckt h~altst, kann ich nicht herunterfallen,@selbst wenn du versuchst, mich ~uber die Kante zu f~uhren. Probier es aus!" + /* 35 */ , "Wenn du dich umsehen willst, halt die Seh-Taste gedr~uckt@und dr~uck das Steuerkreuz in die gew~unschte Blickrichtung." + /* 36 */ , "Wenn ein Sprung zu weit f~ur mich ist, kann ich mich an der Kante@festklammern, damit ich nicht herunterfalle. Geh zur Kante mit dem@wei=en Strich bis ich stehen bleibe. Dr~uck dann die Sprungtaste@und gleich danach das Steuerkreuz hoch. Dr~uck jetzt, w~ahrend ich@noch in der Luft bin, die Handlungstaste und halte sie gedr~uckt." + /* 37 */ , "Dr~uck das Steuerkreuz hoch, damit hochklettere." + /* 38 */ , "Wenn ich Anlauf nehme, bekomme ich so einen Sprung problemlos hin." + /* 39 */ , "Geh zur Kante mit dem wei=en Strich bis ich stehen bleibe. Lass dann@die Geh-Taste los und dr~uck das Steuerkreuz kurz hinunter. Jetzt nehme@ich Anlauf. Dr~uck das Steuerkreuz hoch und sofort danach die Sprungtaste.@Halt die Sprungtaste gedr~uckt. Ich springe erst im letzten Moment." + /* 40 */ , "So, das ist ein richtig Gro=er! Leite den Sprung genauso ein wie eben@erkl~art, aber wenn ich in der Luft bin, dr~uckst du die Handlungstaste@und h~altst sie gedr~uckt, dann kann ich mich an die Kante klammern." + /* 41 */ , "Toll!" + /* 42 */ , "Versuch mal, hier hochzuklettern.@Dr~uck das Steuerkreuz hoch und dann die Handlungstaste." + /* 43 */ , "Ich kann hier nicht hochklettern, weil die L~ucke zu schmal ist.@Wenn du aber das Steuerkreuz nach rechts dr~uckst, hangel ich@mich seitlich durch bis genug Platz zum Hochziehen ist." + /* 44 */ , "Wenn es steil bergab geht und ich mich beim Absprung nicht@verletzen will, kann ich auch vorsichtig hinunterklettern." + /* 45 */ , "Dr~uck das Steuerkreuz nach unten, damit ich r~uckw~arts hinunterspringe.@Dr~uck dann sofort die Handlungstaste und halte sie gedr~uckt, damit ich@mich im Fallen an der Kante festklammere." + /* 46 */ , "Jetzt lass los." + /* 47 */ , "Lass uns schwimmen gehen." + /* 48 */ , "Mit der Sprungtaste und dem Steuerkreuz steuerst du mich unter Wasser." + /* 49 */ , "Ah! Luft!@Dr~uck einfach das Steuerkreuz nach vorne, links und rechts,@um mich an der Oberfl~ache zu bewegen. Dr~uck die Sprungtaste,@wenn ich noch einmal abtauchen soll. Oder geh zur Kante und@dr~uck die Handlungstaste, damit ich aus dem Wasser steige." + /* 50 */ , "So, jetzt lege ich erstmal die nassen Sachen ab." + /* 51 */ , "Bitte l~acheln!" + /* 52 */ , "Ist nichts Pers~onliches." + /* 53 */ , "Sie machen mir immer noch Kopfschmerzen, Lady.@Ein kleiner Vogel sagt mir, ich soll Sie zur H~olle schicken!" + /* 54 */ , "So leicht wirst du mich und meine Brut nicht los, Lara." + /* 55 */ , "Ein bisschen sp~at dran f~ur die Preisverleihung, non?@Aber dabei sein ist ja alles, obwohl das nicht jeder so sieht.@Jammerschade, aber... c'est la vie." + /* 56 */ , "Du schie=t auf mich? Du schie=t auf mich, Puppe, he?@Hier ist kein anderer. Du musst auf mich schie=en!" +// TR1 levels + , "Laras Haus" + , "Die Kavernen" + , "Die Stadt Vilcabamba" + , "Das verlorene Tal" + , "Das Grab von Qualopec" + , "St. Francis' Folly" + , "Das Kolosseum" + , "Der Palast des Midas" + , "Die Zisterne" + , "Das Grab des Tihocan" + , "Die Stadt Khamoon" + , "Der Obelisk von Khamoon" + , "Das Heiligtum des Scion" + , "Natlas Katakomben" + , "Atlantis" + , "Die gro=e Pyramide" + , "R~uckkehr nach ~Agypten" + , "Der Tempel der Katze" + , "Die Festung von Atlantis" + , "Das Nest" +// TR2 levels + , "Laras Haus" + , "Die gro=e Mauer" + , "Venedig" + , "Bartolis Versteck" + , "Das Opernhaus" + , "Der Bohrturm" + , "Die Tiefe" + , "40 Faden" + , "Das Wrack der Maria Doria" + , "Die Quartiere" + , "An Deck" + , "Das tibetianische Hochland" + , "Das Kloster von Barkhang" + , "Die Katakomben des Talion" + , "Der Eispalast" + , "Der Tempel des Xian" + , "Die schwimmenden Inseln" + , "Der Hort des Drachen" + , "Zuhause" +// TR3 levels + , "Laras Haus" + , "Dschungel" + , "Tempelruine" + , "Der Ganges" + , "Kaliya H~ohlen" + , "K~ustendorf" + , "Absturzstelle" + , "Madubu Schlucht" + , "Punatempel" + , "Kai an der Themse" + , "Aldwych" + , "Lud's Gate" + , "Innenstadt" + , "W~uste von Nevada" + , "Hochsicherheitstrakt" + , "Area 51" + , "Antarktis" + , "RX-Techs Bergwerk" + , "Die vergessene Stadt Tinnos" + , "H~ohle des Meteoriten" + , "All Hallows" +}; + +#endif diff --git a/src/lang/en.h b/src/lang/en.h new file mode 100644 index 00000000..ca0746aa --- /dev/null +++ b/src/lang/en.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_EN +#define H_LANG_EN + +// Thanks: Nancy Charlton, Vague Rant + +const char *STR_EN[] = { "" +// help + , "Loading..." + , "Press H for help" + , helpText + , "%s@@@" + "KILLS %d@@" + "PICKUPS %d@@" + "SECRETS %d of %d@@" + "TIME TAKEN %s" + , "Saving game..." + , "Saving done!" + , "SAVING ERROR!" + , "YES" + , "NO" + , "Off" + , "On" + , "Off" + , "Side-By-Side" + , "Anaglyph" + , "Split Screen" + , "VR" + , "Low" + , "Medium" + , "High" + , STR_LANGUAGES + , "Apply" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Not Ready" + , "Player 1" + , "Player 2" + , "Press Any Key" + , "%s - Select" + , "%s - Go Back" +// inventory pages + , "OPTIONS" + , "INVENTORY" + , "ITEMS" +// save game page + , "Save Game?" + , "Current Position" +// inventory option + , "Game" + , "Map" + , "Compass" + , "Statistics" + , "Lara's Home" + , "Detail Levels" + , "Sound" + , "Controls" + , "Gamma" +// passport menu + , "Load Game" + , "New Game" + , "Restart Level" + , "Exit to Title" + , "Exit Game" + , "Select Level" +// detail options + , "Select Detail" + , "Filtering" + , "Lighting" + , "Shadows" + , "Water" + , "VSync" + , "Stereo" + , "Simple Items" + , "Resolution" + , STR_SCALE +// sound options + , "Set Volumes" + , "Reverberation" + , "Subtitles" + , "Language" +// controls options + , "Set Controls" + , "Keyboard" + , "Gamepad" + , "Vibration" + , "Retargeting" + , "Multi-aiming" + // controls + , "Left", "Right", "Run", "Back", "Jump", "Walk", "Action", "Draw Weapon", "Look", "Duck", "Dash", "Roll", "Inventory", "Start" + , STR_KEYS +// inventory items + , "Unknown" + , "Explosive" + , "Pistols" + , "Shotgun" + , "Magnums" + , "Uzis" + , "Pistol Clips" + , "Shotgun Shells" + , "Magnum Clips" + , "Uzi Clips" + , "Small Medi Pack" + , "Large Medi Pack" + , "Lead Bar" + , "Scion" +// keys + , "Key" + , "Silver Key" + , "Rusty Key" + , "Gold Key" + , "Sapphire Key" + , "Neptune Key" + , "Atlas Key" + , "Damocles Key" + , "Thor Key" + , "Ornate Key" +// puzzles + , "Puzzle" + , "Gold Idol" + , "Gold Bar" + , "Machine Cog" + , "Fuse" + , "Ankh" + , "Eye of Horus" + , "Seal of Anubis" + , "Scarab" + , "Pyramid Key" +// TR1 subtitles + /* CAFE */ , + "[43500]What's a man gotta do to@get that kinda attention from ye?" + "[47500]It's hard to say exactly,@but you seem to be doing fine." + "[50000]Well, great. Though, truth is,@it ain't me that wants ye." + "[54500]No?" + "[55000]No. Miss Jacqueline Natla does,@from Natla Technologies." + "[59000]You know, creator of@all things bright and beautiful?" + "[64500]Seal it, Larson." + "[66000]Ma'am." + "[68000]Feast your eyes on this, Lara." + "[70500]How does that make your wallet rumble?" + "[73500]I'm sorry. I only play for sport." + "[76000]Then you'll like a big park." + "[78000]Peru. Vast mountain ranges to cover.@Sheer walls of ice. Rocky crags. Savage winds." + "[87500]And there's this little trinket:@an age old artefact of mystical powers" + "[92500]buried in the unfound tomb of Qualopec." + "[96000]That's my interest." + "[98000]You could leave tomorrow.@Are you busy tomorrow?" + /* LIFT */ , + "[49000]Relocated now to St. Francis' Folly, new temptations torment me." + "[53500]Rumour amongst my fellow brothers is that entombed@beneath our monastery lies the body of Tihocan," + "[60000]one of the three legendary rulers of@the lost continent, Atlantis," + "[64500]and that within lies his piece@of the Atlantean Scion." + "[68000]The pendant divided and shared between the three rulers@" + "[72500]which curbs tremendous powers.@Powers beyond the creator himself." + "[79000]My toes sweat at such possibilities@lying so close to my mortal self." + "[85500]Each night, I bid myself rid of these@fantasies, but it is indeed a test." + "[92000]" + "[93500]Pierre. Tsk. You litterbug." + /* CANYON */ , + "[13500]You just pulled the tough end of a wishbone." + "[16500]Howdy." + "[17500]Afternoon." + "[20000]Left Larson sucking wind then, eh?" + "[22500]If that is the phrase." + "[24000]Well, your little vacation riot's over now." + "[27000]Time to give back what you've hijacked off me." + "[30000]Let's try the lunch-box." + "[32000]" + "[42500]Well? Kill her!" + "[45000]Hey!" + "[48000]" + "[50500]You morons!" + "[53000]" + "[62500]Let's go." + "[65000]" + "[136000]What the heck was that?" + "[138000]What?" + "[138500]That-a-way." + "[140500]Probably just a fish." + "[142500]That's some fish, kid." + "[145000]Man, you have got to learn to chill.@I'm going back inside. You coming?" + "[152000]" + "[158000]Steady..." + "[160000]Here she goes." + "[161500]You ready yet?" + /* PRISON */ , + "[00001]You can't do this!" + "[01500]We condemn you, Natla of Atlantis, for your crimes." + "[06000]For the flagrant misuse of your powers@and for robbing us of our..." + "[11500]You can't! I..." + "[12500]Breaking the free bond of consent that our@people are ruled and secured under," + "[18500]and invading Tihocan and myself with our army." + "[23500]Our warriors emptied from our pyramid" + "[27000]so that you could use the pyramid - its powers@of creation - for your own mindless destruction." + "[33500]Mindless!? Look at you!" + "[35500]Neither of you have one squirt of@inventive juice in your heads." + "[40500]Wasters!" + "[41500]Let's just do it." + "[44000]Tihocan!" + "[45000]You used the sacramental place as a source@of individual pleasure," + "[49500]as some freak factory." + "[51000]They're survivalists. A new generation." + "[54000]A slaughter heap now." + "[56000]And you. We're going to lock you in limbo." + "[60000]Make your veins, heart, feet," + "[64000]and that diseased brain stick solid with frozen blood." + "[70000]Greet your eternal unrest, Natla." + "[73000]You won't rest either, or your@damned continent of Atlantis!" + /* 22 */ , + "[04000]Back again?" + "[05500]And you - for a grand re-opening, I assume." + "[09500]Evolution's in a rut - natural selection at an all time low..." + "[13500]shipping out fresh meat will incite territorial rages again" + "[17500] - will strengthen and advance us..." + "[20500]Even create new breeds." + "[22500]Kind of evolution on steroids, then." + "[24500]A kick in the pants...@those runts Qualopec and Tihocan had no idea" + "[29500] - the cataclysm of Atlantis struck a race of langouring wimps..." + "[33500]plummeted them to the very basics of survival again..." + "[37000]It shouldn't happen like that." + "[39000]Or like this." + "[40000]Hatching commences in 15 seconds." + "[43000]Too late for abortions now!" + "[45000]Not without the heart of the operation!" + "[47000]Noooo!" + "[50000]TEN" + "[54000]FIVE..." + "[55500]4...3...2..." + "[60000]ONE..." + /* 23 */ , + "[00001]Well, you have my total attention now" + "[02500]- I'm not quite sure if I've got yours, though." + "[05000]Hello?" + "[06000]I'll heel an' hide ye to a barn door yit." + "[09000]Of course." + "[10000]Ye and that drivelin' piece of the Scion." + "[13000]Ye want to keep it so bad, I'll harness it right up y..." + "[17000]Wait... we're talking about the artifact here?" + "[20000]Damn straight we are ... right up y ..." + "[22000]Hold on - I'm sorry" + "[24000]- this piece, you say - where's the rest?" + "[26500]Ms. Natla put Pierre Dupont on that trail." + "[29500]And where is that?" + "[30500]Hah. Ye ain't fast enough fer him." + "[34000]So you think all this talking is just holding me up?" + "[37000]I don't know where his little jackrabbit-frog-legs are runnin' him to." + "[42000]You'll have to ask Ms. Natla." + "[46000]" + "[51000]Thank you. I will." + /* 24 */ , "" + /* 25 */ , + "[03500]Here lies Tihocan" + "[05000]...one of the two just rulers of Atlantis..." + "[10000]Who even after the curse of the continent..." + "[13000]...had tried to keep rule here in these barren other-lands..." + "[19000]He died without child and his knowledge has no heritage..." + "[25500]Look over us kindly, Tihocan." + /* 26 */ , "Welcome to my home!@I'll take you on a guided tour." + /* 27 */ , "Use the directional keys to go into the music room." + /* 28 */ , "OK. Let's do some tumbling.@Press the jump button." + /* 29 */ , "Now press it again and quickly press one of@the directions and I'll jump that way." + /* 30 */ , "Ah, the main hall.@Sorry about the crates, I'm having some things put@ into storage and the delivery people haven't been yet." + /* 31 */ , "Run up to a crate, and while still pressing forward,@press action, and I'll vault up onto it." + /* 32 */ , "This used to be the ballroom, but I've@converted it into my own personal gym.@What do you think?@Well, let's do some exercises." + /* 33 */ , "I don't actually run everywhere.@When I want to be careful, I walk.@Hold down the walk button, and walk to the white line." + /* 34 */ , "With the walk button down, I won't fall off even if you try to make me.@Go on, try it." + /* 35 */ , "If you want look around, press and hold the look button.@Then press in the direction you want to look." + /* 36 */ , "If a jump is too far for me, I can grab the ledge and save myself@from a nasty fall. Walk to the edge with the white line until I@won't go any further. Then press jump, immediately followed by@forward and while I'm in the air, press and hold the action button." + /* 37 */ , "Press forward and I'll climb up." + /* 38 */ , "If I do a running jump, I can make a jump like that, no problem." + /* 39 */ , "Walk to the edge with the white line until I stop.@Then let go of walk and tap backwards to give me a run up.@Press forward, and almost immediately press and hold the jump button.@I won't actually jump until the last minute." + /* 40 */ , "Right. This is a really big one.@So do a running jump exactly as before except while I'm in the air@press and hold the action button to make me grab the ledge." + /* 41 */ , "Nice." + /* 42 */ , "Try to vault up here.@Press forward and hold action." + /* 43 */ , "I can't climb up because the gap is too small.@But press right and I'll shimmy sideways@until there is room, then press forward." + /* 44 */ , "Great!@If there is a long drop and I don't want to@hurt myself jumping off, I can let myself down carefully." + /* 45 */ , "Tap backwards, and I'll jump off backwards.@Immediately press and hold the action button,@and I'll grab the ledge on the way down." + /* 46 */ , "Then let go." + /* 47 */ , "Let's go for a swim." + /* 48 */ , "The jump button and the directions@move me around underwater." + /* 49 */ , "Ah! Air!@Just use forward and left and right@to manoeuvre around on the surface.@Press jump to dive down for another swim about.@Or go to the edge and press action to climb out." + /* 50 */ , "Right. Now I'd better take off these wet clothes." + /* 51 */ , "Say cheese!" + /* 52 */ , "Ain't nothin' personal." + /* 53 */ , "I still git a pain in my brain from ye.@An' it's tellin' me funny ideas now.@Like to shoot you to hell!" + /* 54 */ , "You can't bump off me and my brood so easy, Lara." + /* 55 */ , "A leetle late for ze prize giving - non?@Still, it is ze taking-part wheech counts." + /* 56 */ , "You firin' at me?@You firin' at me, huh?@Ain't nobody else here, you must be firin' at me!" +// TR1 levels + , "Lara's Home" + , "Caves" + , "City of Vilcabamba" + , "Lost Valley" + , "Tomb of Qualopec" + , "St. Francis' Folly" + , "Colosseum" + , "Palace Midas" + , "The Cistern" + , "Tomb of Tihocan" + , "City of Khamoon" + , "Obelisk of Khamoon" + , "Sanctuary of the Scion" + , "Natla's Mines" + , "Atlantis" + , "The Great Pyramid" + , "Return to Egypt" + , "Temple of the Cat" + , "Atlantean Stronghold" + , "The Hive" +// TR2 levels + , "Lara's Home" + , "The Great Wall" + , "Venice" + , "Bartoli's Hideout" + , "Opera House" + , "Offshore Rig" + , "Diving Area" + , "40 Fathoms" + , "Wreck of the Maria Doria" + , "Living Quarters" + , "The Deck" + , "Tibetan Foothills" + , "Barkhang Monastery" + , "Catacombs of the Talion" + , "Ice Palace" + , "Temple of Xian" + , "Floating Islands" + , "The Dragon's Lair" + , "Home Sweet Home" +// TR3 levels + , "Lara's House" + , "Jungle" + , "Temple Ruins" + , "The River Ganges" + , "Caves Of Kaliya" + , "Coastal Village" + , "Crash Site" + , "Madubu Gorge" + , "Temple Of Puna" + , "Thames Wharf" + , "Aldwych" + , "Lud's Gate" + , "City" + , "Nevada Desert" + , "High Security Compound" + , "Area 51" + , "Antarctica" + , "RX-Tech Mines" + , "Lost City Of Tinnos" + , "Meteorite Cavern" + , "All Hallows" +}; + +#endif diff --git a/src/lang/es.h b/src/lang/es.h new file mode 100644 index 00000000..a4c5d1a9 --- /dev/null +++ b/src/lang/es.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_ES +#define H_LANG_ES + +// Thanks: RaymanTheHedgehog, RoxasXIIIKeys, Pedro "Perico" Callejas + +const char *STR_ES[] = { "" +// help + , "Cargando..." + , "Pulsa H para ayuda" + , helpText + , "%s@@@" + "BAJAS %d@@" + "RECOGIDAS %d@@" + "SECRETOS %d de %d@@" + "TIEMPO %s" + , "Guardando partida..." + , "E)xito al guardar" + , "\xA1""ERROR al guardar!" + , "S)I" + , "NO" + , "No" + , "S)i" + , "No" + , "Side-By-Side" + , "Anaglifo" + , "Pantalla dividida" + , "VR" + , "Bajo" + , "Medio" + , "Alto" + , STR_LANGUAGES + , "Aplicar" + , "Mando 1" + , "Mando 2" + , "Mando 3" + , "Mando 4" + , "No est)a preparado" + , "Jugador 1" + , "Jugador 2" + , "Pulsa cualquier tecla" + , "%s - Seleccionar" + , "%s - Volver" +// inventory pages + , "OPCIONES" + , "INVENTARIO" + , "OBJETOS" +// save game page + , "\xBFGuardar la partida?" + , "Posici)on actual" +// inventory option + , "Juego" + , "Mapa" + , "Br)ujula" + , "Estad)isticas" + , "Hogar de Lara" + , "Nivel de detalle" + , "Sonido" + , "Controles" + , "Gamma" +// passport menu + , "Cargar partida" + , "Nueva partida" + , "Reiniciar nivel" + , "Regresar al t)itulo" + , "Salir del juego" + , "Seleccionar nivel" +// detail options + , "Nivel de detalle" + , "Filtraci)on" + , "Iluminaci)on" + , "Sombras" + , "Agua" + , "VSync" + , "Stereo" + , "Objetos simples" + , "Resolution" + , STR_SCALE +// sound options + , "Fijar volumen" + , "Reverberaci)on" + , "Subtitulos" + , "Idioma" +// controls options + , "Ajustar controles" + , "Teclado" + , "Mando" + , "Vibraci)on" + , "Retargeting" + , "Multi-objetivo" + // controls + , "Izquierda", "Derecha", "Correr", "Atr)as", "Saltar", "Andar", "Acci)on", "Sacar Armas", "Mirar", "Agacharse", "Esprintar", "Rodar", "Inventario", "Start" + , STR_KEYS +// inventory items + , "Desconocido" + , "Explosivo" + , "Pistolas" + , "Escopeta" + , "M)agnums" + , "Uzis" + , "Cargadores de Pistola" + , "Cartuchos de Escopeta" + , "Cargadores de M)agnum" + , "Cargadores de Uzi" + , "Botiqu)in Peque+no" + , "Botiqu)in Grande" + , "Lingote de Plomo" + , "Scion" +// keys + , "Llave" + , "Llave de plata" + , "Llave oxidada" + , "Llave de Oro" + , "Llave de Zafiro" + , "Llave de Neptuno" + , "Llave de Atlas" + , "Llave de Damocles" + , "Llave de Thor" + , "Llave decorada" +// puzzles + , "Puzzle" + , ")Idolo dorado" + , "Lingote de oro" + , "Rueda Dentada" + , "Fusible" + , "Ankh" + , "Ojo de Horus" + , "Sello de Anubis" + , "Escarabajo" + , "Llave de la pir)amide" +// TR1 subtitles + /* CAFE */ , + "[43500]\xBFQu)e es lo que tiene que hacer un@hombre para atraer tu atenci)on?" + "[47500]Es dif)icil de definir, pero tranquilo,@vas por buen camino." + "[50000]\xA1Genial!. Aunque lo cierto es que no soy yo el que te busca." + "[54500]Ah, \xBFno?" + "[55000]No. La se+nora Jacqueline Natla te busca.@De Tecnolog)ias Natla." + "[59000]Ya sabes... creadora de cosas radiantes y maravillosas. \xA1Ja, ja, ja!" + "[64500]Cierra el pico, Larson." + "[66000]Madam..." + "[68000]Echa un vistazo a esto, Lara." + "[70500]\xBFNo hace retumbar tu cartera?" + "[73500]Lo siento. S)olo trabajo por diversi)on." + "[76000]Entonces, te encantar)an los desaf)ios..." + "[78000]como Per)u: Enormes cordilleras de monta+nas, transparentes laderas de hielo, despe+naderos de roca, vientos huracanados..." + "[87500]Y all)i se esconde esta peque+na joya: Un antiguo artefacto de poderes m)isticos" + "[92500]enterrado en la tumba perdida de Qualopec." + "[96000]Eso es lo que busco." + "[98000]Podr)ias partir ma+nana. \xBF""Est)as ocupada ma+nana?." + /* LIFT */ , + "[49000]Ahora que me he trasladado al monasterio de San Francisco,@nuevas tentaciones me atormentan." + "[53500]Corren rumores entre mis hermanos que hablan de que,@enterrado en los m)as profundo de este monasterio,@descansa el cuerpo de Tihocan," + "[60000]uno de los tres legendarios soberanos del continente perdido, La Atl)antida," + "[64500]y que con )el se encuentra su pieza del Scion atl)antido." + "[68000]El pendiente, dividido y repartido entre los tres soberanos," + "[72500]posee un tremendo poder.@M)as poder que el mism)isimo Creador." + "[79000]Mis pies sudan ante la posibilidad de estar@tan cerca de mi alma mortal." + "[85500]Cada noche, me intento redimir de estas fantas)ias,@pero, sin duda, me est)a poniendo a prueba." + "[92000]" + "[93500]Pierre... Peque+no granuja..." + /* CANYON */ , + "[13500]Me temo que has tenido mala suerte." + "[16500]\xBFQu)e tal?." + "[17500]Buenas tardes..." + "[20000]As)i que le hiciste morder el polvo a Larson, \xBF""eh?." + "[22500]Yo no lo expresar)ia as)i..." + "[24000]Bueno, tu peque+na traici)on ha llegado a su fin." + "[27000]Es hora de que me devuelvas lo que es m)io." + "[30000]Miremos en su bolsita de la merienda." + "[32000]" + "[42500]Ahora... \xA1Matadla!" + "[45000]\xA1""Eh!" + "[48000]" + "[50500]\xA1Imb)eciles!." + "[53000]" + "[62500]V)amonos." + "[65000]" + "[136000]\xBFQu)e demonios ha sido eso?" + "[138000]\xBF""El qu)e?" + "[138500]\xA1""Eso!" + "[140500]Probablemente s)olo un pez." + "[142500]\xA1Pues menudo pez )ese, chico!" + "[145000]\xA1Tienes que aprender a tomarte las cosas con calma, hombre!.@Vuelvo adentro, \xBFvienes?" + "[152000]" + "[158000]\xA1Hemos llegado!" + "[160000]All)a vamos." + "[161500]\xBF""Est)ais listos?" + /* PRISON */ , + "[00001]\xA1No pod)eis hacerme esto!" + "[01500]Te condenamos, Natla de Atl)antida, por tus cr)imenes," + "[06000]por tu escandaloso abuso de poder y por privarnos de nuestro..." + "[11500]\xA1No pod)eis!. Yo..." + "[12500]Rompiendo el v)inculo de libertad y consentimiento@bajo el que nuestro pueblo vive protegido," + "[18500]y por invadirnos con nuestro propio ej)ercito." + "[23500]Nuestros propios soldados, evacuados de nuestra pir)amide" + "[27000]para que pudieras usar la pir)amide y su poder de creaci)on@\xA1""para tu descerebrado plan de destrucci)on!" + "[33500]\xBF""Descerebrado?. \xA1Pero miraos!" + "[35500]Ninguno de vosotros demuestra tener@siquiera un )apice de inteligencia." + "[40500]\xA1Holgazanes!" + "[41500]Hag)amoslo de una vez." + "[44000]\xA1Tihocan!" + "[45000]Usaste el lugar sagrado como fuente para tu placer personal," + "[49500]\xA1""como f)abrica de monstruos!" + "[51000]Son supervivientes. Una nueva generaci)on." + "[54000]Ahora no es m)as que una carnicer)ia." + "[56000]Y en cuanto a ti... Te vamos a encerrar en el limbo." + "[60000]Vamos a solidificar con sangre congelada@tus venas, coraz)on, pies" + "[64000]y ese cerebro enfermizo que tienes." + "[70000]\xA1""Da la bienvenida a tu no descanso eterno, Natla!" + "[73000]Vosotros tampoco descansar)eis, \xA1ni vuestro jodido continente Atl)antida!" + /* 22 */ , + "[04000]Has regresado." + "[05500]Y t)u. Preparando el gran reestreno, supongo." + "[09500]La evoluci)on ha entrado en rutina.@El desarrollo natural est)a en su punto m)as bajo." + "[13500]Poner en circulaci)on algo de carne fresca@incitar)a al hombre de nuevo a la c)olera" + "[17500]y eso nos har)a m)as fuertes, nos har)a avanzar," + "[20500]incluso crear)a nuevas razas." + "[22500]\xBF""Alg)un tipo de evoluci)on hormonal?" + "[24500]Una buena patada en los genitales, dir)ia yo.@Esos enanos de Qualopec y Tihocan no ten)ian ni idea." + "[29500]El cataclismo de Atl)antida cre)o una raza de enclenques," + "[33500]que limit)o al hombre a lo m)as b)asico de la supervivencia." + "[37000]No debi)o suceder de esa manera." + "[39000]Ni de esta." + "[40000]La incubaci)on concluye en quince segundos." + "[43000]Ya es demasiado tarde para detener nada." + "[45000]No sin el n)ucleo de la operaci)on." + "[47000]""\xA1Noooo!" + "[50000]DIEZ" + "[54000]CINCO..." + "[55500]4...3...2..." + "[60000]UNO..." + /* 23 */ , + "[00001]Bueno, tienes toda mi atenci)on." + "[02500]Aunque no estoy muy segura de si tengo la tuya..." + "[05000]\xBFHola?" + "[06000]\xA1""Auh!, \xA1Te enviar)e de una patada al infierno!" + "[09000]Por supuesto..." + "[10000]T)u y esa est)upida pieza del Scion." + "[13000]\xBFPara qu)e la quieres?. \xA1""D)amelo ahora mismo!." + "[17000]Espera. \xBF""Estamos hablando del artefacto?." + "[20000]Claro que s)i, maldita sea. \xA1""D)amelo!." + "[22000]\xA1Quieto ah)i!" + "[24000]Esta pieza de la que hablas... \xBF""D)onde est)an las dem)as?" + "[26500]La se+nora Natla puso a Pierre Dupont tras la pista..." + "[29500]\xBFY donde est)a )el?" + "[30500]\xA1Ja!. \xA1No eres lo suficientemente r)apida para alcanzarlo!" + "[34000]\xBF""Acaso piensas que toda esta charla me est)a retrasando?" + "[37000]Mira, no s)e a d)onde se dirige ese renacuajo." + "[42000]Tendr)as que preguntarle a la se+nora Natla." + "[46000]" + "[51000]Gracias. Lo har)e." + /* 24 */ , "" + /* 25 */ , + "[03500]Aqu)i descansa Tihocan." + "[05000]Uno de los dos soberanos de La Atl)antida supervivientes," + "[10000]quien, incluso tras la maldici)on del continente," + "[13000]intent)o seguir gobernando en estas otras tierras )aridas." + "[19000]Muri)o sin hijos, y su conocimiento no tuvo herederos." + "[25500]Recu)erdanos con cari+no, Tihocan." + /* 26 */ , "Bienvenidos a mi casa, Te llevar)e en un tour guiado." + /* 27 */ , "Utiliza la tecla de control para llegar a@la habitaci)on de la m)usica." + /* 28 */ , "Vale. Hagamos unas cuantas acrobacias.@Presiona la tecla de salto." + /* 29 */ , "Ahora presi)onala de nuevo y presiona tambi)en@la tecla de control para saltar hacia ese lado." + /* 30 */ , "Ah, el sal)on principal.@Perdona por las cajas, estoy guardando algunas cosas@y los transportistas no han llegado." + /* 31 */ , "Corre hasta una caja y, mientras mantienes presionado la tecla Adelante@presiona la tecla Acci)on para saltar encima de la caja" + /* 32 */ , "Esto era la sala de bailes,@pero la he convertido en mi gimnasio particular.@\xBFQu)e te parece? Bien, hagamos un poco de ejercicio." + /* 33 */ , "En realidad no voy corriendo a todos lados.@Cuando quiero tener cuidado, ando.@Mant)en pulsado la tecla andar y anda hasta la linea blanca." + /* 34 */ , "Con la tecla Andar presionada no me caer)e por mucho que lo intentes.@Vamos, int)entalo." + /* 35 */ , "Si quieres mirar alrededor, presiona la tecla mirar y mantenla asi.@A continuaci)on presiona la direcci)on en la que quieras mirar." + /* 36 */ , "Si un salto es demasiado largo, puedo agarrarme@al borde salv)andome de una desagradable caida.@Camina hasta el borde que tiene la l)inea blanca,@hasta que ya no pueda avanzar.@Ahora presiona Saltar y justo a continuaci)on Adelante,@mientras estoy en el aire presiona Acci)on." + /* 37 */ , "Pulsa Adelante y subir)e a pulso." + /* 38 */ , "Si hago un salto en carrera tambi)en puedo hacer@ese tipo de saltos. No hay problema." + /* 39 */ , "Camina hasta el borde que tiene la linea blanca,@hasta que ya no pueda avanzar.@Ahora dame la vuelta para que tenga espacio.@Presiona Adelante y casi inmediatamente presiona@y mant)en presionada la tecla Saltar.@No voy a saltar hasta el )ultimo momento." + /* 40 */ , "Vale. Esto es m)as dificil.@Salta en carrera igual que antes pero, mientras estoy en el aire@presiona y mant)en presionado la tecla para que me agarre al borde." + /* 41 */ , "\xA1""Bien!" + /* 42 */ , "Intenta subir aqui.@Presiona Adelante y mant)en presionado Acci)on." + /* 43 */ , "No puedo escalar porque el espacio es muy peque+no.@Pero si presionas Derecha, oscilar)e a un lado@hasta que haya espacio, presiona entonces Adelante." + /* 44 */ , "\xA1\xA1Muy bien!!@Si la caida es muy grande y no quiero da+narme@puedo descolgarme con cuidado." + /* 45 */ , "Pulsa hacia atr)as y saltar)e.@Presiona a continuaci)on la tecla Acci)on@y me agarrar)e al borde." + /* 46 */ , "Deja que siga." + /* 47 */ , "Vamos a nadar un poco." + /* 48 */ , "La tecla de salto y la de control sirven@para dirigirme mientras buceo." + /* 49 */ , "\xA1""Ah! \xA1""Aire!@S)olo tienes que usar Adelante, Izquierda y@Derecha para moverte por la superficie.@Presiona Saltar para sumergirte y darte otro ba+no.@O Vete al borde y presiona Acci)on para salir." + /* 50 */ , "Vale, mejor me quito esta ropa mojada." + /* 51 */ , "\xA1""Di patata!" + /* 52 */ , "Nada personal." + /* 53 */ , "Todavia tengo dolor de cabeza por tu culpa.@Y ese dolor hace que se me ocurran ideas divertidas.@\xA1""Como dispararte hasta mandarte al infierno!" + /* 54 */ , "No te deshar)as de mi y mi progenie tan f)acilmente, Lara." + /* 55 */ , "Un poco tarde para la entrega de premios \xBFno?@, No importa, lo que cuenta es quien se lo lleva." + /* 56 */ , "\xBFMe disparas a mi, eh?@\xBFMe disparas a mi, \xBF""eh?@\xA1""Aqu)io hay nadie m)as, as)i que debes estar dispar)andome a mi!" +// TR1 levels + , "Hogar de Lara" + , "Cuevas" + , "Ciudad de Vilcabamba" + , "El valle perdido" + , "Tumba de Qualopec" + , "San Francis Folly" + , "El coliseo" + , "Palacio de Midas" + , "La cisterna" + , "Tumba de Tihocan" + , "Ciudad de Khamoon" + , "Obelisco de Khamoon" + , "Santuario del Scion" + , "Minas de Natla" + , "Atl)antida" + , "La gran pir)amide" + , "Regreso a egipto" + , "Templo del gato" + , "Fortaleza atlante" + , "La colmena" +// TR2 levels + , "Hogar de Lara" + , "La Gran Muralla" + , "Venecia" + , "Escondite de Bartoli" + , "Casa de la )Opera" + , "Plataforma marina" + , "Zona de buceo" + , "40 Brazas" + , "Naufragio del Maria Doria" + , "Viviendas" + , "La Cubierta" + , "Estribaciones Tibetanas" + , "Monasterio Barkhang" + , "Catacumbas del Talion" + , "Palacio de hielo" + , "Templo de Xian" + , "Islas flotantes" + , "La Guarida del drag)on" + , "Hogar, dulce hogar" +// TR3 levels + , "Hogar de Lara" + , "Jungla" + , "Ruinas del templo" + , "El rio Ganges" + , "Cuevas de Kaliya" + , "Villa costera" + , "Lugar del accidente" + , "Madubu Gorge" + , "Templo de Puna" + , "Muelle Thames" + , "Aldwych" + , "La Entrada de Lud" + , "Ciudad" + , "Desierto de Nevada" + , "Complejo de Alta Seguridad" + , "Area 51" + , "Antarctica" + , "Minas RX-Tech" + , "La Ciudad perdida de Tinnos" + , "Caverna del meteorito" + , "Todos los santos" +}; + +#endif diff --git a/src/lang/fi.h b/src/lang/fi.h new file mode 100644 index 00000000..fc326e38 --- /dev/null +++ b/src/lang/fi.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_FI +#define H_LANG_FI + +// Thanks: Parnooo + +const char *STR_FI[] = { "Suomi" +// help + , "Ladataan..." + , "Paina H n~ahd~aksesi lis~atietoja" + , helpText + , "%s@@@" + "TAPOT %d@@" + "POIMITUT ESINEET %d@@" + "L~OYDETYT AARTEET%d of %d@@" + "AIKAA KULUNUT %s" + , "Tallennetaan..." + , "Tallennettu!" + , "Virhe Tallentaessa!" + , "Kyll~a" + , "Ei" + , "Off" + , "On" + , "Off" + , "Side-By-Side" + , "Anaglyph" + , "Jaettu Ruutu" + , "VR" + , "Alhainen" + , "Keskitaso" + , "Korkea" + , STR_LANGUAGES + , "K~ayt~a" + , "Ohjain 1" + , "Ohjain 2" + , "Ohjain 3" + , "Ohjain 4" + , "Ei Valmiina" + , "Pelaaja 1" + , "Pelaaja 2" + , "Paina Mit~a tahansa" + , "%s - Valitse" + , "%s - Takaisin" +// inventory pages + , "Asetukset" + , "Tavaraluettelo" + , "Esineet" +// save game page + , "Tallenna Peli?" + , "Nykyinen Sijainti" +// inventory option + , "Peli" + , "Kartta" + , "Kompassi" + , "Statsit" + , "Laran Koti" + , "Grafiikka" + , "~A~Anet" + , "N~app~aimet" + , "Gamma" +// passport menu + , "Lataa Peli" + , "Uusi Peli" + , "Kent~an Alkuun" + , "P~a~avalikkoon" + , "Poistu Pelist~a" + , "Valitse Kentt~a" +// detail options + , "N~ayt~on Asetukset" + , "Pehmennys" + , "Valaistus" + , "Varjot" + , "Vesi" + , "VSync" + , "Stereo" + , "Litte~at Esineet" + , "Resolution" + , STR_SCALE +// sound options + , "~A~anenvoimakkus" + , "Kaikueffekti" + , "Tekstitykset" + , "Kieli" +// controls options + , "N~app~aimet" + , "N~app~aimist~o" + , "Ohjain" + , "V~arin~a" + , "Uudelleent~aht~ays" + , "Multi-T~aht~ays" + // controls + , "Vasen", "Oikea", "Juoksu", "Taaksep~ain", "Hypp~a~a", "K~avely", "Toiminto", "Aseet Esiin", "Katso", "Konttaa", "Rynt~ays", "Kier~ahd~a", "Tavaraluettelo", "Aloita" + , STR_KEYS +// inventory items + , "Tuntematon" + , "R~aj~ahde" + , "Pistoolit" + , "Haulikko" + , "Magnumit" + , "Uzit" + , "Pistoolin Panokset" + , "Haulikon Panokset" + , "Magnumin Panokset" + , "Uzin Panokset" + , "Pieni Ensiapupakkaus" + , "Suuri Ensiapupakkaus" + , "Lyijyharkko" + , "Scion" +// keys + , "Avain" + , "Hopeinen Avain" + , "Ruosteinen Avain" + , "Kultainen Avain" + , "Safiiriavain" + , "Neptunen Avain" + , "Atlaksen Avain" + , "Damoklesin Avain" + , "Thorin Avain" + , "Koristeellinen Avain" +// puzzles + , "Pulma" + , "Kultainen Idoli" + , "Kultaharkko" + , "hammasratas" + , "Sulake" + , "Ankh" + , "Horuksen Silm~a" + , "Anubiksen Sinetti" + , "Pillerinpy~oritt~aj~a" + , "Pyramidiavain" +// TR1 subtitles + /* CAFE */ , + "[43500]Mit~a miehen t~aytyisik~a~an tehd~a@saadakseen t~all~aist~a huomiota sinulta?" + "[47500]Vaikea sanoa tarkalleen,@Mutta sait huomioni." + "[50000]Hienoa, Mutta se en ole@min~a joka kaipaa huomiotasi." + "[54500]Etk~o?" + "[55000]En, vaan neiti Jacqueline Natla,@Natla Technologiesta." + "[59000]Tied~ath~an, kaiken@kirkkaan ja valoisan luoja." + "[64500]Riitt~a~a jo, Larson." + "[66000]Kyll~a rouva." + "[68000]Katsopa t~at~a, Lara." + "[70500]Saako t~am~a lompakkosi tutisemaan?" + "[73500]Olen pahoillani, teen t~at~a rakkaudesta lajiin." + "[76000]Sitten tykk~a~at t~ast~a." + "[78000]Peru. Valtavien vuorien peitt~am~a.@Pystysuoria j~a~aseini~a. Vaarallisia kalliota ja raivokkaita tuulia." + "[87500]Ja siell~a on t~am~a pikku hely:@Muinainen artefakti mystisill~a voimilla" + "[92500]Hautautuneena sinet~oityyn Qualopecin hautaan." + "[96000]Sen min~a haluan." + "[98000]Voisit l~ahte~a huomenna.@Oletko kiireinen huomenna?" + /* LIFT */ , + "[49000]Sen j~alkeen kun minut siirrettiin St. Francis' Follyyn,@Uudet kiusaukset ovat piinanneet minua." + "[53500]Kanssaveljieni keskuudessa huhutaan ett~a@luostarimme alla sijaitsisi Tihocanin hauta," + "[60000]Yksi kolmesta legendaarisesta@Kadonneen Atlantiksen hallitsijasta," + "[64500]Ja ett~a h~anet olisi haudattu@ Atlantiksen Scionin palasen kanssa." + "[68000]Riipus, jonka kolme hallitsijaa jakoivat@" + "[72500]joka k~atkee sis~a~ans~a@Luojiaankin mahtavammat voimat." + "[79000]Varpaani hikoilevat ajatuksesta@ett~a tuo riipus olisi niin l~ahell~a kuolevaista kehoani" + "[85500]joka ikinen y~o lev~atess~ani, Yrit~an hillit~a@fantasioitani, mutta se on todellinen haaste." + "[92000]" + "[93500]Pierre. Tsk. Senkin t~orkimys." + /* CANYON */ , + "[13500]Onnesi loppuu t~ah~an paikkaan." + "[16500]P~aivi~a." + "[17500]Iltaap~aiv~a~a." + "[20000]J~atit sitten Larsonin nuolemaan tuulta?" + "[22500]Jos sen voisi noin sanoa." + "[24000]No, pikku lomakapinasi on ohi nyt." + "[27000]Aika antaa takaisin mit~a varastit minulta." + "[30000]Etsit~a~an ev~aslootasta." + "[32000]" + "[42500]Mit~a odotatte? Tappakaa h~anet!" + "[45000]Hei!" + "[48000]" + "[50500]Senkin idiootit!" + "[53000]" + "[62500]Menn~a~an." + "[65000]" + "[136000]Mik~a hitto se oli?" + "[138000]Mik~a?" + "[138500]Tuo." + "[140500]Luultavasti vain kala." + "[142500]Hitonmoinen kalaksi." + "[145000]Sinun t~aytyy oppia rentoutumaan.@Menen takaisin sis~alle. Tuletko sin~a?" + "[152000]" + "[158000]N-y-t..." + "[160000]Siell~a h~an menee." + "[161500]Oletko valmiina jo?" + /* PRISON */ , + "[00001]Ette voi tehd~a t~at~a!" + "[01500]Me tuomitsemme sinut, Atlantiksen Natla, Rikoksistasi." + "[06000]Vakavasta voimiesi v~a~arink~ayt~ost~a@Ja voimiemme varastamisesta." + "[11500]Ette voi! Min~a..." + "[12500]Rikkeest~asi vapaata tahtoa kohtaan,@johon ihmiset ovat m~a~ar~attyj~a ja turvattuja," + "[18500]ja hy~okk~ayksest~asi Tihocania ja minua vastaan omalla armeijallamme." + "[23500]Omat sotilaamme tyhjensiv~at pyramidimme" + "[27000]jotta voisit k~aytt~a~a sit~a - sen luomisvoimaa@ - sinun j~arjett~om~a~an tuhoamishaluusi." + "[33500]J~arjett~om~a~an!? Katsokaa itse~anne!" + "[35500]Kumallakaan teist~a ei ole@j~arjen pisaraakaan p~a~ass~anne." + "[40500]Tyhj~antoimittajat!" + "[41500]Mit~a en~a~a odotamme?" + "[44000]Tihocan!" + "[45000]K~aytit pyh~a~a paikkaasi@omaan nautintoosi," + "[49500]kuin jotain friikkilaitosta." + "[51000]He ovat selvi~ytyji~a. Uusi sukupolvi." + "[54000]Kasa ruumita en~a~a." + "[56000]Ja sin~a. Aiomme lukita sinut ikuiseen kadotukseen." + "[60000]Aiomme saada suonesi, syd~amesi, jalkasi" + "[64000]ja sairaat aivosi virtaamaan j~a~atynytt~a verta." + "[70000]Kohtaa ikuinen levottomuutesi, Natla." + "[73000]Teist~a kumpikaan ei tule lep~a~amaan,@Tai teid~an kirottu Atlantiksenne!" + /* 22 */ , + "[04000]Sin~a taas?" + "[05500]Sin~a my~os - Suureen uudelleenavajaiseenko?" + "[09500]Evoluutio polkee paikoillaan - Luonnonvalinta pohjamudissa..." + "[13500]Uusi liha toisi hieman vauhtia siihen " + "[17500] - se voimistaisi meit~a ja kehitt~aisi meit~a..." + "[20500]se jopa loisi uusia rotuja." + "[22500]V~ah~an kuin evoluutiosteroidi sitten, vai?" + "[24500]Isku vasten kasvoja niille idiooteille...@Qualopecill~a ja Tihocanilla ei ollut aavistustakaan" + "[29500] - Atlantiksen vedenpaisumus iski nynnyjen rotuun..." + "[33500]ja sy~oksi heid~at takaisin luolamiesten tasolle..." + "[37000]Sen ei olisi pit~anyt menn~a niin." + "[39000]Tai n~ain." + "[40000]Kuoriutuminen alkaa 15 sekunnin p~a~ast~a." + "[43000]Liian my~ohaista perua en~a~a!" + "[45000]Ei ilman operaation syd~ant~a!" + "[47000]EI!" + "[50000]KYMMENEN" + "[54000]VIISI..." + "[55500]NELJ~A...KOLME...KAKSI..." + "[60000]YKSI..." + /* 23 */ , + "[00001]No mutta nyt olet saanut kaiken huomioni." + "[02500]En vain ole ihan varma mit~a ajat takaa" + "[05000]Antaa kuulua" + "[06000]Odotahan vain kun p~a~asen k~asiksi sinuun..." + "[09000]Tietty" + "[10000]Sin~a ja se typer~a Scionin palanen." + "[13000]Jos haluat pit~a~a sen niin kovasti, voin ty~ont~a~a sen suor..." + "[17000]Hetkinen... Puhummeko nyt siit~a artefaktista?" + "[20000]Totta hitossa puhutaan ... suoraan per..." + "[22000]Hetkinen - Anteeksi" + "[24000]Tuo pala, josta puhut - miss~a loput ovat?" + "[26500]Neiti Natla m~a~ar~asi Pierre Dupontin niiden j~aljille." + "[29500]Ja miss~a nuo j~aljet ovat?" + "[30500]Hah. Et ikin~a saisi h~ant~a kiinni." + "[34000]Luuletko ett~a t~am~a pikku keskustelumme hidastaisi minua ?" + "[37000]En tied~a minne h~anen pikku j~anis-sammakko-k~ap~al~ans~a h~ant~a viev~at" + "[42000]Sinun t~aytyy kysy~a Neiti Natlalta" + "[46000]" + "[51000]Kiitos. Min~ap~a kysyn." + /* 24 */ , "" + /* 25 */ , + "[03500]T~ass~a lep~a~a Tihocan" + "[05000]...Yksi kahdesta Atlantiksen oikeudenmukaisesta hallitsijasta..." + "[10000]...Joka jopa Atlantiksen kirouksen j~alkeen..." + "[13000]...Yritti yll~apit~a~a j~arjestyst~a t~a~all~a karussa ulkomaailmassa..." + "[19000]H~an kuoli ilman lasta eik~a h~anen viisauksillaan ei ole perillist~a..." + "[25500]Huolehdi meist~a tuonpuoleisesta, Tihocan." + /* 26 */ , "Tevetuloa kotiini!@Voin esitell~a paikkoja." + /* 27 */ , "K~ayt~a nuolin~app~aimia p~a~ast~aksesi musiikkihuoneeseen." + /* 28 */ , "OK. Kokeillaan hieman voimestella.@Paina hyppyn~appaint~a." + /* 29 */ , "Nyt paina uudelleen hyppyn~appaint~a mit~a tahansa@nuolin~app~aint~a, niin hypp~a~an siihen suuntaan" + /* 30 */ , "Ah, Eteisaulani. Anteeksi laatikot. Minulla on tavaraa@viet~av~an~a varastoon eik~a kuljetusfirma ole viel~a k~aynyt." + /* 31 */ , "Juokse laatikolle, ja sen edess~a k~avele eteenp~ain@Paina toimintan~app~aint~a, niin kiipe~an sen p~a~alle." + /* 32 */ , "T~am~a oli ennen tanssisali, mutta muutin sen kuntosalikseni.@Pid~atk~o siit~a? kuntoillaanpa hieman." + /* 33 */ , "Itseasiassa en juokse kaikkialle, kun olen varovainen,@ Paina k~avelyn~app~aint~a ja k~avele valkoiselle viivalle." + /* 34 */ , "Kun k~avelen, en voi pudota, vaikka yritt~aisit.@Anna menn~a, kokeile." + /* 35 */ , "Jos haluat katsoa ymp~arillesi, Paina katsomisn~app~aint~a .@sen j~alkeen valitse suunta johon haluat katsoa." + /* 36 */ , "Jos hyppy on liian pitk~a minulle, voin tarttua reunasta.@K~avele niin pitk~alle valkoista reunaa kohti kuin voit.@Paina sitten hyppyn~appaint~a ja kun olen ilmassa@paina ja pid~a pohjassa toimintan~app~aint~a." + /* 37 */ , "Paina eteenp~ain niin nousen yl~os." + /* 38 */ , "Jos juoksen ja sitten hypp~a~an, tuollaiset hypyt eiv~at ole ongelma." + /* 39 */ , "K~avele niin pitk~alle valkoista viivaa kohti, kunnes pys~ahdyn.@sen j~alkeen paina taaksep~ain ja juokse.@Paina eteenp~ain ja paina sen j~alkeen heti hyppyn~appaint~a pohjaan.@hypp~a~an vasta viimetingassa." + /* 40 */ , "Noin. Seuraava hyppy on todella iso.@Tee samoin kuin viimeksi, mutta t~all~a kertaa@paina toimintan~app~aint~a ilmassa, jotta nappaan reunasta." + /* 41 */ , "Hienoa." + /* 42 */ , "Yrit~a kiivet~a t~ast~a.@Paina eteenp~ain ja pid~a pohjassa toimintan~app~aint~a." + /* 43 */ , "En voi kiivet~a koska v~ali on liian ahdas,@mutta paina oikealle niin kipuan sivusuuntaan@kunnes on tilaa kiivet~a, Paina sitten eteenp~ain." + /* 44 */ , "Hienoa!@jos pudotus on korkea enk~a halua@satuttaa itse~ani pudotuksessa, voin laskeutua varovasti" + /* 45 */ , "Paina taaksep~ain, niin hypp~a~an taakse.@Paina sen j~alkeen heti toimintan~app~aint~a pohjaan,@niin nappaan reunasta kiinni pudotessani." + /* 46 */ , "Sitten menn~a~an." + /* 47 */ , "Menn~a~an uimaan." + /* 48 */ , "Hyppyn~app~aimell~a sukellan ja nuolin~app~aimet@liikuttavat minua veden alla." + /* 49 */ , "Ah! Ilmaa.@K~ayt~a nuolin~app~aimi~a@liikuttaaksesi minua pinnalla.@Paina hyppyn~appaint~a jos haluat sukeltaa uudestaan.@Tai mene reunalle ja paina toimintan~app~aint~a jos haluat maalle." + /* 50 */ , "Noin. Parempi vaihtaa m~ar~at vaatteet." + /* 51 */ , "Sano Juusto!" + /* 52 */ , "Ei mit~a~an henkil~okohtaista." + /* 53 */ , "Aivoni s~arkev~at edelleen takiasi.@Ja ne antavat hauskoja ideoita nyt,@Kuten sinun ampumisesi helvettiin!" + /* 54 */ , "Et p~a~ase minusta ja laumaastani eroon niin helposti, Lara." + /* 55 */ , "Hieman my~oh~ass~a palkintojen jakoon - eik~o?@Silti, se on se osallistuminen, joka merkitsee." + /* 56 */ , "Ammutko minua?@Sin~a ammut minua?@T~a~all~a ei ole muita, Joten sen t~aytyy olla sin~a!" +// TR1 levels + , "Laran Koti" + , "Luolasto" + , "Vilcabamban Kaupunki" + , "Kadonnut Laakso" + , "Qualopecin Hauta " + , "St. Francis' Folly" + , "Colosseum" + , "Midaan Palatsi" + , "Sadevesis~aili~o" + , "Tihocanin Hauta" + , "Khamoonin Kaupunki" + , "Khamoonin Obeliski" + , "Scionin Pyh~akk~o" + , "Natlan Kaivokset" + , "Atlantis" + , "Suuri Pyramidi" + , "Paluu Egyptiin" + , "Kissan Temppeli" + , "Atlantiksen Linnake" + , "Pes~a" +// TR2 levels + , "Laran Koti" + , "Kiinan Muuri" + , "Venetsia" + , "Bartolin Piilopaikka" + , "Oopperatalo" + , "~oljynporauslautta" + , "Sukellusalue" + , "40 Sylt~a" + , "Maria Dorian Hylky" + , "Asuinhytit" + , "Kannella" + , "Tiibetin Juurella" + , "Barkhangin Luostari" + , "Talionin Katakombi" + , "J~a~apalatsi" + , "Xianin Temppeli" + , "Leijuvat Saaret" + , "Lohik~a~armeen Pes~a" + , "Koti Kullan Kallis" +// TR3 levels + , "Laran Koti" + , "Viidakko" + , "Temppelin Rauniot" + , "Ganges" + , "Kaliyan Luolat" + , "Kyl~a Rannalla" + , "Putoamispaikka" + , "Madubun Rotko" + , "Punan Temppeli" + , "Thamesin Laituri" + , "Aldwych" + , "Ludin Portti" + , "Kaupunki" + , "Nevadan Aavikko" + , "Tiukasti Vartioitu Vankileiri" + , "Area 51" + , "Antarktis" + , "RX-Techin Kaivokset" + , "Tinnosin Kadonnut Kaupunki" + , "Meteoriittiluola" + , "All Hallows" +}; + +#endif diff --git a/src/lang/fr.h b/src/lang/fr.h new file mode 100644 index 00000000..a14d4d9c --- /dev/null +++ b/src/lang/fr.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_FR +#define H_LANG_FR + +// Thanks: Zellphie, Laripette + +const char *STR_FR[] = { "" +// help + , "Chargement..." + , "Appuyez sur H pour afficher l'aide" + , helpText + , "%s@@@" + "ENNEMIS TU)ES %d@@" + "OBJETS TROUVES %d@@" + "SECRETS %d / %d@@" + "TEMPS %s" + , "Sauvegarde..." + , "Sauvegarde achev)ee!" + , "SAUVER ERREUR!" + , "OUI" + , "NON" + , "Arret" + , "Marche" + , "Arret" + , "Side-By-Side" + , "Anaglyphe" + , ")Ecran Divis)e" + , "VR" + , "Bas" + , "Moyen" + , "Haut" + , STR_LANGUAGES + , "Appliquer" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Not Ready" + , "Joueur 1" + , "Joueur 2" + , "Appuyez sur une touche" + , "%s - Choisir" + , "%s - Retour" +// inventory pages + , "OPTIONS" + , "INVENTAIRE" + , "OBJETS" +// save game page + , "Sauver le jeu?" + , "Charger Partie" +// inventory option + , "Jeu" + , "Carte" + , "Boussole" + , "Statistiques" + , "Manoir de Lara" + , "Niveau des D)etails" + , "Sons" + , "Controles" + , "Gamma" +// passport menu + , "Charger" + , "Commencer" + , "Rejouer Niveau" + , "Sortie vers titre" + , "Quitter" + , "Choisir Niveau" +// detail options + , "Niveau de D)etail" + , "Filtration" + , ")Eclairage" + , "Ombres" + , "Eau" + , "VSync" + , "St)er)eo" + , "Objets Simples" + , "Resolution" + , STR_SCALE +// sound options + , "R)egler Volume" + , "R)everb)eration" + , "Sous-titres" + , "Langue" +// controls options + , "R)egler Controles" + , "Clavier" + , "Gamepad" + , "Vibration" + , "Reciblage" + , "Multi-vis)ee" + // controls + , "Gauche", "Droite", "Courir", "Arri$ere", "Sauter", "Marcher", "Action", "D)egainer", "Regarder", "Duck", "Dash", "Roulade", "Inventaire", "Start" + , STR_KEYS +// inventory items + , "Inconnu" + , "Explosif" + , "Pistolets" + , "Fusil $a pompe" + , "Magnums" + , "Uzis" + , "Balles de pistolet" + , "Cartouches de fusil" + , "Balles de magnum" + , "Balles d'uzi" + , "Mini m)edikit" + , "Grand m)edikit" + , "Barre en plomb" + , "Scion" +// keys + , "Cl)e" + , "Cl)e d'argent" + , "Cl)e rouill)ee" + , "Cl)e en or" + , "Cl)e de saphir" + , "Cl)e Neptune" + , "Cl)e d'Atlas" + , "Cl)e Damocl$es" + , "Cl)e de Thor" + , "Cl)e Ornement)ee" +// puzzles + , "Puzzle" + , "Idole d'or" + , "Lingot d'or" + , "Engrenage" + , "Fusible" + , "Ankh" + , "Oeil d'Horus" + , "Sceau d'Anubis" + , "Scarab)ee" + , "Cl)e pyramide" +// TR1 subtitles + /* CAFE */ , + "[43500]Qu'est-ce qu'un mec peut bien faire pour r)eussir $a attirer votre attention?" + "[47500] Je ne sais pas exactement, mais vous vous d)ebrouillez plut(ot bien." + "[50500]Super! Mais en fait, c'est pas moi qui vous cherche." + "[54500]Oh?" + "[55000]Non. C'est Jacqueline Natla, de Natla Technologies, vous voyez?" + "[59000]Ceux qui font tout ce qui est beau et qui brille." + "[64500]La ferme, Larson." + "[66000]M'dame." + "[68000]Jetez un coup d'oeil ici, Lara." + "[70500]Quel effet |ca vous fait de voir |ca?" + "[73500]Je suis d)esol)ee, je fais |ca pour le sport." + "[76000]Alors, vous allez adorer le P)erou." + "[78000]D'immenses montagnes $a franchir,@des falaises de glace. Les cr(etes, les vents glac)es." + "[87500]Et il y a ce petit bibelot, un objet mill)enaire au pouvoir myst)erieux," + "[92500]enfoui dans le tombeau perdu de Qualopec." + "[96000]Et il m'int)eresse..." + "[98000]Partez donc d$es demain. Vous (etes libre demain?" + /* LIFT */ , + "[49000]Je suis maintenant ici, $a Saint Francis, et d'autres tentations me tourmentent." + "[53500]Une rumeur parmi mes fr$eres pr)etend que,@sous notre monast$ere, repose le corps de Tihocan," + "[60000]un des trois monarques l)egendaires du continent perdu d'Atlantide," + "[64500]et qu'il a gard)e son fragment du Scion des Atlantes." + "[68000]le pendentif divis)e partag)e entre trois souverains," + "[72500]dont les pouvoirs sont si immenses.@bien plus immenses que ceux du Cr)eateur." + "[79000]Je suis baign)e de sueur en l'imaginant@si proche de ma d)epouille mortelle." + "[85500]Chaque nuit, je me flagelle pour chasser ces@fantasmes mais je sais que c'est une )epreuve." + "[92000]" + "[93800]Pierre, sale pollueur!" + /* CANYON */ , + "[13500]Je crois que vous venez de gagner le gros lot." + "[16500]Waouh!" + "[17500]Salut!" + "[20000]Larson est dans les choux, alors?" + "[22500]On peut le dire comme |ca." + "[24000]Bon, alors maintenant, on arr(ete de jouer." + "[27000]Vous allez me rendre ce qui m'appartient." + "[30000]Voyons dans le sac." + "[32000]" + "[42500]Et alors? Tuez-la!" + "[45000]H)e!" + "[48000]" + "[50500]Bande d'idiots!" + "[53000]" + "[62500]Allons-y!" + "[65000]" + "[136000]Qu'est-ce que c')etait que |ca?" + "[138000]Quoi?" + "[138500]Par l$a-bas..." + "[140500]Probablement un poisson." + "[142500]Un sacr)e poisson alors, fiston..." + "[145000]Allez, d)ecrispe-toi, mec.@Bon, j'y retourne! Allez, tu viens?" + "[152000]" + "[158000]Doucement..." + "[160000]La voil$a!" + "[161500]On peut y aller?" + /* PRISON */ , + "[00001]Vous n'avez pas le droit!" + "[01500]Nous te condamnons, Natla d'Atlantide, pour tes crimes." + "[06000]Pour avoir tr$es mal utilis)e tes pouvoirs@et nous avoir vol)e les n(otres." + "[11500]Arr(etez ! Je..." + "[12500]Pour avoir bris)e le triple sceau@qui dirige et prot$ege notre peuple," + "[17000]et nous avoir envahis avec notre arm)ee" + "[21000]nos guerriers, ceux de nos pyramides" + "[24500]pour pouvoir te servir de la pyramide,@du pouvoir de la cr)eation, pour semer ton ignoble destruction." + "[33500]Ignoble? Regardez-vous!" + "[35500]aucun de vous n'a la moindre parcelle de@cr)eativit)e dans la t(ete." + "[40500]Vieux fous!" + "[41500]Bien. Allons-y." + "[44000]Tihocan!" + "[45000]Tu as profan)e un lieu sacr)e pour satisfaire@ton seul plaisir," + "[49500]un atelier de monstres." + "[51000]Ce sont des survivants, une nouvelle g)en)eration!" + "[54000]Un troupeau $a abattre!" + "[56500]Et toi, nous t'enfermerons dans le n)eant." + "[61500]Dans tes veines, ton coeur immonde et ton cerveau malade," + "[66000]ton sang gel)e ne coulera plus." + "[70000]Tu ne conna(itras plus le repos, Natla!" + "[73000]Mais toi non plus, ni ton maudit continent d'Atlantide!" + /* 22 */ , + "[04000]Vous revoil$a?" + "[05500]Comme vous, pour la grand r)e-ouverture je pr)esume." + "[09000]L')evolution s'enlise la s)el)ection naturelle est plus lente que jamais," + "[13500]et cette chair bien fra(iche r)eveillera les haines ancestrales et cruelles," + "[17500]nous donnant force et conviction," + "[20500]et m(eme de nouvelles races." + "[22500]Une )evolution gr(ace aux st)ero~ides, en fait." + "[24500]Un bon coup de fouet. Ces idiots de Qualopec et Tihocan sont des ignares." + "[29500]Le cataclysme de l'Atlantide a engendr)e une race de mauviettes," + "[33500]les ramenant au stade primitif de la simple survie." + "[37000]|ca n'aurait jamais d(u arriver." + "[39000]Moi j'arrive." + "[40000]L')eclosion commence dans 15 secondes." + "[43000]Trop tard pour un avortement!" + "[45000]Pas sans le coeur de l'op)eration!" + "[47000]Noooon!" + "[49500]10..." + "[54000]5..." + "[55000]4...3...2..." + "[60000]1..." + /* 23 */ , + "[00001]Bon, vous avez mon attention maintenant," + "[02000]mais je ne sais pas si j'ai la v(otre." + "[05000]Allez!" + "[06000]Je vais vous en faire bouffer de l'avoine, moi." + "[09000]Mais oui..." + "[10000]Vous, et ce satan)e morceau de Scion." + "[13000]Si vous y tenez tant que |ca, je vais vous l'coller dans le.." + "[17000]Attendez. Vous parlez de l'artefact, l$a?" + "[19500]Un peu, mon n'veu! J'vais vous le..." + "[22000]Oh l$a! Du calme!" + "[24000]Un morceau, vous disiez. O$u est le reste?" + "[26500]Miss Natla a mis Pierre DuPont sur l'affaire." + "[29500]A quel endroit?" + "[30500]Ha! Vous n'(etes pas assez rapide pour lui!" + "[33500]Donc je perds du temps $a discuter avec vous ici?" + "[37000]Moi je ne sais pas du tout o$u il court,@avec ses petites pattes de pied tendre." + "[42000]Allez demander $a Miss Natla." + "[46000]" + "[50500]Merci! Je vais..." + /* 24 */ , "" + /* 25 */ , + "[03500]Ci-g(it Tihocan..." + "[05500]... un des deux souverains justes de l'Atlantide..." + "[10000]qui m(eme apr$es le malheur de ce continent..." + "[13000]... tent$erent de r)egner encore sur ces terres d)esol)ees." + "[19000]Mort sans un h)eritier, son savoir n'a point d'h)eritage." + "[25500]Veillez sur nous, Tihocan." + /* 26 */ , "Bienvenue chez moi! je vais vous faire visiter." + /* 27 */ , "Utilisez les touches fl)ech)ees pour@aller dans le salon de musique." + /* 28 */ , "OK. On va bouger un peu.@Appuyez sur la touche de saut." + /* 29 */ , "Recommencez en appuyant sur une touche fl)ech)ee@et je sauterai dans cette direction." + /* 30 */ , "Oh! Voici le grand hall!@Excusez le d)esordre, mais je veux tout envoyer au garde-meuble@et les d)em)enageurs ne sont toujours pas arriv)es." + /* 31 */ , "Courez vers une caisse et appuyez@en m(eme temps sur la touche fl)ech)ee haut et la touche d'action@je sauterai dessus." + /* 32 */ , "C')etait autrefois la salle de bal,@mais je l'ai transform)ee en salle de gym personnelle.@C'est chouette, non?@Allez, un peu d'exercice." + /* 33 */ , "Je ne cours pas sans arr(et dans ce jeu en fait.@Quand je dois (etre prudente, je peux aussi marcher.@Appuyez sur la touche de marche et avancez@jusqu'$a la ligne blanche." + /* 34 */ , "Si vous appuyez encore sur la touche de marche,@je ne tomberai pas, m(eme si vous insistez.@Allez-y, essayez!" + /* 35 */ , "Si vous voulez examiner les environs,@appuyez sur la touche qui vous permet de voir.@Puis sur une touche de direction." + /* 36 */ , "Si je ne peux pas sauter assez loin, je peux toujours me rattraper@de justesse pour ne pas tomber. Avancez vers la ligne blanche@jusqu'$a ce que je m'arr(ete de moi-m(eme,@ensuite appuyez sur la touche de saut et tout de suite apr$es@sur la touche fl)ech)ee haut, et maintenez la touche d'action enfonc)ee pendant que je saute." + /* 37 */ , "Appuyez sur la touche fl)ech)ee haut pour me faire grimper." + /* 38 */ , "Si je prends de l')elan, je peux sauter |ca sans probl$eme!" + /* 39 */ , "Avancez jusqu'$a la ligne blanche, jusqu'$a ce que je m'arr(ete,@et appuyez sur la touche de marche puis sur la touche fl)ech)ee bas pour que je prenne de l')elan.@Appuyez ensuite sur la touche fl)ech)ee haut et sur la touche de saut tout de suite apr$es.@Mais en fait, je ne sauterai qu'au dernier moment, je ne suis pas folle!" + /* 40 */ , "L$a, c'est plus difficile.@Nous allons refaire exactement le m(eme saut, mais@vous maintiendrez la touche d'action enfonc)ee@pour que je me rattrape en catastrophe@Quand je serai en l'air." + /* 41 */ , "Bien jou)e!" + /* 42 */ , "Nous allons essayer de sauter ici.@Appuyez sur la touche fl)ech)ee haut puis sur la touche d'action sans la rel(acher." + /* 43 */ , "Je n'ai pas la place de grimper i|ci, mais si vous appuyez sur la touche@fl)ech)ee droite je longerai la corniche pour trouver un passage@ et vous n'aurez plus qu'$a appuyer sur la touche fl)ech)ee haut $a ce moment l$a." + /* 44 */ , "Super!@Si je me retrouve trop haut je peux me laisser@glisser doucement, pour )eviter de me blesser en sautant." + /* 45 */ , "Appuyez sur la touche fl)ech)ee bas pour que je me laisse tomber@ensuite si vous gardez la touche d'action enfonc)ee@je me rattraperai dans ma chute." + /* 46 */ , "Ensuite laissez aller." + /* 47 */ , "Et maintenant un bon bain!" + /* 48 */ , "La touche de saut et les touches de direction@me permettent d')evoluer sous l'eau." + /* 49 */ , "Oh! Ah! De l'air!@Utilisez les touches fl)ech)ees avant, gauche et droite pour me faire nager en surface.@Appuyez sur la touche de saut pour me faire plonger et nager sous l'eau.@Pour me faire sortir, dirigez-vous vers le bord et appuyez sur la touche d'action." + /* 50 */ , "Super. Bon je ferais mieux d'enlever ces v(etements mouill)es." + /* 51 */ , "Un petit sourire!" + /* 52 */ , "Ca n'a rien de personel." + /* 53 */ , "J'ai encore mal au cr(ane $a cause de toi. Et j'entends des petites voix dans ma t(ete.@Elles me disent de te tuer!" + /* 54 */ , "Vous n'allez pas m')eliminer pas avec ma race aussi facilement Lara!" + /* 55 */ , "Un peu tard pour la remise des prix non?@Ah... L'essentiel, c'est de participer? mais me voici maintenant devant un horrible dilemme!@C'est bien dommage, mais c'est la vie." + /* 56 */ , "C'EST SUR MOI QUE TU TIRES?! C'EST SUR MOI QUE TU TIRES?! @BAH OUI Y'A PERSONNE! @C'EST SUR MOI QUE TU TIRES!!" +// TR1 levels + , "Manoir de Lara" + , "Cavernes" + , "Cit)ee de Vilcabamba" + , "Vall)ee Perdue" + , "Tombe de Qualopec" + , "Monument St. Francis" + , "Colosseum" + , "Palais de Midas" + , "La Citerne" + , "Tombe de Tihocan" + , "Cit)ee de Khamoon" + , "Ob)elisque de Khamoon" + , "Sanctuaire du Scion" + , "Mines de Natla" + , "Atlantide" + , "La Grande Pyramide" + , "Retour en Egypte" + , "Temple du Chat" + , "La Forteresse Atlantique" + , "La Ruche" +// TR2 levels + , "La Demeure de Lara" + , "La Grande Muraille" + , "Venise" + , "La Cache de Bartoli" + , "L'Op)era" + , "La plate-forme p)etroli(ere" + , "L'aire de plongeon" + , "Par 40 brasses de fond" + , "L')epave du Maria Doria" + , "Les Quartiers d')equipage" + , "Le pont" + , "Les collines tib)etaines" + , "Monast(ere de Barkhang" + , "Les Catacombes du Talion" + , "Le Palais des Glaces" + , "Le Temple de Xian" + , "Les ÃŽles du Ciel" + , "L'Antre du Dragon" + , "Home Sweet Home" +// TR3 levels + , "La Demeure de Lara" + , "La Jungle" + , "Les Ruines du Temple" + , "Le Gange" + , "Les Grottes de Kaliya" + , "Le Village Côtier" + , "Le Lieu du Crash" + , "La Gorge de Madubu" + , "Le Temple de Puna" + , "Les Quais de la Tamise" + , "Aldwych" + , "Le Portail du Lude" + , "La Ville" + , "Le Désert du Nevada" + , "Quartier de Haute Sécurit)e" + , "La Zone 51" + , "L'Antarctique" + , "Les Mines de RX-Tech" + , "La Cité Perdu de Tinos" + , "La Caverne du M)etéore" + , "L')Eglise Hallows" +}; + +#endif diff --git a/src/lang/glyph_cn.bmp b/src/lang/glyph_cn.bmp new file mode 100644 index 00000000..076b3f38 Binary files /dev/null and b/src/lang/glyph_cn.bmp differ diff --git a/src/lang/glyph_cn.h b/src/lang/glyph_cn.h new file mode 100644 index 00000000..5e98d234 --- /dev/null +++ b/src/lang/glyph_cn.h @@ -0,0 +1,1676 @@ +#ifndef __GLYPH_CN__ +#define __GLYPH_CN__ + +static unsigned int size_GLYPH_CN = 26686; +static unsigned char GLYPH_CN[] = { + 0x42, 0x4d, 0x3e, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x04, 0x0c, + 0x44, 0x04, 0x1f, 0xf0, 0x58, 0x84, 0x08, 0x84, 0x43, 0xfc, 0x04, 0xac, 0x08, 0xf0, 0x16, 0x1c, + 0x60, 0xfc, 0x0c, 0xb4, 0x3c, 0x20, 0x00, 0x00, 0x7f, 0xfc, 0x78, 0x0c, 0x7f, 0xfc, 0x04, 0x04, + 0x42, 0x08, 0x10, 0x10, 0x44, 0x88, 0x04, 0x48, 0x20, 0x10, 0x04, 0xa4, 0x05, 0x14, 0x11, 0x60, + 0x34, 0x84, 0x04, 0xbc, 0x24, 0x20, 0x00, 0x00, 0x11, 0x00, 0x0f, 0x30, 0x12, 0x90, 0x04, 0x04, + 0x21, 0x10, 0x1f, 0xf0, 0x24, 0x88, 0x62, 0x28, 0x24, 0x90, 0x04, 0xa4, 0x05, 0x44, 0x10, 0x80, + 0x1e, 0x84, 0x02, 0xe8, 0x24, 0x20, 0x00, 0x00, 0x11, 0x00, 0x08, 0x48, 0x12, 0x90, 0x04, 0x24, + 0x21, 0x10, 0x10, 0x10, 0x24, 0x90, 0x19, 0x28, 0x18, 0x88, 0x04, 0xa4, 0x48, 0x48, 0x11, 0x40, + 0x78, 0xa0, 0x47, 0xfc, 0x64, 0x20, 0x00, 0x00, 0x11, 0x00, 0x0f, 0xe0, 0x1f, 0xf0, 0x7f, 0xa4, + 0x10, 0xa0, 0x1f, 0xf0, 0x24, 0x90, 0x01, 0x50, 0x11, 0x08, 0x74, 0xa4, 0x78, 0x80, 0x52, 0x40, + 0x3c, 0xbc, 0x78, 0x40, 0x3d, 0xfc, 0x00, 0x00, 0x11, 0x00, 0x68, 0x2c, 0x00, 0x00, 0x04, 0x24, + 0x10, 0xa0, 0x00, 0x00, 0x24, 0x90, 0x78, 0x90, 0x10, 0x00, 0x57, 0xfc, 0x4b, 0xf8, 0x50, 0x40, + 0x24, 0xa4, 0x4b, 0xf8, 0x10, 0x20, 0x00, 0x00, 0x11, 0x00, 0x1f, 0xf0, 0x0f, 0xe0, 0x04, 0x24, + 0x07, 0xfc, 0x0a, 0x10, 0x25, 0xa8, 0x20, 0x90, 0x7d, 0xf8, 0x51, 0x00, 0x4b, 0x18, 0x33, 0xf8, + 0x26, 0xa4, 0x48, 0x40, 0x3c, 0x20, 0x00, 0x00, 0x11, 0x00, 0x64, 0x40, 0x08, 0x20, 0x3f, 0xa4, + 0x00, 0x48, 0x79, 0x10, 0x3c, 0x64, 0x10, 0x90, 0x11, 0x08, 0x50, 0x80, 0x4a, 0xa8, 0x3a, 0x48, + 0x25, 0xe4, 0x4b, 0xf8, 0x15, 0xfc, 0x00, 0x00, 0x11, 0xf8, 0x1a, 0x88, 0x0f, 0xe0, 0x04, 0x24, + 0x00, 0x48, 0x0e, 0x90, 0x22, 0x10, 0x08, 0x90, 0x11, 0x08, 0x57, 0xfc, 0x4a, 0x48, 0x13, 0xf8, + 0x34, 0xbc, 0x4a, 0x48, 0x14, 0x20, 0x00, 0x00, 0x11, 0x00, 0x15, 0x50, 0x00, 0x00, 0x15, 0x24, + 0x20, 0x48, 0x08, 0x90, 0x21, 0x00, 0x78, 0x90, 0x51, 0xf8, 0x50, 0x00, 0x4b, 0xf8, 0x12, 0x48, + 0x7c, 0xa8, 0x4a, 0xe8, 0x7e, 0x20, 0x00, 0x00, 0x01, 0x00, 0x62, 0x20, 0x67, 0xcc, 0x14, 0xa4, + 0x23, 0xf8, 0x7e, 0xfc, 0x7d, 0xfc, 0x24, 0x90, 0x3c, 0x00, 0x53, 0xf8, 0x4a, 0x48, 0x7b, 0xf8, + 0x10, 0xa0, 0x7b, 0x58, 0x15, 0xfc, 0xa0, 0x00, 0x01, 0x00, 0x3e, 0x50, 0x18, 0x30, 0x24, 0x84, + 0x40, 0x40, 0x28, 0x80, 0x10, 0x80, 0x24, 0x90, 0x20, 0x00, 0x72, 0x48, 0x7a, 0x08, 0x10, 0x40, + 0x10, 0xa0, 0x02, 0x48, 0x3c, 0x50, 0xa0, 0x00, 0x01, 0x00, 0x08, 0x08, 0x06, 0xc0, 0x04, 0x04, + 0x00, 0x40, 0x7e, 0xf0, 0x10, 0x80, 0x10, 0x90, 0x23, 0xfc, 0x02, 0x48, 0x03, 0xf8, 0x17, 0xfc, + 0x10, 0x20, 0x03, 0xf8, 0x00, 0x88, 0xa0, 0x00, 0x01, 0x00, 0x0e, 0xf8, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x10, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3c, + 0x47, 0xfc, 0x40, 0x3c, 0x78, 0x0c, 0x01, 0xf8, 0x30, 0xfc, 0x60, 0xfc, 0x60, 0x3c, 0x48, 0x3c, + 0x60, 0xfc, 0x7f, 0xfc, 0x08, 0x00, 0x37, 0x1c, 0x11, 0x08, 0x0f, 0xfc, 0x30, 0x80, 0x04, 0x44, + 0x28, 0x00, 0x20, 0x24, 0x1c, 0x38, 0x01, 0x08, 0x14, 0x84, 0x11, 0x04, 0x10, 0x44, 0x24, 0x24, + 0x11, 0x04, 0x00, 0x00, 0x26, 0x60, 0x10, 0xe0, 0x11, 0xf8, 0x45, 0x28, 0x08, 0x80, 0x02, 0x40, + 0x10, 0x20, 0x10, 0x24, 0x06, 0x60, 0x01, 0x08, 0x12, 0x84, 0x11, 0x04, 0x08, 0x44, 0x22, 0x64, + 0x09, 0xe8, 0x00, 0x00, 0x21, 0x80, 0x11, 0x10, 0x11, 0x08, 0x45, 0x28, 0x64, 0x80, 0x75, 0x74, + 0x14, 0x20, 0x10, 0x20, 0x32, 0x80, 0x01, 0x08, 0x12, 0xfc, 0x11, 0x00, 0x04, 0x40, 0x12, 0xa4, + 0x05, 0x50, 0x1f, 0xf0, 0x20, 0x80, 0x12, 0x08, 0x71, 0xf8, 0x25, 0x28, 0x1c, 0xf8, 0x2d, 0x68, + 0x14, 0x20, 0x08, 0x20, 0x13, 0x30, 0x79, 0xf8, 0x11, 0x20, 0x51, 0x00, 0x04, 0x40, 0x51, 0x24, + 0x05, 0x20, 0x11, 0x10, 0x61, 0x80, 0x17, 0xfc, 0x1c, 0x40, 0x25, 0x28, 0x04, 0x80, 0x29, 0x50, + 0x12, 0x20, 0x08, 0x20, 0x19, 0x18, 0x48, 0x00, 0x71, 0x20, 0x31, 0x38, 0x1f, 0xf8, 0x37, 0xe4, + 0x1f, 0xf0, 0x11, 0x10, 0x6a, 0x40, 0x72, 0x40, 0x13, 0xfc, 0x17, 0xf8, 0x3c, 0xf0, 0x13, 0xf8, + 0x12, 0x20, 0x09, 0x20, 0x01, 0x10, 0x4b, 0x0c, 0x1d, 0xfc, 0x11, 0x08, 0x11, 0x08, 0x11, 0x24, + 0x11, 0x10, 0x1f, 0xf0, 0x32, 0x40, 0x1b, 0xf8, 0x10, 0x40, 0x10, 0x00, 0x04, 0x80, 0x12, 0x48, + 0x72, 0x20, 0x09, 0x20, 0x1f, 0xf0, 0x48, 0x90, 0x11, 0x20, 0x11, 0x08, 0x11, 0x08, 0x15, 0x24, + 0x11, 0x10, 0x11, 0x10, 0x32, 0x20, 0x16, 0x40, 0x7d, 0xf8, 0x01, 0x08, 0x7c, 0xf8, 0x7f, 0xf8, + 0x03, 0xfc, 0x0a, 0x20, 0x00, 0x10, 0x48, 0x60, 0x11, 0x20, 0x51, 0x08, 0x7f, 0xf8, 0x33, 0xbc, + 0x1f, 0xf0, 0x51, 0x10, 0x7a, 0x20, 0x13, 0xf8, 0x50, 0x40, 0x25, 0x08, 0x04, 0x80, 0x02, 0x48, + 0x02, 0x00, 0x08, 0x20, 0x00, 0x10, 0x4a, 0x90, 0x7d, 0xfc, 0x31, 0x08, 0x10, 0x80, 0x52, 0x00, + 0x11, 0x10, 0x3f, 0xf0, 0x17, 0xe0, 0x7a, 0xa8, 0x21, 0xf8, 0x45, 0x90, 0x04, 0x80, 0x03, 0xf8, + 0x02, 0x00, 0x08, 0x20, 0x7f, 0xfc, 0x49, 0x08, 0x11, 0x04, 0x11, 0x08, 0x08, 0x40, 0x10, 0x00, + 0x11, 0x10, 0x10, 0x80, 0x20, 0x00, 0x13, 0xb8, 0x22, 0x44, 0x05, 0x40, 0x7f, 0xf8, 0x38, 0x80, + 0x13, 0xc0, 0x08, 0x20, 0x1f, 0xf0, 0x78, 0xf8, 0x11, 0x04, 0x29, 0xf8, 0x07, 0xc0, 0x1f, 0xfc, + 0x1f, 0xf0, 0x08, 0x40, 0x00, 0x00, 0x12, 0xa8, 0x7f, 0xfc, 0x15, 0x3c, 0x44, 0x88, 0x00, 0x40, + 0x20, 0x38, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x80, 0x11, 0xfc, 0x48, 0x00, 0x02, 0x00, 0x00, 0x80, + 0x02, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x13, 0xb8, 0x10, 0x40, 0x25, 0x20, 0x7f, 0xf8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x19, 0x18, 0x37, 0xfc, 0x07, 0xfc, 0x05, 0x84, 0x04, 0x04, 0x47, 0xfc, 0x47, 0xfc, 0x47, 0xfc, + 0x30, 0x20, 0x34, 0x10, 0x07, 0x00, 0x08, 0xf8, 0x40, 0x40, 0x04, 0x04, 0x30, 0xe0, 0x01, 0x00, + 0x49, 0x88, 0x11, 0x20, 0x40, 0x20, 0x06, 0xdc, 0x12, 0x08, 0x58, 0x00, 0x58, 0x00, 0x28, 0x00, + 0x10, 0x20, 0x12, 0x10, 0x01, 0x00, 0x48, 0x88, 0x40, 0x40, 0x42, 0x08, 0x10, 0x30, 0x3f, 0xf8, + 0x69, 0xe8, 0x11, 0x20, 0x70, 0xa0, 0x72, 0x70, 0x19, 0x10, 0x28, 0x7c, 0x70, 0x4c, 0x13, 0xfc, + 0x16, 0x2c, 0x12, 0x10, 0x01, 0x00, 0x2a, 0xf8, 0x20, 0x40, 0x41, 0x10, 0x1f, 0xfc, 0x01, 0x00, + 0x19, 0xa8, 0x11, 0x20, 0x1c, 0xb0, 0x1f, 0x30, 0x10, 0xa0, 0x28, 0x44, 0x53, 0x34, 0x12, 0x44, + 0x13, 0xa4, 0x11, 0x14, 0x7f, 0xfc, 0x1c, 0x88, 0x20, 0x40, 0x20, 0xa0, 0x11, 0x90, 0x01, 0x00, + 0x69, 0xa8, 0x51, 0x20, 0x11, 0x90, 0x15, 0x50, 0x17, 0xfc, 0x2e, 0x44, 0x5d, 0x94, 0x13, 0xfc, + 0x12, 0x24, 0x11, 0x18, 0x01, 0x80, 0x7e, 0xf8, 0x10, 0x40, 0x20, 0xa0, 0x12, 0x10, 0x7f, 0xfc, + 0x5d, 0xe8, 0x79, 0x20, 0x11, 0x90, 0x11, 0x48, 0x10, 0x40, 0x28, 0x7c, 0x11, 0x30, 0x12, 0x44, + 0x72, 0x24, 0x71, 0x30, 0x00, 0x40, 0x08, 0x00, 0x10, 0x40, 0x10, 0x40, 0x7f, 0xfc, 0x04, 0x40, + 0x4d, 0x08, 0x15, 0x20, 0x11, 0x10, 0x11, 0x88, 0x10, 0x40, 0x08, 0x00, 0x11, 0x28, 0x73, 0xfc, + 0x1a, 0x24, 0x1d, 0x10, 0x1f, 0xe0, 0x3d, 0xfc, 0x07, 0xfc, 0x17, 0xfc, 0x0b, 0x90, 0x04, 0x20, + 0x79, 0xf8, 0x11, 0x3c, 0x11, 0x18, 0x11, 0x8c, 0x13, 0xf8, 0x7e, 0x98, 0x7d, 0x28, 0x00, 0x00, + 0x12, 0x24, 0x11, 0x10, 0x00, 0x00, 0x08, 0x50, 0x00, 0x40, 0x00, 0x40, 0x09, 0x10, 0x08, 0x20, + 0x49, 0xf8, 0x11, 0x20, 0x7d, 0x10, 0x7d, 0xfc, 0x70, 0x00, 0x08, 0x44, 0x11, 0x28, 0x01, 0xf8, + 0x12, 0x24, 0x11, 0xfc, 0x0f, 0xe0, 0x3c, 0xf8, 0x20, 0x40, 0x21, 0x50, 0x6f, 0xf0, 0x7f, 0xfc, + 0x79, 0x58, 0x11, 0x20, 0x13, 0xfc, 0x11, 0x10, 0x00, 0x00, 0x08, 0x24, 0x11, 0x20, 0x21, 0x08, + 0x7a, 0x24, 0x7d, 0x00, 0x08, 0x20, 0x0a, 0x50, 0x40, 0x40, 0x42, 0x48, 0x30, 0x00, 0x01, 0x00, + 0x49, 0x48, 0x7c, 0x20, 0x10, 0x40, 0x11, 0x10, 0x03, 0xf8, 0x3e, 0x24, 0x7d, 0xfc, 0x41, 0xf8, + 0x12, 0x24, 0x11, 0x00, 0x08, 0x20, 0x04, 0x40, 0x00, 0x40, 0x00, 0x40, 0x1f, 0xf8, 0x1f, 0xf0, + 0x7b, 0x4c, 0x10, 0x20, 0x10, 0x40, 0x13, 0xf0, 0x12, 0x08, 0x08, 0xfc, 0x10, 0x24, 0x10, 0x00, + 0x13, 0x3c, 0x11, 0xe0, 0x7f, 0xfc, 0x7f, 0xfc, 0x13, 0xf8, 0x13, 0xf8, 0x08, 0x00, 0x01, 0x00, + 0x10, 0x60, 0x10, 0x20, 0x10, 0x40, 0x10, 0x00, 0x12, 0x08, 0x08, 0x00, 0x10, 0x28, 0x23, 0xfc, + 0x10, 0xc0, 0x10, 0x18, 0x01, 0x00, 0x04, 0x40, 0x20, 0x00, 0x20, 0x40, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xfc, + 0x01, 0xc0, 0x02, 0x08, 0x47, 0xe0, 0x40, 0x7c, 0x4d, 0xfc, 0x44, 0x0c, 0x78, 0x0c, 0x1f, 0xf0, + 0x24, 0x7c, 0x00, 0x08, 0x4d, 0x78, 0x16, 0x0c, 0x47, 0xfc, 0x40, 0xc0, 0x43, 0xf0, 0x45, 0x00, + 0x48, 0x44, 0x63, 0xf8, 0x28, 0x24, 0x26, 0x84, 0x26, 0x20, 0x24, 0x04, 0x17, 0x14, 0x10, 0x10, + 0x25, 0xc0, 0x3f, 0xf8, 0x45, 0x48, 0x11, 0x90, 0x28, 0x00, 0x44, 0x44, 0x24, 0x14, 0x42, 0x58, + 0x44, 0x44, 0x1a, 0x08, 0x28, 0x84, 0x11, 0x84, 0x25, 0x20, 0x25, 0x14, 0x10, 0x24, 0x10, 0x10, + 0x22, 0x40, 0x10, 0x10, 0x25, 0x44, 0x10, 0x60, 0x10, 0x00, 0x42, 0x48, 0x24, 0x48, 0x72, 0x48, + 0x22, 0x48, 0x02, 0x08, 0x08, 0x88, 0x08, 0xc0, 0x25, 0x20, 0x14, 0xa4, 0x10, 0x40, 0x10, 0x10, + 0x22, 0x40, 0x08, 0x20, 0x24, 0x50, 0x10, 0x60, 0x13, 0xf8, 0x72, 0x48, 0x05, 0x80, 0x4a, 0x78, + 0x22, 0x50, 0x02, 0x08, 0x01, 0x00, 0x08, 0xa0, 0x25, 0x20, 0x54, 0x44, 0x10, 0x40, 0x1f, 0xf0, + 0x22, 0x78, 0x04, 0x00, 0x24, 0x00, 0x14, 0x90, 0x12, 0x08, 0x48, 0x40, 0x10, 0x84, 0x4a, 0x48, + 0x10, 0x40, 0x7b, 0xf8, 0x00, 0x00, 0x04, 0x90, 0x3d, 0x20, 0x34, 0x44, 0x10, 0x80, 0x00, 0x00, + 0x20, 0x40, 0x7f, 0xfc, 0x24, 0xf8, 0x53, 0x30, 0x12, 0x08, 0x4b, 0xf8, 0x48, 0x88, 0x4a, 0x78, + 0x10, 0x40, 0x40, 0x00, 0x61, 0x0c, 0x04, 0x80, 0x25, 0xf8, 0x17, 0xfc, 0x1f, 0xfc, 0x01, 0x00, + 0x60, 0x40, 0x01, 0x00, 0x3c, 0x88, 0x31, 0x48, 0x12, 0x08, 0x48, 0x40, 0x47, 0xf0, 0x4f, 0x48, + 0x03, 0xf8, 0x20, 0x00, 0x1a, 0x30, 0x3f, 0xf8, 0x25, 0x20, 0x10, 0x40, 0x10, 0x80, 0x71, 0x0c, + 0x27, 0xfc, 0x01, 0x00, 0x24, 0xf8, 0x11, 0x88, 0x73, 0xf8, 0x48, 0x40, 0x24, 0x10, 0x50, 0xf8, + 0x02, 0x40, 0x13, 0xf8, 0x04, 0x40, 0x04, 0x20, 0x3d, 0x20, 0x30, 0x40, 0x10, 0x80, 0x0d, 0x30, + 0x10, 0x40, 0x01, 0x00, 0x24, 0x88, 0x10, 0xf8, 0x02, 0x08, 0x55, 0xf4, 0x27, 0xf0, 0x50, 0x40, + 0x02, 0x40, 0x78, 0x40, 0x02, 0x80, 0x00, 0x40, 0x25, 0x20, 0x57, 0xfc, 0x1f, 0xf8, 0x03, 0x00, + 0x10, 0x40, 0x3f, 0xf8, 0x3d, 0xfc, 0x08, 0x80, 0x02, 0x08, 0x52, 0x08, 0x24, 0x10, 0x4b, 0xfc, + 0x11, 0x00, 0x48, 0x40, 0x01, 0x00, 0x45, 0x08, 0x25, 0x00, 0x10, 0x00, 0x10, 0x08, 0x00, 0x80, + 0x43, 0xf8, 0x01, 0x00, 0x24, 0x50, 0x08, 0x80, 0x03, 0xf8, 0x49, 0x10, 0x27, 0xf0, 0x4a, 0x20, + 0x17, 0xfc, 0x27, 0xfc, 0x7f, 0xfc, 0x28, 0x90, 0x25, 0xfc, 0x1f, 0xfc, 0x10, 0x08, 0x7f, 0xfc, + 0x20, 0x40, 0x01, 0x00, 0x25, 0xfc, 0x7f, 0xfc, 0x10, 0x80, 0x48, 0xa0, 0x21, 0x00, 0x78, 0x20, + 0x20, 0x80, 0x10, 0x40, 0x01, 0x00, 0x1e, 0x7c, 0x3c, 0x20, 0x00, 0x80, 0x1f, 0xf8, 0x00, 0x00, + 0x10, 0x40, 0x3f, 0x80, 0x3c, 0x20, 0x01, 0x00, 0x20, 0x40, 0x78, 0x40, 0x3f, 0xfc, 0x00, 0x00, + 0x00, 0x80, 0x10, 0x40, 0x01, 0x00, 0x10, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, + 0x07, 0x00, 0x13, 0xfc, 0x44, 0x30, 0x7f, 0xfc, 0x53, 0x44, 0x40, 0xfc, 0x41, 0x04, 0x1c, 0x08, + 0x23, 0x08, 0x11, 0x04, 0x01, 0x00, 0x00, 0x10, 0x10, 0x0c, 0x01, 0x00, 0x40, 0x18, 0x40, 0x04, + 0x41, 0x04, 0x10, 0x20, 0x42, 0x08, 0x02, 0x00, 0x48, 0xa8, 0x40, 0x84, 0x20, 0x88, 0x02, 0x08, + 0x11, 0x10, 0x19, 0xfc, 0x01, 0x00, 0x1f, 0xf0, 0x10, 0x14, 0x01, 0x00, 0x40, 0x08, 0x47, 0xc4, + 0x21, 0x08, 0x10, 0x20, 0x41, 0x08, 0x02, 0x00, 0x44, 0xa8, 0x40, 0x84, 0x12, 0x50, 0x02, 0x08, + 0x09, 0x20, 0x15, 0x04, 0x01, 0x00, 0x08, 0x20, 0x10, 0x24, 0x3f, 0xf8, 0x50, 0x48, 0x44, 0x44, + 0x11, 0x10, 0x10, 0x20, 0x71, 0x08, 0x02, 0x00, 0x27, 0x90, 0x58, 0xdc, 0x0c, 0x20, 0x02, 0x08, + 0x01, 0x00, 0x11, 0x74, 0x01, 0x00, 0x04, 0x00, 0x10, 0x20, 0x01, 0x00, 0x48, 0x88, 0x44, 0x44, + 0x11, 0x20, 0x10, 0x20, 0x48, 0x88, 0x02, 0x00, 0x24, 0x10, 0x44, 0x84, 0x18, 0x50, 0x02, 0x08, + 0x7f, 0xfc, 0x11, 0x54, 0x7f, 0xfc, 0x7f, 0xfc, 0x10, 0x40, 0x01, 0x00, 0x45, 0x08, 0x47, 0xc4, + 0x09, 0x40, 0x11, 0xfc, 0x48, 0x88, 0x02, 0x30, 0x2f, 0xa8, 0x44, 0xcc, 0x24, 0x50, 0x42, 0x08, + 0x00, 0x00, 0x7d, 0x54, 0x01, 0x00, 0x01, 0x00, 0x10, 0x40, 0x7f, 0xfc, 0x42, 0x08, 0x41, 0x04, + 0x79, 0x40, 0x10, 0x20, 0x48, 0x88, 0x02, 0x08, 0x02, 0x28, 0x44, 0x20, 0x45, 0x88, 0x7e, 0x08, + 0x1f, 0xf0, 0x11, 0x74, 0x21, 0x00, 0x01, 0x00, 0x10, 0x80, 0x04, 0x40, 0x52, 0x48, 0x41, 0x04, + 0x01, 0xa0, 0x52, 0x20, 0x48, 0xf8, 0x02, 0x08, 0x0f, 0xa8, 0x44, 0x00, 0x22, 0x88, 0x20, 0x08, + 0x00, 0x00, 0x11, 0x24, 0x1f, 0xf0, 0x1f, 0xf0, 0x50, 0x80, 0x04, 0x40, 0x48, 0x88, 0x5f, 0xf4, + 0x01, 0x10, 0x52, 0x20, 0x50, 0x80, 0x02, 0x08, 0x28, 0xe8, 0x48, 0x18, 0x24, 0x88, 0x20, 0x08, + 0x49, 0x24, 0x3d, 0x24, 0x09, 0x00, 0x01, 0x00, 0x37, 0xc0, 0x1f, 0xf0, 0x45, 0x08, 0x41, 0x04, + 0x0f, 0x00, 0x55, 0xfc, 0x50, 0x80, 0x02, 0x08, 0x4f, 0xbc, 0x49, 0x04, 0x00, 0xfc, 0x3e, 0x08, + 0x2a, 0xa8, 0x41, 0xfc, 0x49, 0x04, 0x01, 0x00, 0x10, 0xbc, 0x41, 0x04, 0x42, 0x08, 0x41, 0x04, + 0x00, 0x00, 0x19, 0x20, 0x4b, 0xfc, 0x02, 0x08, 0x08, 0xa0, 0x44, 0x84, 0x7e, 0x40, 0x02, 0x08, + 0x1c, 0x70, 0x21, 0x24, 0x40, 0x04, 0x3f, 0xf8, 0x10, 0x80, 0x40, 0x04, 0x7f, 0xf8, 0x40, 0x04, + 0x01, 0x00, 0x11, 0x20, 0x48, 0x40, 0x02, 0x08, 0x2f, 0x90, 0x44, 0x7c, 0x08, 0x40, 0x02, 0x08, + 0x7f, 0xfc, 0x1d, 0x24, 0x7f, 0xfc, 0x24, 0x48, 0x08, 0x88, 0x7f, 0xfc, 0x02, 0x00, 0x7f, 0xfc, + 0x02, 0x00, 0x10, 0x20, 0x78, 0x40, 0x3f, 0xf8, 0x42, 0x10, 0x7c, 0x40, 0x08, 0x40, 0x7e, 0x08, + 0x08, 0x20, 0x11, 0xfc, 0x01, 0x00, 0x24, 0x48, 0x08, 0x90, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x7f, 0xfc, 0x00, 0x18, 0x7f, 0xf8, 0x47, 0xe0, 0x5f, 0xfc, 0x30, 0x18, 0x11, 0x18, 0x06, 0x0c, + 0x42, 0x04, 0x42, 0x30, 0x1f, 0xf0, 0x40, 0x7c, 0x43, 0xfc, 0x43, 0xf0, 0x45, 0x04, 0x61, 0x0c, + 0x24, 0x88, 0x70, 0x04, 0x10, 0x20, 0x40, 0x0c, 0x40, 0x80, 0x08, 0x20, 0x10, 0x84, 0x65, 0x30, + 0x21, 0x08, 0x42, 0x10, 0x10, 0x10, 0x20, 0x84, 0x40, 0x20, 0x24, 0x14, 0x44, 0x88, 0x19, 0x30, + 0x24, 0x88, 0x0c, 0x04, 0x10, 0x20, 0x2e, 0x14, 0x20, 0x80, 0x00, 0x00, 0x12, 0x44, 0x14, 0x40, + 0x21, 0x10, 0x22, 0x10, 0x1f, 0xf0, 0x10, 0x84, 0x41, 0xf8, 0x24, 0x44, 0x24, 0x50, 0x05, 0x40, + 0x24, 0x88, 0x00, 0x04, 0x10, 0x20, 0x25, 0xa0, 0x20, 0x80, 0x7f, 0xfc, 0x13, 0x24, 0x0c, 0xa0, + 0x12, 0x90, 0x23, 0xf0, 0x00, 0x00, 0x08, 0x80, 0x72, 0x20, 0x04, 0x88, 0x24, 0x20, 0x23, 0x98, + 0x3f, 0xf8, 0x00, 0x04, 0x1f, 0xe0, 0x24, 0x20, 0x2f, 0xf8, 0x00, 0x00, 0x12, 0xa4, 0x05, 0x10, + 0x14, 0xa0, 0x12, 0x10, 0x7f, 0xfc, 0x0c, 0x80, 0x49, 0xf8, 0x00, 0x00, 0x15, 0x50, 0x21, 0x08, + 0x00, 0x00, 0x7c, 0x44, 0x10, 0x20, 0x24, 0x40, 0x20, 0x80, 0x0f, 0xe0, 0x12, 0x24, 0x7f, 0xfc, + 0x14, 0xa0, 0x13, 0xf0, 0x09, 0x20, 0x54, 0x80, 0x49, 0x20, 0x1f, 0xf0, 0x14, 0x90, 0x3f, 0xf8, + 0x01, 0x18, 0x20, 0x44, 0x10, 0x20, 0x27, 0xfc, 0x30, 0xc4, 0x08, 0x20, 0x52, 0x24, 0x01, 0x00, + 0x14, 0xa0, 0x02, 0x10, 0x11, 0x10, 0x22, 0xc0, 0x48, 0x20, 0x10, 0x10, 0x04, 0xa8, 0x01, 0x00, + 0x3c, 0x88, 0x10, 0x84, 0x1f, 0xe0, 0x24, 0x40, 0x2a, 0xa8, 0x0f, 0xe0, 0x32, 0x24, 0x62, 0x7c, + 0x08, 0x40, 0x0f, 0xfc, 0x7f, 0xfc, 0x22, 0xb0, 0x4b, 0x8c, 0x1f, 0xf0, 0x04, 0x48, 0x7f, 0xfc, + 0x24, 0xf8, 0x08, 0x04, 0x10, 0x20, 0x27, 0xc0, 0x24, 0x90, 0x08, 0x20, 0x16, 0x24, 0x16, 0x84, + 0x08, 0x40, 0x20, 0x80, 0x01, 0x00, 0x1e, 0x88, 0x50, 0x70, 0x10, 0x10, 0x22, 0x78, 0x01, 0x00, + 0x24, 0x88, 0x7a, 0x04, 0x10, 0x20, 0x20, 0x38, 0x24, 0x90, 0x0f, 0xe0, 0x0b, 0xa4, 0x09, 0xe0, + 0x08, 0x40, 0x47, 0xf8, 0x1f, 0xf0, 0x10, 0x80, 0x50, 0x50, 0x1f, 0xf0, 0x42, 0x40, 0x49, 0x10, + 0x3c, 0xf8, 0x25, 0x04, 0x10, 0x20, 0x20, 0x00, 0x20, 0x00, 0x08, 0x20, 0x4a, 0x24, 0x04, 0x90, + 0x08, 0x40, 0x00, 0x80, 0x01, 0x00, 0x10, 0x80, 0x4b, 0x88, 0x10, 0x10, 0x00, 0x00, 0x3e, 0xfc, + 0x24, 0x88, 0x24, 0xfc, 0x1f, 0xe0, 0x3f, 0xfc, 0x3f, 0xfc, 0x0f, 0xe0, 0x22, 0x24, 0x7f, 0xfc, + 0x08, 0x40, 0x17, 0xf8, 0x3f, 0xf8, 0x7f, 0xfc, 0x48, 0xf8, 0x1f, 0xf0, 0x17, 0xfc, 0x10, 0x40, + 0x3c, 0xf8, 0x10, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x12, 0x7c, 0x02, 0x20, + 0x08, 0x40, 0x20, 0x80, 0x04, 0x40, 0x00, 0x00, 0x78, 0x40, 0x02, 0x00, 0x20, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x02, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x0c, + 0x07, 0x00, 0x1f, 0xf0, 0x20, 0x60, 0x10, 0x38, 0x1f, 0xf0, 0x40, 0x00, 0x43, 0xfc, 0x1f, 0xf8, + 0x42, 0xc0, 0x74, 0x04, 0x17, 0x84, 0x38, 0x40, 0x01, 0x00, 0x24, 0x04, 0x13, 0x9c, 0x45, 0xf4, + 0x61, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x10, 0x10, 0x40, 0x00, 0x3c, 0x00, 0x10, 0x00, + 0x22, 0x30, 0x12, 0x0c, 0x11, 0x74, 0x0c, 0x40, 0x01, 0x00, 0x22, 0x08, 0x10, 0x60, 0x25, 0x14, + 0x11, 0x10, 0x1f, 0xf0, 0x08, 0x10, 0x10, 0x08, 0x1f, 0xf0, 0x20, 0x00, 0x10, 0x00, 0x10, 0x00, + 0x22, 0x08, 0x11, 0x54, 0x11, 0x08, 0x04, 0x40, 0x01, 0x00, 0x21, 0x10, 0x10, 0x90, 0x25, 0x14, + 0x09, 0x20, 0x10, 0x10, 0x04, 0x10, 0x10, 0x08, 0x10, 0x10, 0x20, 0x00, 0x13, 0xf8, 0x10, 0x00, + 0x12, 0x04, 0x11, 0x50, 0x51, 0x08, 0x7f, 0xfc, 0x7f, 0xfc, 0x39, 0x10, 0x11, 0x08, 0x15, 0xf4, + 0x05, 0x60, 0x1f, 0xf0, 0x02, 0x10, 0x13, 0xc8, 0x1f, 0xf0, 0x20, 0x00, 0x12, 0x08, 0x11, 0xe0, + 0x12, 0x00, 0x10, 0x90, 0x50, 0x90, 0x04, 0x60, 0x01, 0x00, 0x24, 0xa0, 0x11, 0xf8, 0x14, 0x44, + 0x7d, 0x90, 0x10, 0x10, 0x3f, 0xf0, 0x12, 0x48, 0x00, 0x00, 0x20, 0x00, 0x72, 0x08, 0x11, 0x20, + 0x12, 0x60, 0x70, 0x90, 0x34, 0x80, 0x00, 0x00, 0x01, 0x00, 0x24, 0xa0, 0x12, 0x04, 0x05, 0xf4, + 0x01, 0x08, 0x1f, 0xf0, 0x02, 0x00, 0x12, 0x48, 0x3f, 0xf8, 0x20, 0x00, 0x03, 0xf8, 0x11, 0x20, + 0x12, 0x10, 0x19, 0x90, 0x38, 0x80, 0x1f, 0xf8, 0x1f, 0xf0, 0x24, 0xa0, 0x13, 0xfc, 0x04, 0x44, + 0x1f, 0xf0, 0x00, 0x00, 0x70, 0x1c, 0x52, 0x48, 0x21, 0x08, 0x20, 0x00, 0x10, 0x40, 0x11, 0x20, + 0x7f, 0x88, 0x12, 0x90, 0x10, 0x80, 0x10, 0x08, 0x09, 0x00, 0x24, 0x40, 0x50, 0x00, 0x27, 0xfc, + 0x10, 0x10, 0x3f, 0xf8, 0x0c, 0x60, 0x33, 0xc8, 0x25, 0x48, 0x20, 0x00, 0x70, 0x40, 0x7f, 0xfc, + 0x12, 0x04, 0x10, 0x90, 0x7c, 0x80, 0x10, 0x10, 0x04, 0x00, 0x28, 0x40, 0x31, 0xf8, 0x40, 0xa0, + 0x1f, 0xf0, 0x20, 0x08, 0x03, 0x80, 0x10, 0x08, 0x69, 0x2c, 0x20, 0x00, 0x47, 0xfc, 0x11, 0x20, + 0x12, 0x00, 0x10, 0x90, 0x10, 0x40, 0x1f, 0xe0, 0x3f, 0xf8, 0x28, 0x40, 0x10, 0x08, 0x01, 0x10, + 0x10, 0x10, 0x3f, 0xf8, 0x24, 0x40, 0x10, 0x08, 0x3f, 0xf8, 0x20, 0x00, 0x10, 0x40, 0x11, 0x20, + 0x12, 0x60, 0x7b, 0xf0, 0x10, 0x40, 0x00, 0x20, 0x02, 0x00, 0x24, 0x40, 0x11, 0xf8, 0x17, 0xfc, + 0x1f, 0xf0, 0x20, 0x08, 0x18, 0x20, 0x0b, 0xfc, 0x10, 0x10, 0x3f, 0xfc, 0x3f, 0xe0, 0x11, 0x20, + 0x7f, 0x90, 0x10, 0x80, 0x70, 0x40, 0x3f, 0xe0, 0x42, 0x04, 0x24, 0x40, 0x08, 0x08, 0x20, 0x40, + 0x02, 0x00, 0x3f, 0xf8, 0x0f, 0xf0, 0x08, 0x00, 0x08, 0x20, 0x00, 0x00, 0x20, 0x38, 0x11, 0x20, + 0x00, 0x08, 0x10, 0x80, 0x0c, 0x40, 0x00, 0x00, 0x7f, 0xfc, 0x3c, 0x40, 0x09, 0xf8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, + 0x60, 0x30, 0x07, 0xf0, 0x7f, 0xfc, 0x31, 0xf8, 0x01, 0x00, 0x42, 0x10, 0x7e, 0x04, 0x0a, 0x30, + 0x4c, 0x04, 0x10, 0x30, 0x44, 0x44, 0x10, 0x30, 0x19, 0x80, 0x46, 0x18, 0x11, 0xf8, 0x01, 0x10, + 0x10, 0x08, 0x04, 0x10, 0x01, 0x00, 0x11, 0x08, 0x01, 0x00, 0x21, 0x10, 0x01, 0xf4, 0x25, 0x54, + 0x22, 0x18, 0x10, 0x10, 0x24, 0x88, 0x11, 0x10, 0x48, 0x60, 0x43, 0x08, 0x11, 0x08, 0x61, 0x10, + 0x08, 0x08, 0x04, 0x10, 0x01, 0x00, 0x11, 0x08, 0x7f, 0xfc, 0x11, 0x10, 0x01, 0x08, 0x25, 0x44, + 0x21, 0x60, 0x12, 0x10, 0x00, 0x00, 0x12, 0x10, 0x2a, 0x10, 0x41, 0x08, 0x11, 0x08, 0x19, 0x10, + 0x04, 0x08, 0x64, 0x10, 0x3f, 0xf8, 0x11, 0x08, 0x01, 0x00, 0x70, 0x90, 0x01, 0x10, 0x12, 0x28, + 0x14, 0x88, 0x11, 0x10, 0x00, 0x00, 0x17, 0xfc, 0x08, 0x08, 0x5c, 0x88, 0x11, 0x08, 0x15, 0x54, + 0x04, 0x08, 0x17, 0xf0, 0x09, 0x20, 0x11, 0x08, 0x1f, 0xf0, 0x1c, 0xfc, 0x01, 0x00, 0x12, 0x40, + 0x14, 0x88, 0x50, 0x90, 0x3d, 0xf8, 0x10, 0x10, 0x3e, 0x04, 0x44, 0x88, 0x11, 0x08, 0x15, 0x54, + 0x7f, 0xf8, 0x08, 0x00, 0x09, 0x20, 0x71, 0xf8, 0x10, 0x10, 0x12, 0x90, 0x01, 0x00, 0x0a, 0x00, + 0x14, 0x08, 0x50, 0x50, 0x25, 0x08, 0x13, 0xf8, 0x22, 0xc0, 0x44, 0xf8, 0x11, 0xf8, 0x13, 0xb8, + 0x02, 0x00, 0x04, 0x00, 0x7f, 0xfc, 0x1c, 0x00, 0x1f, 0xf0, 0x12, 0x90, 0x3f, 0xf8, 0x0a, 0x3c, + 0x17, 0xf8, 0x34, 0x50, 0x25, 0x08, 0x12, 0x48, 0x7f, 0x20, 0x4c, 0x88, 0x11, 0x08, 0x7b, 0xb8, + 0x3f, 0xf0, 0x7f, 0xfc, 0x09, 0x20, 0x10, 0x00, 0x10, 0x10, 0x7e, 0xfc, 0x21, 0x08, 0x23, 0xc4, + 0x10, 0x80, 0x38, 0x30, 0x25, 0xf8, 0x13, 0xf8, 0x08, 0x10, 0x48, 0x88, 0x51, 0x08, 0x11, 0x10, + 0x22, 0x10, 0x02, 0x00, 0x09, 0x20, 0x11, 0xf8, 0x7f, 0xfc, 0x2a, 0xa8, 0x21, 0x08, 0x42, 0x70, + 0x10, 0x80, 0x10, 0x10, 0x3c, 0x00, 0x12, 0x48, 0x3e, 0x08, 0x58, 0xf8, 0x55, 0x08, 0x11, 0x10, + 0x22, 0x10, 0x01, 0x00, 0x7f, 0xfc, 0x7a, 0x04, 0x04, 0x40, 0x28, 0xa8, 0x21, 0x08, 0x02, 0x44, + 0x1f, 0xfc, 0x7d, 0xfc, 0x24, 0x98, 0x7b, 0xf8, 0x22, 0xc0, 0x48, 0x88, 0x55, 0x08, 0x17, 0xfc, + 0x3f, 0xf0, 0x04, 0x40, 0x01, 0x00, 0x11, 0x08, 0x08, 0x20, 0x7c, 0xfc, 0x3f, 0xf8, 0x0b, 0xfc, + 0x10, 0x80, 0x10, 0x10, 0x24, 0x48, 0x10, 0x40, 0x3e, 0x20, 0x4c, 0x88, 0x19, 0xf8, 0x79, 0x10, + 0x22, 0x10, 0x7f, 0xfc, 0x1f, 0x80, 0x10, 0x90, 0x3f, 0xf8, 0x10, 0x90, 0x01, 0x00, 0x10, 0x40, + 0x10, 0x80, 0x10, 0x10, 0x24, 0x48, 0x17, 0xfc, 0x22, 0x10, 0x7e, 0xf8, 0x10, 0x80, 0x01, 0x10, + 0x3f, 0xf0, 0x04, 0x40, 0x00, 0x70, 0x10, 0x60, 0x01, 0x00, 0x10, 0x90, 0x01, 0x00, 0x20, 0x78, + 0x1f, 0x80, 0x10, 0x10, 0x3d, 0xf8, 0x10, 0x48, 0x3e, 0x08, 0x04, 0x00, 0x10, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, + 0x02, 0x08, 0x40, 0x40, 0x17, 0xfc, 0x2b, 0x3c, 0x00, 0x40, 0x07, 0x00, 0x7f, 0xfc, 0x04, 0x1c, + 0x23, 0x04, 0x04, 0x8c, 0x00, 0x08, 0x02, 0x00, 0x40, 0x00, 0x44, 0x44, 0x7f, 0xfc, 0x02, 0x08, + 0x13, 0xf8, 0x40, 0x40, 0x12, 0x08, 0x28, 0xa4, 0x01, 0x80, 0x01, 0x00, 0x09, 0x00, 0x02, 0x04, + 0x20, 0x84, 0x62, 0x50, 0x7f, 0x08, 0x02, 0x00, 0x20, 0x00, 0x24, 0x44, 0x01, 0x00, 0x11, 0x10, + 0x1a, 0x08, 0x20, 0x40, 0x12, 0x08, 0x24, 0xa4, 0x06, 0x00, 0x01, 0x00, 0x09, 0xf0, 0x12, 0xf4, + 0x2c, 0x48, 0x1a, 0x20, 0x08, 0xf0, 0x02, 0x30, 0x20, 0x00, 0x24, 0x88, 0x1f, 0xf0, 0x19, 0x10, + 0x16, 0x08, 0x20, 0x40, 0x13, 0xf8, 0x24, 0xa4, 0x40, 0x04, 0x01, 0x00, 0x01, 0x00, 0x1a, 0x94, + 0x26, 0x30, 0x01, 0x50, 0x04, 0x10, 0x02, 0x08, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x14, 0xa0, + 0x13, 0xf8, 0x10, 0x40, 0x12, 0x08, 0x24, 0xa4, 0x20, 0x88, 0x01, 0x00, 0x3f, 0xf8, 0x16, 0x94, + 0x25, 0x90, 0x01, 0x90, 0x04, 0x20, 0x02, 0x08, 0x1f, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x10, 0xa0, + 0x10, 0x00, 0x17, 0xfc, 0x13, 0xf8, 0x22, 0xa4, 0x21, 0x10, 0x01, 0x00, 0x00, 0x00, 0x12, 0xf4, + 0x24, 0x10, 0x79, 0x08, 0x02, 0x00, 0x02, 0x08, 0x11, 0x10, 0x61, 0x0c, 0x3f, 0xf8, 0x10, 0xa0, + 0x10, 0x00, 0x04, 0x44, 0x12, 0x08, 0x22, 0xa4, 0x12, 0x10, 0x7f, 0xfc, 0x48, 0xcc, 0x12, 0x04, + 0x24, 0x10, 0x41, 0x08, 0x42, 0x04, 0x02, 0x08, 0x11, 0x10, 0x11, 0x10, 0x01, 0x00, 0x10, 0x40, + 0x17, 0xfc, 0x04, 0x44, 0x13, 0xf8, 0x22, 0xa4, 0x10, 0x20, 0x01, 0x00, 0x2b, 0x30, 0x13, 0xfc, + 0x24, 0x10, 0x21, 0x78, 0x21, 0x08, 0x3f, 0xf8, 0x1f, 0xf0, 0x09, 0x20, 0x6f, 0xec, 0x10, 0x40, + 0x71, 0x08, 0x04, 0x44, 0x52, 0x08, 0x62, 0xa4, 0x10, 0x20, 0x09, 0x20, 0x1c, 0x48, 0x12, 0x44, + 0x64, 0x90, 0x11, 0x40, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0x40, 0x19, 0x10, 0x70, 0x40, + 0x01, 0x08, 0x24, 0x44, 0x33, 0xf8, 0x2f, 0xa4, 0x1f, 0xf0, 0x11, 0x10, 0x3e, 0xc8, 0x72, 0xf4, + 0x24, 0x90, 0x79, 0x20, 0x08, 0x20, 0x08, 0x20, 0x3f, 0xf8, 0x03, 0x80, 0x04, 0x20, 0x00, 0x40, + 0x03, 0xf8, 0x27, 0xfc, 0x10, 0x40, 0x22, 0x3c, 0x10, 0x10, 0x01, 0x10, 0x2a, 0x7c, 0x02, 0x44, + 0x25, 0x10, 0x49, 0x10, 0x08, 0x20, 0x08, 0x20, 0x01, 0x00, 0x7f, 0xfc, 0x02, 0x40, 0x10, 0x40, + 0x10, 0x80, 0x40, 0x40, 0x17, 0xfc, 0x12, 0x00, 0x10, 0x10, 0x3f, 0x00, 0x7f, 0x20, 0x12, 0x44, + 0x14, 0x10, 0x21, 0x10, 0x04, 0x40, 0x7f, 0xfc, 0x7f, 0xfc, 0x01, 0x00, 0x7f, 0xfc, 0x10, 0x40, + 0x10, 0x80, 0x00, 0x40, 0x08, 0x40, 0x12, 0x00, 0x1f, 0xf0, 0x00, 0xf0, 0x08, 0x20, 0x13, 0xfc, + 0x10, 0x10, 0x13, 0xf0, 0x04, 0x40, 0x08, 0x20, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x40, + 0x27, 0xfc, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, + 0x7f, 0xfc, 0x3f, 0xf8, 0x10, 0xf8, 0x47, 0xfc, 0x5c, 0x0c, 0x40, 0x40, 0x51, 0x04, 0x7f, 0xfc, + 0x70, 0x30, 0x47, 0xfc, 0x4e, 0x20, 0x01, 0x00, 0x11, 0x08, 0x02, 0x18, 0x00, 0x40, 0x0c, 0x08, + 0x00, 0x00, 0x20, 0x08, 0x11, 0x08, 0x40, 0x20, 0x47, 0x30, 0x24, 0x40, 0x54, 0x88, 0x00, 0x00, + 0x5c, 0x90, 0x28, 0x00, 0x45, 0x40, 0x09, 0x60, 0x19, 0xf8, 0x02, 0x04, 0x10, 0x40, 0x02, 0x08, + 0x00, 0x00, 0x28, 0x28, 0x11, 0x08, 0x41, 0x10, 0x24, 0x50, 0x24, 0x40, 0x04, 0x88, 0x1f, 0xf0, + 0x53, 0xfc, 0x10, 0x40, 0x4c, 0xc0, 0x49, 0x24, 0x15, 0x08, 0x42, 0x04, 0x1b, 0xf8, 0x01, 0x08, + 0x7e, 0xfc, 0x24, 0x48, 0x71, 0x00, 0x71, 0x10, 0x24, 0x88, 0x18, 0x40, 0x70, 0x50, 0x10, 0x10, + 0x50, 0x10, 0x16, 0x4c, 0x25, 0x20, 0x2f, 0xe8, 0x11, 0x08, 0x4a, 0xe4, 0x14, 0x40, 0x3f, 0xf8, + 0x20, 0x80, 0x22, 0x88, 0x1d, 0xc0, 0x4a, 0x48, 0x3f, 0xf8, 0x10, 0x78, 0x0e, 0x50, 0x1f, 0xf0, + 0x51, 0xfc, 0x11, 0x50, 0x0f, 0x40, 0x11, 0x10, 0x11, 0x08, 0x7a, 0xa4, 0x11, 0xf0, 0x01, 0x00, + 0x10, 0x40, 0x21, 0x08, 0x11, 0x20, 0x48, 0x48, 0x20, 0x00, 0x10, 0x40, 0x08, 0x50, 0x10, 0x10, + 0x5d, 0x04, 0x10, 0xe0, 0x04, 0x80, 0x7f, 0xfc, 0x7d, 0xf8, 0x4a, 0xa4, 0x7c, 0x40, 0x31, 0x4c, + 0x08, 0x20, 0x01, 0x00, 0x11, 0x10, 0x48, 0x88, 0x3f, 0xf8, 0x50, 0x40, 0x7e, 0x20, 0x1f, 0xf0, + 0x11, 0x9c, 0x10, 0x40, 0x7a, 0x20, 0x04, 0x00, 0x12, 0x00, 0x4a, 0xa4, 0x11, 0xf0, 0x0e, 0x30, + 0x04, 0x10, 0x00, 0x00, 0x7d, 0x04, 0x48, 0x00, 0x00, 0x00, 0x50, 0x78, 0x08, 0x20, 0x60, 0x0c, + 0x11, 0x54, 0x73, 0xf8, 0x04, 0x40, 0x0f, 0xe0, 0x11, 0x0c, 0x4a, 0xe4, 0x16, 0x4c, 0x34, 0x28, + 0x7c, 0xf8, 0x7f, 0xfc, 0x52, 0x08, 0x55, 0xf4, 0x5d, 0x74, 0x5a, 0x40, 0x7f, 0xfc, 0x11, 0x10, + 0x7d, 0xfc, 0x02, 0x48, 0x03, 0x80, 0x08, 0x20, 0x3c, 0x90, 0x4a, 0x04, 0x39, 0xb0, 0x22, 0x44, + 0x42, 0x84, 0x11, 0x00, 0x21, 0x10, 0x52, 0x08, 0x41, 0x04, 0x55, 0x40, 0x49, 0x20, 0x09, 0x20, + 0x44, 0x50, 0x03, 0xf8, 0x3f, 0xe0, 0x0f, 0xe0, 0x40, 0x90, 0x4a, 0x04, 0x40, 0x40, 0x12, 0x44, + 0x22, 0x44, 0x11, 0x00, 0x20, 0xa0, 0x49, 0x10, 0x7f, 0xfc, 0x14, 0xfc, 0x6d, 0x24, 0x05, 0x40, + 0x45, 0xfc, 0x00, 0x40, 0x41, 0x00, 0x08, 0x20, 0x20, 0x90, 0x7b, 0xfc, 0x22, 0xa0, 0x7e, 0xfc, + 0x20, 0x40, 0x11, 0xf8, 0x7c, 0xa0, 0x48, 0xa0, 0x01, 0x00, 0x10, 0x80, 0x49, 0x28, 0x7f, 0xfc, + 0x44, 0x88, 0x17, 0xfc, 0x00, 0x00, 0x7f, 0xfc, 0x1c, 0x90, 0x00, 0x80, 0x1d, 0x10, 0x08, 0x00, + 0x10, 0x20, 0x11, 0x00, 0x10, 0x40, 0x78, 0x40, 0x1f, 0xf0, 0x10, 0x80, 0x7f, 0x20, 0x01, 0x00, + 0x7c, 0x50, 0x20, 0x40, 0x00, 0x00, 0x04, 0x40, 0x10, 0xf0, 0x00, 0xc0, 0x10, 0xf0, 0x00, 0x00, + 0x10, 0x20, 0x01, 0x00, 0x10, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0xfc, + 0x40, 0x20, 0x03, 0xf8, 0x67, 0xfc, 0x1f, 0xf0, 0x27, 0xf8, 0x00, 0x00, 0x1f, 0xf0, 0x07, 0xf0, + 0x04, 0xfc, 0x7f, 0xfc, 0x4e, 0x3c, 0x11, 0x04, 0x02, 0x30, 0x01, 0x44, 0x01, 0x00, 0x28, 0x00, + 0x20, 0x40, 0x04, 0x08, 0x1a, 0xa8, 0x10, 0x10, 0x20, 0x80, 0x00, 0x00, 0x11, 0x10, 0x04, 0x10, + 0x13, 0x00, 0x12, 0x90, 0x45, 0xa4, 0x19, 0x88, 0x11, 0x08, 0x61, 0x7c, 0x01, 0x00, 0x12, 0x60, + 0x10, 0x80, 0x04, 0x00, 0x02, 0xa8, 0x10, 0x10, 0x20, 0x80, 0x70, 0x00, 0x1f, 0xf0, 0x07, 0xf0, + 0x1a, 0x20, 0x12, 0x90, 0x24, 0x20, 0x15, 0x50, 0x19, 0x08, 0x19, 0x44, 0x01, 0x00, 0x11, 0x20, + 0x09, 0x00, 0x67, 0x00, 0x7b, 0xf8, 0x1f, 0xf0, 0x20, 0x80, 0x50, 0x00, 0x11, 0x10, 0x64, 0x10, + 0x16, 0x20, 0x12, 0x90, 0x24, 0x20, 0x11, 0x10, 0x10, 0xb8, 0x01, 0x7c, 0x7f, 0xfc, 0x11, 0x20, + 0x00, 0x00, 0x1c, 0xe0, 0x20, 0x00, 0x00, 0x80, 0x20, 0x80, 0x50, 0x00, 0x1f, 0xf0, 0x1f, 0xf0, + 0x13, 0x28, 0x1f, 0xf0, 0x17, 0xb8, 0x11, 0x28, 0x10, 0x90, 0x05, 0x44, 0x01, 0x00, 0x74, 0xa4, + 0x7f, 0xe0, 0x04, 0x00, 0x11, 0xf0, 0x00, 0x40, 0x20, 0x80, 0x50, 0x00, 0x00, 0x00, 0x04, 0x40, + 0x12, 0xa8, 0x04, 0x08, 0x14, 0x24, 0x7d, 0x24, 0x7b, 0xf0, 0x7b, 0x7c, 0x40, 0x04, 0x02, 0xa8, + 0x00, 0x80, 0x02, 0x00, 0x79, 0x10, 0x00, 0x20, 0x2f, 0xfc, 0x50, 0x00, 0x1d, 0x70, 0x3f, 0xf8, + 0x12, 0x70, 0x26, 0x10, 0x04, 0x20, 0x11, 0xf8, 0x10, 0x00, 0x41, 0x20, 0x2f, 0x28, 0x02, 0xa8, + 0x10, 0x80, 0x7f, 0xfc, 0x25, 0xf0, 0x0f, 0xe0, 0x20, 0x80, 0x50, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x12, 0x20, 0x25, 0x20, 0x00, 0x00, 0x11, 0x08, 0x12, 0x4c, 0x21, 0x10, 0x02, 0xc0, 0x20, 0xa0, + 0x22, 0x40, 0x02, 0x40, 0x11, 0x10, 0x60, 0x0c, 0x60, 0x80, 0x50, 0x00, 0x5d, 0x74, 0x6f, 0xec, + 0x76, 0xfc, 0x24, 0xf8, 0x27, 0xf8, 0x3d, 0x08, 0x39, 0x50, 0x10, 0xfc, 0x11, 0x10, 0x40, 0xa0, + 0x24, 0x40, 0x02, 0x20, 0x11, 0xf0, 0x1b, 0xb0, 0x20, 0x80, 0x50, 0x00, 0x41, 0x04, 0x19, 0x30, + 0x00, 0x20, 0x04, 0x80, 0x44, 0x08, 0x41, 0xf8, 0x40, 0xe0, 0x78, 0x80, 0x26, 0x88, 0x07, 0xfc, + 0x04, 0x20, 0x3f, 0xd0, 0x00, 0x00, 0x04, 0x40, 0x20, 0x80, 0x5c, 0x00, 0x7f, 0xfc, 0x04, 0x40, + 0x00, 0x70, 0x00, 0x00, 0x07, 0xf8, 0x21, 0x08, 0x23, 0xf8, 0x4a, 0x04, 0x01, 0x00, 0x10, 0x40, + 0x00, 0x00, 0x02, 0x08, 0x04, 0x40, 0x02, 0x80, 0x17, 0xc0, 0x44, 0x00, 0x01, 0x00, 0x7f, 0xfc, + 0x12, 0xa8, 0x08, 0x20, 0x14, 0x08, 0x1d, 0x08, 0x18, 0x40, 0x23, 0xfc, 0x7f, 0xfc, 0x20, 0x40, + 0x00, 0x00, 0x02, 0x00, 0x7f, 0xfc, 0x01, 0x00, 0x10, 0x30, 0x7c, 0x00, 0x1f, 0xf0, 0x01, 0x00, + 0x12, 0x20, 0x7f, 0xfc, 0x27, 0xf8, 0x11, 0xf8, 0x11, 0xc0, 0x10, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x24, 0x20, 0x08, 0x20, 0x00, 0x00, 0x10, 0x00, 0x10, 0x30, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0xfc, + 0x0f, 0xfc, 0x41, 0xf8, 0x00, 0x20, 0x5f, 0xfc, 0x21, 0xe0, 0x47, 0xfc, 0x71, 0x04, 0x40, 0x04, + 0x40, 0x20, 0x00, 0x00, 0x04, 0x0c, 0x5f, 0xfc, 0x44, 0xc4, 0x48, 0x0c, 0x70, 0x60, 0x20, 0x40, + 0x10, 0x04, 0x41, 0x08, 0x10, 0x20, 0x41, 0x40, 0x20, 0x18, 0x2a, 0x08, 0x10, 0x84, 0x20, 0x0c, + 0x20, 0x20, 0x00, 0x00, 0x44, 0x04, 0x40, 0x80, 0x42, 0x48, 0x44, 0x04, 0x5d, 0x24, 0x20, 0x20, + 0x10, 0x04, 0x41, 0x08, 0x19, 0x2c, 0x25, 0x50, 0x21, 0xc4, 0x11, 0x10, 0x12, 0x44, 0x28, 0x54, + 0x10, 0x20, 0x30, 0x00, 0x24, 0x84, 0x2f, 0xf8, 0x20, 0x40, 0x42, 0x04, 0x50, 0xa8, 0x22, 0x10, + 0x10, 0x00, 0x71, 0x08, 0x15, 0x24, 0x29, 0x48, 0x28, 0x30, 0x12, 0xa8, 0x13, 0x28, 0x24, 0x54, + 0x08, 0x20, 0x30, 0x00, 0x15, 0x04, 0x20, 0x80, 0x27, 0xfc, 0x22, 0x24, 0x50, 0xa8, 0x22, 0x10, + 0x10, 0x00, 0x49, 0xf8, 0x11, 0x24, 0x20, 0x00, 0x29, 0xc8, 0x12, 0x48, 0x12, 0xa8, 0x22, 0x90, + 0x04, 0x24, 0x00, 0x00, 0x0e, 0x24, 0x2f, 0xf8, 0x10, 0x00, 0x21, 0x24, 0x50, 0x20, 0x24, 0x08, + 0x1f, 0xf0, 0x48, 0x00, 0x11, 0x24, 0x21, 0xf8, 0x28, 0x30, 0x12, 0x08, 0x72, 0x10, 0x22, 0x90, + 0x04, 0x28, 0x00, 0x00, 0x25, 0xa4, 0x20, 0x80, 0x13, 0xf8, 0x2b, 0x24, 0x5d, 0xfc, 0x28, 0x48, + 0x11, 0x10, 0x48, 0x00, 0x11, 0x24, 0x2f, 0x08, 0x2b, 0x0c, 0x13, 0xf8, 0x1a, 0x10, 0x21, 0x10, + 0x4a, 0x30, 0x00, 0x00, 0x24, 0xa4, 0x27, 0xf0, 0x00, 0x00, 0x04, 0xa4, 0x10, 0x00, 0x20, 0x48, + 0x11, 0x10, 0x4b, 0xfc, 0x11, 0xfc, 0x21, 0xe0, 0x28, 0xd0, 0x70, 0x00, 0x12, 0x10, 0x21, 0x10, + 0x32, 0x20, 0x30, 0x00, 0x24, 0xa4, 0x20, 0x80, 0x03, 0xf8, 0x04, 0xa4, 0x10, 0x00, 0x20, 0x88, + 0x5f, 0xf0, 0x50, 0x90, 0x40, 0x20, 0x21, 0x04, 0x68, 0x20, 0x07, 0xfc, 0x12, 0x10, 0x22, 0x90, + 0x11, 0x60, 0x30, 0x00, 0x3f, 0xa4, 0x3f, 0xfc, 0x02, 0x08, 0x04, 0xa4, 0x7c, 0xf8, 0x21, 0x00, + 0x20, 0x80, 0x50, 0x88, 0x2a, 0x20, 0x3f, 0xfc, 0x2a, 0x50, 0x00, 0x40, 0x12, 0x50, 0x24, 0x90, + 0x11, 0xa0, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x22, 0xe8, 0x23, 0xa4, 0x44, 0x00, 0x20, 0x00, + 0x10, 0x40, 0x49, 0x08, 0x25, 0x20, 0x01, 0x00, 0x21, 0x88, 0x13, 0xf8, 0x7a, 0x50, 0x28, 0x50, + 0x0f, 0x20, 0x00, 0x00, 0x04, 0x24, 0x3f, 0xf8, 0x22, 0xa8, 0x22, 0x24, 0x45, 0x04, 0x3f, 0xfc, + 0x0f, 0xc0, 0x4b, 0xfc, 0x1c, 0xfc, 0x01, 0xf0, 0x10, 0xfc, 0x12, 0x48, 0x12, 0x50, 0x20, 0x50, + 0x08, 0x20, 0x00, 0x00, 0x7f, 0xa4, 0x21, 0x08, 0x47, 0xfc, 0x42, 0x04, 0x45, 0xfc, 0x00, 0x80, + 0x08, 0x00, 0x78, 0x20, 0x10, 0x80, 0x01, 0x00, 0x10, 0x80, 0x23, 0xf8, 0x10, 0x90, 0x20, 0x10, + 0x08, 0x20, 0x00, 0x00, 0x04, 0x04, 0x01, 0x00, 0x00, 0x40, 0x0f, 0xc4, 0x7c, 0x20, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, 0x3f, 0xf0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, + 0x43, 0xf0, 0x03, 0x00, 0x11, 0xfc, 0x31, 0xf8, 0x0e, 0x00, 0x60, 0x3c, 0x70, 0x1c, 0x00, 0x40, + 0x30, 0x08, 0x43, 0xf0, 0x34, 0x10, 0x07, 0xf8, 0x02, 0x30, 0x1c, 0x1c, 0x43, 0xfc, 0x10, 0x10, + 0x24, 0x14, 0x00, 0x80, 0x11, 0x24, 0x11, 0x08, 0x01, 0x80, 0x10, 0x44, 0x0c, 0x60, 0x10, 0x40, + 0x0c, 0x10, 0x24, 0x14, 0x12, 0x10, 0x54, 0x08, 0x11, 0x08, 0x03, 0x60, 0x3c, 0x00, 0x1f, 0xf0, + 0x24, 0x88, 0x00, 0x40, 0x11, 0x24, 0x11, 0x08, 0x00, 0x60, 0x08, 0x44, 0x02, 0x80, 0x18, 0x40, + 0x02, 0x60, 0x24, 0x44, 0x12, 0x10, 0x4f, 0xf8, 0x19, 0x08, 0x40, 0x80, 0x10, 0x40, 0x10, 0x10, + 0x1f, 0xf0, 0x00, 0x40, 0x11, 0xfc, 0x11, 0xf8, 0x00, 0x30, 0x08, 0x40, 0x7f, 0xfc, 0x14, 0x40, + 0x01, 0x80, 0x04, 0x88, 0x11, 0x10, 0x24, 0x00, 0x14, 0xb8, 0x21, 0x40, 0x10, 0x40, 0x1f, 0xf0, + 0x00, 0x10, 0x7f, 0xfc, 0x11, 0x24, 0x11, 0x08, 0x06, 0x48, 0x04, 0x40, 0x01, 0x00, 0x10, 0x40, + 0x1e, 0x40, 0x70, 0x00, 0x11, 0x10, 0x3f, 0xfc, 0x10, 0x90, 0x12, 0x20, 0x10, 0x40, 0x00, 0x00, + 0x1f, 0xf0, 0x00, 0x40, 0x55, 0xfc, 0x71, 0xf8, 0x71, 0x88, 0x04, 0x40, 0x1f, 0xf0, 0x10, 0x40, + 0x08, 0x40, 0x0e, 0x8c, 0x71, 0x10, 0x20, 0x00, 0x13, 0xf0, 0x0a, 0x10, 0x70, 0x40, 0x62, 0x7c, + 0x00, 0x10, 0x00, 0x40, 0x38, 0x00, 0x1c, 0x00, 0x0c, 0x84, 0x7f, 0xfc, 0x10, 0x10, 0x10, 0x40, + 0x08, 0x20, 0x00, 0x54, 0x1d, 0x10, 0x35, 0x24, 0x10, 0x00, 0x07, 0xf0, 0x00, 0x40, 0x14, 0x44, + 0x7f, 0xfc, 0x10, 0x40, 0x10, 0xf8, 0x10, 0xfc, 0x02, 0x7c, 0x01, 0x00, 0x1f, 0xf0, 0x10, 0x40, + 0x04, 0x20, 0x3e, 0x20, 0x11, 0x10, 0x2e, 0xa8, 0x12, 0x4c, 0x04, 0x00, 0x17, 0xfc, 0x08, 0x44, + 0x10, 0x20, 0x1f, 0xc0, 0x08, 0x88, 0x11, 0x04, 0x03, 0x20, 0x21, 0x00, 0x12, 0x90, 0x77, 0xfc, + 0x04, 0x20, 0x22, 0x50, 0x11, 0xfc, 0x24, 0x70, 0x71, 0x50, 0x02, 0x00, 0x70, 0x40, 0x7f, 0x44, + 0x7c, 0xf8, 0x08, 0x00, 0x04, 0xf8, 0x7d, 0x00, 0x34, 0x80, 0x11, 0x00, 0x5f, 0xf4, 0x00, 0x40, + 0x7f, 0xfc, 0x3e, 0x48, 0x7d, 0x00, 0x3e, 0xfc, 0x00, 0xe0, 0x3f, 0xfc, 0x40, 0x40, 0x48, 0x44, + 0x10, 0x20, 0x08, 0x00, 0x7c, 0x00, 0x11, 0xe0, 0x08, 0x40, 0x1f, 0xf8, 0x22, 0x88, 0x00, 0x40, + 0x02, 0x00, 0x00, 0x80, 0x11, 0x00, 0x24, 0x20, 0x03, 0xf8, 0x22, 0x00, 0x10, 0x40, 0x3e, 0x7c, + 0x7c, 0xfc, 0x0f, 0xe0, 0x11, 0xfc, 0x11, 0x18, 0x07, 0xc0, 0x09, 0x00, 0x17, 0xd0, 0x10, 0x40, + 0x01, 0x00, 0x7f, 0xfc, 0x11, 0xe0, 0x3f, 0xfc, 0x10, 0x40, 0x11, 0x08, 0x3f, 0xe0, 0x20, 0x00, + 0x10, 0x20, 0x08, 0x00, 0x10, 0x00, 0x11, 0x00, 0x02, 0x00, 0x09, 0x00, 0x08, 0x20, 0x10, 0x40, + 0x01, 0x00, 0x00, 0x88, 0x10, 0x18, 0x00, 0x80, 0x11, 0xc0, 0x11, 0x10, 0x20, 0x38, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x30, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x20, 0x3f, 0xfc, 0x13, 0xfc, 0x1c, 0x70, 0x47, 0xfc, 0x7f, 0xfc, 0x47, 0xe4, 0x23, 0x0c, + 0x20, 0x40, 0x7e, 0xfc, 0x7f, 0xfc, 0x1a, 0x3c, 0xf8, 0x00, 0x7f, 0xfc, 0x60, 0x0c, 0x00, 0x20, + 0x71, 0x2c, 0x24, 0x20, 0x10, 0x00, 0x12, 0x10, 0x28, 0x00, 0x01, 0x00, 0x28, 0x24, 0x10, 0x84, + 0x3f, 0xc0, 0x42, 0x84, 0x01, 0x10, 0x05, 0x24, 0x88, 0x00, 0x11, 0x00, 0x18, 0x30, 0x7d, 0xfc, + 0x0d, 0x24, 0x27, 0xe0, 0x10, 0x00, 0x11, 0x10, 0x12, 0x30, 0x01, 0x00, 0x29, 0x08, 0x48, 0x84, + 0x24, 0x40, 0x42, 0x84, 0x01, 0x20, 0x65, 0x24, 0xe8, 0x00, 0x11, 0x00, 0x04, 0x40, 0x54, 0x20, + 0x01, 0x24, 0x24, 0x20, 0x10, 0x00, 0x11, 0x90, 0x11, 0x08, 0x1f, 0xf0, 0x02, 0x08, 0x24, 0xa4, + 0x24, 0x40, 0x7e, 0xfc, 0x1f, 0xf0, 0x14, 0xa0, 0x28, 0x00, 0x11, 0x00, 0x02, 0x80, 0x54, 0xf8, + 0x01, 0x24, 0x27, 0xe0, 0x10, 0x00, 0x10, 0x90, 0x10, 0x98, 0x01, 0x00, 0x3f, 0xf8, 0x12, 0xa4, + 0x04, 0x00, 0x42, 0x84, 0x01, 0x00, 0x6c, 0xa0, 0x28, 0x00, 0x11, 0x00, 0x7f, 0xfc, 0x54, 0x88, + 0x7d, 0xfc, 0x24, 0x20, 0x51, 0xf8, 0x50, 0x98, 0x10, 0x90, 0x01, 0x20, 0x10, 0x10, 0x4a, 0xa4, + 0x73, 0x00, 0x7e, 0xfc, 0x01, 0x00, 0x14, 0xa0, 0x28, 0x00, 0x11, 0xf0, 0x01, 0x00, 0x54, 0xf8, + 0x20, 0x20, 0x27, 0xe0, 0x34, 0x00, 0x7b, 0xf8, 0x11, 0xf0, 0x5e, 0x20, 0x08, 0x20, 0x3f, 0xa4, + 0x29, 0x20, 0x00, 0x00, 0x3f, 0xf8, 0x0d, 0xf8, 0x28, 0x00, 0x01, 0x00, 0x3f, 0xf8, 0x54, 0x88, + 0x10, 0xf8, 0x01, 0x00, 0x38, 0x00, 0x3c, 0x04, 0x76, 0x4c, 0x52, 0xf8, 0x7f, 0xfc, 0x10, 0x24, + 0x29, 0x40, 0x1f, 0xf0, 0x00, 0x00, 0x69, 0x08, 0x28, 0x00, 0x01, 0x00, 0x01, 0x00, 0x55, 0xfc, + 0x08, 0x88, 0x7f, 0xfc, 0x10, 0x00, 0x36, 0x08, 0x01, 0x50, 0x3e, 0x20, 0x10, 0x10, 0x3f, 0x24, + 0x09, 0x00, 0x10, 0x10, 0x40, 0x04, 0x19, 0xf8, 0x28, 0x00, 0x61, 0x0c, 0x1f, 0xf0, 0x54, 0x50, + 0x78, 0xf8, 0x01, 0x00, 0x13, 0xfc, 0x12, 0x18, 0x07, 0xfc, 0x21, 0xfc, 0x1f, 0xf0, 0x21, 0x24, + 0x7f, 0xe0, 0x1f, 0xf0, 0x7f, 0xfc, 0x25, 0x08, 0x28, 0x00, 0x19, 0x30, 0x01, 0x00, 0x10, 0x88, + 0x24, 0x88, 0x3f, 0xf8, 0x7c, 0x00, 0x13, 0x10, 0x00, 0x40, 0x3e, 0x50, 0x10, 0x10, 0x3f, 0x24, + 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x69, 0xf8, 0x38, 0x00, 0x04, 0x40, 0x3f, 0xf8, 0x11, 0xfc, + 0x24, 0xf8, 0x24, 0x48, 0x10, 0x90, 0x1a, 0x30, 0x13, 0xe0, 0x22, 0xf8, 0x1f, 0xf0, 0x21, 0x24, + 0x00, 0x00, 0x1f, 0xf0, 0x08, 0x20, 0x10, 0x80, 0x00, 0x00, 0x02, 0x80, 0x04, 0x40, 0x10, 0x20, + 0x10, 0x40, 0x3f, 0xf8, 0x10, 0x88, 0x19, 0xe0, 0x20, 0x18, 0x3e, 0x20, 0x10, 0x10, 0x3f, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x08, 0x40, 0x00, 0x00, 0x01, 0x00, 0x08, 0x20, 0x00, 0x00, + 0x10, 0x20, 0x00, 0x00, 0x11, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3c, + 0x01, 0xc0, 0x20, 0xc0, 0x01, 0xfc, 0x01, 0xfc, 0x2d, 0x84, 0x46, 0x0c, 0x00, 0x18, 0x00, 0xe0, + 0x43, 0xf0, 0x07, 0x00, 0x10, 0x40, 0x10, 0x00, 0x67, 0xfc, 0x43, 0xfc, 0x7f, 0xfc, 0x10, 0x44, + 0x00, 0x20, 0x10, 0x40, 0x71, 0x00, 0x02, 0x04, 0x24, 0x48, 0x21, 0x94, 0x00, 0x04, 0x04, 0x20, + 0x24, 0x14, 0x01, 0x00, 0x10, 0x40, 0x17, 0xfc, 0x10, 0x40, 0x2c, 0x00, 0x0f, 0xe0, 0x10, 0x44, + 0x00, 0x20, 0x08, 0x40, 0x0d, 0x10, 0x02, 0x04, 0x3c, 0x30, 0x10, 0x60, 0x70, 0x04, 0x04, 0x20, + 0x24, 0x44, 0x41, 0x04, 0x10, 0x40, 0x10, 0x00, 0x10, 0x40, 0x10, 0x00, 0x0f, 0xe0, 0x10, 0x40, + 0x10, 0x20, 0x48, 0x44, 0x01, 0x10, 0x02, 0x00, 0x24, 0x10, 0x08, 0x30, 0x1c, 0x04, 0x08, 0x20, + 0x04, 0x88, 0x21, 0x08, 0x10, 0x40, 0x10, 0x00, 0x10, 0x40, 0x33, 0xfc, 0x08, 0x20, 0x10, 0x40, + 0x1f, 0xe0, 0x44, 0x44, 0x01, 0x94, 0x7e, 0x00, 0x3d, 0x88, 0x08, 0x48, 0x13, 0xf4, 0x7f, 0xfc, + 0x00, 0x00, 0x2f, 0xe8, 0x14, 0x44, 0x10, 0x00, 0x50, 0x40, 0x49, 0x20, 0x4f, 0xe4, 0x70, 0x40, + 0x08, 0x00, 0x24, 0x44, 0x7d, 0x54, 0x03, 0xe0, 0x24, 0x44, 0x55, 0xc0, 0x10, 0x04, 0x00, 0x20, + 0x7a, 0xf4, 0x11, 0x10, 0x12, 0x44, 0x10, 0x00, 0x30, 0x40, 0x09, 0x20, 0x7f, 0xfc, 0x1b, 0xc0, + 0x08, 0x00, 0x24, 0x48, 0x21, 0x38, 0x02, 0x1c, 0x3c, 0x20, 0x24, 0x7c, 0x10, 0x04, 0x00, 0x20, + 0x24, 0x48, 0x17, 0xd0, 0x11, 0x48, 0x10, 0x00, 0x13, 0xf8, 0x09, 0x20, 0x61, 0x04, 0x10, 0x7c, + 0x7f, 0xf8, 0x24, 0x48, 0x11, 0x10, 0x02, 0x00, 0x42, 0x50, 0x24, 0x40, 0x7d, 0xfc, 0x3f, 0xf0, + 0x18, 0x30, 0x09, 0x10, 0x50, 0xd0, 0x50, 0x00, 0x10, 0x40, 0x49, 0x20, 0x1e, 0xf8, 0x10, 0x40, + 0x00, 0x00, 0x04, 0x40, 0x09, 0x7c, 0x1f, 0x00, 0x7e, 0x88, 0x1d, 0xf8, 0x11, 0x10, 0x00, 0x10, + 0x24, 0x48, 0x7b, 0xa8, 0x50, 0x40, 0x30, 0x00, 0x50, 0x40, 0x39, 0x3c, 0x36, 0x5c, 0x7c, 0x40, + 0x1f, 0xe0, 0x04, 0x40, 0x79, 0x10, 0x40, 0xe4, 0x24, 0x40, 0x10, 0x40, 0x11, 0x10, 0x00, 0x10, + 0x10, 0x20, 0x01, 0x24, 0x54, 0x40, 0x10, 0x00, 0x30, 0x40, 0x20, 0x20, 0x7e, 0xf8, 0x10, 0x40, + 0x10, 0x20, 0x7f, 0xfc, 0x25, 0x38, 0x40, 0x04, 0x2d, 0xfc, 0x11, 0xf8, 0x11, 0x10, 0x1f, 0xf0, + 0x7f, 0xfc, 0x01, 0x80, 0x18, 0x20, 0x13, 0xf8, 0x10, 0x40, 0x10, 0x20, 0x0f, 0xe0, 0x11, 0xe0, + 0x10, 0x20, 0x01, 0x00, 0x25, 0x54, 0x7f, 0xfc, 0x24, 0x20, 0x7e, 0x48, 0x7c, 0x10, 0x00, 0x10, + 0x04, 0x40, 0x00, 0x40, 0x10, 0x20, 0x08, 0x00, 0x2b, 0xfc, 0x09, 0xe0, 0x0f, 0xc0, 0x10, 0x18, + 0x1f, 0xe0, 0x01, 0x00, 0x11, 0x10, 0x01, 0x00, 0x3c, 0x20, 0x00, 0x50, 0x03, 0xf0, 0x00, 0x10, + 0x08, 0x20, 0x0f, 0xe0, 0x13, 0xfc, 0x08, 0x00, 0x48, 0x00, 0x78, 0x18, 0x1f, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x04, + 0x00, 0x80, 0x70, 0x1c, 0x60, 0x0c, 0x04, 0x08, 0x02, 0x38, 0x11, 0x08, 0x08, 0x5c, 0x60, 0x0c, + 0x04, 0x00, 0x1f, 0xf0, 0x41, 0xf8, 0x63, 0xf8, 0x47, 0xfc, 0x07, 0x04, 0x1f, 0x00, 0x11, 0xc8, + 0x00, 0x80, 0x0c, 0x60, 0x10, 0x10, 0x72, 0x08, 0x12, 0x08, 0x19, 0xf8, 0x4f, 0xc4, 0x18, 0x30, + 0x05, 0x04, 0x10, 0x10, 0x42, 0x08, 0x12, 0x48, 0x28, 0x00, 0x3a, 0x88, 0x00, 0xc0, 0x11, 0x10, + 0x00, 0x80, 0x03, 0x80, 0x08, 0x20, 0x11, 0x10, 0x1b, 0xf8, 0x15, 0x08, 0x28, 0x44, 0x04, 0x40, + 0x05, 0xfc, 0x10, 0x10, 0x22, 0x08, 0x12, 0x48, 0x11, 0x8c, 0x2a, 0x88, 0x1e, 0x20, 0x11, 0x10, + 0x7e, 0x9c, 0x02, 0x80, 0x04, 0x40, 0x10, 0xa0, 0x16, 0x08, 0x11, 0x08, 0x28, 0x44, 0x02, 0x80, + 0x25, 0x24, 0x1f, 0xf0, 0x22, 0x00, 0x13, 0xf8, 0x14, 0x50, 0x3a, 0x50, 0x01, 0x90, 0x11, 0x20, + 0x40, 0x84, 0x04, 0x40, 0x02, 0x80, 0x12, 0x88, 0x13, 0xf8, 0x11, 0x08, 0x1f, 0xd4, 0x7f, 0xfc, + 0x25, 0x24, 0x01, 0x00, 0x23, 0x80, 0x52, 0x48, 0x14, 0x20, 0x02, 0x50, 0x1c, 0x40, 0x15, 0x30, + 0x40, 0x84, 0x08, 0x20, 0x02, 0x80, 0x12, 0x48, 0x12, 0x08, 0x7d, 0x08, 0x11, 0x14, 0x11, 0x10, + 0x25, 0x24, 0x01, 0x00, 0x22, 0x60, 0x32, 0x48, 0x12, 0x50, 0x7f, 0x20, 0x63, 0x0c, 0x13, 0x48, + 0x40, 0x84, 0x5f, 0xe4, 0x21, 0x20, 0x12, 0x48, 0x13, 0xf8, 0x11, 0xf8, 0x11, 0x14, 0x11, 0x10, + 0x25, 0xfc, 0x3f, 0xf8, 0x22, 0x10, 0x13, 0xf8, 0x12, 0x88, 0x00, 0x20, 0x18, 0xb0, 0x51, 0x40, + 0x7e, 0x84, 0x40, 0x04, 0x11, 0x10, 0x12, 0x48, 0x10, 0x00, 0x10, 0x40, 0x1f, 0xd4, 0x11, 0x10, + 0x24, 0x00, 0x01, 0x00, 0x22, 0x00, 0x10, 0x00, 0x72, 0x88, 0x06, 0x20, 0x04, 0x40, 0x30, 0xc0, + 0x40, 0x84, 0x7f, 0xfc, 0x11, 0x08, 0x12, 0x08, 0x77, 0xfc, 0x3c, 0x40, 0x11, 0x14, 0x1f, 0xf0, + 0x26, 0x10, 0x67, 0xcc, 0x20, 0x00, 0x51, 0x10, 0x03, 0xf8, 0x3a, 0xa8, 0x7f, 0xfc, 0x10, 0x40, + 0x40, 0x84, 0x04, 0xa0, 0x11, 0x08, 0x13, 0xf8, 0x00, 0x40, 0x40, 0x40, 0x11, 0x14, 0x01, 0x00, + 0x25, 0x10, 0x18, 0x30, 0x3f, 0xf8, 0x31, 0x10, 0x02, 0x00, 0x2a, 0xa4, 0x02, 0x00, 0x17, 0xfc, + 0x40, 0x84, 0x09, 0x10, 0x01, 0x00, 0x10, 0x80, 0x03, 0xf8, 0x20, 0x7c, 0x1f, 0xd4, 0x04, 0x40, + 0x25, 0x20, 0x04, 0x40, 0x20, 0x08, 0x17, 0xfc, 0x02, 0x00, 0x3a, 0x7c, 0x1f, 0xd0, 0x08, 0x40, + 0x78, 0xfc, 0x3f, 0x80, 0x01, 0x00, 0x7c, 0x40, 0x10, 0x40, 0x1c, 0x40, 0x10, 0x44, 0x7f, 0xfc, + 0x24, 0xfc, 0x02, 0x80, 0x20, 0x08, 0x29, 0x10, 0x13, 0xfc, 0x02, 0x40, 0x04, 0x20, 0x08, 0x40, + 0x06, 0x00, 0x00, 0x78, 0x7f, 0xfc, 0x03, 0xfc, 0x13, 0xf8, 0x10, 0x40, 0x1f, 0xc4, 0x04, 0x40, + 0x04, 0x80, 0x01, 0x00, 0x3f, 0xf8, 0x49, 0x10, 0x20, 0x00, 0x7f, 0x40, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x10, 0x40, 0x00, 0x04, 0x00, 0x00, + 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, + 0x00, 0x18, 0x01, 0x00, 0x43, 0x0c, 0x04, 0x04, 0x14, 0x84, 0x14, 0x04, 0x41, 0xc0, 0x48, 0x08, + 0x00, 0x18, 0x41, 0xc0, 0x47, 0xfc, 0x71, 0x0c, 0x04, 0x7c, 0x40, 0x7c, 0x00, 0x80, 0x10, 0x40, + 0x71, 0xe4, 0x71, 0xfc, 0x55, 0x04, 0x12, 0x04, 0x12, 0x48, 0x12, 0x08, 0x40, 0x40, 0x6f, 0xf8, + 0x00, 0x04, 0x40, 0x40, 0x28, 0x00, 0x1d, 0x38, 0x72, 0x80, 0x26, 0x84, 0x70, 0x9c, 0x10, 0x40, + 0x0d, 0x04, 0x0d, 0x20, 0x55, 0x04, 0x19, 0x08, 0x12, 0x30, 0x11, 0x10, 0x20, 0x40, 0x28, 0x08, + 0x3f, 0xe4, 0x20, 0x40, 0x13, 0xf0, 0x07, 0xc0, 0x2d, 0x00, 0x11, 0x84, 0x2e, 0x84, 0x10, 0x40, + 0x29, 0x54, 0x01, 0x20, 0x55, 0x74, 0x15, 0x10, 0x11, 0x30, 0x51, 0x10, 0x20, 0x48, 0x28, 0x08, + 0x22, 0x24, 0x20, 0x40, 0x12, 0x10, 0x7f, 0xfc, 0x29, 0x44, 0x08, 0x80, 0x20, 0x84, 0x10, 0x40, + 0x2b, 0x24, 0x01, 0xf8, 0x7f, 0x54, 0x10, 0x00, 0x51, 0x48, 0x50, 0xa0, 0x20, 0x44, 0x1f, 0xf8, + 0x22, 0x24, 0x17, 0xfc, 0x12, 0x10, 0x01, 0x00, 0x29, 0x24, 0x08, 0xc0, 0x20, 0x84, 0x10, 0x40, + 0x25, 0x24, 0x7d, 0x20, 0x55, 0x54, 0x10, 0x00, 0x51, 0x48, 0x34, 0xa0, 0x2f, 0xfc, 0x10, 0x00, + 0x02, 0x04, 0x10, 0x20, 0x13, 0xf0, 0x1f, 0xf0, 0x2d, 0x28, 0x04, 0xa0, 0x38, 0x84, 0x10, 0x40, + 0x44, 0xfc, 0x21, 0x20, 0x55, 0x54, 0x13, 0xf8, 0x35, 0x48, 0x3b, 0xfc, 0x20, 0x40, 0x1f, 0xf8, + 0x1f, 0xfc, 0x00, 0x10, 0x12, 0x10, 0x11, 0x10, 0x29, 0x10, 0x04, 0x90, 0x06, 0xfc, 0x1f, 0xf8, + 0x44, 0x80, 0x11, 0xf8, 0x7f, 0x74, 0x12, 0x08, 0x39, 0x48, 0x10, 0x40, 0x20, 0xa0, 0x10, 0x08, + 0x10, 0x00, 0x03, 0xf8, 0x77, 0xf8, 0x1f, 0xf0, 0x09, 0x10, 0x04, 0x88, 0x00, 0x00, 0x10, 0x00, + 0x05, 0xf8, 0x0d, 0x20, 0x00, 0x04, 0x72, 0x08, 0x11, 0xf8, 0x7e, 0x40, 0x20, 0x10, 0x10, 0x08, + 0x10, 0x70, 0x20, 0x00, 0x05, 0x28, 0x11, 0x10, 0x3f, 0x10, 0x02, 0x80, 0x1f, 0xf8, 0x10, 0x00, + 0x01, 0x08, 0x7b, 0x20, 0x3e, 0x74, 0x02, 0x08, 0x11, 0x00, 0x11, 0xf8, 0x27, 0xf8, 0x1f, 0xf8, + 0x11, 0x10, 0x42, 0x50, 0x07, 0xf8, 0x1f, 0xf0, 0x24, 0x7c, 0x7f, 0xfc, 0x10, 0x08, 0x1e, 0x00, + 0x7d, 0xf8, 0x25, 0xfc, 0x22, 0x04, 0x02, 0x08, 0x7d, 0x00, 0x11, 0x40, 0x20, 0x00, 0x10, 0x00, + 0x12, 0x10, 0x04, 0x88, 0x05, 0x28, 0x0d, 0xb0, 0x24, 0x10, 0x02, 0x00, 0x1f, 0xf8, 0x01, 0xc0, + 0x11, 0x08, 0x25, 0x00, 0x22, 0x04, 0x12, 0x08, 0x11, 0xfc, 0x71, 0x40, 0x3f, 0xfc, 0x1f, 0xc0, + 0x1f, 0xf0, 0x17, 0xc0, 0x2f, 0xfc, 0x1b, 0x60, 0x25, 0x10, 0x02, 0x20, 0x10, 0x08, 0x00, 0x30, + 0x11, 0xf8, 0x10, 0x90, 0x3e, 0xfc, 0x13, 0xf8, 0x10, 0x00, 0x08, 0x40, 0x00, 0x80, 0x00, 0x70, + 0x04, 0x00, 0x20, 0x38, 0x41, 0x20, 0x0d, 0xb0, 0x3d, 0x10, 0x02, 0x40, 0x1f, 0xf8, 0x00, 0x00, + 0x00, 0x00, 0x10, 0xa0, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x84, + 0x03, 0x80, 0x61, 0x04, 0x10, 0x7c, 0x60, 0x18, 0x60, 0x0c, 0x4c, 0x78, 0x4e, 0x3c, 0x78, 0x0c, + 0x11, 0xc0, 0x7f, 0xfc, 0x41, 0x98, 0x02, 0x44, 0x70, 0x08, 0x41, 0x30, 0x70, 0x00, 0x22, 0x44, + 0x00, 0x80, 0x10, 0x88, 0x10, 0x84, 0x10, 0x20, 0x18, 0x30, 0x22, 0x48, 0x45, 0x24, 0x0f, 0x10, + 0x10, 0x40, 0x01, 0x00, 0x78, 0xcc, 0x12, 0x28, 0x0c, 0x30, 0x21, 0x10, 0x0e, 0x00, 0x22, 0x28, + 0x60, 0x80, 0x12, 0x88, 0x10, 0x84, 0x00, 0x00, 0x04, 0x40, 0x22, 0x48, 0x25, 0x24, 0x08, 0x20, + 0x10, 0x40, 0x01, 0x00, 0x57, 0x24, 0x1e, 0x10, 0x02, 0xc0, 0x21, 0x10, 0x01, 0x80, 0x12, 0x54, + 0x18, 0x80, 0x13, 0x50, 0x10, 0x80, 0x7f, 0xf8, 0x02, 0x80, 0x12, 0x48, 0x24, 0xa0, 0x08, 0x40, + 0x10, 0x40, 0x01, 0x00, 0x54, 0xb4, 0x13, 0x90, 0x11, 0x10, 0x11, 0xf0, 0x00, 0x40, 0x12, 0x54, + 0x06, 0x80, 0x12, 0x50, 0x10, 0x80, 0x24, 0x90, 0x7f, 0xfc, 0x12, 0x48, 0x24, 0xa0, 0x08, 0x40, + 0x10, 0x40, 0x01, 0x00, 0x53, 0x54, 0x12, 0x28, 0x11, 0x10, 0x51, 0x10, 0x00, 0x20, 0x12, 0x54, + 0x01, 0x80, 0x52, 0x50, 0x54, 0x80, 0x24, 0x90, 0x01, 0x00, 0x12, 0x48, 0x24, 0xa0, 0x68, 0xa0, + 0x10, 0x40, 0x1f, 0xf0, 0x7d, 0xfc, 0x7a, 0x28, 0x10, 0x10, 0x35, 0xf4, 0x3f, 0xf0, 0x12, 0x54, + 0x00, 0xc0, 0x32, 0x20, 0x38, 0x80, 0x24, 0x90, 0x05, 0x80, 0x12, 0x48, 0x3d, 0xf8, 0x18, 0x90, + 0x17, 0xfc, 0x01, 0x00, 0x50, 0x80, 0x13, 0xb8, 0x1f, 0xf0, 0x12, 0x08, 0x0c, 0x10, 0x3e, 0x54, + 0x00, 0xa0, 0x12, 0x20, 0x10, 0x80, 0x3f, 0xf0, 0x64, 0x40, 0x7e, 0x78, 0x25, 0x08, 0x05, 0x08, + 0x50, 0x40, 0x01, 0x00, 0x10, 0x80, 0x12, 0x00, 0x00, 0x00, 0x17, 0x1c, 0x02, 0x08, 0x40, 0x44, + 0x00, 0x80, 0x16, 0xfc, 0x08, 0x80, 0x24, 0x90, 0x14, 0x20, 0x10, 0x00, 0x25, 0x08, 0x03, 0x00, + 0x30, 0x40, 0x01, 0x00, 0x7d, 0xf8, 0x3a, 0x44, 0x30, 0xc0, 0x30, 0xa0, 0x01, 0x08, 0x21, 0x7c, + 0x7f, 0xfc, 0x50, 0x20, 0x04, 0x80, 0x24, 0x90, 0x0d, 0x50, 0x10, 0x00, 0x3d, 0x08, 0x01, 0x00, + 0x10, 0x20, 0x01, 0x00, 0x45, 0x08, 0x43, 0xa8, 0x08, 0x20, 0x56, 0x5c, 0x3f, 0x80, 0x21, 0x20, + 0x00, 0x80, 0x32, 0x24, 0x7c, 0x80, 0x3f, 0xf0, 0x04, 0x88, 0x04, 0x40, 0x25, 0xf8, 0x7f, 0xfc, + 0x10, 0x10, 0x3f, 0xf8, 0x45, 0xf8, 0x22, 0x28, 0x04, 0x20, 0x10, 0x00, 0x10, 0x40, 0x12, 0x10, + 0x00, 0x80, 0x12, 0x24, 0x10, 0x80, 0x04, 0x80, 0x14, 0x78, 0x7f, 0xfc, 0x24, 0x90, 0x01, 0x00, + 0x0b, 0xf8, 0x01, 0x00, 0x7d, 0x08, 0x1a, 0x28, 0x6f, 0xec, 0x1f, 0xfc, 0x08, 0x20, 0x12, 0x7c, + 0x00, 0x80, 0x2c, 0x28, 0x10, 0x80, 0x04, 0x80, 0x24, 0x40, 0x04, 0x40, 0x3d, 0x08, 0x01, 0x00, + 0x08, 0x00, 0x02, 0x00, 0x01, 0xf8, 0x13, 0x38, 0x18, 0x30, 0x00, 0x80, 0x04, 0x20, 0x04, 0x00, + 0x00, 0x00, 0x48, 0x20, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x40, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x48, 0x20, 0x08, 0x7f, 0xfc, 0x00, 0x0c, 0x13, 0x80, 0x40, 0xc0, 0x47, 0xfc, 0x40, 0x80, + 0x03, 0x0c, 0x70, 0x08, 0x44, 0xc4, 0x01, 0x00, 0x30, 0x40, 0x23, 0x30, 0x20, 0xc0, 0x7f, 0xfc, + 0x12, 0x78, 0x3f, 0xf8, 0x01, 0x00, 0x00, 0x14, 0x10, 0x60, 0x48, 0x44, 0x40, 0xa0, 0x40, 0x80, + 0x70, 0x94, 0x13, 0xf8, 0x42, 0x44, 0x01, 0x00, 0x10, 0x40, 0x20, 0x88, 0x20, 0x40, 0x01, 0x00, + 0x13, 0x48, 0x20, 0x08, 0x01, 0x00, 0x00, 0x10, 0x10, 0x10, 0x24, 0x48, 0x22, 0xa8, 0x20, 0x80, + 0x0e, 0x60, 0x11, 0x10, 0x42, 0x48, 0x01, 0x00, 0x10, 0x40, 0x16, 0x48, 0x20, 0x40, 0x01, 0x00, + 0x12, 0x48, 0x20, 0x08, 0x1f, 0xf0, 0x00, 0x20, 0x53, 0x28, 0x22, 0x48, 0x22, 0xa4, 0x2f, 0xfc, + 0x00, 0x20, 0x10, 0x80, 0x70, 0x40, 0x01, 0x00, 0x13, 0xfc, 0x11, 0x28, 0x21, 0xf0, 0x01, 0x00, + 0x12, 0x78, 0x3f, 0xf8, 0x01, 0x00, 0x00, 0x20, 0x50, 0xc8, 0x12, 0x50, 0x14, 0xa4, 0x20, 0x80, + 0x3c, 0x50, 0x17, 0xfc, 0x4b, 0xf8, 0x01, 0x00, 0x54, 0x60, 0x08, 0xa8, 0x24, 0x04, 0x01, 0x00, + 0x13, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x34, 0x44, 0x11, 0x50, 0x10, 0xa0, 0x20, 0x80, + 0x24, 0x50, 0x70, 0x40, 0x4a, 0x08, 0x7f, 0xfc, 0x7e, 0xf4, 0x21, 0xf8, 0x27, 0xfc, 0x01, 0x00, + 0x12, 0xc8, 0x1f, 0xf0, 0x3f, 0x88, 0x00, 0x20, 0x38, 0x3c, 0x07, 0x60, 0x00, 0xa0, 0x27, 0xf0, + 0x24, 0x88, 0x18, 0x40, 0x4b, 0xf8, 0x01, 0x00, 0x19, 0x58, 0x40, 0x80, 0x20, 0x00, 0x01, 0x00, + 0x52, 0x78, 0x10, 0x10, 0x04, 0x70, 0x3f, 0xe0, 0x11, 0xa0, 0x00, 0x50, 0x00, 0x00, 0x20, 0x00, + 0x3c, 0x88, 0x13, 0xf8, 0x4a, 0x08, 0x01, 0x00, 0x16, 0xe4, 0x08, 0x60, 0x23, 0xf8, 0x01, 0x00, + 0x36, 0x20, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x7c, 0x60, 0x20, 0x48, 0x23, 0xf8, 0x3f, 0xfc, + 0x00, 0x80, 0x10, 0x40, 0x53, 0xf8, 0x3f, 0xf8, 0x12, 0xbc, 0x13, 0xf0, 0x62, 0x08, 0x01, 0x00, + 0x10, 0xfc, 0x1f, 0xf0, 0x5f, 0xf4, 0x5f, 0xf0, 0x10, 0x50, 0x41, 0xc0, 0x42, 0x08, 0x00, 0x00, + 0x00, 0x80, 0x13, 0xf8, 0x54, 0x44, 0x01, 0x00, 0x11, 0x48, 0x00, 0x00, 0x23, 0xf8, 0x3f, 0xf8, + 0x12, 0x28, 0x40, 0x04, 0x40, 0x04, 0x20, 0x00, 0x11, 0x88, 0x00, 0x00, 0x03, 0xf8, 0x1f, 0xf8, + 0x7f, 0xfc, 0x7a, 0xa8, 0x4a, 0x48, 0x09, 0x20, 0x7b, 0xfc, 0x04, 0x40, 0x20, 0x00, 0x00, 0x00, + 0x0a, 0x74, 0x7f, 0xfc, 0x7f, 0xfc, 0x1f, 0xf8, 0x70, 0x78, 0x10, 0x40, 0x12, 0x08, 0x11, 0x08, + 0x00, 0x90, 0x12, 0xa8, 0x49, 0x50, 0x09, 0x10, 0x10, 0x40, 0x7f, 0xfc, 0x17, 0xfc, 0x00, 0x00, + 0x0c, 0x24, 0x01, 0x00, 0x01, 0x00, 0x10, 0x00, 0x08, 0x40, 0x20, 0x80, 0x23, 0xf8, 0x01, 0x00, + 0x00, 0xa0, 0x13, 0xf8, 0x78, 0x40, 0x11, 0x10, 0x10, 0x60, 0x04, 0x40, 0x10, 0x40, 0x00, 0x00, + 0x08, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0c, + 0x60, 0x10, 0x24, 0x98, 0x01, 0x00, 0x11, 0xf8, 0x04, 0xfc, 0x14, 0x04, 0x40, 0x7c, 0x60, 0x0c, + 0x41, 0xfc, 0x11, 0xf0, 0x40, 0xe0, 0x20, 0x40, 0x00, 0x20, 0x30, 0x60, 0x6b, 0xcc, 0x18, 0x30, + 0x10, 0x10, 0x24, 0x88, 0x11, 0xfc, 0x11, 0x08, 0x02, 0x10, 0x12, 0x08, 0x20, 0x84, 0x18, 0x30, + 0x42, 0x04, 0x11, 0x10, 0x22, 0x24, 0x10, 0x40, 0x38, 0x20, 0x08, 0x20, 0x29, 0x30, 0x04, 0x40, + 0x09, 0xfc, 0x24, 0x88, 0x19, 0x20, 0x11, 0x08, 0x61, 0x10, 0x11, 0x10, 0x10, 0x84, 0x04, 0x40, + 0x22, 0x04, 0x11, 0x10, 0x29, 0x24, 0x08, 0x40, 0x28, 0x20, 0x08, 0x20, 0x29, 0x30, 0x02, 0x80, + 0x54, 0x50, 0x24, 0x88, 0x15, 0x20, 0x11, 0x08, 0x19, 0x10, 0x10, 0xa0, 0x08, 0x80, 0x02, 0x80, + 0x22, 0x40, 0x51, 0xf0, 0x29, 0x28, 0x08, 0x40, 0x2f, 0xfc, 0x0a, 0x24, 0x2d, 0x48, 0x01, 0x00, + 0x22, 0x50, 0x3f, 0xf8, 0x11, 0xf8, 0x11, 0xf8, 0x10, 0x90, 0x10, 0x40, 0x04, 0x80, 0x7f, 0xfc, + 0x12, 0x58, 0x55, 0x10, 0x10, 0x20, 0x04, 0x40, 0x29, 0x20, 0x49, 0x24, 0x2d, 0x48, 0x02, 0x80, + 0x1e, 0xfc, 0x02, 0x00, 0x11, 0x20, 0x10, 0x00, 0x14, 0x90, 0x10, 0xa0, 0x04, 0x80, 0x01, 0x00, + 0x12, 0x48, 0x39, 0xf0, 0x13, 0xfc, 0x7f, 0xfc, 0x68, 0xa0, 0x79, 0x24, 0x69, 0xf8, 0x04, 0x40, + 0x10, 0x10, 0x7f, 0xfc, 0x11, 0x20, 0x11, 0xf8, 0x12, 0xb8, 0x10, 0x90, 0x02, 0x80, 0x01, 0x00, + 0x02, 0x48, 0x30, 0x00, 0x12, 0x20, 0x04, 0x40, 0x2b, 0xf8, 0x41, 0x28, 0x3f, 0x00, 0x04, 0x40, + 0x3f, 0xf8, 0x00, 0x00, 0x11, 0xf8, 0x50, 0x00, 0x3a, 0x90, 0x11, 0x10, 0x02, 0x00, 0x00, 0x00, + 0x07, 0x48, 0x13, 0xf8, 0x51, 0x20, 0x04, 0x40, 0x3a, 0x48, 0x40, 0x20, 0x29, 0x9c, 0x08, 0x20, + 0x12, 0x90, 0x5d, 0x74, 0x75, 0x20, 0x31, 0xf8, 0x12, 0x90, 0x51, 0x08, 0x02, 0x00, 0x07, 0x00, + 0x22, 0xe8, 0x7a, 0xa8, 0x53, 0xe0, 0x04, 0x40, 0x12, 0x48, 0x7a, 0x20, 0x29, 0x54, 0x08, 0x20, + 0x7f, 0xfc, 0x41, 0x04, 0x03, 0x20, 0x10, 0x00, 0x12, 0x90, 0x31, 0x08, 0x7f, 0xfc, 0x61, 0x0c, + 0x42, 0x58, 0x13, 0xf8, 0x50, 0x80, 0x3f, 0xf8, 0x13, 0xf8, 0x09, 0x20, 0x7d, 0x50, 0x7f, 0xfc, + 0x12, 0x90, 0x7f, 0xfc, 0x01, 0xfc, 0x13, 0xfc, 0x12, 0x90, 0x11, 0x08, 0x02, 0x00, 0x11, 0x10, + 0x02, 0x40, 0x5a, 0xa8, 0x58, 0x80, 0x04, 0x40, 0x12, 0x48, 0x09, 0xfc, 0x29, 0x50, 0x01, 0x00, + 0x3f, 0xf8, 0x01, 0x00, 0x11, 0x00, 0x08, 0x00, 0x7c, 0xfc, 0x11, 0x08, 0x02, 0x10, 0x09, 0x20, + 0x12, 0x40, 0x57, 0xfc, 0x17, 0xf8, 0x04, 0x40, 0x7b, 0xf8, 0x08, 0x80, 0x2f, 0x70, 0x01, 0x00, + 0x08, 0x00, 0x1f, 0xf0, 0x10, 0x90, 0x09, 0xf8, 0x00, 0x80, 0x0b, 0xf8, 0x02, 0x20, 0x01, 0x00, + 0x20, 0x40, 0x10, 0xa0, 0x10, 0x40, 0x04, 0x40, 0x00, 0x80, 0x78, 0x80, 0x24, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, + 0x70, 0xf8, 0x01, 0xf8, 0x01, 0x00, 0x03, 0x00, 0x14, 0x70, 0x11, 0x04, 0x01, 0xf8, 0x10, 0x10, + 0x00, 0x40, 0x13, 0x00, 0x40, 0x00, 0x01, 0x04, 0x30, 0xfc, 0x44, 0x30, 0x30, 0x3c, 0x04, 0x20, + 0x5c, 0x88, 0x71, 0x08, 0x01, 0x00, 0x01, 0x04, 0x12, 0x94, 0x18, 0x88, 0x01, 0x08, 0x10, 0x20, + 0x00, 0x40, 0x10, 0xc0, 0x20, 0x00, 0x00, 0x88, 0x2b, 0x00, 0x22, 0x08, 0x08, 0x44, 0x04, 0x20, + 0x50, 0x88, 0x0d, 0x08, 0x01, 0x00, 0x61, 0x08, 0x12, 0xa4, 0x14, 0x50, 0x79, 0x08, 0x10, 0x50, + 0x7c, 0x40, 0x10, 0x20, 0x20, 0x00, 0x3c, 0x50, 0x24, 0x20, 0x21, 0x08, 0x04, 0x40, 0x02, 0x20, + 0x50, 0x88, 0x29, 0x08, 0x01, 0x00, 0x19, 0x10, 0x10, 0x48, 0x10, 0x50, 0x49, 0x08, 0x70, 0x08, + 0x54, 0x40, 0x50, 0x10, 0x20, 0x00, 0x44, 0x20, 0x25, 0xfc, 0x11, 0x08, 0x1f, 0xf0, 0x7a, 0x20, + 0x50, 0xf8, 0x29, 0x08, 0x01, 0x00, 0x05, 0x20, 0x17, 0xfc, 0x10, 0x20, 0x49, 0xf8, 0x1c, 0x04, + 0x57, 0xfc, 0x50, 0xc8, 0x20, 0x00, 0x40, 0x50, 0x2a, 0x20, 0x11, 0xf8, 0x10, 0x10, 0x4a, 0x20, + 0x5c, 0x00, 0x25, 0xf8, 0x01, 0x00, 0x01, 0x20, 0x50, 0x00, 0x7c, 0x20, 0x48, 0x00, 0x11, 0xfc, + 0x54, 0x40, 0x34, 0x48, 0x20, 0x00, 0x40, 0x50, 0x2a, 0xf8, 0x11, 0x00, 0x10, 0x10, 0x4a, 0x20, + 0x11, 0x8c, 0x44, 0x40, 0x7f, 0xfc, 0x09, 0x50, 0x33, 0xf8, 0x11, 0xfc, 0x48, 0x00, 0x10, 0x80, + 0x7c, 0x40, 0x3a, 0x40, 0x20, 0x00, 0x40, 0x88, 0x22, 0x20, 0x1f, 0xfc, 0x1f, 0xf0, 0x4a, 0x20, + 0x10, 0x70, 0x44, 0x40, 0x01, 0x00, 0x11, 0x88, 0x12, 0xa8, 0x10, 0x20, 0x7b, 0xfc, 0x7c, 0x40, + 0x55, 0xf8, 0x12, 0x44, 0x3f, 0xfc, 0x7e, 0x88, 0x2e, 0xf8, 0x10, 0x40, 0x00, 0x00, 0x4b, 0xfc, + 0x7c, 0x50, 0x04, 0x40, 0x09, 0x20, 0x21, 0x00, 0x0a, 0xa8, 0x3c, 0x20, 0x48, 0x90, 0x51, 0xfc, + 0x54, 0x40, 0x7d, 0x44, 0x04, 0x40, 0x05, 0x88, 0x64, 0x28, 0x1f, 0xf8, 0x7f, 0xfc, 0x4a, 0x00, + 0x45, 0x88, 0x00, 0x7c, 0x09, 0x10, 0x01, 0x00, 0x4b, 0xf8, 0x41, 0x20, 0x48, 0x90, 0x20, 0x40, + 0x55, 0x50, 0x11, 0x48, 0x08, 0x20, 0x04, 0x88, 0x25, 0xfc, 0x10, 0x08, 0x04, 0x40, 0x4a, 0x00, + 0x44, 0x88, 0x7e, 0x40, 0x11, 0x10, 0x7f, 0xfc, 0x20, 0x40, 0x20, 0xf8, 0x49, 0xf0, 0x20, 0x20, + 0x7d, 0x48, 0x10, 0x40, 0x00, 0x00, 0x04, 0xfc, 0x22, 0x28, 0x1f, 0xf8, 0x08, 0x20, 0x7b, 0xc0, + 0x44, 0x78, 0x10, 0x40, 0x01, 0x00, 0x01, 0x10, 0x17, 0xfc, 0x1c, 0xa0, 0x78, 0x40, 0x7d, 0xfc, + 0x02, 0x48, 0x70, 0x40, 0x3f, 0xf8, 0x7c, 0x40, 0x1e, 0xf8, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x38, + 0x7c, 0x40, 0x10, 0x40, 0x3f, 0xf8, 0x01, 0x20, 0x10, 0x40, 0x10, 0xa0, 0x03, 0xf8, 0x10, 0x20, + 0x00, 0x40, 0x08, 0x40, 0x01, 0x00, 0x00, 0x40, 0x10, 0x20, 0x7f, 0xfc, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x10, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0c, + 0x46, 0x00, 0x11, 0x30, 0x01, 0x08, 0x44, 0x04, 0x40, 0x20, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, + 0x13, 0x04, 0x03, 0x00, 0x3e, 0x40, 0x01, 0x00, 0x3f, 0xf8, 0x04, 0x20, 0x04, 0x04, 0x41, 0x10, + 0x41, 0x80, 0x11, 0x18, 0x11, 0xf8, 0x42, 0x24, 0x40, 0x20, 0x7f, 0xfc, 0x10, 0x10, 0x7f, 0xf8, + 0x10, 0xc8, 0x39, 0x18, 0x22, 0x58, 0x21, 0x18, 0x00, 0x08, 0x02, 0x20, 0x02, 0x08, 0x20, 0xa0, + 0x20, 0x40, 0x11, 0x08, 0x19, 0x08, 0x22, 0x24, 0x47, 0xfc, 0x00, 0x00, 0x1f, 0xf0, 0x40, 0x08, + 0x10, 0x30, 0x07, 0xe0, 0x22, 0x44, 0x21, 0x08, 0x00, 0x08, 0x61, 0x38, 0x01, 0x10, 0x27, 0xfc, + 0x20, 0x20, 0x11, 0x08, 0x15, 0x08, 0x21, 0x24, 0x71, 0x20, 0x00, 0x00, 0x10, 0x10, 0x40, 0x08, + 0x10, 0x10, 0x05, 0x40, 0x22, 0x44, 0x21, 0x08, 0x3f, 0xf8, 0x19, 0x24, 0x7d, 0x10, 0x10, 0x40, + 0x10, 0x10, 0x1f, 0xf8, 0x13, 0xf8, 0x11, 0x24, 0x4b, 0xf8, 0x00, 0x00, 0x1f, 0xf0, 0x60, 0x08, + 0x53, 0x08, 0x69, 0x2c, 0x3e, 0x44, 0x21, 0x08, 0x00, 0x08, 0x01, 0x24, 0x54, 0xa0, 0x13, 0xf8, + 0x10, 0xc8, 0x61, 0x40, 0x11, 0x00, 0x01, 0x24, 0x48, 0x20, 0x00, 0x00, 0x00, 0x00, 0x50, 0x68, + 0x50, 0xc4, 0x11, 0x10, 0x00, 0x44, 0x21, 0x08, 0x00, 0x08, 0x07, 0xa4, 0x54, 0x40, 0x02, 0x08, + 0x00, 0x40, 0x18, 0x5c, 0x10, 0x80, 0x09, 0x6c, 0x4b, 0x0c, 0x00, 0x00, 0x7f, 0xfc, 0x48, 0xa8, + 0x34, 0x60, 0x08, 0x20, 0x7f, 0x48, 0x3f, 0xf8, 0x3f, 0xf8, 0x79, 0x24, 0x57, 0xfc, 0x03, 0xf8, + 0x08, 0x44, 0x08, 0x44, 0x17, 0xfc, 0x05, 0x6c, 0x48, 0x90, 0x00, 0x00, 0x0a, 0xa0, 0x48, 0x88, + 0x38, 0x90, 0x7f, 0xfc, 0x14, 0x50, 0x01, 0x00, 0x01, 0x00, 0x21, 0x28, 0x54, 0x40, 0x22, 0x08, + 0x24, 0x44, 0x7f, 0x4c, 0x70, 0x40, 0x25, 0xb4, 0x50, 0x60, 0x00, 0x00, 0x12, 0x90, 0x44, 0x88, + 0x11, 0x88, 0x04, 0x40, 0x12, 0x48, 0x01, 0x00, 0x09, 0x20, 0x13, 0xa8, 0x55, 0x50, 0x43, 0xf8, + 0x42, 0x48, 0x08, 0x58, 0x01, 0x50, 0x41, 0x24, 0x52, 0x90, 0x00, 0x00, 0x02, 0x80, 0x44, 0x88, + 0x10, 0x40, 0x1f, 0xf0, 0x22, 0x48, 0x1f, 0xf0, 0x09, 0x20, 0x79, 0x24, 0x56, 0x48, 0x00, 0xa0, + 0x02, 0x48, 0x3f, 0x50, 0x01, 0x10, 0x01, 0x24, 0x49, 0x08, 0x1f, 0xf0, 0x3f, 0xf8, 0x7f, 0xf8, + 0x7b, 0xfc, 0x02, 0x00, 0x7f, 0x44, 0x10, 0x10, 0x11, 0x10, 0x29, 0x24, 0x54, 0x40, 0x17, 0xfc, + 0x10, 0x40, 0x3f, 0x48, 0x17, 0xfc, 0x11, 0x24, 0x48, 0xf8, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, + 0x10, 0x20, 0x3f, 0xf8, 0x08, 0x7c, 0x10, 0x10, 0x11, 0x10, 0x27, 0xa4, 0x13, 0xf8, 0x20, 0xa0, + 0x20, 0x40, 0x0c, 0x7c, 0x11, 0x10, 0x21, 0x04, 0x78, 0x40, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, + 0x10, 0x20, 0x01, 0x00, 0x08, 0x00, 0x1f, 0xf0, 0x01, 0x00, 0x11, 0x3c, 0x10, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xfc, + 0x14, 0xac, 0x10, 0x40, 0x40, 0x38, 0x3f, 0xf8, 0x59, 0x04, 0x1b, 0xa4, 0x40, 0xe0, 0x09, 0x04, + 0x18, 0x30, 0x01, 0xf8, 0x07, 0xfc, 0x40, 0x20, 0x1b, 0x30, 0x34, 0x7c, 0x23, 0x04, 0x10, 0x40, + 0x14, 0xa4, 0x14, 0x44, 0x40, 0x08, 0x21, 0x08, 0x44, 0x88, 0x04, 0x68, 0x40, 0x20, 0x08, 0x88, + 0x64, 0xc8, 0x11, 0x08, 0x02, 0xa8, 0x20, 0x20, 0x05, 0xc0, 0x12, 0xc0, 0x20, 0x88, 0x17, 0xf8, + 0x14, 0xa4, 0x12, 0x48, 0x40, 0x08, 0x21, 0x08, 0x24, 0x50, 0x05, 0xb0, 0x40, 0x20, 0x08, 0x50, + 0x14, 0x28, 0x19, 0x08, 0x42, 0xa8, 0x10, 0x20, 0x6b, 0x2c, 0x11, 0x40, 0x20, 0x50, 0x13, 0xf8, + 0x17, 0xfc, 0x11, 0x50, 0x40, 0x08, 0x21, 0x08, 0x24, 0x50, 0x64, 0x68, 0x40, 0x20, 0x78, 0x50, + 0x04, 0x08, 0x11, 0xf8, 0x4a, 0xa8, 0x08, 0x20, 0x11, 0x10, 0x11, 0x7c, 0x39, 0x24, 0x13, 0xf8, + 0x10, 0x80, 0x10, 0xe0, 0x50, 0x48, 0x21, 0x08, 0x24, 0x20, 0x15, 0xe0, 0x40, 0x20, 0x0e, 0x20, + 0x24, 0x48, 0x15, 0x08, 0x7b, 0xf8, 0x08, 0x20, 0x7f, 0xfc, 0x11, 0x40, 0x25, 0x24, 0x52, 0x48, + 0x17, 0xfc, 0x10, 0x40, 0x48, 0x88, 0x01, 0x00, 0x25, 0xfc, 0x04, 0x38, 0x40, 0x20, 0x08, 0x20, + 0x44, 0x88, 0x13, 0x08, 0x4b, 0x04, 0x04, 0x20, 0x04, 0x40, 0x70, 0x40, 0x25, 0x24, 0x53, 0xf8, + 0x10, 0x00, 0x17, 0xfc, 0x45, 0x08, 0x01, 0x00, 0x24, 0x20, 0x3c, 0x44, 0x40, 0x20, 0x08, 0x20, + 0x7c, 0xf8, 0x11, 0xf8, 0x4f, 0xf8, 0x04, 0x20, 0x3f, 0xf8, 0x1b, 0xfc, 0x25, 0x24, 0x50, 0x40, + 0x55, 0x54, 0x50, 0x40, 0x42, 0x08, 0x7f, 0xfc, 0x3d, 0x20, 0x2b, 0xd4, 0x44, 0x20, 0x7f, 0x20, + 0x40, 0x80, 0x10, 0x80, 0x49, 0x90, 0x7f, 0xfc, 0x04, 0x40, 0x10, 0x00, 0x25, 0x04, 0x57, 0xfc, + 0x34, 0x44, 0x30, 0x40, 0x42, 0x08, 0x01, 0x00, 0x20, 0xf8, 0x29, 0x68, 0x7f, 0xe0, 0x28, 0x88, + 0x40, 0x80, 0x77, 0xfc, 0x4f, 0xfc, 0x04, 0x20, 0x1f, 0xf0, 0x11, 0xf8, 0x29, 0xfc, 0x5b, 0xf8, + 0x17, 0xfc, 0x14, 0x40, 0x42, 0x08, 0x01, 0x00, 0x22, 0x80, 0x29, 0xc8, 0x04, 0x00, 0x28, 0x84, + 0x7c, 0xf8, 0x00, 0x50, 0x48, 0x40, 0x04, 0x20, 0x10, 0x10, 0x79, 0x08, 0x28, 0x00, 0x18, 0x00, + 0x10, 0x40, 0x13, 0xf8, 0x7f, 0xf8, 0x01, 0x00, 0x7d, 0x00, 0x29, 0x54, 0x04, 0x00, 0x10, 0x7c, + 0x04, 0x08, 0x00, 0x48, 0x78, 0x40, 0x3c, 0x20, 0x1f, 0xf0, 0x11, 0xf8, 0x24, 0xf8, 0x17, 0xfc, + 0x0b, 0xfc, 0x0a, 0x40, 0x02, 0x00, 0x3f, 0xf8, 0x10, 0xfc, 0x09, 0xc4, 0x00, 0x00, 0x7e, 0x40, + 0x04, 0x08, 0x11, 0xf4, 0x03, 0xf8, 0x06, 0x20, 0x10, 0x10, 0x11, 0x08, 0x24, 0x88, 0x11, 0x30, + 0x08, 0x00, 0x08, 0x40, 0x02, 0x00, 0x01, 0x00, 0x10, 0x80, 0x79, 0x5c, 0x00, 0x00, 0x08, 0x40, + 0x7c, 0xf8, 0x10, 0x44, 0x00, 0x40, 0x01, 0x20, 0x1f, 0xf0, 0x11, 0xf8, 0x3c, 0x88, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x08, 0x40, + 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x78, + 0x08, 0x58, 0x1f, 0x00, 0x17, 0xfc, 0x43, 0xf0, 0x63, 0xfc, 0x10, 0x30, 0x10, 0x20, 0x49, 0x04, + 0x7f, 0xfc, 0x5f, 0xfc, 0x7e, 0x04, 0x43, 0xf8, 0x01, 0x00, 0x11, 0x18, 0x01, 0x00, 0x44, 0x48, + 0x65, 0xa8, 0x08, 0x80, 0x10, 0x00, 0x24, 0x14, 0x1c, 0x20, 0x10, 0x10, 0x10, 0x20, 0x49, 0x08, + 0x00, 0x00, 0x40, 0x80, 0x01, 0xf4, 0x42, 0x08, 0x21, 0x08, 0x11, 0x08, 0x01, 0x00, 0x44, 0x48, + 0x5a, 0xa8, 0x58, 0x40, 0x10, 0x00, 0x24, 0x04, 0x14, 0x20, 0x10, 0x10, 0x10, 0x20, 0x25, 0x10, + 0x00, 0x00, 0x20, 0x80, 0x01, 0x08, 0x22, 0x08, 0x3f, 0xf8, 0x11, 0x08, 0x21, 0x38, 0x44, 0x48, + 0x52, 0xa8, 0x77, 0xa0, 0x11, 0xf8, 0x24, 0x48, 0x11, 0xfc, 0x10, 0x10, 0x12, 0x20, 0x25, 0x10, + 0x41, 0x04, 0x20, 0x80, 0x1f, 0xf0, 0x22, 0x08, 0x21, 0x08, 0x51, 0x08, 0x21, 0x08, 0x44, 0x48, + 0x53, 0xb8, 0x54, 0xe0, 0x11, 0x08, 0x04, 0x80, 0x10, 0x20, 0x50, 0x90, 0x51, 0x24, 0x15, 0x20, + 0x20, 0x88, 0x20, 0x80, 0x11, 0x10, 0x12, 0x08, 0x3f, 0xf8, 0x51, 0xf8, 0x21, 0x08, 0x7c, 0x78, + 0x5a, 0xa8, 0x57, 0x80, 0x11, 0x08, 0x00, 0x00, 0x7c, 0x20, 0x50, 0x90, 0x50, 0xa8, 0x15, 0x30, + 0x22, 0x88, 0x2f, 0xf8, 0x7f, 0xf0, 0x13, 0xf8, 0x01, 0x00, 0x35, 0x08, 0x21, 0x08, 0x10, 0x48, + 0x53, 0xb8, 0x74, 0x80, 0x11, 0xf8, 0x1f, 0xf0, 0x54, 0x00, 0x35, 0x10, 0x34, 0xa8, 0x05, 0x28, + 0x12, 0x50, 0x20, 0x80, 0x09, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x39, 0xf8, 0x21, 0x08, 0x10, 0x48, + 0x12, 0xa8, 0x46, 0xc0, 0x51, 0x08, 0x11, 0x10, 0x55, 0xfc, 0x38, 0x10, 0x38, 0x70, 0x05, 0x24, + 0x14, 0x50, 0x20, 0x80, 0x47, 0xe4, 0x04, 0x04, 0x11, 0x10, 0x11, 0x08, 0x3f, 0xf8, 0x7c, 0x48, + 0x7a, 0xa8, 0x3d, 0x20, 0x55, 0x08, 0x11, 0x10, 0x54, 0x20, 0x10, 0x10, 0x10, 0x70, 0x25, 0x20, + 0x08, 0x20, 0x20, 0x80, 0x29, 0x28, 0x22, 0x08, 0x3f, 0xf8, 0x7d, 0xf8, 0x01, 0x00, 0x11, 0xfc, + 0x4b, 0xb8, 0x20, 0xe0, 0x55, 0xf8, 0x1f, 0xf0, 0x7c, 0x20, 0x10, 0x10, 0x10, 0x20, 0x45, 0xe0, + 0x08, 0x20, 0x20, 0x00, 0x0a, 0x80, 0x42, 0x08, 0x11, 0x10, 0x10, 0x40, 0x01, 0x00, 0x10, 0x48, + 0x48, 0x00, 0x20, 0x80, 0x18, 0x00, 0x11, 0x10, 0x11, 0xfc, 0x7d, 0xfc, 0x7d, 0xfc, 0x04, 0x18, + 0x08, 0x20, 0x3f, 0xfc, 0x40, 0x44, 0x01, 0x10, 0x48, 0x24, 0x12, 0x44, 0x7f, 0xfc, 0x70, 0x48, + 0x4b, 0xf8, 0x00, 0x00, 0x13, 0xfc, 0x11, 0x10, 0x10, 0x20, 0x10, 0x10, 0x10, 0x20, 0x17, 0xc0, + 0x08, 0x20, 0x00, 0x80, 0x7f, 0xfc, 0x11, 0x10, 0x7f, 0xfc, 0x71, 0x48, 0x01, 0x00, 0x0c, 0x48, + 0x7a, 0x48, 0x00, 0x00, 0x10, 0x00, 0x1f, 0xf0, 0x10, 0x20, 0x10, 0x10, 0x10, 0x20, 0x20, 0x38, + 0x08, 0x20, 0x00, 0x80, 0x01, 0x00, 0x21, 0x10, 0x01, 0x00, 0x08, 0x40, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, + 0x1f, 0xf0, 0x12, 0x4c, 0x20, 0x70, 0x01, 0x00, 0x60, 0x40, 0x43, 0xf0, 0x43, 0xfc, 0x17, 0xfc, + 0x47, 0xfc, 0x09, 0xfc, 0x60, 0x7c, 0x47, 0xfc, 0x5c, 0x7c, 0x00, 0x80, 0x38, 0x18, 0x02, 0x08, + 0x10, 0x10, 0x12, 0x44, 0x20, 0x10, 0x01, 0x00, 0x10, 0x40, 0x24, 0x14, 0x20, 0x00, 0x10, 0x40, + 0x58, 0x00, 0x04, 0x50, 0x18, 0x84, 0x28, 0x40, 0x4a, 0x80, 0x08, 0x98, 0x06, 0xe0, 0x01, 0x10, + 0x10, 0x10, 0x12, 0x44, 0x27, 0x90, 0x01, 0x00, 0x08, 0x58, 0x24, 0x04, 0x28, 0x00, 0x10, 0x40, + 0x28, 0x20, 0x05, 0xdc, 0x04, 0x90, 0x10, 0x40, 0x29, 0x64, 0x08, 0x88, 0x11, 0x10, 0x60, 0xa0, + 0x1f, 0xf0, 0x12, 0x44, 0x24, 0x90, 0x01, 0x00, 0x08, 0x44, 0x04, 0x48, 0x28, 0x00, 0x10, 0x40, + 0x28, 0x20, 0x63, 0x54, 0x02, 0xa0, 0x10, 0x40, 0x29, 0x48, 0x08, 0x88, 0x11, 0x10, 0x1a, 0x88, + 0x00, 0x00, 0x52, 0xf4, 0x24, 0x90, 0x01, 0x00, 0x08, 0x44, 0x04, 0x80, 0x10, 0x00, 0x50, 0x40, + 0x2e, 0x20, 0x1b, 0x54, 0x02, 0x80, 0x17, 0xfc, 0x29, 0x48, 0x48, 0x88, 0x10, 0x10, 0x12, 0x48, + 0x1f, 0xf0, 0x52, 0x44, 0x27, 0x90, 0x01, 0x00, 0x7f, 0x44, 0x00, 0x00, 0x11, 0xf8, 0x50, 0x40, + 0x08, 0x20, 0x12, 0x00, 0x1f, 0xf0, 0x10, 0x40, 0x29, 0x58, 0x28, 0x88, 0x7f, 0xf0, 0x12, 0x48, + 0x00, 0x00, 0x32, 0xf4, 0x60, 0x10, 0x7f, 0xfc, 0x08, 0x48, 0x02, 0x00, 0x10, 0x00, 0x34, 0x40, + 0x09, 0xfc, 0x12, 0x7c, 0x11, 0x10, 0x10, 0x40, 0x3b, 0x54, 0x1f, 0xf8, 0x10, 0x58, 0x12, 0x48, + 0x1f, 0xf0, 0x3a, 0xa4, 0x20, 0x10, 0x01, 0x00, 0x08, 0x50, 0x03, 0xf8, 0x50, 0x00, 0x38, 0x40, + 0x7f, 0x20, 0x13, 0xc4, 0x11, 0x10, 0x77, 0xf8, 0x28, 0x50, 0x08, 0x80, 0x08, 0x44, 0x12, 0x08, + 0x00, 0x00, 0x12, 0x94, 0x17, 0xfc, 0x01, 0x00, 0x3e, 0x48, 0x02, 0x00, 0x50, 0x00, 0x13, 0xf8, + 0x08, 0x20, 0x12, 0x70, 0x7f, 0xf0, 0x02, 0x40, 0x29, 0x78, 0x04, 0x80, 0x3f, 0xfc, 0x13, 0xf8, + 0x7f, 0xfc, 0x13, 0xfc, 0x10, 0x00, 0x01, 0x00, 0x08, 0x48, 0x43, 0xf8, 0x53, 0xfc, 0x10, 0x40, + 0x08, 0x20, 0x7a, 0x44, 0x11, 0x00, 0x02, 0x40, 0x3a, 0x48, 0x04, 0x00, 0x24, 0x40, 0x10, 0x80, + 0x00, 0x00, 0x78, 0x40, 0x04, 0x40, 0x01, 0x00, 0x7f, 0x44, 0x22, 0x00, 0x58, 0x00, 0x7c, 0x40, + 0x3e, 0x20, 0x13, 0xfc, 0x08, 0x80, 0x11, 0x00, 0x28, 0x78, 0x7f, 0xfc, 0x3f, 0xf8, 0x78, 0x40, + 0x0f, 0xe0, 0x13, 0xfc, 0x7f, 0xfc, 0x3f, 0xf8, 0x08, 0x7c, 0x1f, 0xfc, 0x14, 0x90, 0x10, 0x40, + 0x08, 0xf8, 0x10, 0x40, 0x07, 0xc0, 0x17, 0xf8, 0x29, 0x48, 0x02, 0x00, 0x04, 0x48, 0x03, 0xfc, + 0x00, 0x00, 0x10, 0x40, 0x04, 0x40, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x88, 0x10, 0x40, + 0x08, 0x00, 0x10, 0x78, 0x04, 0x00, 0x20, 0x80, 0x3a, 0x78, 0x02, 0x00, 0x3f, 0xf8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, + 0x16, 0x1c, 0x3e, 0x00, 0x01, 0x00, 0x30, 0x30, 0x4f, 0x38, 0x46, 0x00, 0x04, 0x1c, 0x07, 0xfc, + 0x3e, 0xf8, 0x3f, 0xf8, 0x7f, 0xfc, 0x4f, 0xfc, 0x47, 0x0c, 0x2c, 0xcc, 0x1f, 0xf0, 0x40, 0x08, + 0x11, 0x60, 0x03, 0x80, 0x01, 0x00, 0x10, 0x10, 0x40, 0xc0, 0x21, 0x3c, 0x04, 0x04, 0x00, 0x40, + 0x22, 0x88, 0x21, 0x08, 0x12, 0x90, 0x40, 0x80, 0x40, 0xd0, 0x24, 0x30, 0x10, 0x10, 0x40, 0x08, + 0x10, 0x80, 0x00, 0xc0, 0x01, 0x00, 0x10, 0x90, 0x21, 0x20, 0x21, 0x24, 0x45, 0x04, 0x00, 0x40, + 0x22, 0x88, 0x21, 0x08, 0x12, 0x90, 0x20, 0x80, 0x40, 0x60, 0x3c, 0x30, 0x10, 0x10, 0x70, 0x08, + 0x11, 0x40, 0x63, 0x60, 0x01, 0x00, 0x11, 0x10, 0x22, 0x10, 0x11, 0x24, 0x4c, 0xc4, 0x63, 0xf8, + 0x7e, 0xfc, 0x21, 0x08, 0x12, 0x90, 0x20, 0x80, 0x72, 0x90, 0x24, 0x48, 0x1f, 0xf0, 0x4b, 0xc8, + 0x10, 0x40, 0x31, 0x30, 0x01, 0x00, 0x10, 0x10, 0x27, 0xf0, 0x11, 0x24, 0x7c, 0xf4, 0x18, 0x40, + 0x08, 0x10, 0x21, 0x08, 0x1f, 0xf0, 0x10, 0x80, 0x49, 0x08, 0x7f, 0x48, 0x00, 0x00, 0x4a, 0x48, + 0x13, 0xf8, 0x1d, 0x18, 0x01, 0x00, 0x77, 0xfc, 0x20, 0x00, 0x11, 0x24, 0x4d, 0x54, 0x10, 0x40, + 0x04, 0x20, 0x21, 0x08, 0x20, 0x00, 0x17, 0xf8, 0x48, 0xf8, 0x24, 0x88, 0x7f, 0xfc, 0x4a, 0x48, + 0x12, 0x48, 0x09, 0x10, 0x3f, 0xf8, 0x18, 0x10, 0x23, 0xe0, 0x09, 0x24, 0x4d, 0x54, 0x13, 0xf8, + 0x7f, 0xfc, 0x21, 0x08, 0x10, 0x30, 0x00, 0x80, 0x48, 0x80, 0x7e, 0x7c, 0x04, 0x40, 0x4a, 0x48, + 0x53, 0xf8, 0x01, 0x00, 0x21, 0x08, 0x10, 0x10, 0x22, 0x20, 0x09, 0x24, 0x4d, 0x54, 0x12, 0x48, + 0x01, 0x00, 0x21, 0x08, 0x08, 0x90, 0x00, 0x80, 0x4b, 0x3c, 0x24, 0x40, 0x0f, 0xe0, 0x53, 0xc8, + 0x32, 0x48, 0x7f, 0xfc, 0x21, 0x08, 0x17, 0xfc, 0x2f, 0xf8, 0x09, 0x24, 0x4d, 0x74, 0x12, 0x48, + 0x3e, 0xf8, 0x21, 0x08, 0x09, 0x10, 0x20, 0x80, 0x50, 0xa4, 0x5d, 0x74, 0x08, 0x20, 0x50, 0x08, + 0x13, 0xf8, 0x09, 0x00, 0x3f, 0xf8, 0x78, 0x40, 0x22, 0x20, 0x7f, 0x3c, 0x4d, 0x04, 0x7b, 0xf8, + 0x22, 0x88, 0x01, 0x00, 0x7f, 0xfc, 0x4f, 0xfc, 0x53, 0xfc, 0x41, 0x04, 0x3f, 0xf8, 0x48, 0x08, + 0x10, 0x40, 0x09, 0xf0, 0x21, 0x08, 0x10, 0x40, 0x20, 0x00, 0x08, 0x00, 0x7d, 0x04, 0x12, 0x48, + 0x22, 0x88, 0x01, 0x00, 0x08, 0x90, 0x00, 0x00, 0x48, 0x40, 0x7f, 0xfc, 0x01, 0x00, 0x48, 0x08, + 0x0b, 0xfc, 0x09, 0x00, 0x21, 0x08, 0x13, 0xf8, 0x3f, 0xfc, 0x08, 0x00, 0x07, 0xfc, 0x12, 0x48, + 0x3e, 0xf8, 0x01, 0x00, 0x09, 0x10, 0x10, 0x80, 0x49, 0xf8, 0x01, 0x00, 0x7f, 0xfc, 0x7b, 0xfc, + 0x08, 0x00, 0x01, 0x00, 0x3f, 0xf8, 0x10, 0x40, 0x00, 0x80, 0x08, 0x00, 0x01, 0x00, 0x13, 0xf8, + 0x00, 0x00, 0x01, 0x00, 0x0f, 0xf0, 0x21, 0x00, 0x78, 0x40, 0x1f, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x03, 0x00, 0x47, 0xfc, 0x01, 0x00, 0x01, 0x04, 0x04, 0x00, 0x10, 0xc0, 0x00, 0xc0, 0x08, 0x60, + 0x43, 0xf8, 0x07, 0x00, 0x02, 0x04, 0x70, 0x08, 0x41, 0x80, 0x10, 0x70, 0x1f, 0xf0, 0x61, 0x0c, + 0x38, 0x98, 0x58, 0x88, 0x01, 0x00, 0x71, 0xfc, 0x22, 0x00, 0x17, 0x24, 0x07, 0x00, 0x08, 0x20, + 0x42, 0x08, 0x01, 0x00, 0x4b, 0xfc, 0x13, 0xf8, 0x48, 0x84, 0x10, 0x10, 0x10, 0x10, 0x19, 0x30, + 0x06, 0xa0, 0x28, 0x48, 0x01, 0x00, 0x0d, 0x24, 0x3e, 0x00, 0x10, 0xa8, 0x60, 0x8c, 0x0f, 0xe0, + 0x23, 0xf8, 0x01, 0x00, 0x7a, 0x44, 0x12, 0x48, 0x24, 0x88, 0x1f, 0xf0, 0x1f, 0xf0, 0x05, 0x40, + 0x39, 0xc0, 0x2e, 0x50, 0x7f, 0xfc, 0x01, 0x24, 0x25, 0x00, 0x17, 0x70, 0x13, 0x10, 0x08, 0x20, + 0x22, 0x08, 0x01, 0x00, 0x4a, 0x44, 0x12, 0x48, 0x24, 0x90, 0x10, 0x10, 0x10, 0x10, 0x7f, 0xfc, + 0x06, 0xa0, 0x28, 0xa8, 0x01, 0x00, 0x01, 0x24, 0x25, 0x00, 0x10, 0xb0, 0x08, 0x20, 0x0f, 0xe0, + 0x13, 0xf8, 0x01, 0x00, 0x4b, 0xfc, 0x10, 0x40, 0x12, 0x90, 0x1f, 0xf0, 0x1f, 0xf0, 0x01, 0x00, + 0x39, 0x10, 0x08, 0xa8, 0x11, 0x00, 0x7d, 0x24, 0x25, 0x00, 0x17, 0x48, 0x7f, 0xfc, 0x08, 0x20, + 0x10, 0x00, 0x7f, 0xfc, 0x7a, 0x44, 0x77, 0xfc, 0x12, 0xa0, 0x10, 0x10, 0x00, 0x00, 0x71, 0x1c, + 0x06, 0x00, 0x7e, 0xa8, 0x10, 0x7c, 0x21, 0x24, 0x65, 0x00, 0x10, 0x80, 0x04, 0x40, 0x4f, 0xe4, + 0x04, 0x44, 0x01, 0x00, 0x4b, 0xfc, 0x18, 0x40, 0x02, 0xa0, 0x1f, 0xf0, 0x7f, 0xfc, 0x0c, 0x60, + 0x1f, 0xf0, 0x00, 0xa8, 0x10, 0x84, 0x11, 0xfc, 0x3d, 0x00, 0x53, 0xf8, 0x1f, 0xf0, 0x40, 0x04, + 0x02, 0xa8, 0x01, 0x00, 0x48, 0x00, 0x14, 0x40, 0x02, 0xa0, 0x00, 0x00, 0x11, 0x10, 0x03, 0x80, + 0x40, 0x04, 0x3e, 0x88, 0x16, 0x84, 0x09, 0x24, 0x21, 0x00, 0x32, 0x48, 0x04, 0x40, 0x7f, 0xfc, + 0x21, 0x10, 0x1f, 0xf0, 0x78, 0x90, 0x13, 0xf8, 0x0e, 0xd0, 0x64, 0xfc, 0x1f, 0xf0, 0x32, 0x40, + 0x7f, 0xfc, 0x22, 0xf8, 0x51, 0x80, 0x79, 0x24, 0x11, 0x00, 0x17, 0xf8, 0x5f, 0xf4, 0x09, 0x20, + 0x47, 0xfc, 0x40, 0x04, 0x48, 0x90, 0x12, 0x00, 0x20, 0xc8, 0x1c, 0x84, 0x51, 0x10, 0x0c, 0x20, + 0x04, 0x40, 0x3e, 0x40, 0x30, 0xe0, 0x25, 0x24, 0x11, 0x00, 0x12, 0x20, 0x44, 0x44, 0x09, 0xe0, + 0x01, 0x10, 0x40, 0x04, 0x4b, 0xfc, 0x79, 0x50, 0x20, 0x80, 0x04, 0xe0, 0x3f, 0xf0, 0x07, 0xe0, + 0x7f, 0xfc, 0x22, 0x20, 0x10, 0x90, 0x25, 0x24, 0x7d, 0xfc, 0x09, 0xf0, 0x7f, 0xfc, 0x08, 0x20, + 0x13, 0xb8, 0x7f, 0xfc, 0x78, 0x90, 0x12, 0x88, 0x40, 0x80, 0x7c, 0x98, 0x10, 0x80, 0x02, 0x00, + 0x04, 0x40, 0x3e, 0xf8, 0x08, 0x88, 0x11, 0xfc, 0x00, 0x20, 0x08, 0x80, 0x01, 0x00, 0x0f, 0xe0, + 0x21, 0x10, 0x01, 0x00, 0x00, 0x90, 0x13, 0xc0, 0x00, 0x80, 0x04, 0x80, 0x0f, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x80, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, + 0x07, 0xcc, 0x3f, 0xfc, 0x7f, 0xfc, 0x7f, 0xfc, 0x14, 0x1c, 0x10, 0x10, 0x06, 0x0c, 0x20, 0x1c, + 0x03, 0x4c, 0x01, 0x04, 0x30, 0x40, 0x36, 0x0c, 0x27, 0xe0, 0x00, 0xcc, 0x01, 0x00, 0x40, 0x08, + 0x0e, 0x10, 0x20, 0x44, 0x01, 0x00, 0x01, 0x00, 0x12, 0x14, 0x10, 0x10, 0x11, 0xb0, 0x20, 0x04, + 0x01, 0x34, 0x42, 0x8c, 0x16, 0x4c, 0x11, 0x94, 0x24, 0x24, 0x0e, 0x34, 0x01, 0xfc, 0x40, 0x08, + 0x03, 0x38, 0x21, 0x84, 0x01, 0x10, 0x1f, 0xf0, 0x11, 0x14, 0x10, 0x10, 0x18, 0x40, 0x27, 0xe4, + 0x01, 0x10, 0x7e, 0x54, 0x11, 0x50, 0x10, 0x64, 0x25, 0x0c, 0x01, 0x90, 0x45, 0x20, 0x40, 0x00, + 0x47, 0xfc, 0x26, 0x04, 0x01, 0x20, 0x01, 0x00, 0x11, 0x10, 0x53, 0x90, 0x14, 0xa0, 0x24, 0x24, + 0x71, 0x28, 0x42, 0x24, 0x10, 0xe0, 0x10, 0x20, 0x37, 0x98, 0x60, 0x10, 0x25, 0x20, 0x40, 0x00, + 0x79, 0x20, 0x20, 0x44, 0x01, 0x00, 0x1f, 0xf0, 0x50, 0x90, 0x50, 0x70, 0x11, 0x10, 0x27, 0xe4, + 0x57, 0x28, 0x42, 0x50, 0x17, 0xfc, 0x10, 0x50, 0x01, 0x00, 0x1b, 0xa8, 0x29, 0xf8, 0x40, 0x00, + 0x4b, 0xf8, 0x39, 0x9c, 0x1f, 0xf0, 0x11, 0x10, 0x50, 0x90, 0x34, 0x1c, 0x11, 0x08, 0x24, 0x24, + 0x51, 0xa4, 0x42, 0x50, 0x70, 0x40, 0x70, 0x50, 0x18, 0xc0, 0x12, 0xa8, 0x19, 0x20, 0x40, 0x00, + 0x4f, 0xfc, 0x26, 0x64, 0x01, 0x00, 0x1f, 0xf0, 0x34, 0x90, 0x38, 0x10, 0x13, 0xf8, 0x27, 0xe4, + 0x51, 0x24, 0x42, 0x48, 0x1b, 0xbc, 0x1c, 0x88, 0x16, 0x4c, 0x12, 0xa4, 0x11, 0x20, 0x7f, 0xf0, + 0x49, 0x20, 0x21, 0x84, 0x01, 0x00, 0x11, 0x10, 0x38, 0x90, 0x10, 0x90, 0x14, 0x00, 0x20, 0x04, + 0x51, 0x20, 0x7e, 0x48, 0x12, 0xa4, 0x10, 0x88, 0x13, 0x58, 0x13, 0xa4, 0x29, 0xf8, 0x42, 0x10, + 0x4f, 0xb8, 0x2a, 0x44, 0x1f, 0xf0, 0x7f, 0xfc, 0x10, 0x90, 0x7d, 0x10, 0x72, 0x0c, 0x0b, 0xfc, + 0x57, 0xfc, 0x11, 0xc0, 0x13, 0xbc, 0x13, 0xc0, 0x56, 0x68, 0x10, 0x20, 0x49, 0x20, 0x42, 0x10, + 0x4f, 0xb8, 0x24, 0x24, 0x40, 0x04, 0x10, 0x10, 0x10, 0x90, 0x10, 0x10, 0x01, 0x10, 0x10, 0x00, + 0x51, 0x20, 0x10, 0x7c, 0x78, 0x00, 0x7c, 0xbc, 0x76, 0x48, 0x78, 0x20, 0x07, 0x20, 0x42, 0x10, + 0x78, 0x00, 0x23, 0xe4, 0x40, 0x04, 0x1f, 0xf0, 0x7c, 0x90, 0x10, 0x50, 0x01, 0x10, 0x45, 0x08, + 0x71, 0x24, 0x10, 0x40, 0x11, 0xf0, 0x10, 0x80, 0x33, 0xfc, 0x17, 0xfc, 0x05, 0xfc, 0x7f, 0xf0, + 0x07, 0xfc, 0x22, 0x04, 0x7f, 0xfc, 0x10, 0x10, 0x10, 0xf0, 0x70, 0x90, 0x11, 0x10, 0x28, 0x90, + 0x07, 0x28, 0x1e, 0x48, 0x11, 0x10, 0x10, 0x88, 0x11, 0x00, 0x10, 0x20, 0x7d, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x20, 0x04, 0x01, 0x00, 0x1f, 0xf0, 0x10, 0x00, 0x08, 0x10, 0x11, 0xf0, 0x1e, 0x7c, + 0x00, 0xa0, 0x10, 0x48, 0x11, 0xf0, 0x10, 0x90, 0x09, 0x80, 0x10, 0x28, 0x00, 0x90, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x40, + 0x00, 0x00, 0x10, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xe0, + 0x10, 0xfc, 0x56, 0xa0, 0x08, 0x20, 0x10, 0x40, 0x11, 0x8c, 0x7f, 0xfc, 0x10, 0x40, 0x08, 0x20, + 0x30, 0xfc, 0x60, 0x3c, 0x15, 0x04, 0x47, 0xfc, 0x44, 0x1c, 0x21, 0x18, 0x00, 0x30, 0x08, 0x20, + 0x19, 0x04, 0x2d, 0x60, 0x0c, 0x20, 0x10, 0x40, 0x4a, 0x50, 0x04, 0x40, 0x14, 0x44, 0x49, 0x24, + 0x11, 0x04, 0x10, 0x44, 0x14, 0x88, 0x58, 0x40, 0x44, 0x04, 0x21, 0x08, 0x00, 0x08, 0x08, 0x20, + 0x15, 0x04, 0x18, 0xc0, 0x0a, 0x20, 0x13, 0xf8, 0x40, 0x20, 0x04, 0x40, 0x12, 0x48, 0x2a, 0xa8, + 0x11, 0x00, 0x08, 0x44, 0x55, 0x88, 0x70, 0x54, 0x24, 0x04, 0x21, 0x08, 0x00, 0x08, 0x08, 0x20, + 0x11, 0x30, 0x31, 0x80, 0x08, 0x20, 0x10, 0x40, 0x3f, 0x50, 0x04, 0x40, 0x11, 0x50, 0x1c, 0x70, + 0x11, 0x18, 0x04, 0x40, 0x36, 0x50, 0x53, 0xc8, 0x24, 0x04, 0x2f, 0xe8, 0x7f, 0xe8, 0x08, 0x20, + 0x11, 0x08, 0x4a, 0x40, 0x08, 0x20, 0x55, 0xf4, 0x2a, 0x48, 0x04, 0x40, 0x10, 0xe0, 0x08, 0x20, + 0x11, 0x04, 0x04, 0x40, 0x14, 0x50, 0x5d, 0x48, 0x15, 0xe4, 0x21, 0x08, 0x00, 0x08, 0x6f, 0xec, + 0x11, 0xe8, 0x21, 0x00, 0x3e, 0x20, 0x52, 0x48, 0x2a, 0x48, 0x14, 0x60, 0x17, 0xfc, 0x7e, 0xfc, + 0x71, 0xe4, 0x04, 0x40, 0x7f, 0x20, 0x11, 0x54, 0x15, 0x24, 0x2f, 0xe8, 0x00, 0x08, 0x10, 0x10, + 0x11, 0x28, 0x10, 0x80, 0x08, 0x20, 0x31, 0x10, 0x2a, 0xf8, 0x14, 0x50, 0x10, 0x40, 0x08, 0x20, + 0x18, 0x24, 0x04, 0x40, 0x15, 0x20, 0x11, 0xd4, 0x05, 0x24, 0x22, 0x88, 0x1f, 0xf8, 0x08, 0x20, + 0x11, 0x28, 0x10, 0x80, 0x08, 0x20, 0x37, 0xfc, 0x3f, 0x00, 0x14, 0x50, 0x50, 0x40, 0x01, 0x00, + 0x10, 0x24, 0x7f, 0xfc, 0x7f, 0x20, 0x7d, 0x54, 0x05, 0xe4, 0x24, 0x48, 0x10, 0x00, 0x04, 0x40, + 0x45, 0xe8, 0x7f, 0xe0, 0x5e, 0xfc, 0x18, 0xa0, 0x2a, 0x9c, 0x24, 0x48, 0x33, 0xf8, 0x71, 0x1c, + 0x15, 0xe4, 0x01, 0x00, 0x15, 0x28, 0x11, 0xfc, 0x24, 0x04, 0x3f, 0xf8, 0x10, 0xe0, 0x02, 0x80, + 0x2a, 0x08, 0x09, 0x00, 0x20, 0x20, 0x13, 0xf8, 0x20, 0x54, 0x24, 0x48, 0x12, 0x08, 0x0d, 0x60, + 0x7a, 0x04, 0x09, 0x20, 0x7f, 0xa4, 0x11, 0x40, 0x45, 0xe4, 0x01, 0x00, 0x10, 0x20, 0x31, 0x18, + 0x25, 0x08, 0x10, 0x80, 0x10, 0x20, 0x78, 0x40, 0x3f, 0x50, 0x44, 0x48, 0x12, 0x08, 0x03, 0x80, + 0x13, 0xfc, 0x09, 0x10, 0x14, 0x7c, 0x7d, 0x40, 0x04, 0x04, 0x01, 0x00, 0x10, 0x20, 0x08, 0x20, + 0x1d, 0xf8, 0x00, 0x00, 0x1e, 0x20, 0x13, 0xf8, 0x21, 0x50, 0x04, 0x40, 0x0a, 0x08, 0x3f, 0xf8, + 0x11, 0x00, 0x11, 0x10, 0x76, 0x40, 0x13, 0xfc, 0x14, 0x04, 0x7f, 0xfc, 0x1f, 0xe0, 0x04, 0x40, + 0x10, 0x80, 0x00, 0x00, 0x08, 0x20, 0x10, 0x40, 0x3f, 0x70, 0x04, 0x40, 0x0b, 0xf8, 0x01, 0x00, + 0x11, 0x00, 0x01, 0x00, 0x09, 0x40, 0x10, 0x00, 0x27, 0xfc, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x10, 0x80, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, + 0x3c, 0x0c, 0x09, 0xa0, 0x1f, 0xf0, 0x22, 0x1c, 0x74, 0x00, 0x00, 0xe0, 0x48, 0x9c, 0x47, 0xe0, + 0x1f, 0xf8, 0x10, 0x40, 0x3f, 0xf8, 0x73, 0x84, 0x65, 0x04, 0x02, 0x08, 0x40, 0x38, 0x02, 0x08, + 0x0b, 0x30, 0x04, 0xa0, 0x10, 0x10, 0x21, 0x04, 0x12, 0x00, 0x62, 0x24, 0x44, 0x94, 0x28, 0x24, + 0x10, 0x08, 0x10, 0x40, 0x20, 0x00, 0x5d, 0x68, 0x18, 0x88, 0x63, 0xf8, 0x40, 0x08, 0x01, 0x10, + 0x68, 0x60, 0x06, 0xac, 0x10, 0x10, 0x3d, 0x04, 0x12, 0x00, 0x19, 0x24, 0x24, 0x90, 0x28, 0x84, + 0x1f, 0xf8, 0x11, 0xf0, 0x20, 0x00, 0x51, 0x10, 0x64, 0x50, 0x1a, 0x08, 0x20, 0x08, 0x71, 0x10, + 0x18, 0x90, 0x42, 0xa4, 0x10, 0x10, 0x25, 0x04, 0x11, 0x00, 0x01, 0x28, 0x22, 0x90, 0x08, 0x88, + 0x10, 0x08, 0x14, 0x44, 0x20, 0x00, 0x51, 0x10, 0x24, 0x20, 0x02, 0x08, 0x20, 0x08, 0x1c, 0xa0, + 0x05, 0x08, 0x72, 0xa4, 0x1f, 0xf0, 0xe5, 0xfc, 0x11, 0x00, 0x00, 0x20, 0x12, 0x90, 0x01, 0x00, + 0x1f, 0xf8, 0x12, 0x48, 0x3f, 0xf0, 0x51, 0x28, 0x7e, 0x50, 0x02, 0x08, 0x13, 0xc8, 0x10, 0xa0, + 0x7f, 0xfc, 0x57, 0xe4, 0x10, 0x10, 0x65, 0x24, 0x71, 0x00, 0x7b, 0xfc, 0x12, 0x90, 0x00, 0x00, + 0x10, 0x08, 0x11, 0x50, 0x20, 0x10, 0x5d, 0x24, 0x10, 0x50, 0x7b, 0xf8, 0x12, 0x48, 0x17, 0xfc, + 0x01, 0x00, 0x52, 0xa4, 0x10, 0x10, 0x25, 0xfc, 0x19, 0x04, 0x42, 0x20, 0x02, 0x90, 0x1f, 0xf0, + 0x1f, 0xf8, 0x11, 0x50, 0x20, 0x10, 0x11, 0xf8, 0x08, 0x88, 0x40, 0x00, 0x02, 0x48, 0x10, 0x88, + 0x10, 0x1c, 0x52, 0xa8, 0x10, 0x10, 0x3f, 0x24, 0x15, 0xfc, 0x21, 0x20, 0x00, 0x00, 0x10, 0x10, + 0x00, 0x00, 0x50, 0xe0, 0x20, 0x10, 0x11, 0x08, 0x6b, 0x88, 0x20, 0x00, 0x02, 0x48, 0x10, 0x88, + 0x10, 0x24, 0x57, 0xe8, 0x1f, 0xf0, 0x33, 0xfc, 0x11, 0x04, 0x13, 0xe0, 0x27, 0xc8, 0x10, 0x10, + 0x0f, 0xf8, 0x30, 0x40, 0x3f, 0xf0, 0x7d, 0x08, 0x1c, 0x88, 0x15, 0xf4, 0x23, 0xc8, 0x7c, 0x88, + 0x50, 0x40, 0x52, 0xa8, 0x10, 0x10, 0x11, 0x20, 0x11, 0x04, 0x78, 0x80, 0x41, 0x30, 0x10, 0x10, + 0x10, 0x00, 0x17, 0xfc, 0x20, 0x00, 0x45, 0xf8, 0x7e, 0xfc, 0x7a, 0x08, 0x40, 0x08, 0x10, 0x88, + 0x37, 0xfc, 0x72, 0xac, 0x10, 0x10, 0x11, 0x90, 0x7d, 0x04, 0x48, 0x80, 0x00, 0x80, 0x1f, 0xf0, + 0x10, 0x00, 0x10, 0x40, 0x20, 0x00, 0x45, 0x08, 0x08, 0x40, 0x49, 0x10, 0x00, 0x08, 0x13, 0xf8, + 0x10, 0x90, 0x07, 0xbc, 0x10, 0x10, 0x7c, 0xf8, 0x11, 0xfc, 0x23, 0xf8, 0x17, 0xf8, 0x04, 0x40, + 0x7f, 0xfc, 0x08, 0x40, 0x20, 0x00, 0x45, 0x08, 0x2a, 0x40, 0x20, 0xa0, 0x17, 0xfc, 0x10, 0x80, + 0x08, 0xa0, 0x00, 0x08, 0x1f, 0xf0, 0x00, 0xc0, 0x10, 0x20, 0x10, 0x40, 0x20, 0x80, 0x08, 0x20, + 0x01, 0x00, 0x08, 0x40, 0x3f, 0xf8, 0x7d, 0xf8, 0x08, 0x40, 0x10, 0x40, 0x20, 0x00, 0x10, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x10, 0x40, 0x00, 0x00, 0x10, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x3c, + 0x04, 0x0c, 0x01, 0x00, 0x3f, 0xf8, 0x1c, 0x04, 0x13, 0xc4, 0x37, 0xfc, 0x07, 0x00, 0x30, 0x60, + 0x12, 0x1c, 0x10, 0x40, 0x3f, 0xf8, 0x4c, 0xe0, 0x4d, 0x84, 0x08, 0x0c, 0x40, 0x1c, 0x10, 0x44, + 0x64, 0xc4, 0x01, 0x00, 0x21, 0x08, 0x16, 0x0c, 0x11, 0x38, 0x10, 0x40, 0x01, 0x00, 0x08, 0x10, + 0x12, 0x04, 0x10, 0x40, 0x21, 0x08, 0x24, 0x20, 0x45, 0x48, 0x4b, 0xd4, 0x40, 0x04, 0x08, 0x40, + 0x15, 0x04, 0x01, 0x00, 0x21, 0x08, 0x13, 0x18, 0x10, 0x90, 0x10, 0x40, 0x01, 0x00, 0x04, 0x10, + 0x12, 0x04, 0x10, 0x40, 0x21, 0x08, 0x24, 0x20, 0x25, 0x30, 0x48, 0xa4, 0x27, 0xe4, 0x04, 0x40, + 0x0e, 0x14, 0x01, 0x00, 0x21, 0x08, 0x11, 0x30, 0x10, 0x80, 0x10, 0x40, 0x01, 0x00, 0x03, 0xf0, + 0x12, 0x04, 0x10, 0x40, 0x21, 0x08, 0x24, 0x20, 0x25, 0x30, 0x28, 0x84, 0x24, 0x24, 0x04, 0x40, + 0x55, 0xd4, 0x01, 0x00, 0x01, 0x00, 0x10, 0xa0, 0x50, 0x40, 0x13, 0xf8, 0x7f, 0xfc, 0x02, 0x00, + 0x12, 0x2c, 0x10, 0x40, 0x21, 0x08, 0x15, 0x20, 0x25, 0x48, 0x2f, 0xfc, 0x24, 0x24, 0x7f, 0xfc, + 0x35, 0x54, 0x7f, 0xfc, 0x78, 0x00, 0x50, 0xc0, 0x52, 0x44, 0x70, 0x00, 0x01, 0x00, 0x7f, 0xfc, + 0x13, 0x54, 0x17, 0xfc, 0x3f, 0xf8, 0x7d, 0x20, 0x25, 0x48, 0x20, 0x80, 0x27, 0xe4, 0x00, 0x00, + 0x15, 0x14, 0x01, 0x00, 0x07, 0xe4, 0x76, 0x50, 0x35, 0x44, 0x1a, 0x3c, 0x01, 0x80, 0x01, 0x00, + 0x12, 0x94, 0x10, 0x40, 0x21, 0x08, 0x11, 0x20, 0x3d, 0x48, 0x27, 0xf8, 0x20, 0x04, 0x00, 0x00, + 0x75, 0xd4, 0x01, 0x00, 0x49, 0x24, 0x32, 0x58, 0x39, 0x08, 0x11, 0x24, 0x00, 0x40, 0x40, 0x04, + 0x12, 0x94, 0x50, 0x40, 0x21, 0x08, 0x7d, 0x20, 0x25, 0xf8, 0x24, 0x88, 0x2f, 0xf4, 0x1f, 0xf0, + 0x15, 0x14, 0x21, 0x00, 0x28, 0x88, 0x32, 0x48, 0x10, 0x88, 0x14, 0xa0, 0x4f, 0xe4, 0x7f, 0xfc, + 0x52, 0x94, 0x34, 0x40, 0x21, 0x08, 0x45, 0x20, 0x25, 0x00, 0x27, 0xf8, 0x21, 0x04, 0x40, 0x04, + 0x7f, 0xd4, 0x11, 0x00, 0x0a, 0x40, 0x12, 0x4c, 0x10, 0x90, 0x7c, 0xa4, 0x40, 0x04, 0x04, 0x40, + 0x33, 0xfc, 0x13, 0xf8, 0x3f, 0xf8, 0x45, 0x20, 0x3d, 0x18, 0x20, 0x80, 0x27, 0xe4, 0x40, 0x04, + 0x04, 0x14, 0x1f, 0xf0, 0x40, 0x04, 0x10, 0x40, 0x7c, 0x90, 0x17, 0xfc, 0x7f, 0xfc, 0x08, 0x20, + 0x10, 0x90, 0x12, 0x40, 0x01, 0x00, 0x7c, 0x20, 0x25, 0x08, 0x3f, 0xf8, 0x21, 0x04, 0x7f, 0xfc, + 0x3c, 0x14, 0x08, 0x00, 0x7f, 0xfc, 0x18, 0x40, 0x10, 0x90, 0x10, 0x40, 0x09, 0x20, 0x3f, 0xf8, + 0x10, 0x90, 0x09, 0x40, 0x01, 0x00, 0x00, 0x00, 0x25, 0x08, 0x20, 0x08, 0x20, 0x04, 0x01, 0x00, + 0x03, 0x84, 0x08, 0x00, 0x01, 0x00, 0x18, 0x40, 0x10, 0x10, 0x10, 0x40, 0x12, 0x10, 0x01, 0x00, + 0x0b, 0xfc, 0x09, 0x40, 0x01, 0x00, 0x00, 0x00, 0x3d, 0xf8, 0x3f, 0xf8, 0x3f, 0xfc, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7c, + 0x10, 0x20, 0x13, 0x0c, 0x7f, 0xfc, 0x06, 0x18, 0x4c, 0x0c, 0x00, 0x70, 0x00, 0xd8, 0x20, 0x0c, + 0x6e, 0x00, 0x0c, 0xfc, 0x20, 0x04, 0x20, 0x1c, 0x02, 0x08, 0x01, 0x0c, 0x07, 0x00, 0x10, 0x84, + 0x10, 0x40, 0x10, 0x90, 0x40, 0x04, 0x01, 0x04, 0x23, 0x30, 0x40, 0x10, 0x14, 0x48, 0x20, 0x04, + 0x11, 0xe0, 0x02, 0x80, 0x3f, 0xfc, 0x20, 0x04, 0x11, 0x08, 0x61, 0x54, 0x41, 0x08, 0x08, 0x84, + 0x10, 0xa0, 0x10, 0x60, 0x50, 0x14, 0x00, 0x84, 0x20, 0xc0, 0x22, 0x10, 0x1a, 0x48, 0x20, 0x04, + 0x11, 0x40, 0x62, 0xc8, 0x20, 0x04, 0x21, 0xc4, 0x18, 0x90, 0x1d, 0x54, 0x21, 0x08, 0x04, 0x80, + 0x10, 0x10, 0x13, 0xfc, 0x48, 0x24, 0x0e, 0x84, 0x11, 0x20, 0x12, 0x10, 0x11, 0x48, 0x20, 0x04, + 0x17, 0xe0, 0x1a, 0xa8, 0x21, 0xc4, 0x28, 0x44, 0x10, 0x40, 0x09, 0x54, 0x11, 0x10, 0x04, 0x80, + 0x10, 0x08, 0x50, 0x40, 0x44, 0x44, 0x12, 0x44, 0x12, 0x10, 0x14, 0x10, 0x10, 0xc8, 0x27, 0xe4, + 0x55, 0x20, 0x02, 0xa8, 0x28, 0x44, 0x24, 0x44, 0x17, 0xfc, 0x29, 0x54, 0x11, 0x20, 0x02, 0x80, + 0x13, 0xf8, 0x51, 0xf8, 0x42, 0x84, 0x10, 0x44, 0x12, 0x10, 0x0c, 0x50, 0x17, 0xd8, 0x24, 0x24, + 0x75, 0x20, 0x02, 0x90, 0x24, 0x44, 0x22, 0x44, 0x11, 0x20, 0x25, 0xfc, 0x01, 0x00, 0x02, 0x00, + 0x11, 0x00, 0x35, 0x08, 0x42, 0x84, 0x10, 0x44, 0x1f, 0xf0, 0x08, 0x50, 0x12, 0x68, 0x24, 0x24, + 0x47, 0xe0, 0x3e, 0x90, 0x22, 0x44, 0x21, 0x44, 0x12, 0x20, 0x24, 0x20, 0x01, 0x00, 0x7f, 0xfc, + 0x50, 0x80, 0x39, 0xf8, 0x41, 0x04, 0x70, 0x44, 0x10, 0x80, 0x14, 0x90, 0x13, 0xc8, 0x24, 0x24, + 0x71, 0x00, 0x24, 0xa8, 0x21, 0x44, 0x20, 0xc4, 0x10, 0xa8, 0x45, 0xfc, 0x1f, 0xf0, 0x01, 0x00, + 0x37, 0xfc, 0x11, 0x08, 0x5f, 0xf4, 0x18, 0x44, 0x10, 0x88, 0x24, 0x10, 0x72, 0x48, 0x27, 0xe4, + 0x17, 0xc0, 0x24, 0xa8, 0x20, 0xc4, 0x2f, 0xf4, 0x71, 0x04, 0x04, 0x00, 0x11, 0x00, 0x01, 0x00, + 0x10, 0x80, 0x11, 0xf8, 0x41, 0x04, 0x16, 0x44, 0x10, 0x84, 0x02, 0x10, 0x03, 0xdc, 0x20, 0x04, + 0x14, 0x20, 0x24, 0xc8, 0x2f, 0xf4, 0x20, 0x44, 0x07, 0xfc, 0x01, 0xfc, 0x09, 0x00, 0x01, 0x00, + 0x10, 0x40, 0x78, 0x90, 0x41, 0x04, 0x10, 0x44, 0x1f, 0xfc, 0x02, 0xfc, 0x02, 0x48, 0x20, 0x04, + 0x77, 0xc0, 0x24, 0x80, 0x20, 0x44, 0x20, 0x44, 0x00, 0x40, 0x7d, 0x24, 0x04, 0x00, 0x3f, 0xf8, + 0x0b, 0xf8, 0x13, 0xfc, 0x40, 0x04, 0x11, 0xfc, 0x00, 0x80, 0x3e, 0x10, 0x13, 0xc8, 0x00, 0x04, + 0x00, 0x00, 0x04, 0x80, 0x20, 0x44, 0x00, 0x04, 0x13, 0xf8, 0x11, 0x24, 0x3f, 0xf8, 0x00, 0x00, + 0x08, 0x40, 0x10, 0x90, 0x7f, 0xfc, 0x10, 0x00, 0x00, 0x80, 0x00, 0x10, 0x11, 0x08, 0x0b, 0xfc, + 0x00, 0x00, 0x7c, 0xfc, 0x20, 0x04, 0x17, 0xfc, 0x10, 0x40, 0x10, 0x20, 0x02, 0x00, 0x00, 0x00, + 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x88, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x20, 0x00, 0x20, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0c, + 0x47, 0xfc, 0x7f, 0xfc, 0x04, 0x10, 0x3f, 0xfc, 0x0f, 0xe0, 0x20, 0x38, 0x01, 0x00, 0x22, 0x30, + 0x00, 0x00, 0x30, 0x20, 0x00, 0x00, 0x01, 0x00, 0x60, 0x3c, 0x24, 0xb8, 0x01, 0x00, 0x18, 0x38, + 0x28, 0x00, 0x00, 0x80, 0x42, 0x10, 0x20, 0x00, 0x08, 0x20, 0x20, 0x08, 0x61, 0x0c, 0x12, 0x10, + 0x7f, 0xf8, 0x08, 0x20, 0x7f, 0xfc, 0x01, 0x00, 0x10, 0x44, 0x24, 0x88, 0x61, 0x18, 0x04, 0x60, + 0x10, 0x20, 0x00, 0x80, 0x41, 0x10, 0x28, 0x78, 0x08, 0x20, 0x31, 0x08, 0x11, 0x10, 0x0a, 0x10, + 0x24, 0x90, 0x7f, 0xfc, 0x08, 0x20, 0x01, 0x00, 0x08, 0x44, 0x24, 0x88, 0x19, 0x04, 0x02, 0xc0, + 0x14, 0x20, 0x04, 0x40, 0x21, 0x10, 0x24, 0x48, 0x08, 0x20, 0x39, 0x28, 0x09, 0x20, 0x6b, 0xbc, + 0x24, 0x90, 0x04, 0x20, 0x08, 0x20, 0x01, 0x00, 0x08, 0x40, 0x24, 0x88, 0x05, 0x04, 0x33, 0x80, + 0x13, 0x2c, 0x04, 0x40, 0x21, 0x10, 0x24, 0x40, 0x0f, 0xe0, 0x29, 0xb8, 0x05, 0x40, 0x3a, 0x90, + 0x24, 0x90, 0x70, 0x7c, 0x04, 0x20, 0x01, 0x00, 0x04, 0x40, 0x24, 0x88, 0x43, 0x04, 0x11, 0x30, + 0x12, 0xa4, 0x08, 0x40, 0x11, 0x10, 0x7f, 0xfc, 0x70, 0x1c, 0x27, 0xe8, 0x7f, 0xfc, 0x2a, 0x90, + 0x24, 0x90, 0x1c, 0x84, 0x04, 0x20, 0x01, 0x00, 0x04, 0x40, 0x24, 0x88, 0x7f, 0xfc, 0x11, 0x10, + 0x12, 0x24, 0x08, 0x20, 0x16, 0x0c, 0x08, 0x20, 0x0c, 0x60, 0x24, 0x48, 0x01, 0x00, 0x2a, 0x88, + 0x24, 0x90, 0x62, 0xe0, 0x04, 0x20, 0x01, 0x00, 0x1f, 0xf0, 0x24, 0x88, 0x21, 0x00, 0x19, 0x18, + 0x72, 0x24, 0x10, 0x20, 0x01, 0xb0, 0x0f, 0xe0, 0x03, 0x80, 0x24, 0x48, 0x09, 0x20, 0x3b, 0xb8, + 0x24, 0x90, 0x1e, 0x98, 0x1f, 0xe0, 0x7f, 0xfc, 0x10, 0x10, 0x24, 0x88, 0x21, 0x00, 0x01, 0x00, + 0x02, 0x24, 0x00, 0x20, 0x20, 0x40, 0x08, 0x20, 0x02, 0x80, 0x3f, 0xf8, 0x12, 0x10, 0x2a, 0x80, + 0x24, 0x90, 0x08, 0x80, 0x02, 0x00, 0x01, 0x08, 0x10, 0x10, 0x3f, 0xf8, 0x3f, 0xf8, 0x21, 0x04, + 0x02, 0x24, 0x00, 0x00, 0x40, 0xa0, 0x0f, 0xe0, 0x34, 0x40, 0x04, 0x40, 0x3f, 0x88, 0x2a, 0xd4, + 0x3f, 0xf0, 0x7f, 0xfc, 0x02, 0x00, 0x01, 0x00, 0x10, 0x10, 0x04, 0x00, 0x01, 0x08, 0x20, 0x04, + 0x02, 0x24, 0x3f, 0xf8, 0x01, 0x10, 0x08, 0x20, 0x08, 0x20, 0x04, 0x40, 0x00, 0x70, 0x2a, 0xd4, + 0x04, 0x00, 0x04, 0x40, 0x02, 0x00, 0x01, 0x00, 0x10, 0x10, 0x02, 0x00, 0x3f, 0xf8, 0x3f, 0xfc, + 0x13, 0x3c, 0x01, 0x00, 0x13, 0xfc, 0x7f, 0xfc, 0x07, 0xe0, 0x7f, 0xfc, 0x7f, 0xfc, 0x33, 0xb8, + 0x02, 0x00, 0x7f, 0xfc, 0x3f, 0xf8, 0x01, 0x00, 0x10, 0x10, 0x7f, 0xfc, 0x04, 0x40, 0x01, 0x00, + 0x20, 0x80, 0x01, 0x00, 0x20, 0x40, 0x08, 0x20, 0x02, 0x00, 0x00, 0x00, 0x04, 0x40, 0x08, 0x04, + 0x02, 0x00, 0x04, 0x40, 0x00, 0x00, 0x01, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x41, 0xf8, 0x70, 0xf8, 0x70, 0x1c, 0x41, 0xfc, 0x13, 0xe0, 0x30, 0x40, 0x04, 0x1c, 0x01, 0xfc, + 0x71, 0xfc, 0x20, 0x04, 0x20, 0x1c, 0x30, 0x08, 0x31, 0x8c, 0x0e, 0x0c, 0x00, 0x10, 0x01, 0x00, + 0x25, 0x08, 0x11, 0x08, 0x0c, 0x60, 0x27, 0x00, 0x10, 0x0c, 0x08, 0x40, 0x44, 0x04, 0x01, 0x20, + 0x5d, 0x00, 0x3f, 0xfc, 0x2e, 0x24, 0x0c, 0x10, 0x10, 0x50, 0x03, 0x94, 0x60, 0x60, 0x7f, 0xfc, + 0x19, 0x08, 0x11, 0x08, 0x03, 0x80, 0x29, 0x00, 0x17, 0x14, 0x04, 0x40, 0x44, 0x04, 0x01, 0x20, + 0x51, 0x00, 0x21, 0x04, 0x27, 0xe4, 0x02, 0x20, 0x10, 0x20, 0x02, 0x14, 0x19, 0x80, 0x01, 0x00, + 0x11, 0x08, 0x11, 0x60, 0x04, 0x40, 0x11, 0x00, 0x12, 0xd0, 0x7f, 0xfc, 0x26, 0xac, 0x71, 0xfc, + 0x51, 0x00, 0x21, 0x64, 0x22, 0x44, 0x01, 0x40, 0x13, 0xfc, 0x7a, 0x20, 0x00, 0x30, 0x01, 0x00, + 0x69, 0x08, 0x11, 0x10, 0x08, 0x20, 0x11, 0x00, 0x12, 0x10, 0x04, 0x40, 0x25, 0x14, 0x1d, 0x20, + 0x51, 0xf8, 0x21, 0x14, 0x3f, 0xfc, 0x7f, 0xfc, 0x10, 0x20, 0x4a, 0x20, 0x00, 0xc0, 0x1f, 0xf0, + 0x49, 0xf8, 0x71, 0x10, 0x1f, 0xf0, 0x11, 0xf8, 0x12, 0x20, 0x1f, 0xf0, 0x15, 0x14, 0x11, 0x20, + 0x5d, 0x08, 0x21, 0x14, 0x03, 0x00, 0x00, 0x80, 0x71, 0x20, 0x4a, 0x20, 0x7a, 0x0c, 0x11, 0x10, + 0x44, 0x00, 0x19, 0x10, 0x40, 0x04, 0x11, 0x00, 0x12, 0x20, 0x10, 0x10, 0x17, 0xfc, 0x11, 0xfc, + 0x11, 0x08, 0x2f, 0xf4, 0x1f, 0xf0, 0x08, 0x40, 0x1c, 0xfc, 0x7b, 0xfc, 0x41, 0x10, 0x11, 0x10, + 0x27, 0xc4, 0x11, 0xf4, 0x24, 0x44, 0x01, 0x00, 0x53, 0xfc, 0x1f, 0xf0, 0x01, 0x10, 0x15, 0x20, + 0x11, 0x08, 0x21, 0x04, 0x1c, 0x50, 0x10, 0x40, 0x10, 0x80, 0x4a, 0x40, 0x20, 0xa0, 0x1f, 0xf0, + 0x25, 0x38, 0x12, 0x08, 0x14, 0x48, 0x1f, 0xf0, 0x32, 0x20, 0x10, 0x10, 0x21, 0x10, 0x13, 0x20, + 0x7d, 0xf8, 0x27, 0xe4, 0x13, 0xd0, 0x02, 0x40, 0x10, 0x00, 0x4a, 0x40, 0x10, 0x40, 0x11, 0x10, + 0x24, 0x88, 0x11, 0x10, 0x14, 0x50, 0x10, 0x10, 0x12, 0x20, 0x1f, 0xf0, 0x47, 0xfc, 0x7d, 0xfc, + 0x45, 0x00, 0x21, 0x04, 0x17, 0x90, 0x04, 0x40, 0x7d, 0xf4, 0x7b, 0xf8, 0x7a, 0xa0, 0x11, 0x10, + 0x7c, 0x90, 0x7c, 0xa0, 0x04, 0x40, 0x10, 0x10, 0x12, 0x20, 0x49, 0x20, 0x00, 0x00, 0x11, 0x20, + 0x45, 0x00, 0x2f, 0xf4, 0x10, 0x58, 0x40, 0x04, 0x10, 0x88, 0x4a, 0x08, 0x49, 0x10, 0x1f, 0xf0, + 0x10, 0x40, 0x10, 0xa0, 0x7f, 0xfc, 0x10, 0x10, 0x0b, 0xe0, 0x3e, 0xfc, 0x11, 0x10, 0x10, 0x90, + 0x45, 0x00, 0x21, 0x04, 0x7f, 0xfc, 0x7f, 0xfc, 0x10, 0x48, 0x4a, 0x08, 0x20, 0xf0, 0x04, 0x40, + 0x10, 0x40, 0x10, 0x40, 0x01, 0x00, 0x1f, 0xf0, 0x08, 0x18, 0x10, 0x40, 0x27, 0xfc, 0x10, 0x90, + 0x7d, 0xfc, 0x21, 0x04, 0x01, 0x00, 0x01, 0x00, 0x10, 0x40, 0x7b, 0xf8, 0x10, 0x80, 0x08, 0x20, + 0x00, 0x00, 0x10, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c, + 0x70, 0x3c, 0x07, 0x00, 0x26, 0x0c, 0x7f, 0xfc, 0x7f, 0xfc, 0x27, 0x04, 0x20, 0x1c, 0x3e, 0x6c, + 0x30, 0x18, 0x37, 0x0c, 0x40, 0x30, 0x03, 0xfc, 0x10, 0x20, 0x44, 0x44, 0x53, 0x0c, 0x08, 0x04, + 0x1e, 0x44, 0x21, 0x08, 0x21, 0x10, 0x11, 0x00, 0x01, 0x00, 0x21, 0xc8, 0x20, 0x04, 0x2a, 0x24, + 0x0c, 0x60, 0x10, 0xf0, 0x44, 0x08, 0x70, 0x20, 0x10, 0x20, 0x24, 0x44, 0x28, 0xd0, 0x08, 0x04, + 0x10, 0x44, 0x11, 0x08, 0x28, 0xa0, 0x11, 0x00, 0x01, 0x00, 0x21, 0x10, 0x20, 0x04, 0x2a, 0x24, + 0x00, 0x00, 0x10, 0xa0, 0x27, 0xfc, 0x0c, 0x20, 0x50, 0x20, 0x24, 0x88, 0x24, 0x20, 0x48, 0x44, + 0x10, 0x40, 0x09, 0x10, 0x28, 0x40, 0x11, 0x00, 0x1f, 0xf0, 0x21, 0x10, 0x27, 0xe4, 0x3e, 0x24, + 0x7f, 0xfc, 0x13, 0x10, 0x22, 0x48, 0x00, 0x20, 0x50, 0x20, 0x00, 0x00, 0x22, 0x50, 0x29, 0x44, + 0x10, 0x40, 0x09, 0x20, 0x2b, 0xfc, 0x11, 0x00, 0x01, 0x00, 0x21, 0x28, 0x24, 0x24, 0x2a, 0xb4, + 0x10, 0x10, 0x11, 0x10, 0x12, 0x48, 0x00, 0x20, 0x75, 0x24, 0x66, 0x0c, 0x22, 0x88, 0x1a, 0x44, + 0x10, 0x40, 0x01, 0x00, 0x28, 0x40, 0x11, 0x00, 0x1f, 0xf0, 0x21, 0x24, 0x24, 0x24, 0x3e, 0x6c, + 0x1f, 0xf0, 0x77, 0xfc, 0x12, 0x48, 0x7d, 0xf8, 0x3d, 0xfc, 0x11, 0x10, 0x21, 0xf8, 0x1c, 0x44, + 0x10, 0x40, 0x7f, 0xfc, 0x2a, 0x40, 0x11, 0xf0, 0x11, 0x10, 0x61, 0x20, 0x27, 0xe4, 0x49, 0x24, + 0x10, 0x10, 0x18, 0x80, 0x07, 0xfc, 0x22, 0x00, 0x19, 0x24, 0x18, 0xa0, 0x21, 0x00, 0x08, 0x44, + 0x10, 0x60, 0x01, 0x00, 0x29, 0xf8, 0x11, 0x00, 0x1f, 0xf0, 0x21, 0xf8, 0x24, 0x24, 0x2a, 0x24, + 0x1f, 0xf0, 0x10, 0x00, 0x02, 0x48, 0x11, 0x04, 0x11, 0x24, 0x24, 0xa0, 0x2f, 0xfc, 0x7f, 0x44, + 0x1e, 0x58, 0x31, 0x08, 0x69, 0x00, 0x01, 0x00, 0x11, 0x10, 0x11, 0x08, 0x24, 0x24, 0x7f, 0x6c, + 0x10, 0x10, 0x17, 0xfc, 0x22, 0x48, 0x08, 0x88, 0x7d, 0x24, 0x4c, 0x40, 0x24, 0x80, 0x08, 0x44, + 0x10, 0x44, 0x0c, 0x10, 0x2b, 0xfc, 0x01, 0x00, 0x7f, 0xfc, 0x11, 0x08, 0x27, 0xe4, 0x08, 0xb4, + 0x1f, 0xf0, 0x78, 0xa0, 0x4b, 0xf8, 0x78, 0x50, 0x11, 0xfc, 0x33, 0xfc, 0x24, 0x88, 0x08, 0x44, + 0x10, 0x40, 0x02, 0x60, 0x28, 0x10, 0x01, 0x00, 0x01, 0x00, 0x41, 0xf8, 0x20, 0x04, 0x2a, 0x24, + 0x01, 0x00, 0x11, 0x10, 0x04, 0x00, 0x24, 0x20, 0x10, 0x20, 0x22, 0x40, 0x20, 0x90, 0x38, 0x44, + 0x10, 0x40, 0x01, 0x80, 0x10, 0x10, 0x3f, 0xf8, 0x1f, 0x80, 0x21, 0x08, 0x08, 0x04, 0x79, 0xfc, + 0x7f, 0xfc, 0x13, 0xf8, 0x13, 0xfc, 0x24, 0x10, 0x70, 0x20, 0x1e, 0x48, 0x3f, 0xfc, 0x06, 0x04, + 0x10, 0x40, 0x06, 0x60, 0x11, 0xf0, 0x00, 0x00, 0x00, 0x70, 0x11, 0xf8, 0x0b, 0xfc, 0x06, 0x00, + 0x01, 0x00, 0x10, 0x40, 0x22, 0x00, 0x11, 0xf8, 0x1c, 0x20, 0x10, 0x50, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x78, + 0x11, 0xf0, 0x18, 0x0c, 0x0e, 0x1c, 0x58, 0x04, 0x3f, 0xf8, 0x17, 0x04, 0x7f, 0xfc, 0x08, 0x00, + 0x7f, 0xfc, 0x03, 0xf8, 0x40, 0x00, 0x43, 0xfc, 0x27, 0xfc, 0x00, 0x40, 0x00, 0x84, 0x12, 0x88, + 0x11, 0x10, 0x46, 0x30, 0x43, 0x26, 0x2b, 0xfc, 0x01, 0x00, 0x11, 0xe8, 0x01, 0x00, 0x0c, 0x0c, + 0x01, 0x00, 0x02, 0x08, 0x21, 0xfc, 0x3c, 0x00, 0x20, 0x40, 0x00, 0x40, 0x3a, 0x48, 0x11, 0x80, + 0x11, 0x10, 0x21, 0x40, 0x41, 0xa4, 0x2a, 0x04, 0x6f, 0xec, 0x11, 0x10, 0x01, 0x00, 0x0a, 0x10, + 0x01, 0x00, 0x02, 0x08, 0x16, 0x40, 0x1c, 0x04, 0x20, 0x40, 0x00, 0x40, 0x2a, 0x30, 0x54, 0x84, + 0x11, 0x10, 0x20, 0x80, 0x78, 0xa0, 0x2a, 0x14, 0x11, 0x10, 0x11, 0x10, 0x01, 0x00, 0x08, 0x20, + 0x01, 0x00, 0x7a, 0x08, 0x08, 0x40, 0x16, 0x0c, 0x20, 0x40, 0x60, 0x40, 0x29, 0x30, 0x52, 0xc4, + 0x51, 0xf0, 0x11, 0x40, 0x4a, 0x60, 0x2b, 0x14, 0x08, 0x20, 0x51, 0x28, 0x01, 0x00, 0x08, 0x40, + 0x1f, 0xf0, 0x4a, 0x08, 0x14, 0x40, 0x11, 0x18, 0x20, 0x40, 0x18, 0x44, 0x29, 0x48, 0x32, 0xa8, + 0x56, 0x0c, 0x12, 0x20, 0x4b, 0xfc, 0x3a, 0xa4, 0x7f, 0xfc, 0x51, 0x24, 0x1f, 0xf0, 0x08, 0x80, + 0x01, 0x00, 0x4b, 0xf8, 0x14, 0x40, 0x71, 0xb0, 0x23, 0xf8, 0x12, 0x44, 0x69, 0x48, 0x3a, 0xa0, + 0x31, 0x90, 0x14, 0x10, 0x4a, 0x44, 0x2a, 0x44, 0x04, 0x40, 0x35, 0xf8, 0x01, 0x00, 0x09, 0x00, + 0x01, 0x00, 0x48, 0x00, 0x52, 0x44, 0x00, 0xa0, 0x60, 0x40, 0x11, 0x48, 0x29, 0x48, 0x10, 0x90, + 0x38, 0x60, 0x08, 0x90, 0x7a, 0x44, 0x2a, 0xa4, 0x3f, 0xf8, 0x39, 0x08, 0x41, 0x00, 0x7f, 0xfc, + 0x6f, 0xec, 0x48, 0x00, 0x22, 0x44, 0x10, 0xc0, 0x20, 0x40, 0x10, 0xc8, 0x39, 0xf8, 0x7c, 0x90, + 0x10, 0xa0, 0x08, 0xf0, 0x4f, 0xfc, 0x39, 0x10, 0x04, 0x40, 0x11, 0x08, 0x21, 0x00, 0x08, 0x00, + 0x10, 0x10, 0x4d, 0xf4, 0x22, 0x48, 0x70, 0x40, 0x10, 0x40, 0x10, 0x40, 0x11, 0x20, 0x10, 0x88, + 0x13, 0x10, 0x08, 0x40, 0x4a, 0x20, 0x28, 0x10, 0x1f, 0xf0, 0x11, 0xf8, 0x3f, 0xf8, 0x09, 0x00, + 0x08, 0x20, 0x4a, 0x08, 0x22, 0x50, 0x4f, 0xfc, 0x17, 0xfc, 0x78, 0x20, 0x11, 0x28, 0x10, 0xa8, + 0x7d, 0x10, 0x08, 0x40, 0x49, 0x30, 0x2b, 0xfc, 0x44, 0x44, 0x7d, 0x08, 0x11, 0x00, 0x08, 0x80, + 0x04, 0x40, 0x79, 0x10, 0x1e, 0x40, 0x10, 0x40, 0x40, 0x00, 0x10, 0x20, 0x11, 0x24, 0x70, 0x20, + 0x10, 0xf0, 0x08, 0x20, 0x79, 0xf0, 0x28, 0x40, 0x7f, 0xfc, 0x11, 0x08, 0x11, 0x00, 0x08, 0x40, + 0x02, 0x80, 0x00, 0xa0, 0x10, 0x40, 0x38, 0x40, 0x20, 0x40, 0x13, 0xfc, 0x7d, 0xfc, 0x08, 0x40, + 0x10, 0x80, 0x3f, 0xe0, 0x00, 0x80, 0x38, 0x40, 0x01, 0x00, 0x11, 0xf8, 0x01, 0x00, 0x08, 0x20, + 0x01, 0x00, 0x00, 0x40, 0x10, 0x40, 0x20, 0x40, 0x10, 0x80, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, + 0x60, 0x0c, 0x02, 0x18, 0x00, 0x04, 0x1f, 0xfc, 0x3f, 0xf8, 0x1f, 0x38, 0x48, 0x20, 0x41, 0x04, + 0x70, 0x40, 0x43, 0xf8, 0x00, 0x0c, 0x00, 0x04, 0x15, 0x8c, 0x00, 0x20, 0x40, 0x20, 0x41, 0x08, + 0x10, 0x10, 0x01, 0x04, 0x71, 0x8c, 0x00, 0x80, 0x01, 0x00, 0x21, 0x08, 0x44, 0x20, 0x20, 0x88, + 0x10, 0x40, 0x42, 0x08, 0x78, 0x14, 0x17, 0x0c, 0x12, 0x50, 0x3c, 0x20, 0x20, 0x20, 0x21, 0x08, + 0x08, 0x20, 0x70, 0x84, 0x0c, 0x54, 0x40, 0x80, 0x67, 0xcc, 0x21, 0x08, 0x22, 0x20, 0x20, 0x50, + 0x17, 0xfc, 0x22, 0x08, 0x0f, 0x24, 0x19, 0xd4, 0x12, 0x30, 0x24, 0x20, 0x20, 0x20, 0x11, 0x10, + 0x04, 0x40, 0x1c, 0x44, 0x00, 0x24, 0x20, 0x80, 0x11, 0x10, 0x2c, 0x08, 0x22, 0x20, 0x12, 0x50, + 0x10, 0x40, 0x22, 0x08, 0x08, 0x20, 0x15, 0x14, 0x11, 0x48, 0x24, 0x20, 0x10, 0x20, 0x11, 0x20, + 0x04, 0x40, 0x12, 0x24, 0x00, 0x50, 0x10, 0x80, 0x08, 0x20, 0x22, 0x48, 0x2f, 0xfc, 0x12, 0x20, + 0x10, 0x40, 0x12, 0x08, 0x08, 0x40, 0x11, 0x10, 0x15, 0x48, 0x25, 0xfc, 0x10, 0x20, 0x01, 0x00, + 0x02, 0x80, 0x11, 0x24, 0x7c, 0x48, 0x0f, 0xf8, 0x7f, 0xfc, 0x22, 0x48, 0x21, 0x20, 0x0c, 0x20, + 0x71, 0xf0, 0x13, 0xf8, 0x08, 0x40, 0x11, 0x20, 0x59, 0x48, 0x64, 0x20, 0x10, 0x20, 0x01, 0x00, + 0x02, 0x80, 0x11, 0x14, 0x21, 0xe0, 0x08, 0x00, 0x08, 0x20, 0x22, 0x48, 0x21, 0x20, 0x08, 0x50, + 0x18, 0x40, 0x00, 0x00, 0x3e, 0x40, 0x11, 0x20, 0x35, 0xf8, 0x24, 0x00, 0x1f, 0xe0, 0x3f, 0xfc, + 0x21, 0x10, 0x10, 0x94, 0x10, 0x5c, 0x04, 0x00, 0x0f, 0xe0, 0x3e, 0x48, 0x2f, 0xfc, 0x14, 0x50, + 0x13, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x13, 0xa0, 0x11, 0x20, 0x3d, 0x54, 0x10, 0x00, 0x21, 0x00, + 0x11, 0x08, 0x13, 0xfc, 0x08, 0x40, 0x04, 0x00, 0x08, 0x20, 0x40, 0x48, 0x21, 0x20, 0x24, 0x88, + 0x10, 0xb0, 0x27, 0xc4, 0x00, 0x80, 0x70, 0x20, 0x09, 0x28, 0x10, 0x88, 0x10, 0x00, 0x21, 0x00, + 0x11, 0x08, 0x7d, 0x00, 0x79, 0xc0, 0x7f, 0xfc, 0x0f, 0xe0, 0x21, 0x48, 0x22, 0x10, 0x04, 0x88, + 0x10, 0x40, 0x41, 0x38, 0x7f, 0xfc, 0x00, 0x20, 0x05, 0x24, 0x10, 0x88, 0x1f, 0xfc, 0x11, 0x00, + 0x01, 0x00, 0x10, 0x80, 0x24, 0x78, 0x02, 0x00, 0x08, 0x20, 0x12, 0x48, 0x3f, 0xf8, 0x04, 0x88, + 0x7c, 0xa0, 0x01, 0x10, 0x00, 0x80, 0x07, 0xfc, 0x7d, 0xfc, 0x11, 0xfc, 0x10, 0x80, 0x10, 0x00, + 0x01, 0x00, 0x10, 0x60, 0x24, 0x40, 0x02, 0x00, 0x3f, 0xf8, 0x14, 0x08, 0x20, 0x08, 0x7d, 0xf8, + 0x11, 0x10, 0x10, 0x80, 0x00, 0x88, 0x10, 0x20, 0x10, 0x20, 0x7c, 0x20, 0x10, 0x80, 0x1f, 0x80, + 0x01, 0x00, 0x10, 0x10, 0x10, 0x48, 0x02, 0x00, 0x08, 0x20, 0x08, 0x08, 0x3f, 0xf8, 0x00, 0x00, + 0x13, 0xf8, 0x20, 0x80, 0x00, 0x90, 0x10, 0x24, 0x10, 0x20, 0x00, 0x20, 0x10, 0x80, 0x00, 0x70, + 0x00, 0x00, 0x13, 0xf8, 0x10, 0x50, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x3c, + 0x00, 0xc0, 0x04, 0x0c, 0x00, 0x00, 0x7f, 0xfc, 0x60, 0x0c, 0x40, 0x08, 0x60, 0x8c, 0x1f, 0xf0, + 0x40, 0x04, 0x7f, 0xfc, 0x41, 0xf8, 0x01, 0xc0, 0x60, 0x3c, 0x29, 0x04, 0x3f, 0x04, 0x41, 0x24, + 0x62, 0x24, 0x02, 0x04, 0x7f, 0xfc, 0x01, 0x00, 0x10, 0x10, 0x43, 0xf8, 0x18, 0x84, 0x11, 0x10, + 0x20, 0x08, 0x01, 0x00, 0x41, 0x08, 0x00, 0x20, 0x10, 0x44, 0x29, 0x0c, 0x22, 0x88, 0x41, 0x20, + 0x19, 0x28, 0x01, 0x04, 0x00, 0x00, 0x01, 0x00, 0x08, 0x20, 0x42, 0x48, 0x05, 0x04, 0x11, 0x10, + 0x10, 0x10, 0x01, 0x00, 0x21, 0x08, 0x08, 0x20, 0x08, 0x44, 0x25, 0x54, 0x22, 0x88, 0x70, 0xa0, + 0x02, 0xa8, 0x01, 0x04, 0x00, 0x00, 0x3f, 0xf8, 0x04, 0x40, 0x72, 0x48, 0x62, 0x24, 0x1f, 0xf0, + 0x08, 0x20, 0x1f, 0xf0, 0x21, 0x08, 0x0f, 0xe0, 0x04, 0x40, 0x25, 0x50, 0x22, 0x50, 0x48, 0xa0, + 0x01, 0x70, 0x7c, 0x84, 0x00, 0x00, 0x01, 0x00, 0x02, 0x80, 0x4a, 0x48, 0x19, 0x24, 0x11, 0x10, + 0x04, 0x40, 0x01, 0x00, 0x11, 0xf8, 0x04, 0x00, 0x04, 0x40, 0x25, 0x50, 0x22, 0x50, 0x48, 0xa0, + 0x7a, 0xa8, 0x44, 0x84, 0x00, 0x00, 0x22, 0x04, 0x01, 0x00, 0x48, 0x40, 0x04, 0xa4, 0x11, 0x10, + 0x04, 0x40, 0x0f, 0xe0, 0x16, 0x0c, 0x3f, 0xf8, 0x1f, 0xf0, 0x25, 0x50, 0x3e, 0x20, 0x4b, 0xfc, + 0x41, 0x44, 0x44, 0xfc, 0x1f, 0xf0, 0x39, 0x08, 0x7f, 0xfc, 0x48, 0x40, 0x0a, 0x24, 0x1f, 0xf0, + 0x02, 0x80, 0x08, 0x20, 0x01, 0x90, 0x00, 0x00, 0x10, 0x10, 0x25, 0x50, 0x41, 0x20, 0x48, 0x00, + 0x20, 0x80, 0x44, 0x84, 0x00, 0x00, 0x24, 0x90, 0x01, 0x00, 0x4b, 0xfc, 0x11, 0x24, 0x70, 0x1c, + 0x02, 0x80, 0x08, 0x20, 0x00, 0x60, 0x67, 0xcc, 0x10, 0x10, 0x27, 0xd0, 0x22, 0x20, 0x51, 0xf8, + 0x17, 0xfc, 0x7c, 0x84, 0x00, 0x00, 0x24, 0xa0, 0x21, 0x00, 0x50, 0x40, 0x28, 0x24, 0x0c, 0x60, + 0x01, 0x00, 0x4f, 0xe4, 0x24, 0xa0, 0x18, 0x30, 0x1f, 0xf0, 0x65, 0x10, 0x14, 0xa8, 0x50, 0x00, + 0x78, 0x20, 0x44, 0xfc, 0x00, 0x00, 0x28, 0xa0, 0x11, 0x00, 0x50, 0x40, 0x04, 0x24, 0x03, 0x80, + 0x01, 0x00, 0x40, 0x04, 0x43, 0x10, 0x04, 0x40, 0x01, 0x00, 0x27, 0xd0, 0x08, 0xa4, 0x4a, 0x04, + 0x49, 0xe0, 0x44, 0x84, 0x00, 0x00, 0x28, 0x40, 0x1f, 0xf0, 0x48, 0x40, 0x7f, 0xa4, 0x24, 0x40, + 0x01, 0x00, 0x7f, 0xfc, 0x01, 0x08, 0x02, 0x80, 0x01, 0x00, 0x24, 0x10, 0x40, 0x7c, 0x4b, 0xfc, + 0x21, 0x10, 0x7c, 0x84, 0x3f, 0xf8, 0x24, 0x40, 0x09, 0x00, 0x4b, 0xf8, 0x04, 0x04, 0x18, 0x20, + 0x01, 0x00, 0x09, 0x20, 0x10, 0xf8, 0x7f, 0xfc, 0x7f, 0xfc, 0x17, 0xf0, 0x22, 0x40, 0x78, 0x40, + 0x10, 0xf0, 0x00, 0xfc, 0x00, 0x00, 0x3c, 0x40, 0x09, 0x00, 0x78, 0x40, 0x04, 0x04, 0x0f, 0xf0, + 0x07, 0x00, 0x11, 0x10, 0x20, 0x80, 0x01, 0x00, 0x01, 0x00, 0x10, 0x00, 0x14, 0x40, 0x00, 0x00, + 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x04, + 0x60, 0x18, 0x07, 0x00, 0x06, 0x0c, 0x0f, 0xf0, 0x0f, 0xe0, 0x36, 0x0c, 0x11, 0xf8, 0x41, 0xfc, + 0x41, 0xc0, 0x43, 0xfc, 0x00, 0x70, 0x05, 0x04, 0x3e, 0x3c, 0x08, 0xf8, 0x34, 0x44, 0x21, 0x08, + 0x18, 0x60, 0x01, 0x00, 0x01, 0x10, 0x08, 0x10, 0x08, 0x20, 0x11, 0x90, 0x19, 0x08, 0x24, 0x88, + 0x20, 0x40, 0x3c, 0x00, 0x0c, 0x10, 0x04, 0x88, 0x22, 0x44, 0x08, 0x88, 0x14, 0x44, 0x11, 0x10, + 0x00, 0x00, 0x01, 0x00, 0x00, 0xa0, 0x08, 0x10, 0x08, 0x20, 0x10, 0x60, 0x15, 0x08, 0x18, 0x88, + 0x20, 0x40, 0x16, 0x0c, 0x02, 0x10, 0x64, 0x50, 0x22, 0x44, 0x48, 0x88, 0x12, 0x48, 0x01, 0x00, + 0x7f, 0xf8, 0x1f, 0xf0, 0x60, 0x40, 0x0f, 0xf0, 0x0f, 0xe0, 0x10, 0xa0, 0x11, 0xf8, 0x10, 0x88, + 0x10, 0x40, 0x17, 0xf8, 0x01, 0x10, 0x3c, 0x20, 0x22, 0x40, 0x2a, 0xf8, 0x12, 0x48, 0x3f, 0xf8, + 0x08, 0x40, 0x01, 0x10, 0x1b, 0xfc, 0x08, 0x00, 0x08, 0x20, 0x10, 0x90, 0x11, 0x08, 0x68, 0xf8, + 0x10, 0x40, 0x11, 0x18, 0x00, 0x90, 0x24, 0x20, 0x3e, 0x40, 0x1c, 0x88, 0x12, 0x48, 0x00, 0x00, + 0x08, 0x40, 0x7f, 0xfc, 0x10, 0x40, 0x0f, 0xe0, 0x08, 0x20, 0x71, 0x10, 0x7d, 0x08, 0x48, 0x88, + 0x10, 0x40, 0x71, 0x10, 0x78, 0x50, 0x24, 0x50, 0x08, 0x40, 0x08, 0xf8, 0x72, 0x48, 0x60, 0x0c, + 0x0f, 0xc0, 0x01, 0x10, 0x12, 0x40, 0x08, 0x20, 0x0f, 0xe0, 0x1d, 0x08, 0x11, 0xf8, 0x44, 0x88, + 0x10, 0x40, 0x01, 0xa0, 0x48, 0x30, 0x3c, 0x50, 0x08, 0x40, 0x7e, 0x88, 0x1a, 0x50, 0x17, 0xd0, + 0x08, 0x40, 0x1f, 0xf0, 0x11, 0xf8, 0x4f, 0xe4, 0x00, 0x00, 0x13, 0xf8, 0x10, 0x00, 0x24, 0xf8, + 0x10, 0x40, 0x10, 0x80, 0x4b, 0xfc, 0x24, 0x88, 0x08, 0x40, 0x08, 0xf8, 0x12, 0x50, 0x28, 0x20, + 0x0f, 0xc0, 0x09, 0x20, 0x11, 0x00, 0x40, 0x04, 0x7f, 0xfc, 0x10, 0x40, 0x3d, 0xfc, 0x24, 0x88, + 0x17, 0xfc, 0x77, 0xfc, 0x49, 0x10, 0x24, 0x88, 0x7f, 0x40, 0x08, 0x00, 0x12, 0x50, 0x54, 0x50, + 0x08, 0x40, 0x0f, 0xe0, 0x7b, 0xe8, 0x7f, 0xfc, 0x04, 0x40, 0x7c, 0x40, 0x40, 0x90, 0x24, 0x88, + 0x10, 0x00, 0x40, 0x00, 0x49, 0x10, 0x3c, 0x88, 0x08, 0x40, 0x04, 0x10, 0x7a, 0x50, 0x22, 0x88, + 0x08, 0x40, 0x01, 0x00, 0x10, 0x90, 0x49, 0x10, 0x08, 0x20, 0x13, 0xfc, 0x20, 0x90, 0x7c, 0x88, + 0x10, 0x00, 0x10, 0x00, 0x49, 0x10, 0x24, 0x88, 0x08, 0x40, 0x49, 0x20, 0x12, 0x50, 0x1e, 0xb8, + 0x7f, 0xf8, 0x7f, 0xfc, 0x10, 0x40, 0x3e, 0xfc, 0x3f, 0xf8, 0x10, 0x40, 0x1d, 0xf8, 0x10, 0xf8, + 0x10, 0x00, 0x3b, 0xf8, 0x79, 0x10, 0x25, 0xf8, 0x38, 0x40, 0x3e, 0xfc, 0x13, 0xf0, 0x08, 0x00, + 0x08, 0x40, 0x01, 0x00, 0x10, 0x40, 0x10, 0x40, 0x01, 0x00, 0x10, 0x40, 0x10, 0x90, 0x10, 0x00, + 0x1f, 0xfc, 0x20, 0x00, 0x03, 0xf8, 0x7e, 0x00, 0x06, 0x40, 0x10, 0x40, 0x10, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x90, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3c, + 0x13, 0xf8, 0x14, 0x04, 0x70, 0x30, 0x50, 0x8c, 0x27, 0xc4, 0x0f, 0xfc, 0x1f, 0xf8, 0x10, 0x40, + 0x7f, 0xfc, 0x60, 0x0c, 0x00, 0x00, 0x41, 0xf0, 0x20, 0x18, 0x7f, 0xfc, 0x01, 0x00, 0x04, 0x24, + 0x10, 0x08, 0x12, 0x08, 0x0c, 0x08, 0x49, 0x54, 0x55, 0x2c, 0x10, 0x04, 0x20, 0x08, 0x10, 0x40, + 0x12, 0x90, 0x10, 0x10, 0x00, 0x00, 0x21, 0x10, 0x27, 0xc8, 0x40, 0x00, 0x11, 0x70, 0x62, 0x24, + 0x10, 0x08, 0x11, 0x10, 0x00, 0x08, 0x26, 0x34, 0x57, 0x94, 0x10, 0x04, 0x20, 0x08, 0x10, 0x40, + 0x12, 0x90, 0x08, 0x20, 0x00, 0x00, 0x21, 0x10, 0x24, 0x48, 0x41, 0x00, 0x11, 0x10, 0x1a, 0x20, + 0x10, 0x08, 0x10, 0xa0, 0x7c, 0x48, 0x29, 0x10, 0x54, 0x90, 0x10, 0x60, 0x20, 0x00, 0x10, 0x40, + 0x1f, 0xf0, 0x04, 0x40, 0x00, 0x00, 0x11, 0xf0, 0x27, 0xc8, 0x41, 0x00, 0x11, 0x10, 0x11, 0x20, + 0x53, 0xf8, 0x10, 0xa0, 0x20, 0x88, 0x29, 0x28, 0x77, 0xa8, 0x1f, 0x10, 0x20, 0x00, 0x17, 0xfc, + 0x60, 0x0c, 0x02, 0x80, 0x00, 0x00, 0x16, 0x0c, 0x20, 0x08, 0x41, 0x00, 0x11, 0x10, 0x11, 0x20, + 0x50, 0x08, 0x10, 0x40, 0x12, 0x08, 0x3f, 0xa8, 0x15, 0x28, 0x01, 0x10, 0x20, 0x00, 0x50, 0x40, + 0x7c, 0x7c, 0x02, 0x80, 0xff, 0xff, 0x01, 0x10, 0x3f, 0xf8, 0x4f, 0xe0, 0x1f, 0xf0, 0x11, 0x20, + 0x34, 0x08, 0x17, 0xfc, 0x79, 0x08, 0x24, 0x44, 0x77, 0xa8, 0x01, 0x10, 0x20, 0x00, 0x34, 0x40, + 0x03, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x49, 0x20, 0x01, 0x00, 0x79, 0x20, + 0x3b, 0xf8, 0x50, 0x48, 0x24, 0xf8, 0x24, 0x44, 0x50, 0x20, 0x1f, 0x10, 0x3f, 0xf0, 0x3b, 0xf8, + 0x01, 0x80, 0x3f, 0xf8, 0x00, 0x00, 0x43, 0x10, 0x0f, 0xe0, 0x49, 0x20, 0x41, 0x04, 0x17, 0xfc, + 0x10, 0x40, 0x54, 0x48, 0x10, 0x80, 0x3f, 0x40, 0x5f, 0xfc, 0x40, 0x10, 0x20, 0x10, 0x10, 0x40, + 0x7f, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x10, 0xf0, 0x08, 0x20, 0x4f, 0xe0, 0x7f, 0xfc, 0x10, 0x00, + 0x11, 0x50, 0x54, 0x48, 0x10, 0x80, 0x20, 0x40, 0x00, 0x28, 0x20, 0x10, 0x00, 0x10, 0x10, 0x40, + 0x11, 0x10, 0x01, 0x00, 0x00, 0x00, 0x20, 0x80, 0x0f, 0xe0, 0x49, 0x20, 0x00, 0x00, 0x10, 0x00, + 0x79, 0x48, 0x1b, 0xf8, 0x04, 0x40, 0x3f, 0xfc, 0x04, 0x40, 0x1f, 0xf0, 0x00, 0x10, 0x7b, 0xf8, + 0x11, 0x10, 0x01, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x4f, 0xe0, 0x09, 0x20, 0x7c, 0x00, + 0x12, 0x48, 0x10, 0x40, 0x7f, 0xfc, 0x00, 0x48, 0x7f, 0xfc, 0x08, 0x00, 0x3f, 0xf0, 0x10, 0x00, + 0x1f, 0xf0, 0x7f, 0xfc, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 0xfc, 0x40, 0x00, 0x7f, 0xfc, 0x03, 0xf8, + 0x10, 0x40, 0x10, 0x40, 0x04, 0x40, 0x00, 0x50, 0x04, 0x40, 0x08, 0x00, 0x00, 0x00, 0x11, 0x10, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x01, 0x00, 0x7f, 0xf8, 0x09, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x84, + 0x30, 0xe0, 0x3f, 0xf8, 0x02, 0x18, 0x01, 0x04, 0x47, 0xfc, 0x40, 0x04, 0x0c, 0x00, 0x07, 0x04, + 0x3f, 0xfc, 0x01, 0x04, 0x03, 0xe0, 0x3f, 0xf8, 0x00, 0x18, 0x20, 0x40, 0x05, 0x8c, 0x16, 0xcc, + 0x10, 0x20, 0x01, 0x00, 0x61, 0x04, 0x40, 0x88, 0x28, 0x00, 0x20, 0x08, 0x02, 0x00, 0x01, 0xc8, + 0x20, 0x00, 0x40, 0x8c, 0x04, 0x20, 0x01, 0x00, 0x00, 0x04, 0x10, 0x40, 0x64, 0x50, 0x12, 0x70, + 0x10, 0x20, 0x01, 0x00, 0x38, 0x84, 0x22, 0x50, 0x14, 0x1c, 0x10, 0x10, 0x42, 0x20, 0x79, 0x10, + 0x27, 0xf0, 0x22, 0x54, 0x44, 0x20, 0x6f, 0xec, 0x00, 0x04, 0x08, 0x40, 0x3c, 0x20, 0x53, 0x30, + 0x10, 0x20, 0x01, 0x00, 0x26, 0x84, 0x12, 0x50, 0x12, 0x24, 0x08, 0x20, 0x22, 0x40, 0x49, 0x20, + 0x24, 0x10, 0x12, 0x24, 0x44, 0x04, 0x11, 0x10, 0x7f, 0xe4, 0x08, 0x40, 0x24, 0x50, 0x71, 0x50, + 0x10, 0x20, 0x01, 0x00, 0x24, 0x44, 0x14, 0x20, 0x11, 0x24, 0x08, 0x20, 0x12, 0x40, 0x49, 0x30, + 0x27, 0xf0, 0x14, 0x50, 0x24, 0x04, 0x08, 0x20, 0x00, 0x04, 0x04, 0x40, 0x3c, 0x88, 0x35, 0xd8, + 0x70, 0x20, 0x01, 0x00, 0x3c, 0x44, 0x0c, 0x20, 0x11, 0x20, 0x04, 0x40, 0x12, 0x80, 0x49, 0x48, + 0x24, 0x10, 0x0c, 0x50, 0x24, 0x08, 0x7f, 0xfc, 0x00, 0x04, 0x04, 0x40, 0x24, 0x88, 0x3d, 0x88, + 0x1c, 0x20, 0x01, 0x00, 0x24, 0x44, 0x08, 0x20, 0x11, 0x20, 0x04, 0x40, 0x42, 0x40, 0x79, 0x44, + 0x27, 0xf0, 0x08, 0x48, 0x24, 0x10, 0x08, 0x20, 0x00, 0x04, 0x7f, 0xfc, 0x3d, 0xf8, 0x19, 0x8c, + 0x10, 0x20, 0x7f, 0xfc, 0x24, 0x44, 0x14, 0x20, 0x71, 0x20, 0x04, 0x40, 0x22, 0x40, 0x49, 0xf8, + 0x24, 0x10, 0x14, 0x48, 0x04, 0x00, 0x0f, 0xe0, 0x1f, 0xfc, 0x04, 0x40, 0x24, 0x00, 0x11, 0xf8, + 0x10, 0x20, 0x01, 0x00, 0x3c, 0x44, 0x25, 0x28, 0x07, 0xf8, 0x40, 0x04, 0x1f, 0xe0, 0x49, 0x08, + 0x07, 0xf0, 0x25, 0xc0, 0x04, 0x00, 0x08, 0x20, 0x10, 0x20, 0x04, 0x40, 0x7f, 0xfc, 0x7d, 0x30, + 0x7c, 0x20, 0x01, 0x00, 0x25, 0xfc, 0x02, 0x84, 0x00, 0x00, 0x40, 0x04, 0x10, 0x00, 0x79, 0x08, + 0x01, 0x00, 0x02, 0x7c, 0x00, 0x00, 0x0f, 0xe0, 0x10, 0x20, 0x04, 0x40, 0x10, 0x10, 0x11, 0x30, + 0x10, 0x20, 0x01, 0x00, 0x24, 0x40, 0x02, 0xfc, 0x10, 0x00, 0x7f, 0xfc, 0x10, 0x00, 0x49, 0xf8, + 0x7f, 0xfc, 0x02, 0x40, 0x00, 0x80, 0x04, 0x40, 0x10, 0x20, 0x3f, 0xf8, 0x1f, 0xf0, 0x13, 0xf0, + 0x13, 0xfc, 0x01, 0x00, 0x3c, 0x40, 0x3e, 0x40, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x49, 0x08, + 0x01, 0x00, 0x3e, 0x48, 0x01, 0x00, 0x7f, 0xfc, 0x10, 0x20, 0x04, 0x40, 0x10, 0x10, 0x18, 0x00, + 0x10, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x40, 0x23, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x79, 0xf8, + 0x01, 0x00, 0x00, 0x48, 0x02, 0x00, 0x04, 0x40, 0x00, 0x20, 0x08, 0x20, 0x1f, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, + 0x47, 0xfc, 0x04, 0x0c, 0x7f, 0xf8, 0x17, 0x1c, 0x0f, 0xf0, 0x23, 0x04, 0x00, 0x00, 0x47, 0x04, + 0x60, 0x0c, 0x10, 0x40, 0x3f, 0xf8, 0x10, 0x8c, 0x16, 0x1c, 0x07, 0xf0, 0x04, 0x1c, 0x24, 0x88, + 0x28, 0x00, 0x25, 0x84, 0x44, 0x88, 0x10, 0xe0, 0x08, 0x10, 0x3e, 0x88, 0x4f, 0xc0, 0x21, 0x08, + 0x18, 0x30, 0x10, 0x40, 0x20, 0x08, 0x08, 0x54, 0x11, 0x60, 0x04, 0x10, 0x62, 0x24, 0x00, 0x00, + 0x13, 0xf8, 0x24, 0x84, 0x44, 0x88, 0x10, 0x90, 0x08, 0x10, 0x22, 0x50, 0x52, 0x40, 0x11, 0x10, + 0x04, 0x40, 0x10, 0x40, 0x20, 0x08, 0x0b, 0x30, 0x10, 0x80, 0x04, 0x10, 0x19, 0x24, 0x00, 0x00, + 0x12, 0x08, 0x24, 0x84, 0x47, 0x88, 0x11, 0x08, 0x48, 0x10, 0x22, 0x20, 0x4f, 0xc0, 0x01, 0x00, + 0x02, 0x80, 0x10, 0x40, 0x30, 0x08, 0x65, 0x28, 0x11, 0x40, 0x44, 0x10, 0x01, 0x20, 0x1f, 0xf0, + 0x13, 0xf8, 0x24, 0xa4, 0x44, 0x88, 0x13, 0xf8, 0x28, 0x10, 0x22, 0x50, 0x32, 0x40, 0x7f, 0xfc, + 0x01, 0x80, 0x10, 0x40, 0x28, 0x68, 0x35, 0x28, 0x12, 0x40, 0x24, 0x10, 0x00, 0xa0, 0x10, 0x10, + 0x12, 0x08, 0x3f, 0xa4, 0x47, 0x88, 0x10, 0x00, 0x18, 0x10, 0x3e, 0x50, 0x32, 0x40, 0x00, 0x00, + 0x02, 0x40, 0x10, 0x40, 0x24, 0xa8, 0x25, 0x24, 0x10, 0x40, 0x17, 0xf0, 0x78, 0xa8, 0x10, 0x10, + 0x13, 0xf8, 0x04, 0x24, 0x44, 0x88, 0x17, 0xfc, 0x0f, 0xf0, 0x08, 0x48, 0x2f, 0xc0, 0x67, 0xcc, + 0x04, 0x20, 0x10, 0x40, 0x24, 0x88, 0x27, 0x44, 0x13, 0xfc, 0x08, 0x00, 0x43, 0xf8, 0x10, 0x10, + 0x72, 0x08, 0x7f, 0xa4, 0x44, 0x88, 0x54, 0xa4, 0x08, 0x00, 0x08, 0x48, 0x22, 0x00, 0x18, 0x30, + 0x04, 0x20, 0x57, 0xfc, 0x24, 0x88, 0x24, 0x40, 0x52, 0x44, 0x04, 0x00, 0x21, 0x08, 0x1f, 0xf0, + 0x03, 0xf8, 0x04, 0x24, 0x7f, 0xf8, 0x57, 0xfc, 0x04, 0x00, 0x7f, 0x48, 0x20, 0x00, 0x64, 0x48, + 0x08, 0x10, 0x30, 0x40, 0x3f, 0xf8, 0x74, 0x40, 0x32, 0x44, 0x04, 0x00, 0x10, 0x90, 0x01, 0x00, + 0x00, 0x80, 0x44, 0x24, 0x04, 0x00, 0x55, 0x10, 0x04, 0x00, 0x08, 0x88, 0x3f, 0xe0, 0x1c, 0xb8, + 0x08, 0x10, 0x10, 0x40, 0x04, 0x80, 0x27, 0xfc, 0x13, 0xfc, 0x7f, 0xfc, 0x78, 0x80, 0x01, 0x00, + 0x07, 0xfc, 0x3f, 0xa4, 0x02, 0x00, 0x19, 0xf0, 0x04, 0x00, 0x08, 0x7c, 0x02, 0x00, 0x50, 0x04, + 0x08, 0x10, 0x10, 0x40, 0x04, 0x80, 0x20, 0x40, 0x10, 0x40, 0x02, 0x00, 0x4b, 0xfc, 0x01, 0xf0, + 0x10, 0xa0, 0x14, 0x24, 0x7f, 0xf8, 0x11, 0x10, 0x7f, 0xfc, 0x38, 0x40, 0x00, 0x00, 0x7f, 0xfc, + 0x7f, 0xf0, 0x08, 0x40, 0x7f, 0xfc, 0x20, 0x48, 0x0b, 0xfc, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00, + 0x21, 0x10, 0x14, 0x04, 0x00, 0x00, 0x11, 0xf0, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x50, 0x08, 0x40, 0x01, 0x00, 0x10, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + 0x70, 0xe0, 0x00, 0x1c, 0x47, 0xfc, 0x43, 0xf0, 0x07, 0x00, 0x01, 0x00, 0x08, 0x10, 0x47, 0xfc, + 0x00, 0xe0, 0x7c, 0xf8, 0x03, 0x00, 0x7f, 0xfc, 0x11, 0x0c, 0x3f, 0xf0, 0x7f, 0xfc, 0x21, 0x7c, + 0x0c, 0x20, 0x00, 0x04, 0x28, 0x00, 0x24, 0x14, 0x01, 0x00, 0x01, 0x00, 0x09, 0x10, 0x28, 0x00, + 0x04, 0x20, 0x44, 0x88, 0x03, 0x00, 0x01, 0x00, 0x11, 0x04, 0x20, 0x10, 0x40, 0x04, 0x12, 0x44, + 0x03, 0x20, 0x1f, 0x84, 0x11, 0xf8, 0x24, 0x44, 0x01, 0x00, 0x61, 0x0c, 0x49, 0x10, 0x14, 0x1c, + 0x08, 0x20, 0x44, 0x88, 0x03, 0x18, 0x01, 0x00, 0x11, 0x04, 0x20, 0x10, 0x40, 0x04, 0x14, 0x44, + 0x00, 0xa0, 0x10, 0x84, 0x11, 0x08, 0x04, 0x88, 0x01, 0x00, 0x11, 0x10, 0x2a, 0x90, 0x12, 0x24, + 0x00, 0x20, 0x44, 0x88, 0x03, 0xb0, 0x01, 0x00, 0x11, 0x04, 0x20, 0x10, 0x4f, 0xe4, 0x08, 0x44, + 0x7f, 0xe0, 0x10, 0x84, 0x11, 0x08, 0x00, 0x00, 0x01, 0x00, 0x09, 0x20, 0x1c, 0x90, 0x11, 0x20, + 0x3f, 0xf8, 0x44, 0x88, 0x03, 0x60, 0x1f, 0xf0, 0x51, 0x8c, 0x20, 0x10, 0x48, 0x24, 0x08, 0x44, + 0x10, 0x30, 0x10, 0x84, 0x11, 0xf8, 0x1f, 0xf0, 0x7f, 0xfc, 0x05, 0x40, 0x7e, 0x90, 0x10, 0xa0, + 0x00, 0x20, 0x7c, 0xf8, 0x03, 0x00, 0x01, 0x00, 0x51, 0x54, 0x3f, 0xf0, 0x48, 0x24, 0x7f, 0x44, + 0x1f, 0xe8, 0x1f, 0x84, 0x70, 0x00, 0x10, 0x10, 0x01, 0x00, 0x03, 0x80, 0x08, 0x90, 0x10, 0xa0, + 0x7f, 0xfc, 0x00, 0x00, 0x7f, 0xfc, 0x01, 0x00, 0x35, 0x24, 0x20, 0x10, 0x48, 0x24, 0x08, 0x44, + 0x10, 0x24, 0x00, 0x04, 0x03, 0xfc, 0x1f, 0xf0, 0x00, 0x80, 0x7f, 0xfc, 0x08, 0x90, 0x77, 0xfc, + 0x01, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x3f, 0xc8, 0x39, 0x24, 0x20, 0x10, 0x48, 0x24, 0x08, 0x44, + 0x1f, 0xe0, 0x00, 0x04, 0x00, 0x40, 0x10, 0x10, 0x00, 0x40, 0x01, 0x00, 0x7e, 0xfc, 0x00, 0x40, + 0x1f, 0xf0, 0x1f, 0xe0, 0x03, 0x00, 0x08, 0x30, 0x11, 0xfc, 0x20, 0x10, 0x48, 0x24, 0x48, 0x44, + 0x10, 0x20, 0x3f, 0xc4, 0x02, 0x40, 0x7f, 0xfc, 0x4f, 0xe4, 0x01, 0x00, 0x24, 0x80, 0x04, 0x40, + 0x05, 0x10, 0x10, 0x20, 0x03, 0x00, 0x04, 0x20, 0x10, 0x20, 0x20, 0x10, 0x4f, 0xe4, 0x3e, 0x7c, + 0x1f, 0xe0, 0x00, 0x04, 0x01, 0xf8, 0x04, 0x40, 0x40, 0x04, 0x1f, 0xf0, 0x24, 0x80, 0x13, 0xf8, + 0x49, 0x20, 0x10, 0x20, 0x03, 0xf0, 0x02, 0x00, 0x7c, 0x20, 0x3f, 0xf0, 0x40, 0x04, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x04, 0x11, 0x40, 0x3f, 0xf8, 0x7f, 0xfc, 0x01, 0x00, 0x7e, 0xe0, 0x12, 0x40, + 0x3e, 0xfc, 0x10, 0x20, 0x03, 0x00, 0x7f, 0xfc, 0x11, 0xfc, 0x04, 0x00, 0x40, 0x04, 0x10, 0x00, + 0x01, 0x00, 0x7f, 0xfc, 0x20, 0x40, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x18, 0x22, 0x40, + 0x10, 0x40, 0x1f, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x7f, 0xfc, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08, + 0x04, 0x1c, 0x7f, 0xfc, 0x07, 0x00, 0x20, 0x84, 0x10, 0x30, 0x47, 0xfc, 0x17, 0xfc, 0x38, 0x18, + 0x42, 0x10, 0x40, 0x60, 0x40, 0x3c, 0x1f, 0xf0, 0x20, 0x00, 0x07, 0xfc, 0x30, 0x40, 0x10, 0x88, + 0x42, 0x24, 0x40, 0x00, 0x01, 0x00, 0x2f, 0x48, 0x10, 0x10, 0x58, 0x00, 0x10, 0x00, 0x06, 0x60, + 0x41, 0x10, 0x20, 0x10, 0x20, 0x44, 0x10, 0x10, 0x40, 0x00, 0x10, 0x40, 0x10, 0x40, 0x18, 0x50, + 0x29, 0x24, 0x58, 0x10, 0x01, 0x00, 0x29, 0x48, 0x10, 0x90, 0x28, 0x78, 0x10, 0x00, 0x01, 0x80, + 0x21, 0x10, 0x10, 0x08, 0x10, 0x44, 0x10, 0x10, 0x80, 0x00, 0x18, 0x40, 0x10, 0x40, 0x12, 0x20, + 0x28, 0xa0, 0x44, 0x10, 0x01, 0x00, 0x29, 0x30, 0x11, 0x10, 0x28, 0x88, 0x11, 0xf8, 0x0e, 0x40, + 0x20, 0x90, 0x08, 0x08, 0x08, 0x40, 0x10, 0x10, 0x00, 0x00, 0x14, 0x40, 0x17, 0xfc, 0x11, 0x10, + 0x10, 0xa0, 0x42, 0x20, 0x01, 0x00, 0x29, 0x30, 0x50, 0x10, 0x28, 0x80, 0x11, 0x08, 0x08, 0x40, + 0x20, 0x90, 0x08, 0x48, 0x08, 0x40, 0x10, 0x10, 0x00, 0x00, 0x10, 0x40, 0x10, 0x40, 0x10, 0x88, + 0x12, 0x48, 0x41, 0x40, 0x01, 0x00, 0x29, 0x48, 0x30, 0x10, 0x2e, 0x80, 0x11, 0x08, 0x04, 0x20, + 0x20, 0x90, 0x04, 0x48, 0x04, 0x40, 0x1f, 0xf0, 0x00, 0x00, 0x10, 0x40, 0x73, 0xf8, 0x10, 0x48, + 0x2a, 0x48, 0x40, 0x80, 0x7f, 0xfc, 0x2f, 0x48, 0x17, 0xfc, 0x08, 0x80, 0x11, 0x08, 0x04, 0x20, + 0x3e, 0x90, 0x04, 0x88, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x1a, 0x08, 0x13, 0xe0, + 0x4a, 0x48, 0x41, 0x40, 0x01, 0x00, 0x22, 0x48, 0x10, 0x10, 0x08, 0xf8, 0x51, 0xf8, 0x7f, 0xfc, + 0x22, 0x90, 0x04, 0x08, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x13, 0xf8, 0x71, 0x10, + 0x0a, 0x48, 0x42, 0x40, 0x01, 0x00, 0x62, 0xc8, 0x11, 0x50, 0x7f, 0x08, 0x31, 0x08, 0x02, 0x00, + 0x22, 0xfc, 0x02, 0x08, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x70, 0x78, 0x12, 0x08, 0x00, 0x90, + 0x0a, 0x48, 0x4c, 0x20, 0x00, 0x80, 0x2f, 0x7c, 0x32, 0x48, 0x08, 0x08, 0x11, 0x08, 0x42, 0x04, + 0x3e, 0x80, 0x7f, 0xf8, 0x04, 0x40, 0x7f, 0xfc, 0x00, 0x00, 0x00, 0x40, 0x7b, 0xf8, 0x00, 0x40, + 0x0a, 0x48, 0x40, 0x20, 0x00, 0x40, 0x22, 0x40, 0x50, 0x08, 0x08, 0x08, 0x11, 0x08, 0x40, 0x04, + 0x00, 0x80, 0x02, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x40, 0x13, 0xfc, + 0x7a, 0x08, 0x40, 0x00, 0x00, 0x20, 0x12, 0x20, 0x13, 0xc0, 0x3e, 0xf8, 0x09, 0xf8, 0x7f, 0xfc, + 0x00, 0xf0, 0x0a, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x10, 0x78, 0x10, 0x40, + 0x03, 0xf8, 0x7f, 0xf8, 0x1f, 0xf0, 0x12, 0x20, 0x10, 0x38, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, + 0x7e, 0x0c, 0x12, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x10, 0x40, 0x20, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, + 0x30, 0xc0, 0x01, 0x00, 0x48, 0x1c, 0x02, 0x08, 0x1f, 0x20, 0x41, 0x8c, 0x47, 0xfc, 0x7f, 0xfc, + 0x17, 0xfc, 0x40, 0x04, 0x07, 0xf8, 0x04, 0x7c, 0x23, 0x9c, 0x01, 0x00, 0x47, 0xfc, 0x01, 0x00, + 0x08, 0x20, 0x01, 0x00, 0x48, 0x60, 0x13, 0xf8, 0x11, 0x20, 0x4c, 0x54, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x20, 0x20, 0x08, 0x08, 0x08, 0x06, 0x84, 0x20, 0x84, 0x61, 0x0c, 0x28, 0x00, 0x01, 0x00, + 0x04, 0x10, 0x41, 0x04, 0x28, 0x80, 0x1a, 0x08, 0x11, 0x38, 0x22, 0x24, 0x13, 0x04, 0x00, 0x00, + 0x11, 0x20, 0x10, 0x10, 0x08, 0x08, 0x42, 0x84, 0x20, 0x84, 0x11, 0x10, 0x10, 0x40, 0x01, 0x00, + 0x04, 0x10, 0x2f, 0xe8, 0x29, 0x00, 0x16, 0x08, 0x1f, 0x24, 0x22, 0x20, 0x11, 0xc8, 0x00, 0x00, + 0x11, 0x20, 0x08, 0x20, 0x08, 0x00, 0x42, 0x80, 0x30, 0x84, 0x09, 0x20, 0x10, 0x40, 0x1f, 0xf0, + 0x02, 0x10, 0x11, 0x10, 0x29, 0x7c, 0x12, 0x08, 0x51, 0x24, 0x22, 0x50, 0x11, 0x10, 0x1f, 0xf0, + 0x11, 0x10, 0x00, 0x00, 0x0e, 0x00, 0x7a, 0xc0, 0x2a, 0xa4, 0x05, 0x40, 0x10, 0x40, 0x00, 0x00, + 0x02, 0x10, 0x09, 0x20, 0x2a, 0x84, 0x13, 0xf8, 0x31, 0x24, 0x22, 0x50, 0x11, 0x28, 0x00, 0x00, + 0x11, 0x10, 0x1f, 0xf0, 0x09, 0x80, 0x4a, 0xbc, 0x2a, 0xa4, 0x7f, 0xfc, 0x14, 0x44, 0x00, 0x00, + 0x02, 0x10, 0x05, 0x40, 0x2a, 0x80, 0x10, 0x40, 0x1f, 0x24, 0x3e, 0x48, 0x11, 0x24, 0x78, 0x3c, + 0x12, 0x10, 0x10, 0x10, 0x08, 0x60, 0x4a, 0x88, 0x24, 0xa4, 0x01, 0x00, 0x12, 0x44, 0x30, 0x78, + 0x5f, 0xf4, 0x05, 0x40, 0x2a, 0xf8, 0x10, 0x40, 0x08, 0x28, 0x20, 0x88, 0x71, 0xf8, 0x2f, 0x44, + 0x52, 0x10, 0x10, 0x10, 0x08, 0x10, 0x4a, 0xc0, 0x24, 0xa4, 0x01, 0x00, 0x71, 0x48, 0x08, 0x48, + 0x20, 0x08, 0x03, 0x80, 0x2a, 0xa8, 0x77, 0xfc, 0x7f, 0xa8, 0x20, 0x80, 0x01, 0x08, 0x28, 0x40, + 0x30, 0x00, 0x10, 0x10, 0x48, 0x04, 0x4b, 0xf8, 0x2a, 0xa4, 0x1f, 0xf0, 0x00, 0xd0, 0x44, 0x40, + 0x10, 0x10, 0x7f, 0xfc, 0x2a, 0xa8, 0x00, 0x40, 0x0a, 0x24, 0x20, 0x80, 0x01, 0x08, 0x28, 0x40, + 0x17, 0xfc, 0x10, 0x10, 0x40, 0x04, 0x4a, 0x08, 0x32, 0xa4, 0x11, 0x10, 0x00, 0x40, 0x44, 0x44, + 0x08, 0x20, 0x01, 0x00, 0x2a, 0xa8, 0x00, 0x40, 0x09, 0x24, 0x3f, 0xfc, 0x01, 0xf8, 0x2f, 0x70, + 0x10, 0x40, 0x10, 0x10, 0x7f, 0xfc, 0x7a, 0x08, 0x22, 0xa4, 0x1f, 0xf0, 0x10, 0x20, 0x7f, 0xfc, + 0x04, 0x40, 0x01, 0x00, 0x3e, 0xf8, 0x13, 0xc0, 0x3f, 0x3c, 0x00, 0x90, 0x11, 0x08, 0x28, 0x4c, + 0x08, 0x40, 0x1f, 0xf0, 0x01, 0x00, 0x03, 0xf8, 0x20, 0x84, 0x11, 0x10, 0x10, 0x20, 0x01, 0x00, + 0x04, 0x40, 0x01, 0x00, 0x03, 0x00, 0x10, 0x38, 0x08, 0x00, 0x00, 0xa0, 0x21, 0xf8, 0x08, 0x40, + 0x08, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x84, 0x1f, 0xf0, 0x27, 0xfc, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xe0, + 0x07, 0xf0, 0x26, 0x18, 0x20, 0x60, 0x1f, 0xfc, 0x30, 0x40, 0x0f, 0xfc, 0x43, 0xfc, 0x59, 0x04, + 0x61, 0xfc, 0x01, 0xf8, 0x7f, 0xfc, 0x47, 0xfc, 0x07, 0x00, 0x0f, 0xf0, 0x03, 0xfc, 0x20, 0x20, + 0x04, 0x10, 0x22, 0x08, 0x10, 0x10, 0x11, 0x00, 0x08, 0x40, 0x10, 0x04, 0x2d, 0x00, 0x44, 0x88, + 0x5d, 0x04, 0x01, 0x08, 0x01, 0x00, 0x28, 0x00, 0x01, 0x00, 0x08, 0x10, 0x42, 0x40, 0x20, 0x20, + 0x44, 0x10, 0x22, 0x08, 0x08, 0x10, 0x1f, 0xf0, 0x0b, 0xfc, 0x10, 0x04, 0x11, 0x00, 0x24, 0x50, + 0x51, 0x00, 0x01, 0x08, 0x01, 0x00, 0x14, 0x30, 0x01, 0x00, 0x08, 0x10, 0x22, 0x40, 0x20, 0x20, + 0x27, 0xf0, 0x22, 0x48, 0x04, 0x10, 0x11, 0x00, 0x08, 0x40, 0x11, 0x00, 0x11, 0x00, 0x24, 0x20, + 0x51, 0x18, 0x61, 0x08, 0x01, 0x00, 0x12, 0x08, 0x01, 0x00, 0x6f, 0xf0, 0x23, 0xf8, 0x20, 0x20, + 0x14, 0x10, 0x3e, 0x48, 0x04, 0x10, 0x5f, 0xf0, 0x08, 0x40, 0x11, 0x30, 0x11, 0xf0, 0x24, 0x50, + 0x51, 0xe8, 0x19, 0xf8, 0x3f, 0xf8, 0x11, 0x08, 0x01, 0x00, 0x18, 0x10, 0x12, 0x40, 0x20, 0x20, + 0x0f, 0xf0, 0x22, 0x48, 0x3f, 0xf0, 0x31, 0x00, 0x7b, 0xf8, 0x11, 0x10, 0x01, 0x00, 0x24, 0x50, + 0x5d, 0x28, 0x10, 0x00, 0x41, 0x04, 0x11, 0x08, 0x01, 0x00, 0x07, 0xf0, 0x12, 0x40, 0x60, 0x20, + 0x04, 0x10, 0x3e, 0x48, 0x02, 0x00, 0x1f, 0xf8, 0x42, 0x48, 0x71, 0x10, 0x01, 0x00, 0x26, 0x88, + 0x11, 0x28, 0x12, 0xf4, 0x79, 0x3c, 0x10, 0x88, 0x01, 0x00, 0x02, 0x00, 0x03, 0xf8, 0x23, 0xfc, + 0x7f, 0xfc, 0x22, 0x48, 0x42, 0x04, 0x08, 0x80, 0x42, 0x48, 0x1d, 0x10, 0x3f, 0xf8, 0x3d, 0x88, + 0x15, 0xe8, 0x11, 0x08, 0x0e, 0xe0, 0x70, 0x88, 0x7f, 0xfc, 0x7f, 0xfc, 0x02, 0x40, 0x10, 0x00, + 0x02, 0x00, 0x3e, 0x08, 0x7f, 0xfc, 0x5d, 0x74, 0x43, 0xf8, 0x13, 0x90, 0x00, 0x00, 0x20, 0x88, + 0x7e, 0x08, 0x10, 0x90, 0x01, 0x80, 0x00, 0x88, 0x01, 0x00, 0x02, 0x40, 0x0a, 0x40, 0x10, 0x00, + 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x41, 0x04, 0x7a, 0x48, 0x11, 0x70, 0x40, 0x04, 0x20, 0xfc, + 0x45, 0x08, 0x78, 0x60, 0x02, 0xc0, 0x00, 0x88, 0x01, 0x00, 0x02, 0x20, 0x07, 0xfc, 0x40, 0x00, + 0x01, 0x00, 0x7f, 0xfc, 0x08, 0x20, 0x7f, 0xfc, 0x0a, 0x48, 0x11, 0x00, 0x40, 0x04, 0x7e, 0x40, + 0x45, 0xf8, 0x10, 0x90, 0x04, 0x60, 0x17, 0xf8, 0x01, 0x00, 0x1f, 0xd0, 0x22, 0x20, 0x21, 0xf8, + 0x1f, 0x00, 0x04, 0x40, 0x7f, 0xfc, 0x01, 0x00, 0x0b, 0xf8, 0x11, 0x00, 0x7f, 0xfc, 0x10, 0x40, + 0x7c, 0x80, 0x13, 0xfc, 0x3f, 0xf8, 0x10, 0x80, 0x3f, 0xf8, 0x02, 0x08, 0x41, 0x10, 0x10, 0x00, + 0x00, 0xf0, 0x08, 0x20, 0x08, 0x20, 0x1f, 0xf0, 0x78, 0xa0, 0x01, 0x00, 0x01, 0x00, 0x10, 0x40, + 0x00, 0x80, 0x10, 0x90, 0x00, 0x10, 0x20, 0x80, 0x00, 0x00, 0x02, 0x00, 0x01, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, + 0x04, 0x1c, 0x3c, 0x18, 0x01, 0x00, 0x78, 0x3c, 0x1f, 0xf8, 0x3f, 0xf8, 0x12, 0x1c, 0x04, 0x1c, + 0x02, 0x04, 0x04, 0x04, 0x46, 0x0c, 0x40, 0x1c, 0x10, 0x7c, 0x11, 0xc0, 0x70, 0x1c, 0x42, 0x08, + 0x02, 0x24, 0x03, 0xe0, 0x01, 0x00, 0x27, 0x44, 0x20, 0x08, 0x21, 0x08, 0x19, 0x04, 0x02, 0x24, + 0x71, 0x08, 0x02, 0x08, 0x41, 0x90, 0x40, 0x04, 0x10, 0x84, 0x10, 0x40, 0x1c, 0x38, 0x21, 0x10, + 0x61, 0x24, 0x0c, 0x40, 0x01, 0x00, 0x24, 0x44, 0x20, 0x08, 0x21, 0x08, 0x15, 0x04, 0x12, 0x24, + 0x2e, 0x88, 0x01, 0x10, 0x20, 0x60, 0x40, 0x04, 0x10, 0x84, 0x10, 0x40, 0x06, 0x60, 0x21, 0x10, + 0x18, 0xa0, 0x04, 0x20, 0x01, 0x00, 0x24, 0x40, 0x20, 0x00, 0x21, 0x08, 0x10, 0x84, 0x19, 0x20, + 0x28, 0x50, 0x71, 0x10, 0x20, 0x90, 0x47, 0xc4, 0x10, 0x80, 0x10, 0x40, 0x03, 0x80, 0x10, 0xa0, + 0x10, 0xa0, 0x7f, 0xfc, 0x01, 0x00, 0x24, 0x40, 0x20, 0x00, 0x21, 0x08, 0x10, 0x84, 0x15, 0x20, + 0x28, 0x50, 0x1c, 0xa0, 0x11, 0x08, 0x44, 0x44, 0x10, 0x80, 0x17, 0xfc, 0x01, 0x80, 0x10, 0xa0, + 0x12, 0x48, 0x02, 0x00, 0x3f, 0xf8, 0x24, 0x40, 0x20, 0x00, 0x01, 0x00, 0x7c, 0xfc, 0x11, 0x20, + 0x2e, 0x20, 0x10, 0xa0, 0x11, 0x08, 0x44, 0x44, 0x10, 0x80, 0x50, 0x40, 0x01, 0x00, 0x00, 0x40, + 0x12, 0x48, 0x01, 0x00, 0x21, 0x08, 0x24, 0x40, 0x3f, 0xf0, 0x01, 0x00, 0x10, 0x84, 0x13, 0xf8, + 0x28, 0x20, 0x10, 0x40, 0x03, 0xf8, 0x47, 0xc4, 0x10, 0x80, 0x30, 0x20, 0x3f, 0xf8, 0x04, 0x48, + 0x7a, 0x48, 0x3f, 0xf8, 0x21, 0x08, 0x27, 0x60, 0x00, 0x10, 0x1f, 0xf0, 0x10, 0x84, 0x12, 0x08, + 0x09, 0xfc, 0x10, 0x40, 0x04, 0x00, 0x40, 0x04, 0x50, 0xe0, 0x10, 0x10, 0x01, 0x00, 0x02, 0x44, + 0x12, 0x48, 0x24, 0x48, 0x21, 0x08, 0x24, 0x58, 0x00, 0x10, 0x11, 0x10, 0x3c, 0xfc, 0x12, 0x08, + 0x3c, 0x20, 0x12, 0x48, 0x22, 0x1c, 0x40, 0x04, 0x30, 0x98, 0x0b, 0xf0, 0x01, 0x00, 0x02, 0x44, + 0x12, 0x48, 0x24, 0x48, 0x21, 0x08, 0x24, 0x44, 0x00, 0x10, 0x11, 0x10, 0x40, 0x84, 0x72, 0x08, + 0x24, 0x20, 0x7d, 0x44, 0x41, 0x14, 0x4f, 0xe4, 0x10, 0x84, 0x08, 0x00, 0x3f, 0xf0, 0x11, 0xfc, + 0x12, 0x48, 0x3f, 0xf8, 0x3f, 0xf8, 0x04, 0x40, 0x00, 0x10, 0x11, 0x10, 0x20, 0x84, 0x03, 0xf8, + 0x24, 0x20, 0x11, 0xfc, 0x01, 0x10, 0x40, 0x04, 0x10, 0x80, 0x04, 0x00, 0x04, 0x40, 0x21, 0x00, + 0x7a, 0x08, 0x04, 0x40, 0x01, 0x00, 0x04, 0x40, 0x3f, 0xf0, 0x01, 0x00, 0x1c, 0x84, 0x11, 0x20, + 0x24, 0xe0, 0x10, 0x80, 0x11, 0x10, 0x40, 0x04, 0x08, 0x80, 0x7f, 0xfc, 0x0c, 0x60, 0x01, 0x00, + 0x03, 0xf8, 0x7f, 0xfc, 0x01, 0x00, 0x04, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0xfc, 0x11, 0x10, + 0x3c, 0x18, 0x10, 0x80, 0x21, 0xf0, 0x7f, 0xfc, 0x08, 0x80, 0x02, 0x00, 0x08, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x22, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xf8, + 0x20, 0x10, 0x00, 0x70, 0x03, 0x00, 0x07, 0x00, 0x02, 0x38, 0x08, 0x00, 0x10, 0x70, 0x00, 0x18, + 0x60, 0x70, 0x7f, 0xfc, 0x10, 0x20, 0x41, 0x18, 0x40, 0x00, 0x7f, 0xfc, 0x41, 0x04, 0x11, 0x08, + 0x3f, 0xf8, 0x00, 0x10, 0x38, 0x8c, 0x01, 0x00, 0x62, 0x08, 0x08, 0x7c, 0x10, 0x10, 0x00, 0x04, + 0x10, 0x08, 0x00, 0x00, 0x10, 0x20, 0x41, 0x08, 0x22, 0x7c, 0x01, 0x00, 0x21, 0x08, 0x11, 0x08, + 0x0c, 0x30, 0x48, 0x10, 0x06, 0x90, 0x41, 0x0c, 0x1a, 0x08, 0x08, 0x44, 0x10, 0x10, 0x00, 0x04, + 0x08, 0x08, 0x00, 0x00, 0x10, 0x20, 0x21, 0x08, 0x14, 0x44, 0x09, 0x20, 0x12, 0x10, 0x11, 0x60, + 0x04, 0x20, 0x78, 0x10, 0x01, 0xa0, 0x21, 0x10, 0x02, 0x08, 0x48, 0x44, 0x10, 0x10, 0x48, 0x04, + 0x04, 0x08, 0x00, 0x00, 0x10, 0x20, 0x21, 0x08, 0x18, 0x44, 0x11, 0x10, 0x08, 0x20, 0x11, 0x10, + 0x06, 0x60, 0x48, 0x10, 0x38, 0xc0, 0x11, 0x20, 0x02, 0x08, 0x29, 0x44, 0x7f, 0xfc, 0x7b, 0xf4, + 0x04, 0x08, 0x00, 0x00, 0x11, 0xfc, 0x3f, 0xf8, 0x64, 0x44, 0x01, 0x00, 0x04, 0x40, 0x51, 0x10, + 0x42, 0x00, 0x48, 0x90, 0x06, 0xa0, 0x09, 0x20, 0x7b, 0x18, 0x1a, 0x44, 0x11, 0x10, 0x48, 0x04, + 0x02, 0x08, 0x1f, 0xf0, 0x55, 0x24, 0x21, 0x08, 0x44, 0x44, 0x3f, 0xf8, 0x04, 0x40, 0x35, 0x10, + 0x62, 0x00, 0x48, 0x90, 0x31, 0x90, 0x09, 0x40, 0x42, 0xa8, 0x1c, 0x44, 0x11, 0x10, 0x48, 0x04, + 0x02, 0x08, 0x00, 0x00, 0x39, 0x24, 0x21, 0x08, 0x44, 0x44, 0x01, 0x00, 0x02, 0x80, 0x39, 0xf4, + 0x33, 0x00, 0x79, 0x10, 0x0d, 0x08, 0x05, 0x60, 0x22, 0x48, 0x08, 0x44, 0x1f, 0xf0, 0x49, 0xfc, + 0x02, 0x08, 0x00, 0x00, 0x11, 0xfc, 0x21, 0x08, 0x22, 0x44, 0x01, 0x00, 0x02, 0x80, 0x12, 0x08, + 0x18, 0x00, 0x48, 0x10, 0x02, 0x00, 0x7d, 0x90, 0x12, 0x48, 0x7f, 0x44, 0x11, 0x10, 0x49, 0x10, + 0x02, 0x08, 0x00, 0x00, 0x09, 0x24, 0x3f, 0xf8, 0x22, 0x44, 0x67, 0xcc, 0x01, 0x00, 0x11, 0x10, + 0x08, 0x00, 0x48, 0x10, 0x1f, 0xf0, 0x01, 0x88, 0x7a, 0x48, 0x08, 0x44, 0x11, 0x10, 0x49, 0x10, + 0x7f, 0xf8, 0x00, 0x00, 0x05, 0x24, 0x21, 0x08, 0x22, 0x44, 0x18, 0x30, 0x7f, 0xfc, 0x7c, 0xa0, + 0x0c, 0x00, 0x4b, 0xfc, 0x40, 0x04, 0x01, 0x00, 0x4b, 0xf8, 0x08, 0x44, 0x1f, 0xf0, 0x49, 0x10, + 0x02, 0x00, 0x3f, 0xf8, 0x7d, 0xfc, 0x21, 0x08, 0x7e, 0x7c, 0x04, 0x40, 0x01, 0x00, 0x10, 0xa0, + 0x04, 0x00, 0x78, 0x10, 0x7f, 0xfc, 0x01, 0x00, 0x20, 0x40, 0x38, 0x7c, 0x01, 0x00, 0x78, 0x10, + 0x02, 0x00, 0x04, 0x40, 0x10, 0x20, 0x21, 0x08, 0x10, 0x00, 0x02, 0x80, 0x01, 0x00, 0x10, 0x40, + 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x01, 0x00, 0x10, 0x40, 0x06, 0x00, 0x7f, 0xfc, 0x03, 0xf0, + 0x02, 0x00, 0x08, 0x20, 0x10, 0x20, 0x3f, 0xf8, 0x10, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x40, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, + 0x4f, 0xfc, 0x70, 0x40, 0x07, 0x00, 0x43, 0xf0, 0x07, 0xf8, 0x47, 0xfc, 0x31, 0xfc, 0x3e, 0x08, + 0x03, 0x04, 0x7f, 0xfc, 0x10, 0x40, 0x47, 0xfc, 0x11, 0x18, 0x41, 0xfc, 0x4b, 0x30, 0x20, 0x10, + 0x38, 0x00, 0x18, 0x40, 0x01, 0x00, 0x24, 0x14, 0x44, 0x08, 0x28, 0x00, 0x12, 0x04, 0x09, 0xf0, + 0x60, 0xc4, 0x04, 0x40, 0x10, 0x40, 0x28, 0x00, 0x10, 0x84, 0x27, 0x00, 0x44, 0x90, 0x20, 0x10, + 0x28, 0x00, 0x0c, 0x40, 0x01, 0x00, 0x24, 0x04, 0x24, 0x08, 0x10, 0x70, 0x12, 0x04, 0x04, 0x20, + 0x18, 0x28, 0x04, 0x40, 0x10, 0x40, 0x12, 0x10, 0x12, 0x44, 0x29, 0x00, 0x24, 0x90, 0x20, 0x10, + 0x2e, 0x3c, 0x04, 0x40, 0x01, 0x00, 0x24, 0x48, 0x24, 0x08, 0x10, 0x10, 0x12, 0x00, 0x04, 0x00, + 0x16, 0x10, 0x04, 0x40, 0x10, 0x40, 0x11, 0x10, 0x11, 0x24, 0x11, 0x00, 0x22, 0x90, 0x3f, 0xf0, + 0x08, 0x44, 0x04, 0x40, 0x41, 0x04, 0x04, 0x80, 0x14, 0x08, 0x10, 0x10, 0x12, 0x00, 0x02, 0x00, + 0x10, 0x10, 0x14, 0x50, 0x10, 0x7c, 0x11, 0x10, 0x70, 0xa4, 0x11, 0xf0, 0x12, 0xfc, 0x20, 0x10, + 0x08, 0x40, 0x04, 0x40, 0x21, 0x04, 0x00, 0x00, 0x17, 0xf8, 0x10, 0x10, 0x72, 0x00, 0x3f, 0xf8, + 0x10, 0x08, 0x14, 0x48, 0x10, 0x40, 0x11, 0x10, 0x1c, 0x94, 0x11, 0x00, 0x12, 0x90, 0x20, 0x10, + 0x7f, 0x40, 0x7f, 0xfc, 0x21, 0x08, 0x08, 0xf8, 0x10, 0x00, 0x11, 0x10, 0x1b, 0xf8, 0x00, 0x00, + 0x10, 0x08, 0x24, 0x48, 0x10, 0x40, 0x17, 0xfc, 0x10, 0x54, 0x01, 0x00, 0x02, 0x90, 0x3f, 0xf0, + 0x00, 0x40, 0x04, 0x40, 0x11, 0x08, 0x48, 0x88, 0x10, 0x00, 0x71, 0x10, 0x12, 0x48, 0x00, 0x00, + 0x10, 0x08, 0x24, 0x44, 0x54, 0x7c, 0x71, 0x10, 0x12, 0x54, 0x7f, 0xfc, 0x03, 0x88, 0x20, 0x10, + 0x3e, 0x70, 0x04, 0x40, 0x11, 0x10, 0x2a, 0xf8, 0x1f, 0xfc, 0x02, 0x10, 0x12, 0x48, 0x67, 0xcc, + 0x10, 0x88, 0x44, 0x44, 0x32, 0x40, 0x01, 0x10, 0x51, 0x54, 0x01, 0x00, 0x22, 0x38, 0x20, 0x10, + 0x22, 0x4c, 0x04, 0x40, 0x01, 0x00, 0x1c, 0x88, 0x10, 0x00, 0x00, 0x10, 0x7a, 0x48, 0x18, 0x30, + 0x11, 0x08, 0x04, 0x40, 0x12, 0x40, 0x01, 0x10, 0x7d, 0xfc, 0x01, 0x00, 0x42, 0x40, 0x3f, 0xf0, + 0x3e, 0x40, 0x04, 0x40, 0x01, 0x00, 0x08, 0xf8, 0x10, 0x00, 0x17, 0xfc, 0x12, 0x48, 0x04, 0x40, + 0x12, 0x08, 0x04, 0x40, 0x11, 0xfc, 0x17, 0xfc, 0x50, 0x80, 0x3f, 0xf8, 0x07, 0xbc, 0x04, 0x00, + 0x22, 0x40, 0x3f, 0xf8, 0x01, 0x00, 0x7e, 0x88, 0x1f, 0x80, 0x10, 0x10, 0x13, 0xf8, 0x02, 0x80, + 0x10, 0x08, 0x04, 0x40, 0x09, 0x00, 0x11, 0x10, 0x50, 0x80, 0x01, 0x00, 0x12, 0x20, 0x02, 0x00, + 0x3e, 0x40, 0x00, 0x00, 0x01, 0x00, 0x08, 0xf8, 0x00, 0x78, 0x20, 0x10, 0x10, 0x00, 0x01, 0x00, + 0x10, 0x08, 0x3f, 0xf8, 0x09, 0x00, 0x21, 0x10, 0x10, 0x80, 0x01, 0x00, 0x22, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xfc, + 0x07, 0xf0, 0x20, 0x30, 0x64, 0x3c, 0x04, 0x30, 0x20, 0xe0, 0x60, 0x0c, 0x40, 0x1c, 0x11, 0xfc, + 0x42, 0x10, 0x7f, 0xfc, 0x02, 0x18, 0x01, 0xfc, 0x17, 0xfc, 0x07, 0x00, 0x7f, 0xfc, 0x10, 0x20, + 0x44, 0x10, 0x20, 0x90, 0x5a, 0x24, 0x04, 0x10, 0x10, 0x10, 0x10, 0x10, 0x40, 0x04, 0x12, 0x04, + 0x21, 0x10, 0x01, 0x00, 0x01, 0x04, 0x02, 0x04, 0x10, 0x40, 0x01, 0x00, 0x01, 0x00, 0x10, 0x20, + 0x27, 0xf0, 0x21, 0x10, 0x51, 0x20, 0x04, 0x10, 0x08, 0x10, 0x08, 0x20, 0x40, 0x04, 0x12, 0x04, + 0x25, 0x10, 0x01, 0x00, 0x02, 0x84, 0x62, 0x04, 0x10, 0x40, 0x01, 0x00, 0x01, 0x00, 0x10, 0x90, + 0x14, 0x10, 0x20, 0x10, 0x51, 0x20, 0x07, 0xf0, 0x04, 0x10, 0x04, 0x40, 0x47, 0xc4, 0x12, 0x40, + 0x00, 0x90, 0x01, 0x00, 0x7e, 0x84, 0x1a, 0x40, 0x10, 0x40, 0x01, 0x00, 0x3f, 0xf8, 0x10, 0x90, + 0x0f, 0xf0, 0x27, 0xfc, 0x54, 0xa4, 0x44, 0x10, 0x04, 0x10, 0x04, 0x40, 0x44, 0x44, 0x12, 0x58, + 0x7e, 0x90, 0x01, 0x00, 0x22, 0x44, 0x12, 0x58, 0x10, 0x40, 0x01, 0x00, 0x01, 0x00, 0x70, 0x90, + 0x04, 0x10, 0x20, 0x10, 0x5a, 0xa8, 0x27, 0xf0, 0x02, 0x10, 0x02, 0x80, 0x44, 0x44, 0x12, 0x48, + 0x24, 0x90, 0x01, 0x00, 0x24, 0x44, 0x12, 0x48, 0x13, 0xf8, 0x7f, 0xfc, 0x01, 0x00, 0x19, 0x08, + 0x7f, 0xfc, 0x63, 0xf8, 0x11, 0xb0, 0x14, 0x10, 0x03, 0xf0, 0x02, 0x80, 0x44, 0x44, 0x16, 0x48, + 0x3c, 0x90, 0x01, 0x00, 0x10, 0x44, 0x12, 0x48, 0x10, 0x40, 0x01, 0x00, 0x1f, 0xf0, 0x11, 0x08, + 0x01, 0x00, 0x20, 0x00, 0x10, 0xa0, 0x0f, 0xf0, 0x02, 0x00, 0x01, 0x00, 0x47, 0xc4, 0x53, 0x48, + 0x24, 0x90, 0x01, 0xf8, 0x10, 0x44, 0x17, 0x48, 0x50, 0x40, 0x01, 0x00, 0x11, 0x10, 0x10, 0x08, + 0x1f, 0xf0, 0x11, 0xf8, 0x78, 0xa0, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x40, 0x04, 0x32, 0xc8, + 0x3c, 0xfc, 0x01, 0x00, 0x7e, 0x44, 0x12, 0xe8, 0x30, 0x40, 0x3f, 0xf8, 0x11, 0x10, 0x78, 0x00, + 0x01, 0x00, 0x11, 0x08, 0x49, 0xa8, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x40, 0x04, 0x12, 0x68, + 0x24, 0x80, 0x01, 0x00, 0x00, 0x44, 0x7a, 0x58, 0x17, 0xfc, 0x01, 0x00, 0x1f, 0xf0, 0x13, 0xfc, + 0x3f, 0xf8, 0x41, 0xf8, 0x4a, 0xa4, 0x7f, 0xfc, 0x7f, 0xfc, 0x01, 0x00, 0x7f, 0xfc, 0x12, 0x58, + 0x7e, 0x80, 0x01, 0x00, 0x01, 0xfc, 0x12, 0x40, 0x10, 0x00, 0x01, 0x00, 0x11, 0x10, 0x10, 0x40, + 0x04, 0x40, 0x21, 0x08, 0x48, 0xa0, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x0a, 0x40, + 0x24, 0xe0, 0x01, 0x00, 0x00, 0x40, 0x12, 0x40, 0x08, 0x40, 0x1f, 0x80, 0x11, 0x10, 0x10, 0x40, + 0x08, 0x20, 0x11, 0xf8, 0x78, 0xa0, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0x40, + 0x24, 0x18, 0x01, 0x00, 0x3c, 0x40, 0x10, 0x40, 0x08, 0x80, 0x00, 0x70, 0x1f, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0xfc, + 0x47, 0xfc, 0x00, 0x00, 0x41, 0xfc, 0x01, 0xfc, 0x3e, 0x08, 0x19, 0x1c, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x70, 0x10, 0x30, 0x26, 0x3c, 0x40, 0x04, 0x01, 0x00, 0x78, 0x18, 0x40, 0xe0, 0x2d, 0x00, + 0x28, 0x00, 0x21, 0x08, 0x26, 0x00, 0x02, 0x04, 0x09, 0xe8, 0x08, 0x94, 0x61, 0x0c, 0x01, 0x00, + 0x00, 0x10, 0x10, 0x10, 0x22, 0x44, 0x20, 0x08, 0x11, 0x30, 0x0f, 0x08, 0x24, 0x20, 0x11, 0x00, + 0x12, 0x08, 0x00, 0x00, 0x18, 0x00, 0x42, 0x04, 0x04, 0x10, 0x4a, 0x90, 0x11, 0x10, 0x01, 0x00, + 0x00, 0x10, 0x10, 0x90, 0x22, 0x40, 0x10, 0x10, 0x11, 0x10, 0x08, 0x08, 0x18, 0x20, 0x11, 0xf0, + 0x11, 0x10, 0x00, 0x00, 0x14, 0x00, 0x4a, 0x00, 0x04, 0x20, 0x2a, 0x50, 0x09, 0x20, 0x01, 0x00, + 0x1f, 0x10, 0x11, 0x10, 0x3e, 0x70, 0x08, 0x20, 0x11, 0x10, 0x08, 0x08, 0x10, 0x20, 0x11, 0x00, + 0x10, 0xa0, 0x00, 0x00, 0x03, 0x00, 0x7a, 0x00, 0x02, 0x00, 0x2a, 0x50, 0x05, 0x40, 0x01, 0x00, + 0x11, 0x10, 0x70, 0x10, 0x22, 0x4c, 0x04, 0x40, 0x5f, 0xf4, 0x7f, 0x48, 0x68, 0x20, 0x01, 0x00, + 0x10, 0x40, 0x00, 0x00, 0x00, 0x80, 0x4a, 0x08, 0x02, 0x00, 0x08, 0x50, 0x03, 0x80, 0x01, 0x00, + 0x11, 0x10, 0x1d, 0xfc, 0x3e, 0x40, 0x04, 0x40, 0x41, 0x04, 0x08, 0x48, 0x48, 0x20, 0x7f, 0xfc, + 0x10, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x4b, 0xf8, 0x7f, 0xfc, 0x3e, 0x30, 0x7f, 0xfc, 0x01, 0x00, + 0x11, 0x10, 0x10, 0x10, 0x22, 0x00, 0x02, 0x80, 0x7f, 0xfc, 0x00, 0x48, 0x45, 0xfc, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x00, 0x20, 0x4a, 0x48, 0x01, 0x00, 0x22, 0x20, 0x01, 0x00, 0x61, 0x0c, + 0x11, 0x10, 0x50, 0x10, 0x3e, 0x3c, 0x02, 0x80, 0x04, 0x40, 0x79, 0x48, 0x24, 0x20, 0x0f, 0xe0, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x4a, 0x48, 0x01, 0x00, 0x22, 0x20, 0x09, 0x20, 0x11, 0x10, + 0x1f, 0x10, 0x53, 0xfc, 0x00, 0x44, 0x01, 0x00, 0x3f, 0xf8, 0x26, 0x48, 0x24, 0x20, 0x08, 0x20, + 0x00, 0x10, 0x00, 0x00, 0x3f, 0xf0, 0x4a, 0x48, 0x01, 0x00, 0x3e, 0xfc, 0x11, 0x10, 0x08, 0x20, + 0x00, 0x10, 0x7c, 0x20, 0x7d, 0x40, 0x7f, 0xfc, 0x01, 0x00, 0x10, 0x48, 0x24, 0x10, 0x0f, 0xe0, + 0x17, 0xfc, 0x00, 0x00, 0x01, 0x00, 0x7a, 0x48, 0x3f, 0xf8, 0x00, 0x20, 0x01, 0x00, 0x04, 0x40, + 0x00, 0x10, 0x50, 0x20, 0x22, 0x70, 0x01, 0x00, 0x04, 0x40, 0x10, 0x48, 0x7c, 0x08, 0x08, 0x20, + 0x10, 0x40, 0x00, 0x00, 0x01, 0x00, 0x03, 0xf8, 0x01, 0x00, 0x7f, 0x24, 0x3f, 0xf8, 0x02, 0x80, + 0x7f, 0xfc, 0x51, 0xf8, 0x14, 0x4c, 0x01, 0x00, 0x7f, 0xfc, 0x7f, 0x48, 0x11, 0xf8, 0x0f, 0xe0, + 0x20, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x28, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x10, 0x20, 0x10, 0x40, 0x01, 0x00, 0x04, 0x40, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, + 0x40, 0x00, 0x30, 0x00, 0x19, 0x0c, 0x11, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x33, 0x04, 0x17, 0xfc, 0x01, 0x00, 0x08, 0x7c, 0x4c, 0x40, 0x12, 0x1c, 0x00, 0x00, 0x00, 0x04, + 0x20, 0x00, 0x48, 0x00, 0x08, 0x94, 0x10, 0x40, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x10, 0x98, 0x10, 0x40, 0x01, 0x00, 0x15, 0xa0, 0x22, 0x40, 0x12, 0x04, 0x03, 0x00, 0x7c, 0x04, + 0x60, 0x00, 0x48, 0x00, 0x08, 0x60, 0x14, 0x44, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x10, 0x60, 0x10, 0x40, 0x01, 0x00, 0x1a, 0x20, 0x22, 0x58, 0x12, 0x04, 0x03, 0x00, 0x44, 0x04, + 0x60, 0x00, 0x30, 0x00, 0x08, 0x20, 0x12, 0x4c, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x11, 0x90, 0x10, 0x40, 0x01, 0x00, 0x15, 0x7c, 0x12, 0x44, 0x12, 0x04, 0x00, 0x00, 0x44, 0x44, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x50, 0x12, 0x48, 0x01, 0x00, 0x00, 0x00, 0x61, 0x04, 0x00, 0x00, + 0x11, 0x10, 0x50, 0x40, 0x01, 0x00, 0x11, 0x20, 0x12, 0x44, 0x12, 0x04, 0x00, 0x00, 0x44, 0x44, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x48, 0x52, 0x48, 0x01, 0x00, 0x02, 0x00, 0x11, 0x08, 0x00, 0x00, + 0x70, 0x88, 0x33, 0xf8, 0x01, 0x00, 0x79, 0x78, 0x7e, 0x44, 0x12, 0x04, 0x02, 0x00, 0x7c, 0x84, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x48, 0x73, 0x50, 0x01, 0x00, 0x02, 0x00, 0x09, 0x10, 0x7f, 0xfc, + 0x18, 0x88, 0x10, 0x40, 0x01, 0x10, 0x11, 0x20, 0x12, 0x44, 0x12, 0x04, 0x02, 0x00, 0x44, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x34, 0x48, 0x01, 0x00, 0x02, 0x00, 0x05, 0x60, 0x00, 0x08, + 0x13, 0xfc, 0x08, 0x40, 0x01, 0x60, 0x13, 0x78, 0x12, 0x48, 0x12, 0x04, 0x01, 0x00, 0x46, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x34, 0x48, 0x00, 0x80, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x10, 0x40, 0x08, 0x40, 0x01, 0x80, 0x3a, 0x28, 0x7e, 0x48, 0x52, 0x04, 0x00, 0x80, 0x45, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x12, 0x4c, 0x00, 0x40, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x78, 0x40, 0x04, 0x00, 0x01, 0x00, 0x41, 0xfc, 0x12, 0x44, 0x32, 0x04, 0x10, 0x80, 0x7d, 0xfc, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x13, 0xfc, 0x00, 0x20, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x12, 0x04, 0x7f, 0xfc, 0x01, 0x00, 0x21, 0x28, 0x12, 0x44, 0x12, 0x04, 0x10, 0x80, 0x20, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x48, 0x19, 0x00, 0x3f, 0xf0, 0x02, 0x00, 0x7f, 0xfc, 0x00, 0x00, + 0x13, 0xfc, 0x02, 0x00, 0x7f, 0xfc, 0x1b, 0x78, 0x7e, 0x7c, 0x10, 0x7c, 0x0f, 0x00, 0x10, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x50, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x40, 0x02, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +#endif diff --git a/src/lang/glyph_gr.bmp b/src/lang/glyph_gr.bmp new file mode 100644 index 00000000..89d3240e Binary files /dev/null and b/src/lang/glyph_gr.bmp differ diff --git a/src/lang/glyph_gr.h b/src/lang/glyph_gr.h new file mode 100644 index 00000000..8e6a2f67 --- /dev/null +++ b/src/lang/glyph_gr.h @@ -0,0 +1,140 @@ +#ifndef __GLYPH_GR__ +#define __GLYPH_GR__ + +static unsigned int size_GLYPH_GR = 2110; +static unsigned char GLYPH_GR[] = { + 0x42, 0x4d, 0x3e, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, + 0x1f, 0x80, 0x18, 0x00, 0xe1, 0xc0, 0x60, 0x00, 0x7f, 0x00, 0x60, 0x00, 0x61, 0x80, 0xff, 0x00, + 0x7f, 0x80, 0x7f, 0xe0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0xc0, + 0x31, 0xc0, 0x18, 0x00, 0x61, 0xc0, 0x60, 0x00, 0x63, 0x80, 0x60, 0x00, 0x61, 0x80, 0x60, 0x00, + 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xe0, + 0x70, 0xe0, 0x18, 0x00, 0x61, 0x80, 0x60, 0x00, 0x61, 0x80, 0x60, 0x00, 0x61, 0x80, 0x70, 0x00, + 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, + 0x60, 0x60, 0x18, 0x00, 0x7f, 0x80, 0x60, 0x00, 0x61, 0x80, 0x60, 0x00, 0x61, 0x80, 0x38, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, + 0x60, 0x60, 0x18, 0x00, 0x33, 0x00, 0x7c, 0x00, 0x63, 0x80, 0x60, 0x00, 0x61, 0x80, 0x18, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xe0, + 0x60, 0x60, 0x3c, 0x00, 0x33, 0x00, 0x67, 0x00, 0x7e, 0x00, 0x60, 0x00, 0x7f, 0x80, 0x1c, 0x00, + 0x3f, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, + 0x60, 0x60, 0x3c, 0x00, 0x1f, 0x00, 0x63, 0x00, 0x63, 0x00, 0x60, 0x00, 0x61, 0x80, 0x0c, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xe0, + 0x70, 0xe0, 0x7e, 0x00, 0x1e, 0x00, 0x63, 0x00, 0x63, 0x00, 0x60, 0x00, 0x61, 0x80, 0x06, 0x00, + 0x00, 0x00, 0x70, 0xe0, 0x00, 0x00, 0x70, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xc1, + 0xb8, 0xc0, 0x66, 0x00, 0xde, 0x00, 0x67, 0x00, 0x63, 0x00, 0x60, 0x03, 0x61, 0x80, 0x07, 0x00, + 0x00, 0x00, 0x38, 0xc0, 0x60, 0x01, 0xb8, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, + 0xdf, 0x80, 0xe7, 0x00, 0x6e, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x01, 0xe1, 0x80, 0x7f, 0x00, + 0x7f, 0x80, 0x1f, 0x80, 0x30, 0x00, 0xdf, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7e, 0x00, + 0x7f, 0x00, 0x7f, 0x00, 0x63, 0x18, 0x3c, 0x00, 0x7f, 0x80, 0x61, 0xc0, 0x1f, 0x80, 0x61, 0x80, + 0x63, 0x80, 0x3c, 0x00, 0xe1, 0xc0, 0x1f, 0x80, 0x7f, 0x00, 0x1f, 0x80, 0x60, 0x00, 0x63, 0x80, + 0x60, 0x00, 0x70, 0x00, 0x67, 0x98, 0x70, 0x00, 0x61, 0x80, 0x61, 0xc0, 0x31, 0xc0, 0x61, 0x80, + 0x73, 0x00, 0x70, 0x00, 0x61, 0x80, 0x76, 0xc0, 0x60, 0x00, 0x76, 0xe0, 0x60, 0x00, 0x61, 0x80, + 0x60, 0x00, 0x38, 0x00, 0x67, 0x98, 0x60, 0x00, 0x61, 0x80, 0x63, 0xc0, 0x70, 0xe0, 0x61, 0x80, + 0x37, 0x00, 0x60, 0x00, 0x61, 0x80, 0x66, 0x60, 0x60, 0x00, 0x66, 0x60, 0x60, 0x00, 0x61, 0x80, + 0x60, 0x00, 0x18, 0x00, 0x6f, 0xd8, 0x60, 0x00, 0x61, 0x80, 0x67, 0xc0, 0x60, 0x60, 0x61, 0x80, + 0x3e, 0x00, 0x60, 0x00, 0x33, 0x00, 0x66, 0x60, 0x60, 0x00, 0xc6, 0x30, 0x60, 0x00, 0x63, 0x80, + 0x60, 0x00, 0x1c, 0x00, 0x6c, 0xd8, 0x30, 0x00, 0x33, 0x00, 0x66, 0xc0, 0x60, 0x60, 0x61, 0x80, + 0x1c, 0x00, 0x60, 0x00, 0x33, 0x00, 0x66, 0x60, 0x60, 0x00, 0xc6, 0x30, 0x60, 0x00, 0x7e, 0x00, + 0x7e, 0x00, 0x0c, 0x00, 0x7c, 0xd8, 0x3c, 0x00, 0x33, 0x00, 0x6e, 0xc0, 0x60, 0x60, 0x7f, 0x80, + 0x1c, 0x00, 0x30, 0x00, 0x33, 0x00, 0x66, 0x60, 0x7e, 0x00, 0xc6, 0x30, 0x60, 0x00, 0x66, 0x00, + 0x60, 0x00, 0x1c, 0x00, 0x78, 0x78, 0x70, 0x00, 0x3f, 0x00, 0x7c, 0xc0, 0x60, 0x60, 0x61, 0x80, + 0x3e, 0x00, 0x30, 0x00, 0x1e, 0x00, 0x66, 0x60, 0x60, 0x00, 0xc6, 0x30, 0x60, 0x00, 0x63, 0x00, + 0x60, 0x00, 0x38, 0x00, 0x78, 0x78, 0x60, 0x00, 0x1e, 0x00, 0x78, 0xc0, 0x70, 0xe0, 0x61, 0x80, + 0x36, 0x00, 0x18, 0x00, 0x1e, 0x00, 0x06, 0x00, 0x60, 0x00, 0x66, 0x70, 0x60, 0x00, 0x63, 0x00, + 0x60, 0x00, 0x70, 0x00, 0x78, 0x38, 0x60, 0x00, 0x1e, 0x00, 0x78, 0xc0, 0x38, 0xc0, 0x61, 0x80, + 0x73, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x06, 0x01, 0xe0, 0x00, 0x76, 0xe0, 0x60, 0x00, 0x73, 0x00, + 0x7f, 0x00, 0x7f, 0x00, 0x70, 0x38, 0x70, 0x00, 0x0e, 0x00, 0x70, 0xc0, 0x1f, 0x80, 0x61, 0x80, + 0x63, 0x80, 0x7e, 0x00, 0x0c, 0x00, 0x06, 0x00, 0xff, 0x00, 0x1f, 0x80, 0x60, 0x00, 0x3e, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0xc0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0xc7, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x6e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, + 0x3f, 0x00, 0x3e, 0x00, 0x30, 0x00, 0x3e, 0x00, 0x3f, 0xc0, 0x63, 0x00, 0x3c, 0x00, 0x1e, 0x00, + 0x3f, 0xc0, 0x3e, 0x00, 0x61, 0x80, 0x1f, 0x80, 0x18, 0x00, 0xe1, 0xc0, 0x63, 0x00, 0x60, 0x00, + 0x60, 0x00, 0x77, 0x00, 0x38, 0x00, 0x73, 0x00, 0x76, 0xe0, 0x63, 0x00, 0x3c, 0x00, 0x33, 0x00, + 0x76, 0xe0, 0x66, 0x00, 0x61, 0x80, 0x36, 0xc0, 0x18, 0x00, 0x61, 0xc0, 0x66, 0x00, 0x60, 0x00, + 0x60, 0x00, 0x63, 0x00, 0x7c, 0x00, 0x61, 0x80, 0x66, 0x60, 0x63, 0x00, 0x1c, 0x00, 0x61, 0x80, + 0x66, 0x60, 0x63, 0x00, 0x61, 0x80, 0x66, 0x60, 0x18, 0x00, 0x61, 0x80, 0x6e, 0x00, 0x60, 0x00, + 0x3e, 0x00, 0x63, 0x00, 0x6c, 0x00, 0x61, 0x80, 0x66, 0x60, 0x63, 0x00, 0x3c, 0x00, 0x61, 0x80, + 0x66, 0x60, 0x63, 0x00, 0x61, 0x80, 0x66, 0x60, 0x18, 0x00, 0x7f, 0x80, 0x7c, 0x00, 0x60, 0x00, + 0x60, 0x00, 0x63, 0x00, 0x66, 0x00, 0x61, 0x80, 0x66, 0x60, 0x63, 0x00, 0x36, 0x00, 0x61, 0x80, + 0x66, 0x60, 0x63, 0x00, 0x61, 0x80, 0x66, 0x60, 0x18, 0x00, 0x33, 0x00, 0x78, 0x00, 0x60, 0x00, + 0x60, 0x00, 0x77, 0x00, 0xc6, 0x00, 0x37, 0x00, 0x60, 0x60, 0x73, 0x00, 0x76, 0x00, 0x7f, 0x80, + 0x60, 0x60, 0x63, 0x00, 0x61, 0x80, 0x36, 0xc0, 0x18, 0x00, 0x33, 0x00, 0x78, 0x00, 0x60, 0x00, + 0x3f, 0x00, 0x3e, 0x00, 0xc6, 0x00, 0x1e, 0x00, 0x30, 0xc0, 0x7e, 0x00, 0xe3, 0x00, 0x61, 0x80, + 0x30, 0xc0, 0x63, 0x00, 0x61, 0x80, 0x1f, 0x80, 0x18, 0x00, 0x1f, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x61, 0x80, 0x06, 0x00, 0x18, 0x00, 0x1e, 0x00, 0x6c, 0x00, 0x60, 0x00, + 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x61, 0x80, + 0x06, 0x00, 0x18, 0x00, 0x61, 0x80, 0x06, 0x00, 0x18, 0x00, 0x1e, 0x00, 0x66, 0x00, 0x30, 0x00, + 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x33, 0x00, + 0x03, 0x00, 0x0c, 0x00, 0x7f, 0x80, 0x06, 0x00, 0xff, 0x00, 0x0e, 0x00, 0x67, 0x00, 0x30, 0x00, + 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, + 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, + 0x1c, 0x00, 0x3e, 0x00, 0x78, 0x00, 0x3f, 0x00, 0x18, 0x00, 0x7e, 0x00, 0xc7, 0x80, 0x3e, 0x00, + 0x7f, 0x80, 0x3f, 0xc0, 0x63, 0x00, 0x1c, 0x00, 0x63, 0x00, 0xc7, 0x00, 0x3e, 0x00, 0x77, 0x00, + 0x30, 0x00, 0x77, 0x00, 0x60, 0x00, 0x60, 0x00, 0x3c, 0x00, 0x63, 0x80, 0xe6, 0x00, 0x77, 0x00, + 0x6e, 0x00, 0x77, 0x00, 0x6e, 0x00, 0x70, 0x00, 0x63, 0x00, 0xc6, 0x00, 0x66, 0x00, 0x63, 0x00, + 0x30, 0x00, 0x63, 0x00, 0x60, 0x00, 0x60, 0x00, 0x3c, 0x00, 0x61, 0x80, 0x66, 0x00, 0x63, 0x00, + 0x66, 0x00, 0x63, 0x00, 0x7c, 0x00, 0x60, 0x00, 0x63, 0x00, 0x66, 0x00, 0x63, 0x00, 0x63, 0x00, + 0x30, 0x00, 0x63, 0x00, 0x60, 0x00, 0x3e, 0x00, 0x36, 0x00, 0x61, 0x80, 0x66, 0x00, 0x63, 0x00, + 0x66, 0x00, 0x63, 0x00, 0x70, 0x00, 0x60, 0x00, 0x63, 0x00, 0x6c, 0x00, 0x63, 0x00, 0x63, 0x00, + 0x30, 0x00, 0x63, 0x00, 0x60, 0x00, 0x60, 0x00, 0x66, 0x00, 0x61, 0x80, 0x66, 0x00, 0x63, 0x00, + 0x66, 0x00, 0x63, 0x00, 0x78, 0x00, 0x60, 0x00, 0x63, 0x00, 0x7c, 0x00, 0x63, 0x00, 0x77, 0x80, + 0x30, 0x00, 0x77, 0x00, 0x60, 0x00, 0x60, 0x00, 0x66, 0x00, 0x73, 0x80, 0x66, 0x00, 0x76, 0x00, + 0x66, 0x00, 0x77, 0x80, 0x6e, 0x00, 0x76, 0x00, 0x73, 0x00, 0x38, 0x00, 0x63, 0x00, 0x3d, 0x80, + 0xfe, 0x00, 0x3e, 0x00, 0x60, 0x00, 0x3f, 0x00, 0x66, 0x00, 0x3f, 0x00, 0xff, 0x80, 0x3f, 0x80, + 0x66, 0x00, 0x3d, 0x80, 0x63, 0x00, 0x3e, 0x00, 0x7e, 0x00, 0x38, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +#endif diff --git a/src/lang/glyph_ja.bmp b/src/lang/glyph_ja.bmp new file mode 100644 index 00000000..775762c9 Binary files /dev/null and b/src/lang/glyph_ja.bmp differ diff --git a/src/lang/glyph_ja.h b/src/lang/glyph_ja.h new file mode 100644 index 00000000..f9754c2c --- /dev/null +++ b/src/lang/glyph_ja.h @@ -0,0 +1,940 @@ +#ifndef __GLYPH_JA__ +#define __GLYPH_JA__ + +static unsigned int size_GLYPH_JA = 14910; +static unsigned char GLYPH_JA[] = { + 0x42, 0x4d, 0x3e, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x10, 0x8c, 0x0c, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x00, 0x80, 0x10, 0x84, 0x42, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x20, + 0x00, 0x40, 0x14, 0x84, 0x22, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x10, + 0x00, 0x20, 0x12, 0x94, 0x22, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x08, + 0x00, 0x20, 0x12, 0x94, 0x12, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x88, + 0x00, 0x10, 0x52, 0x94, 0x12, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x88, + 0x0f, 0xf0, 0x32, 0xa4, 0x12, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x50, + 0x00, 0x00, 0x12, 0xa4, 0x13, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, + 0x60, 0x03, 0x08, 0xc4, 0x12, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, + 0x13, 0xe4, 0x08, 0x84, 0x1f, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, + 0x08, 0x08, 0x47, 0xff, 0x10, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, + 0x04, 0x10, 0x24, 0x80, 0x10, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x02, 0x20, 0x14, 0xa0, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x10, 0xa0, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x08, 0xde, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x08, 0x80, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x07, + 0x04, 0x06, 0x43, 0x86, 0x03, 0x83, 0x00, 0x00, 0x00, 0x78, 0x00, 0xf8, 0x60, 0x01, 0x01, 0x01, + 0x40, 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x80, 0x08, 0x00, 0x42, 0x18, 0x60, 0x1e, 0x0c, 0x18, + 0x04, 0x02, 0x21, 0x42, 0x00, 0xe4, 0x00, 0x00, 0x10, 0x80, 0x41, 0x09, 0x18, 0x03, 0x1f, 0x82, + 0x20, 0x04, 0x0c, 0x00, 0x41, 0x08, 0x00, 0x80, 0x48, 0x3f, 0x22, 0x08, 0x10, 0x22, 0x02, 0x20, + 0x04, 0x02, 0x21, 0x42, 0x06, 0x88, 0x00, 0x00, 0x08, 0x80, 0x22, 0x09, 0x04, 0x25, 0x11, 0x44, + 0x10, 0x08, 0x03, 0x00, 0x22, 0x09, 0x00, 0x80, 0x2a, 0x41, 0x12, 0x08, 0x08, 0x42, 0x01, 0x40, + 0x44, 0x02, 0x11, 0x22, 0x61, 0x90, 0x01, 0xc0, 0x06, 0x80, 0x12, 0x02, 0x02, 0x45, 0x11, 0x24, + 0x08, 0x10, 0x00, 0x80, 0x12, 0x21, 0x00, 0x80, 0x2a, 0x81, 0x12, 0x08, 0x04, 0x42, 0x00, 0x80, + 0x24, 0xa2, 0x1f, 0x3e, 0x18, 0xa8, 0x00, 0x30, 0x01, 0x00, 0x12, 0x24, 0x01, 0x88, 0x11, 0x28, + 0x08, 0x10, 0x00, 0x40, 0x12, 0x22, 0x00, 0x80, 0x2a, 0x80, 0x6b, 0x88, 0x02, 0x40, 0x00, 0x80, + 0x14, 0xa2, 0x11, 0x22, 0x14, 0x44, 0x00, 0x08, 0x00, 0x80, 0x00, 0x20, 0x02, 0x88, 0x5f, 0x28, + 0x04, 0x20, 0x00, 0x20, 0x12, 0x44, 0x00, 0x80, 0x2c, 0x80, 0x3a, 0xff, 0x02, 0x40, 0x01, 0x40, + 0x15, 0x22, 0x11, 0x22, 0x13, 0xff, 0x00, 0x04, 0x00, 0x40, 0x60, 0x40, 0x0c, 0x48, 0x20, 0x90, + 0x04, 0x20, 0x00, 0x10, 0x00, 0x80, 0x00, 0x80, 0x08, 0xfe, 0x2a, 0x88, 0x02, 0x40, 0x02, 0x20, + 0x0e, 0x22, 0x1f, 0x3e, 0x10, 0x20, 0x00, 0x02, 0x0f, 0xe0, 0x18, 0x81, 0x00, 0x48, 0x11, 0x10, + 0x04, 0x20, 0x00, 0x10, 0x0f, 0xf8, 0x00, 0x80, 0x7d, 0x92, 0x2a, 0x84, 0x7f, 0xfe, 0x02, 0x20, + 0x0c, 0x22, 0x11, 0x22, 0x11, 0xfc, 0x00, 0x02, 0x00, 0x00, 0x05, 0x62, 0x1f, 0xf8, 0x0a, 0x10, + 0x00, 0x20, 0x04, 0x08, 0x10, 0x08, 0x00, 0x80, 0x12, 0x92, 0x2b, 0xbe, 0x00, 0x00, 0x04, 0x10, + 0x7f, 0xa2, 0x11, 0x22, 0x11, 0x54, 0x00, 0x02, 0x00, 0x60, 0x3e, 0x14, 0x40, 0x00, 0x0a, 0x98, + 0x43, 0xe2, 0x04, 0x08, 0x10, 0x08, 0x00, 0x80, 0x0c, 0x92, 0x3b, 0xc0, 0x00, 0x00, 0x04, 0x10, + 0x04, 0x22, 0x1f, 0x3e, 0x7f, 0x54, 0x78, 0x04, 0x01, 0x80, 0x12, 0x08, 0x20, 0x00, 0x24, 0x54, + 0x40, 0x02, 0x04, 0x04, 0x10, 0x00, 0x00, 0xc0, 0x09, 0xfe, 0x3b, 0xa1, 0x1f, 0xf8, 0x04, 0x10, + 0x04, 0x22, 0x00, 0x00, 0x11, 0xfc, 0x07, 0x18, 0x02, 0x00, 0x09, 0x14, 0x17, 0xf8, 0x15, 0x52, + 0x40, 0x02, 0x08, 0x04, 0x1f, 0xf0, 0x00, 0x20, 0x14, 0x90, 0x2a, 0xa9, 0x40, 0x02, 0x7f, 0xff, + 0x04, 0x22, 0x1f, 0xfe, 0x10, 0x20, 0x00, 0xe4, 0x00, 0x00, 0x09, 0x22, 0x10, 0x00, 0x11, 0x3f, + 0x7f, 0xfe, 0x10, 0x04, 0x00, 0x10, 0x00, 0x10, 0x72, 0x48, 0x2a, 0xa9, 0x40, 0x02, 0x00, 0x80, + 0x3c, 0x22, 0x10, 0x82, 0x13, 0xfe, 0x00, 0x05, 0x00, 0x00, 0x7f, 0xfe, 0x0f, 0xfe, 0x09, 0x20, + 0x01, 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x08, 0x0a, 0x48, 0x2a, 0xf2, 0x7f, 0xfe, 0x00, 0x80, + 0x03, 0x22, 0x10, 0x82, 0x10, 0x20, 0x00, 0x09, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x20, + 0x01, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x3f, 0xfc, 0x08, 0x3c, 0x33, 0x8c, 0x01, 0x00, 0x00, 0x80, + 0x00, 0x82, 0x00, 0x80, 0x00, 0x20, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0a, 0x20, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x08, 0x02, 0x01, 0x00, 0x01, 0x80, + 0x18, 0x20, 0x0a, 0x01, 0x00, 0xc0, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x09, 0x81, 0x00, 0x00, + 0x0d, 0x01, 0x10, 0x60, 0x42, 0x87, 0x50, 0x41, 0x60, 0x00, 0x25, 0x0c, 0x04, 0x06, 0x00, 0x80, + 0x0a, 0x22, 0x09, 0x02, 0x40, 0x40, 0x02, 0x04, 0x3f, 0xfe, 0x1f, 0x7c, 0x48, 0x42, 0x0f, 0xf8, + 0x04, 0x82, 0x10, 0x20, 0x23, 0x49, 0x4b, 0x22, 0x18, 0xfc, 0x3d, 0x54, 0x44, 0x02, 0x00, 0x80, + 0x09, 0x22, 0x08, 0x84, 0x20, 0x40, 0x01, 0x02, 0x00, 0x80, 0x11, 0x44, 0x28, 0x24, 0x08, 0x08, + 0x44, 0x44, 0x10, 0x20, 0x12, 0xa9, 0x24, 0x94, 0x05, 0x04, 0x25, 0x54, 0x24, 0x02, 0x00, 0x80, + 0x08, 0xa4, 0x48, 0x48, 0x20, 0x40, 0x0e, 0x82, 0x60, 0x83, 0x11, 0x44, 0x29, 0x7e, 0x08, 0x08, + 0x24, 0xa8, 0x10, 0x20, 0x0a, 0x28, 0x24, 0x94, 0x02, 0x04, 0x25, 0x54, 0x14, 0x82, 0x00, 0x80, + 0x08, 0xa8, 0x28, 0x28, 0x10, 0x50, 0x12, 0x42, 0x17, 0xf4, 0x7f, 0x7f, 0x1a, 0x42, 0x0f, 0xf8, + 0x15, 0x10, 0x10, 0x20, 0x0a, 0x28, 0x12, 0x88, 0x42, 0x04, 0x25, 0xfc, 0x14, 0x92, 0x00, 0x80, + 0x08, 0x21, 0x29, 0x30, 0x10, 0x48, 0x12, 0x42, 0x08, 0x88, 0x18, 0x0c, 0x1c, 0x42, 0x08, 0x08, + 0x15, 0x18, 0x57, 0xff, 0x1f, 0x7c, 0x13, 0x88, 0x23, 0x01, 0x3d, 0x54, 0x0d, 0x12, 0x00, 0x80, + 0x6b, 0xfa, 0x1a, 0x10, 0x10, 0x44, 0x10, 0x22, 0x04, 0x90, 0x06, 0x30, 0x28, 0x7e, 0x08, 0x08, + 0x0e, 0x28, 0x30, 0x20, 0x11, 0x44, 0x12, 0x18, 0x22, 0x81, 0x01, 0x54, 0x2e, 0x12, 0x7f, 0xff, + 0x18, 0x44, 0x1c, 0x10, 0x1f, 0xfe, 0x10, 0x22, 0x7f, 0xff, 0x01, 0x40, 0x3f, 0x42, 0x0f, 0xf8, + 0x0e, 0xa4, 0x10, 0x10, 0x11, 0x44, 0x0f, 0xd4, 0x12, 0x42, 0x3d, 0xfc, 0x25, 0x92, 0x00, 0x80, + 0x0c, 0x28, 0x09, 0xff, 0x10, 0x40, 0x10, 0x22, 0x04, 0x10, 0x7f, 0xff, 0x29, 0x42, 0x61, 0x00, + 0x25, 0x44, 0x18, 0x08, 0x1f, 0x7c, 0x21, 0x54, 0x12, 0x22, 0x00, 0x01, 0x24, 0x92, 0x00, 0x80, + 0x08, 0x30, 0x08, 0x10, 0x11, 0xa0, 0x70, 0x22, 0x07, 0xf0, 0x00, 0x80, 0x29, 0x7e, 0x1c, 0x9f, + 0x25, 0x44, 0x15, 0xfc, 0x00, 0x00, 0x27, 0xa4, 0x12, 0x24, 0x02, 0x02, 0x24, 0x92, 0x00, 0x40, + 0x09, 0xc8, 0x7f, 0x10, 0x10, 0x10, 0x1c, 0x22, 0x04, 0x10, 0x00, 0x80, 0x3f, 0x42, 0x13, 0x21, + 0x44, 0xa4, 0x04, 0x00, 0x7f, 0xff, 0x44, 0xa4, 0x02, 0x10, 0x3d, 0xfc, 0x3f, 0x92, 0x00, 0x20, + 0x08, 0x44, 0x08, 0x90, 0x17, 0xf8, 0x13, 0x22, 0x07, 0xf0, 0x1f, 0x7c, 0x08, 0x7e, 0x10, 0x21, + 0x04, 0x24, 0x02, 0x00, 0x0a, 0x28, 0x07, 0x94, 0x02, 0x10, 0x00, 0x88, 0x04, 0x12, 0x00, 0x10, + 0x04, 0x20, 0x08, 0xfe, 0x10, 0x00, 0x10, 0x22, 0x04, 0x10, 0x11, 0x44, 0x08, 0x20, 0x10, 0x20, + 0x7f, 0xbf, 0x7f, 0xff, 0x11, 0x44, 0x04, 0x9f, 0x02, 0x48, 0x7e, 0x50, 0x04, 0x12, 0x00, 0x08, + 0x03, 0xe0, 0x78, 0x50, 0x1f, 0xff, 0x10, 0x22, 0x3f, 0xfe, 0x11, 0x44, 0x7f, 0x10, 0x1f, 0xb8, + 0x04, 0x20, 0x01, 0x00, 0x3f, 0xfe, 0x17, 0x90, 0x00, 0x48, 0x00, 0x50, 0x7f, 0xd2, 0x1f, 0xf8, + 0x7e, 0x18, 0x0c, 0x50, 0x00, 0x40, 0x11, 0xfe, 0x04, 0x10, 0x1f, 0x7c, 0x08, 0xff, 0x10, 0x26, + 0x04, 0xa0, 0x01, 0x00, 0x04, 0x10, 0x12, 0x10, 0x00, 0x88, 0x3c, 0x20, 0x04, 0x12, 0x00, 0x00, + 0x00, 0x04, 0x02, 0x10, 0x00, 0x40, 0x10, 0x00, 0x04, 0x10, 0x00, 0x00, 0x08, 0x00, 0x10, 0x20, + 0x05, 0x20, 0x01, 0x00, 0x04, 0x10, 0x21, 0x10, 0x01, 0x00, 0x00, 0x20, 0x04, 0x02, 0x00, 0x20, + 0x08, 0x00, 0x40, 0xff, 0x00, 0x30, 0x40, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x00, 0x70, 0x3e, + 0x08, 0x30, 0x00, 0x00, 0x10, 0x02, 0x40, 0x0e, 0x00, 0x3f, 0x04, 0x0f, 0x32, 0x00, 0x60, 0xa0, + 0x08, 0x3e, 0x23, 0x00, 0x70, 0x10, 0x20, 0x80, 0x3c, 0x13, 0x3f, 0x04, 0x7f, 0xff, 0x0c, 0x42, + 0x08, 0x10, 0x00, 0x00, 0x17, 0xc2, 0x21, 0x12, 0x00, 0x41, 0x02, 0x11, 0x11, 0x0f, 0x38, 0xac, + 0x08, 0x42, 0x14, 0x00, 0x0f, 0x10, 0x10, 0x80, 0x25, 0xeb, 0x04, 0xf8, 0x02, 0x20, 0x02, 0x42, + 0x0b, 0x11, 0x00, 0x00, 0x11, 0x3e, 0x11, 0x12, 0x60, 0x81, 0x01, 0x11, 0x10, 0x91, 0x27, 0x32, + 0x08, 0x42, 0x0d, 0xfc, 0x08, 0x10, 0x11, 0x7e, 0x25, 0x2d, 0x02, 0x08, 0x04, 0x10, 0x0f, 0xf2, + 0x08, 0x92, 0x00, 0x00, 0x11, 0x04, 0x09, 0x12, 0x10, 0x80, 0x00, 0x90, 0x10, 0x91, 0x21, 0x22, + 0x48, 0x42, 0x09, 0x04, 0x08, 0x10, 0x09, 0x42, 0x25, 0x24, 0x02, 0x10, 0x0f, 0xf8, 0x08, 0x10, + 0x48, 0x74, 0x00, 0x00, 0x10, 0x84, 0x09, 0x10, 0x0c, 0x90, 0x00, 0x90, 0x10, 0x50, 0x22, 0x22, + 0x29, 0x40, 0x09, 0x04, 0x7f, 0x10, 0x0a, 0x42, 0x3d, 0xec, 0x01, 0x20, 0x08, 0x08, 0x0f, 0xf0, + 0x28, 0x58, 0x00, 0x06, 0x10, 0x88, 0x09, 0x10, 0x0a, 0x9c, 0x7c, 0x50, 0x16, 0x52, 0x24, 0x22, + 0x1a, 0x40, 0x09, 0x04, 0x08, 0x18, 0x04, 0x42, 0x01, 0x2a, 0x01, 0x00, 0x0f, 0xf8, 0x08, 0x10, + 0x28, 0x9c, 0x00, 0x18, 0x10, 0x50, 0x00, 0x00, 0x08, 0x92, 0x44, 0x50, 0x71, 0x54, 0x3f, 0x24, + 0x0c, 0x40, 0x09, 0xfc, 0x08, 0x14, 0x7f, 0xc2, 0x3d, 0xea, 0x7f, 0xff, 0x00, 0x00, 0x0f, 0xf0, + 0x1a, 0x12, 0x40, 0x20, 0x50, 0x40, 0x07, 0xf0, 0x08, 0x92, 0x44, 0x50, 0x1c, 0xd8, 0x21, 0x28, + 0x08, 0x40, 0x79, 0x00, 0x3f, 0x12, 0x04, 0x42, 0x00, 0x08, 0x00, 0x80, 0x7f, 0xff, 0x08, 0x10, + 0x1b, 0xff, 0x20, 0x40, 0x30, 0x40, 0x08, 0x00, 0x08, 0x92, 0x45, 0xfc, 0x10, 0x50, 0x21, 0x30, + 0x04, 0x40, 0x01, 0xf8, 0x29, 0xff, 0x44, 0x42, 0x03, 0xff, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xf0, + 0x1c, 0x10, 0x10, 0x80, 0x17, 0xff, 0x08, 0x00, 0x0b, 0x92, 0x45, 0x04, 0x10, 0x50, 0x3f, 0x28, + 0x04, 0x40, 0x01, 0x08, 0x29, 0x10, 0x24, 0x42, 0x3c, 0xa8, 0x00, 0x80, 0x1f, 0xfc, 0x04, 0x20, + 0x08, 0x10, 0x09, 0x00, 0x10, 0x00, 0x7f, 0xfe, 0x08, 0xf2, 0x45, 0x04, 0x11, 0x58, 0x21, 0x24, + 0x02, 0x40, 0x01, 0x08, 0x3f, 0x30, 0x24, 0x42, 0x00, 0xa8, 0x00, 0x80, 0x12, 0x24, 0x5f, 0xfa, + 0x09, 0xfc, 0x06, 0x00, 0x08, 0x00, 0x01, 0x00, 0x7e, 0x9e, 0x45, 0x04, 0x7d, 0x54, 0x21, 0x24, + 0x7e, 0x40, 0x11, 0x08, 0x29, 0x48, 0x1f, 0xfe, 0x7d, 0x2a, 0x1f, 0xfc, 0x1f, 0xfc, 0x44, 0x22, + 0x7e, 0x10, 0x00, 0x00, 0x08, 0x00, 0x04, 0x20, 0x08, 0x92, 0x45, 0x04, 0x11, 0x54, 0x3f, 0x24, + 0x08, 0x40, 0x11, 0xf8, 0x29, 0x04, 0x10, 0x00, 0x03, 0xfa, 0x00, 0x80, 0x12, 0x24, 0x7f, 0xfe, + 0x09, 0xfe, 0x00, 0x00, 0x05, 0xfc, 0x7f, 0xfe, 0x08, 0x90, 0x7d, 0x04, 0x12, 0x54, 0x08, 0x3c, + 0x08, 0x40, 0x20, 0x40, 0x3f, 0xfe, 0x10, 0x00, 0x3c, 0x8c, 0x00, 0x80, 0x1f, 0xfc, 0x01, 0x00, + 0x08, 0x48, 0x00, 0x00, 0x04, 0x00, 0x04, 0x20, 0x08, 0x90, 0x01, 0xfc, 0x10, 0x50, 0x08, 0x00, + 0x08, 0x40, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x88, 0x00, 0x80, 0x02, 0x20, 0x01, 0x00, + 0x08, 0x84, 0x00, 0x00, 0x04, 0x00, 0x04, 0x20, 0x08, 0x10, 0x00, 0x00, 0x10, 0x50, 0x08, 0x02, + 0x41, 0xff, 0x00, 0x10, 0x08, 0x00, 0x40, 0x00, 0x00, 0x00, 0x06, 0x02, 0x0a, 0x07, 0x18, 0x00, + 0x00, 0x18, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x40, 0xff, 0x00, 0x00, 0x48, 0x0c, + 0x26, 0x04, 0x3e, 0x10, 0x48, 0xfe, 0x41, 0xfc, 0x00, 0x00, 0x01, 0x86, 0x49, 0x09, 0x08, 0xfe, + 0x02, 0x08, 0x3e, 0x04, 0x7f, 0xff, 0x01, 0x80, 0x10, 0x20, 0x23, 0x00, 0x3e, 0xfe, 0x29, 0x70, + 0x2b, 0x18, 0x22, 0x10, 0x2a, 0x92, 0x21, 0x04, 0x7f, 0xff, 0x79, 0x6a, 0x2a, 0x89, 0x08, 0x82, + 0x04, 0x08, 0x05, 0xf8, 0x08, 0x80, 0x20, 0x80, 0x12, 0x21, 0x14, 0x00, 0x22, 0x82, 0x29, 0x00, + 0x10, 0xa0, 0x22, 0x10, 0x2a, 0x92, 0x21, 0x04, 0x00, 0x00, 0x49, 0x0a, 0x2a, 0x88, 0x08, 0x82, + 0x7f, 0xff, 0x04, 0x08, 0x08, 0x80, 0x10, 0x82, 0x11, 0x22, 0x0c, 0x01, 0x22, 0x82, 0x2a, 0x04, + 0x1f, 0xfe, 0x23, 0xff, 0x2a, 0x92, 0x11, 0x04, 0x00, 0x00, 0x49, 0x08, 0x2a, 0x48, 0x08, 0xfe, + 0x40, 0x08, 0x02, 0x10, 0x08, 0x80, 0x08, 0x82, 0x10, 0xa4, 0x0a, 0x02, 0x22, 0x82, 0x28, 0x38, + 0x11, 0x10, 0x3e, 0x10, 0x2c, 0x92, 0x11, 0x04, 0x00, 0x00, 0x49, 0x10, 0x2c, 0x48, 0x08, 0x82, + 0x21, 0xff, 0x02, 0x20, 0x08, 0x80, 0x08, 0x84, 0x70, 0x68, 0x09, 0x04, 0x3e, 0xfe, 0x09, 0x81, + 0x11, 0x10, 0x00, 0x10, 0x08, 0x92, 0x09, 0xfc, 0x00, 0x00, 0x49, 0x10, 0x08, 0x28, 0x78, 0x82, + 0x17, 0x04, 0x01, 0x40, 0x08, 0x80, 0x04, 0x84, 0x1f, 0xff, 0x08, 0x88, 0x00, 0x10, 0x7d, 0x42, + 0x17, 0xfc, 0x3e, 0x10, 0x7d, 0x92, 0x08, 0x02, 0x00, 0x00, 0x79, 0xff, 0x7d, 0x28, 0x0e, 0xfe, + 0x09, 0x04, 0x41, 0x01, 0x08, 0x80, 0x04, 0x88, 0x10, 0x20, 0x08, 0x50, 0x00, 0x10, 0x12, 0x24, + 0x71, 0x10, 0x00, 0xfe, 0x12, 0xfe, 0x27, 0xc2, 0x00, 0x00, 0x49, 0x10, 0x12, 0x2a, 0x08, 0x00, + 0x09, 0xfc, 0x21, 0x02, 0x08, 0xfc, 0x04, 0x90, 0x12, 0x20, 0x78, 0x50, 0x3e, 0x10, 0x0d, 0x18, + 0x03, 0xde, 0x00, 0x10, 0x0c, 0x92, 0x21, 0x3c, 0x00, 0x00, 0x49, 0x10, 0x0d, 0xe2, 0x08, 0x7f, + 0x09, 0x04, 0x11, 0x04, 0x08, 0x80, 0x00, 0x80, 0x11, 0x0e, 0x00, 0x20, 0x01, 0xff, 0x08, 0xa8, + 0x04, 0x62, 0x3e, 0x10, 0x08, 0x92, 0x41, 0x04, 0x00, 0x00, 0x79, 0xfc, 0x08, 0x9c, 0x08, 0x81, + 0x79, 0xfc, 0x08, 0x08, 0x00, 0x80, 0x00, 0x80, 0x10, 0x92, 0x00, 0x20, 0x3e, 0x10, 0x14, 0x48, + 0x04, 0x20, 0x00, 0x10, 0x14, 0x92, 0x00, 0x88, 0x00, 0x00, 0x49, 0x04, 0x14, 0x48, 0x7f, 0x81, + 0x01, 0x04, 0x08, 0x10, 0x00, 0x80, 0x3f, 0xfe, 0x7c, 0x90, 0x00, 0x20, 0x00, 0x10, 0x62, 0x44, + 0x17, 0xbc, 0x7f, 0xfe, 0x72, 0x92, 0x00, 0x90, 0x00, 0x00, 0x49, 0x04, 0x72, 0x20, 0x08, 0x80, + 0x11, 0xfc, 0x04, 0x10, 0x00, 0x80, 0x00, 0x89, 0x12, 0x52, 0x10, 0x20, 0x7f, 0x10, 0x12, 0x3c, + 0x10, 0x84, 0x00, 0x48, 0x0a, 0x92, 0x08, 0x40, 0x1f, 0xfc, 0x49, 0x04, 0x0b, 0xfe, 0x08, 0xf8, + 0x10, 0x40, 0x04, 0x20, 0x00, 0x80, 0x00, 0x89, 0x12, 0x52, 0x10, 0x20, 0x00, 0xf0, 0x08, 0x20, + 0x27, 0xbc, 0x3e, 0x44, 0x08, 0xfe, 0x08, 0x40, 0x00, 0x00, 0x79, 0xfc, 0x08, 0x20, 0x08, 0x86, + 0x27, 0xff, 0x04, 0x20, 0x3f, 0xfe, 0x00, 0x86, 0x13, 0xfe, 0x20, 0xe0, 0x3e, 0x18, 0x08, 0x20, + 0x00, 0x00, 0x00, 0x84, 0x08, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x08, 0x80, + 0x00, 0x88, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x30, 0x00, + 0x40, 0x04, 0x0b, 0x03, 0x21, 0x81, 0x00, 0x00, 0x00, 0x00, 0x38, 0x01, 0x02, 0x06, 0x00, 0x80, + 0x33, 0x02, 0x7f, 0xff, 0x01, 0x80, 0x08, 0x00, 0x00, 0x00, 0x48, 0x03, 0x08, 0x00, 0x11, 0xfc, + 0x22, 0x04, 0x08, 0xc4, 0x20, 0xc2, 0x7f, 0xff, 0x07, 0xf0, 0x14, 0x02, 0x3f, 0x02, 0x04, 0xb0, + 0x10, 0x84, 0x00, 0x80, 0x00, 0x80, 0x0f, 0xff, 0x3f, 0xff, 0x44, 0x04, 0x0f, 0xff, 0x11, 0x04, + 0x21, 0x04, 0x48, 0x28, 0x2e, 0xa2, 0x08, 0x80, 0x04, 0x10, 0x12, 0x04, 0x23, 0x02, 0x64, 0x88, + 0x14, 0x48, 0x1f, 0xfc, 0x00, 0x80, 0x08, 0x20, 0x27, 0xf0, 0x22, 0x08, 0x08, 0x20, 0x11, 0x04, + 0x10, 0x84, 0x2a, 0x10, 0x2a, 0x94, 0x08, 0xf8, 0x04, 0x10, 0x11, 0x08, 0x22, 0xba, 0x14, 0x8b, + 0x12, 0x30, 0x00, 0x80, 0x00, 0x80, 0x08, 0x90, 0x24, 0x10, 0x21, 0x10, 0x08, 0x20, 0x11, 0x04, + 0x10, 0x84, 0x1a, 0x28, 0x2a, 0x94, 0x00, 0x80, 0x07, 0xf0, 0x11, 0x08, 0x22, 0xaa, 0x0f, 0xfc, + 0x11, 0x10, 0x0f, 0xf8, 0x00, 0x80, 0x08, 0x90, 0x27, 0xf0, 0x10, 0xa0, 0x48, 0x20, 0x11, 0x04, + 0x10, 0x44, 0x1c, 0x48, 0x2e, 0x88, 0x1f, 0xfc, 0x04, 0x10, 0x70, 0x90, 0x3e, 0xaa, 0x04, 0x90, + 0x11, 0x28, 0x08, 0x88, 0x00, 0x80, 0x08, 0x88, 0x24, 0x10, 0x10, 0xa0, 0x28, 0x20, 0x71, 0xfc, + 0x10, 0x44, 0x08, 0x48, 0x24, 0x88, 0x04, 0x01, 0x04, 0x10, 0x1c, 0x90, 0x00, 0xba, 0x7f, 0xff, + 0x70, 0xa8, 0x0f, 0xf8, 0x7f, 0xff, 0x08, 0x88, 0x27, 0xf0, 0x08, 0x40, 0x18, 0x20, 0x1c, 0x00, + 0x1f, 0x44, 0x7f, 0xf8, 0x3f, 0x94, 0x64, 0xc2, 0x07, 0xf0, 0x10, 0xa0, 0x3e, 0x82, 0x01, 0x00, + 0x1c, 0xc4, 0x08, 0x88, 0x00, 0x80, 0x48, 0x88, 0x24, 0x10, 0x0f, 0xff, 0x0b, 0xfe, 0x14, 0x01, + 0x11, 0x44, 0x0a, 0x00, 0x24, 0x94, 0x15, 0x34, 0x00, 0x00, 0x10, 0xa0, 0x00, 0xfe, 0x07, 0xf8, + 0x10, 0x84, 0x0f, 0xf8, 0x00, 0xc0, 0x29, 0x04, 0x27, 0xf0, 0x00, 0x44, 0x0c, 0x20, 0x12, 0xfa, + 0x11, 0x44, 0x09, 0x06, 0x24, 0xd4, 0x0e, 0x08, 0x7f, 0xff, 0x10, 0xfe, 0x00, 0x92, 0x04, 0x08, + 0x10, 0xfc, 0x00, 0x00, 0x00, 0x20, 0x18, 0x04, 0x00, 0x80, 0x20, 0x44, 0x0c, 0x20, 0x11, 0x04, + 0x11, 0x7f, 0x62, 0x8a, 0x3f, 0xa4, 0x3f, 0x94, 0x02, 0x20, 0x10, 0x82, 0x3e, 0x92, 0x07, 0xf8, + 0x10, 0x40, 0x7f, 0xff, 0x0f, 0xf0, 0x18, 0x04, 0x7f, 0xff, 0x20, 0x44, 0x02, 0x20, 0x7c, 0x88, + 0x1f, 0x40, 0x14, 0x8a, 0x0a, 0x24, 0x25, 0x54, 0x02, 0x10, 0x7e, 0x82, 0x00, 0xfe, 0x04, 0x08, + 0x7c, 0x40, 0x08, 0x08, 0x40, 0x02, 0x0b, 0xfe, 0x00, 0x80, 0x40, 0x44, 0x02, 0x20, 0x10, 0x50, + 0x00, 0x40, 0x08, 0x88, 0x11, 0x1f, 0x3f, 0x64, 0x04, 0x10, 0x10, 0x82, 0x7f, 0x92, 0x07, 0xf8, + 0x13, 0xff, 0x0f, 0xf8, 0x40, 0x02, 0x08, 0x20, 0x3f, 0xfc, 0x07, 0xfc, 0x7f, 0xff, 0x10, 0x50, + 0x00, 0x70, 0x14, 0x88, 0x7f, 0xd0, 0x04, 0x3f, 0x3f, 0xfe, 0x10, 0x82, 0x00, 0x92, 0x02, 0x10, + 0x10, 0x40, 0x08, 0x08, 0x7f, 0xfe, 0x04, 0x20, 0x22, 0x44, 0x08, 0x40, 0x01, 0x00, 0x10, 0x20, + 0x3f, 0x8c, 0x22, 0xf8, 0x04, 0x10, 0x7f, 0xa0, 0x00, 0x80, 0x10, 0xfe, 0x3e, 0xfe, 0x7f, 0xff, + 0x10, 0x40, 0x0f, 0xf8, 0x00, 0x80, 0x04, 0x20, 0x3f, 0xfc, 0x08, 0x40, 0x01, 0x00, 0x10, 0x20, + 0x00, 0x02, 0x02, 0x00, 0x04, 0x10, 0x04, 0x20, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x02, 0x10, + 0x10, 0x40, 0x00, 0x00, 0x00, 0x80, 0x04, 0x20, 0x00, 0x00, 0x10, 0x40, 0x01, 0x00, 0x00, 0x00, + 0x0c, 0x41, 0x40, 0x18, 0x48, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x7f, + 0x40, 0x8c, 0x10, 0x01, 0x20, 0x06, 0x38, 0x03, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, + 0x0a, 0x23, 0x40, 0x04, 0x44, 0x02, 0x3f, 0xfe, 0x1f, 0x82, 0x00, 0x04, 0x3f, 0xfe, 0x21, 0x80, + 0x20, 0x84, 0x17, 0xf3, 0x20, 0x02, 0x07, 0x0c, 0x40, 0x80, 0x0f, 0xf8, 0x00, 0x00, 0x00, 0x80, + 0x09, 0x15, 0x20, 0x02, 0x22, 0x44, 0x22, 0x22, 0x10, 0x82, 0x00, 0x04, 0x20, 0x02, 0x13, 0x06, + 0x20, 0x84, 0x10, 0x05, 0x27, 0xf2, 0x04, 0x10, 0x20, 0x82, 0x08, 0x08, 0x00, 0x00, 0x00, 0x80, + 0x09, 0x29, 0x23, 0xfa, 0x21, 0x48, 0x22, 0x22, 0x10, 0x82, 0x7c, 0x84, 0x27, 0xf2, 0x15, 0x02, + 0x10, 0x84, 0x16, 0x04, 0x24, 0x12, 0x04, 0x20, 0x10, 0x82, 0x08, 0x08, 0x00, 0x00, 0x00, 0x80, + 0x48, 0xc8, 0x12, 0x4a, 0x11, 0x88, 0x22, 0x22, 0x10, 0x92, 0x44, 0x84, 0x24, 0x92, 0x09, 0x7a, + 0x10, 0x84, 0x11, 0xc8, 0x24, 0x12, 0x74, 0x50, 0x08, 0x84, 0x08, 0x08, 0x00, 0x02, 0x1f, 0xf8, + 0x28, 0x94, 0x12, 0x4a, 0x11, 0x10, 0x23, 0xe2, 0x1f, 0x92, 0x45, 0x04, 0x24, 0x92, 0x09, 0x4a, + 0x10, 0x84, 0x11, 0x08, 0x27, 0xf2, 0x0c, 0x48, 0x08, 0x84, 0x08, 0x08, 0x00, 0x04, 0x00, 0x80, + 0x28, 0x94, 0x08, 0x42, 0x08, 0x90, 0x22, 0x22, 0x00, 0x12, 0x47, 0xff, 0x24, 0x92, 0x09, 0x7a, + 0x1f, 0xfc, 0x11, 0x08, 0x20, 0x02, 0x02, 0x84, 0x04, 0x88, 0x08, 0x08, 0x40, 0x08, 0x00, 0x80, + 0x1b, 0xff, 0x0b, 0xfe, 0x08, 0xa0, 0x23, 0xe2, 0x7f, 0xd2, 0x44, 0x04, 0x27, 0xf2, 0x09, 0x22, + 0x10, 0x84, 0x51, 0x10, 0x3f, 0xfe, 0x7f, 0xff, 0x04, 0x90, 0x08, 0x08, 0x20, 0x10, 0x00, 0x80, + 0x1c, 0x22, 0x22, 0x42, 0x20, 0xa0, 0x22, 0x22, 0x04, 0x12, 0x7c, 0x04, 0x24, 0x92, 0x79, 0xfe, + 0x10, 0x84, 0x31, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x0f, 0xf8, 0x10, 0x20, 0x6f, 0xfb, + 0x1b, 0xe4, 0x21, 0x42, 0x20, 0x60, 0x22, 0x22, 0x3f, 0x92, 0x47, 0xff, 0x24, 0x92, 0x01, 0x22, + 0x10, 0x84, 0x11, 0xff, 0x07, 0xf0, 0x00, 0x80, 0x7f, 0xff, 0x08, 0x08, 0x08, 0x40, 0x18, 0x0c, + 0x09, 0x7d, 0x45, 0xfa, 0x4f, 0xff, 0x3f, 0xfe, 0x04, 0x12, 0x44, 0x20, 0x24, 0x92, 0x01, 0xfe, + 0x1f, 0xfc, 0x11, 0x10, 0x04, 0x10, 0x1f, 0xfc, 0x00, 0x00, 0x08, 0x08, 0x04, 0x80, 0x04, 0x10, + 0x08, 0xaa, 0x02, 0x82, 0x00, 0x40, 0x02, 0x00, 0x3f, 0x92, 0x44, 0x20, 0x27, 0xf2, 0x00, 0x48, + 0x10, 0x84, 0x09, 0x10, 0x07, 0xf0, 0x00, 0x80, 0x00, 0x00, 0x08, 0x08, 0x03, 0x00, 0x02, 0x20, + 0x7c, 0xa4, 0x02, 0x82, 0x00, 0x40, 0x01, 0x00, 0x44, 0x52, 0x44, 0x20, 0x00, 0x80, 0x10, 0x84, + 0x10, 0x84, 0x09, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x01, 0x40, + 0x0b, 0x78, 0x09, 0xfe, 0x08, 0x40, 0x01, 0x00, 0x40, 0x52, 0x7d, 0xfe, 0x00, 0x80, 0x13, 0xff, + 0x10, 0x84, 0x05, 0xf0, 0x7f, 0xff, 0x3f, 0xfe, 0x1f, 0xfc, 0x08, 0x08, 0x00, 0x00, 0x00, 0x80, + 0x08, 0xa4, 0x09, 0x00, 0x08, 0x40, 0x7f, 0xff, 0x7f, 0xd2, 0x00, 0x20, 0x7f, 0xff, 0x20, 0x20, + 0x1f, 0xfc, 0x04, 0x18, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x00, 0x80, + 0x08, 0xa4, 0x11, 0x00, 0x10, 0x40, 0x00, 0x00, 0x04, 0x02, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x04, 0x04, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x8c, + 0x00, 0x00, 0x60, 0x00, 0x61, 0x81, 0x40, 0x82, 0x08, 0x00, 0x23, 0x1f, 0x08, 0x18, 0x08, 0x00, + 0x0c, 0x01, 0x00, 0x00, 0x0e, 0x04, 0x00, 0x00, 0x40, 0x02, 0x20, 0x20, 0x09, 0x07, 0x18, 0x84, + 0x04, 0x00, 0x18, 0x7c, 0x18, 0x62, 0x2c, 0x42, 0x0f, 0xff, 0x21, 0x21, 0x08, 0x08, 0x48, 0x7e, + 0x05, 0x83, 0x3f, 0xfe, 0x01, 0x04, 0x3e, 0xfc, 0x21, 0x22, 0x11, 0x2c, 0x08, 0x89, 0x0e, 0x84, + 0x02, 0x00, 0x0e, 0x44, 0x07, 0x54, 0x22, 0xa6, 0x08, 0x20, 0x21, 0x21, 0x08, 0x08, 0x29, 0x42, + 0x04, 0x45, 0x20, 0x82, 0x00, 0x84, 0x22, 0x84, 0x11, 0x24, 0x11, 0x24, 0x08, 0x89, 0x2c, 0xfc, + 0x01, 0x00, 0x29, 0x44, 0x14, 0x48, 0x11, 0x9a, 0x49, 0xfe, 0x3f, 0x20, 0x0f, 0xf8, 0x29, 0x42, + 0x04, 0x29, 0x20, 0x82, 0x00, 0x84, 0x22, 0x84, 0x12, 0x48, 0x09, 0x24, 0x08, 0x48, 0x2a, 0x84, + 0x01, 0x00, 0x2c, 0x44, 0x16, 0x48, 0x1f, 0x08, 0x28, 0x20, 0x21, 0x38, 0x08, 0x08, 0x2a, 0x42, + 0x74, 0x10, 0x20, 0x82, 0x00, 0x84, 0x22, 0x84, 0x00, 0x00, 0x09, 0x24, 0x08, 0x48, 0x4a, 0xfc, + 0x01, 0x40, 0x4a, 0x44, 0x25, 0x54, 0x14, 0x98, 0x29, 0xfc, 0x21, 0x26, 0x0f, 0xf8, 0x28, 0x7e, + 0x0c, 0x18, 0x20, 0x82, 0x00, 0x84, 0x3e, 0xfc, 0x63, 0x01, 0x09, 0xfc, 0x49, 0x28, 0x08, 0x84, + 0x01, 0x20, 0x08, 0x44, 0x04, 0x52, 0x14, 0x94, 0x1b, 0x24, 0x3f, 0x20, 0x08, 0x08, 0x09, 0x00, + 0x07, 0x28, 0x20, 0x82, 0x3f, 0x84, 0x00, 0x00, 0x18, 0x82, 0x4a, 0x21, 0x2a, 0x28, 0x7f, 0xfc, + 0x01, 0x10, 0x7e, 0x7c, 0x7f, 0x52, 0x1f, 0xd4, 0x1d, 0xfc, 0x21, 0x20, 0x0f, 0xf8, 0x7d, 0x00, + 0x04, 0x24, 0x00, 0x80, 0x20, 0x04, 0x3e, 0x00, 0x04, 0x44, 0x2a, 0x21, 0x1c, 0x28, 0x08, 0x00, + 0x1f, 0xf0, 0x09, 0x01, 0x04, 0x7c, 0x12, 0x22, 0x09, 0x24, 0x21, 0x1f, 0x66, 0xcc, 0x12, 0xfe, + 0x04, 0x24, 0x00, 0x80, 0x20, 0x04, 0x01, 0xfe, 0x0a, 0x28, 0x2b, 0xff, 0x08, 0x28, 0x09, 0xff, + 0x00, 0x00, 0x08, 0x82, 0x44, 0x44, 0x12, 0x22, 0x7f, 0xfc, 0x3f, 0x21, 0x11, 0x22, 0x0c, 0x10, + 0x7f, 0xff, 0x1f, 0xfc, 0x20, 0x04, 0x00, 0x20, 0x52, 0x28, 0x28, 0x00, 0x04, 0xfe, 0x7e, 0x20, + 0x00, 0x00, 0x7f, 0x42, 0x3f, 0xc4, 0x1f, 0xa0, 0x08, 0x20, 0x00, 0xa1, 0x7f, 0xfe, 0x08, 0x10, + 0x04, 0x40, 0x10, 0x84, 0x3f, 0x84, 0x3e, 0x20, 0x25, 0x10, 0x29, 0xfc, 0x04, 0x82, 0x22, 0xfc, + 0x00, 0x00, 0x22, 0x44, 0x11, 0x7c, 0x10, 0x20, 0x0b, 0xff, 0x7e, 0xa0, 0x08, 0x10, 0x14, 0x10, + 0x04, 0x40, 0x10, 0x84, 0x00, 0x84, 0x00, 0x20, 0x11, 0xff, 0x28, 0x04, 0x02, 0x82, 0x12, 0x20, + 0x00, 0x00, 0x12, 0x24, 0x0a, 0x44, 0x1f, 0xff, 0x08, 0x20, 0x11, 0x38, 0x1c, 0x60, 0x65, 0xff, + 0x34, 0x44, 0x10, 0x84, 0x00, 0x84, 0x7f, 0xff, 0x08, 0x92, 0x28, 0xfc, 0x7e, 0x82, 0x17, 0xfe, + 0x00, 0x00, 0x14, 0x24, 0x0c, 0x44, 0x00, 0x24, 0x79, 0xe0, 0x12, 0x26, 0x03, 0x10, 0x12, 0x10, + 0x0c, 0x48, 0x10, 0x84, 0x00, 0x84, 0x00, 0x20, 0x0f, 0x92, 0x08, 0x04, 0x08, 0x82, 0x08, 0x20, + 0x00, 0x00, 0x08, 0x04, 0x04, 0x7c, 0x00, 0x24, 0x0c, 0x18, 0x08, 0x20, 0x0f, 0xf0, 0x08, 0x10, + 0x02, 0x50, 0x00, 0x80, 0x7f, 0x84, 0x3e, 0x20, 0x04, 0x14, 0x09, 0xfc, 0x08, 0xfe, 0x08, 0x20, + 0x00, 0x00, 0x08, 0x3c, 0x04, 0x00, 0x00, 0x28, 0x02, 0x04, 0x08, 0x20, 0x00, 0x80, 0x08, 0x10, + 0x01, 0x40, 0x00, 0x80, 0x00, 0x04, 0x00, 0x20, 0x04, 0x10, 0x08, 0x00, 0x08, 0x00, 0x70, 0x06, + 0x00, 0x00, 0x20, 0x06, 0x43, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x70, 0x07, 0x43, 0x41, + 0x0b, 0x83, 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x03, 0x00, 0x04, 0x01, 0x00, 0x80, 0x0c, 0x18, + 0x3f, 0x7e, 0x20, 0x02, 0x20, 0x80, 0x1f, 0xfc, 0x00, 0x80, 0x00, 0x80, 0x0c, 0x18, 0x22, 0xa2, + 0x08, 0x6c, 0x00, 0x00, 0x07, 0xfc, 0x23, 0x26, 0x01, 0x00, 0x05, 0xf1, 0x00, 0x80, 0x03, 0x60, + 0x21, 0x42, 0x20, 0x02, 0x10, 0xbe, 0x10, 0x84, 0x00, 0x80, 0x3f, 0xfe, 0x02, 0x20, 0x22, 0x94, + 0x08, 0x10, 0x07, 0xf8, 0x44, 0x04, 0x20, 0xa8, 0x01, 0x00, 0x04, 0x4e, 0x00, 0x80, 0x00, 0x80, + 0x21, 0x42, 0x23, 0xe2, 0x10, 0xa2, 0x14, 0x94, 0x7f, 0xff, 0x00, 0x80, 0x01, 0x40, 0x12, 0x4c, + 0x09, 0x68, 0x08, 0x00, 0x24, 0x04, 0x12, 0x70, 0x01, 0x00, 0x7f, 0xa2, 0x00, 0x80, 0x01, 0x40, + 0x21, 0x42, 0x22, 0x22, 0x08, 0xa2, 0x12, 0xa4, 0x00, 0x80, 0x00, 0x80, 0x3f, 0xff, 0x12, 0x48, + 0x08, 0x84, 0x10, 0x00, 0x14, 0x04, 0x13, 0xab, 0x41, 0x04, 0x04, 0x24, 0x00, 0x80, 0x02, 0x20, + 0x21, 0x42, 0x32, 0x22, 0x08, 0xa2, 0x11, 0xc4, 0x0f, 0xf8, 0x1f, 0xfc, 0x00, 0x80, 0x12, 0x54, + 0x48, 0x7c, 0x10, 0x00, 0x0c, 0x04, 0x14, 0xa4, 0x21, 0x04, 0x3f, 0x24, 0x60, 0x81, 0x04, 0x10, + 0x3f, 0x7e, 0x2b, 0xe2, 0x08, 0xa2, 0x1f, 0xfc, 0x08, 0x88, 0x08, 0x88, 0x00, 0x80, 0x12, 0x54, + 0x28, 0x20, 0x10, 0x00, 0x0c, 0x04, 0x08, 0x48, 0x11, 0x04, 0x25, 0x10, 0x18, 0x82, 0x5f, 0xf2, + 0x00, 0x00, 0x24, 0x1e, 0x08, 0xa2, 0x10, 0x84, 0x08, 0x88, 0x08, 0x88, 0x1f, 0xfe, 0x1e, 0x52, + 0x18, 0xfc, 0x10, 0x00, 0x04, 0x04, 0x4b, 0xff, 0x11, 0x08, 0x25, 0x10, 0x04, 0x84, 0x40, 0x02, + 0x00, 0x00, 0x22, 0x26, 0x08, 0xa2, 0x12, 0xa4, 0x0f, 0xf8, 0x7f, 0xff, 0x00, 0x80, 0x10, 0x62, + 0x08, 0x84, 0x1e, 0x00, 0x07, 0xfc, 0x28, 0x48, 0x09, 0x08, 0x3f, 0x10, 0x02, 0x88, 0x7f, 0xfe, + 0x07, 0xf0, 0x22, 0x22, 0x08, 0xa2, 0x14, 0x94, 0x08, 0x88, 0x08, 0x88, 0x00, 0x80, 0x10, 0x62, + 0x08, 0xfc, 0x11, 0xc0, 0x02, 0x00, 0x2d, 0xfe, 0x09, 0x10, 0x25, 0xff, 0x01, 0xb0, 0x09, 0x20, + 0x04, 0x10, 0x3f, 0xfe, 0x08, 0xa2, 0x7f, 0xff, 0x08, 0x88, 0x08, 0x88, 0x0f, 0xfc, 0x1f, 0xfe, + 0x46, 0x84, 0x10, 0x30, 0x02, 0x00, 0x2a, 0x48, 0x09, 0x20, 0x25, 0x00, 0x00, 0xc0, 0x09, 0x10, + 0x04, 0x10, 0x02, 0x20, 0x7f, 0xa2, 0x08, 0x80, 0x0f, 0xf8, 0x1f, 0xfc, 0x00, 0x80, 0x12, 0x40, + 0x25, 0xfc, 0x10, 0x00, 0x01, 0x00, 0x2a, 0xfc, 0x01, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x12, 0x08, + 0x04, 0x10, 0x04, 0x10, 0x08, 0x22, 0x08, 0x80, 0x00, 0x80, 0x04, 0x10, 0x3f, 0xff, 0x12, 0x40, + 0x15, 0x00, 0x10, 0x00, 0x01, 0x00, 0x0a, 0x84, 0x01, 0x00, 0x04, 0x00, 0x00, 0x40, 0x7f, 0x88, + 0x04, 0x10, 0x7f, 0xff, 0x08, 0x3e, 0x08, 0xfc, 0x3f, 0xfe, 0x7f, 0xff, 0x02, 0x20, 0x12, 0x40, + 0x10, 0xff, 0x10, 0x00, 0x01, 0x00, 0x08, 0xfc, 0x01, 0x00, 0x7f, 0xc0, 0x00, 0x40, 0x00, 0x70, + 0x07, 0xf0, 0x00, 0x80, 0x08, 0x00, 0x08, 0x80, 0x00, 0x80, 0x04, 0x10, 0x02, 0x10, 0x12, 0x7f, + 0x08, 0x80, 0x10, 0x00, 0x3f, 0xff, 0x08, 0x84, 0x01, 0x00, 0x04, 0x3e, 0x7f, 0xff, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, 0x00, 0x80, 0x04, 0x10, 0x04, 0x10, 0x12, 0x00, + 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0xfc, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x30, 0x08, + 0x14, 0x01, 0x01, 0xf8, 0x40, 0x00, 0x01, 0x06, 0x38, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0x4d, 0x18, 0x00, 0x00, 0x00, 0x80, 0x20, 0x06, 0x40, 0x00, 0x00, 0xf8, 0x0c, 0x10, + 0x6a, 0x02, 0x42, 0x09, 0x47, 0xff, 0x01, 0x4a, 0x06, 0x00, 0x21, 0x7c, 0x7f, 0xfe, 0x06, 0x00, + 0x41, 0x0a, 0x24, 0x84, 0x00, 0x00, 0x00, 0x80, 0x27, 0xe2, 0x20, 0x3e, 0x41, 0x09, 0x02, 0x60, + 0x09, 0x04, 0x22, 0x49, 0x20, 0x20, 0x71, 0x4a, 0x01, 0x80, 0x21, 0x44, 0x08, 0x20, 0x01, 0x80, + 0x22, 0x2a, 0x24, 0x44, 0x00, 0xfc, 0x00, 0x80, 0x24, 0x22, 0x10, 0x42, 0x22, 0x09, 0x01, 0x80, + 0x08, 0x88, 0x12, 0x42, 0x20, 0x20, 0x0d, 0x4a, 0x00, 0x40, 0x15, 0x44, 0x08, 0x20, 0x00, 0x40, + 0x12, 0x24, 0x24, 0x24, 0x01, 0x00, 0x7f, 0xff, 0x27, 0xe2, 0x08, 0x42, 0x12, 0x22, 0x0e, 0x40, + 0x48, 0x50, 0x12, 0x80, 0x10, 0x20, 0x0b, 0x4a, 0x00, 0x20, 0x15, 0x44, 0x08, 0x20, 0x00, 0x20, + 0x12, 0x48, 0x26, 0x25, 0x02, 0x00, 0x00, 0x80, 0x24, 0x22, 0x04, 0x40, 0x12, 0x24, 0x08, 0x40, + 0x28, 0x50, 0x07, 0xf8, 0x10, 0x20, 0x29, 0x4a, 0x01, 0x90, 0x19, 0x44, 0x08, 0x20, 0x00, 0x10, + 0x12, 0x80, 0x25, 0xfe, 0x02, 0x00, 0x00, 0x80, 0x27, 0xe2, 0x04, 0x40, 0x12, 0x40, 0x04, 0x40, + 0x18, 0x20, 0x04, 0x08, 0x09, 0xfc, 0x29, 0xfe, 0x40, 0x90, 0x71, 0x44, 0x08, 0x20, 0x00, 0x10, + 0x00, 0x40, 0x3c, 0xa4, 0x02, 0x20, 0x0f, 0xfc, 0x20, 0x02, 0x46, 0x40, 0x00, 0x80, 0x04, 0x40, + 0x1f, 0xff, 0x07, 0xf8, 0x08, 0x20, 0x24, 0x40, 0x20, 0x8a, 0x1d, 0x7d, 0x08, 0x20, 0x00, 0x08, + 0x00, 0x20, 0x24, 0x48, 0x02, 0x10, 0x08, 0x84, 0x3f, 0x7e, 0x2a, 0x60, 0x1f, 0xfc, 0x7f, 0xfe, + 0x08, 0xa8, 0x04, 0x08, 0x20, 0x20, 0x44, 0x20, 0x10, 0x8a, 0x13, 0x82, 0x08, 0x20, 0x20, 0x08, + 0x0f, 0xf0, 0x27, 0xff, 0x02, 0x08, 0x08, 0x84, 0x21, 0x42, 0x11, 0x50, 0x10, 0x84, 0x02, 0x00, + 0x08, 0xa4, 0x07, 0xf8, 0x20, 0x20, 0x05, 0xff, 0x08, 0x84, 0x15, 0x42, 0x0f, 0xfc, 0x20, 0x08, + 0x60, 0x03, 0x24, 0x30, 0x3e, 0x04, 0x0f, 0xfc, 0x3f, 0x7e, 0x11, 0x48, 0x10, 0x84, 0x02, 0x00, + 0x51, 0x24, 0x00, 0x00, 0x40, 0x20, 0x7f, 0x00, 0x08, 0x84, 0x15, 0x44, 0x08, 0x00, 0x20, 0x08, + 0x1b, 0xec, 0x3c, 0x20, 0x03, 0xe2, 0x08, 0x84, 0x21, 0x42, 0x09, 0x44, 0x10, 0x84, 0x42, 0x02, + 0x32, 0x24, 0x7f, 0xff, 0x03, 0xfe, 0x08, 0xfe, 0x04, 0x88, 0x19, 0x24, 0x08, 0x00, 0x20, 0x08, + 0x04, 0x10, 0x25, 0xfe, 0x02, 0x1e, 0x08, 0x84, 0x3f, 0x7e, 0x0f, 0x44, 0x1f, 0xfc, 0x42, 0x02, + 0x10, 0x20, 0x02, 0x20, 0x00, 0x00, 0x08, 0x92, 0x04, 0x90, 0x11, 0x24, 0x08, 0x00, 0x3f, 0xf8, + 0x02, 0x20, 0x24, 0x20, 0x02, 0x04, 0x0f, 0xfc, 0x42, 0x88, 0x08, 0x40, 0x10, 0x84, 0x7f, 0xfe, + 0x2b, 0xfe, 0x04, 0x10, 0x08, 0x20, 0x08, 0x92, 0x00, 0x80, 0x1f, 0x24, 0x0f, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x24, 0xa8, 0x02, 0x05, 0x04, 0x90, 0x24, 0x50, 0x08, 0x40, 0x10, 0x84, 0x01, 0x00, + 0x44, 0x20, 0x3f, 0xfe, 0x08, 0x20, 0x08, 0x92, 0x00, 0x80, 0x08, 0x04, 0x00, 0xe0, 0x00, 0x00, + 0x00, 0x80, 0x3d, 0x24, 0x02, 0x09, 0x04, 0x88, 0x1f, 0xbf, 0x7f, 0xff, 0x1f, 0xfc, 0x01, 0x00, + 0x04, 0x20, 0x00, 0x80, 0x10, 0x40, 0x00, 0x10, 0x00, 0x80, 0x04, 0x3c, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x20, 0x00, 0x02, 0x09, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, + 0x00, 0x41, 0x20, 0x60, 0x00, 0x00, 0x62, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, + 0x40, 0x20, 0x00, 0x00, 0x60, 0x03, 0x26, 0x03, 0x26, 0x03, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x0c, + 0x0c, 0x23, 0x10, 0x10, 0x3f, 0xfe, 0x19, 0x71, 0x04, 0x7e, 0x47, 0xfc, 0x0f, 0xf8, 0x00, 0x80, + 0x20, 0x20, 0x0f, 0xf0, 0x10, 0x04, 0x21, 0x04, 0x21, 0x8c, 0x7f, 0xff, 0x3f, 0xfe, 0x05, 0x90, + 0x63, 0x15, 0x08, 0x08, 0x20, 0x82, 0x0e, 0xae, 0x44, 0x42, 0x24, 0x04, 0x08, 0x08, 0x40, 0x81, + 0x26, 0x23, 0x08, 0x10, 0x08, 0x08, 0x20, 0x88, 0x20, 0x50, 0x00, 0x80, 0x20, 0x02, 0x04, 0x20, + 0x18, 0xcd, 0x04, 0x08, 0x20, 0x82, 0x29, 0x92, 0x24, 0x42, 0x14, 0x04, 0x08, 0x08, 0x20, 0x82, + 0x11, 0x24, 0x08, 0x10, 0x04, 0x10, 0x38, 0x50, 0x38, 0x20, 0x1f, 0xfc, 0x30, 0x02, 0x04, 0x50, + 0x16, 0x28, 0x04, 0x08, 0x20, 0x82, 0x2c, 0x54, 0x24, 0xfe, 0x0c, 0x04, 0x08, 0x08, 0x10, 0x84, + 0x10, 0xa8, 0x0f, 0xf0, 0x02, 0x20, 0x24, 0x20, 0x27, 0x50, 0x00, 0x80, 0x28, 0x02, 0x04, 0x88, + 0x12, 0x4c, 0x02, 0x08, 0x20, 0x82, 0x4a, 0x50, 0x15, 0x42, 0x07, 0xfc, 0x0f, 0xf8, 0x08, 0x88, + 0x08, 0x70, 0x08, 0x10, 0x02, 0x20, 0x25, 0xfc, 0x24, 0x88, 0x0f, 0xf8, 0x24, 0x1e, 0x05, 0x08, + 0x13, 0xcc, 0x02, 0x08, 0x20, 0x82, 0x08, 0x48, 0x0e, 0x7e, 0x02, 0x00, 0x00, 0x80, 0x04, 0x90, + 0x08, 0x20, 0x0f, 0xf0, 0x01, 0x40, 0x25, 0x24, 0x24, 0x78, 0x08, 0x88, 0x24, 0x22, 0x7f, 0xff, + 0x12, 0x54, 0x02, 0x08, 0x20, 0x82, 0x7f, 0x48, 0x0c, 0x42, 0x02, 0x00, 0x00, 0x80, 0x04, 0xa0, + 0x07, 0xff, 0x08, 0x10, 0x01, 0x40, 0x25, 0x24, 0x27, 0x40, 0x08, 0x88, 0x22, 0x22, 0x04, 0x00, + 0x12, 0x52, 0x01, 0x08, 0x20, 0x82, 0x08, 0x48, 0x7f, 0x42, 0x1f, 0xf8, 0x00, 0x80, 0x02, 0xa0, + 0x00, 0x20, 0x0f, 0xf0, 0x00, 0x80, 0x29, 0xfc, 0x28, 0x8e, 0x0f, 0xf8, 0x22, 0x22, 0x04, 0x00, + 0x12, 0x52, 0x01, 0x08, 0x20, 0x82, 0x08, 0x48, 0x04, 0x7e, 0x01, 0x08, 0x7f, 0xff, 0x7e, 0xd0, + 0x23, 0x20, 0x00, 0x00, 0x00, 0x80, 0x28, 0x21, 0x30, 0x52, 0x08, 0x88, 0x22, 0x22, 0x07, 0xf8, + 0x7f, 0xd2, 0x01, 0xf8, 0x20, 0x82, 0x7e, 0x48, 0x44, 0x00, 0x01, 0x08, 0x00, 0x80, 0x00, 0xc8, + 0x20, 0x8e, 0x3f, 0xfc, 0x7f, 0xff, 0x33, 0xfe, 0x28, 0x50, 0x0f, 0xf8, 0x3f, 0xfe, 0x04, 0x00, + 0x10, 0x10, 0x01, 0x00, 0x00, 0x80, 0x21, 0x40, 0x22, 0x84, 0x7f, 0xff, 0x04, 0x90, 0x04, 0x84, + 0x40, 0x92, 0x20, 0x04, 0x00, 0x84, 0x29, 0x04, 0x27, 0xff, 0x00, 0x80, 0x02, 0x20, 0x07, 0xf8, + 0x13, 0xff, 0x01, 0x00, 0x00, 0x80, 0x12, 0x7f, 0x14, 0x48, 0x01, 0x08, 0x04, 0x10, 0x08, 0x82, + 0x02, 0x51, 0x3f, 0xfc, 0x00, 0x84, 0x24, 0x88, 0x24, 0x20, 0x7f, 0xff, 0x02, 0x20, 0x04, 0x00, + 0x10, 0x12, 0x01, 0x00, 0x00, 0x80, 0x14, 0x10, 0x1f, 0x7f, 0x01, 0x08, 0x7f, 0xff, 0x10, 0x82, + 0x0a, 0x51, 0x20, 0x04, 0x00, 0x88, 0x24, 0x50, 0x25, 0xfe, 0x00, 0x80, 0x02, 0x20, 0x07, 0xfc, + 0x10, 0x14, 0x7f, 0xfe, 0x00, 0x80, 0x08, 0x10, 0x08, 0x20, 0x1f, 0xf8, 0x04, 0x10, 0x00, 0x80, + 0x0b, 0xff, 0x3f, 0xfc, 0x00, 0x90, 0x3c, 0x20, 0x3c, 0x20, 0x1f, 0xe0, 0x7f, 0xff, 0x00, 0x00, + 0x10, 0x10, 0x00, 0x00, 0x00, 0x80, 0x08, 0x10, 0x08, 0x20, 0x00, 0x00, 0x04, 0x10, 0x00, 0x80, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x20, 0x00, 0x18, 0x00, 0x00, 0x20, 0x1c, + 0x00, 0x00, 0x26, 0xc2, 0x42, 0x06, 0x00, 0xc0, 0x00, 0x40, 0x08, 0x01, 0x00, 0x00, 0x10, 0x00, + 0x02, 0x18, 0x08, 0x18, 0x03, 0x01, 0x00, 0x30, 0x30, 0x02, 0x40, 0xff, 0x00, 0x00, 0x22, 0x25, + 0x4f, 0xfc, 0x22, 0x22, 0x42, 0x02, 0x00, 0x20, 0x40, 0x40, 0x08, 0x03, 0x0f, 0xf8, 0x6b, 0xfe, + 0x3f, 0x04, 0x08, 0x08, 0x00, 0x82, 0x60, 0x10, 0x08, 0x04, 0x23, 0x00, 0x7f, 0xff, 0x21, 0x41, + 0x28, 0x44, 0x22, 0x14, 0x22, 0x02, 0x00, 0x10, 0x3f, 0xff, 0x08, 0x05, 0x08, 0x08, 0x0a, 0x22, + 0x22, 0x82, 0x08, 0x08, 0x3e, 0x44, 0x18, 0x10, 0x04, 0x18, 0x14, 0x00, 0x00, 0x80, 0x39, 0x49, + 0x28, 0x44, 0x3e, 0x08, 0x22, 0x02, 0x00, 0x10, 0x20, 0x40, 0x08, 0x09, 0x08, 0x08, 0x0a, 0x22, + 0x22, 0x42, 0x08, 0x08, 0x42, 0x28, 0x04, 0x10, 0x02, 0x20, 0x0d, 0xfc, 0x00, 0x80, 0x25, 0x4a, + 0x17, 0xf8, 0x22, 0xc4, 0x12, 0xfa, 0x08, 0x10, 0x27, 0xfc, 0x08, 0x08, 0x08, 0x08, 0x4a, 0x22, + 0x22, 0x42, 0x7f, 0xff, 0x42, 0x18, 0x02, 0x10, 0x00, 0x00, 0x09, 0x04, 0x1f, 0xfc, 0x24, 0x10, + 0x14, 0x48, 0x3e, 0x24, 0x12, 0x8a, 0x07, 0xf0, 0x14, 0x44, 0x08, 0x10, 0x08, 0x08, 0x2b, 0xfe, + 0x3e, 0x22, 0x08, 0x88, 0x40, 0x10, 0x01, 0x10, 0x7f, 0xff, 0x09, 0x04, 0x00, 0x80, 0x25, 0xfe, + 0x14, 0x48, 0x62, 0x12, 0x0a, 0x8a, 0x04, 0x00, 0x14, 0x44, 0x08, 0x10, 0x08, 0x08, 0x1a, 0x22, + 0x00, 0x22, 0x08, 0x88, 0x40, 0x28, 0x00, 0x90, 0x04, 0x10, 0x09, 0x04, 0x00, 0x80, 0x24, 0x02, + 0x1f, 0xfc, 0x7f, 0x12, 0x0a, 0x8a, 0x04, 0x00, 0x17, 0xfc, 0x48, 0x10, 0x0f, 0xf8, 0x1a, 0x22, + 0x00, 0x22, 0x08, 0x88, 0x41, 0x28, 0x00, 0x50, 0x04, 0x10, 0x09, 0xfc, 0x1f, 0xfc, 0x24, 0xfe, + 0x10, 0x04, 0x41, 0x28, 0x02, 0xfa, 0x7f, 0xff, 0x14, 0x44, 0x28, 0x20, 0x00, 0x80, 0x0a, 0x22, + 0x3e, 0x3e, 0x0f, 0xf8, 0x42, 0xa4, 0x7f, 0xff, 0x04, 0x10, 0x78, 0x00, 0x10, 0x84, 0x28, 0x02, + 0x1f, 0xfc, 0x7f, 0x64, 0x22, 0x02, 0x00, 0x00, 0x17, 0xfc, 0x1b, 0xe0, 0x00, 0x80, 0x4b, 0xfe, + 0x00, 0x20, 0x08, 0x88, 0x7e, 0xa4, 0x04, 0x10, 0x04, 0x10, 0x07, 0xff, 0x10, 0x84, 0x31, 0xfe, + 0x30, 0x00, 0x2a, 0x14, 0x22, 0x02, 0x0f, 0xf0, 0x10, 0x40, 0x18, 0x3f, 0x00, 0x80, 0x28, 0x00, + 0x3e, 0x20, 0x08, 0x88, 0x02, 0x44, 0x04, 0x10, 0x04, 0x10, 0x02, 0x20, 0x10, 0x84, 0x28, 0x98, + 0x4c, 0x7c, 0x2a, 0x10, 0x43, 0xfe, 0x08, 0x10, 0x1f, 0xfe, 0x08, 0x20, 0x00, 0x80, 0x10, 0x88, + 0x00, 0x20, 0x0f, 0xf8, 0x02, 0x44, 0x04, 0x10, 0x07, 0xfe, 0x02, 0x20, 0x1f, 0xfc, 0x25, 0x24, + 0x42, 0x42, 0x2e, 0xff, 0x02, 0x02, 0x08, 0x10, 0x10, 0x40, 0x08, 0x20, 0x7f, 0xff, 0x10, 0x88, + 0x7f, 0xff, 0x00, 0x80, 0x02, 0x7f, 0x04, 0x10, 0x04, 0x00, 0x11, 0xfe, 0x10, 0x84, 0x27, 0xe2, + 0x7f, 0xfe, 0x22, 0x10, 0x0a, 0x02, 0x08, 0x10, 0x10, 0x40, 0x04, 0x22, 0x00, 0x80, 0x2f, 0xff, + 0x00, 0x10, 0x00, 0x80, 0x7e, 0x40, 0x04, 0x10, 0x07, 0x00, 0x11, 0x20, 0x10, 0x84, 0x3c, 0x1a, + 0x01, 0x00, 0x3e, 0x10, 0x0b, 0xfe, 0x0f, 0xf0, 0x1f, 0xff, 0x04, 0x24, 0x00, 0x80, 0x44, 0x88, + 0x3e, 0x10, 0x3f, 0xfe, 0x00, 0x40, 0x07, 0xfc, 0x00, 0xe0, 0x21, 0x20, 0x1f, 0xfc, 0x00, 0x06, + 0x01, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x28, 0x00, 0x80, 0x04, 0x88, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x40, 0x06, 0x27, 0x01, 0x37, 0x02, 0x00, 0x00, + 0x40, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xc1, 0x40, 0x3f, 0x40, 0x30, 0x0f, 0xf8, + 0x50, 0x44, 0x7f, 0xff, 0x7f, 0xff, 0x18, 0xfe, 0x20, 0x02, 0x22, 0x82, 0x10, 0xcc, 0x11, 0xe0, + 0x40, 0x02, 0x1f, 0xf8, 0x7f, 0xfe, 0x27, 0xf8, 0x11, 0x22, 0x40, 0x41, 0x22, 0x10, 0x08, 0x08, + 0x28, 0x84, 0x00, 0x80, 0x08, 0x80, 0x14, 0x92, 0x23, 0xf2, 0x22, 0x44, 0x10, 0x30, 0x12, 0x12, + 0x40, 0x02, 0x10, 0x08, 0x01, 0x00, 0x14, 0x08, 0x49, 0x14, 0x20, 0x81, 0x12, 0x10, 0x08, 0x08, + 0x28, 0x81, 0x0f, 0xf8, 0x08, 0x80, 0x14, 0x92, 0x12, 0x12, 0x22, 0x28, 0x13, 0xd0, 0x2a, 0x1c, + 0x40, 0x02, 0x10, 0x08, 0x01, 0x00, 0x0f, 0xf8, 0x2a, 0x08, 0x20, 0x80, 0x14, 0x10, 0x08, 0x08, + 0x24, 0x81, 0x20, 0x80, 0x08, 0x80, 0x12, 0x92, 0x12, 0x12, 0x3e, 0x10, 0x10, 0x88, 0x21, 0xf0, + 0x40, 0x02, 0x10, 0x08, 0x1f, 0xf8, 0x08, 0x00, 0x20, 0x18, 0x10, 0x90, 0x3e, 0x10, 0x08, 0x08, + 0x14, 0x81, 0x20, 0x30, 0x08, 0x80, 0x12, 0x10, 0x12, 0x12, 0x22, 0x18, 0x70, 0x88, 0x20, 0x10, + 0x40, 0x02, 0x1f, 0xf8, 0x01, 0x00, 0x07, 0xf0, 0x3f, 0x94, 0x10, 0x9c, 0x22, 0x10, 0x6f, 0xfb, + 0x14, 0x82, 0x3b, 0x11, 0x08, 0x80, 0x72, 0xfe, 0x13, 0xf2, 0x3e, 0x28, 0x1f, 0xff, 0x20, 0x10, + 0x40, 0x02, 0x02, 0x00, 0x01, 0x00, 0x04, 0x10, 0x2a, 0x24, 0x08, 0x92, 0x22, 0x10, 0x18, 0x0c, + 0x14, 0x84, 0x24, 0x92, 0x08, 0x80, 0x1e, 0x92, 0x10, 0x02, 0x22, 0x24, 0x10, 0x40, 0x20, 0x10, + 0x40, 0x02, 0x01, 0x00, 0x0f, 0xf0, 0x07, 0xf0, 0x2a, 0xfc, 0x08, 0x92, 0x22, 0x10, 0x04, 0x10, + 0x10, 0x90, 0x27, 0x54, 0x08, 0x80, 0x12, 0x92, 0x1f, 0xfe, 0x3e, 0xa4, 0x10, 0x40, 0x20, 0x10, + 0x40, 0x02, 0x0f, 0xf0, 0x08, 0x10, 0x04, 0x10, 0x3f, 0x40, 0x20, 0x92, 0x3e, 0x10, 0x02, 0x20, + 0x10, 0x90, 0x24, 0xb8, 0x08, 0xfc, 0x12, 0x92, 0x10, 0x42, 0x00, 0x44, 0x17, 0xff, 0x20, 0x10, + 0x7e, 0x7e, 0x08, 0x10, 0x08, 0x10, 0x67, 0xf3, 0x2a, 0x23, 0x27, 0x92, 0x22, 0xff, 0x21, 0x40, + 0x10, 0x20, 0x2b, 0x5c, 0x08, 0x80, 0x12, 0x10, 0x10, 0x42, 0x7f, 0xc4, 0x10, 0x90, 0x13, 0xf0, + 0x42, 0x42, 0x08, 0x10, 0x4f, 0xf2, 0x18, 0x0c, 0x2a, 0x25, 0x40, 0xf2, 0x22, 0x00, 0x10, 0x84, + 0x10, 0x40, 0x30, 0xaa, 0x08, 0x80, 0x7f, 0xfe, 0x17, 0xfa, 0x12, 0x24, 0x7c, 0x88, 0x10, 0x1e, + 0x42, 0x42, 0x4f, 0xf2, 0x40, 0x02, 0x07, 0xf0, 0x3f, 0x25, 0x00, 0x9e, 0x3e, 0x82, 0x08, 0x84, + 0x10, 0x80, 0x28, 0x40, 0x00, 0x80, 0x12, 0x02, 0x10, 0x42, 0x12, 0x3f, 0x11, 0x08, 0x10, 0x16, + 0x7e, 0x7e, 0x40, 0x02, 0x7f, 0xfe, 0x02, 0x20, 0x21, 0x24, 0x00, 0x92, 0x22, 0x82, 0x08, 0x08, + 0x1f, 0xff, 0x27, 0xff, 0x00, 0x80, 0x12, 0x02, 0x10, 0x42, 0x7f, 0x20, 0x13, 0xfe, 0x10, 0x19, + 0x42, 0x42, 0x7f, 0xfe, 0x09, 0x20, 0x01, 0x40, 0x21, 0x24, 0x08, 0x90, 0x22, 0xfe, 0x04, 0x08, + 0x00, 0x40, 0x3c, 0x48, 0x00, 0x80, 0x13, 0xfe, 0x1f, 0xfe, 0x12, 0x20, 0x10, 0x20, 0x10, 0x19, + 0x7e, 0x7e, 0x01, 0x00, 0x09, 0x10, 0x00, 0x80, 0x3f, 0x3c, 0x08, 0x90, 0x3e, 0x10, 0x04, 0x10, + 0x00, 0x40, 0x00, 0x84, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x12, 0x20, 0x10, 0x20, 0x00, 0x16, + 0x00, 0x00, 0x01, 0x00, 0x11, 0x10, 0x00, 0x80, 0x00, 0x00, 0x10, 0x10, 0x00, 0x10, 0x40, 0x60, + 0x03, 0x87, 0x00, 0x1c, 0x40, 0x01, 0x43, 0x40, 0x00, 0x00, 0x60, 0x1f, 0x08, 0x00, 0x30, 0x02, + 0x03, 0x00, 0x46, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x8c, 0x10, 0x00, 0x40, 0x20, + 0x3e, 0x68, 0x3f, 0xe2, 0x20, 0x02, 0x41, 0x7f, 0x30, 0x00, 0x18, 0x21, 0x09, 0xff, 0x0c, 0x0c, + 0x00, 0xc0, 0x41, 0x8c, 0x5f, 0xff, 0x3f, 0x20, 0x00, 0x40, 0x10, 0x84, 0x17, 0xff, 0x20, 0x20, + 0x22, 0x30, 0x22, 0x22, 0x10, 0x04, 0x41, 0x48, 0x0c, 0x00, 0x04, 0x21, 0x08, 0x10, 0x02, 0x30, + 0x00, 0x20, 0x20, 0x50, 0x20, 0x40, 0x21, 0x26, 0x30, 0x20, 0x10, 0x84, 0x10, 0x00, 0x20, 0x20, + 0x22, 0xc8, 0x22, 0x22, 0x08, 0x08, 0x7b, 0x48, 0x02, 0x00, 0x02, 0x20, 0x08, 0x10, 0x1f, 0xfc, + 0x1e, 0x10, 0x20, 0x20, 0x20, 0x40, 0x21, 0x29, 0x48, 0x20, 0x10, 0x84, 0x10, 0xc0, 0x10, 0x20, + 0x23, 0xfc, 0x02, 0x02, 0x04, 0x10, 0x55, 0x48, 0x01, 0x00, 0x02, 0x20, 0x48, 0x10, 0x10, 0x04, + 0x12, 0x08, 0x17, 0xff, 0x17, 0xfc, 0x21, 0x31, 0x44, 0x10, 0x1f, 0xfc, 0x10, 0x31, 0x17, 0xff, + 0x3e, 0x00, 0x0f, 0xfe, 0x02, 0x20, 0x49, 0x7e, 0x00, 0x80, 0x7f, 0xff, 0x29, 0x10, 0x1f, 0xfc, + 0x52, 0x38, 0x10, 0x20, 0x10, 0x40, 0x3f, 0x21, 0x22, 0x12, 0x10, 0x84, 0x52, 0xaa, 0x08, 0x20, + 0x00, 0xfe, 0x08, 0x00, 0x02, 0x20, 0x7f, 0x48, 0x00, 0x40, 0x02, 0x20, 0x1a, 0x10, 0x10, 0x04, + 0x32, 0x14, 0x09, 0xfc, 0x1f, 0xfa, 0x00, 0x22, 0x1a, 0x1c, 0x10, 0x84, 0x53, 0xa4, 0x08, 0x10, + 0x3e, 0x90, 0x0f, 0xff, 0x01, 0x40, 0x08, 0x48, 0x00, 0x20, 0x62, 0x21, 0x0c, 0x10, 0x1f, 0xfc, + 0x33, 0x15, 0x09, 0x04, 0x13, 0x0c, 0x00, 0x22, 0x07, 0xe8, 0x17, 0xf4, 0x32, 0xa4, 0x20, 0x08, + 0x00, 0xfc, 0x08, 0x00, 0x01, 0x40, 0x3e, 0x7e, 0x00, 0x20, 0x12, 0x22, 0x08, 0x10, 0x10, 0x04, + 0x12, 0x91, 0x01, 0xfc, 0x10, 0xb0, 0xff, 0xa4, 0x01, 0x08, 0x11, 0x44, 0x36, 0xaa, 0x23, 0xfc, + 0x01, 0x90, 0x0f, 0xf0, 0x00, 0x80, 0x36, 0x48, 0x00, 0x10, 0x0f, 0xfc, 0x04, 0x10, 0x1f, 0xfc, + 0x1e, 0x92, 0x21, 0x04, 0x1f, 0xfe, 0x14, 0x28, 0x01, 0x08, 0x12, 0x24, 0x1b, 0xa2, 0x41, 0x28, + 0x3e, 0xfc, 0x08, 0x10, 0x00, 0x80, 0x2b, 0x48, 0x00, 0x10, 0x04, 0x0a, 0x04, 0xfe, 0x00, 0x00, + 0x08, 0x52, 0x21, 0xfc, 0x10, 0x00, 0x12, 0x24, 0x01, 0x08, 0x1f, 0xfc, 0x10, 0x3e, 0x01, 0x28, + 0x00, 0x90, 0x0f, 0xf0, 0x00, 0x80, 0x3a, 0xc8, 0x00, 0x08, 0x0a, 0x09, 0x02, 0x10, 0x0f, 0xf8, + 0x08, 0x54, 0x40, 0x88, 0x1f, 0xfc, 0x12, 0x24, 0x00, 0x80, 0x00, 0x80, 0x10, 0xe0, 0x02, 0x44, + 0x7f, 0x7e, 0x08, 0x10, 0x00, 0x80, 0x26, 0x7f, 0x00, 0x08, 0x12, 0x11, 0x7e, 0x10, 0x08, 0x08, + 0x08, 0x58, 0x00, 0x88, 0x10, 0x04, 0x21, 0x22, 0x00, 0x80, 0x00, 0x80, 0x7e, 0x40, 0x0f, 0xc4, + 0x00, 0x48, 0x0f, 0xf0, 0x00, 0x80, 0x7f, 0x48, 0x00, 0x08, 0x01, 0x18, 0x08, 0x10, 0x08, 0x08, + 0x08, 0x10, 0x0f, 0xff, 0x10, 0x04, 0x7f, 0xa2, 0x1f, 0x80, 0x7f, 0xff, 0x10, 0x40, 0x08, 0x30, + 0x3e, 0xfe, 0x02, 0x00, 0x00, 0x80, 0x08, 0x24, 0x00, 0x08, 0x01, 0x24, 0x08, 0x10, 0x0f, 0xf8, + 0x7f, 0x10, 0x08, 0x88, 0x1f, 0xfc, 0x08, 0x3e, 0x00, 0x00, 0x00, 0x80, 0x13, 0xfe, 0x10, 0x08, + 0x00, 0x48, 0x01, 0x00, 0x03, 0x80, 0x08, 0x24, 0x00, 0x00, 0x0f, 0x24, 0x08, 0x10, 0x00, 0x00, + 0x00, 0x10, 0x10, 0x88, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x40, 0x7f, 0x40, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x3f, 0xfe, + 0x47, 0xe3, 0x1f, 0xf8, 0x0f, 0xfe, 0x00, 0x10, 0x48, 0x7e, 0x03, 0x00, 0x21, 0x80, 0x40, 0x08, + 0x1f, 0xfc, 0x00, 0x80, 0x10, 0x10, 0x7f, 0xff, 0x0f, 0xf8, 0x49, 0x11, 0x3f, 0xfe, 0x04, 0x90, + 0x20, 0x05, 0x10, 0x08, 0x08, 0x00, 0x00, 0x20, 0x29, 0x42, 0x00, 0xc0, 0x12, 0x20, 0x22, 0x04, + 0x10, 0x04, 0x00, 0x80, 0x08, 0x10, 0x00, 0x80, 0x08, 0x08, 0x2a, 0x92, 0x20, 0x02, 0x04, 0x88, + 0x2c, 0x08, 0x10, 0x08, 0x08, 0x00, 0x00, 0x40, 0x29, 0x42, 0x00, 0x20, 0x17, 0xfe, 0x23, 0xff, + 0x10, 0x04, 0x00, 0x80, 0x08, 0x10, 0x00, 0x80, 0x08, 0x08, 0x2a, 0x54, 0x20, 0x02, 0x08, 0x88, + 0x13, 0x88, 0x10, 0x08, 0x08, 0x00, 0x00, 0x40, 0x2a, 0x42, 0x00, 0x10, 0x08, 0x20, 0x11, 0x24, + 0x10, 0x04, 0x00, 0x80, 0x04, 0x10, 0x00, 0x80, 0x0f, 0xf8, 0x2a, 0x54, 0x20, 0x02, 0x00, 0x80, + 0x12, 0x10, 0x10, 0x08, 0x08, 0xf8, 0x00, 0x80, 0x2c, 0x42, 0x08, 0x10, 0x0b, 0xfc, 0x11, 0x24, + 0x1f, 0xfc, 0x38, 0x82, 0x04, 0x10, 0x00, 0x80, 0x08, 0x08, 0x2c, 0x38, 0x23, 0xe2, 0x1f, 0xfe, + 0x12, 0x10, 0x1f, 0xf8, 0x08, 0x88, 0x00, 0x80, 0x09, 0x7e, 0x08, 0x08, 0x0a, 0x24, 0x09, 0x24, + 0x10, 0x04, 0x06, 0x8c, 0x04, 0x10, 0x00, 0x80, 0x0f, 0xf8, 0x08, 0xfe, 0x22, 0x22, 0x00, 0x80, + 0x13, 0xff, 0x10, 0x08, 0x08, 0x88, 0x00, 0x80, 0x7f, 0x00, 0x08, 0x08, 0x0b, 0xfc, 0x0f, 0xff, + 0x10, 0x04, 0x01, 0xb0, 0x04, 0x10, 0x00, 0x80, 0x01, 0x00, 0x7d, 0x92, 0x22, 0x22, 0x00, 0x80, + 0x12, 0x20, 0x10, 0x08, 0x08, 0x88, 0x00, 0x80, 0x12, 0x8c, 0x0f, 0xf8, 0x7a, 0x24, 0x00, 0xa4, + 0x1f, 0xfc, 0x00, 0x40, 0x04, 0x10, 0x1f, 0xfc, 0x60, 0x86, 0x12, 0x92, 0x22, 0x22, 0x67, 0xf3, + 0x12, 0x20, 0x10, 0x08, 0x08, 0x88, 0x00, 0x80, 0x0a, 0x42, 0x00, 0x80, 0x03, 0xfc, 0x24, 0xa4, + 0x10, 0x04, 0x00, 0x20, 0x64, 0x13, 0x00, 0x80, 0x19, 0x62, 0x0c, 0xfe, 0x22, 0x22, 0x18, 0x0c, + 0x13, 0xe0, 0x1f, 0xf8, 0x7f, 0xff, 0x00, 0x40, 0x08, 0x42, 0x00, 0x80, 0x00, 0x20, 0x23, 0xfc, + 0x10, 0x04, 0x00, 0x10, 0x18, 0x0c, 0x00, 0x80, 0x05, 0x1a, 0x08, 0x92, 0x23, 0xe2, 0x04, 0x10, + 0x10, 0x18, 0x10, 0x08, 0x08, 0x88, 0x00, 0x40, 0x14, 0x22, 0x00, 0x80, 0x03, 0xfc, 0x41, 0x00, + 0x10, 0x04, 0x00, 0x08, 0x04, 0x10, 0x00, 0x80, 0x13, 0x26, 0x14, 0xfe, 0x20, 0x02, 0x02, 0x20, + 0x10, 0x04, 0x10, 0x08, 0x08, 0x88, 0x00, 0x20, 0x72, 0x22, 0x00, 0x00, 0x14, 0x22, 0x01, 0x00, + 0x1f, 0xfc, 0x1f, 0xf8, 0x02, 0x20, 0x00, 0x80, 0x11, 0x22, 0x72, 0x10, 0x20, 0x02, 0x01, 0x40, + 0x1f, 0xff, 0x10, 0x08, 0x08, 0x88, 0x00, 0x10, 0x0a, 0x22, 0x00, 0x00, 0x14, 0x22, 0x08, 0xfe, + 0x02, 0x00, 0x00, 0x80, 0x01, 0x40, 0x00, 0x80, 0x21, 0x42, 0x13, 0xff, 0x20, 0x02, 0x00, 0x80, + 0x00, 0x40, 0x1f, 0xf8, 0x08, 0x88, 0x00, 0x08, 0x08, 0xfe, 0x00, 0x00, 0x27, 0xfe, 0x08, 0x80, + 0x01, 0x00, 0x00, 0x80, 0x00, 0x80, 0x3f, 0xfe, 0x7f, 0xfe, 0x08, 0x10, 0x3f, 0xfe, 0x00, 0x80, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, + 0x01, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x62, 0x0e, 0x16, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x10, 0x08, 0x20, 0x00, 0x80, 0x00, 0x00, + 0x0f, 0xf8, 0x00, 0x80, 0x03, 0x80, 0x18, 0x18, 0x3e, 0x7e, 0x07, 0xe0, 0x1f, 0xf8, 0x08, 0x00, + 0x19, 0x12, 0x11, 0x8c, 0x30, 0x86, 0x30, 0x00, 0x0f, 0x90, 0x08, 0x20, 0x00, 0x80, 0x00, 0xf8, + 0x08, 0x08, 0x00, 0x40, 0x04, 0x40, 0x04, 0x20, 0x22, 0x42, 0x08, 0x10, 0x11, 0x08, 0x04, 0x00, + 0x0e, 0x92, 0x10, 0x70, 0x0c, 0x98, 0x0c, 0x04, 0x08, 0x96, 0x08, 0x20, 0x00, 0x80, 0x01, 0x00, + 0x08, 0x08, 0x00, 0x40, 0x40, 0x20, 0x02, 0x40, 0x22, 0x42, 0x08, 0x08, 0x1f, 0xf8, 0x02, 0x00, + 0x28, 0x92, 0x10, 0x30, 0x02, 0xa0, 0x02, 0x08, 0x48, 0x99, 0x0b, 0xfe, 0x10, 0x98, 0x02, 0x00, + 0x08, 0x08, 0x03, 0x40, 0x20, 0x21, 0x7f, 0xfe, 0x22, 0x42, 0x18, 0x08, 0x11, 0x08, 0x02, 0x00, + 0x2c, 0x50, 0x56, 0x48, 0x01, 0xc0, 0x01, 0x10, 0x2f, 0x91, 0x48, 0x20, 0x10, 0x84, 0x02, 0x00, + 0x0f, 0xf8, 0x04, 0xc0, 0x20, 0x21, 0x01, 0x00, 0x3e, 0x7e, 0x28, 0x08, 0x1f, 0xf8, 0x01, 0x00, + 0x4a, 0x50, 0x31, 0x88, 0x7f, 0xfe, 0x00, 0xa0, 0x18, 0x91, 0x29, 0xfc, 0x10, 0x84, 0x02, 0x00, + 0x00, 0x00, 0x04, 0x40, 0x10, 0x42, 0x01, 0x00, 0x00, 0x00, 0x24, 0x08, 0x00, 0x00, 0x01, 0x00, + 0x08, 0x50, 0x10, 0xfc, 0x00, 0x80, 0x00, 0x40, 0x08, 0x91, 0x2a, 0x23, 0x10, 0x84, 0x02, 0x00, + 0x0f, 0xf8, 0x04, 0x40, 0x10, 0x44, 0x1f, 0xf0, 0x01, 0xff, 0x24, 0x10, 0x0f, 0xf0, 0x01, 0x00, + 0x7f, 0x50, 0x10, 0x41, 0x0f, 0xf8, 0x01, 0xa0, 0x0f, 0x92, 0x19, 0x24, 0x10, 0x84, 0x7f, 0xfc, + 0x00, 0x00, 0x04, 0xc0, 0x00, 0x88, 0x01, 0x00, 0x3e, 0x24, 0x24, 0x02, 0x08, 0x10, 0x01, 0x00, + 0x09, 0xfa, 0x0b, 0xfd, 0x08, 0x88, 0x06, 0x20, 0x04, 0x14, 0x1a, 0x88, 0x10, 0x84, 0x02, 0x00, + 0x00, 0x00, 0x03, 0x40, 0x01, 0x00, 0x01, 0x00, 0x00, 0x24, 0x1c, 0x02, 0x0f, 0xf0, 0x01, 0x00, + 0x08, 0x8c, 0x08, 0x42, 0x08, 0x88, 0x00, 0x10, 0x7f, 0xf8, 0x1f, 0xff, 0x1f, 0xfc, 0x02, 0x00, + 0x0f, 0xf8, 0x00, 0x40, 0x01, 0x00, 0x3f, 0xf8, 0x3e, 0x24, 0x04, 0x04, 0x00, 0x00, 0x02, 0x00, + 0x7e, 0x50, 0x44, 0x24, 0x0f, 0xf8, 0x00, 0x10, 0x05, 0x14, 0x08, 0x50, 0x00, 0x80, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x80, 0x41, 0x02, 0x00, 0xfc, 0x04, 0x04, 0x5f, 0xfa, 0x02, 0x00, + 0x21, 0x20, 0x24, 0xd0, 0x08, 0x88, 0x00, 0x08, 0x05, 0x14, 0x09, 0xfc, 0x00, 0x80, 0x02, 0x00, + 0x7f, 0xff, 0x3f, 0xc4, 0x00, 0x40, 0x40, 0x02, 0x7f, 0x10, 0x3f, 0x88, 0x40, 0x02, 0x04, 0x00, + 0x13, 0xff, 0x13, 0x10, 0x0f, 0xf8, 0x0f, 0xf8, 0x04, 0x92, 0x7e, 0x20, 0x7f, 0xff, 0x1f, 0xf0, + 0x00, 0x00, 0x00, 0x7d, 0x01, 0xc0, 0x7f, 0xfe, 0x00, 0x10, 0x04, 0x00, 0x7f, 0xfe, 0x08, 0x00, + 0x14, 0x20, 0x10, 0x88, 0x04, 0x90, 0x00, 0x00, 0x3f, 0x92, 0x0b, 0xfe, 0x00, 0x80, 0x00, 0x00, + 0x07, 0xf0, 0x00, 0x49, 0x02, 0x00, 0x01, 0x00, 0x3e, 0xfe, 0x04, 0x00, 0x01, 0x00, 0x10, 0x00, + 0x08, 0x20, 0x08, 0x48, 0x04, 0x88, 0x00, 0x00, 0x04, 0x9e, 0x08, 0x20, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x20, 0x08, 0x40, 0x09, 0x08, 0x00, 0x00, 0x04, 0x00, 0x08, 0x20, 0x00, 0x80, 0x40, 0x00, + 0x00, 0x60, 0x01, 0x80, 0x70, 0x8c, 0x00, 0x00, 0x0b, 0x00, 0x18, 0x0f, 0x00, 0x04, 0x08, 0x0c, + 0x10, 0x60, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7f, 0x00, 0x00, 0x41, 0xfc, + 0x00, 0x20, 0x00, 0x80, 0x0e, 0x42, 0x00, 0xc0, 0x08, 0xc0, 0x06, 0x11, 0x40, 0x04, 0x08, 0x04, + 0x08, 0x10, 0x00, 0x80, 0x00, 0x40, 0x1f, 0xff, 0x7f, 0xff, 0x21, 0x80, 0x00, 0x00, 0x21, 0x04, + 0x00, 0x20, 0x00, 0x80, 0x05, 0xa2, 0x00, 0x20, 0x48, 0x20, 0x01, 0x11, 0x20, 0x04, 0x08, 0x04, + 0x04, 0x10, 0x60, 0x83, 0x1e, 0x58, 0x40, 0x40, 0x00, 0x80, 0x12, 0x00, 0x40, 0x02, 0x21, 0x04, + 0x00, 0x20, 0x00, 0x80, 0x3f, 0x22, 0x10, 0x10, 0x28, 0x10, 0x60, 0x90, 0x20, 0x04, 0x08, 0x44, + 0x02, 0x10, 0x18, 0x8c, 0x12, 0x44, 0x20, 0x40, 0x00, 0x80, 0x0f, 0xff, 0x20, 0x02, 0x11, 0xfc, + 0x04, 0x20, 0x1f, 0xf8, 0x04, 0x12, 0x10, 0x10, 0x28, 0x08, 0x1c, 0x50, 0x10, 0x84, 0x48, 0x44, + 0x02, 0x10, 0x04, 0x90, 0x12, 0x44, 0x10, 0x40, 0x00, 0x80, 0x08, 0x90, 0x10, 0x02, 0x11, 0x04, + 0x04, 0x20, 0x00, 0x88, 0x1f, 0x92, 0x28, 0x10, 0x19, 0x68, 0x10, 0x50, 0x10, 0x84, 0x28, 0x84, + 0x01, 0x10, 0x02, 0xa0, 0x12, 0x44, 0x08, 0x40, 0x00, 0x80, 0x14, 0x90, 0x10, 0x04, 0x09, 0xfc, + 0x08, 0x20, 0x00, 0x88, 0x14, 0x92, 0x20, 0x10, 0x1a, 0x24, 0x11, 0xfc, 0x10, 0x84, 0x1b, 0xff, + 0x01, 0x10, 0x01, 0xc0, 0x12, 0x44, 0x04, 0x40, 0x1f, 0xfc, 0x14, 0x90, 0x08, 0x04, 0x08, 0x00, + 0x00, 0x20, 0x7f, 0xff, 0x14, 0x92, 0x20, 0x10, 0x0c, 0x26, 0x11, 0x04, 0x10, 0x84, 0x08, 0x04, + 0x41, 0x11, 0x00, 0x80, 0x1e, 0x7c, 0x07, 0xfc, 0x40, 0x80, 0x24, 0x90, 0x08, 0x08, 0x24, 0x51, + 0x7f, 0xfe, 0x00, 0x88, 0x1f, 0x92, 0x20, 0x10, 0x09, 0x22, 0x11, 0x04, 0x10, 0x84, 0x04, 0x04, + 0x2f, 0xf2, 0x7f, 0xff, 0x00, 0x00, 0x02, 0x00, 0x20, 0x80, 0x04, 0x90, 0x08, 0x08, 0x22, 0x8a, + 0x00, 0x20, 0x00, 0x88, 0x14, 0x92, 0x20, 0x10, 0x7e, 0xa2, 0x7d, 0xfc, 0x10, 0x84, 0x05, 0xff, + 0x10, 0x04, 0x04, 0xa0, 0x60, 0x03, 0x02, 0x00, 0x10, 0x80, 0x3c, 0x9e, 0x04, 0x10, 0x41, 0x04, + 0x00, 0x20, 0x1f, 0xf8, 0x1f, 0x92, 0x23, 0xf0, 0x08, 0xa4, 0x11, 0x04, 0x10, 0x84, 0x22, 0x20, + 0x08, 0x08, 0x04, 0x90, 0x1b, 0xec, 0x02, 0x00, 0x10, 0x80, 0x10, 0x90, 0x04, 0x10, 0x07, 0xdf, + 0x40, 0x22, 0x18, 0x80, 0x04, 0x7e, 0x10, 0x1e, 0x08, 0xa4, 0x11, 0xfc, 0x10, 0x84, 0x12, 0x20, + 0x08, 0x10, 0x08, 0x88, 0x04, 0x10, 0x01, 0x00, 0x0f, 0xfe, 0x08, 0x10, 0x04, 0x20, 0x01, 0x04, + 0x40, 0x02, 0x04, 0x40, 0x7f, 0xd0, 0x10, 0x14, 0x08, 0xa8, 0x11, 0x04, 0x10, 0x84, 0x08, 0x20, + 0x04, 0x10, 0x00, 0x88, 0x02, 0x20, 0x7f, 0xfe, 0x08, 0x80, 0x08, 0x10, 0x04, 0x40, 0x0f, 0xdf, + 0x7f, 0xfe, 0x02, 0x20, 0x04, 0x10, 0x10, 0x15, 0x78, 0x20, 0x7d, 0x04, 0x10, 0x84, 0x09, 0xfe, + 0x04, 0x20, 0x3f, 0xfe, 0x01, 0x40, 0x01, 0x00, 0x08, 0x80, 0x05, 0xf0, 0x00, 0x00, 0x09, 0x04, + 0x01, 0x00, 0x01, 0xe0, 0x1e, 0x10, 0x10, 0x19, 0x0c, 0x20, 0x01, 0xfc, 0x10, 0x04, 0x04, 0x20, + 0x00, 0x20, 0x00, 0x80, 0x00, 0x80, 0x01, 0x00, 0x08, 0x80, 0x7c, 0x18, 0x00, 0x00, 0x11, 0x04, + 0x01, 0x00, 0x01, 0x00, 0x01, 0x90, 0x00, 0x12, 0x02, 0x20, 0x00, 0x00, 0x00, 0x04, 0x04, 0x20, + 0x03, 0xe0, 0x00, 0x80, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x60, 0x81, + 0x01, 0x00, 0x00, 0x18, 0x08, 0x3f, 0x61, 0x18, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00, 0x40, 0xff, + 0x48, 0x41, 0x04, 0x18, 0x00, 0x00, 0x18, 0x0c, 0x5c, 0x06, 0x40, 0x7f, 0x02, 0x18, 0x19, 0x42, + 0x61, 0x06, 0x00, 0x04, 0x08, 0x41, 0x38, 0x88, 0x46, 0x08, 0x03, 0xc0, 0x03, 0x80, 0x23, 0x04, + 0x46, 0x23, 0x04, 0x04, 0x3f, 0xfc, 0x08, 0x04, 0x23, 0x18, 0x21, 0x90, 0x61, 0x04, 0x06, 0x24, + 0x11, 0x18, 0x3e, 0x02, 0x08, 0x81, 0x2e, 0x48, 0x21, 0x10, 0x0c, 0x00, 0x04, 0x40, 0x15, 0xf8, + 0x25, 0x15, 0x04, 0x42, 0x00, 0x04, 0x08, 0x04, 0x20, 0xa0, 0x12, 0x10, 0x38, 0x82, 0x3e, 0x14, + 0x09, 0x20, 0x22, 0x02, 0x08, 0x81, 0x28, 0x48, 0x20, 0xa0, 0x10, 0x00, 0x40, 0x20, 0x0d, 0x08, + 0x24, 0x95, 0x04, 0x22, 0x00, 0x04, 0x08, 0x44, 0x10, 0x60, 0x14, 0x10, 0x26, 0x42, 0x11, 0x18, + 0x05, 0x40, 0x22, 0x02, 0x08, 0x90, 0x2a, 0x29, 0x10, 0xc0, 0x10, 0x00, 0x20, 0x21, 0x09, 0xf8, + 0x12, 0xac, 0x05, 0x22, 0x00, 0x04, 0x08, 0x44, 0x10, 0x90, 0x0a, 0xff, 0x23, 0x42, 0x09, 0x08, + 0x03, 0x80, 0x22, 0x02, 0x08, 0x9c, 0x29, 0x29, 0x10, 0x40, 0x08, 0x30, 0x20, 0x21, 0x09, 0x08, + 0x12, 0x44, 0x3c, 0x92, 0x1f, 0xfc, 0x78, 0x84, 0x11, 0x08, 0x0a, 0x10, 0x22, 0x42, 0x7f, 0x98, + 0x7f, 0xfe, 0x22, 0x12, 0x08, 0x92, 0x2e, 0xaa, 0x1f, 0xff, 0x07, 0xd0, 0x10, 0x42, 0x09, 0xf8, + 0x0a, 0xcc, 0x06, 0x52, 0x00, 0x04, 0x0f, 0xff, 0x17, 0xf8, 0x09, 0xfe, 0x22, 0x22, 0x44, 0x14, + 0x01, 0x00, 0x3e, 0x12, 0x48, 0x92, 0x28, 0xaa, 0x10, 0x40, 0x00, 0x20, 0x10, 0x44, 0x09, 0x08, + 0x0a, 0xea, 0x05, 0x4a, 0x00, 0x04, 0x08, 0x04, 0x10, 0x00, 0x09, 0x10, 0x3e, 0x22, 0x24, 0xa4, + 0x1f, 0xf8, 0x23, 0x22, 0x28, 0x92, 0x08, 0xac, 0x10, 0x40, 0x00, 0x20, 0x00, 0x88, 0x79, 0xf8, + 0x03, 0x5a, 0x45, 0x2a, 0x00, 0x04, 0x08, 0x04, 0x11, 0xf0, 0x79, 0xfe, 0x22, 0x22, 0x15, 0xa4, + 0x11, 0x08, 0x22, 0xc2, 0x1b, 0x92, 0x3e, 0x28, 0x1f, 0xfc, 0x3f, 0x40, 0x01, 0x00, 0x00, 0x00, + 0x22, 0x4a, 0x24, 0xaa, 0x3f, 0xfc, 0x0b, 0xff, 0x11, 0x10, 0x01, 0x28, 0x22, 0x22, 0x0e, 0x44, + 0x11, 0x08, 0x22, 0x82, 0x18, 0xf2, 0x22, 0x28, 0x10, 0x04, 0x00, 0xf8, 0x01, 0x00, 0x07, 0xfe, + 0x23, 0xfa, 0x24, 0xaa, 0x01, 0x00, 0x08, 0x20, 0x1f, 0xfe, 0x01, 0x44, 0x3e, 0x22, 0x7f, 0xa4, + 0x1f, 0xf8, 0x22, 0x42, 0x08, 0x9e, 0x22, 0x28, 0x10, 0x04, 0x00, 0x80, 0x00, 0x88, 0x00, 0x20, + 0x42, 0x08, 0x1f, 0xaa, 0x05, 0x20, 0x7e, 0x20, 0x11, 0x10, 0x01, 0xfe, 0x23, 0xfe, 0x15, 0x3f, + 0x11, 0x08, 0x3e, 0x7e, 0x08, 0x92, 0x23, 0xff, 0x1f, 0xfc, 0x1f, 0x88, 0x00, 0x4a, 0x11, 0xf8, + 0x03, 0xff, 0x14, 0x7e, 0x05, 0x10, 0x08, 0x20, 0x11, 0x10, 0x11, 0x02, 0x22, 0x20, 0x15, 0x20, + 0x11, 0x08, 0x10, 0x40, 0x04, 0x90, 0x22, 0x10, 0x00, 0x00, 0x01, 0x7a, 0x01, 0xd2, 0x11, 0x28, + 0x08, 0x08, 0x14, 0x40, 0x09, 0x08, 0x09, 0xfe, 0x1f, 0xfe, 0x11, 0x02, 0x22, 0x20, 0x24, 0xa0, + 0x1f, 0xf8, 0x08, 0x40, 0x04, 0x10, 0x3e, 0x10, 0x3f, 0xff, 0x01, 0x12, 0x02, 0x04, 0x21, 0xf8, + 0x08, 0x0a, 0x14, 0x40, 0x11, 0x08, 0x08, 0x20, 0x00, 0x40, 0x21, 0xfe, 0x3e, 0x20, 0x04, 0xa0, + 0x00, 0x00, 0x08, 0x40, 0x04, 0x10, 0x00, 0x10, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x20, + 0x10, 0x0c, 0x04, 0x40, 0x01, 0x00, 0x08, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x40, 0x26, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x20, 0x09, 0x07, + 0x08, 0x30, 0x00, 0x00, 0x40, 0xff, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x11, 0xe0, + 0x5c, 0x22, 0x61, 0xc2, 0x00, 0x40, 0x03, 0xf8, 0x7f, 0xfe, 0x13, 0x0c, 0x00, 0x20, 0x48, 0x89, + 0x49, 0x11, 0x00, 0x00, 0x23, 0x00, 0x1f, 0xf8, 0x49, 0x04, 0x00, 0x00, 0x03, 0x00, 0x12, 0x12, + 0x47, 0xe2, 0x1f, 0x24, 0x00, 0x40, 0x02, 0x08, 0x01, 0x00, 0x10, 0x90, 0x00, 0x20, 0x29, 0x49, + 0x2a, 0x92, 0x00, 0x00, 0x14, 0x02, 0x10, 0x08, 0x28, 0x84, 0x00, 0x08, 0x00, 0x80, 0x2a, 0x1c, + 0x44, 0x22, 0x11, 0x18, 0x00, 0x40, 0x02, 0x08, 0x01, 0x00, 0x10, 0x60, 0x00, 0x40, 0x29, 0x48, + 0x2a, 0x54, 0x00, 0x00, 0x0d, 0x02, 0x10, 0x08, 0x19, 0x84, 0x00, 0x08, 0x00, 0x40, 0x21, 0xf0, + 0x47, 0xe2, 0x1f, 0x28, 0x00, 0x80, 0x63, 0xf8, 0x01, 0x00, 0x10, 0x40, 0x00, 0x40, 0x2a, 0x28, + 0x2a, 0x58, 0x7f, 0xfe, 0x08, 0x84, 0x10, 0x08, 0x1a, 0x44, 0x00, 0x10, 0x00, 0x20, 0x20, 0x10, + 0x44, 0x22, 0x11, 0x44, 0x00, 0x80, 0x1a, 0x08, 0x01, 0x00, 0x10, 0xa0, 0x3c, 0x40, 0x28, 0x28, + 0x2d, 0xfc, 0x00, 0x00, 0x08, 0x48, 0x10, 0x08, 0x0c, 0x44, 0x10, 0x60, 0x04, 0x20, 0x20, 0x10, + 0x47, 0xe2, 0x1f, 0x7c, 0x00, 0x80, 0x06, 0x08, 0x1f, 0xf8, 0x13, 0xfe, 0x03, 0x40, 0x09, 0xa9, + 0x08, 0x12, 0x00, 0x00, 0x08, 0x30, 0x10, 0x08, 0x7f, 0x44, 0x09, 0xa0, 0x04, 0x10, 0x20, 0x10, + 0x44, 0x22, 0x11, 0x00, 0x01, 0x20, 0x03, 0xf8, 0x20, 0x00, 0x52, 0x22, 0x00, 0xf0, 0x7d, 0x81, + 0x7d, 0x10, 0x00, 0x00, 0x0f, 0xff, 0x1f, 0xf8, 0x08, 0x44, 0x04, 0x10, 0x04, 0x10, 0x20, 0x10, + 0x5f, 0xfa, 0x7f, 0xff, 0x01, 0x10, 0x01, 0x00, 0x10, 0x3c, 0x32, 0x22, 0x00, 0x8e, 0x12, 0xff, + 0x12, 0xfc, 0x00, 0x00, 0x78, 0x20, 0x10, 0x08, 0x08, 0x44, 0x02, 0x10, 0x04, 0x10, 0x23, 0xf0, + 0x40, 0x02, 0x00, 0x00, 0x3a, 0x08, 0x7f, 0xff, 0x08, 0x44, 0x12, 0x22, 0x00, 0x80, 0x0c, 0x00, + 0x0c, 0x84, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x7f, 0xc4, 0x02, 0x08, 0x04, 0x10, 0x20, 0x1c, + 0x7e, 0x7e, 0x0f, 0xf8, 0x07, 0x84, 0x00, 0xc0, 0x04, 0x44, 0x13, 0xfe, 0x1e, 0x80, 0x08, 0xfe, + 0x08, 0x84, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x14, 0x7f, 0x01, 0x08, 0x7f, 0xfe, 0x10, 0x10, + 0x42, 0x42, 0x08, 0x08, 0x02, 0x72, 0x00, 0xa0, 0x44, 0x42, 0x08, 0x20, 0x01, 0xe8, 0x14, 0x10, + 0x14, 0xfc, 0x1f, 0xf8, 0x03, 0xfe, 0x10, 0x08, 0x12, 0x40, 0x01, 0xf8, 0x04, 0x10, 0x10, 0x10, + 0x7e, 0x7e, 0x0f, 0xf8, 0x02, 0x0e, 0x00, 0x90, 0x44, 0x42, 0x08, 0x20, 0x01, 0x1a, 0x72, 0x10, + 0x72, 0x84, 0x00, 0x00, 0x10, 0x20, 0x1f, 0xf8, 0x22, 0x40, 0x01, 0x00, 0x04, 0x10, 0x10, 0x10, + 0x42, 0x42, 0x08, 0x08, 0x04, 0x00, 0x1f, 0xf8, 0x7f, 0xfe, 0x07, 0xff, 0x01, 0x12, 0x0b, 0xff, + 0x0a, 0xfc, 0x00, 0x00, 0x10, 0x90, 0x02, 0x00, 0x7f, 0x70, 0x01, 0x00, 0x04, 0x10, 0x13, 0xfc, + 0x7e, 0x7e, 0x0f, 0xf8, 0x04, 0x00, 0x00, 0x84, 0x01, 0x00, 0x04, 0x20, 0x01, 0x04, 0x08, 0x10, + 0x08, 0x20, 0x00, 0x00, 0x20, 0x88, 0x01, 0x00, 0x04, 0x0c, 0x01, 0x00, 0x04, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, + 0x08, 0x10, 0x00, 0x00, 0x01, 0x08, 0x01, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, + 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x22, 0x07, 0x00, 0x80, 0x10, 0x01, 0x00, 0x00, + 0x00, 0x4c, 0x03, 0x03, 0x3c, 0x04, 0x01, 0x01, 0x53, 0x03, 0x00, 0x00, 0x20, 0x00, 0x0b, 0xc1, + 0x21, 0xc0, 0x7f, 0xff, 0x3f, 0xfe, 0x00, 0x80, 0x21, 0x09, 0x00, 0x80, 0x08, 0x43, 0x01, 0x00, + 0x02, 0x22, 0x3e, 0xc4, 0x03, 0x18, 0x01, 0x82, 0x48, 0xcc, 0x00, 0x00, 0x21, 0xfc, 0x04, 0x3e, + 0x12, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x20, 0x89, 0x00, 0x80, 0x05, 0xa5, 0x01, 0x00, + 0x61, 0x12, 0x22, 0x28, 0x00, 0xe0, 0x61, 0x42, 0x24, 0x30, 0x01, 0xf8, 0x11, 0x04, 0x04, 0x22, + 0x14, 0x80, 0x1f, 0xf8, 0x70, 0x87, 0x00, 0x80, 0x28, 0x88, 0x40, 0x81, 0x04, 0x55, 0x01, 0x00, + 0x10, 0x92, 0x22, 0x10, 0x0f, 0x40, 0x1f, 0x24, 0x24, 0x28, 0x02, 0x00, 0x11, 0x04, 0x04, 0x24, + 0x08, 0x80, 0x00, 0x80, 0x0f, 0xf8, 0x00, 0x80, 0x34, 0x48, 0x27, 0xf2, 0x62, 0x58, 0x02, 0x60, + 0x1a, 0x4a, 0x22, 0x28, 0x04, 0x20, 0x11, 0x14, 0x12, 0x48, 0x04, 0x00, 0x0f, 0xff, 0x05, 0xfc, + 0x08, 0xfc, 0x3f, 0xfe, 0x02, 0xa0, 0x7f, 0xff, 0x24, 0x48, 0x10, 0x84, 0x1a, 0x48, 0x32, 0x10, + 0x15, 0x4a, 0x3e, 0x48, 0x02, 0x20, 0x11, 0x08, 0x12, 0x44, 0x04, 0x40, 0x09, 0x04, 0x05, 0x24, + 0x08, 0x80, 0x01, 0x00, 0x7f, 0xff, 0x00, 0x80, 0x24, 0x48, 0x08, 0x88, 0x16, 0x4c, 0x0c, 0x08, + 0x10, 0xfe, 0x00, 0x44, 0x7f, 0xff, 0x11, 0x18, 0x0b, 0xfc, 0x04, 0x20, 0x20, 0xd8, 0x3d, 0x24, + 0x08, 0x80, 0x71, 0x00, 0x01, 0x00, 0x00, 0x80, 0x27, 0xff, 0x04, 0x90, 0x12, 0x4c, 0x07, 0x08, + 0x10, 0x80, 0x01, 0xfc, 0x01, 0x00, 0x1f, 0x14, 0x0a, 0x00, 0x04, 0x20, 0x22, 0x20, 0x21, 0x24, + 0x00, 0x80, 0x1f, 0x3e, 0x0f, 0xf8, 0x00, 0x80, 0x24, 0x00, 0x02, 0xa0, 0x12, 0x52, 0x04, 0xf0, + 0x17, 0xff, 0x3e, 0x00, 0x1f, 0xf8, 0x11, 0x14, 0x22, 0x7c, 0x04, 0x20, 0x41, 0x50, 0x21, 0xfc, + 0x7f, 0xff, 0x11, 0x22, 0x08, 0x08, 0x3f, 0xfe, 0x28, 0x00, 0x02, 0xa0, 0x13, 0xd2, 0x08, 0x00, + 0x10, 0x00, 0x01, 0x03, 0x12, 0x48, 0x11, 0x22, 0x22, 0x44, 0x7c, 0x20, 0x08, 0x88, 0x3c, 0x20, + 0x00, 0x80, 0x1f, 0x22, 0x0f, 0xf8, 0x00, 0x80, 0x30, 0xfe, 0x01, 0xc0, 0x12, 0x12, 0x08, 0x20, + 0x7e, 0xfc, 0x3e, 0x85, 0x12, 0x48, 0x1f, 0x22, 0x23, 0xff, 0x07, 0xe0, 0x08, 0xfc, 0x04, 0x21, + 0x00, 0x80, 0x11, 0x22, 0x08, 0x08, 0x00, 0x80, 0x29, 0x01, 0x7f, 0xff, 0x7e, 0x10, 0x00, 0xc0, + 0x10, 0x84, 0x00, 0x45, 0x1f, 0xf8, 0x11, 0x22, 0x42, 0x44, 0x04, 0x3c, 0x10, 0x80, 0x07, 0xfa, + 0x00, 0x80, 0x1f, 0x22, 0x0f, 0xf8, 0x00, 0x80, 0x25, 0x01, 0x00, 0x80, 0x13, 0xff, 0x00, 0x00, + 0x10, 0xfc, 0x7f, 0x44, 0x02, 0x40, 0x11, 0x22, 0x0a, 0x44, 0x04, 0x25, 0x02, 0xa0, 0x04, 0x8c, + 0x1f, 0xfc, 0x11, 0x22, 0x02, 0x20, 0x0f, 0xc0, 0x25, 0xff, 0x00, 0x80, 0x10, 0x12, 0x00, 0x00, + 0x10, 0x84, 0x00, 0x44, 0x02, 0x40, 0x11, 0x7e, 0x0b, 0xff, 0x04, 0x29, 0x7f, 0xff, 0x7c, 0x50, + 0x00, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0x00, 0x30, 0x3c, 0x10, 0x00, 0x80, 0x10, 0x12, 0x00, 0x00, + 0x10, 0xfc, 0x3e, 0x7c, 0x7f, 0xfe, 0x7f, 0x80, 0x08, 0x20, 0x00, 0x22, 0x02, 0x20, 0x00, 0x40, + 0x00, 0x80, 0x00, 0x00, 0x02, 0x20, 0x00, 0x08, 0x00, 0x10, 0x00, 0x80, 0x10, 0x14, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x06, 0x40, 0x7f, 0x08, 0x1f, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x43, 0x01, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x80, + 0x11, 0xe0, 0x01, 0x02, 0x21, 0x80, 0x08, 0x21, 0x23, 0xff, 0x08, 0x80, 0x60, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x20, 0xc3, 0x07, 0x00, 0x48, 0x21, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x80, 0x04, 0x60, + 0x12, 0x12, 0x00, 0x82, 0x13, 0x00, 0x08, 0x41, 0x20, 0x20, 0x08, 0xb0, 0x18, 0x04, 0x00, 0x08, + 0x00, 0x00, 0x10, 0x25, 0x08, 0xc0, 0x24, 0x22, 0x00, 0x80, 0x07, 0xf8, 0x00, 0x80, 0x08, 0x10, + 0x2a, 0x1c, 0x00, 0x82, 0x15, 0xfe, 0x08, 0x41, 0x3c, 0x20, 0x08, 0x88, 0x04, 0x08, 0x3f, 0xf8, + 0x00, 0x00, 0x08, 0x19, 0x10, 0x20, 0x22, 0x24, 0x00, 0x80, 0x08, 0x04, 0x01, 0x00, 0x08, 0x08, + 0x21, 0xf0, 0x3e, 0x42, 0x09, 0x10, 0x08, 0x40, 0x23, 0xfe, 0x08, 0x88, 0x02, 0x10, 0x00, 0x08, + 0x00, 0x02, 0x08, 0x0c, 0x20, 0x20, 0x11, 0x28, 0x1f, 0xfc, 0x10, 0x00, 0x01, 0x00, 0x08, 0x00, + 0x20, 0x10, 0x22, 0x42, 0x09, 0x10, 0x08, 0x40, 0x22, 0x20, 0x08, 0x88, 0x01, 0x20, 0x00, 0x08, + 0x00, 0x04, 0x04, 0x12, 0x20, 0x10, 0x11, 0x28, 0x00, 0x80, 0x10, 0x00, 0x02, 0x38, 0x08, 0x00, + 0x20, 0x10, 0x22, 0x7e, 0x09, 0xfc, 0x48, 0x40, 0x22, 0x20, 0x0f, 0xf8, 0x00, 0xc0, 0x00, 0x08, + 0x40, 0x08, 0x4d, 0xff, 0x20, 0x10, 0x00, 0xb0, 0x00, 0x80, 0x10, 0x00, 0x02, 0x04, 0x08, 0x00, + 0x20, 0x10, 0x22, 0x42, 0x09, 0x10, 0x28, 0x60, 0x25, 0x2e, 0x40, 0x82, 0x00, 0x80, 0x00, 0x08, + 0x20, 0x10, 0x32, 0x20, 0x20, 0x12, 0x00, 0xb8, 0x3f, 0xfe, 0x00, 0x00, 0x74, 0x02, 0x08, 0x00, + 0x20, 0x10, 0x22, 0x42, 0x39, 0x10, 0x18, 0x50, 0x28, 0x92, 0x40, 0x82, 0x00, 0x40, 0x00, 0x08, + 0x10, 0x20, 0x22, 0x20, 0x10, 0x14, 0x07, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x02, 0x08, 0x00, + 0x20, 0x10, 0x3e, 0x42, 0x01, 0xfc, 0x08, 0x48, 0x30, 0x90, 0x7f, 0xfe, 0x00, 0x40, 0x00, 0x08, + 0x08, 0x40, 0x12, 0xfe, 0x10, 0x18, 0x20, 0x24, 0x0f, 0xf8, 0x00, 0x00, 0x05, 0x82, 0x08, 0x20, + 0x13, 0xf0, 0x22, 0x7e, 0x05, 0x10, 0x08, 0x44, 0x2b, 0xff, 0x04, 0x20, 0x00, 0x20, 0x00, 0x08, + 0x04, 0x80, 0x1e, 0x20, 0x08, 0x18, 0x20, 0x22, 0x08, 0x08, 0x00, 0x00, 0x08, 0x7c, 0x08, 0x28, + 0x10, 0x1e, 0x22, 0x42, 0x03, 0x10, 0x04, 0x44, 0x24, 0x20, 0x04, 0x10, 0x00, 0x28, 0x00, 0x08, + 0x03, 0x18, 0x11, 0xff, 0x04, 0x14, 0x41, 0xe2, 0x0f, 0xf8, 0x00, 0x00, 0x08, 0x00, 0x08, 0x48, + 0x10, 0x15, 0x22, 0x42, 0x11, 0xfe, 0x04, 0x42, 0x24, 0x20, 0x08, 0x10, 0x1f, 0xea, 0x3f, 0xfc, + 0x00, 0x24, 0x10, 0x22, 0x72, 0x15, 0x00, 0x00, 0x08, 0x08, 0x00, 0xfa, 0x10, 0x10, 0x08, 0x10, + 0x10, 0x15, 0x22, 0x42, 0x11, 0x10, 0x02, 0x42, 0x25, 0xfc, 0x3f, 0xfe, 0x00, 0x12, 0x00, 0x05, + 0x00, 0x24, 0x10, 0x22, 0x0f, 0x09, 0x08, 0x10, 0x0f, 0xf8, 0x07, 0x0a, 0x10, 0x10, 0x08, 0x00, + 0x10, 0x15, 0x3e, 0x7e, 0x20, 0x88, 0x02, 0x40, 0x3c, 0x20, 0x00, 0x80, 0x00, 0x04, 0x00, 0x09, + 0x00, 0x18, 0x7f, 0x24, 0x01, 0x02, 0x08, 0x20, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x02, 0x40, 0x00, 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0xc0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x7e, 0x26, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x30, 0x3f, 0xff, 0x07, 0xf8, 0x20, 0x60, 0x01, 0x80, 0x06, 0x00, 0x0c, 0x00, + 0x21, 0x80, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x5f, 0xff, 0x40, 0x02, 0x00, 0x00, + 0x02, 0x10, 0x30, 0x08, 0x01, 0x20, 0x04, 0x08, 0x10, 0x10, 0x20, 0x80, 0x01, 0x00, 0x03, 0x00, + 0x13, 0x00, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x41, 0x04, 0x20, 0x40, 0x47, 0xe2, 0x00, 0x00, + 0x02, 0x10, 0x4d, 0x04, 0x01, 0x10, 0x44, 0x08, 0x08, 0x08, 0x10, 0x82, 0x00, 0x80, 0x00, 0x80, + 0x15, 0x00, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x40, 0x88, 0x20, 0x40, 0x44, 0x22, 0x00, 0x02, + 0x04, 0x10, 0x42, 0x04, 0x02, 0x10, 0x24, 0x08, 0x04, 0x08, 0x08, 0x82, 0x00, 0x40, 0x00, 0x40, + 0x09, 0x00, 0x3e, 0x44, 0x00, 0x00, 0x00, 0x00, 0x20, 0x50, 0x17, 0xfc, 0x44, 0x22, 0x00, 0x04, + 0x08, 0x10, 0x42, 0x02, 0x07, 0xf8, 0x14, 0x08, 0x02, 0x08, 0x08, 0x84, 0x00, 0x40, 0x00, 0x20, + 0x09, 0x00, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x20, 0x50, 0x10, 0x40, 0x47, 0xe2, 0x40, 0x08, + 0x3f, 0xfe, 0x25, 0x02, 0x04, 0x08, 0x0c, 0x08, 0x02, 0x08, 0x04, 0x84, 0x20, 0x20, 0x00, 0x10, + 0x09, 0xf8, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x1f, 0xfe, 0x44, 0x22, 0x20, 0x10, + 0x00, 0x10, 0x29, 0x02, 0x04, 0x08, 0x07, 0xf8, 0x01, 0x08, 0x04, 0x88, 0x10, 0x20, 0x00, 0x10, + 0x09, 0x00, 0x3e, 0x44, 0x00, 0x00, 0x00, 0x00, 0x14, 0x20, 0x10, 0x40, 0x47, 0xe2, 0x10, 0x20, + 0x00, 0x10, 0x18, 0x84, 0x67, 0xf9, 0x04, 0x00, 0x01, 0x08, 0x04, 0x90, 0x08, 0x20, 0x00, 0x08, + 0x01, 0x00, 0x22, 0x44, 0x00, 0x00, 0x7f, 0xff, 0x02, 0x24, 0x10, 0x40, 0x40, 0x02, 0x08, 0x40, + 0x7f, 0xff, 0x18, 0x84, 0x10, 0x02, 0x02, 0x00, 0x01, 0x08, 0x00, 0x80, 0x08, 0x20, 0x10, 0x08, + 0x01, 0x00, 0x22, 0x44, 0x00, 0x00, 0x00, 0x02, 0x02, 0x22, 0x17, 0xfc, 0x7e, 0x7e, 0x04, 0x88, + 0x00, 0x80, 0x16, 0x88, 0x0f, 0xfc, 0x02, 0x00, 0x01, 0x08, 0x00, 0x80, 0x04, 0x20, 0x11, 0x04, + 0x1f, 0xf8, 0x3e, 0x44, 0x00, 0x00, 0x00, 0x00, 0x11, 0x21, 0x10, 0x40, 0x42, 0x42, 0x03, 0x0a, + 0x00, 0x80, 0x11, 0xf0, 0x14, 0x0a, 0x02, 0x00, 0x3f, 0xfc, 0x3f, 0xfe, 0x07, 0xfe, 0x11, 0x04, + 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xff, 0x1f, 0xff, 0x42, 0x42, 0x00, 0x12, + 0x00, 0x80, 0x10, 0x40, 0x22, 0x11, 0x7f, 0xfe, 0x01, 0x05, 0x00, 0x80, 0x04, 0x00, 0x21, 0x04, + 0x40, 0x02, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x04, + 0x1f, 0xfc, 0x10, 0x40, 0x01, 0x18, 0x01, 0x00, 0x01, 0x09, 0x00, 0x80, 0x04, 0x00, 0x02, 0x00, + 0x7f, 0xfe, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x1f, 0xfc, 0x42, 0x42, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x40, 0x0f, 0x24, 0x01, 0x00, 0x01, 0x02, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x84, 0x7e, 0x7e, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x84, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x01, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x04, 0x01, 0x70, 0x1f, 0x01, 0x80, + 0x38, 0x00, 0x0c, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x18, 0x00, 0x20, 0x02, 0x06, 0x00, 0x04, 0x01, 0x0c, 0x21, 0x00, 0x60, + 0x06, 0x00, 0x02, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x20, 0x40, 0x83, + 0x07, 0xf8, 0x00, 0x80, 0x06, 0x00, 0x10, 0x04, 0x01, 0x00, 0x45, 0xe2, 0x02, 0x21, 0x00, 0x10, + 0x01, 0x00, 0x01, 0x00, 0x08, 0x08, 0x01, 0xc0, 0x00, 0x40, 0x7f, 0xfe, 0x07, 0xff, 0x20, 0x84, + 0x08, 0x00, 0x00, 0x80, 0x01, 0x00, 0x08, 0x08, 0x00, 0x80, 0x24, 0x5e, 0x01, 0x20, 0x00, 0x08, + 0x00, 0x80, 0x01, 0x00, 0x48, 0x08, 0x00, 0x30, 0x00, 0x40, 0x00, 0x80, 0x04, 0x20, 0x10, 0x88, + 0x10, 0x00, 0x00, 0x80, 0x00, 0x84, 0x04, 0x10, 0x00, 0x40, 0x14, 0x42, 0x01, 0x20, 0x00, 0x04, + 0x00, 0x40, 0x00, 0x80, 0x28, 0x08, 0x00, 0x08, 0x00, 0x80, 0x00, 0x80, 0x04, 0x20, 0x08, 0x90, + 0x10, 0x00, 0x00, 0x80, 0x00, 0x48, 0x02, 0x20, 0x00, 0x40, 0x14, 0xa4, 0x07, 0xf8, 0x10, 0x04, + 0x00, 0x20, 0x00, 0x80, 0x18, 0x08, 0x00, 0x04, 0x01, 0x00, 0x00, 0x80, 0x3d, 0xfc, 0x04, 0xa0, + 0x10, 0x00, 0x00, 0x88, 0x00, 0x30, 0x02, 0x20, 0x20, 0x20, 0x0c, 0xa4, 0x04, 0x08, 0x08, 0x04, + 0x00, 0xd0, 0x00, 0x80, 0x08, 0x08, 0x00, 0x02, 0x02, 0x00, 0x00, 0x80, 0x21, 0x24, 0x04, 0xa0, + 0x10, 0x00, 0x00, 0x88, 0x00, 0x20, 0x01, 0x40, 0x10, 0x20, 0x0d, 0x28, 0x04, 0x08, 0x06, 0x08, + 0x33, 0x10, 0x7f, 0xfc, 0x04, 0x08, 0x00, 0x02, 0x04, 0x00, 0x00, 0x80, 0x21, 0x24, 0x02, 0xc0, + 0x1e, 0x00, 0x00, 0x90, 0x00, 0x50, 0x01, 0x40, 0x08, 0x20, 0x06, 0x20, 0x07, 0xf8, 0x03, 0xf0, + 0x08, 0x08, 0x00, 0x80, 0x05, 0xff, 0x00, 0x02, 0x04, 0x00, 0x00, 0x80, 0x21, 0xfc, 0x02, 0xe0, + 0x11, 0xc0, 0x00, 0xa0, 0x01, 0x90, 0x00, 0x80, 0x08, 0x20, 0x7f, 0x90, 0x04, 0x08, 0x01, 0x00, + 0x04, 0x08, 0x00, 0x80, 0x22, 0x00, 0x78, 0x04, 0x02, 0x08, 0x00, 0x80, 0x3d, 0x24, 0x7e, 0xd0, + 0x10, 0x30, 0x00, 0xc0, 0x06, 0x10, 0x00, 0x80, 0x04, 0x20, 0x04, 0x10, 0x04, 0x08, 0x00, 0x80, + 0x02, 0x04, 0x00, 0x80, 0x12, 0x00, 0x07, 0x18, 0x01, 0x0a, 0x1f, 0xf8, 0x05, 0x24, 0x00, 0x88, + 0x10, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00, 0x80, 0x07, 0xfc, 0x04, 0x10, 0x07, 0xf8, 0x00, 0x40, + 0x01, 0xfc, 0x1f, 0x80, 0x08, 0x00, 0x00, 0xe0, 0x00, 0x92, 0x00, 0x00, 0x05, 0xfc, 0x00, 0x84, + 0x10, 0x0a, 0x00, 0x80, 0x00, 0x08, 0x00, 0x80, 0x04, 0x05, 0x04, 0x10, 0x04, 0x08, 0x00, 0x20, + 0x01, 0x05, 0x00, 0xe0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x05, 0x28, 0x00, 0x84, + 0x10, 0x12, 0x00, 0x80, 0x00, 0x08, 0x00, 0x80, 0x04, 0x09, 0x3c, 0x10, 0x04, 0x08, 0x07, 0xe0, + 0x01, 0x09, 0x00, 0x10, 0x04, 0xfe, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x7d, 0x24, 0x00, 0x80, + 0x10, 0x04, 0x7f, 0xff, 0x00, 0x08, 0x00, 0x80, 0x04, 0x02, 0x06, 0x10, 0x07, 0xf8, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x02, 0x44, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x1c, 0x00, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x20, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x07, 0xf8, 0x00, 0xc0, 0x00, 0x00, 0x03, 0x00, 0x00, 0xc0, + 0x00, 0xc0, 0x00, 0x00, 0x06, 0x00, 0x10, 0x04, 0x03, 0x00, 0x0f, 0xf0, 0x00, 0x20, 0x40, 0x02, + 0x01, 0x00, 0x00, 0x08, 0x11, 0x30, 0x08, 0x00, 0x18, 0x30, 0x00, 0xfc, 0x00, 0xc0, 0x00, 0x20, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1f, 0xfc, 0x00, 0x80, 0x10, 0x00, 0x00, 0x20, 0x20, 0x02, + 0x00, 0x80, 0x3f, 0xf8, 0x11, 0xc0, 0x10, 0x00, 0x24, 0x08, 0x01, 0x00, 0x00, 0x20, 0x21, 0x92, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10, 0x04, 0x00, 0x80, 0x20, 0x00, 0x00, 0x40, 0x10, 0x02, + 0x00, 0x80, 0x00, 0x08, 0x0f, 0x00, 0x10, 0x00, 0x22, 0x04, 0x02, 0x00, 0x00, 0x10, 0x10, 0x8a, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x04, 0x00, 0x40, 0x20, 0x00, 0x00, 0x80, 0x10, 0x04, + 0x00, 0x40, 0x00, 0x08, 0x01, 0x00, 0x08, 0x00, 0x22, 0x04, 0x02, 0x00, 0x00, 0x08, 0x08, 0x84, + 0x00, 0x20, 0x00, 0x38, 0x00, 0x20, 0x10, 0x04, 0x00, 0x40, 0x20, 0x00, 0x03, 0x40, 0x08, 0x04, + 0x00, 0x40, 0x00, 0x08, 0x01, 0x00, 0x04, 0x00, 0x12, 0x04, 0x02, 0x20, 0x00, 0x08, 0x04, 0x88, + 0x00, 0x40, 0x40, 0xc4, 0x00, 0x20, 0x10, 0x04, 0x00, 0x40, 0x20, 0x00, 0x0c, 0x20, 0x08, 0x08, + 0x00, 0x40, 0x00, 0x08, 0x01, 0x00, 0x02, 0x00, 0x0e, 0x18, 0x02, 0x10, 0x10, 0x04, 0x04, 0x90, + 0x01, 0x80, 0x23, 0x02, 0x00, 0x10, 0x10, 0x04, 0x00, 0x40, 0x3c, 0x00, 0x00, 0x10, 0x08, 0x08, + 0x3f, 0xfe, 0x00, 0x08, 0x01, 0xe0, 0x01, 0x80, 0x03, 0xe0, 0x02, 0x08, 0x10, 0x04, 0x00, 0x80, + 0x06, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x10, 0x04, 0x00, 0x40, 0x23, 0x80, 0x00, 0x08, 0x04, 0x10, + 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x02, 0x60, 0x02, 0x00, 0x3e, 0x04, 0x10, 0x04, 0x7f, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x04, 0x3f, 0xfe, 0x20, 0x60, 0x00, 0x04, 0x04, 0x10, + 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x02, 0x18, 0x02, 0x01, 0x03, 0xe2, 0x10, 0x04, 0x08, 0x80, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x10, 0x04, 0x00, 0x40, 0x20, 0x0c, 0x00, 0x04, 0x04, 0x20, + 0x00, 0x08, 0x00, 0x08, 0x01, 0x00, 0x04, 0x08, 0x3e, 0x02, 0x02, 0x1e, 0x1f, 0xfc, 0x08, 0x80, + 0x00, 0x60, 0x00, 0x00, 0x3f, 0xf8, 0x1f, 0xfc, 0x00, 0x40, 0x20, 0x12, 0x3f, 0xfe, 0x04, 0x4c, + 0x0f, 0xea, 0x3f, 0xf8, 0x00, 0x00, 0x04, 0x0a, 0x03, 0xc4, 0x02, 0x00, 0x00, 0x80, 0x08, 0xfc, + 0x01, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x40, 0x20, 0x12, 0x00, 0x00, 0x00, 0x12, + 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x08, 0x12, 0x02, 0x18, 0x02, 0x00, 0x00, 0x80, 0x08, 0x80, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x40, 0x20, 0x0c, 0x00, 0x00, 0x00, 0x12, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x02, 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x64, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x03, 0x07, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x1a, 0x30, 0x00, 0xc0, 0x00, 0xe0, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x60, + 0x03, 0xc0, 0x00, 0x1c, 0x70, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10, 0x04, 0x04, 0xc0, + 0x01, 0x00, 0x01, 0x00, 0x15, 0x50, 0x00, 0x20, 0x01, 0x10, 0x03, 0x00, 0x40, 0x02, 0x10, 0x10, + 0x00, 0x30, 0x20, 0x20, 0x0c, 0x84, 0x01, 0xf8, 0x3f, 0xf8, 0x00, 0x80, 0x08, 0x08, 0x04, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x31, 0x90, 0x10, 0x10, 0x02, 0x08, 0x00, 0x80, 0x20, 0x02, 0x08, 0x08, + 0x00, 0x08, 0x10, 0x40, 0x02, 0x88, 0x02, 0x00, 0x00, 0x40, 0x00, 0x80, 0x04, 0x10, 0x04, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x39, 0x7e, 0x10, 0x10, 0x04, 0x04, 0x00, 0x40, 0x10, 0x02, 0x04, 0x08, + 0x00, 0x04, 0x08, 0x40, 0x31, 0x90, 0x04, 0x00, 0x00, 0x40, 0x00, 0x80, 0x02, 0x20, 0x04, 0x08, + 0x01, 0x00, 0x01, 0x00, 0x56, 0x90, 0x28, 0x10, 0x04, 0x04, 0x00, 0x20, 0x10, 0x04, 0x02, 0x08, + 0x08, 0x04, 0x04, 0x40, 0x0c, 0xa0, 0x04, 0x40, 0x00, 0x40, 0x00, 0x80, 0x02, 0x20, 0x04, 0x04, + 0x01, 0x00, 0x01, 0x00, 0x12, 0xfc, 0x20, 0x10, 0x04, 0x04, 0x00, 0x10, 0x08, 0x04, 0x02, 0x08, + 0x0c, 0x04, 0x03, 0x80, 0x02, 0xb0, 0x04, 0x20, 0x00, 0x40, 0x3f, 0xfe, 0x01, 0x40, 0x04, 0x04, + 0x00, 0x80, 0x01, 0x00, 0x7c, 0x90, 0x20, 0x10, 0x04, 0x00, 0x00, 0x10, 0x08, 0x08, 0x01, 0x08, + 0x0b, 0x08, 0x01, 0x00, 0x31, 0xc8, 0x04, 0x20, 0x0f, 0xc0, 0x20, 0x82, 0x01, 0x40, 0x04, 0x00, + 0x00, 0x40, 0x01, 0x00, 0x13, 0xfc, 0x20, 0x10, 0x3f, 0x80, 0x00, 0x08, 0x08, 0x08, 0x01, 0x08, + 0x04, 0xf0, 0x00, 0x80, 0x0d, 0x44, 0x04, 0x20, 0x00, 0x00, 0x20, 0x82, 0x00, 0x80, 0x04, 0x00, + 0x04, 0x20, 0x01, 0x00, 0x12, 0x14, 0x20, 0x10, 0x04, 0x60, 0x00, 0x08, 0x04, 0x10, 0x01, 0x08, + 0x04, 0x00, 0x00, 0x40, 0x02, 0x04, 0x7c, 0x20, 0x00, 0x00, 0x20, 0x82, 0x00, 0x80, 0x04, 0x00, + 0x08, 0x10, 0x01, 0x00, 0x79, 0x14, 0x23, 0xf0, 0x02, 0x00, 0x00, 0x04, 0x04, 0x10, 0x01, 0x08, + 0x04, 0x00, 0x00, 0x20, 0x1f, 0xf0, 0x07, 0xe0, 0x00, 0x00, 0x20, 0x82, 0x7f, 0xff, 0x04, 0x00, + 0x08, 0x10, 0x01, 0x80, 0x25, 0xff, 0x10, 0x1e, 0x02, 0x00, 0x00, 0x04, 0x04, 0x28, 0x3f, 0xf8, + 0x02, 0x00, 0x0f, 0xf0, 0x40, 0x02, 0x04, 0x3e, 0x00, 0x00, 0x20, 0x82, 0x00, 0x80, 0x04, 0x00, + 0x08, 0x10, 0x01, 0x80, 0x28, 0x94, 0x10, 0x10, 0x1f, 0xc0, 0x3f, 0xfc, 0x04, 0x4a, 0x01, 0x00, + 0x3f, 0xf0, 0x00, 0x00, 0x40, 0x02, 0x04, 0x20, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x80, 0x04, 0x00, + 0x04, 0x20, 0x01, 0x80, 0x1b, 0xfc, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x12, 0x01, 0x00, + 0x02, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0x04, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x04, 0x00, + 0x03, 0xc0, 0x01, 0x80, 0x10, 0x10, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, + 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x03, 0xc0, 0x20, 0x18, 0x00, 0x04, 0x7f, 0xff, 0x00, 0xe0, 0x08, 0x00, 0x07, 0xf0, 0x00, 0x40, + 0x00, 0xf0, 0x00, 0xe0, 0x00, 0x80, 0x03, 0x00, 0x00, 0x60, 0x30, 0x00, 0x20, 0x7e, 0x02, 0x00, + 0x0c, 0x00, 0x20, 0x24, 0x00, 0x04, 0x00, 0x80, 0x01, 0x00, 0x08, 0x38, 0x00, 0x10, 0x00, 0x40, + 0x03, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x80, 0x18, 0x18, 0x0c, 0x00, 0x20, 0x80, 0x02, 0x00, + 0x10, 0x00, 0x10, 0x42, 0x3e, 0x04, 0x00, 0x80, 0x02, 0x00, 0x48, 0x46, 0x00, 0x10, 0x00, 0x80, + 0x04, 0x00, 0x18, 0x20, 0x00, 0x80, 0x00, 0x40, 0x25, 0x04, 0x02, 0x00, 0x20, 0x80, 0x02, 0x00, + 0x10, 0x00, 0x10, 0x41, 0x09, 0xf8, 0x00, 0x80, 0x02, 0x00, 0x28, 0x44, 0x00, 0x10, 0x00, 0x80, + 0x08, 0x00, 0x04, 0x20, 0x00, 0x80, 0x00, 0x20, 0x23, 0x02, 0x01, 0x00, 0x10, 0x00, 0x02, 0x08, + 0x08, 0x30, 0x08, 0x40, 0x04, 0x08, 0x00, 0x80, 0x02, 0x00, 0x18, 0x3c, 0x07, 0xf0, 0x19, 0x20, + 0x08, 0x00, 0x02, 0x20, 0x00, 0x80, 0x00, 0x20, 0x24, 0x82, 0x00, 0x80, 0x10, 0x00, 0x02, 0x10, + 0x07, 0xd0, 0x0c, 0x40, 0x04, 0x10, 0x00, 0x80, 0x01, 0x00, 0x18, 0x04, 0x00, 0x10, 0x07, 0x10, + 0x04, 0x18, 0x01, 0x20, 0x00, 0x80, 0x04, 0x10, 0x14, 0x82, 0x00, 0x40, 0x10, 0x00, 0x02, 0x60, + 0x00, 0x20, 0x06, 0x40, 0x02, 0x10, 0x00, 0x80, 0x00, 0x80, 0x08, 0x04, 0x00, 0x10, 0x01, 0xc8, + 0x03, 0xe8, 0x00, 0xa0, 0x30, 0x80, 0x0a, 0x10, 0x0c, 0x44, 0x20, 0x40, 0x08, 0x00, 0x03, 0x80, + 0x00, 0x20, 0x05, 0x80, 0x02, 0x20, 0x00, 0x80, 0x3f, 0xc0, 0x0c, 0x04, 0x00, 0x10, 0x01, 0x38, + 0x00, 0x10, 0x00, 0xa0, 0x0c, 0x80, 0x08, 0x10, 0x04, 0x48, 0x10, 0x20, 0x08, 0xe0, 0x02, 0x00, + 0x3f, 0x40, 0x02, 0x00, 0x02, 0x00, 0x00, 0xfc, 0x04, 0x3c, 0x0a, 0x04, 0x07, 0xf0, 0x02, 0x00, + 0x00, 0x20, 0x00, 0x60, 0x03, 0x80, 0x08, 0x10, 0x03, 0xf0, 0x08, 0x20, 0x08, 0x1c, 0x02, 0x00, + 0x00, 0xf8, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x09, 0x04, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x20, 0x00, 0x20, 0x00, 0x80, 0x08, 0x10, 0x02, 0x40, 0x04, 0x10, 0x08, 0x00, 0x02, 0x08, + 0x00, 0x80, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x78, 0x88, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x1f, 0xfe, 0x00, 0x40, 0x08, 0x10, 0x02, 0x00, 0x02, 0x10, 0x04, 0x08, 0x02, 0x0a, + 0x1f, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x80, 0x0c, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0xf0, 0x00, 0x20, 0x00, 0x20, 0x04, 0x10, 0x1f, 0x80, 0x03, 0xf4, 0x3f, 0x0a, 0x02, 0x12, + 0x01, 0x70, 0x01, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x8c, 0x00, 0x20, 0x00, 0x10, 0x04, 0x10, 0x02, 0x60, 0x01, 0x05, 0x04, 0xd2, 0x02, 0x04, + 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x07, 0xf0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x20, 0x00, 0x10, 0x04, 0x10, 0x02, 0x00, 0x01, 0x09, 0x04, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x70, 0x20, 0x06, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, + 0x08, 0x00, 0x20, 0x00, 0x06, 0x00, 0x00, 0x20, 0x1c, 0x00, 0x18, 0x00, 0x1e, 0x00, 0x00, 0x80, + 0x08, 0x08, 0x20, 0x02, 0x04, 0x00, 0x00, 0x80, 0x03, 0x00, 0x03, 0x00, 0x00, 0x20, 0x06, 0x00, + 0x08, 0x60, 0x10, 0x60, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x06, 0x00, 0x21, 0x04, 0x00, 0x80, + 0x04, 0x08, 0x20, 0x02, 0x44, 0x0c, 0x00, 0x40, 0x00, 0x80, 0x00, 0x80, 0x00, 0x20, 0x01, 0x00, + 0x08, 0x18, 0x08, 0x50, 0x00, 0x80, 0x00, 0x40, 0x00, 0xc0, 0x01, 0x00, 0x20, 0x98, 0x00, 0x80, + 0x04, 0x08, 0x20, 0x02, 0x24, 0x12, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x80, + 0x48, 0x04, 0x08, 0x48, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x80, 0x30, 0xe0, 0x00, 0x80, + 0x02, 0x08, 0x27, 0xf2, 0x14, 0x11, 0x03, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, + 0x28, 0x04, 0x04, 0x44, 0x00, 0x40, 0x3c, 0x40, 0x00, 0x10, 0x00, 0x40, 0x0f, 0x80, 0x0c, 0x80, + 0x02, 0x08, 0x24, 0x12, 0x0c, 0x10, 0x04, 0xc0, 0x00, 0x20, 0x00, 0x20, 0x00, 0x80, 0x00, 0x20, + 0x18, 0x02, 0x04, 0x42, 0x00, 0x40, 0x03, 0x40, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x03, 0x80, + 0x01, 0x08, 0x24, 0x12, 0x0c, 0x10, 0x04, 0x40, 0x00, 0x10, 0x08, 0x10, 0x01, 0x00, 0x10, 0x10, + 0x08, 0x02, 0x04, 0x42, 0x00, 0x40, 0x00, 0xf0, 0x00, 0x04, 0x00, 0x20, 0x00, 0x80, 0x00, 0x80, + 0x01, 0x08, 0x24, 0x12, 0x04, 0x10, 0x04, 0x40, 0x08, 0x10, 0x09, 0x10, 0x02, 0x00, 0x08, 0x10, + 0x0c, 0x04, 0x04, 0x41, 0x3f, 0xfe, 0x00, 0x8e, 0x04, 0x04, 0x00, 0x10, 0x00, 0x80, 0x00, 0x40, + 0x01, 0xf8, 0x27, 0xf2, 0x04, 0x10, 0x04, 0xc0, 0x08, 0x10, 0x11, 0x10, 0x04, 0x00, 0x04, 0x08, + 0x0b, 0x08, 0x04, 0x41, 0x00, 0x00, 0x00, 0x80, 0x18, 0x02, 0x00, 0x10, 0x00, 0x80, 0x00, 0x20, + 0x01, 0x00, 0x20, 0x02, 0x04, 0x10, 0x03, 0x40, 0x08, 0x10, 0x02, 0x00, 0x04, 0x00, 0x02, 0x08, + 0x68, 0xf0, 0x04, 0x40, 0x00, 0x00, 0x1e, 0x80, 0x00, 0x02, 0x00, 0x08, 0x00, 0x80, 0x00, 0x10, + 0x01, 0x00, 0x20, 0x02, 0x76, 0x10, 0x00, 0x40, 0x08, 0x10, 0x00, 0x00, 0x02, 0x00, 0x01, 0x04, + 0x1c, 0x00, 0x04, 0x40, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x08, 0x00, 0x0e, 0x00, 0xf0, 0x00, 0x00, + 0x01, 0x00, 0x3f, 0xfe, 0x0d, 0x10, 0x00, 0x40, 0x08, 0x10, 0x00, 0x00, 0x01, 0x00, 0x01, 0xfc, + 0x0e, 0x00, 0x04, 0x40, 0x0f, 0xf8, 0x01, 0x18, 0x02, 0x0a, 0x3f, 0xf9, 0x00, 0x8c, 0x00, 0x00, + 0x7f, 0xff, 0x04, 0x00, 0x04, 0xe0, 0x3f, 0xc0, 0x08, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, + 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x12, 0x00, 0x09, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x04, 0x00, 0x00, 0x7e, 0x08, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x80, + 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x06, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x01, 0x00, 0x04, 0x00, 0x00, 0x40, 0x08, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x01, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, + 0x00, 0x00, 0x38, 0x00, 0x03, 0x00, 0x11, 0xe0, 0x01, 0x80, 0x60, 0x04, 0x0e, 0x00, 0x07, 0x80, + 0x18, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x01, 0x80, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60, + 0x07, 0xf8, 0x06, 0x00, 0x24, 0x80, 0x12, 0x12, 0x00, 0x60, 0x18, 0x04, 0x01, 0x80, 0x18, 0x40, + 0x04, 0x00, 0x24, 0x80, 0x03, 0x00, 0x20, 0x80, 0x01, 0x80, 0x00, 0x38, 0x02, 0x00, 0x00, 0x10, + 0x08, 0x04, 0x01, 0x00, 0x20, 0x80, 0x2a, 0x1c, 0x00, 0x10, 0x04, 0x08, 0x00, 0x60, 0x10, 0x4c, + 0x02, 0x00, 0x20, 0x80, 0x00, 0xc0, 0x10, 0x82, 0x00, 0x40, 0x00, 0x40, 0x02, 0x00, 0x00, 0x08, + 0x10, 0x00, 0x00, 0x80, 0x10, 0x40, 0x21, 0xf0, 0x00, 0x08, 0x02, 0x10, 0x00, 0x10, 0x08, 0x70, + 0x02, 0x00, 0x10, 0x40, 0x00, 0x20, 0x08, 0x82, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x04, + 0x10, 0x00, 0x00, 0x40, 0x10, 0x40, 0x20, 0x10, 0x00, 0x08, 0x01, 0x20, 0x00, 0x08, 0x07, 0xc0, + 0x01, 0x00, 0x10, 0x40, 0x00, 0x10, 0x08, 0x84, 0x00, 0x10, 0x01, 0x00, 0x02, 0x08, 0x0c, 0x04, + 0x10, 0x00, 0x00, 0x20, 0x08, 0x42, 0x20, 0x10, 0x0e, 0x08, 0x00, 0xc0, 0x00, 0x08, 0x00, 0x40, + 0x01, 0x00, 0x08, 0x42, 0x00, 0x08, 0x04, 0x84, 0x00, 0x10, 0x01, 0x00, 0x02, 0x10, 0x0b, 0x08, + 0x00, 0x00, 0x00, 0xd0, 0x08, 0x42, 0x20, 0x10, 0x01, 0xf0, 0x00, 0x80, 0x00, 0x04, 0x00, 0x40, + 0x01, 0x60, 0x08, 0x42, 0x00, 0x04, 0x04, 0x88, 0x00, 0x08, 0x01, 0x00, 0x02, 0x60, 0x08, 0xf0, + 0x00, 0x00, 0x33, 0x10, 0x08, 0x42, 0x20, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x04, 0x00, 0x40, + 0x01, 0x10, 0x08, 0x42, 0x04, 0x04, 0x04, 0x90, 0x00, 0x08, 0x01, 0x00, 0x03, 0x80, 0x08, 0x00, + 0x00, 0x00, 0x08, 0x08, 0x04, 0x44, 0x20, 0x10, 0x00, 0x00, 0x00, 0x40, 0x3f, 0xfc, 0x1f, 0xc0, + 0x01, 0x08, 0x04, 0x44, 0x18, 0x02, 0x00, 0x80, 0x00, 0x08, 0x00, 0x84, 0x02, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x04, 0x08, 0x3f, 0x84, 0x23, 0xf0, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x78, + 0x01, 0x04, 0x3f, 0x84, 0x00, 0x02, 0x00, 0x80, 0x1c, 0x10, 0x00, 0x85, 0x02, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x02, 0x04, 0x04, 0x08, 0x10, 0x1e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x04, 0x04, 0x08, 0x00, 0x00, 0x3f, 0xfc, 0x03, 0xe0, 0x00, 0x49, 0x02, 0x00, 0x08, 0x00, + 0x00, 0xf8, 0x01, 0xfc, 0x04, 0x10, 0x10, 0x10, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x00, 0x40, + 0x7f, 0xfc, 0x04, 0x12, 0x02, 0x00, 0x00, 0x85, 0x00, 0x00, 0x7c, 0x22, 0x02, 0x00, 0x00, 0x60, + 0x07, 0x00, 0x01, 0x00, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x1f, 0xfc, + 0x00, 0x00, 0x04, 0x0a, 0x0c, 0x00, 0x00, 0x89, 0x00, 0x00, 0x03, 0xf0, 0x02, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x82, 0x00, 0xc0, 0x00, 0x0e, 0x02, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x03, 0x80, 0x30, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x03, 0xc0, 0x03, 0xc0, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x7e, 0x03, 0xfc, 0x10, 0x20, 0x00, 0x60, + 0x03, 0x00, 0x00, 0x00, 0x04, 0x60, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x70, 0x04, 0x24, + 0x10, 0x00, 0x00, 0x38, 0x0c, 0x00, 0x28, 0x7c, 0x20, 0x80, 0x04, 0x00, 0x10, 0x20, 0x00, 0x10, + 0x00, 0xc0, 0x00, 0x00, 0x08, 0x10, 0x48, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x88, 0x04, 0x38, + 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x21, 0x80, 0x20, 0x80, 0x08, 0x00, 0x10, 0x20, 0x18, 0x08, + 0x00, 0x20, 0x00, 0x00, 0x08, 0x08, 0x30, 0x00, 0x00, 0x00, 0x04, 0x40, 0x03, 0x04, 0x03, 0xe0, + 0x00, 0x00, 0x00, 0x80, 0x12, 0x02, 0x22, 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x20, 0x24, 0x04, + 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x04, 0x20, 0x20, + 0x00, 0x00, 0x01, 0x00, 0x20, 0x02, 0x22, 0x00, 0x10, 0x00, 0x04, 0x00, 0x70, 0x20, 0x22, 0x04, + 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x40, 0x20, 0x04, 0x10, 0x20, + 0x00, 0x00, 0x01, 0x00, 0x20, 0x02, 0x20, 0x00, 0x10, 0x00, 0x02, 0x00, 0x1d, 0xfe, 0x21, 0x02, + 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x80, 0x10, 0xc0, 0x10, 0x08, 0x10, 0x20, + 0x00, 0x00, 0x01, 0x00, 0x20, 0x02, 0x20, 0x00, 0x08, 0x00, 0x01, 0x00, 0x11, 0x22, 0x21, 0x02, + 0x00, 0x04, 0x3f, 0xfc, 0x08, 0x00, 0x00, 0x00, 0x01, 0x80, 0x08, 0x60, 0x0c, 0x10, 0x08, 0x20, + 0x00, 0x00, 0x01, 0x00, 0x20, 0x04, 0x20, 0x00, 0x08, 0xe0, 0x00, 0xc0, 0x11, 0x22, 0x10, 0x84, + 0x00, 0x02, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x98, 0x07, 0xe0, 0x08, 0x20, + 0x00, 0x00, 0x00, 0x80, 0x20, 0x04, 0x20, 0x00, 0x08, 0x1c, 0x01, 0x30, 0x11, 0x22, 0x10, 0x84, + 0x02, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x02, 0x00, 0x08, 0x22, + 0x00, 0x00, 0x00, 0x80, 0x10, 0x08, 0x20, 0x00, 0x08, 0x00, 0x01, 0x0c, 0x11, 0xfe, 0x08, 0x88, + 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x04, + 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, 0x11, 0xc0, 0x04, 0x00, 0x02, 0x00, 0x7d, 0x22, 0x06, 0x90, + 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x80, 0x3c, 0x18, + 0x00, 0x00, 0x7c, 0x20, 0x10, 0x00, 0x10, 0x38, 0x3f, 0x00, 0x02, 0x00, 0x11, 0x22, 0x01, 0xe0, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x40, 0x07, 0x80, + 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x10, 0x00, 0x04, 0xc0, 0x04, 0x00, 0x11, 0x22, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xe0, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x11, 0xfe, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, +}; + +#endif diff --git a/src/lang/glyph_ru.h b/src/lang/glyph_ru.h new file mode 100644 index 00000000..8015f558 --- /dev/null +++ b/src/lang/glyph_ru.h @@ -0,0 +1,136 @@ +#ifndef __GLYPH_RU__ +#define __GLYPH_RU__ + +static unsigned int size_GLYPH_RU = 2035; +static unsigned char GLYPH_RU[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x30, 0x08, 0x03, 0x00, 0x00, 0x00, 0xc9, 0xa1, 0x54, + 0x4d, 0x00, 0x00, 0x00, 0x3f, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0x5a, 0x42, 0x00, 0xef, + 0xc6, 0x73, 0xde, 0xa5, 0x63, 0xa5, 0x6b, 0x39, 0xb5, 0x84, 0x52, 0xce, 0x94, 0x5a, 0x73, 0x5a, + 0x29, 0x31, 0x08, 0x00, 0x8c, 0x5a, 0x29, 0xff, 0xef, 0x8c, 0xa5, 0x7b, 0x4a, 0xdc, 0xa0, 0x64, + 0xff, 0xff, 0x9c, 0x70, 0x5c, 0x2c, 0xff, 0xd6, 0x7b, 0x30, 0x0c, 0x04, 0xe8, 0xc0, 0x70, 0x58, + 0x44, 0x00, 0xc8, 0x90, 0x58, 0xb0, 0x80, 0x50, 0x53, 0xa3, 0xe1, 0x5f, 0x00, 0x00, 0x00, 0x01, + 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x07, 0x62, 0x49, 0x44, 0x41, + 0x54, 0x78, 0x5e, 0xed, 0x9a, 0xeb, 0x72, 0x22, 0xbb, 0x0e, 0x85, 0x59, 0x92, 0xaf, 0x0d, 0xe4, + 0x32, 0xfb, 0xbc, 0xff, 0xb3, 0x1e, 0xc9, 0xa0, 0x5e, 0x36, 0x81, 0x9d, 0xa4, 0x8a, 0x1f, 0xd9, + 0x53, 0x51, 0xc5, 0xf4, 0x2c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, 0x01, 0x5c, 0x21, 0x26, 0xdd, + 0x04, 0x52, 0x20, 0xa2, 0x17, 0x62, 0x3b, 0x80, 0x6b, 0xbc, 0xc7, 0x41, 0x64, 0xc8, 0x0f, 0x05, + 0x53, 0xfb, 0x85, 0x7f, 0x63, 0x61, 0xdc, 0x9f, 0x5d, 0xa2, 0xc0, 0x8b, 0x03, 0x26, 0x79, 0xc3, + 0xc9, 0x81, 0xcd, 0xf4, 0x04, 0x00, 0x59, 0x60, 0x00, 0x22, 0xac, 0xab, 0xd7, 0x1e, 0x00, 0x22, + 0xdf, 0xeb, 0xc9, 0xa0, 0xc6, 0x70, 0xde, 0xd7, 0x83, 0x40, 0x97, 0x62, 0x8e, 0x58, 0x4f, 0xca, + 0x28, 0x94, 0x40, 0x6f, 0x01, 0x28, 0x01, 0xdc, 0x16, 0x0c, 0xc9, 0x43, 0x47, 0x06, 0xb6, 0xd8, + 0x3a, 0xeb, 0x8b, 0x4b, 0x00, 0x58, 0x3e, 0x2f, 0xb8, 0xb7, 0x15, 0x00, 0x91, 0x67, 0x31, 0x00, + 0xa7, 0x58, 0x1f, 0x08, 0x68, 0xcc, 0xf7, 0xfa, 0x03, 0x00, 0x3e, 0x01, 0x60, 0x15, 0x0e, 0x00, + 0xc9, 0xc5, 0x0a, 0x80, 0xf1, 0x5d, 0x09, 0xa0, 0x38, 0x00, 0x02, 0x67, 0xc1, 0x8f, 0x01, 0x98, + 0x3d, 0x06, 0x00, 0xe1, 0x3b, 0xf2, 0x13, 0x00, 0x24, 0x20, 0xa3, 0x7e, 0x42, 0x15, 0x2c, 0x00, + 0xbb, 0x28, 0x1e, 0x01, 0xa0, 0x8e, 0x6c, 0x15, 0x78, 0x59, 0xa1, 0xb4, 0x3b, 0x80, 0xfe, 0x08, + 0x40, 0x71, 0x00, 0xe5, 0x5b, 0x00, 0xfc, 0x53, 0x67, 0x8e, 0xef, 0xbd, 0x07, 0x80, 0x48, 0x80, + 0x68, 0x10, 0x80, 0x3e, 0x06, 0xc0, 0x82, 0x4f, 0x94, 0x9e, 0xb2, 0x9e, 0x00, 0xaf, 0xff, 0x31, + 0x00, 0xcd, 0x58, 0x6f, 0x92, 0xa4, 0x14, 0x49, 0x3b, 0x0e, 0x95, 0x2e, 0xa5, 0x8b, 0x3e, 0x04, + 0x90, 0x52, 0xfa, 0x0e, 0x00, 0x1d, 0xf5, 0x09, 0xef, 0xaf, 0x2a, 0x9a, 0x03, 0x40, 0x14, 0x6c, + 0xba, 0x7e, 0x0e, 0x80, 0xf5, 0x9f, 0x4e, 0xfd, 0x96, 0x00, 0x01, 0x88, 0xb2, 0xc4, 0xb5, 0xe0, + 0x55, 0xf3, 0x08, 0x48, 0x01, 0x95, 0xaa, 0x14, 0x55, 0xb8, 0x67, 0x05, 0x10, 0x04, 0xdc, 0xbe, + 0x05, 0xc0, 0x92, 0x26, 0x00, 0xb9, 0x77, 0xd5, 0xac, 0xdf, 0x01, 0x80, 0xe5, 0xc8, 0xe6, 0xad, + 0x9f, 0xfa, 0x29, 0xcf, 0xff, 0x8e, 0x63, 0x06, 0xe0, 0xf5, 0x7f, 0x09, 0x00, 0x89, 0x96, 0x34, + 0xa9, 0x6e, 0x1a, 0x40, 0x48, 0x25, 0x80, 0x61, 0x30, 0x2b, 0x47, 0x4a, 0xcd, 0xc0, 0x74, 0xe2, + 0xfa, 0x8d, 0x86, 0x16, 0x38, 0xb5, 0xe5, 0xfe, 0x4e, 0x99, 0x00, 0x52, 0x00, 0xa0, 0xa6, 0x41, + 0xae, 0x16, 0xf1, 0x3d, 0x4b, 0x37, 0x00, 0x41, 0x00, 0xaa, 0x20, 0x80, 0x70, 0x2c, 0x00, 0x12, + 0xb8, 0xe8, 0x1d, 0x20, 0x70, 0x00, 0x0b, 0xf3, 0xd0, 0x01, 0xa0, 0xf7, 0x51, 0x15, 0x03, 0x08, + 0xe0, 0x63, 0xc1, 0x49, 0x73, 0xce, 0x36, 0x22, 0x03, 0x2a, 0x37, 0x00, 0xd2, 0x07, 0x00, 0xc6, + 0xdc, 0xe2, 0xdb, 0x03, 0x00, 0xda, 0xdc, 0xf6, 0xf8, 0x7c, 0xfd, 0x0e, 0xd0, 0xb7, 0xec, 0xb2, + 0x65, 0x71, 0xe2, 0x62, 0xe9, 0xcc, 0x07, 0x01, 0x40, 0x3e, 0x01, 0xd0, 0x0a, 0x58, 0xef, 0x5d, + 0x00, 0xc3, 0x96, 0x23, 0x83, 0x23, 0x01, 0xb0, 0xe0, 0xee, 0x12, 0x59, 0xc3, 0x62, 0x03, 0x12, + 0x47, 0x86, 0xf5, 0x96, 0xd2, 0x79, 0x42, 0x86, 0xb1, 0x7e, 0x5f, 0x20, 0x82, 0x79, 0xb8, 0x77, + 0xc0, 0x55, 0x4e, 0x18, 0x00, 0x20, 0x52, 0xaf, 0x04, 0x24, 0xd2, 0x99, 0x8f, 0x40, 0xec, 0x3c, + 0x42, 0xc5, 0x7c, 0x46, 0x66, 0x41, 0x8d, 0x6f, 0x68, 0x32, 0x9f, 0xb6, 0xd0, 0x86, 0x21, 0x6b, + 0xbf, 0x0b, 0x60, 0x2d, 0x38, 0xc2, 0x99, 0x81, 0x63, 0x71, 0x3b, 0x36, 0x1e, 0x50, 0x35, 0xcd, + 0x23, 0x70, 0x09, 0xb6, 0x61, 0x82, 0xda, 0x05, 0x35, 0x2f, 0x06, 0xc0, 0xf5, 0x75, 0xd4, 0x88, + 0x70, 0xbd, 0xe6, 0x63, 0xd8, 0x45, 0x87, 0x93, 0xf3, 0xd4, 0x66, 0x4c, 0xa6, 0xe3, 0xae, 0x8f, + 0x0a, 0x54, 0xb1, 0xfd, 0x0f, 0x39, 0x00, 0x3a, 0x81, 0x2c, 0xfb, 0xe3, 0x0e, 0x9e, 0x68, 0xbf, + 0xf6, 0xdb, 0xb6, 0x7f, 0x3d, 0xb2, 0xff, 0x24, 0x00, 0x6c, 0x97, 0xd7, 0x8e, 0x79, 0x51, 0xac, + 0x8f, 0x01, 0x74, 0x25, 0x13, 0x22, 0x9f, 0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c, 0xd0, 0x5b, 0x00, 0x0e, 0x67, 0x07, 0xd0, 0xd8, 0xfd, 0xef, + 0xeb, 0x25, 0xd6, 0xef, 0xda, 0x00, 0xd0, 0x10, 0xf1, 0xbb, 0xf7, 0xcf, 0xfb, 0xe9, 0xfd, 0x74, + 0xfa, 0xc3, 0x10, 0xa8, 0xd7, 0x4f, 0x91, 0x44, 0xd2, 0x0c, 0xa0, 0xdc, 0x00, 0x40, 0x96, 0x8c, + 0x57, 0xad, 0x71, 0x22, 0xe5, 0x7c, 0x9e, 0x01, 0x94, 0x0f, 0x00, 0x0e, 0x82, 0xc3, 0x9c, 0xb0, + 0x02, 0x50, 0xed, 0xc3, 0x4b, 0x84, 0xdd, 0x7c, 0x8b, 0xc3, 0xf3, 0x1d, 0x40, 0xcc, 0x07, 0xe7, + 0x20, 0xd7, 0xa6, 0x13, 0x55, 0xcb, 0x3d, 0x00, 0x5d, 0xc1, 0xfa, 0xff, 0xb1, 0xb7, 0x80, 0x11, + 0xe0, 0x87, 0x54, 0x6b, 0x24, 0x00, 0x2d, 0x80, 0xea, 0x4e, 0xa0, 0x62, 0x00, 0x28, 0x47, 0x02, + 0x68, 0xc8, 0x68, 0x71, 0x62, 0x71, 0x2c, 0xad, 0x05, 0x1f, 0x9e, 0xd0, 0x25, 0xde, 0x01, 0x30, + 0x21, 0x17, 0x00, 0x85, 0xed, 0x7a, 0x16, 0x05, 0x74, 0x7d, 0x86, 0x97, 0x25, 0x1c, 0x51, 0x3f, + 0x01, 0x34, 0x68, 0x77, 0x5f, 0x00, 0xe0, 0x7a, 0xf7, 0x01, 0x38, 0x81, 0xae, 0x68, 0x51, 0xff, + 0xf6, 0xcf, 0xcb, 0xcb, 0xc9, 0x7e, 0xb6, 0x0b, 0x01, 0xe4, 0x0c, 0x20, 0xf3, 0x71, 0x81, 0xe7, + 0x37, 0x12, 0xa8, 0x05, 0x32, 0x03, 0x68, 0x5e, 0x10, 0x8f, 0x84, 0x77, 0xca, 0x16, 0x5f, 0xa6, + 0xed, 0x4b, 0x00, 0x60, 0xbc, 0x4c, 0x09, 0x2d, 0xe5, 0x52, 0x58, 0xff, 0xe8, 0xef, 0xf5, 0xa6, + 0xbf, 0x87, 0xf9, 0xc2, 0x01, 0x75, 0x74, 0x10, 0x21, 0x01, 0x88, 0xb2, 0x20, 0xae, 0x17, 0x05, + 0x68, 0x4c, 0xed, 0xc0, 0x88, 0xcb, 0x00, 0xfc, 0xef, 0xe5, 0x60, 0x00, 0x6c, 0xfc, 0xd9, 0x13, + 0x54, 0x33, 0xf3, 0xf3, 0xe5, 0x08, 0x07, 0x46, 0x8c, 0xc7, 0x07, 0xed, 0xb8, 0x03, 0xc8, 0xb9, + 0x5d, 0x2e, 0xe0, 0xa3, 0x02, 0x64, 0xee, 0xdf, 0x01, 0xde, 0xc6, 0x67, 0x30, 0x61, 0x6d, 0x97, + 0xe9, 0x59, 0x94, 0xfb, 0x56, 0xed, 0x86, 0xc5, 0x45, 0xb1, 0xac, 0x17, 0x82, 0xb6, 0xce, 0xbf, + 0xbd, 0xbd, 0xc5, 0xb8, 0x3b, 0xcf, 0xe7, 0x11, 0xd4, 0xe1, 0xa5, 0xa6, 0xc3, 0x35, 0xd5, 0x83, + 0x78, 0x86, 0xfc, 0xe5, 0xf6, 0x6b, 0x6c, 0x79, 0xff, 0xf6, 0x67, 0x11, 0xd5, 0x46, 0x58, 0x05, + 0xc6, 0xa0, 0x43, 0x36, 0xc1, 0x5f, 0x0b, 0xa0, 0xf6, 0x73, 0x29, 0xd5, 0xc6, 0xf4, 0x55, 0x19, + 0x3e, 0xa6, 0x90, 0xed, 0xa0, 0xed, 0xef, 0x05, 0x20, 0x82, 0x62, 0x03, 0x04, 0x00, 0x1f, 0x4b, + 0x88, 0x3e, 0x02, 0xc0, 0x86, 0xeb, 0x3f, 0x6b, 0x00, 0xc6, 0x20, 0x91, 0x13, 0xc6, 0x98, 0x0c, + 0xed, 0x5f, 0xeb, 0x87, 0x35, 0x6b, 0x75, 0x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xa7, 0xaf, 0x0e, 0x09, 0x46, 0x3c, 0xb9, 0x91, 0xff, 0x3f, 0x00, + 0x75, 0x50, 0xd5, 0x0c, 0x7e, 0x2a, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, + 0x42, 0x60, 0x82, +}; + +#endif diff --git a/src/lang/glyph_ru.png b/src/lang/glyph_ru.png new file mode 100644 index 00000000..2af50a85 Binary files /dev/null and b/src/lang/glyph_ru.png differ diff --git a/src/lang/gr.h b/src/lang/gr.h new file mode 100644 index 00000000..b46b8751 --- /dev/null +++ b/src/lang/gr.h @@ -0,0 +1,716 @@ +#ifndef H_LANG_GR +#define H_LANG_GR + +// Thanks: Tenebra Studios + +#include "glyph_gr.h" + +#if 0 +const char *STR_GR[] = { "Ελληνικά" +// help + , "ΦόÏτωση..." + , "Πατήστε H για βοήθεια" + , helpText + , "%s@@@" + "ΘΥΜΑΤΑ %d@@" + "ΑÎΤΙΚΕΙΜΕÎΑ %d@@" + "ΜΥΣΤΙΚΑ %d από %d@@" + "ΧΡΟÎΟΣ %s" + , "Αποθήκευση παιχνιδιοÏ..." + , "ΟλοκληÏώθηκε η αποθήκευση!" + , "ΣΦΑΛΜΑ ΑΠΟΘΗΚΕΥΣΗΣ!" + , "ÎΑΙ" + , "ΟΧΙ" + , "Όχι" + , "Îαι" + , "Όχι" + , "Side-By-Side" + , "Anaglyph" + , "ΧωÏισμένη Οθόνη" + , "VR" + , "Χαμηλό" + , "Μεσαίο" + , "Υψηλό" + , STR_LANGUAGES + , "ΕφαÏμογή" + , "ΧειÏιστήÏιο 1" + , "ΧειÏιστήÏιο 2" + , "ΧειÏιστήÏιο 3" + , "ΧειÏιστήÏιο 4" + , "Δεν είναι έτοιμο" + , "Παίκτης 1" + , "Παίκτης 2" + , "Πατήστε Οποιοδήποτε ΠλήκτÏο" + , "%s - Επιλογή" + , "%s - Πίσω" +// inventory pages + , "ΡΥΘΜΙΣΕΙΣ" + , "ΣΑΚΙΔΙΟ" + , "ΑÎΤΙΚΕΙΜΕÎΑ" +// save game page + , "Αποθήκευση παιχνιδιοÏ;" + , "ΤÏέχουσα Τοποθεσία" +// inventory option + , "Παιχνίδι" + , "ΧάÏτης" + , "Πυξίδα" + , "Στατιστικά" + , "Η Έπαυλη της ΛάÏα" + , "Επίπεδο ΛεπτομέÏειας" + , "Ήχος" + , "ΧειÏισμός" + , "Φωτεινότητα" +// passport menu + , "ΦόÏτωση ΠαιχνιδιοÏ" + , "Îέο Παιχνίδι" + , "Επανεκκίνηση Επιπέδου" + , "ΕπιστÏοφή στο ΜενοÏ" + , "Έξοδος από το παιχνίδι" + , "Επιλογή Επιπέδου" +// detail options + , "Επιλογή ΛεπτομέÏειας" + , "ΦιλτÏάÏισμα" + , "Φωτισμός" + , "Σκιές" + , "ÎεÏÏŒ" + , "VSync" + , "ΣτεÏεοσκοπία" + , "Απλά Αντικείμενα" + , "Resolution" + , STR_SCALE +// sound options + , "ΡÏθμιση Εντάσεων" + , "Αντήχηση" + , "Υπότιτλοι" + , "Γλώσσα" +// controls options + , "ΡÏθμιση ΧειÏισμοÏ" + , "ΠληκτÏολόγιο" + , "ΧειÏιστήÏιο" + , "Δόνηση" + , "Îέος Στόχος" + , "Πολλαπλή Στόχευση" + // controls + , "ΑÏιστεÏÏŒ", "Δεξί", "ΜπÏοστά", "Πίσω", "Άλμα", "ΠεÏπάτημα", "ΔÏάση", "ΧÏήση Όπλου", "Κοίταγμα", "ΣκÏψιμο", "ΤÏέξιμο", "ΤοÏμπα", "Σακίδιο", "Ξεκίνημα" + , STR_KEYS +// inventory items + , "Άγνωστο" + , "ΕκÏηκτικά" + , "Πιστόλια" + , "ΚαÏαμπίνα" + , "Μάγκνουμ" + , "ΟÏζι" + , "ΣφαίÏες ΠιστολιοÏ" + , "Φυσίγγια ΚαÏαμπίνας" + , "ΣφαίÏες Μάγκνουμ" + , "ΣφαίÏες ΟÏζι" + , "ΜικÏÏŒ Κουτί ΠÏώτων Βοηθειών" + , "Μεγάλο Κουτί ΠÏώτων Βοηθειών" + , "Ράβδος ΜολÏβδου" + , "Κειμήλιο" +// keys + , "Κλειδί" + , "Ασημένιο Κλειδί" + , "ΣκουÏιασμένο Κλειδί" + , "ΧÏυσό Κλειδί" + , "ΖαφειÏένιο Κλειδί" + , "Κλειδί Ποσειδώνα" + , "Κλειδί Άτλαντα" + , "Κλειδί Δαμοκλή" + , "Κλειδί ΘωÏ" + , "Διακοσμημένο Κλειδί" +// puzzles + , "ΓÏίφος" + , "ΧÏυσό Είδωλο" + , "Ράβδος ΧÏυσοÏ" + , "ΓÏανάζι Μηχανής" + , "Ασφάλεια" + , "Ανκ" + , "Το Μάτι του ÎÏου" + , "Η ΣφÏαγίδα του Άνουβι" + , "ΣκαÏαβαίος" + , "Κλειδί ΠυÏαμίδα" +// TR1 subtitles + /* CAFE */ , + "[43500]Τι Ï€Ïέπει να κάνει κανείς για να πάÏει@Î±Ï…Ï„Î¿Ï Ï„Î¿Ï… είδους την Ï€Ïοσοχή από σένα;" + "[47500]ΔÏσκολο να σου πω ακÏιβώς,@αλλά φαίνεται να τα πας καλά." + "[50000]Τέλεια. Αν και για να ποÏμε την αλήθεια,@δεν είμαι εγώ αυτός που σε θέλει." + "[54500]Όχι;" + "[55000]Όχι. Η Δεσποινίς Τζακλίν Îάτλα σε θέλει,@από την Natla Technologies." + "[59000]ΞέÏεις, η δημιουÏγός όλων@των φανταχτεÏών και όμοÏφων Ï€Ïαγμάτων." + "[64500]Σκάσε ΛάÏσον." + "[66000]Μάλιστα ΚυÏία." + "[68000]Ρίξε μια ματιά σε αυτό ΛάÏα." + "[70500]Πώς θα σου φαινόταν να Ï€Ïοσθέσεις κάποια μηδενικά στο λογαÏιασμό σου;" + "[73500]Λυπάμαι. Παίζω μόνο για την φανέλα." + "[76000]Τότε θα σου αÏέσουν τα μεγάλα γήπεδα." + "[78000]ΠεÏοÏ. Μεγάλες βουνοκοÏφές Ï€Ïος εξεÏεÏνηση.@ΤεÏάστια τείχη πάγου. ΑπόκÏημνα βÏάχια. Ανελέητοι άνεμοι." + "[87500]Και υπάÏχει ακόμη κι αυτό το μικÏÏŒ μπιχλιμπίδι:@Ένα πανάÏχαιο κειμήλιο με μυστικές δυνάμεις" + "[92500]θαμμένο στον χαμένο Ï„Ïμβο του Κουαλοπέκ." + "[96000]Αυτό με ενδιαφέÏει." + "[98000]Θα μποÏοÏσες να φÏγεις αÏÏιο.@Κάνεις τίποτα αÏÏιο;" + /* LIFT */ , + "[49000]Εγκατεστημένος πλέον στην Μονή του Αγ. ΦÏαγκίσκου, νέοι πειÏασμοί με βασανίζουν." + "[53500]Φήμες ανάμεσα στους αδεÏφοÏÏ‚ μου λένε ότι κάτω@από το μοναστήÏι μας βÏίσκεται ενταφιασμένο το σώμα του Τιόκαν," + "[60000]ενός από τους Ï„Ïείς μυθικοÏÏ‚ κυβεÏνήτες@ της Ατλαντίδας, της χαμένης ηπείÏου" + "[64500]και πως μαζί του είναι το δικό του κομμάτι@από το Κειμήλιο της Ατλαντίδας." + "[68000]Το πεÏιδέÏαιο που χωÏίστηκε και μοιÏάστηκε ανάμεσα στους Ï„Ïεις κυβεÏνήτες@" + "[72500]το οποίο δίνει τεÏάστιες δυνάμεις.@Δυνάμεις Ï€Î¿Î»Ï Ï€Î­Ïαν του ίδιου του ΔημιουÏγοÏ." + "[79000]ΙδÏώνω και μόνο στην σκέψη τέτοιων δυνατοτήτων@ενώ είμαι ακόμη θνητός." + "[85500]Κάθε βÏάδυ, πιέζω τον εαυτό μου να ξεχάσει αυτές τις@φαντασιώσεις, αλλά είναι γεγονός ότι Ï€Ïόκειται για μια μεγάλη δοκιμασία." + "[92000]" + "[93500]ΠιέÏ. Τσκ. Î’ÏωμιάÏη." + /* CANYON */ , + "[13500]Την πάτησες." + "[16500]'ΣπέÏα." + "[17500]ΚαλησπέÏα." + "[20000]ΠαÏάτησες τον ΛάÏσον να Ïουφάει αέÏα λοιπόν;" + "[22500]Δεν βγάζει και Ï€Î¿Î»Ï Î½ÏŒÎ·Î¼Î± αυτή η φÏάση." + "[24000]Λοιπόν, το πανηγυÏάκι σου τελείωσε." + "[27000]ΉÏθε η ÏŽÏα να μου δώσεις ότι μου έκλεψες." + "[30000]Ας ψάξουμε στο σακίδιο." + "[32000]" + "[42500]Τι πεÏιμένετε; Σκοτώστε την!" + "[45000]Έι!" + "[48000]" + "[50500]Ζωντόβολα!" + "[53000]" + "[62500]Πάμε." + "[65000]" + "[136000]Τι στο διάολο ήταν αυτό;" + "[138000]Ποιο;" + "[138500]Από εκεί ακοÏστηκε." + "[140500]Μάλλον κάνα ψάÏι." + "[142500]ΠÏέπει να είναι μεγάλο ψάÏι, φίλε." + "[145000]ΧαλάÏωσε μεγάλε.@Πάω πάλι μέσα. ΈÏχεσαι;" + "[152000]" + "[158000]ΉÏεμα..." + "[160000]Έφυγε." + "[161500]Είσαι έτοιμος;" + /* PRISON */ , + "[00001]Δεν μποÏείτε να το κάνετε αυτό!" + "[01500]Σε καταδικάζουμε, Îάτλα της Ατλαντίδας, για τα εγκλήματά σου." + "[06000]Για την κατάφωÏη κατάχÏηση των δυνάμεών σου@και γιατί μας έκλεψες τις δικές μας." + "[11500]Δεν μποÏείτε! Εγώ..." + "[12500]Σπάζοντας τα δεσμά της συγκατάθεσης κάτω απ' τα οποία@ο λαός μας κυβεÏνάται και εξασφαλίζεται," + "[18500]βάλλοντας τον Τιόκαν και εμένα με τον ίδιο μας το στÏατό." + "[23500]Η πυÏαμίδα μας εκκενώθηκε από τους στÏατιώτες μας" + "[27000]για να μποÏείς ÎµÏƒÏ Î½Î± χÏησιμοποιήσεις την πυÏαμίδα - τις δυνάμεις της@για δημιουÏγία - για τη δική σου απεÏίσκεπτη καταστÏοφή." + "[33500]ΑπεÏίσκεπτη;!; Κοίταξε πώς είσαι!" + "[35500]Κανείς από σας δεν έχει μια στάλα εφευÏετικότητας στο κεφάλι του." + "[40500]ΆχÏηστοι!" + "[41500]Ας το κάνουμε." + "[44000]Τιόκαν!" + "[45000]ΧÏησιμοποίησες αυτόν τον ιεÏÏŒ τόπο ως πηγή@της Ï€Ïοσωπικής σου ευχαÏίστησης," + "[49500]σαν εÏγοστάσιο τεÏατογενέσεων." + "[51000]Είναι επιζήσαντες. Μια νέα γενιά." + "[54000]ΤώÏα πια ένας σωÏός σφαγής." + "[56000]Κι εσÏ. Θα φÏοντίσουμε να ξεχαστείς από όλους." + "[60000]Είθε οι φλέβες, η καÏδιά, τα πόδια σου" + "[64000]κι αυτός ο αÏÏωστημένος εγκέφαλος να κολλήσουν γεÏά με παγωμένο αίμα." + "[70000]Δεν θα αναπαυθεί η ψυχή σου στους αιώνες των αιώνων Îάτλα." + "[73000]Δεν θα αναπαυθείτε οÏτε εσείς, οÏτε η καταÏαμένη ήπειÏος της Ατλαντίδας!" + /* 22 */ , + "[04000]ΕπέστÏεψες;" + "[05500]Κι ÎµÏƒÏ - φαντάζομαι για μια εντυπωσιακή είσοδο." + "[09500]Η εξέλιξη βÏίσκει το δÏόμο της - η φυσική επιλογή είναι σε Ï€Ïωτοφανή χαμηλά επίπεδα..." + "[13500]Η νέα φουÏνιά θα Ï€Ïοκαλέσει και πάλι εδαφικές διαμάχες" + "[17500] - θα μας δυναμώσει και θα μας πάει μπÏοστά..." + "[20500]ΔημιουÏγώντας ακόμη και νέα είδη." + "[22500]Κάπως σαν εξέλιξη με στεÏοειδή τότε." + "[24500]Δεν ήξεÏαν από Ï€Î¿Ï Ï„Î¿Ï…Ï‚ ήÏθε...@αυτά τα Ïεμάλια ο Κουάλοπεκ και ο Τιόκαν δεν είχαν ιδέα" + "[29500] - ο κατακλυσμός της Ατλαντίδας χτÏπησε μια φυλή ηλιθίων..." + "[33500]τους γÏÏισε πάλι πίσω στα βασικά της επιβίωσης..." + "[37000]Δεν έπÏεπε να γίνει έτσι." + "[39000]ΟÏτε όπως Ï„ÏŽÏα." + "[40000]Η εκκόλαψη ξεκινά σε 15 δευτεÏόλεπτα." + "[43000]Î Î¿Î»Ï Î±Ïγά για εκτÏώσεις πια!" + "[45000]Όχι χωÏίς την καÏδιά της επιχείÏησης!" + "[47000]Όοοοχι!" + "[50000]ΔΕΚΑ" + "[54000]ΠΕÎΤΕ..." + "[55500]4...3...2..." + "[60000]ΕÎΑ..." + /* 23 */ , + "[00001]Λοιπόν, έχεις την πλήÏη Ï€Ïοσοχή μου Ï„ÏŽÏα" + "[02500]Δεν είμαι σίγουÏη αν εγώ έχω τη δική σου ωστόσο" + "[05000]Έι!" + "[06000]Θα σε κυνηγήσω και θα σε πιάσω όπου κι αν πας" + "[09000]Βέβαια" + "[10000]Εσένα κι αυτό το αναθεματισμένο κομμάτι απ' το Κειμήλιο." + "[13000]Αν θες ντε και καλά να το κÏατήσεις, θα στο βάλω στον..." + "[17000]Μισό... μιλάμε για το Κειμήλιο εδώ πέÏα;" + "[20000]Τι λέμε τόσην ÏŽÏα ... όλο μέσα στ..." + "[22000]ΠεÏιμένε - συγνώμη" + "[24000]αυτό το κομμάτι που λες - Ï€Î¿Ï Î„Î½Î±Î¹ το υπόλοιπο μέÏος;" + "[26500]Η κα Îάτλα έβαλε τον Î Î¹Î­Ï Îτουπόν να το βÏει." + "[29500]Και Ï€Î¿Ï ÎµÎ¯Î½Î±Î¹;" + "[30500]Χα. Δεν είσαι αÏκετά γÏήγοÏη γι' αυτόν." + "[34000]ΆÏα όλο αυτό το μπλα μπλα γίνεται μόνο και μόνο για να με καθυστεÏήσει;" + "[37000]Δεν ξέÏω Ï€Î¿Ï Ï„Î¿Î½ έχουν πάει τα μικÏά του ποδαÏάκια" + "[42000]Θα Ï€Ïέπει να Ïωτήσεις την κα Îάτλα" + "[46000]" + "[51000]ΕυχαÏιστώ. Θα το κάνω." + /* 24 */ , "" + /* 25 */ , + "[03500]Εδώ αναπαÏεται ο Τιόκαν" + "[05000]...ένας από τους δÏο δίκαιους ηγεμόνες της Ατλαντίδας..." + "[10000]ο οποίος παÏά την κατάÏα που έπεσε πάνω στην ήπειÏο..." + "[13000]...Ï€Ïοσπάθησε να συνεχίσει να επιβάλλει την τάξη σε αυτά τα άγονα ξένα εδάφη..." + "[19000]Πέθανε χωÏίς απογόνους και η γνώση του δεν έχει κληÏονόμο..." + "[25500]Ρίξε το βλέμμα σου πάνω μας με συμπόνοια, Τιόκαν." + /* 26 */ , "Καλώς ήÏθες σπίτι μου!@Θα σε ξεναγήσω." + /* 27 */ , "ΧÏησιμοποίησε τα κουμπιά κατεÏθυνσης@για να πας στο δωμάτιο μουσικής." + /* 28 */ , "OK. Ας κάνουμε μεÏικές τοÏμπες.@Πάτα το πλήκτÏο για άλμα." + /* 29 */ , "ΤώÏα πάτα το ξανά και πάτα μια από@τις κατευθÏνσεις και θα πηδήξω Ï€Ïος τα εκεί." + /* 30 */ , "Α, το κυÏίως χωλ.@Συγνώμη για την ακαταστασία, θέλω να δώσω κάποια Ï€Ïάγματα@ για αποθήκευση και δεν έχουν έÏθει να τα μαζέψουν ακόμη." + /* 31 */ , "ΤÏέξε Ï€Ïος ένα κιβώτιο και ενώ κÏατάς@πατημένο το μπÏοστά πάτα το πλήκτÏο δÏάσης@και θα σκαÏφαλώσω πάνω του." + /* 32 */ , "Αυτή ήταν η αίθουσα χοÏοÏ, αλλά την μετέτÏεψα στο Ï€Ïοσωπικό μου γυμναστήÏιο.@Πώς σου φαίνεται;@Λοιπόν, ας κάνουμε μεÏικές ασκήσεις." + /* 33 */ , "Δεν συνηθίζω να Ï„Ïέχω παντοÏ.@Όταν θέλω να είμαι Ï€Ïοσεκτική πεÏπατάω.@ΚÏάτα πατημένο το πλήκτÏο πεÏπατήματος και πεÏπάτα μέχÏι την άσπÏη γÏαμμή." + /* 34 */ , "Με πατημένο το πλήκτÏο πεÏπατήματος,@δεν θα πέσω όταν φτάσω στην άκÏη@ακόμη κι αν Ï€Ïοσπαθήσεις να με Ïίξεις.@ΕμπÏός, Ï€Ïοσπάθησέ το." + /* 35 */ , "Εάν θες να κοιτάξεις Ï„ÏιγÏÏω,@κÏάτα πατημένο το πλήκτÏο κοιτάγματος.@Έπειτα πάτα Ï€Ïος την κατεÏθυνση που θες να κοιτάξεις." + /* 36 */ , "Εάν ένα άλμα είναι Ï€Î¿Î»Ï Î¼Î±ÎºÏιά για εμένα,@μποÏÏŽ να πιαστώ από την άκÏη και να γλυτώσω από ένα άσχημο πέσιμο.@ΠεÏπάτα μέχÏι την άκÏη με την άσπÏη γÏαμμή μέχÏι να μην μποÏÏŽ να πάω παÏαπέÏα.@Τότε πάτα το άλμα και αμέσως το μπÏοστά και καθώς@είμαι στον αέÏα πάτα και κÏάτα πατημένο το πλήκτÏο δÏάσης." + /* 37 */ , "Πάτα το μπÏοστά και θα σκαÏφαλώσω επάνω." + /* 38 */ , "Εάν κάνω ένα άλμα Ï„Ïέχοντας, μποÏÏŽ να καταφέÏω@ένα τέτοιο άλμα, χωÏίς Ï€Ïόβλημα." + /* 39 */ , "ΠεÏπάτα μέχÏι την άκÏη με την άσπÏη γÏαμμή μέχÏι να σταματήσω.@Μετά άσε το πεÏπάτημα και πάτα το πίσω για να μου δώσεις χώÏο να πάÏω φόÏα.@Πάτα μπÏοστά και σχεδόν αμέσως πάτα και κÏάτα πατημένο το πλήκτÏο άλμπατος.@Δεν Ï€Ïόκειται να κάνω το άλμα παÏά την τελευταία στιγμή." + /* 40 */ , "Λοιπόν. Αυτό είναι ένα Ï€Î¿Î»Ï Î¼ÎµÎ³Î¬Î»Î¿ άλμα.@Οπότε κάνε ένα άλμα Ï„Ïέχοντας ακÏιβώς όπως Ï€Ïιν με την διαφοÏά πως@ενώ είμαι στον αέÏα@πάτα και κÏάτα πατημένο το@πλήκτÏο δÏάσης για να με κάνεις να κÏατηθώ από την άκÏη." + /* 41 */ , "Τέλεια." + /* 42 */ , "ΠÏοσπάθησε να σκαÏφαλώσεις εδώ πάνω.@Πάτα το μπÏοστά και κÏάτα πατημένο το πλήκτÏο δÏάσης." + /* 43 */ , "Δεν μποÏÏŽ να σκαÏφαλώσω επάνω γιατί το κενό είναι Ï€Î¿Î»Ï Î¼Î¹ÎºÏÏŒ.@Αλλά πάτα το δεξί και θα κινηθώ πλάγια μέχÏι@να υπάÏχει χώÏος και τότε πάτα το μπÏοστά." + /* 44 */ , "Τέλεια!@Εάν υπάÏχει μεγάλη απόσταση από το έδαφος και δεν θέλω να@χτυπήσω πηδώντας κατευθείαν, μποÏÏŽ να κÏατηθώ από την@άκÏη και να αφεθώ Ï€Ïοσεκτικά." + /* 45 */ , "Πάτα το πίσω και θα κάνω άλμα Ï€Ïος τα πίσω.@Αμέσως πάτα και κÏάτα πατημένο το πλήκτÏο δÏάσης@και θα πιαστώ από την άκÏη καθώς πέφτω." + /* 46 */ , "Τότε άσε το πλήκτÏο." + /* 47 */ , "Πάμε για μπάνιο." + /* 48 */ , "Το πλήκτÏο άλματος και οι κατευθÏνσεις@με μετακινοÏν κάτω από το νεÏÏŒ." + /* 49 */ , "Α! ΑέÏας!@Απλώς χÏησιμοποίησε το μπÏοστά και το αÏιστεÏά και δεξιά@για να κινηθείς στην επιφάνεια.@Πάτα το πλήκτÏο άλματος για να βουτήξεις κάτω από την επιφάνεια.@Αλλιώς πήγαινε στην άκÏη και πάτα το πλήκτÏο δÏάσης για να βγεις έξω." + /* 50 */ , "ΩÏαία. ΚαλÏτεÏα να βγάλω αυτά τα βÏεγμένα ÏοÏχα." + /* 51 */ , "Πες αλεÏÏι!" + /* 52 */ , "Δεν είναι Ï€Ïοσωπικό το θέμα." + /* 53 */ , "Έχω ακόμα πονοκέφαλο από σένα.@Και μου μπαίνουν πεÏίεÏγες ιδέες Ï„ÏŽÏα.@Όπως το να σε γεμίσω σφαίÏες!" + /* 54 */ , "Δεν μποÏείς να γλυτώσεις από μένα και@το σινάφι μου τόσο εÏκολα ΛάÏα." + /* 55 */ , "Λίγο αÏγά για βÏαβεία - δε νομίζεις;@Όμως αυτό που αξίζει είναι να κεÏδίζεις." + /* 56 */ , "Με πυÏοβόλησες;@Με πυÏοβόλησες, ε;@Δεν υπάÏχει κάνας άλλος, άÏα μάλλον εμένα πυÏοβολείς!" +// TR1 levels + , "Η Έπαυλη της ΛάÏα" + , "Σπήλαια" + , "Η Πόλη της Βιλκαμπάμπα" + , "Χαμένη Κοιλάδα" + , "Ο ΤÏμβος του Κουαλοπέκ" + , "Η Μονή του Αγ. ΦÏαγκίσκου" + , "Το Κολοσσαίο" + , "Το Παλάτι του Μίδα" + , "Το ΥδÏαγωγείο" + , "Ο ΤÏμβος του Τιόκαν" + , "Η Πόλη του ΚαμοÏν" + , "Ο Οβελίσκος του ΚαμοÏν" + , "Ο Îαός του Κειμηλίου" + , "Τα ΟÏυχεία της Îάτλα" + , "Η Ατλαντίδα" + , "Η Μεγαλή ΠυÏαμίδα" + , "ΕπιστÏοφή στην Αίγυπτο" + , "Ο Îαός της Γάτας" + , "Το ΟχυÏÏŒ της Ατλαντίδας" + , "Η Φωλιά" +// TR2 levels + , "Η Έπαυλη της ΛάÏα" + , "Το Σεινικό Τείχος" + , "Βενετία" + , "Το ΚÏησφÏγετο του ΜπαÏτόλι" + , "Η ΌπεÏα" + , "ΥπεÏάκτιες Εγκαταστάσεις" + , "ΠεÏιοχή ΚαταδÏσεων" + , "40 ΟÏγιές" + , "Το Îαυάγιο του ΜαÏία ÎÏ„ÏŒÏια" + , "Καμπίνες" + , "ΚατάστÏωμα" + , "Στους ΠÏόποδες του Θιβέτ" + , "Το ΜοναστήÏι ΜπάÏκχανγκ" + , "Οι Κατακόμβες του Τάλιον" + , "Το Παλάτι του Πάγου" + , "Ο Îαός του Σιάν" + , "Τα Ιπτάμενα Îησιά" + , "Η Φωλιά του ΔÏάκου" + , "Σπίτι μου Σπιτάκι μου" +// TR3 levels + , "Η Έπαυλη της ΛάÏα" + , "ΖοÏγκλα" + , "Τα ΕÏείπια του ÎαοÏ" + , "Ο Ποταμός Γάγγης" + , "Τα Σπήλαια της Καλίγια" + , "ΠαÏάκτιο ΧωÏιό" + , "Σημείο Ατυχήματος" + , "Το ΦαÏάγγι ΜαντοÏμπου" + , "Ο Îαός της ΠοÏνα" + , "Η ΑποβάθÏα του Τάμεση" + , "Άλντγουιτς" + , "Η ΠÏλη της Λουντ" + , "Πόλη" + , "Η ΈÏημος της Îεβάδα" + , "Εγκαταστάσεις Υψίστης Ασφαλείας" + , "ΠεÏίοχη 51" + , "ΑνταÏκτική" + , "Τα ΟÏυχεία της RX-Tech" + , "Η Χαμένη Πόλη της Τίννος" + , "Το Σπήλαιο του ΜετεωÏίτη" + , "Άγιοι Πάντες" +}; +#endif + +#define GR_GLYPH_COUNT 61 +#define GR_GLYPH_BASE 3 +const uint8 GR_GLYPH_WIDTH[] = { + 11, 8, 9, 6, 9, 8, 10, 10, 10, 10, 11, 9, 8, 9, 9, 9, + 6, 9, 9, 8, 10, 12, 9, 9, 10, 12, 9, 10, 12, 9, 11, 9, + 10, 9, 9, 14, 8, 10, 11, 12, 10, 10, 8, 11, 12, 9, 13, 4, + 12, 12, 9, 11, 9, 10, 8, 10, 9, 10, 12, 5, 12, }; + +const char *STR_GR[] = { "\x11\x01\x22\x01\x0F\x01\x0F\x01\x0E\x01\x06\x01\x04\x01\x0C\x01\x0B\xFF\xFF" +// help + , "\x11\x01\x2F\x01\x13\x01\x07\x01\x02\x01\x16\x01\x09\x01\x0E\xFF\xFF""..." + , "\x11\x01\x1C\x01\x01\x01\x02\x01\x17\x01\x09\x01\x02\x01\x05\xFF\xFF"" H \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x03\x01\x17\x01\x19\x01\x05\x01\x04\x01\x01\xFF\xFF" + , helpText + , "%s@@@" + "\x11\x01\x31\x01\x33\x01\x24\x01\x1F\x01\x1E\x01\x1F\xFF\xFF"" %d@@" + "\x11\x01\x1F\x01\x27\x01\x1E\x01\x30\x01\x20\x01\x22\x01\x30\x01\x24\x01\x22\x01\x27\x01\x1F\xFF\xFF"" %d@@" + "\x11\x01\x24\x01\x33\x01\x23\x01\x1E\x01\x30\x01\x20\x01\x1F\xFF\xFF"" %d \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" %d@@" + "\x11\x01\x2A\x01\x35\x01\x28\x01\x27\x01\x28\x01\x23\xFF\xFF"" %s" + , "\x11\x01\x1F\x01\x08\x01\x03\x01\x19\x01\x17\x01\x0C\x01\x05\x01\x10\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x04\x01\x18\x01\x06\x01\x04\x01\x15\x01\x04\x01\x03\x01\x1B\xFF\xFF""..." + , "\x11\x01\x28\x01\x0F\x01\x03\x01\x0C\x01\x0F\x01\x0E\x01\x07\x01\x1A\x01\x19\x01\x0E\x01\x0C\x01\x05\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x03\x01\x19\x01\x17\x01\x0C\x01\x05\x01\x10\x01\x09\x01\x0E\xFF\xFF""!" + , "\x11\x01\x23\x01\x2F\x01\x1F\x01\x2C\x01\x24\x01\x1F\xFF\xFF"" \x11\x01\x1F\x01\x1C\x01\x28\x01\x31\x01\x29\x01\x20\x01\x22\x01\x33\x01\x23\x01\x29\x01\x23\xFF\xFF""!" + , "\x11\x01\x27\x01\x1F\x01\x30\xFF\xFF" + , "\x11\x01\x28\x01\x2A\x01\x30\xFF\xFF" + , "\x11\x01\x32\x01\x18\x01\x04\xFF\xFF" + , "\x11\x01\x27\x01\x01\x01\x04\xFF\xFF" + , "\x11\x01\x32\x01\x18\x01\x04\xFF\xFF" + , "Side-By-Side" + , "Anaglyph" + , "\x11\x01\x2A\x01\x16\x01\x07\x01\x04\x01\x09\x01\x0A\x01\x12\x01\x06\x01\x0E\xFF\xFF"" \x11\x01\x28\x01\x19\x01\x13\x01\x06\x01\x0E\xFF\xFF" + , "VR" + , "\x11\x01\x2A\x01\x01\x01\x0A\x01\x0E\x01\x0F\x01\x13\xFF\xFF" + , "\x11\x01\x24\x01\x05\x01\x09\x01\x01\x01\x11\x01\x03\xFF\xFF" + , "\x11\x01\x33\x01\x2D\x01\x0E\x01\x0F\x01\x13\xFF\xFF" + , STR_LANGUAGES + , "\x11\x01\x22\x01\x1D\x01\x01\x01\x07\x01\x0A\x01\x03\x01\x14\x01\x17\xFF\xFF" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF"" 1" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF"" 2" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF"" 3" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF"" 4" + , "\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x12\x01\x02\x01\x03\x01\x04\x01\x0A\x01\x03\xFF\xFF" + , "\x11\x01\x1C\x01\x01\x01\x11\x01\x0C\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" 1" + , "\x11\x01\x1C\x01\x01\x01\x11\x01\x0C\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" 2" + , "\x11\x01\x1C\x01\x01\x01\x02\x01\x17\x01\x09\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x28\x01\x08\x01\x03\x01\x04\x01\x03\x01\x15\x01\x17\x01\x08\x01\x03\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x1C\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF" + , "%s - \x11\x01\x22\x01\x08\x01\x04\x01\x0F\x01\x03\x01\x14\x01\x17\xFF\xFF" + , "%s - \x11\x01\x1C\x01\x11\x01\x09\x01\x16\xFF\xFF" +// inventory pages + , "\x11\x01\x35\x01\x33\x01\x31\x01\x24\x01\x30\x01\x23\x01\x22\x01\x30\x01\x23\xFF\xFF" + , "\x11\x01\x23\x01\x1F\x01\x20\x01\x30\x01\x26\x01\x30\x01\x28\xFF\xFF" + , "\x11\x01\x1F\x01\x27\x01\x1E\x01\x30\x01\x20\x01\x22\x01\x30\x01\x24\x01\x22\x01\x27\x01\x1F\xFF\xFF" +// save game page + , "\x11\x01\x1F\x01\x08\x01\x03\x01\x19\x01\x17\x01\x0C\x01\x05\x01\x10\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x04\x01\x18\x01\x06\x01\x04\x01\x15\x01\x04\x01\x03\x01\x1B\xFF\xFF"";" + , "\x11\x01\x1E\x01\x07\x01\x12\x01\x18\x01\x03\x01\x10\x01\x09\x01\x01\xFF\xFF"" \x11\x01\x1E\x01\x03\x01\x08\x01\x03\x01\x19\x01\x05\x01\x09\x01\x11\x01\x01\xFF\xFF" +// inventory option + , "\x11\x01\x1C\x01\x01\x01\x04\x01\x18\x01\x06\x01\x11\x01\x15\x01\x04\xFF\xFF" + , "\x11\x01\x2A\x01\x0B\x01\x07\x01\x02\x01\x0E\x01\x0D\xFF\xFF" + , "\x11\x01\x1C\x01\x10\x01\x25\x01\x11\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x23\x01\x02\x01\x01\x01\x02\x01\x04\x01\x09\x01\x02\x01\x04\x01\x0C\x01\x0B\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2E\x01\x08\x01\x01\x01\x10\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF" + , "\x11\x01\x22\x01\x08\x01\x11\x01\x08\x01\x05\x01\x15\x01\x03\xFF\xFF"" \x11\x01\x2C\x01\x05\x01\x08\x01\x02\x01\x03\x01\x0A\x01\x12\x01\x07\x01\x05\x01\x04\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x38\x01\x18\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x0A\x01\x13\x01\x0D\xFF\xFF" + , "\x11\x01\x2F\x01\x16\x01\x02\x01\x05\x01\x04\x01\x06\x01\x13\x01\x02\x01\x0E\x01\x02\x01\x01\xFF\xFF" +// passport menu + , "\x11\x01\x2F\x01\x13\x01\x07\x01\x02\x01\x16\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x1C\x01\x01\x01\x04\x01\x18\x01\x06\x01\x04\x01\x15\x01\x04\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x27\x01\x12\x01\x03\xFF\xFF"" \x11\x01\x1C\x01\x01\x01\x04\x01\x18\x01\x06\x01\x11\x01\x15\x01\x04\xFF\xFF" + , "\x11\x01\x22\x01\x08\x01\x01\x01\x06\x01\x05\x01\x0C\x01\x0C\x01\x11\x01\x06\x01\x0E\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x22\x01\x08\x01\x04\x01\x08\x01\x12\x01\x15\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x22\x01\x08\x01\x04\x01\x09\x01\x02\x01\x07\x01\x03\x01\x1D\x01\x17\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x24\x01\x05\x01\x06\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x2E\x01\x25\x01\x03\x01\x15\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x04\x01\x18\x01\x06\x01\x11\x01\x15\x01\x04\xFF\xFF" + , "\x11\x01\x22\x01\x08\x01\x04\x01\x0F\x01\x03\x01\x14\x01\x17\xFF\xFF"" \x11\x01\x22\x01\x08\x01\x04\x01\x08\x01\x12\x01\x15\x01\x03\x01\x10\xFF\xFF" +// detail options + , "\x11\x01\x22\x01\x08\x01\x04\x01\x0F\x01\x03\x01\x14\x01\x17\xFF\xFF"" \x11\x01\x2C\x01\x05\x01\x08\x01\x02\x01\x03\x01\x0A\x01\x12\x01\x07\x01\x05\x01\x04\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x2F\x01\x04\x01\x0F\x01\x02\x01\x07\x01\x0B\x01\x07\x01\x04\x01\x09\x01\x0A\x01\x01\xFF\xFF" + , "\x11\x01\x2F\x01\x16\x01\x02\x01\x04\x01\x09\x01\x0A\x01\x13\x01\x0D\xFF\xFF" + , "\x11\x01\x23\x01\x0C\x01\x04\x01\x12\x01\x0D\xFF\xFF" + , "\x11\x01\x27\x01\x05\x01\x07\x01\x13\xFF\xFF" + , "VSync" + , "\x11\x01\x23\x01\x02\x01\x05\x01\x07\x01\x05\x01\x03\x01\x09\x01\x0C\x01\x03\x01\x08\x01\x11\x01\x01\xFF\xFF" + , "\x11\x01\x1F\x01\x08\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x1F\x01\x06\x01\x02\x01\x04\x01\x0C\x01\x05\x01\x11\x01\x0A\x01\x05\x01\x06\x01\x01\xFF\xFF" + , "Resolution" + , STR_SCALE +// sound options + , "\x11\x01\x35\x01\x1B\x01\x19\x01\x0A\x01\x04\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x22\x01\x06\x01\x02\x01\x0B\x01\x09\x01\x05\x01\x16\x01\x06\xFF\xFF" + , "\x11\x01\x1F\x01\x06\x01\x02\x01\x17\x01\x18\x01\x0E\x01\x09\x01\x0E\xFF\xFF" + , "\x11\x01\x33\x01\x08\x01\x13\x01\x02\x01\x04\x01\x02\x01\x0F\x01\x03\x01\x04\xFF\xFF" + , "\x11\x01\x37\x01\x0F\x01\x1A\x01\x09\x01\x09\x01\x01\xFF\xFF" +// controls options + , "\x11\x01\x35\x01\x1B\x01\x19\x01\x0A\x01\x04\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x0A\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x1C\x01\x0F\x01\x0E\x01\x0C\x01\x02\x01\x07\x01\x03\x01\x0F\x01\x13\x01\x14\x01\x04\x01\x03\xFF\xFF" + , "\x11\x01\x2A\x01\x05\x01\x04\x01\x07\x01\x04\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF" + , "\x11\x01\x26\x01\x13\x01\x06\x01\x0E\x01\x09\x01\x0E\xFF\xFF" + , "\x11\x01\x27\x01\x12\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x23\x01\x02\x01\x13\x01\x18\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x1C\x01\x03\x01\x0F\x01\x0F\x01\x01\x01\x08\x01\x0F\x01\x17\xFF\xFF"" \x11\x01\x23\x01\x02\x01\x13\x01\x18\x01\x05\x01\x10\x01\x09\x01\x0E\xFF\xFF" + // controls + , "\x11\x01\x1F\x01\x07\x01\x04\x01\x09\x01\x02\x01\x05\x01\x07\x01\x13\xFF\xFF", "\x11\x01\x26\x01\x05\x01\x25\x01\x11\xFF\xFF", "\x11\x01\x24\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF", "\x11\x01\x1C\x01\x11\x01\x09\x01\x16\xFF\xFF", "\x11\x01\x34\x01\x0F\x01\x0A\x01\x01\xFF\xFF", "\x11\x01\x1C\x01\x05\x01\x07\x01\x08\x01\x0B\x01\x02\x01\x0E\x01\x0A\x01\x01\xFF\xFF", "\x11\x01\x26\x01\x07\x01\x0B\x01\x09\x01\x0E\xFF\xFF", "\x11\x01\x2A\x01\x07\x01\x17\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x32\x01\x08\x01\x0F\x01\x03\x01\x10\xFF\xFF", "\x11\x01\x20\x01\x03\x01\x11\x01\x02\x01\x01\x01\x14\x01\x0A\x01\x01\xFF\xFF", "\x11\x01\x23\x01\x0C\x01\x1B\x01\x2D\x01\x04\x01\x0A\x01\x03\xFF\xFF", "\x11\x01\x1E\x01\x07\x01\x12\x01\x25\x01\x04\x01\x0A\x01\x03\xFF\xFF", "\x11\x01\x1E\x01\x03\x01\x1B\x01\x0A\x01\x08\x01\x01\xFF\xFF", "\x11\x01\x23\x01\x01\x01\x0C\x01\x11\x01\x15\x01\x04\x01\x03\xFF\xFF", "\x11\x01\x3A\x01\x05\x01\x0C\x01\x11\x01\x06\x01\x0E\x01\x0A\x01\x01\xFF\xFF" + , STR_KEYS +// inventory items + , "\x11\x01\x34\x01\x14\x01\x06\x01\x16\x01\x09\x01\x02\x01\x03\xFF\xFF" + , "\x11\x01\x22\x01\x0C\x01\x07\x01\x0E\x01\x0C\x01\x02\x01\x04\x01\x0C\x01\x0B\xFF\xFF" + , "\x11\x01\x1C\x01\x04\x01\x09\x01\x02\x01\x13\x01\x0F\x01\x04\x01\x01\xFF\xFF" + , "\x11\x01\x20\x01\x01\x01\x07\x01\x01\x01\x0A\x01\x08\x01\x11\x01\x06\x01\x01\xFF\xFF" + , "\x11\x01\x24\x01\x0B\x01\x14\x01\x0C\x01\x06\x01\x03\x01\x10\x01\x0A\xFF\xFF" + , "\x11\x01\x28\x01\x1B\x01\x2B\x01\x04\xFF\xFF" + , "\x11\x01\x23\x01\x1D\x01\x01\x01\x11\x01\x07\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x1C\x01\x04\x01\x09\x01\x02\x01\x03\x01\x0F\x01\x04\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x2F\x01\x10\x01\x09\x01\x11\x01\x14\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x07\x01\x01\x01\x0A\x01\x08\x01\x11\x01\x06\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x23\x01\x1D\x01\x01\x01\x11\x01\x07\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x24\x01\x0B\x01\x14\x01\x0C\x01\x06\x01\x03\x01\x10\x01\x0A\xFF\xFF" + , "\x11\x01\x23\x01\x1D\x01\x01\x01\x11\x01\x07\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x28\x01\x1B\x01\x2B\x01\x04\xFF\xFF" + , "\x11\x01\x24\x01\x04\x01\x0C\x01\x07\x01\x13\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x10\x01\x02\x01\x11\xFF\xFF"" \x11\x01\x1C\x01\x07\x01\x1A\x01\x02\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x36\x01\x03\x01\x0E\x01\x19\x01\x05\x01\x04\x01\x1A\x01\x06\xFF\xFF" + , "\x11\x01\x24\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x10\x01\x02\x01\x11\xFF\xFF"" \x11\x01\x1C\x01\x07\x01\x1A\x01\x02\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x36\x01\x03\x01\x0E\x01\x19\x01\x05\x01\x04\x01\x1A\x01\x06\xFF\xFF" + , "\x11\x01\x35\x01\x0B\x01\x21\x01\x15\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x24\x01\x03\x01\x0F\x01\x1B\x01\x21\x01\x15\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x20\x01\x05\x01\x04\x01\x0A\x01\x17\x01\x0F\x01\x04\x01\x03\xFF\xFF" +// keys + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" + , "\x11\x01\x1F\x01\x09\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" + , "\x11\x01\x23\x01\x0C\x01\x03\x01\x10\x01\x07\x01\x04\x01\x01\x01\x09\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" + , "\x11\x01\x2A\x01\x07\x01\x10\x01\x09\x01\x13\xFF\xFF"" \x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" + , "\x11\x01\x39\x01\x01\x01\x1D\x01\x05\x01\x04\x01\x07\x01\x12\x01\x06\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF"" \x11\x01\x1C\x01\x03\x01\x09\x01\x05\x01\x04\x01\x15\x01\x1A\x01\x06\x01\x01\xFF\xFF" + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF"" \x11\x01\x34\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x01\xFF\xFF" + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF"" \x11\x01\x26\x01\x01\x01\x0A\x01\x03\x01\x0C\x01\x0F\x01\x17\xFF\xFF" + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF"" \x11\x01\x31\x01\x16\x01\x07\xFF\xFF" + , "\x11\x01\x26\x01\x04\x01\x01\x01\x0C\x01\x03\x01\x09\x01\x0A\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF" +// puzzles + , "\x11\x01\x37\x01\x07\x01\x11\x01\x1D\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x2A\x01\x07\x01\x10\x01\x09\x01\x13\xFF\xFF"" \x11\x01\x22\x01\x11\x01\x15\x01\x16\x01\x0F\x01\x03\xFF\xFF" + , "\x11\x01\x35\x01\x0B\x01\x21\x01\x15\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x2A\x01\x07\x01\x10\x01\x09\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x37\x01\x07\x01\x01\x01\x06\x01\x0B\x01\x2B\x01\x04\xFF\xFF"" \x11\x01\x24\x01\x0E\x01\x18\x01\x01\x01\x06\x01\x17\x01\x0D\xFF\xFF" + , "\x11\x01\x1F\x01\x09\x01\x1D\x01\x0B\x01\x0F\x01\x05\x01\x04\x01\x01\xFF\xFF" + , "\x11\x01\x1F\x01\x06\x01\x0C\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x24\x01\x0B\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x3D\x01\x07\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x23\x01\x1D\x01\x07\x01\x01\x01\x14\x01\x11\x01\x15\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x34\x01\x06\x01\x03\x01\x10\x01\x21\x01\x04\xFF\xFF" + , "\x11\x01\x23\x01\x0C\x01\x01\x01\x07\x01\x01\x01\x21\x01\x01\x01\x11\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x20\x01\x0F\x01\x05\x01\x04\x01\x15\x01\x11\xFF\xFF"" \x11\x01\x1C\x01\x10\x01\x07\x01\x01\x01\x0A\x01\x11\x01\x15\x01\x01\xFF\xFF" +// TR1 subtitles + /* CAFE */ , + "[43500]\x11\x01\x1E\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x12\x01\x08\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x06\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x07\x01\x05\x01\x04\xFF\xFF""@\x11\x01\x01\x01\x10\x01\x02\x01\x03\x01\x1B\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x15\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x03\x01\x18\x01\x17\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x09\x01\x12\x01\x06\x01\x01\xFF\xFF"";" + "[47500]\x11\x01\x26\x01\x1B\x01\x09\x01\x0C\x01\x03\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x08\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x07\x01\x04\x01\x21\x01\x1A\x01\x0D\xFF\xFF"",@\x11\x01\x01\x01\x0F\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x1D\x01\x01\x01\x11\x01\x06\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x0F\x01\x0B\xFF\xFF""." + "[50000]\x11\x01\x1E\x01\x12\x01\x0F\x01\x05\x01\x04\x01\x01\xFF\xFF"". \x11\x01\x1F\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x1B\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x0F\x01\x17\x01\x19\x01\x05\x01\x04\x01\x01\xFF\xFF"",@\x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x14\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x19\x01\x12\x01\x0F\x01\x05\x01\x04\xFF\xFF""." + "[54500]\x11\x01\x32\x01\x18\x01\x04\xFF\xFF"";" + "[55000]\x11\x01\x32\x01\x18\x01\x04\xFF\xFF"". \x11\x01\x29\xFF\xFF"" \x11\x01\x26\x01\x05\x01\x09\x01\x08\x01\x03\x01\x04\x01\x06\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x1E\x01\x2B\x01\x01\x01\x0C\x01\x0F\x01\x11\x01\x06\xFF\xFF"" \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x19\x01\x12\x01\x0F\x01\x05\x01\x04\xFF\xFF"",@\x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" Natla Technologies." + "[59000]\x11\x01\x3A\x01\x12\x01\x07\x01\x05\x01\x04\x01\x0D\xFF\xFF"", \x11\x01\x0E\xFF\xFF"" \x11\x01\x15\x01\x0E\x01\x0A\x01\x04\x01\x03\x01\x10\x01\x07\x01\x14\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x13\x01\x0F\x01\x16\x01\x06\xFF\xFF""@\x11\x01\x02\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x1D\x01\x01\x01\x06\x01\x02\x01\x01\x01\x18\x01\x02\x01\x05\x01\x07\x01\x1A\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x13\x01\x0A\x01\x03\x01\x07\x01\x1D\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x01\x01\x14\x01\x0A\x01\x0B\x01\x02\x01\x16\x01\x06\xFF\xFF""." + "[64500]\x11\x01\x23\x01\x0C\x01\x0B\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x09\x01\x03\x01\x06\xFF\xFF""." + "[66000]\x11\x01\x24\x01\x0B\x01\x0F\x01\x04\x01\x09\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x20\x01\x10\x01\x07\x01\x11\x01\x01\xFF\xFF""." + "[68000]\x11\x01\x35\x01\x11\x01\x25\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x02\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF""." + "[70500]\x11\x01\x1C\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1D\x01\x01\x01\x04\x01\x06\x01\x13\x01\x02\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x19\x01\x12\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x08\x01\x03\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x0E\x01\x15\x01\x05\x01\x06\x01\x04\x01\x0C\x01\x0B\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0F\x01\x03\x01\x14\x01\x01\x01\x07\x01\x04\x01\x01\x01\x09\x01\x0A\x01\x13\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"";" + "[73500]\x11\x01\x2C\x01\x10\x01\x08\x01\x0B\x01\x0A\x01\x01\x01\x04\xFF\xFF"". \x11\x01\x1C\x01\x01\x01\x11\x01\x2B\x01\x16\xFF\xFF"" \x11\x01\x0A\x01\x13\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x1D\x01\x01\x01\x06\x01\x12\x01\x0F\x01\x01\xFF\xFF""." + "[76000]\x11\x01\x1E\x01\x13\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x12\x01\x09\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x17\x01\x08\x01\x05\x01\x15\x01\x01\xFF\xFF""." + "[78000]\x11\x01\x1C\x01\x05\x01\x07\x01\x03\x01\x1B\xFF\xFF"". \x11\x01\x24\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x21\x01\x03\x01\x10\x01\x06\x01\x03\x01\x0C\x01\x03\x01\x07\x01\x1D\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x25\x01\x05\x01\x07\x01\x05\x01\x1B\x01\x06\x01\x0E\x01\x09\x01\x0E\xFF\xFF"".@\x11\x01\x1E\x01\x05\x01\x07\x01\x0B\x01\x09\x01\x02\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x05\x01\x11\x01\x18\x01\x0E\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x14\x01\x03\x01\x10\xFF\xFF"". \x11\x01\x1F\x01\x08\x01\x13\x01\x0C\x01\x07\x01\x0E\x01\x0A\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x0B\x01\x18\x01\x04\x01\x01\xFF\xFF"". \x11\x01\x1F\x01\x06\x01\x05\x01\x0F\x01\x12\x01\x0E\x01\x02\x01\x03\x01\x04\xFF\xFF"" \x11\x01\x0B\x01\x06\x01\x05\x01\x0A\x01\x03\x01\x04\xFF\xFF""." + "[87500]\x11\x01\x20\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x10\x01\x08\x01\x0B\x01\x07\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x0C\x01\x07\x01\x13\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x04\x01\x18\x01\x0F\x01\x04\x01\x0A\x01\x08\x01\x11\x01\x15\x01\x04\xFF\xFF"":@\x11\x01\x2E\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x06\x01\x0B\x01\x07\x01\x18\x01\x01\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x05\x01\x04\x01\x0A\x01\x17\x01\x0F\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x10\x01\x09\x01\x02\x01\x04\x01\x0C\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x04\x01\x0D\xFF\xFF" + "[92500]\x11\x01\x19\x01\x01\x01\x0A\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x18\x01\x01\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x1B\x01\x0A\x01\x21\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x10\x01\x01\x01\x0F\x01\x03\x01\x08\x01\x12\x01\x0C\xFF\xFF""." + "[96000]\x11\x01\x1F\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x05\x01\x06\x01\x15\x01\x04\x01\x01\x01\x1D\x01\x12\x01\x07\x01\x05\x01\x04\xFF\xFF""." + "[98000]\x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x03\x01\x1B\x01\x09\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x1D\x01\x1B\x01\x14\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x1B\x01\x07\x01\x04\x01\x03\xFF\xFF"".@\x11\x01\x20\x01\x0B\x01\x06\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x11\x01\x08\x01\x03\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x1B\x01\x07\x01\x04\x01\x03\xFF\xFF"";" + /* LIFT */ , + "[49000]\x11\x01\x22\x01\x14\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x09\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x12\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x24\x01\x03\x01\x06\x01\x17\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1F\x01\x14\xFF\xFF"". \x11\x01\x2F\x01\x07\x01\x01\x01\x14\x01\x0C\x01\x11\x01\x09\x01\x0C\x01\x03\x01\x10\xFF\xFF"", \x11\x01\x06\x01\x12\x01\x03\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x04\x01\x07\x01\x01\x01\x09\x01\x0A\x01\x03\x01\x11\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x21\x01\x01\x01\x09\x01\x01\x01\x06\x01\x11\x01\x2B\x01\x03\x01\x10\x01\x06\xFF\xFF""." + "[53500]\x11\x01\x2F\x01\x17\x01\x0A\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x09\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x15\x01\x05\x01\x07\x01\x1D\x01\x03\x01\x1B\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x0F\x01\x12\x01\x06\x01\x05\xFF\xFF"" \x11\x01\x13\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x02\x01\x16\xFF\xFF""@\x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x06\x01\x01\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x11\x01\x09\x01\x0C\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x06\x01\x02\x01\x01\x01\x1D\x01\x04\x01\x01\x01\x09\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x1A\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF""," + "[60000]\x11\x01\x05\x01\x06\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x10\x01\x19\x01\x04\x01\x0C\x01\x03\x01\x1B\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x10\x01\x21\x01\x05\x01\x07\x01\x06\x01\x17\x01\x02\x01\x05\x01\x0D\xFF\xFF""@ \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF"", \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x18\x01\x01\x01\x0A\x01\x12\x01\x06\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x0E\x01\x08\x01\x05\x01\x11\x01\x07\x01\x03\x01\x10\xFF\xFF" + "[64500]\x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x2B\x01\x11\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x0C\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x0A\x01\x0A\x01\x0B\x01\x02\x01\x04\xFF\xFF""@\x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x05\x01\x04\x01\x0A\x01\x17\x01\x0F\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF""." + "[68000]\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x04\x01\x15\x01\x12\x01\x07\x01\x01\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x18\x01\x16\x01\x07\x01\x11\x01\x09\x01\x02\x01\x0E\x01\x0C\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x04\x01\x07\x01\x0B\x01\x09\x01\x02\x01\x0E\x01\x0C\x01\x05\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x09\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x10\x01\x21\x01\x05\x01\x07\x01\x06\x01\x17\x01\x02\x01\x05\x01\x0D\xFF\xFF""@" + "[72500]\x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x03\x01\x08\x01\x03\x01\x11\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x11\x01\x06\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x05\x01\x07\x01\x0B\x01\x09\x01\x02\x01\x04\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x04\x01\x0D\xFF\xFF"".@\x11\x01\x26\x01\x10\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x08\x01\x12\x01\x07\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x11\x01\x15\x01\x04\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x26\x01\x0E\x01\x0A\x01\x04\x01\x03\x01\x10\x01\x07\x01\x14\x01\x03\x01\x1B\xFF\xFF""." + "[79000]\x11\x01\x30\x01\x15\x01\x07\x01\x1A\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x13\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x09\x01\x0C\x01\x12\x01\x2D\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x12\x01\x02\x01\x03\x01\x04\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x01\x01\x02\x01\x03\x01\x02\x01\x17\x01\x02\x01\x16\x01\x06\xFF\xFF""@\x11\x01\x05\x01\x06\x01\x1A\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x0E\xFF\xFF"" \x11\x01\x19\x01\x06\x01\x0E\x01\x02\x01\x13\x01\x0D\xFF\xFF""." + "[85500]\x11\x01\x20\x01\x0B\x01\x19\x01\x05\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x0B\x01\x15\x01\x10\xFF\xFF"", \x11\x01\x08\x01\x04\x01\x12\x01\x2B\x01\x16\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x25\x01\x05\x01\x18\x01\x0B\x01\x09\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x04\x01\x0D\xFF\xFF""@\x11\x01\x1D\x01\x01\x01\x06\x01\x02\x01\x01\x01\x09\x01\x04\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"", \x11\x01\x01\x01\x0F\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x14\x01\x05\x01\x14\x01\x03\x01\x06\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x13\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x13\x01\x0C\x01\x05\x01\x04\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x15\x01\x03\x01\x0C\x01\x04\x01\x0A\x01\x01\x01\x09\x01\x11\x01\x01\xFF\xFF""." + "[92000]" + "[93500]\x11\x01\x1C\x01\x04\x01\x12\x01\x07\xFF\xFF"". \x11\x01\x1E\x01\x09\x01\x0C\xFF\xFF"". \x11\x01\x36\x01\x07\x01\x16\x01\x0A\x01\x04\x01\x0B\x01\x07\x01\x0E\xFF\xFF""." + /* CANYON */ , + "[13500]\x11\x01\x1E\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x0E\x01\x09\x01\x05\x01\x0D\xFF\xFF""." + "[16500]'\x11\x01\x23\x01\x08\x01\x12\x01\x07\x01\x01\xFF\xFF""." + "[17500]\x11\x01\x20\x01\x01\x01\x0F\x01\x0E\x01\x09\x01\x08\x01\x12\x01\x07\x01\x01\xFF\xFF""." + "[20000]\x11\x01\x1C\x01\x01\x01\x07\x01\x0B\x01\x02\x01\x0E\x01\x09\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x09\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x07\x01\x03\x01\x10\x01\x1D\x01\x0B\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x12\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x0F\x01\x03\x01\x04\x01\x08\x01\x13\x01\x06\xFF\xFF"";" + "[22500]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x21\x01\x14\x01\x0B\x01\x2B\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x06\x01\x13\x01\x0E\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x17\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x1D\x01\x07\x01\x0B\x01\x09\x01\x0E\xFF\xFF""." + "[24000]\x11\x01\x2C\x01\x03\x01\x04\x01\x08\x01\x13\x01\x06\xFF\xFF"", \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x06\x01\x0E\x01\x14\x01\x10\x01\x07\x01\x0B\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x02\x01\x05\x01\x0F\x01\x05\x01\x11\x01\x16\x01\x09\x01\x05\xFF\xFF""." + "[27000]\x11\x01\x38\x01\x07\x01\x19\x01\x05\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x1A\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x15\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x13\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x12\x01\x0C\x01\x0F\x01\x05\x01\x2D\x01\x05\x01\x0D\xFF\xFF""." + "[30000]\x11\x01\x1F\x01\x0D\xFF\xFF"" \x11\x01\x2D\x01\x0B\x01\x25\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x01\x01\x0C\x01\x11\x01\x15\x01\x04\x01\x03\xFF\xFF""." + "[32000]" + "[42500]\x11\x01\x1E\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x04\x01\x0A\x01\x12\x01\x06\x01\x05\x01\x02\x01\x05\xFF\xFF""; \x11\x01\x23\x01\x0C\x01\x03\x01\x02\x01\x1A\x01\x09\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF""!" + "[45000]\x11\x01\x2E\x01\x04\xFF\xFF""!" + "[48000]" + "[50500]\x11\x01\x39\x01\x16\x01\x06\x01\x02\x01\x13\x01\x21\x01\x03\x01\x0F\x01\x01\xFF\xFF""!" + "[53000]" + "[62500]\x11\x01\x1C\x01\x0B\x01\x0A\x01\x05\xFF\xFF""." + "[65000]" + "[136000]\x11\x01\x1E\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x0B\x01\x03\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x17\x01\x02\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"";" + "[138000]\x11\x01\x1C\x01\x03\x01\x04\x01\x03\xFF\xFF"";" + "[138500]\x11\x01\x1F\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x05\x01\x0C\x01\x05\x01\x11\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x03\x01\x1B\x01\x09\x01\x02\x01\x0E\x01\x0C\x01\x05\xFF\xFF""." + "[140500]\x11\x01\x24\x01\x0B\x01\x0F\x01\x0F\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x2D\x01\x0B\x01\x07\x01\x04\xFF\xFF""." + "[142500]\x11\x01\x1C\x01\x07\x01\x12\x01\x08\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x2D\x01\x0B\x01\x07\x01\x04\xFF\xFF"", \x11\x01\x1D\x01\x11\x01\x0F\x01\x05\xFF\xFF""." + "[145000]\x11\x01\x2A\x01\x01\x01\x0F\x01\x0B\x01\x07\x01\x16\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x05\xFF\xFF"".@\x11\x01\x1C\x01\x0B\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x0F\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x09\x01\x01\xFF\xFF"". \x11\x01\x2E\x01\x07\x01\x18\x01\x05\x01\x09\x01\x01\x01\x04\xFF\xFF"";" + "[152000]" + "[158000]\x11\x01\x38\x01\x07\x01\x05\x01\x0A\x01\x01\xFF\xFF""..." + "[160000]\x11\x01\x2E\x01\x1D\x01\x10\x01\x14\x01\x05\xFF\xFF""." + "[161500]\x11\x01\x22\x01\x11\x01\x09\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x12\x01\x02\x01\x03\x01\x04\x01\x0A\x01\x03\x01\x0D\xFF\xFF"";" + /* PRISON */ , + "[00001]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x05\x01\x11\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x05\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF""!" + "[01500]\x11\x01\x23\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x15\x01\x04\x01\x0C\x01\x0B\x01\x2B\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF"", \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF"", \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x14\x01\x0C\x01\x0F\x01\x17\x01\x0A\x01\x01\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF""." + "[06000]\x11\x01\x37\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x0B\x01\x1D\x01\x16\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x0B\x01\x18\x01\x07\x01\x0E\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x1A\x01\x06\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF""@\x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\x01\x02\x01\x11\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x12\x01\x0C\x01\x0F\x01\x05\x01\x2D\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x0C\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF""." + "[11500]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x05\x01\x11\x01\x02\x01\x05\xFF\xFF""! \x11\x01\x22\x01\x14\x01\x1A\xFF\xFF""..." + "[12500]\x11\x01\x23\x01\x08\x01\x0B\x01\x2B\x01\x03\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x09\x01\x0A\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x10\x01\x14\x01\x0C\x01\x01\x01\x02\x01\x0B\x01\x19\x01\x05\x01\x09\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x02\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x08\xFF\xFF""' \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x03\x01\x08\x01\x03\x01\x11\x01\x01\xFF\xFF""@\x11\x01\x03\xFF\xFF"" \x11\x01\x0F\x01\x01\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x10\x01\x21\x01\x05\x01\x07\x01\x06\x01\x0B\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x25\x01\x01\x01\x09\x01\x1D\x01\x01\x01\x0F\x01\x11\x01\x2B\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF""," + "[18500]\x11\x01\x21\x01\x0B\x01\x0F\x01\x0F\x01\x03\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x0A\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x11\x01\x15\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x07\x01\x01\x01\x02\x01\x13\xFF\xFF""." + "[23500]\x11\x01\x29\xFF\xFF"" \x11\x01\x08\x01\x10\x01\x07\x01\x01\x01\x0A\x01\x11\x01\x15\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x0C\x01\x0C\x01\x05\x01\x06\x01\x1A\x01\x19\x01\x0E\x01\x0C\x01\x05\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x07\x01\x01\x01\x02\x01\x04\x01\x1A\x01\x02\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF" + "[27000]\x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x09\x01\x1B\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x18\x01\x07\x01\x0E\x01\x09\x01\x04\x01\x0A\x01\x03\x01\x08\x01\x03\x01\x04\x01\x17\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x10\x01\x07\x01\x01\x01\x0A\x01\x11\x01\x15\x01\x01\xFF\xFF"" - \x11\x01\x02\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x0B\x01\x0A\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF""@\x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x15\x01\x0E\x01\x0A\x01\x04\x01\x03\x01\x10\x01\x07\x01\x14\x01\x11\x01\x01\xFF\xFF"" - \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x0C\x01\x17\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x05\x01\x07\x01\x11\x01\x09\x01\x0C\x01\x05\x01\x08\x01\x02\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x09\x01\x02\x01\x07\x01\x03\x01\x1D\x01\x17\xFF\xFF""." + "[33500]\x11\x01\x1F\x01\x08\x01\x05\x01\x07\x01\x11\x01\x09\x01\x0C\x01\x05\x01\x08\x01\x02\x01\x0E\xFF\xFF"";!; \x11\x01\x20\x01\x03\x01\x11\x01\x02\x01\x01\x01\x25\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x09\x01\x01\x01\x04\xFF\xFF""!" + "[35500]\x11\x01\x20\x01\x01\x01\x06\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x09\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0B\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x1D\x01\x05\x01\x10\x01\x07\x01\x05\x01\x02\x01\x04\x01\x0C\x01\x13\x01\x02\x01\x0E\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x05\x01\x1D\x01\x0B\x01\x0F\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF""." + "[40500]\x11\x01\x34\x01\x18\x01\x07\x01\x0E\x01\x09\x01\x02\x01\x03\x01\x04\xFF\xFF""!" + "[41500]\x11\x01\x1F\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF""." + "[44000]\x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF""!" + "[45000]\x11\x01\x2A\x01\x07\x01\x0E\x01\x09\x01\x04\x01\x0A\x01\x03\x01\x08\x01\x03\x01\x11\x01\x0E\x01\x09\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\x01\x06\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x04\x01\x05\x01\x07\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x13\x01\x08\x01\x03\xFF\xFF"" \x11\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x0E\x01\x14\x01\x17\xFF\xFF""@\x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x16\x01\x08\x01\x04\x01\x0C\x01\x17\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x05\x01\x10\x01\x18\x01\x01\x01\x07\x01\x11\x01\x09\x01\x02\x01\x0E\x01\x09\x01\x0E\x01\x0D\xFF\xFF""," + "[49500]\x11\x01\x09\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x07\x01\x14\x01\x03\x01\x09\x01\x02\x01\x0B\x01\x09\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x05\x01\x07\x01\x01\x01\x02\x01\x03\x01\x14\x01\x05\x01\x06\x01\x12\x01\x09\x01\x05\x01\x16\x01\x06\xFF\xFF""." + "[51000]\x11\x01\x22\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x2B\x01\x17\x01\x09\x01\x01\x01\x06\x01\x02\x01\x05\x01\x0D\xFF\xFF"". \x11\x01\x24\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x12\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x05\x01\x06\x01\x04\x01\x0B\xFF\xFF""." + "[54000]\x11\x01\x1E\x01\x1A\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x16\x01\x07\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x1D\x01\x01\x01\x14\x01\x17\x01\x0D\xFF\xFF""." + "[56000]\x11\x01\x20\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x09\x01\x1B\xFF\xFF"". \x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x1D\x01\x07\x01\x03\x01\x06\x01\x02\x01\x11\x01\x09\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x25\x01\x05\x01\x18\x01\x01\x01\x09\x01\x02\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x13\x01\x0F\x01\x03\x01\x10\x01\x0D\xFF\xFF""." + "[60000]\x11\x01\x22\x01\x11\x01\x19\x01\x05\xFF\xFF"" \x11\x01\x03\x01\x04\xFF\xFF"" \x11\x01\x1D\x01\x0F\x01\x12\x01\x21\x01\x05\x01\x0D\xFF\xFF"", \x11\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x07\x01\x15\x01\x04\x01\x0B\xFF\xFF"", \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x13\x01\x15\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF" + "[64000]\x11\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x07\x01\x16\x01\x09\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x14\x01\x0C\x01\x12\x01\x1D\x01\x01\x01\x0F\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x0F\x01\x0F\x01\x17\x01\x09\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x14\x01\x05\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x14\x01\x16\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x11\x01\x0A\x01\x01\xFF\xFF""." + "[70000]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x01\x01\x08\x01\x01\x01\x10\x01\x19\x01\x05\x01\x11\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x2D\x01\x10\x01\x18\x01\x17\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x04\x01\x1A\x01\x06\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x04\x01\x1A\x01\x06\x01\x16\x01\x06\xFF\xFF"" \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF""." + "[73000]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x01\x01\x08\x01\x01\x01\x10\x01\x19\x01\x05\x01\x11\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x03\x01\x1B\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x05\x01\x09\x01\x05\x01\x11\x01\x0D\xFF\xFF"", \x11\x01\x03\x01\x1B\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x07\x01\x01\x01\x0A\x01\x12\x01\x06\x01\x0E\xFF\xFF"" \x11\x01\x17\x01\x08\x01\x05\x01\x04\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF""!" + /* 22 */ , + "[04000]\x11\x01\x22\x01\x08\x01\x12\x01\x09\x01\x02\x01\x07\x01\x05\x01\x2D\x01\x05\x01\x0D\xFF\xFF"";" + "[05500]\x11\x01\x20\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x09\x01\x1B\xFF\xFF"" - \x11\x01\x1D\x01\x01\x01\x06\x01\x02\x01\x0B\x01\x2B\x01\x03\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x06\x01\x02\x01\x10\x01\x08\x01\x16\x01\x09\x01\x04\x01\x01\x01\x0C\x01\x17\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x09\x01\x03\x01\x15\x01\x03\xFF\xFF""." + "[09500]\x11\x01\x29\xFF\xFF"" \x11\x01\x05\x01\x25\x01\x12\x01\x0F\x01\x04\x01\x25\x01\x0E\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x11\x01\x09\x01\x0C\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x13\x01\x0A\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" - \x11\x01\x0E\xFF\xFF"" \x11\x01\x1D\x01\x10\x01\x09\x01\x04\x01\x0C\x01\x17\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x0F\x01\x03\x01\x14\x01\x17\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x16\x01\x02\x01\x03\x01\x1D\x01\x01\x01\x06\x01\x17\xFF\xFF"" \x11\x01\x18\x01\x01\x01\x0A\x01\x0E\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x11\x01\x08\x01\x05\x01\x15\x01\x01\xFF\xFF""..." + "[13500]\x11\x01\x29\xFF\xFF"" \x11\x01\x06\x01\x12\x01\x01\xFF\xFF"" \x11\x01\x1D\x01\x03\x01\x10\x01\x07\x01\x06\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0C\x01\x01\x01\x0F\x01\x12\x01\x09\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x0F\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x15\x01\x01\x01\x1D\x01\x04\x01\x0C\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x01\x01\x0A\x01\x0B\x01\x18\x01\x05\x01\x0D\xFF\xFF" + "[17500] - \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x10\x01\x06\x01\x01\x01\x0A\x01\x1A\x01\x09\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF""..." + "[20500]\x11\x01\x26\x01\x0E\x01\x0A\x01\x04\x01\x03\x01\x10\x01\x07\x01\x14\x01\x1A\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x12\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x15\x01\x0E\xFF\xFF""." + "[22500]\x11\x01\x20\x01\x0B\x01\x08\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x25\x01\x12\x01\x0F\x01\x04\x01\x25\x01\x0E\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x05\x01\x07\x01\x03\x01\x05\x01\x04\x01\x15\x01\x17\xFF\xFF"" \x11\x01\x02\x01\x13\x01\x02\x01\x05\xFF\xFF""." + "[24500]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x17\x01\x25\x01\x05\x01\x07\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x1B\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x17\x01\x07\x01\x19\x01\x05\xFF\xFF""...@\x11\x01\x01\x01\x10\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x07\x01\x05\x01\x0A\x01\x0B\x01\x0F\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x10\x01\x0B\x01\x0F\x01\x03\x01\x08\x01\x05\x01\x0C\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x03\xFF\xFF"" \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x18\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x04\x01\x15\x01\x12\x01\x01\xFF\xFF" + "[29500] - \x11\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x0C\x01\x0F\x01\x10\x01\x09\x01\x0A\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x18\x01\x02\x01\x1B\x01\x08\x01\x0E\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x1D\x01\x10\x01\x0F\x01\x17\xFF\xFF"" \x11\x01\x0E\x01\x0F\x01\x04\x01\x19\x01\x11\x01\x16\x01\x06\xFF\xFF""..." + "[33500]\x11\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x14\x01\x1B\x01\x07\x01\x04\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x0F\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x11\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x01\x01\x09\x01\x04\x01\x0C\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x21\x01\x11\x01\x16\x01\x09\x01\x0E\x01\x0D\xFF\xFF""..." + "[37000]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x08\x01\x07\x01\x05\x01\x08\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x11\x01\x06\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x12\x01\x02\x01\x09\x01\x04\xFF\xFF""." + "[39000]\x11\x01\x28\x01\x1B\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x13\x01\x08\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x1A\x01\x07\x01\x01\xFF\xFF""." + "[40000]\x11\x01\x29\xFF\xFF"" \x11\x01\x05\x01\x0C\x01\x0C\x01\x13\x01\x0F\x01\x01\x01\x2D\x01\x0E\xFF\xFF"" \x11\x01\x25\x01\x05\x01\x0C\x01\x04\x01\x06\x01\x0B\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" 15 \x11\x01\x15\x01\x05\x01\x10\x01\x02\x01\x05\x01\x07\x01\x13\x01\x0F\x01\x05\x01\x08\x01\x02\x01\x01\xFF\xFF""." + "[43000]\x11\x01\x1C\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x14\x01\x0B\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x0C\x01\x02\x01\x07\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x04\x01\x01\xFF\xFF""!" + "[45000]\x11\x01\x32\x01\x18\x01\x04\xFF\xFF"" \x11\x01\x18\x01\x16\x01\x07\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x07\x01\x15\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x18\x01\x05\x01\x11\x01\x07\x01\x0E\x01\x09\x01\x0E\x01\x0D\xFF\xFF""!" + "[47000]\x11\x01\x32\x01\x03\x01\x03\x01\x03\x01\x18\x01\x04\xFF\xFF""!" + "[50000]\x11\x01\x26\x01\x22\x01\x20\x01\x1F\xFF\xFF" + "[54000]\x11\x01\x1C\x01\x22\x01\x27\x01\x1E\x01\x22\xFF\xFF""..." + "[55500]4...3...2..." + "[60000]\x11\x01\x22\x01\x27\x01\x1F\xFF\xFF""..." + /* 23 */ , + "[00001]\x11\x01\x2C\x01\x03\x01\x04\x01\x08\x01\x13\x01\x06\xFF\xFF"", \x11\x01\x12\x01\x18\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x03\x01\x18\x01\x17\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x02\x01\x1A\x01\x07\x01\x01\xFF\xFF" + "[02500]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x11\x01\x14\x01\x03\x01\x10\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x14\x01\x1A\xFF\xFF"" \x11\x01\x12\x01\x18\x01\x16\xFF\xFF"" \x11\x01\x02\x01\x0E\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x0C\x01\x17\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x16\x01\x09\x01\x02\x01\x13\x01\x09\x01\x03\xFF\xFF" + "[05000]\x11\x01\x2E\x01\x04\xFF\xFF""!" + "[06000]\x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x10\x01\x06\x01\x0E\x01\x14\x01\x17\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x04\x01\x0B\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x13\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x0D\xFF\xFF" + "[09000]\x11\x01\x36\x01\x12\x01\x21\x01\x01\x01\x04\x01\x01\xFF\xFF" + "[10000]\x11\x01\x22\x01\x09\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x01\x01\x19\x01\x05\x01\x0A\x01\x01\x01\x02\x01\x04\x01\x09\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x0A\x01\x0A\x01\x0B\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x08\xFF\xFF""' \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x05\x01\x04\x01\x0A\x01\x17\x01\x0F\x01\x04\x01\x03\xFF\xFF""." + "[13000]\x11\x01\x1F\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x01\x01\x02\x01\x17\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"", \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x21\x01\x0B\x01\x0F\x01\x16\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x06\xFF\xFF""..." + "[17000]\x11\x01\x24\x01\x04\x01\x09\x01\x13\xFF\xFF""... \x11\x01\x0A\x01\x04\x01\x0F\x01\x0B\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x05\x01\x04\x01\x0A\x01\x17\x01\x0F\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x05\x01\x15\x01\x1A\xFF\xFF"" \x11\x01\x08\x01\x12\x01\x07\x01\x01\xFF\xFF"";" + "[20000]\x11\x01\x1E\x01\x04\xFF\xFF"" \x11\x01\x0F\x01\x12\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x13\x01\x09\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x1A\x01\x07\x01\x01\xFF\xFF"" ... \x11\x01\x13\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x09\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\xFF\xFF""..." + "[22000]\x11\x01\x1C\x01\x05\x01\x07\x01\x04\x01\x0A\x01\x12\x01\x06\x01\x05\xFF\xFF"" - \x11\x01\x09\x01\x10\x01\x14\x01\x06\x01\x1A\x01\x0A\x01\x0E\xFF\xFF" + "[24000]\x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x0A\x01\x0A\x01\x0B\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x0F\x01\x05\x01\x0D\xFF\xFF"" - \x11\x01\x08\x01\x03\x01\x1B\xFF\xFF"" \x11\x01\x3C\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x10\x01\x08\x01\x13\x01\x0F\x01\x03\x01\x04\x01\x08\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x07\x01\x03\x01\x0D\xFF\xFF"";" + "[26500]\x11\x01\x29\xFF\xFF"" \x11\x01\x0C\x01\x01\xFF\xFF"" \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x12\x01\x21\x01\x01\x01\x0F\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x1C\x01\x04\x01\x12\x01\x07\xFF\xFF"" \x11\x01\x27\x01\x02\x01\x03\x01\x10\x01\x08\x01\x13\x01\x06\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x05\x01\x04\xFF\xFF""." + "[29500]\x11\x01\x20\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x1B\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"";" + "[30500]\x11\x01\x2A\x01\x01\xFF\xFF"". \x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x09\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x0C\x01\x05\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x14\x01\x07\x01\x17\x01\x14\x01\x03\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x04\xFF\xFF""' \x11\x01\x01\x01\x10\x01\x02\x01\x13\x01\x06\xFF\xFF""." + "[34000]\x11\x01\x34\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x13\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x11\x01\x06\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x13\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x13\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x19\x01\x10\x01\x09\x01\x02\x01\x05\x01\x07\x01\x17\x01\x09\x01\x05\x01\x04\xFF\xFF"";" + "[37000]\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x25\x01\x12\x01\x07\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x1B\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x18\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x0C\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x15\x01\x01\x01\x07\x01\x0B\x01\x0C\x01\x04\x01\x01\xFF\xFF" + "[42000]\x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x12\x01\x08\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x07\x01\x16\x01\x02\x01\x17\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\xFF\xFF"" \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF" + "[46000]" + "[51000]\x11\x01\x22\x01\x10\x01\x18\x01\x01\x01\x07\x01\x04\x01\x09\x01\x02\x01\x1A\xFF\xFF"". \x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x16\xFF\xFF""." + /* 24 */ , "" + /* 25 */ , + "[03500]\x11\x01\x22\x01\x15\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x06\x01\x01\x01\x08\x01\x01\x01\x1B\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x03\xFF\xFF"" \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF" + "[05000]...\x11\x01\x12\x01\x06\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x15\x01\x1B\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x11\x01\x0C\x01\x01\x01\x04\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x0E\x01\x14\x01\x05\x01\x0A\x01\x13\x01\x06\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF""..." + "[10000]\x11\x01\x03\xFF\xFF"" \x11\x01\x03\x01\x08\x01\x03\x01\x11\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x0B\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x12\x01\x08\x01\x05\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x17\x01\x08\x01\x05\x01\x04\x01\x07\x01\x03\xFF\xFF""..." + "[13000]...\x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x08\x01\x0B\x01\x19\x01\x0E\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x10\x01\x06\x01\x05\x01\x18\x01\x11\x01\x09\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x21\x01\x0B\x01\x0F\x01\x0F\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x02\x01\x0B\x01\x25\x01\x0E\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x14\x01\x03\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x25\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x15\x01\x0B\x01\x1D\x01\x0E\xFF\xFF""..." + "[19000]\x11\x01\x1C\x01\x12\x01\x19\x01\x01\x01\x06\x01\x05\xFF\xFF"" \x11\x01\x18\x01\x16\x01\x07\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x03\x01\x14\x01\x13\x01\x06\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x06\x01\x1A\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x0F\x01\x0E\x01\x07\x01\x03\x01\x06\x01\x13\x01\x0A\x01\x03\xFF\xFF""..." + "[25500]\x11\x01\x35\x01\x11\x01\x25\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x21\x01\x0F\x01\x12\x01\x0A\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x09\x01\x10\x01\x0A\x01\x08\x01\x13\x01\x06\x01\x03\x01\x04\x01\x01\xFF\xFF"", \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF""." + /* 26 */ , "\x11\x01\x20\x01\x01\x01\x0F\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x17\x01\x07\x01\x19\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x08\x01\x11\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF""!@\x11\x01\x31\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x25\x01\x05\x01\x06\x01\x01\x01\x14\x01\x17\x01\x09\x01\x16\xFF\xFF""." + /* 27 */ , "\x11\x01\x2A\x01\x07\x01\x0E\x01\x09\x01\x04\x01\x0A\x01\x03\x01\x08\x01\x03\x01\x11\x01\x0E\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x10\x01\x0A\x01\x08\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x1B\x01\x19\x01\x10\x01\x06\x01\x09\x01\x0E\x01\x0D\xFF\xFF""@\x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x16\x01\x0A\x01\x0B\x01\x02\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\x01\x09\x01\x04\x01\x0C\x01\x17\x01\x0D\xFF\xFF""." + /* 28 */ , "OK. \x11\x01\x1F\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x07\x01\x04\x01\x0C\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x1B\x01\x0A\x01\x08\x01\x05\x01\x0D\xFF\xFF"".@\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF""." + /* 29 */ , "\x11\x01\x1E\x01\x1A\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x25\x01\x01\x01\x06\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF""@\x11\x01\x02\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x10\x01\x19\x01\x1B\x01\x06\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0E\x01\x15\x01\x17\x01\x25\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x0C\x01\x05\x01\x11\xFF\xFF""." + /* 30 */ , "\x11\x01\x1F\xFF\xFF"", \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x10\x01\x07\x01\x11\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x18\x01\x16\x01\x0F\xFF\xFF"".@\x11\x01\x23\x01\x10\x01\x14\x01\x06\x01\x1A\x01\x0A\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x09\x01\x02\x01\x01\x01\x09\x01\x11\x01\x01\xFF\xFF"", \x11\x01\x19\x01\x12\x01\x0F\x01\x16\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x15\x01\x1A\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x08\x01\x03\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x0B\x01\x14\x01\x0A\x01\x01\x01\x02\x01\x01\xFF\xFF""@ \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x03\x01\x19\x01\x17\x01\x0C\x01\x05\x01\x10\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x18\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x07\x01\x19\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x2B\x01\x12\x01\x2D\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x0E\xFF\xFF""." + /* 31 */ , "\x11\x01\x1E\x01\x07\x01\x12\x01\x25\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x04\x01\x21\x01\x1A\x01\x02\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x06\x01\x1A\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x01\x01\x02\x01\x0B\x01\x0D\xFF\xFF""@\x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF""@\x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x0C\x01\x01\x01\x07\x01\x1D\x01\x01\x01\x0F\x01\x1A\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF""." + /* 32 */ , "\x11\x01\x1F\x01\x10\x01\x02\x01\x17\xFF\xFF"" \x11\x01\x17\x01\x02\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x0E\xFF\xFF"" \x11\x01\x01\x01\x11\x01\x19\x01\x03\x01\x10\x01\x09\x01\x01\xFF\xFF"" \x11\x01\x18\x01\x03\x01\x07\x01\x03\x01\x1B\xFF\xFF"", \x11\x01\x01\x01\x0F\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x02\x01\x12\x01\x02\x01\x07\x01\x05\x01\x2D\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x16\x01\x08\x01\x04\x01\x0C\x01\x13\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x14\x01\x10\x01\x0A\x01\x06\x01\x01\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\x01\x03\xFF\xFF"".@\x11\x01\x1C\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1D\x01\x01\x01\x11\x01\x06\x01\x05\x01\x02\x01\x01\x01\x04\xFF\xFF"";@\x11\x01\x2C\x01\x03\x01\x04\x01\x08\x01\x13\x01\x06\xFF\xFF"", \x11\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x03\x01\x10\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x07\x01\x04\x01\x0C\x01\x12\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x09\x01\x0C\x01\x17\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF""." + /* 33 */ , "\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x09\x01\x10\x01\x06\x01\x0E\x01\x19\x01\x11\x01\x2B\x01\x16\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x12\x01\x18\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x06\x01\x02\x01\x03\x01\x1B\xFF\xFF"".@\x11\x01\x32\x01\x02\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x12\x01\x0F\x01\x16\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x05\x01\x0C\x01\x02\x01\x04\x01\x0C\x01\x17\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x08\x01\x01\x01\x02\x01\x0B\x01\x16\xFF\xFF"".@\x11\x01\x20\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x08\x01\x01\x01\x02\x01\x17\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x08\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x07\x01\x01\x01\x0A\x01\x0A\x01\x17\xFF\xFF""." + /* 34 */ , "\x11\x01\x24\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x08\x01\x01\x01\x02\x01\x17\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"",@\x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x12\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x13\x01\x02\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x1D\x01\x02\x01\x0B\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF""@\x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x08\x01\x01\x01\x19\x01\x17\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x07\x01\x11\x01\x25\x01\x05\x01\x04\x01\x0D\xFF\xFF"".@\x11\x01\x22\x01\x0A\x01\x08\x01\x07\x01\x13\x01\x0D\xFF\xFF"", \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x08\x01\x0B\x01\x19\x01\x0E\x01\x09\x01\x12\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF""." + /* 35 */ , "\x11\x01\x22\x01\x0B\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x04\x01\x02\x01\x0B\x01\x25\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x04\x01\x14\x01\x1B\x01\x07\x01\x16\xFF\xFF"",@\x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x04\x01\x02\x01\x0B\x01\x14\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"".@\x11\x01\x2E\x01\x08\x01\x05\x01\x04\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x1B\x01\x19\x01\x10\x01\x06\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x19\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x03\x01\x04\x01\x02\x01\x0B\x01\x25\x01\x05\x01\x04\x01\x0D\xFF\xFF""." + /* 36 */ , "\x11\x01\x22\x01\x0B\x01\x06\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x0A\x01\x01\x01\x0C\x01\x07\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x05\x01\x0A\x01\x12\x01\x06\x01\x01\xFF\xFF"",@\x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x1A\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x04\x01\x01\x01\x09\x01\x02\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x0F\x01\x10\x01\x02\x01\x1A\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x18\x01\x0E\x01\x0A\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x12\x01\x09\x01\x04\x01\x0A\x01\x03\xFF\xFF"".@\x11\x01\x1C\x01\x05\x01\x07\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x08\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x07\x01\x01\x01\x0A\x01\x0A\x01\x17\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x1A\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x07\x01\x01\x01\x08\x01\x12\x01\x07\x01\x01\xFF\xFF"".@\x11\x01\x1E\x01\x13\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x01\x01\x0A\x01\x12\x01\x09\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x19\x01\x1A\x01\x0D\xFF\xFF""@\x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x12\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF""." + /* 37 */ , "\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x0C\x01\x01\x01\x07\x01\x1D\x01\x01\x01\x0F\x01\x1A\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF""." + /* 38 */ , "\x11\x01\x22\x01\x0B\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x12\x01\x18\x01\x03\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"", \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x1A\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x1D\x01\x12\x01\x07\x01\x16\xFF\xFF""@\x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x12\x01\x02\x01\x03\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"", \x11\x01\x18\x01\x16\x01\x07\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x13\x01\x21\x01\x0F\x01\x0E\x01\x0A\x01\x01\xFF\xFF""." + /* 39 */ , "\x11\x01\x1C\x01\x05\x01\x07\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x08\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x14\x01\x07\x01\x01\x01\x0A\x01\x0A\x01\x17\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x01\x01\x0A\x01\x01\x01\x02\x01\x17\x01\x09\x01\x16\xFF\xFF"".@\x11\x01\x24\x01\x05\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x08\x01\x0B\x01\x02\x01\x0E\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x11\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x15\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x18\x01\x1A\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x07\x01\x16\xFF\xFF"" \x11\x01\x1D\x01\x13\x01\x07\x01\x01\xFF\xFF"".@\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x18\x01\x05\x01\x15\x01\x13\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x0A\x01\x12\x01\x09\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x08\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"".@\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x13\x01\x0C\x01\x05\x01\x04\x01\x02\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x02\x01\x05\x01\x0F\x01\x05\x01\x10\x01\x02\x01\x01\x01\x11\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x04\x01\x14\x01\x0A\x01\x17\xFF\xFF""." + /* 40 */ , "\x11\x01\x2C\x01\x03\x01\x04\x01\x08\x01\x13\x01\x06\xFF\xFF"". \x11\x01\x1F\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"".@\x11\x01\x28\x01\x08\x01\x13\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x05\xFF\xFF"" \x11\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x07\x01\x12\x01\x18\x01\x03\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x07\x01\x04\x01\x21\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x13\x01\x08\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x04\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x15\x01\x04\x01\x01\x01\x1D\x01\x03\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x08\x01\x16\x01\x0D\xFF\xFF""@\x11\x01\x05\x01\x06\x01\x1A\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x0A\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x01\x01\x12\x01\x07\x01\x01\xFF\xFF""@\x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF""@\x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x01\x01\x02\x01\x0E\x01\x19\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF""." + /* 41 */ , "\x11\x01\x1E\x01\x12\x01\x0F\x01\x05\x01\x04\x01\x01\xFF\xFF""." + /* 42 */ , "\x11\x01\x1C\x01\x07\x01\x03\x01\x09\x01\x08\x01\x0B\x01\x19\x01\x0E\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x0C\x01\x01\x01\x07\x01\x1D\x01\x01\x01\x0F\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x05\x01\x15\x01\x1A\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF"".@\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF""." + /* 43 */ , "\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x1A\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x0C\x01\x01\x01\x07\x01\x1D\x01\x01\x01\x0F\x01\x1A\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\x01\x02\x01\x11\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0C\x01\x05\x01\x06\x01\x13\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x0F\x01\x1B\xFF\xFF"" \x11\x01\x0A\x01\x04\x01\x0C\x01\x07\x01\x13\xFF\xFF"".@\x11\x01\x1F\x01\x0F\x01\x0F\x01\x0B\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x25\x01\x11\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x04\x01\x06\x01\x0E\x01\x19\x01\x1A\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x0B\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x18\x01\x07\x01\x04\xFF\xFF""@\x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x10\x01\x08\x01\x0B\x01\x07\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x18\x01\x1A\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x13\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF""." + /* 44 */ , "\x11\x01\x1E\x01\x12\x01\x0F\x01\x05\x01\x04\x01\x01\xFF\xFF""!@\x11\x01\x22\x01\x0B\x01\x06\xFF\xFF"" \x11\x01\x10\x01\x08\x01\x0B\x01\x07\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x14\x01\x0B\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\x01\x09\x01\x02\x01\x01\x01\x09\x01\x0E\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x12\x01\x15\x01\x01\x01\x1D\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x19\x01\x12\x01\x0F\x01\x16\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF""@\x11\x01\x18\x01\x02\x01\x10\x01\x08\x01\x17\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x08\x01\x0E\x01\x15\x01\x1A\x01\x06\x01\x02\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x10\x01\x19\x01\x05\x01\x11\x01\x01\x01\x06\xFF\xFF"", \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x1A\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x01\x01\x02\x01\x0E\x01\x19\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF""@\x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x01\x01\x1D\x01\x05\x01\x19\x01\x1A\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x05\x01\x0C\x01\x02\x01\x04\x01\x0C\x01\x0B\xFF\xFF""." + /* 45 */ , "\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x11\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x16\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x11\x01\x09\x01\x16\xFF\xFF"".@\x11\x01\x1F\x01\x0A\x01\x12\x01\x09\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x07\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x01\x01\x02\x01\x0E\x01\x0A\x01\x12\x01\x06\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF""@\x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x19\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x04\x01\x01\x01\x09\x01\x02\x01\x1A\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x19\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x12\x01\x1D\x01\x02\x01\x16\xFF\xFF""." + /* 46 */ , "\x11\x01\x1E\x01\x13\x01\x02\x01\x05\xFF\xFF"" \x11\x01\x0B\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF""." + /* 47 */ , "\x11\x01\x1C\x01\x0B\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x0B\x01\x06\x01\x04\x01\x03\xFF\xFF""." + /* 48 */ , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x03\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x02\x01\x05\x01\x10\x01\x19\x01\x1B\x01\x06\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF""@\x11\x01\x0A\x01\x05\xFF\xFF"" \x11\x01\x0A\x01\x05\x01\x02\x01\x01\x01\x0C\x01\x04\x01\x06\x01\x03\x01\x1B\x01\x06\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x02\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x06\x01\x05\x01\x07\x01\x13\xFF\xFF""." + /* 49 */ , "\x11\x01\x1F\xFF\xFF""! \x11\x01\x1F\x01\x12\x01\x07\x01\x01\x01\x0D\xFF\xFF""!@\x11\x01\x1F\x01\x08\x01\x0F\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x18\x01\x07\x01\x0E\x01\x09\x01\x04\x01\x0A\x01\x03\x01\x08\x01\x03\x01\x11\x01\x0E\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x07\x01\x03\x01\x09\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x04\x01\x09\x01\x02\x01\x05\x01\x07\x01\x0B\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x15\x01\x05\x01\x25\x01\x04\x01\x0B\xFF\xFF""@\x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x04\x01\x06\x01\x0E\x01\x19\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x1D\x01\x0B\x01\x06\x01\x05\x01\x04\x01\x01\xFF\xFF"".@\x11\x01\x1C\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x03\x01\x10\x01\x02\x01\x17\x01\x25\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x02\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x08\x01\x04\x01\x1D\x01\x0B\x01\x06\x01\x05\x01\x04\x01\x01\xFF\xFF"".@\x11\x01\x1F\x01\x0F\x01\x0F\x01\x04\x01\x1A\x01\x0D\xFF\xFF"" \x11\x01\x08\x01\x17\x01\x14\x01\x01\x01\x04\x01\x06\x01\x05\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x0B\x01\x0C\x01\x07\x01\x0E\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x0B\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x08\x01\x0F\x01\x17\x01\x0C\x01\x02\x01\x07\x01\x03\xFF\xFF"" \x11\x01\x15\x01\x07\x01\x0B\x01\x09\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x14\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x12\x01\x25\x01\x16\xFF\xFF""." + /* 50 */ , "\x11\x01\x3B\x01\x07\x01\x01\x01\x11\x01\x01\xFF\xFF"". \x11\x01\x20\x01\x01\x01\x0F\x01\x1B\x01\x02\x01\x05\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x14\x01\x0B\x01\x0F\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x05\x01\x14\x01\x0A\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x07\x01\x03\x01\x1B\x01\x18\x01\x01\xFF\xFF""." + /* 51 */ , "\x11\x01\x1C\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x0F\x01\x05\x01\x1B\x01\x07\x01\x04\xFF\xFF""!" + /* 52 */ , "\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x08\x01\x07\x01\x03\x01\x09\x01\x16\x01\x08\x01\x04\x01\x0C\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x19\x01\x12\x01\x0A\x01\x01\xFF\xFF""." + /* 53 */ , "\x11\x01\x2E\x01\x18\x01\x16\xFF\xFF"" \x11\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x06\x01\x03\x01\x0C\x01\x12\x01\x1D\x01\x01\x01\x0F\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x09\x01\x12\x01\x06\x01\x01\xFF\xFF"".@\x11\x01\x20\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x01\x01\x11\x01\x06\x01\x03\x01\x10\x01\x06\xFF\xFF"" \x11\x01\x08\x01\x05\x01\x07\x01\x11\x01\x05\x01\x07\x01\x14\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x04\x01\x15\x01\x12\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x1A\x01\x07\x01\x01\xFF\xFF"".@\x11\x01\x32\x01\x08\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x09\x01\x05\xFF\xFF"" \x11\x01\x14\x01\x05\x01\x0A\x01\x11\x01\x09\x01\x16\xFF\xFF"" \x11\x01\x09\x01\x1D\x01\x01\x01\x11\x01\x07\x01\x05\x01\x0D\xFF\xFF""!" + /* 54 */ , "\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x0A\x01\x08\x01\x03\x01\x07\x01\x05\x01\x11\x01\x0D\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x14\x01\x0F\x01\x10\x01\x02\x01\x1A\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x08\x01\x13\xFF\xFF"" \x11\x01\x0A\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x01\x01\x04\xFF\xFF""@\x11\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x09\x01\x04\x01\x06\x01\x0B\x01\x1D\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x02\x01\x13\x01\x09\x01\x03\xFF\xFF"" \x11\x01\x05\x01\x1B\x01\x0C\x01\x03\x01\x0F\x01\x01\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF""." + /* 55 */ , "\x11\x01\x2C\x01\x11\x01\x14\x01\x03\xFF\xFF"" \x11\x01\x01\x01\x07\x01\x14\x01\x0B\xFF\xFF"" \x11\x01\x14\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x21\x01\x07\x01\x01\x01\x21\x01\x05\x01\x11\x01\x01\xFF\xFF"" - \x11\x01\x15\x01\x05\xFF\xFF"" \x11\x01\x06\x01\x03\x01\x0A\x01\x11\x01\x2B\x01\x05\x01\x04\x01\x0D\xFF\xFF"";@\x11\x01\x32\x01\x0A\x01\x16\x01\x0D\xFF\xFF"" \x11\x01\x01\x01\x10\x01\x02\x01\x13\xFF\xFF"" \x11\x01\x08\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x01\x01\x25\x01\x11\x01\x2B\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x05\x01\x11\x01\x06\x01\x01\x01\x04\xFF\xFF"" \x11\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x0C\x01\x05\x01\x07\x01\x15\x01\x11\x01\x2B\x01\x05\x01\x04\x01\x0D\xFF\xFF""." + /* 56 */ , "\x11\x01\x24\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x10\x01\x07\x01\x03\x01\x21\x01\x13\x01\x0F\x01\x0E\x01\x09\x01\x05\x01\x0D\xFF\xFF"";@\x11\x01\x24\x01\x05\xFF\xFF"" \x11\x01\x08\x01\x10\x01\x07\x01\x03\x01\x21\x01\x13\x01\x0F\x01\x0E\x01\x09\x01\x05\x01\x0D\xFF\xFF"", \x11\x01\x05\xFF\xFF"";@\x11\x01\x26\x01\x05\x01\x06\xFF\xFF"" \x11\x01\x10\x01\x08\x01\x0B\x01\x07\x01\x18\x01\x05\x01\x04\xFF\xFF"" \x11\x01\x0C\x01\x0B\x01\x06\x01\x01\x01\x0D\xFF\xFF"" \x11\x01\x0B\x01\x0F\x01\x0F\x01\x03\x01\x0D\xFF\xFF"", \x11\x01\x0B\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x0A\x01\x0B\x01\x0F\x01\x0F\x01\x03\x01\x06\xFF\xFF"" \x11\x01\x05\x01\x0A\x01\x12\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x08\x01\x10\x01\x07\x01\x03\x01\x21\x01\x03\x01\x0F\x01\x05\x01\x11\x01\x0D\xFF\xFF""!" +// TR1 levels + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2E\x01\x08\x01\x01\x01\x10\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF" + , "\x11\x01\x23\x01\x08\x01\x17\x01\x0F\x01\x01\x01\x04\x01\x01\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x1C\x01\x13\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x36\x01\x04\x01\x0F\x01\x0C\x01\x01\x01\x0A\x01\x08\x01\x0B\x01\x0A\x01\x08\x01\x01\xFF\xFF" + , "\x11\x01\x2A\x01\x01\x01\x0A\x01\x12\x01\x06\x01\x0E\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x04\x01\x0F\x01\x0B\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x1E\x01\x1B\x01\x0A\x01\x21\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x10\x01\x01\x01\x0F\x01\x03\x01\x08\x01\x12\x01\x0C\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x24\x01\x03\x01\x06\x01\x17\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1F\x01\x14\xFF\xFF"". \x11\x01\x2F\x01\x07\x01\x01\x01\x14\x01\x0C\x01\x11\x01\x09\x01\x0C\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x03\x01\x0F\x01\x03\x01\x09\x01\x09\x01\x01\x01\x11\x01\x03\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x1C\x01\x01\x01\x0F\x01\x0B\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x24\x01\x11\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x33\x01\x15\x01\x07\x01\x01\x01\x14\x01\x16\x01\x14\x01\x05\x01\x11\x01\x03\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x1E\x01\x1B\x01\x0A\x01\x21\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1E\x01\x04\x01\x13\x01\x0C\x01\x01\x01\x06\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x1C\x01\x13\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x0A\x01\x03\x01\x1B\x01\x06\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x28\x01\x21\x01\x05\x01\x0F\x01\x11\x01\x09\x01\x0C\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x0A\x01\x03\x01\x1B\x01\x06\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x20\x01\x05\x01\x04\x01\x0A\x01\x0E\x01\x0F\x01\x11\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x1E\x01\x01\xFF\xFF"" \x11\x01\x28\x01\x07\x01\x10\x01\x18\x01\x05\x01\x11\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x27\x01\x0B\x01\x02\x01\x0F\x01\x01\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x24\x01\x05\x01\x14\x01\x01\x01\x0F\x01\x17\xFF\xFF"" \x11\x01\x1C\x01\x10\x01\x07\x01\x01\x01\x0A\x01\x11\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x22\x01\x08\x01\x04\x01\x09\x01\x02\x01\x07\x01\x03\x01\x1D\x01\x17\xFF\xFF"" \x11\x01\x09\x01\x02\x01\x0E\x01\x06\xFF\xFF"" \x11\x01\x1F\x01\x11\x01\x14\x01\x10\x01\x08\x01\x02\x01\x03\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x37\x01\x0B\x01\x02\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x28\x01\x18\x01\x10\x01\x07\x01\x13\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x0F\x01\x01\x01\x06\x01\x02\x01\x11\x01\x15\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2F\x01\x16\x01\x0F\x01\x04\x01\x0B\xFF\xFF" +// TR2 levels + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2E\x01\x08\x01\x01\x01\x10\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x23\x01\x05\x01\x04\x01\x06\x01\x04\x01\x0C\x01\x13\xFF\xFF"" \x11\x01\x1E\x01\x05\x01\x11\x01\x18\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x36\x01\x05\x01\x06\x01\x05\x01\x02\x01\x11\x01\x01\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x20\x01\x07\x01\x0E\x01\x09\x01\x1D\x01\x1B\x01\x14\x01\x05\x01\x02\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x24\x01\x08\x01\x01\x01\x07\x01\x02\x01\x13\x01\x0F\x01\x04\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x32\x01\x08\x01\x05\x01\x07\x01\x01\xFF\xFF" + , "\x11\x01\x33\x01\x08\x01\x05\x01\x07\x01\x0B\x01\x0C\x01\x02\x01\x04\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x22\x01\x14\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x09\x01\x02\x01\x0B\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF" + , "\x11\x01\x1C\x01\x05\x01\x07\x01\x04\x01\x03\x01\x18\x01\x17\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x02\x01\x01\x01\x15\x01\x1B\x01\x09\x01\x05\x01\x16\x01\x06\xFF\xFF" + , "40 \x11\x01\x28\x01\x07\x01\x14\x01\x04\x01\x12\x01\x0D\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x10\x01\x0B\x01\x14\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x24\x01\x01\x01\x07\x01\x11\x01\x01\xFF\xFF"" \x11\x01\x27\x01\x02\x01\x13\x01\x07\x01\x04\x01\x01\xFF\xFF" + , "\x11\x01\x20\x01\x01\x01\x0A\x01\x08\x01\x11\x01\x06\x01\x05\x01\x0D\xFF\xFF" + , "\x11\x01\x20\x01\x01\x01\x02\x01\x0B\x01\x09\x01\x02\x01\x07\x01\x16\x01\x0A\x01\x01\xFF\xFF" + , "\x11\x01\x23\x01\x02\x01\x03\x01\x10\x01\x0D\xFF\xFF"" \x11\x01\x1C\x01\x07\x01\x13\x01\x08\x01\x03\x01\x15\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x31\x01\x04\x01\x21\x01\x12\x01\x02\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x24\x01\x03\x01\x06\x01\x01\x01\x09\x01\x02\x01\x17\x01\x07\x01\x04\xFF\xFF"" \x11\x01\x24\x01\x08\x01\x0B\x01\x07\x01\x0C\x01\x18\x01\x01\x01\x06\x01\x14\x01\x0C\xFF\xFF" + , "\x11\x01\x28\x01\x04\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x02\x01\x01\x01\x0C\x01\x13\x01\x0A\x01\x21\x01\x05\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1E\x01\x0B\x01\x0F\x01\x04\x01\x03\x01\x06\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x1C\x01\x01\x01\x0F\x01\x0B\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1C\x01\x0B\x01\x14\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x23\x01\x04\x01\x0B\x01\x06\xFF\xFF" + , "\x11\x01\x1E\x01\x01\xFF\xFF"" \x11\x01\x30\x01\x08\x01\x02\x01\x0B\x01\x0A\x01\x05\x01\x06\x01\x01\xFF\xFF"" \x11\x01\x27\x01\x0E\x01\x09\x01\x04\x01\x0B\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2F\x01\x16\x01\x0F\x01\x04\x01\x0B\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x26\x01\x07\x01\x0B\x01\x0C\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x23\x01\x08\x01\x11\x01\x02\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x23\x01\x08\x01\x04\x01\x02\x01\x0B\x01\x0C\x01\x04\xFF\xFF"" \x11\x01\x0A\x01\x03\x01\x10\xFF\xFF" +// TR3 levels + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2E\x01\x08\x01\x01\x01\x10\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x2C\x01\x0B\x01\x07\x01\x01\xFF\xFF" + , "\x11\x01\x39\x01\x03\x01\x1B\x01\x14\x01\x0C\x01\x0F\x01\x01\xFF\xFF" + , "\x11\x01\x1E\x01\x01\xFF\xFF"" \x11\x01\x22\x01\x07\x01\x05\x01\x11\x01\x08\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x03\x01\x1B\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x1C\x01\x03\x01\x02\x01\x01\x01\x0A\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x37\x01\x0B\x01\x14\x01\x14\x01\x0E\x01\x0D\xFF\xFF" + , "\x11\x01\x1E\x01\x01\xFF\xFF"" \x11\x01\x23\x01\x08\x01\x17\x01\x0F\x01\x01\x01\x04\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x20\x01\x01\x01\x0F\x01\x11\x01\x14\x01\x04\x01\x01\xFF\xFF" + , "\x11\x01\x1C\x01\x01\x01\x07\x01\x0B\x01\x0C\x01\x02\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x2A\x01\x16\x01\x07\x01\x04\x01\x13\xFF\xFF" + , "\x11\x01\x23\x01\x0E\x01\x0A\x01\x05\x01\x11\x01\x03\xFF\xFF"" \x11\x01\x1F\x01\x02\x01\x10\x01\x18\x01\x17\x01\x0A\x01\x01\x01\x02\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x2F\x01\x01\x01\x07\x01\x0B\x01\x14\x01\x14\x01\x04\xFF\xFF"" \x11\x01\x24\x01\x01\x01\x06\x01\x02\x01\x03\x01\x1B\x01\x0A\x01\x08\x01\x03\x01\x10\xFF\xFF" + , "\x11\x01\x28\xFF\xFF"" \x11\x01\x27\x01\x01\x01\x13\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1C\x01\x03\x01\x1B\x01\x06\x01\x01\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x1F\x01\x08\x01\x03\x01\x21\x01\x0B\x01\x19\x01\x07\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x1E\x01\x0B\x01\x0A\x01\x05\x01\x09\x01\x0E\xFF\xFF" + , "\x11\x01\x34\x01\x0F\x01\x06\x01\x02\x01\x14\x01\x03\x01\x10\x01\x04\x01\x02\x01\x0D\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x1C\x01\x1B\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x2C\x01\x03\x01\x10\x01\x06\x01\x02\xFF\xFF" + , "\x11\x01\x1C\x01\x13\x01\x0F\x01\x0E\xFF\xFF" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2E\x01\x07\x01\x0E\x01\x0A\x01\x03\x01\x0D\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x27\x01\x05\x01\x21\x01\x0B\x01\x15\x01\x01\xFF\xFF" + , "\x11\x01\x22\x01\x14\x01\x0C\x01\x01\x01\x02\x01\x01\x01\x09\x01\x02\x01\x0B\x01\x09\x01\x05\x01\x04\x01\x0D\xFF\xFF"" \x11\x01\x33\x01\x2D\x01\x11\x01\x09\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1F\x01\x09\x01\x1D\x01\x01\x01\x0F\x01\x05\x01\x11\x01\x01\x01\x0D\xFF\xFF" + , "\x11\x01\x1C\x01\x05\x01\x07\x01\x11\x01\x03\x01\x18\x01\x0E\xFF\xFF"" 51" + , "\x11\x01\x1F\x01\x06\x01\x02\x01\x01\x01\x07\x01\x0C\x01\x02\x01\x04\x01\x0C\x01\x17\xFF\xFF" + , "\x11\x01\x1E\x01\x01\xFF\xFF"" \x11\x01\x28\x01\x07\x01\x10\x01\x18\x01\x05\x01\x11\x01\x01\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" RX-Tech" + , "\x11\x01\x29\xFF\xFF"" \x11\x01\x2A\x01\x01\x01\x0A\x01\x12\x01\x06\x01\x0E\xFF\xFF"" \x11\x01\x1C\x01\x13\x01\x0F\x01\x0E\xFF\xFF"" \x11\x01\x02\x01\x0E\x01\x0D\xFF\xFF"" \x11\x01\x1E\x01\x11\x01\x06\x01\x06\x01\x03\x01\x0D\xFF\xFF" + , "\x11\x01\x1E\x01\x03\xFF\xFF"" \x11\x01\x23\x01\x08\x01\x17\x01\x0F\x01\x01\x01\x04\x01\x03\xFF\xFF"" \x11\x01\x02\x01\x03\x01\x10\xFF\xFF"" \x11\x01\x24\x01\x05\x01\x02\x01\x05\x01\x16\x01\x07\x01\x11\x01\x02\x01\x0E\xFF\xFF" + , "\x11\x01\x34\x01\x14\x01\x04\x01\x03\x01\x04\xFF\xFF"" \x11\x01\x1C\x01\x0B\x01\x06\x01\x02\x01\x05\x01\x0D\xFF\xFF" +}; + +#endif diff --git a/src/lang/hu.h b/src/lang/hu.h new file mode 100644 index 00000000..26402321 --- /dev/null +++ b/src/lang/hu.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_HU +#define H_LANG_HU + +// Thanks: Varga Viktor + +const char *STR_HU[] = { "" +// help + , "Bet~olt)es..." + , "Nyomj H-t a S)ug)ohoz" + , helpText + , "%s@@@" + "~OL)ESEK %d@@" + "FELVETT %d@@" + "TITKOK %d/%d@@" + "SZ~UKS)EGES ID\"O %s" + , "J)at)ek ment)ese..." + , "Ment)es k)esz!" + , "MENT)ESI HIBA!" + , "IGEN" + , "NEM" + , "Ki" + , "Be" + , "Ki" + , "Side-By-Side" + , "Anaglyph" + , "Osztott k)eperny\"o" + , "VR" + , "Alacsony" + , "K~ozepes" + , "Magas" + , STR_LANGUAGES + , "Alkalmaz" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Nincs k)esz" + , "1. j)at)ekos" + , "2. j)at)ekos" + , "Nyomj meg egy gombot" + , "%s - Kiv)alaszt" + , "%s - Vissza" +// inventory pages + , "OPCI)OK" + , "T)ARGYLISTA" + , "T)ARGYAK" +// save game page + , "J)at)ek ment)ese?" + , "Aktu)alis poz)ici)o" +// inventory option + , "J)at)ek" + , "T)erk)ep" + , "Ir)anyt\"u" + , "Statisztika" + , "Lara otthona" + , "R)eszletess)egi szintek" + , "Hang" + , "Ir)any)it)as" + , "Gamma" +// passport menu + , "J)at)ek bet~olt)ese" + , ")Uj j)at)ek" + , "Szint )ujraind)it)asa" + , "Kil)ep)es a kezd\"ok)eperny\"oh~oz" + , "Kil)ep)es a j)at)ekb)ol" + , "Szint kiv)alaszt)asa" +// detail options + , "R)eszletek kiv)alaszt)asa" + , "Sz\"ur)es" + , "Vil)ag)it)as" + , ")Arny)ekok" + , "V)iz" + , "VSync" + , "Sztere)o" + , "Egyszer\"u t)argyak" + , "Felbont)as" + , STR_SCALE +// sound options + , "Hanger\"o be)all)it)asa" + , "Visszaver\"od)es" + , "Feliratok" + , "Nyelv" +// controls options + , "Ir)any)it)as be)all)it)asa" + , "Billenty\"uzet" + , "Gamepad" + , "Vibr)aci)o" + , ")Uj c)elpont" + , "Multi-c)elz)as" + // controls + , "Bal", "Jobb", "Fut)as", "Vissza", "Ugr)as", "S)eta", "Akci)o", "Fegyver el\"ov)etel", "N)ez", "Gugol", "L~ok", "Gurul", "T)argylista", "Kezd)es" + , STR_KEYS +// inventory items + , "Ismeretlen" + , "Robban)oanyag" + , "Pisztolyok" + , "Shotgun" + , "Magnumok" + , "Uzik" + , "Pisztoly t~olt)enyek" + , "Shotgun t~olt)enyek" + , "Magnum t~olt)enyek" + , "Uzi t~olt)enyek" + , "Kis Medi pakk" + , "Nagy Medi pakk" + , ")Olomr)ud" + , "Scion" +// keys + , "Kulcs" + , "Ez~ust kulcs" + , "Rozsd)as kulcs" + , "Arany kulcs" + , "Zaf)ir kulcs" + , "Neptunusz kulcs" + , "Atlasz kulcs" + , "Damokl)esz kulcs" + , "Thor kulcs" + , "D)iszes kulcs" +// puzzles + , "Rejtv)eny" + , "Arany szobor" + , "Arany r)ud" + , "Fogasker)ek" + , "Biztos)it)ek" + , "Ankh" + , "H)orusz szeme" + , "Anubisz pecs)etje" + , "Szkarabeusz" + , "Piramis kulcs" +// TR1 subtitles + /* CAFE */ , + "[43500]Mit kell tennie az embernek, ahhoz,@hogy megkapja azt a bizonyos figyelmet?" + "[47500]Neh)ez pontosan megmondani,@de )ugy t\"unik j)ol vagy." + "[50000]Nos, nagyszer\"u. B)ar az az igazs)ag,@nem )en akarlak." + "[54500]Nem?" + "[55000]Nem. Miss Jacqueline Natla szeretne,@a Natla Technologies-t)ol." + "[59000]Tudod, minden f)enyes@)es sz)ep alkot)oja?" + "[64500]Z)arja le, Larson." + "[66000]H~olgyem." + "[68000]Ezt figyeld, Lara." + "[70500]Hogyan )erinti ez a p)enzt)arc)ad?" + "[73500]Bocs. )En csak a sport)ert j)atszom." + "[76000]Akkor tetszeni fog egy nagy park." + "[78000]Peru. Hatalmas hegyl)ancok, amit fel kell fedezni.@J)egfalak. )Eles szikl)ak. Vad szelek." + "[87500])Es itt van ez a kis csecsebecse:@\"osi id\"ok misztikus er\"ovel rendelkez\"o m\"ut)argya" + "[92500]eltemetve Qualopec fel nem lelt s)irj)aban." + "[96000]Ez az ami )erdekel." + "[98000]Holnap elmehetsz.@Elfoglalt vagy holnap?" + /* LIFT */ , + "[49000])Athelyezve Szt. Ferenc kolostor)aba, )uj k)is)ert)esek k)inoznak engem." + "[53500]A testv)erek k~ozt az a h)ir j)arja, hogy a kolostor alatt@ker~ult s)irba Tihocan," + "[60000]egyike az elveszett kontinens, Atlantisz,@ legend)as uralkod)oinak," + "[64500])es vele egy~utt fekszik az \"o darabja@az Atlantiszi Scion-nak." + "[68000]A med)alt felosztott)ak a h)arom uralkod)o k~oz~ott@" + "[72500]ami hatalmas er\"oket f)ekez meg.@Er\"ot, ami meghaladja az alkot)o erej)et is." + "[79000]Izzad a l)abam ezekt\"ol a lehet\"os)egekt\"ol,@amik olyan k~ozel )allnak a haland)o )enemhez." + "[85500]Minden este t)ul teszem magam@ezeken a fant)azi)akon, de ez val)oj)aban egy teszt." + "[92000]" + "[93500]Pierre. Nee. Te szem)et." + /* CANYON */ , + "[13500])Epp most h)uztad a szerencsecsont nagyobb v)eg)et." + "[16500]Mizu." + "[17500]D)elut)an." + "[20000]Ott hagytuk Larson-t szelet aratni, mi?" + "[22500]Ha ez a kifejez)es." + "[24000]Nos, a kis nyaral)asi zavarg)asnak most m)ar v)ege." + "[27000]Itt az ideje visszaadni azt, amit ellopt)al t\"olem." + "[30000]Pr)ob)aljuk meg az )eteldobozt." + "[32000]" + "[42500]Nos? ~Old meg!" + "[45000]H)e!" + "[48000]" + "[50500]Debilek!" + "[53000]" + "[62500]Gyer~unk." + "[65000]" + "[136000]Mi a fene volt ez?" + "[138000]Mi?" + "[138500]Egyszer\"u." + "[140500]Val)osz)in\"uleg csak egy hal." + "[142500]Ez egy hal, k~oly~ok." + "[145000]Ember, meg kell tanulnod laz)itani.@Visszamegyek. J~ossz?" + "[152000]" + "[158000])Alland)o..." + "[160000]Itt van." + "[161500]K)eszen )allsz m)ar?" + /* PRISON */ , + "[00001]Nem tehetik ezt!" + "[01500]El)it)elj~uk ~Ont, atlantiszi Natla a b\"unei)ert." + "[06000]Hatalmaddal er\"oteljesen vissza)el)esei miatt,@ )es mert kiraboltad a mi..." + "[11500]Nem tehetik! )En..." + "[12500]Megsz~untetve a beleegyez)es szabad k~otel)ek)et@amely alatt n)ep~unket ir)any)itj)ak," + "[18500])es megt)amadva Tihocan-t )es engem a sereg~unkkel." + "[23500]A harcosaink t)avoztak a piramisunkb)ol" + "[27000])igy fel tudod haszn)alni a piramist - annak erej)et@a teremt)esre - az esztelen rombol)asodhoz." + "[33500]Esztelen!? N)ezz magadra!" + "[35500]Egyik\"ot~oknek sincs egy lelem)enyes@gondolat se a fej)eben." + "[40500]Pazarl)ok!" + "[41500]Csak csin)alj)atok." + "[44000]Tihocan!" + "[45000]Egy szent helyet haszn)alt)al@saj)at ~or~om~odre," + "[49500]mint valami korcs gy)arat." + "[51000]\"Ok a t)ul)el\"ok. Egy )uj gener)aci)o." + "[54000]Egy lem)esz)arolt halom most." + "[56000])Es te. A pokol torn)ac)ara z)arunk." + "[60000]Az ereid, a sz)ived, a l)abad," + "[64000])es a beteg agyad szil)ardd)a teszi majd a fagyott v)er." + "[70000]~Udv~oz~old az ~or~ok nyugtalans)agod, Natla." + "[73000]Te sem fogsz nyugodni, ak)ar az @)atkozott kontinensed Atlantisz!" + /* 22 */ , + "[04000])Ujra itt?" + "[05500])Es te - a nagy )ujra megnyit)ora, gondolom." + "[09500]Az evol)uci)o bajban van - a term)eszetes szelekci)o m)ara alig )erv)enyes~ul..." + "[13500]Az )uj h)us megjelen)ese fel fogja ism)et gerjeszteni a ter~uleti vit)akat" + "[17500] - meger\"os)it )es el\"oseg)it minket..." + "[20500]M)eg )uj fajokat is l)etre hozhat." + "[22500]Az evol)uci)o szteroidokon, akkor." + "[24500]Egy seggber)ug)as...@a nyomorult Qualopec-enk )es Tihocan-nak nem voltak ~otletei" + "[29500] - Atlantisz kataklizm)aja az )ert)ektelen gyeng)ek verseny)et s)ujtotta..." + "[33500]visszazuhan)asra k)enyszer)itve \"oket )ujra a t)ul)el)es alapjaihoz..." + "[37000]Nem volna szabad )ugy t~ort)ennie." + "[39000]Vagy )igy." + "[40000]A kikel)es 15 m)asodperc m)ulva kezd\"odik." + "[43000]Most m)ar k)es\"o le)all)itani!" + "[45000]A m\"uvelet sz)ive n)elk~ul nem!" + "[47000]Neee!" + "[50000]T)IZ" + "[54000]~OT..." + "[55500]4...3...2..." + "[60000]EGY..." + /* 23 */ , + "[00001]Nos, most m)ar a teljes figyelmem rajtad" + "[02500]- M)egsem vagyok biztos abban, hogy )en is megkaptam a tied." + "[05000]Hell)o?" + "[06000]Elkaplak )es lel\"olek, mint egy kuty)at." + "[09000]Term)eszetesen." + "[10000]Te )es az az idi)ota Scion darabod." + "[13000]Annyira szeretn)ed megtartani, hogy kihaszn)alom ezt..." + "[17000]V)arjunk... itt most a m\"ut)argyr)ol besz)el~unk?" + "[20000]Egyenesben vagyunk ... eg)eszen ..." + "[22000]Tarts ki - Sajn)alom" + "[24000]- ez csak egy r)esz, mondtad - hol van a t~obbi?" + "[26500]Ms. Natla Pierre Dupont-ot )all)itotta arra a nyomra." + "[29500])Es hol van az?" + "[30500]H)a)a)a. Nem vagy el)eg gyors, hogy utol)erd." + "[34000]Sz)oval azt gondolod, ez a besz)elget)es csak arra van, hogy feltartson?" + "[37000]Nem tudom, hogy a kis ny)ul-b)eka l)abai hov)a vezetik \"ot." + "[42000]Meg kell k)erdezned Ms. Natla-t)ol." + "[46000]" + "[51000]K~osz~on~om. Megteszem." + /* 24 */ , "" + /* 25 */ , + "[03500]Itt nyugszik Tihocan" + "[05000]...Atlantisz k)et ur)anak egyike..." + "[10000]Ki a kontinens )atka ut)an is..." + "[13000]...megpr)ob)alt uralkodni ezeken a kop)ar m)as-f~oldeken..." + "[19000]Ki Gyermek n)elk~ul halt meg )es a tud)as)anak nem volt ~or~ok~ose..." + "[25500]Tekints r)ank j)oindulattal, Tihocan." + /* 26 */ , "K~osz~ontelek az otthonomban!@Vezetett t)ur)ara foglak vinni." + /* 27 */ , "Haszn)ald az ir)any gombokat, hogy a zeneszob)aba menj." + /* 28 */ , "OK. Ugr)aljunk egy kicsit.@Nyomd meg az ugr)as gombot." + /* 29 */ , "Most nyomd meg )ujra )es gyorsan nyomj hozz)a@egy ir)anyt )es abba az ir)anyba fogok ugrani." + /* 30 */ , ")A)a, a nagyterem.@Bocs a l)ad)ak)ert, de n)eh)any dolgot@rakt)arakba vitetek )es sz)all)it)ok m)eg nem j~ottek." + /* 31 */ , "Fuss oda egy l)ad)ahoz, )es am)ig nyomva tartod az el\"ore gombot,@nyomj akci)o gombot )es )en felugrok r)a." + /* 32 */ , "Ez kor)abban b)alterem volt, de )atalak)itottam@ a saj)at torna termemnek.@Mi a v)elem)enyed?@Nos csin)aljunk n)eh)any gyakorlatot." + /* 33 */ , "Nem mindenhova rohanok.@Ha )ovatos akarok lenni, s)et)alok@Tartsd nyomva a s)eta gombot, )es s)et)alj a feh)er vonalhoz." + /* 34 */ , "A s)eta gomb nyomva tart)as)aval nem fogok leesni, m)eg akkor sem ha megpr)ob)alod.@Rajta, pr)ob)ald ki." + /* 35 */ , "Ha szeretn)el k~orbe n)ezni, tartsd nyomva a n)ez gombot.@Ut)ana nyomd le az ir)anyt amerre n)ezni szeretn)el." + /* 36 */ , "Ha egy ugr)as t)ul nagy nekem, el tudom kapni a peremet )es megmenteni magam@egy cs)unya zuhan)ast)ol. S)et)alj a sz)el)ehez a feh)er vonallal, addig, am)ig @m)ar nem megyek tov)abb. Ut)ana nyomj ugr)ast, ut)ana meg r~ogt~on@ el\"ore gombot, )es am)ig a leveg\"oben vagyok, nyomd le )es tartsd nyomva az akci)o gombot." + /* 37 */ , "Nyomj el\"or)et, )es felm)aszom." + /* 38 */ , "Ha fut)o ugr)ast csin)alok, akkor tudok ekkor)at ugrani, nem probl)ema." + /* 39 */ , "S)et)alj a sz)el)ehez a feh)er vonallal, addig, am)ig m)ar nem megyek tov)abb.@Azt)an engedd el a s)et)at, nyomj h)atr)at, hogy neki tudjak futni.@Nyomj el\"or)et, )es r~ogt~on nyomd le )es tartsd nyomva az ugr)as gombot.@Nem fogok elugrani az utols)o pillanatig." + /* 40 */ , "Helyes. Ez egy igaz)an nagy@ Csin)alj egy fut)o ugr)ast, mint kor)abban, de am)ig a leveg\"oben@vagyok, nyomd le )es tarts nyomva az akci)o gombot, hogy elkapjam a peremet." + /* 41 */ , "Sz)ep." + /* 42 */ , "Pr)ob)alj meg felm)aszni itt.@Nyomj el\"or)et, )es tartsd nyomva az akci)o gombot." + /* 43 */ , "Nem tudok felm)aszni, mert a r)es t)ul kicsi.@Nyomj jobbot, )es oldalra m)aszom,@am)ig el)eg hely lesz, akkor nyomj el\"or)et." + /* 44 */ , "Remek!@Ha nagy a m)elys)eg, )es nem szeretn)ek@s)er~ulni a leugr)assal, le tudom magam ereszteni )ovatosan." + /* 45 */ , "Nyomj h)atr)at )es h)atrafel)e ugrok.@Azonnal nyomd meg )es tartsd nyomva az akci)o gombot,@)es elkapom a peremet )utban lefel)e." + /* 46 */ , "Akkor engedd el." + /* 47 */ , "Menj~unk )uszni egyet." + /* 48 */ , "Az ugr)as gomb )es az ir)anyok@navig)alnak engem a v)iz alatt." + /* 49 */ , ")O! Leveg\"o!@Csak haszn)ald az el\"or)et, balr)at, vagy jobbr)at@a felsz)in k~ozeli man\"overez)eshez.@Nyomj ugr)ast egy )ujabb )usz)ashoz lemer~ul)eshez.@Vagy menj a sz)el)ehez, )es nyomj akci)o gombot a kim)asz)ashoz." + /* 50 */ , "Helyes. A legjobb lesz, ha leveszem ezeket a nedves ruh)akat." + /* 51 */ , "Mond: Cs)i)iz!" + /* 52 */ , "Semmi szem)elyes." + /* 53 */ , "M)eg mindig f)aj a fejem t\"oled.@)Es m)ok)as ~otleteket ad nekem.@Hogy l\"ojelek a pokolra, p)eld)aul!" + /* 54 */ , "Nem tudsz meg~olni engem vagy a fi)ok)aimat olyan k~onnyed)en, Lara." + /* 55 */ , "Egy kicsit elk)esett a d)ij)atad)as, non?@M)eg mindig a r)eszv)etel ami sz)am)it." + /* 56 */ , "R)am l\"osz?@R)am l\"osz, mi?@Nincs senki m)as itt, csak r)am l\"ohetsz!" +// TR1 levels + , "Lara otthona" + , "Barlangok" + , "Vilcabamba v)arosa" + , "Elveszett v~olgy" + , "Qualopec s)irja" + , "Szt. Ferenc kolostor" + , "Colosseum" + , "Mid)asz palota" + , "A Ciszterna" + , "Tihocan s)irja" + , "Khamoon v)arosa" + , "Khamoon obeliszkje" + , "Scion szent)elye" + , "Natla b)any)ai" + , "Atlantisz" + , "A nagy piramis" + , "Visszat)er)es Egyiptomba" + , "Macska templom" + , "Atlantiszi t)amaszpont" + , "A kapt)ar" +// TR2 levels + , "Lara otthona" + , "A nagy fal" + , "Velence" + , "Bartoli rejtekhelye" + , "Operah)az" + , "Tengeri f)ur)otorony" + , "B)uv)arter~ulet" + , "40 ~ol" + , "A Maria Doria roncsa" + , "Lak)okabinok" + , "A fed)elzet" + , "Tibeti hegyl)abak" + , "Barkhang kolostor" + , "Talion katakomb)ai" + , "J)egpalota" + , "Xian temploma" + , ")Usz)o szigetek" + , "A S)ark)anyod)u" + , "Otthon )edes otthon" +// TR3 levels + , "Lara otthona" + , "Dzsungel" + , "Templom romok" + , "A Gangesz foly)o" + , "Kaliya barlangjai" + , "Tengerparti falu" + , "A baleset helysz)ine" + , "Madubu szurdok" + , "Puna temploma" + , "Temze rakpart" + , "Aldwych" + , "Lud kapuja" + , "V)aros" + , "Nevada sivatag" + , "Magas biztons)ag)u )ep~ulet" + , "51-es k~orzet" + , "Antarktisz" + , "RX-Tech b)any)ak" + , "Tinnos elveszett v)arosa" + , "Meteorit barlang" + , "Mindenszentek" +}; + +#endif diff --git a/src/lang/it.h b/src/lang/it.h new file mode 100644 index 00000000..bfdb78e4 --- /dev/null +++ b/src/lang/it.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_IT +#define H_LANG_IT + +// Thanks: MontyTRC, Leo-89 + +const char *STR_IT[] = { "" +// help + , "Caricamento in corso" + , "Premi H per la lista dei comandi" + , helpText + , "%s@@@" + "NEMICI UCCISI %d@@" + "OGGETTI RACCOLTI %d@@" + "SEGRETI %d di %d@@" + "TEMPO IMPIEGATO %s" + , "Salvataggio in corso" + , "Salvataggio completato" + , "ERRORE DURANTE IL SALVATAGGIO" + , "S$I" + , "NO" + , "Spento" + , "Acceso" + , "Spento" + , "Doppio schermo" + , "Anaglifo" + , "Compressione" + , "VR" + , "Basso" + , "Medio" + , "Alto" + , STR_LANGUAGES + , "Applica" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Non pronto" + , "Giocatore 1" + , "Giocatore 2" + , "Premi un tasto qualsiasi" + , "%s - Seleziona" + , "%s - Indietro" +// inventory pages + , "OPZIONI" + , "INVENTARIO" + , "OGGETTI" +// save game page + , "Salvare la partita?" + , "Posizione attuale" +// inventory option + , "Partita" + , "Mappa" + , "Bussola" + , "Statistiche" + , "Casa di Lara" + , "Grafica" + , "Suoni" + , "Controlli" + , "Gamma" +// passport menu + , "Carica partita" + , "Inizia partita" + , "Ricomincia il livello" + , "Torna ai titoli" + , "Esci dal gioco" + , "Selezione del livello" +// detail options + , "Livello di Dettaglio" + , "Textures" + , "Illuminazione" + , "Ombre" + , "Acqua" + , "VSync" + , "Stereo" + , "Oggetti semplificati" + , "Risoluzione" + , STR_SCALE +// sound options + , "Impostazioni audio" + , "Riverbero" + , "Sottotitoli" + , "Lingua" +// controls options + , "Personalizzazione comandi" + , "Tastiera" + , "Gamepad" + , "Vibrazione" + , "Retargeting" + , "Mira multipla" + // controls + , "Sinistra", "Destra", "Avanti", "Indietro", "Salto", "Camminata", "Azione", "Estrarre l'arma", "Osservare", "Accovacciarsi", "Scatto", "Capriola", "Inventario", "Start" + , STR_KEYS +// inventory items + , "Sconosciuto" + , "Esplosivo" + , "Pistole" + , "Fucile" + , "Magnum" + , "Uzi" + , "Munizioni pistola" + , "Munizioni fucile" + , "Munizioni Magnum" + , "Munizioni Uzi" + , "Medikit piccolo" + , "Medikit grande" + , "Barra di piombo" + , "Scion" +// keys + , "Chiave" + , "Chiave d'argento" + , "Chiave arrugginita" + , "Chiave d'oro" + , "Chiave di zaffiro" + , "Chiave di Nettuno" + , "Chiave di Atlante" + , "Chiave di Damocle" + , "Chiave di Thor" + , "Chiave cesellata" +// puzzles + , "Puzzle" + , "Idolo d'oro" + , "Barra d'oro" + , "Ruota dentata" + , "Fusibile" + , "Ankh" + , "Occhio di Horus" + , "Sigillo di Anubi" + , "Scarabeo" + , "Chiave della piramide" +// TR1 subtitles + /* CAFE */ , + "[43500]Che cosa deve fare un uomo@per ricevere da te questo genere di attenzioni?" + "[47500]Difficile dirlo con certezza,@ma forse sei sulla buona strada." + "[50000]Ottimo allora. Anche se a dire il vero@non sono io che ti sto cercando." + "[54500]No?" + "[55000]No. Sono qui per conto di Miss Jacqueline Natla,@della Natla Technologies." + "[59000]Hai presente quella che crea@cose scintillanti e belle?" + "[64500]Sta' zitto, Larson." + "[66000]Mmm.." + "[68000]Rifatti gli occhi, Lara." + "[70500]Non senti gi$a il tintinnio del tuo portamonete?" + "[73500]Mi spiace; Lavoro solo per divertirmi." + "[76000]Allora non potrai non amare questo immenso parco giochi." + "[78000]Peru'. Sterminate catene montuose da valicare.@Muri di ghiaccio trasparente. Dirupi rocciosi. Venti sferzanti." + "[87500]E poi ci sarebbe questo gingillo:@un antichissimo artefatto dai poteri mistici" + "[92500]sepolto nella tomba perduta di Qualopec." + "[96000]E' tutto ci$o che mi interessa." + "[98000]Potresti partire gi$a domani.@O avevi in previsione altri programmi?" + /* LIFT */ , + "[49000]Sono stato assegnato alle rovine di St. Francis,@nuove tentazioni mi tormentano." + "[53500]Tra i fratelli gira voce che sepolto@sotto il nostro monastero riposi il corpo di Tihocan," + "[60000]uno dei tre leggendari sovrani@del continente perduto, Atlantide," + "[64500]e che con lui si trovi il suo frammento@dello Scion atlantideo." + "[68000]L'amuleto diviso e spartito tra i tre sovrani" + "[72500]capace di controllare poteri inimmaginabili.@Poteri che superano quelli dello stesso Iddio." + "[79000]Mi tremano le gambe al solo pensiero@che giaccia talmente vicino al mio corpo mortale!" + "[85500]Ogni notte provo a rifuggire certe fantasie,@ma $e una sfida estremamente ardua." + "[92000]" + "[93500]Pierre. Tsss. Che idiota!" + /* CANYON */ , + "[13500]Sei appena giunta al capolinea!" + "[16500]Salve." + "[17500]Buon pomeriggio." + "[20000]E cos$i hai lasciato Larson a bocca asciutta?" + "[22500]Se cos$i si pu$o dire." + "[24000]Bene, le tue scorribande finiscono qui." + "[27000]E' tempo di restituirmi ci$o che mi hai sottratto." + "[30000]Diamo un'occhiata nel suo sacchetto per il pranzo." + "[32000]" + "[42500]Ottimo. Sbarazzatene!" + "[45000]Hey!" + "[48000]" + "[50500]Idioti!" + "[53000]" + "[62500]Andiamo." + "[65000]" + "[136000]Che diamine era quello?" + "[138000]Cosa?" + "[138500]Quella cosa.." + "[140500]Sar$a stato solo un pesce." + "[142500]Allora deve essere stato un pesce bello grosso, genio!" + "[145000]Ragazzo, vedi di darti una calmata!@Torno dentro. Vieni con me?" + "[152000]" + "[158000]Piano..." + "[160000]Eccola qui." + "[161500]Siete pronti?" + /* PRISON */ , + "[00001]Non puoi farlo!" + "[01500]Noi ti condanniamo, Natla di Atlantide, per i tuoi crimini." + "[06000]Per l'uso spregiudicato dei tuoi poteri@e per averci derubato del nostro..." + "[11500]Non ne avete il diritto! Io..." + "[12500]Infrangendo le leggi che governano@e tutelano il nostro popolo" + "[18500]e invadendo Tihocan e me con il nostro esercito." + "[23500]I nostri guerrieri hanno lasciato la piramide" + "[27000]cosicch)e tu potessi usare il suo potere creativo@per perseguire la tua dissennata brama di distruzione." + "[33500]Dissennata!? Guardatevi!" + "[35500]Nessuno di voi possiede un briciolo di ambizione!" + "[40500]Inetti!" + "[41500]Facciamolo e basta." + "[44000]Tihocan!" + "[45000]Hai usato il nostro luogo sacro@come fonte di piacere personale," + "[49500]come fosse una fabbrica di mostri." + "[51000]Sono dei sopravvissuti; una nuova generazione!" + "[54000]Solo un mucchio di carcasse dilaniate ora." + "[56000]E tu, tu verrai imprigionata nel limbo." + "[60000]Render$a le tue vene, cuore, gambe," + "[64000]e quella tua mente schizzata un tutt'uno con il sangue gelido." + "[70000]Saluta la tua eterna disperazione, Natla!" + "[73000]Neppure tu riposerai bene, o tantomeno il tuo@dannato continente di Atlantide!" + /* 22 */ , + "[04000]Di nuovo qui?" + "[05500]Anche tu - per assistere alla grande riapertura, suppongo." + "[09500]L'evoluzione fluisce ma la selezione naturale scorre pi$u lenta che mai..." + "[13500]Un rifornimento di carne fresca risveglier$a il nostro orgoglio identitario" + "[17500] - ci rinforzer$a e ci avvantagger$a..." + "[20500]..dar$a persino origine a nuove razze." + "[22500]Una specie di evoluzione sotto steroidi, quindi." + "[24500]Una spintarella...quei buoni a nulla@di Qualopec e Tihocan non avevano la bench)e minima idea" + "[29500] - il cataclisma che colp$i Atlantide ha spazzato via una razza di rammolliti..." + "[33500]facendoli ripiombare alle basi della sopravvivenza..." + "[37000]..ma non doveva andare in quel modo!" + "[39000]O in questo." + "[40000]La schiusura avr$a inizio tra 15 secondi." + "[43000]Troppo tardi ormai per tirarsi indietro!" + "[45000]Non senza la mente dell'operazione!" + "[47000]Noooo!" + "[50000]10" + "[54000]5..." + "[55500]4...3...2..." + "[60000]1..." + /* 23 */ , + "[00001]Bene, adesso hai la mia attenzione" + "[02500]- Tuttavia, non sono cos$i sicura di avere la tua." + "[05000]Hey?" + "[06000]Ti accopper$o e ti sbatter$o dentro una stalla." + "[09000]Come no." + "[10000]Tu e quel dannato pezzo di Scion." + "[13000]Se vuoi tenerlo ad ogni costo, provveder$o immediatamente a..." + "[17000]Aspetta... stiamo parlando di questo artefatto?" + "[20000]Siamo sulla buona strada ... te lo far$o ingoi..." + "[22000]Alt - Scusa un secondo" + "[24000]- hai detto questo pezzo - dove sono gli altri?" + "[26500]Miss Natla ha gi$a messo Pierre Dupont sulle loro tracce." + "[29500]E lui dove si trova adesso?" + "[30500]Hah. Non sei abbastanza veloce per raggiungerlo." + "[34000]Hai forse intenzione di trattenermi blaterando?" + "[37000]Non so dove lo stiano conducendo ora le sue gambette da leprotto." + "[42000]Dovresti chiederlo a Miss Natla." + "[46000]" + "[51000]Grazie. Provveder$o." + /* 24 */ , "" + /* 25 */ , + "[03500]Qui giace Tihocan" + "[05000]...uno dei due onorati sovrani di Atlantide..." + "[10000]..che anche dopo la rovina del continente..." + "[13000]...tent$o di ristabilire l'ordine in queste lande desolate..." + "[19000]Egli mor$i senza un erede e la sua conoscenza non fu tramandata..." + "[25500]Veglia su di noi, Tihocan." + /* 26 */ , "Benvenuto nella mia casa! Lascia che ti porti a dare un'occhiata in giro." + /* 27 */ , "Usa i tasti direzionali per spostarti nella sala della musica." + /* 28 */ , "Ok, facciamo qualche acrobazia!@Premi il tasto Salto." + /* 29 */ , "Ora fallo di nuovo premendo un tasto direzionale;@io salter$o da quella parte." + /* 30 */ , "Questo $e l'atrio principale!@Vorrai perdonare il disordine ma ho imballato alcune cose@e come immaginerai il fattorino non si $e ancora fatto vivo." + /* 31 */ , "Posizionami di fronte ad una cassa e continuando a premere Avanti@premi il tasto Azione: mi ci arrampicher$o sopra." + /* 32 */ , "Una volta questa era la sala da ballo@ma io l'ho trasformata nella mia palestra personale; Che te ne pare?@Bene, facciamo qualche esercizio!" + /* 33 */ , "Ovviamente io non corro sempre;@quando serve una certa prudenza cammino.@Tieni premuto il tasto Camminata e raggiungi la linea bianca." + /* 34 */ , "Con il tasto Camminata premuto non cadr$o@nemmeno se mi spingi a farlo.@Avanti, prova pure!" + /* 35 */ , "Se vuoi guardarti intorno premi e tieni premuto il tasto Osserva;@infine con i tasti direzionali muovi la visuale verso il punto che vuoi." + /* 36 */ , "Se un salto $e troppo lungo posso aggrapparmi al bordo@evitando una rovinosa caduta.@Cammina verso il bordo con la linea bianca finch)e non posso pi$u andare avanti;@quindi premi Salto, immediatamente seguito da Avanti@e mentre sono in aria premi e tieni premuto il tasto Azione." + /* 37 */ , "Adesso premi il tasto Avanti e mi arrampicher$o." + /* 38 */ , "Facendo un salto con rincorsa arrivare a quella distanza@sar$a sicuramente uno scherzo!" + /* 39 */ , "Cammina verso il bordo con la linea bianca finch)e non mi fermo.@Quindi rilascia il tasto Cammina e premi una volta Indietro@in modo da farmi prendere la rincorsa.@Premi Avanti e subito dopo premi e tieni premuto il tasto Salto:@non salter$o fino all'ultimo secondo." + /* 40 */ , "Perfetto; questo $e davvero un gran bel salto!@Allora: fai un salto con rincorsa esattamente come prima@ma questa volta mentre sono in aria premi e tieni premuto Azione@per farmi aggrappare al bordo." + /* 41 */ , "Bene!" + /* 42 */ , "Ora prova a sollevarti qui!@Premi Avanti e tieni premuto il tasto Azione." + /* 43 */ , "Come vedi non posso tirarmi su perch)e la fessura $e troppo stretta,@per$o puoi spingere verso destra: mi sposter$o@lateralmente finch)e c'$e spazio. Infine premi Avanti." + /* 44 */ , "Ottimo!@Se c'$e un grosso dislivello e non voglio farmi male cadendo@posso calarmi gi$u lentamente." + /* 45 */ , "Premi una volta Indietro e far$o uno scatto in quella direzione.@Poi, immediatamente, premi e tieni premuto il@tasto Azione: mi aggrapper$o al bordo per scendere." + /* 46 */ , "Ora rilascia." + /* 47 */ , "Adesso andiamo a farci una bella nuotata!" + /* 48 */ , "Usa il tasto Salto insieme ai tasti direzionali@per farmi muovere quando sono sott'acqua." + /* 49 */ , "Ah! Aria!@Premi i tasti direzionali per muovermi quando sono a galla.@Premi Salto per farmi immergere di nuovo,@altrimenti raggiungi il bordo e premi Avanti e Azione per farmi uscire." + /* 50 */ , "Perfetto! Ora per$o sar$a meglio che mi tolga@questi vestiti bagnati.." + /* 51 */ , "Sorridi!" + /* 52 */ , "Niente di personale." + /* 53 */ , "Essere maledetto, mi fai sempre venire il mal di testa.@E mi provochi anche brutti pensieri,@ad esempio quello di spararti!" + /* 54 */ , "Non puoi liberarti di me e della mia stirpe@cos$i facilmente, Lara!" + /* 55 */ , "Un po' in ritardo per la premiazione, no?@Ma l'importante in fin dei conti $e partecipare, sbaglio?" + /* 56 */ , "Mi stai sparando?@Ehi, stai sparando a me?@Eh s$i, non c'$e nessun altro, stai proprio sparando a me!" +// TR1 levels + , "Casa di Lara" + , "Caverne" + , "Citt$a di Vilcabamba" + , "La Valle Perduta" + , "Tomba di Qualopec" + , "Rovine di St. Francis" + , "Colosseo" + , "Palazzo di Mida" + , "Cisterna" + , "Tomba di Tihocan" + , "Citt$a di Khamoon" + , "Obelisco di Khamoon" + , "Santuario dello Scion" + , "Miniere di Natla" + , "Atlantide" + , "La Grande Piramide" + , "Ritorno in Egitto" + , "Tempio del Gatto" + , "Fortezza atlantidea" + , "L'alveare" +// TR2 levels + , "Casa di Lara" + , "La Grande Muraglia" + , "Venezia" + , "Covo di Bartoli" + , "Teatro dell'Opera" + , "Piattaforma offshore" + , "Area d'immersione" + , "40 atmosfere" + , "Relitto della Maria Doria" + , "Saloni abitati" + , "Il ponte" + , "Pendici tibetante" + , "Monastero di Barkhang" + , "Catacombe di Talion" + , "Palazzo di ghiaccio" + , "Tempio dello Xian" + , "Isole galleggianti" + , "La tana del drago" + , "Casa dolce casa" +// TR3 levels + , "Casa di Lara" + , "Giungla" + , "Rovine del tempio" + , "Il fiume Gange" + , "Caverne di Kaliya" + , "Villaggio costiero" + , "Luogo dell'incidente" + , "Gola di Madubu" + , "Tempio di Puna" + , "Molo sul Tamigi" + , "Aldwych" + , "Cancello di Lud" + , "Citt$a di Londra" + , "Deserto del Nevada" + , "Reparto di massima sicurezza" + , "Area 51" + , "Antartico" + , "Miniere RX-Tech" + , "Citt$a perduta di Tinnos" + , "Caverna del meteorite" + , "Hallows" +}; + +#endif diff --git a/src/lang/ja.h b/src/lang/ja.h new file mode 100644 index 00000000..76d09d28 --- /dev/null +++ b/src/lang/ja.h @@ -0,0 +1,597 @@ +#ifndef H_LANG_JA +#define H_LANG_JA + +// Thanks: Eringo + +#include "glyph_ja.h" + +#if 0 +const char *STR_JA[] = { "日本語" +// help + , "ロード中・・・" + , "Hボタンã§ãƒ˜ãƒ«ãƒ—を表示" + , helpText + , "%s@@@" + "殺ã—ãŸæ•µæ•° %d@@" + "拾ã£ãŸã‚¢ã‚¤ãƒ†ãƒ æ•° %d@@" + "シークレット %d / %d@@" + "所è¦æ™‚é–“ %s" + , "セーブ中・・・" + , "セーブã—ã¾ã—ãŸï¼" + , "セーブã§ãã¾ã›ã‚“ã§ã—ãŸï¼" + , "ã¯ã„" + , "ã„ã„ãˆ" + , "オフ" + , "オン" + , "オフ" + , "Side-By-Side" + , "Anaglyph" + , "ç”»é¢åˆ†å‰²" + , "VR" + , "低" + , "中" + , "高" + , STR_LANGUAGES + , "é©ç”¨" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Not Ready" + , "Player 1" + , "Player 2" + , "ボタンを押ã—ã¦ãã ã•ã„" + , "%s - 決定" + , "%s - 戻る" +// inventory pages + , "オプション" + , "æŒã¡ç‰©" + , "アイテム" +// save game page + , "セーブã—ã¾ã™ã‹ï¼Ÿ" + , "ç¾åœ¨ä½ç½®" +// inventory option + , "ゲーム" + , "マップ" + , "コンパス" + , "ステータス" + , "ララã®å®¶" + , "詳細設定" + , "サウンド" + , "コントローラ" + , "明るã•" +// passport menu + , "ロード" + , "æ–°ã—ã„ゲーム" + , "リプレイ" + , "メニューã«æˆ»ã‚‹" + , "ゲームを終ã‚ã‚‹" + , "レベルをé¸æŠžã™ã‚‹" +// detail options + , "ディテール調整" + , "フィルタリング" + , "ライティングクオリティ" + , "シャドウクオリティ" + , "水クオリティ" + , "VSync" + , "パラレルビュー" + , "2Dアイテム" + , "Resolution" + , STR_SCALE +// sound options + , "音é‡è¨­å®š" + , "リãƒãƒ¼ãƒ–レーション" + , "字幕" + , "言語" +// controls options + , "コントローラ設定" + , "キーボード" + , "ゲームパッド" + , "ãƒã‚¤ãƒ–レーション" + , "リターゲティング" + , "マルãƒã‚¨ã‚¤ãƒŸãƒ³ã‚°" + // controls + , "å·¦", "å³", "上", "下", "ジャンプ", "æ­©ã", "アクション", "銃を抜ã", "見る", "ã—ゃãŒã‚€", "ダッシュ", "転ãŒã‚‹", "æŒã¡ç‰©ã‚’見る", "スタート" + , STR_KEYS +// inventory items + , "ä¸æ˜Ž" + , "爆弾" + , "ピストル" + , "ショットガン" + , "マグナム" + , "ウージー" + , "ピストル弾" + , "ショットガン弾" + , "マグナム弾" + , "ウージー弾" + , "メディパック(å°ï¼‰" + , "メディパック(大)" + , "鉛ã®å»¶æ£’" + , "シオン" +// keys + , "éµ" + , "銀ã®éµ" + , "錆ã³ãŸéµ" + , "金ã®éµ" + , "サファイアキー" + , "ãƒãƒ—トゥーヌスã®éµ" + , "アトラースã®éµ" + , "ダモクレスã®éµ" + , "トールã®éµ" + , "è¯ç¾Žãªéµ" +// puzzles + , "パズル" + , "ゴールドアイドル" + , "金ã®å»¶æ£’" + , "歯車" + , "ヒューズ" + , "アンク" + , "ホルスã®ç›®" + , "アヌビスã®çŸ³ç‰ˆ" + , "スカラベ" + , "ピラミッドã®éµ" +// TR1 subtitles + /* CAFE */ , + "" + /* LIFT */ , + "" + /* CANYON */ , + "" + /* PRISON */ , + "" + /* 22 */ , + "[04000]ã¾ãŸæ¥ãŸã®ï¼Ÿ" + "[05500]ãã†ã‚ˆï½žã‚ãªãŸã®å¾©å¸°ã‚’ç¥ã„ã«ã­ã€‚" + "[09000]生命ã®é€²åŒ–ã¯è¡Œãè©°ã£ã¦ã—ã¾ã„ã€è‡ªç„¶æ·˜æ±°ã¯å…¨ã機能ã—ãªããªã£ã¦ã„る。" + "[14000]ã—ã‹ã—ã€è„…å¨ã¨ã‚‚ãªã‚‹æ–°ç¨®ã‚’世ã«é€ã‚Šå‡ºã›ã°ã€äººé–“ã¯é–“引ãã•ã‚Œã€" + "[18000]çµæžœçš„ã«ã¯æˆ‘々をより強ãã€" + "[20500]より進化ã•ã›ã‚‹ã€‚" + "[22500]ãªã‚“ã ã‹ãƒ‰ãƒ¼ãƒ”ングã—ãŸé€²åŒ–è«–ã£ã¦ã“ã¨ã­" + "[24500]å¼·ã„刺激ãŒå¿…è¦ãªã®ã‚ˆã€‚ã ã‹ã‚‰ã€å¤§é™¸ã‚’崩壊ã•ã›ã€" + "[29500]文明ã®åˆ©å™¨ã«é ¼ã‚Šåˆ‡ã£ã¦ã„ãŸè€…ãŸã¡ã«ã€" + "[33000]最も基本的ãªç”Ÿå­˜ç«¶äº‰ã‚’å¼·ã„ãŸã‚“ã ã€‚" + "[37000]ç§ã®ãƒ—ランãŒçš†ã‚’æ•‘ã†ã®ã‚ˆã€‚" + "[39000]ãã†ä¸Šæ‰‹ãã„ãã‹ã—ら。。。" + "[40000]孵化完了ã¾ã§15秒å‰ã€‚" + "[43000]中絶ã™ã‚‹ã«ã¯é…ã™ãŽã‚‹ã‚ã­ã€‚" + "[45000]手術ã¯ã€ä»–ã®ã¨ã“ã«æ–½ã™ã‚。" + "[47000]ダメï¼ã†ã‚ã~ï¼ï¼ï¼" + "[50000]10秒å‰" + "[54000]5・・・" + "[55500]4・・・3・・・2・・・" + "[60000]1・・・" + /* 23 */ , + "[00001]今度ã¯æœ¬å½“ã«ã‚ãŸã—を怒らã›ã¦ã—ã¾ã£ãŸã‚ˆã†ã­ã€‚" + "[04000]æ°—ã¥ã„ãŸã‹ãªï¼Ÿ" + "[06000]ã¦ã‚ã‡ã®ä¸‹æ‰‹ãªéŠƒã®ãŠã‹ã’ã§åŠ©ã‹ã£ãŸãœã€‚" + "[09000]ãã‚Œã¯ã©ã†ã‚‚" + "[10000]ãŠã‚ãˆã•ã‚“ã€ã‚ã®ã‚¯ã‚½å¿Œã€…ã—ã„シオンã®ã‹ã‘らãŒãã‚“ãªã«æ¬²ã—ã„ã®ã‹ã„?" + "[13500]ãªã‚‰ãれをアンタã®ã‚±ãƒ„ã®ç©´ã«ã¶ã¡è¾¼ã‚“ã§ã‚„ã£ãƒ»ãƒ»ãƒ»" + "[17000]ã¡ã‚‡ã£ã¨å¾…ã£ã¦ãƒ»ãƒ»ãƒ»ã‚ãªãŸã‚ã®ãŠå®ˆã‚Šã®è©±ã—ã¦ã‚‹ã®ï¼Ÿ" + "[20000]当ãŸã‚Šå‰ã ã‚ˆãƒ»ãƒ»ãƒ»ç›®ã®ã‚±ãƒ„ã®ãƒ»ãƒ»ãƒ»" + "[21500]ã‚ã£ã€ã¡ã‚‡ã£ã¨å¾…ã£ã¦ - ã”ã‚ã‚“ãªã•ã„。" + "[24000]ã“ã®ã‚·ã‚ªãƒ³ã¨ãŠå®ˆã‚Šã®ã‹ã‘らã¯ä»–ã«ã©ã“ã«ã‚ã‚‹ã®" + "[26500]ミス・ナトラãŒãƒ”エール・ドゥãƒãƒ³ã£ã¦ãƒ¤ãƒ„を使ã£ã¦æŽ¢ã•ã›ã¦ã„る。" + "[29500]ãã‚Œã¯ã©ã“ãªã®ï¼Ÿ" + "[30500]ã¯ãƒ¼ï¼ãŠã‚ãˆã•ã‚“ã£ã¦ãƒ¤ãƒ„追ã„ã¤ãã“ã¨ã¯ã§ãã­ãˆã‚ˆã€‚" + "[34000]ã©ã“ã£ã¦èžã„ã¦ã‚‹ã­ã‚“ï¼" + "[37000]ã„や~ã‚ã®ãƒ•ãƒ©ãƒ³ã‚¹é‡ŽéƒŽãŒã©ã“ã„ã£ãŸã‹ã‚ã‹ã‚“ã­ãˆã‚“ã ã‚ˆã€‚" + "[41500]ミス・ナトラã«èžãã—ã‹ã­ãˆã˜ã‚ƒã­ãƒ¼ã‹ï¼Ÿ" + "[46000]" + "[50500]ã‚ã‚ŠãŒã¨ã†ã€‚ã»ã‚“ã®ãŠç¤¼ã€‚" + /* 24 */ , "" + /* 25 */ , + "[03000]ã“ã“ã«çœ ã‚‹ã¯çš‡å¸ãƒ†ã‚£ãƒ›ã‚«ãƒ³" + "[06000]・・・大陸アトランティスを統治ã—ãŸäºŒäººã®å…¬æ˜Žæ­£å¤§ãªæŒ‡å°Žè€…ã®ä¸€äººãƒ»ãƒ»ãƒ»" + "[11000]皇å¸ã¯å¤§é™¸ã®å‘ªã„ã«æŒ‘ã‚€ã‹ã®ã‚ˆã†ã«ãƒ»ãƒ»ãƒ»" + "[14000]・・・ã“ã®è’れ果ã¦ã„ãŸåœ°ã«ç§©åºã¨å¯Œã‚’実らãã†ã¨ã—ãŸãƒ»ãƒ»ãƒ»" + "[18000]å­å­«ã®æ®‹ã•ãšåŽ»ã£ãŸçš‡å¸ã¯ãã®è±Šå¯Œã®çŸ¥è­˜ã‚’後世ã¸ä¼ãˆã‚‹ã“ã¨ã¯ãªã‹ã£ãŸãƒ»ãƒ»ãƒ»" + "[25000]寛大ãªã‚‹ãƒ†ã‚£ãƒ›ã‚«ãƒ³æ§˜ã€ç§ãŸã¡ã«ã”加護を。" + /* 26 */ , "ç§ã®å®¶ã«ã‚ˆã†ã“ã。@家ã®ä¸­ã‚’紹介ã™ã‚‹ã‚。" + /* 27 */ , "æ–¹å‘キー押ã—ã¦ã€ãƒŸãƒ¥ãƒ¼ã‚¸ãƒƒã‚¯ãƒ«ãƒ¼ãƒ ã«å…¥ã£ã¦ã€‚" + /* 28 */ , "OK。ジャンプã®ç·´ç¿’ã—ã¾ã—ょã†ã€‚@ジャンプボタンを押ã—ã¦ã€‚" + /* 29 */ , "ジャンプボタンを押ã—ã¦ã‹ã‚‰ã™ãã«æ–¹å‘キーを押ã—ã¦ã€@æ–¹å‘キーを押ã—ãŸæ–¹å‘ã«ã‚¸ãƒ£ãƒ³ãƒ—ã™ã‚‹ã‚。" + /* 30 */ , "ã†ãµãµã€ã“ã“ã¯å¿œæŽ¥é–“よ@散らã‹ã£ã¦ã„ã¦ã”ã‚ã‚“ãªã•ã„ã­ã€‚@é‹é€å“¡ãŒã¾ã æ¥ãªã„ã®ã‚ˆã€‚" + /* 31 */ , "次ã¯ã‚³ãƒ³ãƒ†ãƒŠã«ã‚ˆã˜ç™»ã£ã¦ã¿ã¾ã—ょã†ã€‚@æ–¹å‘キーã®ä¸Šã‚’押ã—ãªãŒã‚‰ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ã€‚" + /* 32 */ , "ã“ã®éƒ¨å±‹ã¯ç§ã®ã‚¸ãƒ ã‚ˆã€‚@ã©ã†ï¼Ÿ" + /* 33 */ , "æ­©ãボタンを押ã—ãªãŒã‚‰æ–¹å‘キーを押ã—ã¦ã€@白線ã®ã¨ã“ã‚ã¾ã§æ­©ã„ã¦ã€‚" + /* 34 */ , "æ­©ãボタンを押ã—ã¦ã„ã‚‹ã¨ã€å´–ã‹ã‚‰è½ã¡ãªã„ã‚よ。" + /* 35 */ , "周りを見渡ã—ãŸã„ã¨ãã¯è¦‹ã‚‹ãƒœã‚¿ãƒ³ã‚’押ã—ãªãŒã‚‰ã€æ–¹å‘キーを押ã—ã¦ã€‚@見るボタンを押ã—ãªãŒã‚‰ã€æ–¹å‘キーを押ã—ã¦ã€‚" + /* 36 */ , "ã¾ãšã¯ã€ç™½ç·šã®ã¨ã“ã‚ã¾ã§æ­©ã„ã¦ã€@ジャンプボタンを押ã—ãªãŒã‚‰ã€ã™ãã«æ–¹å‘キーã®ä¸Šã‚’押ã—ã¦ã€@空中ã«ã„ã‚‹ã¨ãã«ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã‚’押ã—ã£ã±ãªã—ã«ã™ã‚‹ã¨ã€@フãƒã«ã¤ã‹ã¾ã‚Œã‚‹ã‚。" + /* 37 */ , "アクションボタンを押ã—ãŸã¾ã¾ã€ä¸Šã‚’押ã™ã¨ç™»ã‚Œã‚‹ã‚。" + /* 38 */ , "æ–¹å‘キーã®ä¸Šã‚’押ã—ãªãŒã‚‰ã€ã‚¸ãƒ£ãƒ³ãƒ—ボタンを押ã™ã¨èµ°ã‚ŠãªãŒã‚‰ã‚¸ãƒ£ãƒ³ãƒ—ãŒã§ãã‚‹ã‚。" + /* 39 */ , "å‹•ããŒæ­¢ã¾ã‚‹ã¾ã§æ­©ã„ã¦å‰é€²ã—ã€æ­©ãボタンを離ã—ã¦ã‹ã‚‰@æ–¹å‘キーã®ä¸‹ã‚’1回押ã—ã¦ã€ã“ã‚Œã§åŠ©èµ°ãŒã§ãるよã†ã«ãªã‚‹ã‚。@上を押ã—ã€ã™ãã«ã‚¸ãƒ£ãƒ³ãƒ—ボタンを押ã—続ã‘る。@ãã†ã™ã‚‹ã¨ã‚®ãƒªã‚®ãƒªã®ã¨ã“ã‚ã§ã‚¸ãƒ£ãƒ³ãƒ—ã§ãã‚‹ã‚。" + /* 40 */ , "ãã—ã¦æ¬¡ã¯æœ€ã‚‚é‡è¦ãªã“ã¨ã€‚@èµ°ã‚ŠãªãŒã‚‰ã‚¸ãƒ£ãƒ³ãƒ—ã‚’ã—ã¦ç©ºä¸­ã«ã„ã‚‹ã¨ãã€@アクションボタンã ã‘を押ã—続ã‘ã‚‹ã¨å´–ã®ãƒ•ãƒã«ã¤ã‹ã¾ã‚Œã‚‹ã‚。" + /* 41 */ , "ã„ã„ã‚~ OK。" + /* 42 */ , "よã˜ç™»ã‚‹ã«ã¯ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã‚’押ã—ãŸã¾ã¾ã€æ–¹å‘キーã®ä¸Šã‚’押ã—ã¦ã€‚" + /* 43 */ , "上ã®ã‚¹ãƒšãƒ¼ã‚¹ãŒç‹­ãã¦ã€ã“ã“ã‹ã‚‰ã¯ç™»ã‚Œãªã„ã‚。@アクションボタンを押ã—ãŸã¾ã¾ã€æ–¹å‘キーã®å³ã‚’押ã—ã¦ã€@å³ç«¯ã¾ã§è¡Œã£ãŸã‚‰ã€ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã‚’押ã—ãŸã¾ã¾ã€æ–¹å‘キーã®ä¸Šã‚’押ã›ã°ç™»ã‚Œã‚‹ã‚。" + /* 44 */ , "ã„ã„ã‚~ もã—ケガをã—ãŸããªã‹ã£ãŸã‚‰ã€éºè·¡ã®ä¸­ã§ã¯æ³¨æ„æ·±ã行動ã™ã‚‹ã“ã¨ã­ã€‚" + /* 45 */ , "自分ã®å¾Œã‚ã«å´–ãŒã‚ã‚‹ã¨ãã€@一度方å‘キーã®ä¸‹ã‚’押ã—ã€ã™ãã«ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã ã‘を押ã—ã¦ã€@å´–ã®ãƒ•ãƒã«ã¶ã‚‰ä¸‹ãŒã‚‹ã“ã¨ã‚‚ã§ãã‚‹ã‚。" + /* 46 */ , "ã˜ã‚ƒã‚ã€æ¬¡ã«è¡Œãã¾ã—ょã†ã€‚" + /* 47 */ , "次ã¯æ³³ãŽã®ç·´ç¿’ã­ã€‚" + /* 48 */ , "ジャンプボタンã¨æ–¹å‘キーを使ã£ã¦ã€@æ³³ã’ã‚‹ã‚。" + /* 49 */ , "苦ã—ã‹ã£ãŸï½ž@æ–¹å‘キーã®ä¸Šã€å·¦ã¨å³ãƒœã‚¿ãƒ³ã§æ°´ä¸Šæ³³ãã“ã¨ãŒã§ãã‚‹ã‚。@ジャンプボタンã§ã¾ãŸæ½œã‚Œã‚‹ã®ã€‚@プールã®ãƒ•ãƒã«è¡Œã£ã¦ã€ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ãƒœã‚¿ãƒ³ã¨æ–¹å‘キーã®ä¸Šã‚’押ã™ã¨æ°´ã‹ã‚‰ä¸ŠãŒã‚Œã‚‹ã‚。" + /* 50 */ , "ãã‚ãã‚冒険ã«è¡Œãã¾ã—ょã†ã‹ï¼Ÿ" + /* 51 */ , "ã“ã®ãƒ¡ã‚¹çŠ¬ãŒãƒ»ãƒ»ãƒ»ï¼" + /* 52 */ , "ã“ã„ã¤ã‚‰ä¸€äººä¸€äººç´¹ä»‹ã—ã­ãˆã¨ãªã€‚" + /* 53 */ , "ãã„ã¤æ¸¡ã›ã¨ã¯è¨€ã‚ã­ãˆï¼@ãªãœãªã‚‰ã€ã“ã“ã§æ­»ã‚“ã§ã‚‚らã†ã‹ã‚‰ã•ã‚。" + /* 54 */ , "ç§ãŒãã‚“ãªã«ç°¡å˜ã«ã‚„られるã¨æ€ã†ï¼Ÿ" + /* 55 */ , "ビンゴã®å•†å“ã‚’å—ã‘å–ã‚‹ã«ã¯å°‘ã—é…ã‹ã£ãŸã‚ˆã†ã ãªã€€ãƒžãƒ‰ãƒ¢ãƒ¯ã‚¼ãƒ«ã€‚@ã“ã†ã„ã†ã‚‚ã®ã¯å‹ã¡å–らãªã‘ã‚Œã°ãªã‚‰ãªã„ã‹ã‚‰ã­ã€‚@ã†ï½žã€€å®Ÿã«æ®‹å¿µã ã€‚å›ã¨ã“ã†ã—ã¦äº‰ã‚ãªã‘ã‚Œã°ãªã‚‰ãªã„ãªã‚“ã¦ã€‚@ã§ã‚‚ã€ã“ã‚ŒãŒé‹å‘½ãªã®ã•ã€‚" + /* 56 */ , "" +// TR1 levels + , "ララã®å®¶" + , "洞窟" + , "å¤ä»£éƒ½å¸‚ビルカãƒãƒ³ãƒ" + , "ロスト・ãƒãƒ¬ãƒ¼" + , "クアロペック王墓" + , "è–フランシスè–å ‚" + , "コロシアム" + , "ミダスã®å®®æ®¿" + , "貯水池" + , "ティホカン王墓" + , "カームーンã®éƒ½å¸‚éºè·¡" + , "カームーンã®ã‚ªãƒ™ãƒªã‚¹ã‚¯" + , "シオンã®è–域" + , "ナトラã®é‰±å±±" + , "アトランティス" + , "グレート・ピラミッド" + , "エジプトå†è¨ª" + , "猫ã®å¯º" + , "アトランティス改造兵ã®ç‰™åŸŽ" + , "巣箱" +// TR2 levels + , "ララã®å®¶" + , "万里ã®é•·åŸŽ" + , "ベニス" + , "ãƒãƒ«ãƒˆãƒ¼ãƒªã®éš ã‚Œå®¶" + , "オペラãƒã‚¦ã‚¹" + , "海上倉庫" + , "潜水場" + , "海底" + , "マリアå·ã®æ®‹éª¸" + , "船底" + , "デッキ" + , "ãƒãƒ™ãƒƒãƒˆã®ä¸˜é™µ" + , "ãƒãƒ¼ã‚«ãƒ³ã‚°å¯ºé™¢" + , "タリオンã®å¢“" + , "æ°·ã®åŸŽ" + , "西安ã®å¯º" + , "浮島" + , "ドラゴンã®å·£" + , "ララã®å®¶" +// TR3 levels + , "ララã®å®¶" + , "ジャングル" + , "æ»…ã³ãŸå¯ºé™¢" + , "ガンジスå·" + , "カリアケーブ" + , "コーストビレッジ" + , "墜è½ç¾å ´" + , "マデュãƒã®è°·" + , "ピュナ寺院" + , "テムズå·ã®ã»ã¨ã‚Š" + , "アンダーグラウンド" + , "ルッドã®é–€" + , "シティ" + , "ãƒãƒãƒ€ç ‚æ¼ " + , "ãƒã‚¤ã‚»ã‚­ãƒ¥ãƒªãƒ†ã‚£ã‚¨ãƒªã‚¢" + , "エリア51" + , "å—極大陸" + , "RX-TECH社発掘場" + , "æ»…ã³ãŸãƒ†ã‚£ãƒŽã‚¹" + , "クレーター" + , "セイントデイ" +}; +#endif + +#define JA_GLYPH_COUNT 452 +#define JA_GLYPH_BASE 0 +const uint8 JA_GLYPH_WIDTH[] = { + 16, 16, 15, 14, 6, 10, 16, 15, 16, 6, 16, 16, 15, 16, 15, 16, + 15, 15, 15, 16, 16, 14, 15, 15, 15, 15, 16, 16, 17, 14, 17, 14, + 15, 16, 17, 16, 16, 16, 17, 15, 13, 17, 16, 17, 16, 13, 13, 12, + 16, 14, 17, 15, 17, 15, 16, 13, 14, 15, 16, 13, 13, 16, 17, 16, + 15, 13, 10, 17, 16, 15, 15, 16, 14, 15, 15, 16, 16, 14, 16, 17, + 17, 13, 16, 16, 15, 16, 16, 16, 16, 16, 14, 13, 16, 17, 16, 15, + 15, 17, 15, 17, 16, 16, 16, 17, 17, 16, 17, 15, 17, 17, 17, 17, + 16, 17, 16, 17, 16, 17, 16, 16, 15, 16, 17, 2, 17, 17, 17, 16, + 14, 17, 16, 17, 17, 17, 16, 16, 17, 16, 17, 17, 17, 17, 16, 16, + 17, 17, 17, 17, 17, 17, 17, 17, 14, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 17, 16, 17, 16, 17, 16, 17, 17, 16, 17, 14, 17, 14, 16, + 17, 16, 16, 17, 17, 17, 16, 17, 17, 17, 16, 15, 17, 16, 17, 16, + 17, 16, 17, 16, 17, 16, 17, 15, 17, 17, 17, 17, 17, 17, 17, 16, + 15, 17, 17, 17, 16, 17, 16, 16, 9, 17, 17, 16, 15, 17, 17, 17, + 17, 17, 14, 17, 14, 16, 14, 17, 17, 15, 16, 17, 17, 16, 17, 16, + 17, 17, 17, 17, 17, 14, 17, 17, 16, 17, 17, 17, 17, 16, 17, 17, + 17, 17, 17, 17, 16, 16, 17, 17, 17, 16, 16, 16, 17, 17, 17, 17, + 17, 16, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 16, 16, 17, 17, 17, 17, 17, 17, 15, 17, 17, 17, 17, 17, + 16, 17, 17, 17, 17, 16, 17, 16, 14, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 17, 16, 17, 17, 17, 17, 17, 17, 14, 17, 17, 15, 17, 17, + 17, 13, 17, 17, 17, 17, 17, 16, 17, 17, 16, 15, 17, 17, 17, 17, + 17, 17, 16, 17, 17, 16, 17, 17, 17, 15, 17, 17, 17, 17, 14, 16, + 17, 17, 17, 17, 17, 17, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 17, 17, 16, 17, 17, 17, 16, 17, 16, 17, 16, 17, 17, 17, + 17, 17, 17, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, + 17, 16, 16, 17, 17, 14, 17, 17, 17, 16, 15, 17, 15, 17, 17, 16, + 14, 17, 17, 17, }; + +const char *STR_JA[] = { "\x11\x02\x70\x01\x97\x01\xD6\xFF\xFF" +// help + , "\x11\x01\x55\x01\x03\x01\x31\x01\x4F\x01\x06\x01\x06\x01\x06\xFF\xFF" + , "H\x11\x01\x1D\x01\x13\x01\x02\x01\x1F\x02\x71\x01\x23\x01\x27\x01\x07\x02\x6E\x02\x6F\xFF\xFF" + , helpText + , "%s@@@" + "\x11\x02\x74\x01\x04\x01\x0E\x02\x75\x01\xB1\xFF\xFF"" %d@@" + "\x11\x02\x72\x01\x16\x01\x0E\x01\x1A\x01\x3C\x01\x24\x01\x34\x01\xB1\xFF\xFF"" %d@@" + "\x11\x01\x1C\x01\x03\x01\x21\x01\x41\x01\x2F\x01\x20\xFF\xFF"" %d / %d@@" + "\x11\x02\x73\x01\x9C\x02\x68\x01\x80\xFF\xFF"" %s" + , "\x11\x01\x5F\x01\x03\x01\x54\x01\x4F\x01\x06\x01\x06\x01\x06\xFF\xFF" + , "\x11\x01\x5F\x01\x03\x01\x54\x01\x04\x01\x19\x01\x04\x01\x0E\x01\x43\xFF\xFF" + , "\x11\x01\x5F\x01\x03\x01\x54\x01\x1F\x01\x32\x01\x19\x01\x4D\x01\x33\x01\x1F\x01\x04\x01\x0E\x01\x43\xFF\xFF" + , "\x11\x01\x15\x01\x0C\xFF\xFF" + , "\x11\x01\x0C\x01\x0C\x01\x4B\xFF\xFF" + , "\x11\x01\x3B\x01\x47\xFF\xFF" + , "\x11\x01\x3B\x01\x02\xFF\xFF" + , "\x11\x01\x3B\x01\x47\xFF\xFF" + , "Side-By-Side" + , "Anaglyph" + , "\x11\x02\x69\x02\x66\x01\xCA\x02\x67\xFF\xFF" + , "VR" + , "\x11\x02\x6C\xFF\xFF" + , "\x11\x01\x4F\xFF\xFF" + , "\x11\x02\x6D\xFF\xFF" + , STR_LANGUAGES + , "\x11\x02\x6A\x02\x6B\xFF\xFF" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "Not Ready" + , "Player 1" + , "Player 2" + , "\x11\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x30\x01\x40\x01\x3A\x01\x0C\xFF\xFF" + , "%s - \x11\x02\x80\x01\x7A\xFF\xFF" + , "%s - \x11\x01\xB6\x01\x08\xFF\xFF" +// inventory pages + , "\x11\x01\x3B\x01\x27\x01\x1C\x01\x38\x01\x02\xFF\xFF" + , "\x11\x01\xBD\x01\x4A\x01\xBB\xFF\xFF" + , "\x11\x01\x1A\x01\x3C\x01\x24\x01\x34\xFF\xFF" +// save game page + , "\x11\x01\x5F\x01\x03\x01\x54\x01\x04\x01\x19\x01\x2D\x01\x14\x01\x42\xFF\xFF" + , "\x11\x01\xC7\x02\x81\x02\x7E\x02\x7F\xFF\xFF" +// inventory option + , "\x11\x01\x6E\x01\x03\x01\x34\xFF\xFF" + , "\x11\x01\x58\x01\x2F\x01\x27\xFF\xFF" + , "\x11\x01\x5B\x01\x02\x01\x59\x01\x17\xFF\xFF" + , "\x11\x01\x17\x01\x24\x01\x03\x01\x13\x01\x17\xFF\xFF" + , "\x11\x01\x18\x01\x18\x01\x01\x01\x4C\xFF\xFF" + , "\x11\x02\x84\x02\x85\x01\x9B\x01\x7A\xFF\xFF" + , "\x11\x01\xB0\x01\x60\x01\x02\x01\x31\xFF\xFF" + , "\x11\x01\x5B\x01\x02\x01\x20\x01\x55\x01\x03\x01\x18\xFF\xFF" + , "\x11\x01\x83\x01\x08\x01\x3A\xFF\xFF" +// passport menu + , "\x11\x01\x55\x01\x03\x01\x31\xFF\xFF" + , "\x11\x01\xAE\x01\x04\x01\x0C\x01\x6E\x01\x03\x01\x34\xFF\xFF" + , "\x11\x01\x2E\x01\x27\x01\x41\x01\x3C\xFF\xFF" + , "\x11\x01\x6C\x01\xAB\x01\x4E\x01\x03\x01\x0D\x01\xB6\x01\x08\xFF\xFF" + , "\x11\x01\x6E\x01\x03\x01\x34\x01\x07\x02\x82\x01\x22\x01\x08\xFF\xFF" + , "\x11\x01\x41\x01\x71\x01\x23\x01\x07\x02\x83\x02\x78\x01\x2D\x01\x08\xFF\xFF" +// detail options + , "\x11\x01\x5A\x01\x29\x01\x24\x01\x03\x01\x23\x02\x79\x02\x76\xFF\xFF" + , "\x11\x01\x47\x01\x29\x01\x23\x01\x13\x01\x2E\x01\x02\x01\x3F\xFF\xFF" + , "\x11\x01\x18\x01\x3C\x01\x24\x01\x29\x01\x02\x01\x3F\x01\x21\x01\x3B\x01\x2E\x01\x24\x01\x29\xFF\xFF" + , "\x11\x01\x1C\x01\x39\x01\x31\x01\x60\x01\x21\x01\x3B\x01\x2E\x01\x24\x01\x29\xFF\xFF" + , "\x11\x01\x69\x01\x21\x01\x3B\x01\x2E\x01\x24\x01\x29\xFF\xFF" + , "VSync" + , "\x11\x01\x59\x01\x18\x01\x41\x01\x23\x01\x6A\x01\x4E\x01\x03\xFF\xFF" + , "2D\x11\x01\x1A\x01\x3C\x01\x24\x01\x34\xFF\xFF" + , "Resolution" + , STR_SCALE +// sound options + , "\x11\x02\x77\x02\x7C\x01\x9B\x01\x7A\xFF\xFF" + , "\x11\x01\x2E\x01\x48\x01\x03\x01\x54\x01\x41\x01\x03\x01\x1C\x01\x38\x01\x02\xFF\xFF" + , "\x11\x02\x7D\x02\x7A\xFF\xFF" + , "\x11\x01\xD2\x01\xD6\xFF\xFF" +// controls options + , "\x11\x01\x5B\x01\x02\x01\x20\x01\x55\x01\x03\x01\x18\x01\x9B\x01\x7A\xFF\xFF" + , "\x11\x01\x25\x01\x03\x01\x1D\x01\x03\x01\x31\xFF\xFF" + , "\x11\x01\x6E\x01\x03\x01\x34\x01\x59\x01\x2F\x01\x31\xFF\xFF" + , "\x11\x01\x48\x01\x3C\x01\x54\x01\x41\x01\x03\x01\x1C\x01\x38\x01\x02\xFF\xFF" + , "\x11\x01\x2E\x01\x13\x01\x03\x01\x6E\x01\x24\x01\x29\x01\x02\x01\x3F\xFF\xFF" + , "\x11\x01\x58\x01\x23\x01\x63\x01\x67\x01\x3C\x01\x52\x01\x02\x01\x3F\xFF\xFF" + // controls + , "\x11\x01\xCD\xFF\xFF", "\x11\x01\x75\xFF\xFF", "\x11\x01\x35\xFF\xFF", "\x11\x01\x6B\xFF\xFF", "\x11\x01\x26\x01\x39\x01\x02\x01\x27\xFF\xFF", "\x11\x01\x51\x01\x30\xFF\xFF", "\x11\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\xFF\xFF", "\x11\x01\xDA\x01\x07\x02\x7B\x01\x30\xFF\xFF", "\x11\x01\x70\x01\x08\xFF\xFF", "\x11\x01\x04\x01\x99\x01\x1B\x01\xD7\xFF\xFF", "\x11\x01\x62\x01\x2F\x01\x1C\x01\x4E\xFF\xFF", "\x11\x02\x50\x01\x1B\x01\x08\xFF\xFF", "\x11\x01\xBD\x01\x4A\x01\xBB\x01\x07\x01\x70\x01\x08\xFF\xFF", "\x11\x01\x17\x01\x13\x01\x03\x01\x20\xFF\xFF" + , STR_KEYS +// inventory items + , "\x11\x02\x51\x01\x83\xFF\xFF" + , "\x11\x02\x4E\x01\x68\xFF\xFF" + , "\x11\x01\x57\x01\x17\x01\x20\x01\x23\xFF\xFF" + , "\x11\x01\x1C\x01\x38\x01\x2F\x01\x20\x01\x76\x01\x02\xFF\xFF" + , "\x11\x01\x58\x01\x3F\x01\x56\x01\x34\xFF\xFF" + , "\x11\x01\x60\x01\x03\x01\x26\x01\x03\xFF\xFF" + , "\x11\x01\x57\x01\x17\x01\x20\x01\x23\x01\x68\xFF\xFF" + , "\x11\x01\x1C\x01\x38\x01\x2F\x01\x20\x01\x76\x01\x02\x01\x68\xFF\xFF" + , "\x11\x01\x58\x01\x3F\x01\x56\x01\x34\x01\x68\xFF\xFF" + , "\x11\x01\x60\x01\x03\x01\x26\x01\x03\x01\x68\xFF\xFF" + , "\x11\x01\x6C\x01\x5A\x01\x29\x01\x59\x01\x2F\x01\x21\x01\xE5\x02\x4F\x01\xD9\xFF\xFF" + , "\x11\x01\x6C\x01\x5A\x01\x29\x01\x59\x01\x2F\x01\x21\x01\xE5\x01\x50\x01\xD9\xFF\xFF" + , "\x11\x02\x54\x01\x01\x01\xCF\x01\xDF\xFF\xFF" + , "\x11\x01\x1C\x01\x3B\x01\x02\xFF\xFF" +// keys + , "\x11\x01\x44\xFF\xFF" + , "\x11\x02\x55\x01\x01\x01\x44\xFF\xFF" + , "\x11\x02\x52\x01\x8C\x01\x0E\x01\x44\xFF\xFF" + , "\x11\x01\xE1\x01\x01\x01\x44\xFF\xFF" + , "\x11\x01\xB0\x01\x47\x02\x53\x01\x3C\x01\x1A\x01\x25\x01\x03\xFF\xFF" + , "\x11\x01\xEB\x01\x27\x01\x20\x01\xE7\x01\x03\x01\xDD\x01\x17\x01\x01\x01\x44\xFF\xFF" + , "\x11\x01\x1A\x01\x20\x01\x18\x01\x03\x01\x17\x01\x01\x01\x44\xFF\xFF" + , "\x11\x01\x62\x01\xD1\x01\x21\x01\x41\x01\x17\x01\x01\x01\x44\xFF\xFF" + , "\x11\x01\x20\x01\x03\x01\x23\x01\x01\x01\x44\xFF\xFF" + , "\x11\x02\x48\x02\x49\x01\x09\x01\x44\xFF\xFF" +// puzzles + , "\x11\x01\x59\x01\x88\x01\x23\xFF\xFF" + , "\x11\x01\x89\x01\x03\x01\x23\x01\x31\x01\x1A\x01\x3C\x01\x31\x01\x23\xFF\xFF" + , "\x11\x01\xE1\x01\x01\x01\xCF\x01\xDF\xFF\xFF" + , "\x11\x02\x46\x02\x47\xFF\xFF" + , "\x11\x02\x4C\x01\x4E\x01\x03\x01\x88\xFF\xFF" + , "\x11\x01\x1A\x01\x02\x01\x21\xFF\xFF" + , "\x11\x01\x77\x01\x23\x01\x17\x01\x01\x01\xE3\xFF\xFF" + , "\x11\x01\x1A\x01\xDD\x01\x6A\x01\x17\x01\x01\x02\x4D\x02\x4A\xFF\xFF" + , "\x11\x01\x17\x01\x49\x01\x18\x01\x71\xFF\xFF" + , "\x11\x01\x57\x01\x18\x01\x52\x01\x2F\x01\x31\x01\x01\x01\x44\xFF\xFF" +// TR1 subtitles + /* CAFE */ , + "" + /* LIFT */ , + "" + /* CANYON */ , + "" + /* PRISON */ , + "" + /* 22 */ , + "[04000]\x11\x01\x19\x01\x0E\x01\xCB\x01\x0E\x01\x01\x01\x42\xFF\xFF" + "[05500]\x11\x01\x36\x01\x1E\x01\x28\x01\x53\x01\x3E\x01\x09\x01\x0E\x01\x01\x02\x4B\x02\x60\x01\x07\x02\x61\x01\x0C\x01\x0D\x01\x37\x01\x05\xFF\xFF" + "[09000]\x11\x01\xCE\x01\xCC\x01\x01\x01\x84\x01\x85\x01\x15\x01\x64\x01\x32\x02\x5E\x01\x16\x01\x0B\x01\x04\x01\x19\x01\x0C\x01\x0A\x01\xEA\x02\x5F\x02\x64\x02\x65\x01\x15\x02\x62\x01\x30\x02\x63\x02\x58\x01\x04\x01\x09\x01\x30\x01\x09\x01\x16\x01\x0B\x01\x0C\x01\x08\x01\x05\xFF\xFF" + "[14000]\x11\x01\x04\x01\x14\x01\x04\x01\x0A\x02\x59\x02\x56\x01\x0F\x01\x46\x01\x09\x01\x08\x01\xAE\x02\x57\x01\x07\x01\xE4\x01\x0D\x01\xAC\x01\x3D\x02\x5C\x01\x4D\x01\x82\x01\x0A\x01\x6D\x01\x80\x01\x15\x01\x80\x02\x5D\x01\x32\x01\x3A\x01\x2C\x01\x0A\xFF\xFF" + "[18000]\x11\x02\x5A\x01\xB2\x01\xB3\x01\x0D\x01\x15\x02\x5B\x01\xAF\x01\x07\x01\x28\x01\x3D\x01\x91\x01\x30\x01\x0A\xFF\xFF" + "[20500]\x11\x01\x28\x01\x3D\x01\x84\x01\x85\x01\x3A\x01\x4D\x01\x08\x01\x05\xFF\xFF" + "[22500]\x11\x01\x09\x01\x33\x01\x40\x01\x14\x01\x31\x01\x03\x01\x57\x01\x02\x01\x3F\x01\x04\x01\x0E\x01\x84\x01\x85\x02\xB0\x01\x16\x01\x0B\x01\x12\x01\x0F\x01\x37\xFF\xFF" + "[24500]\x11\x01\x91\x01\x0C\x02\xB1\x02\xAE\x01\x1B\x02\xAF\x01\x9C\x01\x09\x01\x01\x01\x28\x01\x05\x01\x40\x01\x14\x01\x11\x01\x0A\x01\x50\x01\x86\x01\x07\x02\xB4\x02\xB5\x01\x3A\x01\x4D\x01\x0A\xFF\xFF" + "[29500]\x11\x02\xB2\x01\x83\x01\x01\x02\xB3\x02\xA8\x01\x0D\x02\xA9\x01\x3D\x02\xA6\x01\x16\x01\x0B\x01\x0C\x01\x0E\x01\xA5\x01\x0E\x01\x4A\x01\x0D\x01\x0A\xFF\xFF" + "[33000]\x11\x01\xA3\x01\x46\x02\xA7\x01\x97\x01\xB3\x01\x09\x01\xCE\x02\xAC\x02\xAD\x01\xC3\x01\x07\x01\x91\x01\x0C\x01\x0E\x01\x33\x01\x40\x01\x05\xFF\xFF" + "[37000]\x11\x01\x6F\x01\x01\x01\x27\x01\x18\x01\x02\x01\x1B\x02\xAA\x01\x07\x02\xAB\x01\x1E\x01\x01\x01\x28\x01\x05\xFF\xFF" + "[39000]\x11\x01\x36\x01\x1E\x01\x35\x01\x95\x01\x30\x01\x0C\x01\x30\x01\x14\x01\x04\x01\x11\x01\x05\x01\x05\x01\x05\xFF\xFF" + "[40000]\x11\x02\xC0\x01\x85\x02\xC1\x02\xBE\x01\x19\x01\x1F\xFF\xFF""15\x11\x01\xC6\x01\x7B\x01\x05\xFF\xFF" + "[43000]\x11\x01\x4F\x02\xBF\x01\x2D\x01\x08\x01\x0D\x01\x15\x01\xBF\x01\x2D\x01\xB7\x01\x08\x01\x22\x01\x37\x01\x05\xFF\xFF" + "[45000]\x11\x01\x95\x02\xC4\x01\x15\x01\x0A\x01\xB4\x01\x01\x01\x0F\x01\x12\x01\x0D\x02\xC5\x01\x2D\x01\x22\x01\x05\xFF\xFF" + "[47000]\x11\x01\x62\x01\x6C\x01\x43\x01\x1E\x01\x22\x02\xC2\x01\x53\x01\x43\x01\x43\x01\x43\xFF\xFF" + "[50000]10\x11\x01\xC6\x01\x7B\xFF\xFF" + "[54000]5\x11\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[55500]4\x11\x01\x06\x01\x06\x01\x06\xFF\xFF""3\x11\x01\x06\x01\x06\x01\x06\xFF\xFF""2\x11\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[60000]1\x11\x01\x06\x01\x06\x01\x06\xFF\xFF" + /* 23 */ , + "[00001]\x11\x02\xC3\x01\xBE\x01\x15\x01\x97\x01\xBC\x01\x0D\x01\x3E\x01\x0E\x01\x04\x01\x07\x02\xB8\x01\x11\x01\x4D\x01\x0B\x01\x04\x01\x19\x01\x16\x01\x0E\x01\x28\x01\x1E\x01\x37\x01\x05\xFF\xFF" + "[04000]\x11\x02\xB9\x02\xB6\x01\x0C\x01\x0E\x01\x14\x01\x09\x01\x42\xFF\xFF" + "[06000]\x11\x01\x0B\x01\x73\x02\xB7\x01\x01\x01\x6B\x01\x95\x01\x09\x01\xDA\x01\x01\x01\x5E\x01\x14\x01\xC5\x01\x1F\x01\xC0\x01\x14\x01\x16\x01\x0E\x01\x9F\x01\x05\xFF\xFF" + "[09000]\x11\x01\x36\x01\x2C\x01\x15\x01\x5D\x01\x1E\x01\x46\xFF\xFF" + "[10000]\x11\x01\x5E\x01\x73\x01\x4B\x01\x3A\x01\x33\x01\x0A\x01\x3E\x01\x01\x01\x21\x02\xBC\x02\xBD\x01\xAF\x01\x04\x01\x0C\x01\x1C\x01\x3B\x01\x02\x01\x01\x01\x14\x01\x45\x01\x11\x01\x1B\x01\x36\x01\x33\x01\x09\x01\x0D\x02\xBA\x01\x04\x01\x0C\x01\x01\x01\x14\x01\x0C\x01\x42\xFF\xFF" + "[13500]\x11\x01\x09\x01\x11\x01\x36\x01\x2C\x01\x07\x01\x1A\x01\x02\x01\x13\x01\x01\x01\x78\x01\x79\x01\x01\x02\xBB\x01\x0D\x01\xB8\x01\x4A\x02\x90\x01\x33\x01\x1F\x01\x90\x01\x16\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[17000]\x11\x01\x4A\x01\x5C\x01\x16\x01\x0F\x01\xC9\x01\x16\x01\x0B\x01\x06\x01\x06\x01\x06\x01\x3E\x01\x09\x01\x0E\x01\x3E\x01\x01\x01\x5E\x01\xC2\x01\x3D\x01\x01\x02\x91\x01\x04\x01\x0B\x01\x08\x01\x01\x01\x42\xFF\xFF" + "[20000]\x11\x01\xBC\x01\x0E\x01\x3D\x01\x7B\x01\x40\x01\x28\x01\x06\x01\x06\x01\x06\x01\xE3\x01\x01\x01\x78\x01\x79\x01\x01\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[21500]\x11\x01\x3E\x01\x16\x01\x0A\x01\x4A\x01\x5C\x01\x16\x01\x0F\x01\xC9\x01\x16\x01\x0B\xFF\xFF"" - \x11\x01\x8F\x01\x73\x01\x33\x01\x09\x01\x3A\x01\x0C\x01\x05\xFF\xFF" + "[24000]\x11\x01\x12\x01\x01\x01\x1C\x01\x3B\x01\x02\x01\x0F\x01\x5E\x01\xC2\x01\x3D\x01\x01\x01\x14\x01\x45\x01\x11\x01\x15\x01\xB4\x01\x0D\x01\x5D\x01\x12\x01\x0D\x01\x3E\x01\x08\x01\x01\xFF\xFF" + "[26500]\x11\x01\x52\x01\x17\x01\x06\x01\x56\x01\x20\x01\x18\x01\x1B\x01\x57\x01\x67\x01\x03\x01\x23\x01\x06\x01\x31\x01\xE7\x02\x8E\x01\x02\x01\x16\x01\x0B\x01\xA4\x01\x79\x01\x07\x01\xA7\x01\x16\x01\x0B\x02\x8F\x01\x3A\x01\x4D\x01\x0B\x01\x0C\x01\x08\x01\x05\xFF\xFF" + "[29500]\x11\x01\x36\x01\x2C\x01\x15\x01\x5D\x01\x12\x01\x09\x01\x01\x01\x42\xFF\xFF" + "[30500]\x11\x01\x15\x01\x03\x01\x43\x01\x5E\x01\x73\x01\x4B\x01\x3A\x01\x33\x01\x16\x01\x0B\x01\xA4\x01\x79\x02\x94\x01\x0C\x01\x65\x01\x30\x01\x12\x01\x0F\x01\x15\x01\x1F\x01\x32\x01\x37\x01\x4B\x01\x28\x01\x05\xFF\xFF" + "[34000]\x11\x01\x5D\x01\x12\x01\x16\x01\x0B\x01\xA2\x01\x0C\x01\x0B\x01\x08\x01\x37\x01\x33\x01\x43\xFF\xFF" + "[37000]\x11\x01\x0C\x01\x90\x01\x53\x01\x3E\x01\x01\x01\x47\x01\x18\x01\x02\x01\x17\x02\x95\x02\x92\x01\x1B\x01\x5D\x01\x12\x01\x0C\x01\x16\x01\x0E\x01\x14\x01\x22\x01\x14\x01\x33\x01\x37\x01\x4B\x01\x33\x01\x40\x01\x28\x01\x05\xFF\xFF" + "[41500]\x11\x01\x52\x01\x17\x01\x06\x01\x56\x01\x20\x01\x18\x01\x0D\x01\xA2\x01\x30\x01\x04\x01\x14\x01\x37\x01\x4B\x01\x81\x01\x99\x01\x37\x01\x03\x01\x14\x01\x42\xFF\xFF" + "[46000]" + "[50500]\x11\x01\x3E\x01\x3D\x01\x1B\x01\x0F\x01\x1E\x01\x05\x01\xA1\x01\x33\x01\x01\x01\x5E\x02\x93\x01\x05\xFF\xFF" + /* 24 */ , "" + /* 25 */ , + "[03000]\x11\x01\x12\x01\x12\x01\x0D\x02\x88\x01\x08\x01\x15\x01\x8E\x01\x87\x01\x24\x01\x29\x01\x77\x01\x49\x01\x02\xFF\xFF" + "[06000]\x11\x01\x06\x01\x06\x01\x06\x01\x50\x01\x86\x01\x1A\x01\x20\x01\x18\x01\x02\x01\x24\x01\x29\x01\x17\x01\x07\x02\x89\x02\x86\x01\x04\x01\x0E\x02\x87\x01\x6D\x01\x01\x02\x8C\x01\x83\x02\x8D\x01\x50\x01\x09\x02\x8A\x02\x8B\x01\xA5\x01\x01\x01\x7D\x01\x6D\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[11000]\x11\x01\x8E\x01\x87\x01\x15\x01\x50\x01\x86\x01\x01\x02\xA0\x01\x0C\x01\x0D\x02\xA1\x01\xD7\x01\x14\x01\x01\x01\x28\x01\x1E\x01\x0D\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[14000]\x11\x01\x06\x01\x06\x01\x06\x01\x12\x01\x01\x02\x9E\x01\x2C\x01\xB2\x01\x0B\x01\x0C\x01\x0E\x02\x9F\x01\x0D\x02\xA4\x02\xA5\x01\x0F\x01\xD8\x01\x07\x01\xD5\x01\x11\x01\x36\x01\x1E\x01\x0F\x01\x04\x01\x0E\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[18000]\x11\x02\xA2\x02\xA3\x01\x01\x01\x8B\x01\x3A\x01\xD3\x02\x98\x01\x16\x01\x0E\x01\x8E\x01\x87\x01\x15\x01\x36\x01\x01\x02\x99\x01\xD8\x01\x01\x02\x96\x02\x97\x01\x07\x01\xDB\x01\xE4\x02\x9C\x02\x9D\x01\x4B\x01\x08\x01\x12\x01\x0F\x01\x15\x01\x09\x01\x14\x01\x16\x01\x0E\x01\x06\x01\x06\x01\x06\xFF\xFF" + "[25000]\x11\x02\x9A\x01\x50\x01\x09\x01\x08\x01\x24\x01\x29\x01\x77\x01\x49\x01\x02\x02\x9B\x01\x0A\x01\x6F\x01\x0E\x01\x4A\x01\x0D\x01\x8F\x02\x45\x01\xF2\x01\x07\x01\x05\xFF\xFF" + /* 26 */ , "\x11\x01\x6F\x01\x01\x01\x4C\x01\x0D\x01\x28\x01\x1E\x01\x12\x01\x36\x01\x05\xFF\xFF""@\x11\x01\x4C\x01\x01\x01\x4F\x01\x07\x01\xE6\x01\xEC\x01\x2D\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 27 */ , "\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x10\x01\x04\x01\x0B\x01\x0A\x01\x52\x01\x4E\x01\x03\x01\x26\x01\x2F\x01\x21\x01\x23\x01\x03\x01\x34\x01\x0D\x01\xF4\x01\x16\x01\x0B\x01\x05\xFF\xFF" + /* 28 */ , "OK\x11\x01\x05\x01\x26\x01\x39\x01\x02\x01\x27\x01\x01\x01\xEF\x01\xEE\x01\x04\x01\x19\x01\x04\x01\x5C\x01\x1E\x01\x05\xFF\xFF""@\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x05\xFF\xFF" + /* 29 */ , "\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x14\x01\x11\x01\x2D\x01\x66\x01\x0D\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\x10\x01\x04\x01\x0E\x01\x2A\x01\x2B\x01\x0D\x01\x26\x01\x39\x01\x02\x01\x27\x01\x2D\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 30 */ , "\x11\x01\x1E\x01\xD4\x01\xD4\x01\x0A\x01\x12\x01\x12\x01\x15\x02\x03\x02\x09\x01\x80\x01\x28\xFF\xFF""@\x11\x02\x08\x01\x11\x01\x14\x01\x16\x01\x0B\x01\x0C\x01\x0B\x01\x8F\x01\x73\x01\x33\x01\x09\x01\x3A\x01\x0C\x01\x37\x01\x05\xFF\xFF""@\x11\x01\xE8\x01\xAC\x01\xF9\x01\x1B\x01\x19\x01\x40\x01\xCB\x01\x09\x01\x0C\x01\x01\x01\x28\x01\x05\xFF\xFF" + /* 31 */ , "\x11\x01\x7E\x01\x15\x01\x5B\x01\x02\x01\x24\x01\x56\x01\x0D\x01\x28\x01\x81\x01\x74\x01\x16\x01\x0B\x01\xFE\x01\x19\x01\x04\x01\x5C\x01\x1E\x01\x05\xFF\xFF""@\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x05\xFF\xFF" + /* 32 */ , "\x11\x01\x12\x01\x01\x01\xFD\x01\xFC\x01\x15\x01\x6F\x01\x01\x01\x26\x01\x34\x01\x28\x01\x05\xFF\xFF""@\x11\x01\x5D\x01\x1E\x01\x42\xFF\xFF" + /* 33 */ , "\x11\x01\x51\x01\x30\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\xAD\x01\xAA\x01\x01\x01\x0F\x01\x12\x01\x61\x01\x19\x01\x1F\x01\x51\x01\x0C\x01\x0B\x01\x05\xFF\xFF" + /* 34 */ , "\x11\x01\x51\x01\x30\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0C\x01\x08\x01\x0F\x01\x0A\x01\x7F\x01\x14\x01\x11\x01\xA0\x01\x4A\x01\x09\x01\x0C\x01\x22\x01\x28\x01\x05\xFF\xFF" + /* 35 */ , "\x11\x02\x07\x01\x3D\x01\x07\x01\x70\x01\x9E\x01\x04\x01\x0E\x01\x0C\x01\x0F\x01\x32\x01\x15\x01\x70\x01\x08\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x0A\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x05\xFF\xFF""@\x11\x01\x70\x01\x08\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x0A\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x05\xFF\xFF" + /* 36 */ , "\x11\x01\x19\x01\xD3\x01\x15\x01\x0A\x01\xAD\x01\xAA\x01\x01\x01\x0F\x01\x12\x01\x61\x01\x19\x01\x1F\x01\x51\x01\x0C\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x0A\x01\x2D\x01\x66\x01\x0D\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\xA6\x01\x4F\x01\x0D\x01\x0C\x01\x08\x01\x0F\x01\x32\x01\x0D\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x16\x02\x0A\x01\x09\x01\x04\x01\x0D\x01\x2D\x01\x08\x01\x0F\x01\x0A\xFF\xFF""@\x11\x01\x47\x01\x63\x01\x0D\x01\x65\x01\x14\x01\x19\x01\x2C\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 37 */ , "\x11\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0E\x01\x19\x01\x19\x01\x0A\x01\x35\x01\x07\x01\x10\x01\x2D\x01\x0F\x01\x74\x01\x2C\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 38 */ , "\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x04\x01\x09\x01\x1B\x01\x11\x01\x0A\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x2D\x01\x0F\x01\x92\x01\x3D\x01\x09\x01\x1B\x01\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1B\x01\x1F\x01\x32\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 39 */ , "\x11\x01\xC4\x01\x32\x01\x1B\x02\x05\x01\x19\x01\x08\x01\x19\x01\x1F\x01\x51\x01\x0C\x01\x0B\x01\x7B\x01\x84\x01\x04\x01\x0A\x01\x51\x01\x30\x01\x1D\x01\x13\x01\x02\x01\x07\x01\xF5\x01\x04\x01\x0B\x01\x14\x01\x11\xFF\xFF""@\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x6B\x01\x07\xFF\xFF""1\x11\x01\xF0\x01\x10\x01\x04\x01\x0B\x01\x0A\x01\x12\x01\x2C\x01\x1F\x01\xC0\x01\x92\x01\x1B\x01\x1F\x01\x32\x01\x08\x01\x28\x01\x1E\x01\x0D\x01\x09\x01\x08\x01\x22\x01\x05\xFF\xFF""@\x11\x01\x35\x01\x07\x01\x10\x01\x04\x01\x0A\x01\x2D\x01\x66\x01\x0D\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\xA9\x01\x45\x01\x08\x01\x05\xFF\xFF""@\x11\x01\x36\x01\x1E\x01\x2D\x01\x08\x01\x0F\x01\xA8\x01\x2E\x01\xA8\x01\x2E\x01\x01\x01\x0F\x01\x12\x01\x61\x01\x1F\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1F\x01\x32\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 40 */ , "\x11\x01\x36\x01\x04\x01\x0B\x01\x7E\x01\x15\x01\xA3\x01\x46\x02\x30\x01\x9C\x01\x09\x01\x12\x01\x0F\x01\x05\xFF\xFF""@\x11\x01\x92\x01\x3D\x01\x09\x01\x1B\x01\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x07\x01\x04\x01\x0B\x01\xA6\x01\x4F\x01\x0D\x01\x0C\x01\x08\x01\x0F\x01\x32\x01\x0A\xFF\xFF""@\x11\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x40\x01\x45\x01\x07\x01\x10\x01\x04\x01\xA9\x01\x45\x01\x08\x01\x0F\x01\x7F\x01\x01\x01\x47\x01\x63\x01\x0D\x01\x65\x01\x14\x01\x19\x01\x2C\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 41 */ , "\x11\x01\x0C\x01\x0C\x01\x22\x01\x53\x01\x7C\xFF\xFF""OK\x11\x01\x05\xFF\xFF" + /* 42 */ , "\x11\x01\x28\x01\x81\x01\x74\x01\x08\x01\x0D\x01\x15\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0E\x01\x19\x01\x19\x01\x0A\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x05\xFF\xFF" + /* 43 */ , "\x11\x01\x35\x01\x01\x01\x17\x01\x8A\x01\x03\x01\x17\x01\x1B\x02\x33\x01\x30\x01\x0B\x01\x0A\x01\x12\x01\x12\x01\x14\x01\x11\x01\x15\x01\x74\x01\x2C\x01\x09\x01\x0C\x01\x22\x01\x05\xFF\xFF""@\x11\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0E\x01\x19\x01\x19\x01\x0A\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x75\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\x75\x02\x36\x01\x19\x01\x1F\x01\x64\x01\x16\x01\x0E\x01\x11\x01\x0A\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x07\x01\x10\x01\x04\x01\x0E\x01\x19\x01\x19\x01\x0A\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x4D\x01\x82\x01\x74\x01\x2C\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 44 */ , "\x11\x01\x0C\x01\x0C\x01\x22\x01\x53\x01\x7C\x01\x46\x01\x04\x01\x78\x01\x76\x01\x07\x01\x04\x01\x0E\x01\x30\x01\x09\x01\x14\x01\x16\x01\x0E\x01\x11\x01\x0A\x01\xB9\x01\xB5\x01\x01\x01\x4F\x01\x1F\x01\x15\x02\x35\x02\x34\x02\x2B\x01\x30\x01\x64\x01\xC4\x01\x2D\x01\x08\x01\x12\x01\x0F\x01\x37\x01\x05\xFF\xFF" + /* 45 */ , "\x11\x01\xEA\x01\xCA\x01\x01\x01\xDB\x01\x61\x01\x0D\x01\x7F\x01\x1B\x01\x3E\x01\x08\x01\x0F\x01\x32\x01\x0A\xFF\xFF""@\x11\x01\x7D\x01\xBE\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x6B\x01\x07\x01\x10\x01\x04\x01\x0A\x01\x2D\x01\x66\x01\x0D\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x40\x01\x45\x01\x07\x01\x10\x01\x04\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\x7F\x01\x01\x01\x47\x01\x63\x01\x0D\x01\xB8\x01\x11\x01\x6B\x01\x1B\x01\x08\x01\x12\x01\x0F\x01\x46\x01\x1F\x01\x32\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 46 */ , "\x11\x01\x81\x01\x99\x01\x3E\x01\x0A\x01\x7E\x01\x0D\x01\x64\x01\x32\x01\x19\x01\x04\x01\x5C\x01\x1E\x01\x05\xFF\xFF" + /* 47 */ , "\x11\x01\x7E\x01\x15\x01\x8D\x01\xB7\x01\x01\x01\xEF\x01\xEE\x01\x37\x01\x05\xFF\xFF" + /* 48 */ , "\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x0F\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x07\x01\xA7\x01\x16\x01\x0B\x01\x0A\xFF\xFF""@\x11\x01\x8D\x01\xC5\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 49 */ , "\x11\x02\x29\x01\x04\x01\x14\x01\x16\x01\x0E\x01\x53\xFF\xFF""@\x11\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x0A\x01\xCD\x01\x0F\x01\x75\x01\x1D\x01\x13\x01\x02\x01\x1F\x01\x69\x01\x35\x01\x8D\x01\x66\x01\x12\x01\x0F\x01\x1B\x01\x1F\x01\x32\x01\x08\x01\x22\x01\x05\xFF\xFF""@\x11\x01\x26\x01\x39\x01\x02\x01\x27\x01\x1D\x01\x13\x01\x02\x01\x1F\x01\x19\x01\x0E\x01\xC1\x01\x2C\x01\x08\x01\x01\x01\x05\xFF\xFF""@\x11\x01\x27\x01\x03\x01\x23\x01\x01\x01\x47\x01\x63\x01\x0D\x01\x64\x01\x16\x01\x0B\x01\x0A\x01\x1A\x01\x21\x01\x1C\x01\x38\x01\x02\x01\x1D\x01\x13\x01\x02\x01\x0F\x01\x2A\x01\x2B\x01\x25\x01\x03\x01\x01\x01\x35\x01\x07\x01\x10\x01\x2D\x01\x0F\x01\x69\x01\x14\x01\x11\x01\x35\x01\x1B\x01\x2C\x01\x08\x01\x22\x01\x05\xFF\xFF" + /* 50 */ , "\x11\x01\x36\x01\x61\x01\x36\x01\x61\x02\x2C\x02\x2E\x01\x0D\x01\x64\x01\x32\x01\x19\x01\x04\x01\x5C\x01\x1E\x01\x14\x01\x42\xFF\xFF" + /* 51 */ , "\x11\x01\x12\x01\x01\x01\x6C\x01\x17\x02\x2D\x01\x1B\x01\x06\x01\x06\x01\x06\x01\x43\xFF\xFF" + /* 52 */ , "\x11\x01\x12\x01\x0C\x01\x65\x01\x11\x01\x7D\x01\x6D\x01\x7D\x01\x6D\x01\xE6\x01\xEC\x01\x04\x01\x37\x01\x4B\x01\x0F\x01\x09\x01\x05\xFF\xFF" + /* 53 */ , "\x11\x01\x36\x01\x0C\x01\x65\x01\x9E\x01\x4D\x01\x0F\x01\x15\x01\xD2\x01\x22\x01\x37\x01\x4B\x01\x43\xFF\xFF""@\x11\x01\x09\x01\x9F\x01\x09\x01\x11\x01\x0A\x01\x12\x01\x12\x01\x1F\x02\x40\x01\x33\x01\x1F\x01\x46\x01\x11\x01\x1E\x01\x14\x01\x11\x01\x3A\x01\x3E\x01\x05\xFF\xFF" + /* 54 */ , "\x11\x01\x6F\x01\x1B\x01\x36\x01\x33\x01\x09\x01\x0D\x02\x3F\x02\x3E\x01\x0D\x01\x90\x01\x11\x01\x2C\x01\x08\x01\x0F\x02\x41\x01\x1E\x01\x42\xFF\xFF" + /* 55 */ , "\x11\x01\x6A\x01\x02\x01\x89\x01\x01\x02\x44\x02\x43\x01\x07\x02\x42\x01\x45\x01\x9D\x01\x08\x01\x0D\x01\x15\x02\x37\x01\x04\x01\xBF\x01\x14\x01\x16\x01\x0E\x01\x28\x01\x1E\x01\x40\x01\x09\x01\x7C\x01\x58\x01\x31\x01\xD1\x02\x3A\x02\x3D\x01\x23\x01\x05\xFF\xFF""@\x11\x01\x12\x01\x1E\x01\x0C\x01\x1E\x01\x46\x01\x01\x01\x15\x02\x3C\x01\x4A\x01\x9D\x01\x11\x01\x09\x01\x45\x01\x2C\x01\x82\x01\x09\x01\x11\x01\x09\x01\x0C\x01\x14\x01\x11\x01\x37\x01\x05\xFF\xFF""@\x11\x01\x1E\x01\x53\x01\x7C\x01\xD5\x01\x0D\x01\x8B\x02\x3B\x01\x40\x01\x05\x02\x28\x01\x0F\x01\x12\x01\x1E\x01\x04\x01\x0B\x01\xC3\x01\x22\x01\x09\x01\x45\x01\x2C\x01\x82\x01\x09\x01\x11\x01\x09\x01\x0C\x01\x09\x01\x33\x01\x0B\x01\x05\xFF\xFF""@\x11\x01\x1F\x01\x46\x01\x0A\x01\x12\x01\x2C\x01\x1B\x01\xE8\x01\xCC\x01\x09\x01\x01\x01\x3A\x01\x05\xFF\xFF" + /* 56 */ , "" +// TR1 levels + , "\x11\x01\x18\x01\x18\x01\x01\x01\x4C\xFF\xFF" + , "\x11\x02\x15\x02\x13\xFF\xFF" + , "\x11\x02\x19\x02\x18\x01\xDE\x01\xE0\x01\x6A\x01\x23\x01\x49\x01\x48\x01\x02\x01\x48\xFF\xFF" + , "\x11\x01\x55\x01\x17\x01\x20\x01\x06\x01\x48\x01\x41\x01\x03\xFF\xFF" + , "\x11\x01\x21\x01\x1A\x01\x55\x01\x8A\x01\x2F\x01\x21\x01\xED\x01\x94\xFF\xFF" + , "\x11\x01\x93\x01\x47\x01\x18\x01\x02\x01\x1C\x01\x17\x01\x93\x02\x0D\xFF\xFF" + , "\x11\x01\x5B\x01\x55\x01\x1C\x01\x1A\x01\x34\xFF\xFF" + , "\x11\x01\x52\x01\x62\x01\x17\x01\x01\x02\x0C\x02\x0F\xFF\xFF" + , "\x11\x02\x11\x01\x69\x02\x10\xFF\xFF" + , "\x11\x01\x24\x01\x29\x01\x77\x01\x49\x01\x02\x01\xED\x01\x94\xFF\xFF" + , "\x11\x01\x49\x01\x03\x01\x34\x01\x03\x01\x02\x01\x01\x01\xDE\x01\xE0\x01\xB9\x01\xB5\xFF\xFF" + , "\x11\x01\x49\x01\x03\x01\x34\x01\x03\x01\x02\x01\x01\x01\x3B\x01\x71\x01\x2E\x01\x17\x01\x21\xFF\xFF" + , "\x11\x01\x1C\x01\x3B\x01\x02\x01\x01\x01\x93\x02\x23\xFF\xFF" + , "\x11\x01\x56\x01\x20\x01\x18\x01\x01\x02\x26\x02\x25\xFF\xFF" + , "\x11\x01\x1A\x01\x20\x01\x18\x01\x02\x01\x24\x01\x29\x01\x17\xFF\xFF" + , "\x11\x01\x3F\x01\x41\x01\x03\x01\x20\x01\x06\x01\x57\x01\x18\x01\x52\x01\x2F\x01\x31\xFF\xFF" + , "\x11\x01\x67\x01\x26\x01\x27\x01\x20\x02\x1C\x02\x1B\xFF\xFF" + , "\x11\x02\x1A\x01\x01\x01\x72\xFF\xFF" + , "\x11\x01\x1A\x01\x20\x01\x18\x01\x02\x01\x24\x01\x29\x01\x17\x02\x1D\x02\x20\x02\x1F\x01\x01\x02\x1E\x01\x98\xFF\xFF" + , "\x11\x01\xDC\x02\x27\xFF\xFF" +// TR2 levels + , "\x11\x01\x18\x01\x18\x01\x01\x01\x4C\xFF\xFF" + , "\x11\x02\x24\x02\x21\x01\x01\x02\x22\x01\x98\xFF\xFF" + , "\x11\x01\x71\x01\xAB\x01\x17\xFF\xFF" + , "\x11\x01\x48\x01\x23\x01\x20\x01\x03\x01\x2E\x01\x01\x02\x12\x01\x2C\x01\x4C\xFF\xFF" + , "\x11\x01\x3B\x01\x8A\x01\x18\x01\xD0\x01\x60\x01\x17\xFF\xFF" + , "\x11\x01\xE9\x01\x35\x02\x0E\x02\x17\xFF\xFF" + , "\x11\x01\xC1\x01\x69\x01\x9A\xFF\xFF" + , "\x11\x01\xE9\x01\xE2\xFF\xFF" + , "\x11\x01\x58\x01\x2E\x01\x1A\x02\x16\x01\x01\x01\x8B\x02\x14\xFF\xFF" + , "\x11\x02\x38\x01\xE2\xFF\xFF" + , "\x11\x01\x5A\x01\x2F\x01\x25\xFF\xFF" + , "\x11\x01\x63\x01\x71\x01\x2F\x01\x20\x01\x01\x02\x39\x02\x2F\xFF\xFF" + , "\x11\x01\x48\x01\x03\x01\x49\x01\x02\x01\x3F\x01\x72\x01\x96\xFF\xFF" + , "\x11\x01\x13\x01\x2E\x01\x3B\x01\x02\x01\x01\x01\x94\xFF\xFF" + , "\x11\x02\x2A\x01\x01\x01\x98\xFF\xFF" + , "\x11\x02\x31\x02\x32\x01\x01\x01\x72\xFF\xFF" + , "\x11\x01\xF1\x01\xF3\xFF\xFF" + , "\x11\x01\x31\x01\x18\x01\x89\x01\x02\x01\x01\x01\xDC\xFF\xFF" + , "\x11\x01\x18\x01\x18\x01\x01\x01\x4C\xFF\xFF" +// TR3 levels + , "\x11\x01\x18\x01\x18\x01\x01\x01\x4C\xFF\xFF" + , "\x11\x01\x26\x01\x39\x01\x02\x01\x3F\x01\x23\xFF\xFF" + , "\x11\x01\xBA\x01\x8C\x01\x0E\x01\x72\x01\x96\xFF\xFF" + , "\x11\x01\x76\x01\x02\x01\x26\x01\x17\x01\xC8\xFF\xFF" + , "\x11\x01\x49\x01\x2E\x01\x1A\x01\x78\x01\x03\x01\x54\xFF\xFF" + , "\x11\x01\x5B\x01\x03\x01\x17\x01\x20\x01\x6A\x01\x41\x01\x2F\x01\x26\xFF\xFF" + , "\x11\x02\x04\x01\xA0\x01\xC7\x01\x9A\xFF\xFF" + , "\x11\x01\x58\x01\x5A\x01\x4E\x01\x48\x01\x01\x02\x02\xFF\xFF" + , "\x11\x01\x57\x01\x4E\x01\x56\x01\x72\x01\x96\xFF\xFF" + , "\x11\x01\x24\x01\x34\x01\x88\x01\xC8\x01\x01\x01\xA1\x01\x0F\x01\x3D\xFF\xFF" + , "\x11\x01\x1A\x01\x02\x01\x62\x01\x03\x01\x3F\x01\x18\x01\x60\x01\x02\x01\x31\xFF\xFF" + , "\x11\x01\x23\x01\x2F\x01\x31\x01\x01\x02\x0B\xFF\xFF" + , "\x11\x01\x1C\x01\x24\x01\x29\xFF\xFF" + , "\x11\x01\xEB\x01\x48\x01\x62\x01\xFA\x01\xFB\xFF\xFF" + , "\x11\x01\xD0\x01\x3C\x01\x5F\x01\x25\x01\x4E\x01\x2E\x01\x24\x01\x29\x01\x67\x01\x2E\x01\x1A\xFF\xFF" + , "\x11\x01\x67\x01\x2E\x01\x1A\xFF\xFF""51" + , "\x11\x01\xFF\x02\x01\x01\x50\x01\x86\xFF\xFF" + , "RX-TECH\x11\x01\xF8\x01\xF7\x02\x06\x01\x9A\xFF\xFF" + , "\x11\x01\xBA\x01\x8C\x01\x0E\x01\x24\x01\x29\x01\xF6\x01\x17\xFF\xFF" + , "\x11\x01\x21\x01\x41\x01\x03\x01\x13\x01\x03\xFF\xFF" + , "\x11\x01\x5F\x01\x3C\x01\x02\x01\x20\x01\x5A\x01\x3C\xFF\xFF" +}; + +#endif diff --git a/src/lang/pl.h b/src/lang/pl.h new file mode 100644 index 00000000..f5fb7dd5 --- /dev/null +++ b/src/lang/pl.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_PL +#define H_LANG_PL + +// Thanks: Nickelony, Dustie + +const char *STR_PL[] = { "" +// help + , "Wczytywanie..." + , "Wci)snij H je*zeli potrzebujesz pomocy" + , helpText + , "%s@@@" + "ZAB)OJSTWA %d@@" + "ZNAJD)ZKI %d@@" + "SEKRETY %d z %d@@" + "CZAS %s" + , "Zapisywanie..." + , "Zapis uko)nczony!" + , "B}L|AD ZAPISU!" + , "TAK" + , "NIE" + , "Wy}l" + , "W}l" + , "Wy}l" + , "Side-By-Side" + , "Anaglif" + , "Podzielony ekran" + , "VR" + , "Niska" + , ")Srednia" + , "Wysoka" + , STR_LANGUAGES + , "Zastosuj" + , "Kontroler 1" + , "Kontroler 2" + , "Kontroler 3" + , "Kontroler 4" + , "Nie Gotowy" + , "Gracz 1" + , "Gracz 2" + , "Wci)snij dowolny przycisk" + , "%s - Wybierz" + , "%s - Wr)o)c" +// inventory pages + , "OPCJE" + , "EKWIPUNEK" + , "PRZEDMIOTY" +// save game page + , "Zapisa)c gr|e?" + , "Aktualna pozycja" +// inventory option + , "Gra" + , "Mapa" + , "Kompas" + , "Statystyki" + , "Posiad}lo)s)c Lary" + , "Poziom detali" + , "D)zwi|ek" + , "Sterowanie" + , "Gamma" +// passport menu + , "Wczytaj gr|e" + , "Nowa gra" + , "Powt)orz poziom" + , "Wyjd)z to menu g}l)ownego" + , "Wyjd)z z gry" + , "Wybierz poziom" +// detail options + , "Wybierz poziom detali" + , "Filtrowanie tekstur" + , "Jako)s)c )swiat}la" + , "Jako)s)c cieni" + , "Jako)s)c wody" + , "VSync" + , "Stereoskopia" + , "Proste przedmioty" + , "Resolution" + , STR_SCALE +// sound options + , "Ustaw g}lo)sno)s)c" + , "Pog}los" + , "Napisy" + , "J|ezyk" +// controls options + , "Ustaw sterowanie" + , "Klawiatura" + , "Kontroler" + , "Wibracje" + , "Auto. zmiana celu" + , "Wielo-celowanie" + // controls + , "Lewo", "Prawo", "Prz)od", "Ty}l", "Skok", "Ch)od", "Akcja", "Bro)n", "Rozgl|adanie si|e", "Kucanie", "Sprint", "Przewr)ot", "Ekwipunek", "Menu pauzy" + , STR_KEYS +// inventory items + , "Nieznany" + , "Materia}l wybuchowy" + , "Pistolety" + , "Strzelba" + , "Pistolety Magnum" + , "Pistolety Uzi" + , "Amunicja do pistolet)ow" + , "Naboje do strzelby" + , "Amunicja do Magnum)ow" + , "Amunicja do Uzi" + , "Ma}la apteczka" + , "Du*za apteczka" + , "Sztabka o}lowiu" + , "Dzieci|e" +// keys + , "Klucz" + , "Srebrny klucz" + , "Zardzewia}ly klucz" + , "Z}loty klucz" + , "Szafirowy klucz" + , "Klucz Neptuna" + , "Klucz Atlasa" + , "Klucz Damoklesa" + , "Klucz Thora" + , "Ozdobiony klucz" +// puzzles + , "Zagadka" + , "Z}lota figurka" + , "Sztabka z}lota" + , "Z|ebatka" + , "Bezpiecznik" + , "Anch" + , "Oko Horusa" + , "Piecz|e)c Anubisa" + , "Skarabeusz" + , "Klucz do piramidy" +// TR1 subtitles + /* CAFE */ , + "[43500]Co m|e*zczyzna musi zrobi)c,@*zeby zwr)oci)c na siebie a*z tak|a uwag|e?" + "[47500]Trudno dok}ladnie powiedzie)c,@ale wydaje si|e, *ze dobrze sobie radzisz." + "[50000]C)o*z, )swietnie. Cho)c prawda jest taka,@*ze to nie ja ci|e poszukuje." + "[54500]Nie?" + "[55000]No nie. Ale Pani Jacqueline Natla,@z Natla Technologies ju*z tak." + "[59000]No wiesz, tw)orczyni@wszystkiego co jasne i pi|ekne?" + "[64500]Daj spok)oj, Larson." + "[66000]Prosz|e pani." + "[68000]Naciesz tym swoje oczy, Laro." + "[70500]Czy to nie sprawia, *ze tw)oj portfel a*z si|e trz|esie?" + "[73500]Przepraszam ale robie to tylko dla sportu." + "[76000]Wi|ec spodoba ci si|e du*zy park." + "[78000]Peru. Ogromne pasma g)orskie do pokrycia.@Urwiste )sciany lodu. Skaliste turnie. Dzikie wiatry." + "[87500]I jest tam ma}ly drobiazg: @staro*zytny artefakt o mistycznej mocy" + "[92500]pochowany w nieodnalezionym grobowcu Qualopeca." + "[96000]Jestem nim zainteresowana." + "[98000]Mog}laby)s ju*z jutro wyjecha)c.@Masz jakie)s plany na jutro?" + /* LIFT */ , + "[49000]Przeniesiony teraz do )Swi|etego Francisa Folly,@nowe pokusy mnie dr|ecz|a." + "[53500]Plotka w)sr)od moich wsp)o}lbraci g}losi,@*ze pod naszym klasztorem le*zy cia}lo Tihocana," + "[60000]jednego z trzech legendarnych w}ladc)ow@ zaginionego kontynentu Atlantydy" + "[64500]i )ze w )srodku znajduje si|e jego@kawa}lek Atlantydzkiego Scionu." + "[68000]isiorek zosta}l podzielony i@rozdzielony pomi|edzy trzech w}ladc)ow" + "[72500]aby ograniczy)c jego ogromne moce.@Moce przewy*zszaj|ace samego tw)orc|e." + "[79000]Palce mi si|e poc|a przy takich mo*zliwo)sciach@ le*z|acych tak blisko mojego )smiertelnego ja." + "[85500]Ka*zdej nocy pr)obuje pozby)c si|e tych @fantazji, ale to niezwykle trudny test." + "[92000]" + "[93500]Pierre. Ty )smieciarzu." + /* CANYON */ , + "[13500]Twoje szcz|e)scie w}la)snie si|e sko)nczy}lo." + "[16500]Siema." + "[17500]Dobry." + "[20000]Wi|ec Larson jest w tarapatach?" + "[22500]Mo*zna tak powiedzie)c." + "[24000]No c)o*z, twoje ma}le wakacyjne@zamieszki w}la)snie si|e sko)nczy}ly." + "[27000]Czas odda)c to, co zosta}lo mi przez ciebie porwane." + "[30000]Sprawd)zmy pude}lko na lunch." + "[32000]" + "[42500]Wi|ec? Zabijcie j|a!" + "[45000]Hej!" + "[48000]" + "[50500]Kretyni!" + "[53000]" + "[62500]Chod)zmy." + "[65000]" + "[136000]Co to do diab}la by}lo?" + "[138000]Co?" + "[138500]Z tej strony." + "[140500]Prawdopodobnie to tylko ryba." + "[142500]M}lody, ca}lkiem spora ta ryba." + "[145000]Cz}lowieku, musisz nauczy)c si|e wyluzowa)c.@Wracam do )srodka. Idziesz?" + "[152000]" + "[158000]Spokojnie..." + "[160000]Oto i ona." + "[161500]Jeste)scie gotowi?" + /* PRISON */ , + "[00001]Nie mo*zecie mi tego zrobi)c!" + "[01500]Pot|epiamy ci|e, Natlo z Atlantydy,@za twoje zbrodnie." + "[06000]Za ra*z|ace nadu*zywanie swoich mocy@i okradanie nas z naszych..." + "[11500]Nie mo*zecie! Ja..." + "[12500]}Lamanie wolnej wi|ezi zgody,@kt)ora rz|adzi i zabezpiecza nasz nar)od," + "[18500]i za najechanie Tihocana i mnie@nasz|a w}lasn|a armi|a." + "[23500]Nasi wojownicy opu)scili piramid|e" + "[27000]by)s mog}la wykorzysta)c piramid|e@i jej moc tworzenia do bezmy)slnej destrukcji." + "[33500]Bezmy)slnej!? Sp)ojrzcie na siebie!" + "[35500]*Zadne z was nie ma w g}lowie@cho)c krzty inwencji." + "[40500]Marnotrawcy!" + "[41500]Po prostu zr)obmy to." + "[44000]Tihocanie!" + "[45000]Wykorzysta}la)s )swi|ete miejsce jako@)zr)od}lo indywidualnej przyjemno)sci," + "[49500]jak jaka)s fabryk|e dziwak)ow." + "[51000]To survivalowcy. Nowe pokolenie" + "[54000]Teraz to tylko stado na rze)z." + "[56000]A co do ciebie. Zamkniemy ci|e w otch}lani." + "[60000]Sprawimy, aby twoje *zy}ly, serce, stopy," + "[64000]i ten chory m)ozg sklei}l si|e z zamro*zon|a krwi|a." + "[70000]Powitaj sw)oj wieczny odpoczynek, Natlo." + "[73000]Wy i tak nie odpoczniecie,@ani wasz przekl|ety kontynent Atlantyda!" + /* 22 */ , + "[04000]Powr)oci}la)s?" + "[05500]Ty te*z - na ponowne wielkie otwarcie,@jak zak}ladam." + "[09500]Ewolucja ugrz|ez}la w rutynie.@Dob)or naturalny jest wolniejszy ni*z kiedykolwiek..." + "[13500]wysy}lka )swie*zego mi|esa zn)ow wywo}la terytorialny sza}l" + "[17500] - wzmocni i rozwinie nas..." + "[20500]Nawet stworzy nowe rasy." + "[22500]Co)s w rodzaju ewolucji na sterydach." + "[24500]Kopniak na zach|et|e...@te cherlaki Qualopec and Tihocan nie mieli poj|ecia," + "[29500]- *ze kataklizm Atlantydy uderzy}l@w ras|e leniwych mi|eczak)ow..." + "[33500]ponownie sprowadzaj|ac ich do samych@korzeni przetrwania..." + "[37000]To nie powinno tak dzia}la)c." + "[39000]Ani w ten spos)ob." + "[40000]Wyl|eganie rozpoczynie si|e za 15 sekund." + "[43000]Na aborcje jest ju*z za p)o)zno!" + "[45000]Nie bez serca operacji!" + "[47000]Nieeeee!" + "[50000]10" + "[54000]5..." + "[55500]4...3...2..." + "[60000]1..." + /* 23 */ , + "[00001]Wi|ec, teraz masz moj|a ca}lkowit|a uwage" + "[02500]- Ale nie jestem pewna, czy ja mam twoj|a." + "[05000]Halo?" + "[06000]Poczekaj, niech tylko dostane ci|e w swoje r|ece." + "[09000]Oczywi)scie." + "[10000]Ty i ten cholerny kawa}lek Scionu." + "[13000]Tak bardzo chcesz go zatrzyma)c. Zaraz wsadz|e ci go w..." + "[17000]Czekaj... m)owimy tu o artefakcie?" + "[20000]Jasne, *ze tak... prosto w..." + "[22000]Poczekaj - Przepraszam" + "[24000]- ten kawa}lek, powiadasz - gdzie jest reszta?" + "[26500]Pani Natla naprowadzi}la Pierre'a Duponta na ten trop." + "[29500]A gdzie to jest?" + "[30500]Ha. Nie jeste)s dla niego wystarczaj|aco szybka." + "[34000]Wi|ec my)slisz, *ze ca}le to gadanie tylko mnie wstrzymuje?" + "[37000]Nie wiem, dok|ad prowadz|a go jego ma}le, *zabie n)o*zki." + "[42000]B|edziesz musia}la spyta)c pann|a Natl|e." + "[46000]" + "[51000]Dzi|ekuj|e. Tak zrobi|e." + /* 24 */ , "" + /* 25 */ , + "[03500]Tu le*zy Tihocan" + "[05000]...jeden z dw)och sprawiedliwych w}ladc)ow Atlantydy..." + "[10000]Kt)ory nawet po kl|atwie kontynentu..." + "[13000]...pr)obowa}l utrzyma)c rz|ady tutaj, w tych pustkowiach..." + "[19000]Zmar}l bezdzietnie, a jego wiedza nie ma dziedzictwa..." + "[25500]Sp)ojrz na nas }laskawie, Tihocan." + /* 26 */ , "Witaj w mojej posiad}lo)sci! Chod)z, oprowadz|e ci|e." + /* 27 */ , "U*zywaj przycisk)ow kierunkowych, aby p)oj)s)c do pokoju muzycznego." + /* 28 */ , "No dobrze, teraz zr)obmy kilka akrobacji.@Wci)snij przycisk Skoku." + /* 29 */ , "Teraz wci)snij go jeszcze raz wraz z jednym z przycisk)ow@kierunkowych, aby skoczy)c w danym kierunku." + /* 30 */ , "Ah, g}l)owna hala. Wybacz za te skrzynie,@ale mam kilka rzeczy, kt)ore musz|e wnie)s)c do magazynu,@ale ludzie od dostawy wci|a*z si|e nie zjawili." + /* 31 */ , "Podejd)z do skrzyni.@Podczas stania w miejscu i wciskania przycisku Prz)od,@wci)snij Akcj|e abym mog}la si|e wspi|a)c na skrzyni|e." + /* 32 */ , "Tu by}la kiedy)s sala balowa, ale przekszta}lci}lam@j|a we w}lasn|a sal|e gimnastyczn|a.@Co o tym my)slisz?@Zr)obmy kilka )cwicze)n." + /* 33 */ , "W}la)sciwie, to wsz|edzie nie mog|e tylko biec.@Gdy chc|e by)c ostro*zna, zaczynam chodzi)c.@Trzymaj przycisk Chodu, aby ostro*znie podej)s)c@do bia}lej linii." + /* 34 */ , "Podczas trzymania przycisku Chodu nie spadn|e@z *zadnej kraw|edzi, nawet je)sli tego spr)obujesz.@)Smia}lo, spr)obuj." + /* 35 */ , "Je)sli chcesz si|e rozejrze)c, wci)snij i trzymaj przycisk Rozgl|adania si|e.@Podczas trzymania, mo*zesz u*zy)c przycisk)ow@kierunkowych, aby rozejrze)c si|e w dan|a stron|e." + /* 36 */ , "Je)sli skok jest dla mnie zbyt daleki, mog|e chwyci)c@si|e kraw)edzi, aby uratowa)c si|e od gro)znego upadku.@Podejd)z do kraw|edzi z bia}l|a lini|a a*z si|e zatrzymam.@Wci)snij Skok i od razu wci)snij przycisk Prz)od.@W powietrzu, wci)snij i trzymaj Akcj|e." + /* 37 */ , "Wci)snij przycisk Prz)od, abym mog}la si|e wspi|a)c." + /* 38 */ , "Je)sli przed skopkiem zrobi|e rozbieg, mog|e@przeskoczy)c ten dystans bez problemu." + /* 39 */ , "Podejd)z do kraw|edzi z bia}l|a lini|a a*z si|e zatrzymam.@Potem p)o)s)c przycisk Chodu i raz wci)snij@przycisk Ty}l, abym mia}la miejsce na rozbieg.@Wci)snij przycisk Prz)od i prawie od razu@wci)snij i trzymaj przycisk Skoku.@Dzi|eki temu skocz|e w idealnym momencie." + /* 40 */ , "No dobra. To jest bardzo du*zy skok.@Zr)ob skok z rozbiegiem tak samo jak przed chwil|a,@ale dodatkowo w powietrzu, wci)snij i trzymaj Akcj|e@abym mog}la si|e chwyci)c kraw|edzi." + /* 41 */ , "Nie)zle." + /* 42 */ , "Spr)obuj tu wskoczy)c na g)or|e.@Wci)snij Prz)od i trzymaj Akcj|e." + /* 43 */ , "Nie mog|e wspi|a)c si|e na g)or|e, poniewa*z szczelina jest zbyt ma}la.@Ale naci)snij w prawo, a ja b|ed|e kiwa}la si|e na boki@a*z b|edzie miejsce, a potem naci)snij do przodu." + /* 44 */ , ")Swietnie! Je)sli jest d}lugi spadek i nie chc|e@ zrobi)c sobie krzywdy zeskakuj|ac z niego,@mog|e ostro*znie opu)sci)c si|e w d)o}l." + /* 45 */ , "Naci)snij klawisz do ty}lu, a odskocz|e do ty}lu.@Natychmiast naci)snij i przytrzymaj przycisk akcji,@a z}lapi|e si|e gzymsu w drodze na d)o}l." + /* 46 */ , "Nast|epnie pu)s)c." + /* 47 */ , "Chod)zmy pop}lywa)c." + /* 48 */ , "Klawisz skoku i kierunk)ow@poruszaj|a mn|a pod wod|a." + /* 49 */ , "Ach! Powietrze! Wystarczy u*zy)c klawiszy do przodu, w lewo i w prawo@do manwerowania na powierzchni.@Naci)snij skok, aby jeszcze raz zanurkowa)c.@Albo podejd)z do kraw|edzi i naci)snij przycisk akcji, aby wyj)s)c z wody." + /* 50 */ , "Dobra. A teraz lepiej zdejm|e te mokre ubrania." + /* 51 */ , "U)smiechnij si|e!" + /* 52 */ , "To nic osobistego." + /* 53 */ , "Wci|a*z przyprawiasz mnie o b)ol g}lowy.@Przez co mam zamiar wys}la)c ci|e do diab}la!" + /* 54 */ , "Nie mo*zesz tak }latwo pomiata)c mn|a@i moj|a zgraj|a, Laro." + /* 55 */ , "Troch|e p)o)zno na rozdanie nagr)od - Czy*z nie?@?Wci|a*z jednak mo*zesz wzi|a)c udzia}l." + /* 56 */ , "Strzelasz do mnie? Czy ty do mnie strzelasz?@Nie ma tu nikogo innego,@wi|ec to ty musisz do mnie strzela)c!" +// TR1 levels + , "Posiad}lo)s)c Lary" + , "G)orskie jaskinie" + , "Miasto Vilcabamba" + , "Zaginiona dolina" + , "Grobowiec Qualopeca" + , ")Swi|atynia )sw. Franciszka" + , "Koloseum" + , "Pa}lac Midasa" + , "Cysterna" + , "Grobowiec Tihocana" + , "Miasto Khamoon" + , "Obelisk Khamoon" + , "Sanktuarium Dzieci|ecia" + , "Kopalnie Natli" + , "Atlantyda" + , "Wielka piramida" + , "Powr)ot do Egiptu" + , ")Swi|atynia kota" + , "Atlantydzka twierdza" + , "R)oj" +// TR2 levels + , "Posiad}lo)s)c Lary" + , "Wielki Mur" + , "Wenecja" + , "Kryj)owka Bartoliego" + , "Opera" + , "Platforma na morzu" + , "Strefa nurkowania" + , "40 s|a*zni" + , "Wrak Marii Dorii" + , "Kwatery mieszkalne" + , "Pok}lad" + , "Pog)orza Tybetu" + , "Klasztor Barkhang" + , "Katakumby Talionu" + , "Lodowy pa}lac" + , ")Swi|atynia Xian" + , "Lewituj|ace wyspy" + , "Gniazdo smoka" + , "Nie ma to jak w domu" +// TR3 levels + , "Posiad}lo)s)c Lary" + , "D*zungla" + , "Ruiny )swi|atyni" + , "Rzeka Ganges" + , "Jaskinie bogini Kaliya" + , "Nadbrze*zna wioska" + , "Miejsce katastrofy" + , "W|aw)oz Madubu" + , ")Swi|atynia Puny" + , "Zatoka Tamizy" + , "Aldwych" + , "Lud's Gate" + , "Dzielnica City" + , "Pustynia w Nevadzie" + , "Strefa Wysokiego Nadzoru" + , "Strefa 51" + , "Antarktyda" + , "Kopalnie RX-Tech" + , "Zaginione miasto Tinnos" + , "Grota meteorytu" + , "Wszyscy )Swi|eci" +}; + +#endif diff --git a/src/lang/pt.h b/src/lang/pt.h new file mode 100644 index 00000000..2fdbfe9e --- /dev/null +++ b/src/lang/pt.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_PT +#define H_LANG_PT + +// Thanks: SrDanielPonces + +const char *STR_PT[] = { "" +// help + , "A Carregar..." + , "Press H for help" + , helpText + , "%s@@@" + "BAIXAS %d@@" + "PICKUPS %d@@" + "SEGREDOS %d de %d@@" + "TEMPO DEMORADO %s" + , "A salvar..." + , "Salvo!" + , "ERRO AO SALVAR!" + , "SIM" + , "N+AO" + , "Desligado" + , "Ligado" + , "Desligado" + , "Side-By-Side" + , "An)aglifo" + , "Tela Separada" + , "VR" + , "Baixo" + , "M)edio" + , "Alto" + , STR_LANGUAGES + , "Aplicar" + , "Gamepad 1" + , "Gamepad 2" + , "Gamepad 3" + , "Gamepad 4" + , "N+ao Preparado" + , "Player 1" + , "Player 2" + , "Pressione Qualquer Tecla" + , "%s - Selecionar" + , "%s - Voltar" +// inventory pages + , "OP|C+OES" + , "INVENT)ARIO" + , "ITENS" +// save game page + , "Salvar?" + , "Posi|c+ao Atual" +// inventory option + , "Jogo" + , "Mapa" + , "Compasso" + , "Estat)isticas" + , "Casa da Lara" + , "Gr)aficos" + , "Som" + , "Controles" + , "Gama" +// passport menu + , "Carregar Jogo" + , "Novo Jogo" + , "Recome|car o N)ivel" + , "Sair para o Menu" + , "Sair do Jogo" + , "Selecionar N)ivel" +// detail options + , "Selecionar Detalhe" + , "Filtragem" + , "Ilumina|c+ao" + , "Sombras" + , ")Agua" + , "VSync" + , "Est)ereo" + , "Itens Simples" + , "Resolution" + , STR_SCALE +// sound options + , "Configurar o Volume" + , "Revertebra|c+ao" + , "Legendas" + , "L)ingua" +// controls options + , "Configurar Controles" + , "Teclado" + , "Gamepad" + , "Vibra|c+ao" + , "Mudar Alvo" + , "Alvo Duplo" + // controls + , "Esquerda", "Direita", "Correr", "Atr)as", "Pular", "Andar", "A|c+ao", "Sacar as Armas", "Olhar", "Abaixar", "Corrida R)apida", "Rolar", "Invent)ario", "Start" + , STR_KEYS +// inventory items + , "Desconhecido" + , "Explosivo" + , "Pistolas" + , "Espingarda" + , "Magnums" + , "Uzis" + , "Clipes de Pistola" + , "Cartuchos de Espingarda" + , "Clipes de Magnum" + , "Clipes de Uzi" + , "Pequeno Medi Pack" + , "Grande Medi Pack" + , "Barra de Chumbo" + , "Scion" +// keys + , "Chave" + , "Chave de Prata" + , "Chave Enferrujada" + , "Chave Dourada" + , "Chave de Safira" + , "Chave de Neptuno" + , "Chave de Atlas" + , "Chave de D(amocles" + , "Chave de Thor" + , "Chave Ornamentada" +// puzzles + , "Puzzle" + , ")Idolo Dourado" + , "Barra de Ouro" + , "M)aquina de Roda Dentada" + , "Fus)ive|c" + , "Ankh" + , "Olho de Horus" + , "Selo de Anubis" + , "Escaravelho" + , "Chave da Pir(amide" +// TR1 subtitles + /* CAFE */ , + "[43500]O que um homem tem de fazer para@ter a tua aten|c+ao?" + "[47500])E dif)icil dizer de facto,@mas pareces estar a ir bem." + "[50000]Bem, )otimo. Por)em, a verdade )e que,@ n+ao sou eu que te procura." + "[54500]N+ao?" + "[55000]N+ao. A Senhora Jacqueline Natla quer,@da Natla Technologies." + "[59000]Tu sabes, a criadora de@todas as coisas brilhantes e lindas." + "[64500]Cala-te, Larson." + "[66000]Senhora." + "[68000]Olhe com aten|c+ao nisto, Lara." + "[70500]O qu+ao )e que isto deixa a tua carteira a tremer?" + "[73500]Desculpe. Apenas fa|co isso por divers+ao." + "[76000]Ent+ao gostar)as de um grande parque." + "[78000]Peru. Vastas montanhas longes para descobrir.@Puras paredes de gelo. Penhascos rochosos. Ventos fortes." + "[87500]E a)i est)a esta pequena bugiganga:@Um artefacto anci+ao de poderes m)isticos," + "[92500]enterrado na perdida Tumba de Qualopec." + "[96000]Este )e o meu interesse." + "[98000]Podias partir amanh+a.@Est)as ocupada amanh+a?" + /* LIFT */ , + "[49000]Realocado agora em St. Francis' Folly, novas tenta|c+oes tormentam-me." + "[53500]Os meus irm+ao t(em rumorado que o corpo de Tihocan@ est)a sepultado embaixo do nosso monast)erio," + "[60000]um dos tr(es lend)arios governantes do@continente perdido, Atl(antida," + "[64500]e nele est)a o seu peda|co@da Scion da Atl(antida." + "[68000]O colar dividido e partilhado entre os tr(es governantes,@" + "[72500]da qual origina altos poderes.@ Poderes al)em do pr)oprio criador." + "[79000]Os meus dedos suam em tais possibilidades@deixadas t+ao perto do meu ser mortal." + "[85500]Todas as noites, eu penso em livrar-me destas@fantasias, mas )e de facto um desafio." + "[92000]" + "[93500]Pierre. Tsk. Seu poluidor." + /* CANYON */ , + "[13500]Acabaste de ficar com a parte pequena de um osso de desejos." + "[16500]Prazer." + "[17500]Boa Tarde." + "[20000]Deixaste o Larson a chupar o dedo, eh?" + "[22500]Se esta )e a express+ao." + "[24000]Bem, as tuas pequenas f)erias tumultuosas acabam agora." + "[27000]Est)a na altura de devolveres o que pegaste de mim." + "[30000]Vamos ver na lancheira." + "[32000]" + "[42500]Ent+ao? Matem-na!" + "[45000]Hey!" + "[48000]" + "[50500]Idiotas!" + "[53000]" + "[62500]Vamos." + "[65000]" + "[136000]O que raio foi aquilo?" + "[138000]O qu(e?" + "[138500]Aquilo." + "[140500]Provavelmente foi um peixe." + "[142500]Que peixe, puto." + "[145000]Meu, tens de aprender a relaxar.@Eu vou para dentro. Vens?" + "[152000]" + "[158000]Calma..." + "[160000]L)a vai ela." + "[161500]J)a est)as pronto?" + /* PRISON */ , + "[00001]N+ao podes fazer isto!" + "[01500]N)os condenamos-te, Natla de Atl(antida, pelos teus crimes." + "[06000]Pelo teu flagrante mau uso dos teus poderes,@e por teres roubado os nossos." + "[11500]N+ao podes! Eu..." + "[12500]Destruindo o la|co de concenso da qual o nosso@povo )e governado e protegido," + "[18500]e por invadir Tihocan e at)e eu mesmo com o nosso pr)orpio ex)ercito." + "[23500]Os nossos guerreiros que sairam da nossa pir(amide" + "[27000]para que possas ter usado - os seus poderes@de cria|c+ao - pela tua est)upida cria|c+ao." + "[33500]Est)upida!? Olha para ti!" + "[35500]Nenhum de voc(es tem um pouco@de criatividade nas vossas cabe|cas." + "[40500]Desperdi|cadores!" + "[41500]Vamos apenas fazer isto." + "[44000]Tihocan!" + "[45000]Usaste o lugar sagrado como fonte para o@teu prazer individual," + "[49500]como se fosse uma f)abrica de loucos." + "[51000]Eles s+ao sobreviventes. Uma nova gera|c+ao." + "[54000]Um monte de massacrados agora." + "[56000]E tu. Vamos prender-te no limbo." + "[60000]Meter as tuas veias, cora|c+ao, p)es," + "[64000]e este c)erebro doentio ficarem s)olidos em sangue congelado." + "[70000]D)a as boas vindas $a tua falta de descanso, Natla." + "[73000]Voc(es tamb)em n+ao v+ao descansar, nem o vosso@maldito continente de Atl(antida!" + /* 22 */ , + "[04000]De volta?" + "[05500]E tu - assumo que seja para uma grande reinaugura|c+ao." + "[09500]A evolu|c+ao )e c)iclica - sele|c+ao natural numa constante baixa..." + "[13500]Despachar carne fresca ir)a estimular disputas territoriais de novo" + "[17500] - ir)a fortalecer e evoluir-nos..." + "[20500]At)e criar)a novas esp)ecies." + "[22500]Ent+ao ser)a um tipo de evolu|c+ao por ester)oides." + "[24500]Por uma ajuda minha...@aqueles tolos do Qualopec e Tihocan n+ao faziam ideia" + "[29500] - o cataclismo da Atl(antida criou uma ra|ca de fracos..." + "[33500]fazendo-os voltar para o instinto b)asico de sobreviv(encia de novo..." + "[37000]As coisas n+ao deviam ser assim." + "[39000]Nem desta forma." + "[40000]A incuba|c+ao come|ca em 15 segundos." + "[43000]J)a )e tarde para remendar!" + "[45000]N+ao sem o cora|c+ao da opera|c+ao!" + "[47000]N+a+a+a+a+ao!" + "[50000]DEZ" + "[54000]CINCO..." + "[55500]4...3...2..." + "[60000]UM..." + /* 23 */ , + "[00001]Bem, tens toda a minha aten|c+ao agora," + "[02500]embora n+ao tenha a certeza que tenha a tua." + "[05000]Ent+ao?" + "[06000]Eu pego-te e prendo-te num celeiro" + "[09000]Claro" + "[10000]Tu e aquela maldita pe|ca do Scion." + "[13000]Queres mant(e-lo custe o que custar, meto-o mesmo n..." + "[17000]Espere... estamos a falar do artefacto?" + "[20000])Obviamente que sim ... meto-o mesmo n..." + "[22000]Espere - Desculpe" + "[24000]este peda|co de que falas - onde est)a o resto?" + "[26500]A senhora Natla encarregou o Pierre Dupont neste percurso." + "[29500]E onde fica?" + "[30500]Hah. N+ao )es r)apida o suficiente para alcan|c)a-lo." + "[34000]Ent+ao pensas que esta conversa est)a a retardar-me?" + "[37000]Eu n+ao sei one esse coelho-com-pernas-de-sapo est)a a ir" + "[42000]Tens de perguntar $a senhora Natla" + "[46000]" + "[51000]Obrigada. Farei." + /* 24 */ , "" + /* 25 */ , + "[03500]Aqui jaz Tihocan" + "[05000]...um dos dois verdadeiros governadores de Atl(antida..." + "[10000]Que mesmo depois da maldi|c+ao do continente..." + "[13000]...tentou manter a ordem, nestas outras terras )aridas..." + "[19000]Ele morreu sem descendentes e a sua sabedoria n+ao foi herdada..." + "[25500]Olhe por n)os gentilmente, Tihocan." + /* 26 */ , "Bem-vindo ao meu lar!@Levarei-te num passeio guiado." + /* 27 */ , "Usa os bot+oes direcionais para ir $a sala de m)usica." + /* 28 */ , "OK. Vamos fazer algumas acrobacias.@Pressiona o bot+ao de pular." + /* 29 */ , "Agora pressiona-a de novo juntamente com alguma das@dire|c+oes, e saltarei em dire|c+ao desta." + /* 30 */ , "Ah, a sala de entrada.@Perdoe-me pelas caixas, estou a colocar algumas coisas@ no armaz)em, mas os homens das mudan|cas ainda n+ao chegaram." + /* 31 */ , "Aproxima-te de uma caixa, e enquanto pressionas o bot+ao da frente,@pressiona a|c+ao e subirei para cima." + /* 32 */ , "Aqui costumava a ser a sala de dan|ca, mas eu mudei-a@para ser o meu gin)asio pessoal. O que achas?@Bem, vamos fazer alguns exerc)icios." + /* 33 */ , "Eu n+ao ando a correr constantemente.@Quando quero ter cuidado, eu ando.@Pressiona o bot+ao de andar, e andar at)e a linha branca." + /* 34 */ , "Com o bot+ao de andar pressionado, eu n+ao caio mesmo que tentes.@Vai l)a, tenta." + /* 35 */ , "Se queres olhar nos arredores, pressiona e segura o bot+ao de olhar.@Depois, pressiona qualquer dire|c+ao a que queres olhar." + /* 36 */ , "Se a plataforma )e muito distante de mim, eu posso segurar na borda@e salvar-me de uma grande queda.@Anda para a borda com a@linha branca at)e parar. De seguida, pressiona o bot+ao da frente imediatamente@depois de pular, e quando estiver no ar, pressiona e@segura o bot+ao de a|c+ao." + /* 37 */ , "Pressiona o bot+ao da frente, e eu subirei." + /* 38 */ , "Se eu pular enquanto corro, posso pular esta dist(ancia, sem problemas." + /* 39 */ , "Anda para a borda com a linha branca at)e parar.@Depois larga o bot+ao, e pressiona o bot+ao de tr)as para que possa correr.@Pressiona o bot+ao da frente, e quase imediatamente pressiona e segura o bot+ao de pular.@Eu apenas pularei na borda." + /* 40 */ , "Certo. Este )e muito grande.@Faz um salto a correr tal como o de antes, exceto enquanto estiver no ar,@pressiona e segura o bot+ao de a|c+ao para que eu possa segurar-me." + /* 41 */ , "Boa." + /* 42 */ , "Tenta subir isto.@Pressiona o bot+ao da frente em simult(aneo com o de a|c+ao." + /* 43 */ , "N+ao posso subir porque o buraco )e muito pequeno.@Mas pressiona o bot+ao da direita e escalarei para o lado@at)e haver espa|co, depois pressiona o bot+ao da frente." + /* 44 */ , ")Otimo!@Se houver uma queda grande e n+ao quiser magoar-me@ao pular, eu posso cair com mais cuidado." + /* 45 */ , "Pressiona o bot+ao de tr)as, e cairei de tr)as.@Pressiona o bot+ao de a|c+ao imediatamente,@e eu irei segurar a borda antes de ir para baixo." + /* 46 */ , "De seguida, larga o bot+ao." + /* 47 */ , "Vamos dar um banho." + /* 48 */ , "O bot+ao de pular e as dire|c+oes@deslocam-me debaixo de )agua." + /* 49 */ , "Ah! Ar!@Usa os bot+oes direcionais@para movimentar-me na superf)icie.@Pressiona o bot+ao de pular para dar outro mergulho,@ou vai para a borda e pressiona a|c+ao para sair." + /* 50 */ , "Certo. Agora devo mudar estas roupas molhadas." + /* 51 */ , "Diz queijo!" + /* 52 */ , "N+ao )e nada pessoal." + /* 53 */ , "Ainda tenho uma dor de cabe|ca por tua culpa.@E ando com ideias engra|cadas agora.@Tais como atirar-te at)e ao inferno!" + /* 54 */ , "N+ao podes derrotar-me e a minha vassoura t+ao f)acilmente, Lara." + /* 55 */ , "Um pouco tarde para o pr)emio - n+ao?@De qualquer modo, )e a tomada de partes que conta." + /* 56 */ , "Est)as a disparar em mim?@Est)as a disparar em mim, huh?@N+ao h)a mais ningu)em, portanto deves estar a atirar em mim!" +// TR1 levels + , "Casa da Lara" + , "Cavernas" + , "Cidade de Vilcabamba" + , "Vale Perdido" + , "Tumba de Qualopec" + , "St. Francis' Folly" + , "Coliseu" + , "Pal)acio de Midas" + , "A Cisterna" + , "Tumba de Tihocan" + , "Cidade de Khamoon" + , "Obelisco de Khamoon" + , "Sanctu)ario do Scion" + , "Minas da Natla" + , "Atl(antida" + , "A Grande Pir(amide" + , "De Volta ao Egipto" + , "Templo do Gato" + , "Fortaleza Atl(antica" + , "A Colmeia" +// TR2 levels + , "Casa da Lara" + , "A Grande Muralha" + , "Veneza" + , "Esconderijo de Bartoli" + , "Casa de )Opera" + , "Offshore Rig" + , ")Area de Mergulho" + , "40 Bra|cas" + , "Naufr)agio de Maria Doria" + , "Aposentos" + , "O Conv)es" + , "Sop)es Tibetanos" + , "Monast)erio de Barkhang" + , "Catacumbas do Talion" + , "Pal)acio de Gelo" + , "Templo de Xian" + , "Ilhas Flutuantes" + , "O Lar do Drag+ao" + , "Lar, Doce Lar" +// TR3 levels + , "Casa da Lara" + , "Selva" + , "Ru)inas do Templo" + , "O Rio Ganges" + , "Cavernas de Kaliya" + , "A Vila Costeira" + , "A Zona do Acidente" + , "Madubu Gorge" + , "Templo de Puna" + , "Thames Wharf" + , "Aldwych" + , "O Port+ao de Lud" + , "Cidade" + , "O Deserto de Nevada" + , "Composto de Alta Seguran|ca" + , ")Area 51" + , "Ant)artida" + , "Minas RX-Tech" + , "Cidade Perdida De Tinnos" + , "Caverna do Meteorito" + , "Todos os Santos" +}; + +#endif diff --git a/src/lang/ru.h b/src/lang/ru.h new file mode 100644 index 00000000..26be97bb --- /dev/null +++ b/src/lang/ru.h @@ -0,0 +1,395 @@ +#ifndef H_LANG_RU +#define H_LANG_RU + +/*** ACHTUNG! THIS FILE MUST BE ANSI! ***/ + +// Thanks: ElikaStudio + +#include "glyph_ru.h" + +const char *STR_RU[] = { "" +// help + , "Çàãðóçêà..." + , "Íàæìèòå H äëÿ ïîìîùè" + , helpText + , "%s@@@" + "Óáè{èñòâ %d@@" + "Ïðåäìåòîâ %d@@" + "Ñåêðåòîâ %d èç %d@@" + "Âðåìÿ %s" + , "Ñîõðàíåíèå èãðû..." + , "Ñîõðàíåíèå çàâåðøåíî!" + , "ÎØÈÁÊÀ ÑÎÕÐÀÍÅÍÈß!" + , "ÄÀ" + , "ÍÅÒ" + , "Âûêë" + , "Âêë" + , "Âûêë" + , "Ñòåðåîïàðà" + , "Àíàãëèô" + , "Ðàçäåë~åííû{è ýêðàí" + , "VR" + , "Íèçêîå" + , "Ñðåäíåå" + , "Âûñîêîå" + , STR_LANGUAGES + , "Ïðèìåíèòü" + , "Ãå{èìïàä 1" + , "Ãå{èìïàä 2" + , "Ãå{èìïàä 3" + , "Ãå{èìïàä 4" + , "Íå ãîòîâ" + , "Èãðîê 1" + , "Èãðîê 2" + , "Íàæìèòå ëþáóþ êëàâèøó" + , "%s - Âûáðàòü" + , "%s - Íàçàä" +// inventory pages + , "ÎÏÖÈÈ" + , "ÈÍÂÅÍÒÀÐÜ" + , "Ïðåäìåòû" +// save game page + , "Ñîõðàíèòü èãðó?" + , "Òåêóùàÿ ïîçèöèÿ" +// inventory option + , "Èãðà" + , "Êàðòà" + , "Êîìïàñ" + , "Ñòàòèñòèêà" + , "Îñîáíÿê Ëàðû" + , "Ãðàôèêà" + , "Çâóê" + , "Óïðàâëåíèå" + , "Ãàììà" +// passport menu + , "Çàãðóçèòü èãðó" + , "Íîâàÿ èãðà" + , "Ïåðåçàïóñòèòü" + , "Âûõîä â ìåíþ" + , "Âû{èòè èç èãðû" + , "Âûáîð óðîâíÿ" +// detail options + , "Íàñòðî{èêà ãðàôèêè" + , "Ôèëüòðàöèÿ" + , "Îñâåùåíèå" + , "Òåíè" + , "Âîäà" + , "VSync" + , "Ñòåðåî" + , "Ïðîñòûå ïðåäìåòû" + , "Ðàçðåøåíèå" + , STR_SCALE +// sound options + , "Íàñòðî{èêà çâóêà" + , "Ðåâåðáåðàöèÿ" + , "Ñóáòèòðû" + , "ßçûê" +// controls options + , "Íàñòðî{èêà óïðàâëåíèÿ" + , "Êëàâèàòóðà" + , "Ãå{èìïàä" + , "Âèáðàöèÿ" + , "Àâòîñìåíà öåëè" + , "Ìíîæåñòâåííûå öåëè" + // controls + , "Âëåâî", "Âïðàâî", "Áåã", "Íàçàä", "Ïðûæîê", "Øàã", "Äå{èñòâèå", "Îðóæèå", "Ñìîòðåòü", "Ïðèñåñòü", "Ñïðèíò", "Êóâûðîê", "Èíâåíòàðü", "Ñòàðò" + , STR_KEYS +// inventory items + , "Íåèçâåñòíî" + , "Âçðûâ÷àòêà" + , "Ïèñòîëåòû" + , "Äðîáîâèê" + , "Ìàãíóìû" + , "Óçè" + , "Îáî{èìû ïèñòîëåòîâ" + , "Ïàòðîíû äðîáîâèêà" + , "Îáî{èìû ìàãíóìîâ" + , "Îáî{èìû óçè" + , "Ìàëåíüêàÿ àïòå÷êà" + , "Áîëüøàÿ àïòå÷êà" + , "Ñâèíöîâû{è ñëèòîê" + , "Ñöèîí" +// keys + , "Êëþ÷" + , "Ñåðåáðÿíû{è êëþ÷" + , "Ðæàâû{è êëþ÷" + , "Çîëîòî{è êëþ÷" + , "Ñàïôèðîâû{è êëþ÷" + , "Êëþ÷ Íåïòóíà" + , "Êëþ÷ Àòëàíòà" + , "Êëþ÷ Äàìîêëà" + , "Êëþ÷ Òîðà" + , "Èçûñêàííû{è êëþ÷" +// puzzles + , "Ýëåìåíò" + , "Çîëîòî{è èäîë" + , "Çîëîòî{è ñëèòîê" + , "Øåñòåðíÿ" + , "Ïðåäîõðàíèòåëü" + , "Àíêõ" + , "Ãëàç Ãîðà" + , "Ïå÷àòü Àíóáèñà" + , "Ñêàðàáå{è" + , "Êëþ÷ ïèðàìèäû" +// TR1 subtitles + /* CAFE */ , + "[43500]×òî æå äîëæåí ñäåëàòü ìóæ÷èíà,@÷òîáû äîáèòüñÿ îò òåáÿ òàêîãî æå âíèìàíèÿ?" + "[47500]Òðóäíî ñêàçàòü, íî, êàæåòñÿ, òû íà âåðíîì ïóòè." + "[50500]×òî æ, îòëè÷íî, ïðàâäà ýòî íå ÿ òîáî{è òàê èíòåðåñóþñü..." + "[54500]À êòî?" + "[55000]Îîî... Ìèññ Æàêëèí Íàòëà èç Natla Technologies." + "[59000]Íó çíàåøü... ñîçäàòåëü âñåãî è âñÿ!@Òàêàÿ âûñîêàÿ, ñèìïàòè÷íàÿ õåõåõåõå." + "[64500]Îòî{èäè êà, Ëàðñåí!" + "[66000]Ìýì." + "[68000]Âçãëÿíè íà ýòî, Ëàðà." + "[70500]Ïîíèìàåøü î êàêèõ ñóììàõ èä~åò ðå÷ü?" + "[73500]Èçâèíèòå, ÿ ðàáîòàþ èç ñïîðòèâíîãî èíòåðåñà." + "[76000]Òîãäà òåáå òåì áîëåå ïîíðàâèòñÿ." + "[78000]Ïåðó. Íåîáúÿòíûå ãîðíûå ïðîñòîðû, ïîêðûòûå ëåäíèêàìè,@êðóòûå óò~åñû, êîâàðíûå ðàñùåëèíû, äèêèå âåòðà..." + "[87500]è åù~å âîò ýòà âåùèöà: ñòàðèííû{è àðòåôàêò ñ ìàãè÷åñêî{è ñèëî{è," + "[92500]ñïðÿòàííû{è â ãðîáíèöå Êâàëîïåêà" + "[96000]Îí òî ìíå è íóæåí." + "[98000]Òû ìîãëà áû îòïðàâèòüñÿ çàâòðà.@Ó òåáÿ æå íåò ïëàíîâ íà çàâòðà?" + /* LIFT */ , + "[49000]Ìû ïåðåáðàëèñü â ìîíàñòûðü Ñâÿòîãî Ôðàíöèñêà,@è íîâûå ñîáëàçíû ìó÷àþò ìåíÿ." + "[53500]Ñðåäè ìîèõ áðàòüåâ õîäÿò ñëóõè,@÷òî ïîä íàøèì ìîíàñòûð~åì ïîãðåáåíî òåëî Òèõîêàíà" + "[59000]- îäíîãî èç òð~åõ ëåãåíäàðíûõ ïðàâèòåëå{è@çàòåðÿííîãî êîíòèíåíòà Àòëàíòèäà" + "[64000]è âìåñòå ñ íèì ëåæèò åãî ÷àñòü Ñöèîíà." + "[67000]Êóëîíà, ðàçäåë~åííîãî ìåæäó òðåìÿ ïðàâèòåëÿìè íà òðè ÷àñòè," + "[72000]â êîòîðûõ çàêëþ÷åíû îãðîìíûå ñèëû.@Ñèëû, ïðåâîñõîäÿùèå ñàìîãî ñîçäàòåëÿ!" + "[79000]Ìîè ëàäîíè ïîòåþò îò òàêèõ âîçìîæíîñòå{è,@ñêðûòûõ òàê áëèçêî îò ìåíÿ-ñìåðòíîãî." + "[85000]Êàæäóþ íî÷ü ÿ áîðþñü ñ ñîáî{è è ñâîèìè ôàíòàçèÿìè.@Ýòî è âïðàâäó èñïûòàíèå." + "[92000]" + "[93500]Ïüåð... íó òû è ïîìî{èêà." + /* CANYON */ , + "[13500]Òîëüêî ïîïðîáó{è ðûïíóòüñÿ..." + "[16500]Çäàðîâà!" + "[17000]Äåíü äîáðû{è!" + "[20000]Îñòàâèëà Ëàðñåíà íå ó äåë, äà?" + "[22500] êàêîì-òî ñìûñëå." + "[24000]Èòàê, òâîÿ âîñêðåñíàÿ ïîäðàáîòêà îêîí÷åíà." + "[27000]Ïîðà îòäàâàòü òî, ÷òî òû ó ìåíÿ óêðàëà!" + "[30000]Ïîèùåì â ðþêçà÷êå..." + "[32000]" + "[42000]×òî æ, óáèòü å~å!" + "[45000]Ý{è!" + "[48000]" + "[50500]Èäèîòû!" + "[53000]" + "[62500]Ïîøëè." + "[65000]" + "[136000]×òî ýòî, ÷~åðò âîçüìè, áûëî?" + "[138000]×òî?" + "[138500]Âîí òàìà..." + "[140500]Äà ñêîðåå âñåãî, ïðîñòî ðûáà." + "[142500]Êàêàÿ æå ýòî ðûáà?" + "[145000]×óâàê, òåáå íóæíî íàó÷èòüñÿ îòäûõàòü.@ß îáðàòíî âíóòðü, òû èä~åøü?" + "[152000]" + "[158000]Ïðèïëûëè." + "[160000]Âîò è îíà." + "[161500]Âû ãîòîâû?" + /* PRISON */ , + "[00001]Âû íå ñìååòå ýòîãî ñäåëàòü!" + "[01500]Ìû ñóäèì òåáÿ Íàòëà Àòëàíòèäû, çà òâîè ïðåñòóïëåíèÿ." + "[06500]Çà âîïèþùåå çëîóïîòðåáëåíèå ñèëàìè è çà òî, ÷òî îáîêðàëà íàñ." + "[11500]Âû íå ìîæåòå, ÿ..." + "[12500]Ðàçðóøèëà ñèìâîë ñîãëàñèÿ, òî,@÷òî óïðàâëÿåò íàøèì íàðîäîì è çàùèùàåò åãî." + "[19500]Òû âòîðãëàñü ê Òèõîêàíó, è ïðè ïîìîùè íàøå{è æå àðìèè âûãíàëà" + "[24000]íàøèõ âîèíîâ èç íàøå{è ïèðàìèäû," + "[27000]÷òîáû èñïîëüçîâàòü å~å ñîçèäàòåëüíûå ñèëû,@ðàäè ñâîèõ áåçäóìíûõ ðàçðóøåíè{è." + "[33000]Áåçäóìíûõ? Ïîñìîòðèòå íà ñåáÿ!" + "[35500]Íèêòî èç âàñ íå ñïîñîáåí ïðîÿâèòü õîòü êàïëþ èçîáðåòàòåëüíîñòè." + "[40000]Íåóäà÷íèêè!" + "[41500]Äàâà{èòå ïîêîí÷èì ñ ýòèì." + "[44000]Òèõîêàí!" + "[45000]Òû èñïîëüçîâàëà ñàêðàëüíîå ìåñòî@äëÿ ñâîèõ êîðûñòíûõ öåëå{è" + "[49500]êàê êàêóþ-òî ôàáðèêó óðîäîâ." + "[51000]Îíè âûæèâøèå. Íîâîå ïîêîëåíèå!" + "[54000]Òåïåðü ýòî ãðóäà ìÿñà..." + "[56000]È òû. Ìû çàòî÷èì òåáÿ â ëèìáî," + "[60000]Êðîâü â òâî~åì òåëå, âåíàõ, ñåðäöå" + "[65000]è òâî~åì áîëüíîì ðàçóìå çàñòûíåò íàâåêè." + "[70000]Âñòðå÷à{è ñâîè áåñêîíå÷íûå ñòðàäàíèÿ, Íàòëà!" + "[73000]Âû òîæå áóäåòå ñòðàäàòü, êàê è âàø@ïðîêëÿòû{è êîíòèíåíò - Àòëàíòèäà!" + /* 22 */ , + "[04500]Ñ âîçâðàùåíèåì!" + "[06000]È òåáÿ, ïðèøëà íà òîðæåñòâåííîå îòêðûòèå?" + "[09500]Ýâîëþöèÿ â òóïèêå, åñòåñòâåííû{è îòáîð íåòîðîïëèâ." + "[13500]Ïîÿâëåíèå ñâåæåãî ìÿñà ïðîáóäèò òåððèòîðèàëüíûå ðàñïðè." + "[17500]Ñäåëàåò íàñ ñèëüíåå è ëó÷øå." + "[20500]Äàæå ñîçäàñò íîâûå âèäû!" + "[22500]×òî-òî âðîäå ýâîëþöèè íà ñòåðîèäàõ?" + "[24500]Ïèíîê ïîä çàä...@ýòè îòñòàëûå Òèõîêàí è Êâàëîïåê íå èìåëè è ïîíÿòèÿ!" + "[30000]Êàòàêëèçì Àòëàíòèäû ñêîñèë ðàñó íåäîðàçâèòûõ ñëàáàêîâ," + "[34000]çàñòàâèë âåðíóòüñÿ ê ñàìûì îñíîâàì âûæèâàíèÿ..." + "[37000]Âñ~å äîëæíî áûëî áûòü íå òàê." + "[39000]È íå òàê!" + "[40000]Èíêóáàöèÿ çàâåðøèòñÿ ÷åðåç 15 ñåêóíä." + "[43000]Ñëèøêîì ïîçäíî ïîâîðà÷èâàòü íàçàä!" + "[45000]Òû èìååøü ââèäó áåç âðåäà äëÿ îïåðàöèè?" + "[47500]ÍÅÅÅÒ!" + "[50000]ÄÅÑßÒÜ..." + "[54000]ÏßÒÜ..." + "[55500]×ÅÒÛÐÅ... ÒÐÈ... ÄÂÀ..." + "[60000]ÎÄÈÍ..." + /* 23 */ , + "[00001]Èòàê, òû ïîëíîñòüþ çàâëàäåë ìîèì âíèìàíèåì" + "[03000]Íå óâåðåíà, ÷òî ÿ çàâëàäåëà òâîèì." + "[05500]Ïðèâåò?" + "[06500]Àýýý... âåðòåë ÿ òåáÿ, çíàëà áû òû ãäå!" + "[09000]Êîíå÷íî" + "[10000]Äà, òåáÿ è ýòîò òóïî{è êóñîê Ñöèîíà!" + "[13500]Õî÷åøü çíàòü êàê? ß çàñóíó òåáå åãî ÏÐßÌÎ Â..." + "[17000]Ñòî{è! Ìû ãîâîðèì îá àðòåôàêòå?" + "[19500]×~åðò ÄÀ... ÏÐßÌÎ ÒÅÁÅ Â..." + "[22000]Ïîãîäè, è-èçâèíè." + "[24000]Òû ñêàçàë, ÷òî ýòî ÷àñòü, ãäå äðóãèå?" + "[26500]Ìèññ Íàòëà íàíÿëà äëÿ ýòîãî Ïüåðà Äþïîíà." + "[29500]È ãäå æå îí?" + "[30500]Õà! Òåáå çà íèì íå óãíàòüñÿ." + "[34000]Äóìàåøü, ýòè ñëîâà ìåíÿ îñòàíîâÿò?" + "[37000]ß íå çíàþ êóäà ïîáåæàëè åãî ðåçâûå ëÿãóøà÷üè ëàïêè." + "[42500]Ëó÷øå ñïðîñè îá ýòîì ó ìèññ Íàòëû." + "[46000]" + "[51000]Ñïàñèáî. Ñïðîøó." + /* 24 */ , "" + /* 25 */ , + "[03500]Çäåñü ïîêîèòñÿ Òèõîêàí" + "[06000]îäèí èç äâóõ ïðàâèòåëå{è Àòëàíòèäû..." + "[10000]êîòîðû{è, äàæå ïîñëå ïðîêëÿòèÿ êîíòèíåíòà, ïîïûòàëñÿ ïðàâèòü çäåñü..." + "[16000]â ýòèõ ñîâñåì äðóãèõ çåìëÿõ." + "[19000]Îí óìåð áåçäåòíûì è åãî çíàíèÿ òàê è íå îáðåëè íàñëåäíèêà." + "[26000]Íå ñóäè íàñ ñòðîãî, Òèõîêàí." + /* 26 */ , "Äîáðî ïîæàëîâàòü êî ìíå äîìî{è.@ß ïðîâåäó íåáîëüøóþ ýêñêóðñèþ." + /* 27 */ , "Èñïîëüçó{èòå ñòðåëêè,@÷òîáû èäòè â ìóçûêàëüíóþ êîìíàòó." + /* 28 */ , "Õîðîøî. Òåïåðü íåìíîãî àêðîáàòèêè.@Íàæìèòå êëàâèøó ïðûæêà." + /* 29 */ , "Òåïåðü ñíîâà íàæìèòå ïðûæîê è áûñòðî íàæìèòå îäíó èç ñòðåëîê.@ß ïðûãíó â îäíîì èç íàïðàâëåíè{è." + /* 30 */ , "Ýòî ãëàâíû{è õîëë.@Ïðîøó ïðîùåíèÿ çà áåñïîðÿäîê,@ìíîãî âåùå{è íóæíî ïåðåíåñòè â õðàíèëèùå,@íî ãðóç÷èêè åù~å íå ïðèáûëè." + /* 31 */ , "Ïîäî{èäèòå ê ÿùèêó è, ïðîäîëæàÿ íàæèìàòü êëàâèøó âïåð~åä,@íàæèìà{èòå êëàâèøó äå{èñòâèÿ,@òîãäà ÿ çàëåçó íà ÿùèê." + /* 32 */ , "Ðàíüøå ýòî áûë áàëüíû{è çàë, íî@ÿ ïåðåäåëàëà åãî äëÿ çàíÿòè{è ãèìíàñòèêî{è.@×òî ñêàæåòå?@×òî æ, ñäåëàåì ïàðó óïðàæíåíè{è." + /* 33 */ , "ß íå âñåãäà áåãàþ ñëîìÿ ãîëîâó.@Èíîãäà òðåáóåòñÿ îñòîðîæíî ïîäî{èòè ê ÷åìó-íèáóäü.@Çàæìèòå êëàâèøó õîäüáû è ïîäî{èäèòå ê áåëî{è ëèíèè." + /* 34 */ , "Ñ çàæàòî{è êëàâèøå{è õîäüáû ÿ íèêóäà óïàäó,@äàæå åñëè âû áóäåòå íåîñòîðîæíû.@Äàâà{èòå, ïîïðîáó{èòå." + /* 35 */ , "Åñëè âû õîòèòå îñìîòðåòüñÿ,@íàæìèòå è äåðæèòå êëàâèøó ñìîòðåòü,@çàòåì íàæìèòå êëàâèøó íóæíîãî íàïðàâëåíèÿ." + /* 36 */ , "Åñëè ÿ íå ìîãó äîïðûãíóòü êóäà-ëèáî,@ÿ ìîãó óõâàòèòüñÿ çà êðà{è è óáåðå÷üñÿ îò ïàäåíèÿ.@Èäèòå ê êðàþ ñ áåëî{è ëèíèå{è äî òåõ ïîð ïîêà ÿ íå îñòàíîâëþñü.@Çàòåì íàæìèòå ïðûæîê è ñðàçó æå êëàâèøó âïåð~åä.@Êîãäà ÿ îêàæóñü â âîçäóõå, íàæìèòå è äåðæèòå êëàâèøó äå{èñòâèÿ." + /* 37 */ , "Íàæìèòå êëàâèøó âïåð~åä è ÿ ïîëåçó íàâåðõ." + /* 38 */ , "Åñëè íàæàòü ïðûæîê âî âðåìÿ áåãà,@òî ÿ áåç ïðîáëåì ñîâåðøó òàêèå ïðûæêè." + /* 39 */ , "Èäèòå ê êðàþ ñ áåëî{è ëèíèå{è, ïîêà ÿ íå îñòàíîâëþñü.@Çàòåì ïåðå{èäÿ íà øàã íàæìèòå êëàâèøó íàçàä,@÷òîáû äàòü ìíå ìåñòî äëÿ ðàçáåãà.@Íàæìèòå êëàâèøó âïåð~åä è ñðàçó íàæìèòå è äåðæèòå êëàâèøó ïðûæêà.@ß ñîâåðøó ïðûæîê â òó æå ñåêóíäó." + /* 40 */ , "Òàê, ÿ òåïåðü ñëîæíû{è òðþê.@Ñäåëà{èòå êàê è ïðåæäå ïðûæîê ñ ðàçáåãà, à çàòåì, ïîêà ÿ â âîçäóõå,@íàæìèòå êëàâèøó äå{èñòâèÿ, ÷òîáÿ ÿ óõâàòèëàñü çà óñòóï." + /* 41 */ , "Îòëè÷íî!" + /* 42 */ , "Ïîïðîáóåì òóäà çàáðàòüñÿ.@Íàæìèòå êëàâèøó âïåð~åä, à çàòåì çàæìèòå êëàâèøó äå{èñòâèÿ." + /* 43 */ , "Ìíå òóäà íå çàëåçòü, ïðîõîä ñëèøêîì óçêè{è.@Íàæìèòå êëàâèøó âïðàâî è ÿ ïåðå{èäó íà ðóêàõ íà ñâîáîäíîå ìåñòî.@Çàòåì íàæìèòå âïåð~åä." + /* 44 */ , "Îòëè÷íî!@Åñëè óñòóï ñëèøêîì âûñîêè{è è ïðè ïðûæêå ñ íåãî ìîæíî ïîêàëå÷èòüñÿ,@ÿ ìîãó ñïóñòèòüñÿ îñòîðîæíî." + /* 45 */ , "Íàæìèòå êëàâèøó íàçàä è ÿ îòïðûãíó íàçàä.@Ñðàçó æå íàæìèòå è äåðæèòå êëàâèøó äå{èñòâèÿ,@òîãäà ÿ íå óïàäó, à óõâà÷óñü çà êðà{è." + /* 46 */ , "Çàòåì îòïóñòèòå êëàâèøó." + /* 47 */ , "À òåïåðü ïîïëàâàåì." + /* 48 */ , "Êëàâèøà ïðûæêà è ñòðåëêè èçìåíÿþò ìî~å íàïðàâëåíèå@ïðè ïëàâàíèè ïîä âîäî{è." + /* 49 */ , "Àõ! Ý!@Èñïîëüçó{èòå êëàâèøè âïåð~åä, âïðàâî è âëåâî@äëÿ ïåðåìåùåíèÿ ïî ïîâåðõíîñòè âîäû.@Íàæìèòå ïðûæîê, ÷òîáû íûðíóòü,@èëè ïëûâèòå ê êðàþ è íàæìèòå äå{èñòâèå,@÷òîáû âû{èòè èç âîäû." + /* 50 */ , "Õîðîøî. À òåïåðü ïîðà ïåðåîäåòüñÿ â ñóõóþ îäåæäó." + /* 51 */ , "Ñêàæè ñûûûð!" + /* 52 */ , "Íè÷åãî ëè÷íîãî." + /* 53 */ , "Ó ìåíÿ âñ~å åù~å áîëü â ãîëîâå ïîñëå òåáÿ.@È îíà ïîäêèäûâàåò çàáàâíûå èäåè.@Íàïðèìåð, ïðèñòðåëèòü òåáÿ ê ÷åðòÿì!" + /* 54 */ , "Òàê ïðîñòî îò ìåíÿ è ìîèõ âûðîäêîâ òåáå íå èçáàâèòüñÿ, Ëàðà." + /* 55 */ , "Íåìíîãî ïîçäíî äëÿ ðàçàä÷è ïðèçîâ, íî...@âïðî÷åì, òâî~å ó÷àñòèå åù~å ñ÷èòàåòñÿ." + /* 56 */ , "Òû â ìåíÿ ñòðåëÿåøü? Òû â ìåíÿ ñòðåëÿåøü?! Òóò áîëüøå íèêîãî, çíà÷èò òû â ìåíÿ ñòðåëÿåøü!" +// TR1 levels + , "Îñîáíÿê Ëàðû" + , "Ïåùåðû" + , "Ãîðîä Âèëêàáàìáà" + , "Çàòåðÿííàÿ Äîëèíà" + , "Ãðîáíèöà Êâàëîïåêà" + , "Ìîíàñòûðü Ñâ. Ôðàíöèñêà" + , "Êîëèçå{è" + , "Äâîðåö Ìèäàñà" + , "Öèñòåðíà" + , "Ãðîáíèöà Òèõîêàíà" + , "Õðàì Êàìóí" + , "Îáåëèñê Êàìóí" + , "Ñâÿòèëèùå Ñöèîíà" + , "Ðàñêîïêè Íàòëû" + , "Àòëàíòèäà" + , "Âåëèêàÿ Ïèðàìèäà" + , "Âîçâðàùåíèå â Åãèïåò" + , "Õðàì Êîøêè" + , "Êðåïîñòü Àòëàíòèäû" + , "Óëå{è" +// TR2 levels + , "Lara's Home" + , "The Great Wall" + , "Venice" + , "Bartoli's Hideout" + , "Opera House" + , "Offshore Rig" + , "Diving Area" + , "40 Fathoms" + , "Wreck of the Maria Doria" + , "Living Quarters" + , "The Deck" + , "Tibetan Foothills" + , "Barkhang Monastery" + , "Catacombs of the Talion" + , "Ice Palace" + , "Temple of Xian" + , "Floating Islands" + , "The Dragon's Lair" + , "Home Sweet Home" +// TR3 levels + , "Lara's House" + , "Jungle" + , "Temple Ruins" + , "The River Ganges" + , "Caves Of Kaliya" + , "Coastal Village" + , "Crash Site" + , "Madubu Gorge" + , "Temple Of Puna" + , "Thames Wharf" + , "Aldwych" + , "Lud's Gate" + , "City" + , "Nevada Desert" + , "High Security Compound" + , "Area 51" + , "Antarctica" + , "RX-Tech Mines" + , "Lost City Of Tinnos" + , "Meteorite Cavern" + , "All Hallows" +}; + +inline bool isCyrillic(char c) { + return (c >= 'À' && c <= 'ß') || (c >= 'à' && c <= 'ÿ'); +} + +inline char remapCyrillic(char c) { + if (!isCyrillic(c)) { + return c; + } + + switch (c) { + case 'à' : return 'a'; + case 'å' : return 'e'; + case '¸' : return 'e'; + case 'è' : return 'u'; + case 'é' : return 'u'; + case 'î' : return 'o'; + case 'ð' : return 'p'; + case 'ñ' : return 'c'; + case 'ó' : return 'y'; + case 'õ' : return 'x'; + case 'À' : return 'A'; + case 'Â' : return 'B'; + case 'Å' : return 'E'; + case '¨' : return 'E'; + case 'Ê' : return 'K'; + case 'Ì' : return 'M'; + case 'Í' : return 'H'; + case 'Î' : return 'O'; + case 'Ð' : return 'P'; + case 'Ñ' : return 'C'; + case 'Ò' : return 'T'; + case 'Õ' : return 'X'; + } + return c; +} + +#endif diff --git a/src/lang/sv.h b/src/lang/sv.h new file mode 100644 index 00000000..22fce1d6 --- /dev/null +++ b/src/lang/sv.h @@ -0,0 +1,355 @@ +#ifndef H_LANG_SV +#define H_LANG_SV + +// Thanks: Carl Lindmark, Rickard Andreasson + +const char *STR_SV[] = { "" +// help + , "Laddar..." + , "Tryck H f~or hj~alp" + , helpText + , "%s@@@" + "D~ODADE %d@@" + "PLOCKAT %d@@" + "HEMLIGHETER %d av %d@@" + "TID TAGEN %s" + , "Sparar spel..." + , "Sparar klart!" + , "SPARA MISSLYCKATS!" + , "JA" + , "NEJ" + , "Av" + , "P^a" + , "Av" + , "Sida-vid-Sida" + , "Anaglyf" + , "Delad sk~arm" + , "VR" + , "L^ag" + , "Mellan" + , "H~og" + , STR_LANGUAGES + , "Till~ampa" + , "Handkontroll 1" + , "Handkontroll 2" + , "Handkontroll 3" + , "Handkontroll 4" + , "Ej Redo" + , "Spelare 1" + , "Spelare 2" + , "Tryck Valfri Knapp" + , "%s - V~alj" + , "%s - Tillbaka" +// inventory pages + , "ALTERNATIV" + , "LAGER" + , "OBJEKT" +// save game page + , "Spara Spel?" + , "Nuvarande Position" +// inventory option + , "Spel" + , "Karta" + , "Kompass" + , "Statistik" + , "Lara's Hem" + , "Detaljniv^aer" + , "Ljud" + , "Kontroller" + , "Gamma" +// passport menu + , "~Oppna Spel" + , "Nytt Spel" + , "Starta om Niv^a" + , "Avsluta till Titel" + , "Avsluta Spel" + , "V~alj Niv^a" +// detail options + , "V~alj detalj" + , "Filtrering" + , "Belysning" + , "Skuggor" + , "Vatten" + , "VSync" + , "Stereo" + , "Enkla Objekt" + , "Uppl~osning" + , STR_SCALE +// sound options + , "St~all in Volym" + , "Eko" + , "Undertexter" + , "Spr^ak" +// controls options + , "St~all in Kontroller" + , "Tangentbord" + , "Handkontroll" + , "Vibration" + , "Omniriktning" + , "Multi-riktning" + // controls + , "V~anster", "H~oger", "Spring", "Backa", "Hoppa", "G^a", "Action", "Dra Vapen", "Titta", "Ducka", "Rusa", "Rulla", "Lager", "Start" + , STR_KEYS +// inventory items + , "Ok~and" + , "Explosivt" + , "Pistoler" + , "Hagelgev~ar" + , "Magnum" + , "Uzis" + , "Pistol-Ammunition" + , "Hagelgev~ar-Ammunition" + , "Magnum-Ammunition" + , "Uzi-Ammunition" + , "Litet First-Aid" + , "Stort First-Aid" + , "Blytacka" + , "Scion" +// keys + , "Nyckel" + , "Silvernyckel" + , "Rostig Nyckel" + , "Guld Nyckel" + , "Safir Nyckel" + , "Neptunes Nyckel" + , "Atlas Nyckel" + , "Damokles Nyckel" + , "Thors Nyckel" + , "Dekorerad Nyckel" +// puzzles + , "Pussel" + , "Guld-Idol" + , "Guld-Tacka" + , "Kugghjul" + , "S~akring" + , "Ankh" + , "Horus ~Oga" + , "Anubis Sigill" + , "Scarab" + , "Pyramid-Nyckeln" +// TR1 subtitles + /* CAFE */ , + "[43500]Vad m^aste en man g~ora f~or att@f^a din uppm~arskamhet?" + "[47500]Det ~ar sv^art att s~aga,@men du verkar klara det bra." + "[50000]Bra. Men det ~ar inte jag som beh~over dig." + "[54500]Inte?" + "[55000]Nej, men fr~oken Jacqueline Natla,@fr^an Natla Technologies." + "[59000]Du vet, skaparen av@allt ljust och vackert?" + "[64500]Tyst, Larson." + "[66000]Fr~oken." + "[68000]Titta, Lara." + "[70500]Vill du tj~ana stora pengar?" + "[73500]Detta ~ar bara en sport f~or mig, tyv~arr." + "[76000]D^a kanske du kommer att gilla det h~ar." + "[78000]Peru. Enorma bergskedjor, branta isv~aggar,@bergskrevor, kalla vindar" + "[87500]och sedan finns denna saken:@en gammal artefakt med mystiska krafter," + "[92500]begravd i Qualopecs bortgl~omda grav." + "[96000]Det vill jag ha." + "[98000]Du kan ^aka i morgon.@Har du n^agra planer f~or morgondagen?" + /* LIFT */ , + "[49000]Jag befinner mig i S:t Francis folly,@nya frestelser pl^agar mig." + "[53500]Det g^ar rykten att Tihocans kropp@~ar begravd under v^art kloster," + "[60000]en av de tre legendariska h~arskarna@av kontinenten Atlantis," + "[64500]och att med honom vilar hans del av The scion." + "[68000]ett smycke som delades mellan de tre h~arskarna@ och som har enorma krafter," + "[72500]krafter bortom Skaparen@." + "[79000]Jag blir yr av tankarna p^a vad som@ligger s^a n~ara mitt d~odliga jag.." + "[85500]Varje kv~all sl^ar jag bort de hemska tankarna)en,@men det ~ar verkligen ett test." + "[92000]" + "[93500]Pierre. Din nerskr~apare." + /* CANYON */ , + "[13500]H~ar har vi ~antligen det lilla odjuret." + "[16500]Howdy." + "[17500]God eftermiddag." + "[20000]Bl^aste du ut ljuset f~or Larson?" + "[22500]Om du vill uttrycka det s^a." + "[24000]N^av~al, din lilla semesterresa ~ar ~over." + "[27000]Dags att ge tillbaka det du stal fr^an mig." + "[30000]L^at oss ta en titt i lunchl^adan." + "[32000]" + "[42500]N^a? D~oda henne!" + "[45000]Hej!" + "[48000]" + "[50500]Era idioter!" + "[53000]" + "[62500]L^at oss g^a." + "[65000]" + "[136000]Vad i helvete var det?" + "[138000]Vad?" + "[138500]D~ar borta." + "[140500]F~ormodligen bara en fisk." + "[142500]Men m^aste ha varit ganska stor." + "[145000]Mannen, du m^aste l~ara dig a det lugnt@Jag g^ar in igen, kommer du?" + "[152000]" + "[158000]H^all dig lugn..." + "[160000]H~ar kommer det." + "[161500]~Ar du redo?" + /* PRISON */ , + "[00001]Ni kan inte g~ora detta!" + "[01500]Vi d~ommer dig, Natla fr^an Atlantis, f~or dina brott," + "[06000]f~or grovt missbruk av dina befogenheter@och f~or att stj~ala v^ara befogenheter." + "[11500]Du kan inte! Jag..." + "[12500]Du har f~orst~ort den trippelallians som har@lett och skyddat v^art folk..." + "[18500]och utmanade Tihocan och mig med v^ar egen arm)e..." + "[23500]lockade v^ara krigare bort fr^an pyramiden..." + "[27000]s^a att du kan missbruka pyramidens kreativa@kraft f~or din sjuka destruktivitet." + "[33500]Sjuk!? Titta p^a dig!" + "[35500]Ingen av er har en gnista av kreativitet i huvudet." + "[40500]Od^agor!" + "[41500]L^at oss bara g~ora det nu." + "[44000]Tihocan!" + "[45000]Du har vandaliserat ditt heliga offer av ren girighet," + "[49500]som en freak show." + "[51000]En ny generation, f~odd f~or att ~overleva." + "[54000]Nu ~ar de k~ottf~ars." + "[56000]Och du, Natla, vi kommer att sm~ada..." + "[60000]dina vener och f~otter, ditt hj~arta..." + "[64000]och din sjuka hj~arna fryses ned till is med ditt blod," + "[70000]Se din eviga rastl~oshet i ~ogonen, Natla.." + "[73000]Du kommer aldrig finna frid,@f~orbannad m^a din kontinent Atlantis!" + /* 22 */ , + "[04000]Tillbaka igen?" + "[05500]Och du - F~or den ceremoniella ^ater~oppningen, antar jag." + "[09500]Evolutionen ~ar i en ^aterv~andsgr~and - n~astan inget naturligt urval..." + "[13500]spridningen av nya varelser" + "[17500] - kommer att stimulera nya regionala krafter..." + "[20500]~Aven skapa nya arter." + "[22500]som en evolution p^a steroider." + "[24500]Ja, med en spark i rumpan...@De d~ar Qualopec och Tihocan hade ingen aning." + "[29500] - Atlantis fall har drabbat ett lopp av tr~otta svagheter..." + "[33500]och kastade dem tillbaka till ursprunget f~or ~overlevnad...." + "[37000]Detta ~ar vad v~arlden beh~over." + "[39000]Inte s^a." + "[40000]Det b~orjar om 15 sekunder." + "[43000]F~or sent f~or att avbryta!" + "[45000]Inte utan hj~artat av operationen!" + "[47000]Neeeeej!" + "[50000]10" + "[54000]5..." + "[55500]4...3...2..." + "[60000]1..." + /* 23 */ , + "[00001]N^a, du har min fulla uppm~arksamhet nu," + "[02500]men jag har nog inte din" + "[05000]Hall^a!" + "[06000]Jag ska jaga dig." + "[09000]Naturligtvis." + "[10000]Du och den d~ar dumma delen av Scion." + "[13000]Om du s^a g~arna vill beh^alla den, ska jag trycka den i din..." + "[17000]V~anta... pratar vi om artifakten?" + "[20000]Det kan du ta dig p^a ... r~att upp i din ..." + "[22000]V~anta lite - Jag ~ar ledsen" + "[24000]-Denna delen sa du - vart ~ar resten?" + "[26500]Miss Natla satte Pierre Dupont p^a att hitta den." + "[29500]Vart d^a?" + "[30500]Ha! Du ~ar inte lika snabb som honom." + "[34000]S^a du menar att detta samtalet h~ar bara hindrar mig?" + "[37000]Jag har ingen aning var de d~ar@skurkbenen leder honom." + "[42000]Du f^ar fr^aga fr~oken Natla." + "[46000]" + "[51000]Det ska jag, tackar." + /* 24 */ , "" + /* 25 */ , + "[03500]H~ar ligger Tihocan" + "[05000]...en av de tv^a r~attf~ardiga ledarna i Atlantis..." + "[10000]som ~aven efter att kontinentens f~orbannelse..." + "[13000]...f~ors~okte styra i detta karga, fr~ammande land..." + "[19000]Han dog utan barn och hans kunskaper levde inte vidare..." + "[25500]V~anligen vaka ~over oss, Tihocan." + /* 26 */ , "V~alkommen till mitt hem!@Vi tar en liten rundtur." + /* 27 */ , "Anv~and pilknapparna f~or att g^a till musikrummet." + /* 28 */ , "OK, vi ska r~ora oss lite nu!@Tryck p^a hoppknappen." + /* 29 */ , "Tryck nu p^a den igen och tryck sedan snabbt p^a en av@pilknapparna, och jag hoppar i den riktningen." + /* 30 */ , "Ah, den stora salen. Urs~akta l^adorna.@Jag ska l~agga saker i f~orr^ad och flyttfirman har inte kommit." + /* 31 */ , "Spring fram till en l^ada och medan du h^aller inne pilknappen fram^at,@tryck p^a actionknappen, d^a kl~attrar jag upp." + /* 32 */ , "Detta var en g^ang balsalen, men det ~ar mitt egna gym nu@Vad tycker du? @ Vi g~or n^agra ~ovningar." + /* 33 */ , "Jag springer inte ~overallt. Om jag vill vara f~orsiktig,@ g^ar jag. H^all ner g^a-knappen@och gÃ¥ till den vita linjen." + /* 34 */ , "Med g^a-knappen nedtryckt kan jag inte ramla av kanten@~aven om du f~ors~oker. Prova!." + /* 35 */ , "Om du vill se dig omkring h^aller du ner titta-knappen@och trycker p^a pilknapparna f~or att titta." + /* 36 */ , "Om ett hopp ~ar f~or l^angt f~or mig kan jag@ta tag i kanten och undvika ett otrevligt fall. G^a fram till kanten med den@vita linjen. Tryck sedan p^a hoppknappen@och direkt d~arefter framm^at. Medan jag fortfarande ~ar i luften, tryck och h^all inne actionknappen s^a jag tar tag i kanten." + /* 37 */ , "Tryck p^a pil upp f~or att kl~attra upp" + /* 38 */ , "Om jag springer och hoppar kan jag klara stora hopp utan bekymmer." + /* 39 */ , "G^a till kanten med den vita linjen tills jag stannar. Sl~app sedan@g^a knappen och tryck ner bak^at kort. Jag tar ett litet hopp bak^at. Tryck in pilknappen fram^at och omedelbart d~arefter hopp-knappen@ Jag hoppar i sista stund." + /* 40 */ , "Detta ~ar ett riktigt stort hopp! Starta hoppet precis som f~orut,@ n~ar jag ~ar i luften trycker du p^a actionknappen@och h^aller den nedtryck, s^a kan jag ta tag i kanten." + /* 41 */ , "Bra." + /* 42 */ , "F~ors~ok att kl~attra upp.@Tryck pil upp^at och actionknappen." + /* 43 */ , "Jag kan inte kl~attra upp h~ar eftersom utrymmet ~ar f~or litet.@Men om du trycker p^a knappen f~or h~oger, flyttar jag mig@i sidled tills att det finns tillr~ackligt med utrymme att komma upp." + /* 44 */ , "" + /* 45 */ , "Tryck bak^at s^a hoppar jag bak^at.@Tryck omedelbart p^a actionknappen och h^all ned den s^a att jag@tar tag i kanten n~ar jag faller ner." + /* 46 */ , "Sl~app nu." + /* 47 */ , "L^at oss ta en simtur." + /* 48 */ , "Hoppknappen och v~anster eller h~ogerknappen- samt anv~ands f~or@att styra mig under vatten." + /* 49 */ , "Ah! Luft!@Tryck bara p^a pilknapparna fram^at, v~anster och h~oger,@f~or att r~ora dig runt ytan. Tryck p^a hoppknappen@om du vill att jag ska dyka igen. Eller g^a till kanten och@tryck p^a actionknappen f~or att hoppa ur vattnet." + /* 50 */ , "jag m^aste byta kl~aderna." + /* 51 */ , "Va god le!" + /* 52 */ , "Det ~ar inget personligt." + /* 53 */ , "Du ger mig fortfarande huvudv~ark.@En liten f^agel viskade att jag ska skicka dig till helvetet!" + /* 54 */ , "Jag och mina v~anner f~orsvinner inte s^a l~att, Lara." + /* 55 */ , "Inte lite sent f~or prisutdelningen?@Men den som tar priset har vunnit" + /* 56 */ , "Du skjuter p^a mig?@Du skjuter p^a mig?@Det finns ingen annan h~ar, s^a du m^aste skjuta p^a mig!" +// TR1 levels + , "Lara's Hem" + , "Grottan" + , "Vilcabambas Stad" + , "F~orsvunna Dalen" + , "Qualopecs Gravkammare" + , "S:t Francis Kloster" + , "Kolosseum" + , "Midas Palats" + , "Cisternen" + , "Tihocans Gravkammare" + , "Khamoons Stad" + , "Khamoons Obelisk" + , "Scions Fristad" + , "Natla's Gruva" + , "Atlantis" + , "Den Stora Pyramiden" + , "^Aterv~and till Egypten" + , "Kattens tempel" + , "Atlantiska F~astningen" + , "Kupan" +// TR2 levels + , "Lara's Hem" + , "Den Kinesiska Muren" + , "Venedig" + , "Bartolis G~omst~alle" + , "Operahus" + , "Kustriggen" + , "Dykomr^ade" + , "40 Famnar" + , "Maria Dorias Vrakplats" + , "Hytterna" + , "D~acket" + , "Tibetanska H~ogl~andet" + , "Barkhang-Klostret" + , "Talion-Katakomberna" + , "Ispalatset" + , "Xian-templet" + , "Den Flytande ~On" + , "Drakens Lya" + , "Hem Ljuva Hem" +// TR3 levels + , "Lara's Hem" + , "Djungel" + , "Tempelruinerna" + , "Floden Ganges" + , "Kaliya-Grottorna" + , "Kustby" + , "Kraschplats" + , "Madubu Gorge" + , "Punatemplet" + , "Thames Wharf" + , "Aldwych" + , "Lud's Port" + , "Stad" + , "Nevada~oknen" + , "H~og s~akerhetsanstalten" + , "Area 51" + , "Antarktis" + , "RX-Techs Gruvor" + , "Tinnos F~orlorade Stad" + , "Meteoritgrottan" + , "All Hallows" +}; + +#endif diff --git a/src/lara.h b/src/lara.h index a7f58981..bc893194 100644 --- a/src/lara.h +++ b/src/lara.h @@ -4,7 +4,7 @@ /* Desine sperare qui hic intras */ /*****************************************/ #include "character.h" -#include "trigger.h" +#include "objects.h" #include "sprite.h" #include "enemy.h" #include "inventory.h" @@ -64,10 +64,14 @@ #define LARA_VIBRATE_HIT_TIME 0.2f +#define COLLIDE_MAX_RANGE (1024.0f * 4.0f) + struct Lara : Character { // http://www.tombraiderforums.com/showthread.php?t=148859 enum { + ANIM_RUN = 0, + ANIM_STAND_LEFT = 2, ANIM_STAND_RIGHT = 3, @@ -276,8 +280,6 @@ struct Lara : Character { JOINT_MASK_BRAID = JOINT_MASK_HEAD | JOINT_MASK_CHEST | JOINT_MASK_ARM_L1 | JOINT_MASK_ARM_L2 | JOINT_MASK_ARM_R1 | JOINT_MASK_ARM_R2, }; - bool dozy; - struct Weapon { enum State { IS_HIDDEN, IS_ARMED, IS_FIRING }; struct Anim { @@ -322,6 +324,9 @@ struct Lara : Character { float hitTimer; + bool dozy; + bool canJump; + int32 networkInput; #ifdef _DEBUG @@ -380,7 +385,7 @@ struct Lara : Character { void integrate() { float TIMESTEP = Core::deltaTime; - float ACCEL = 16.0f * GRAVITY * TIMESTEP * TIMESTEP; + float ACCEL = 16.0f * GRAVITY * 30.0f * TIMESTEP * TIMESTEP; float DAMPING = 1.5f; if (lara->stand == STAND_UNDERWATER) { @@ -414,7 +419,7 @@ struct Lara : Character { if (joints[j].pos.y > info.floor) joints[j].pos.y = info.floor; - #define BRAID_RADIUS 16.0f + #define BRAID_RADIUS 0.0f lara->updateJoints(); @@ -493,19 +498,24 @@ struct Lara : Character { mesh->renderModel(lara->level->extra.braid); } - } *braid; + } *braid[2]; - Lara(IGame *game, int entity) : Character(game, entity, LARA_MAX_HEALTH), dozy(false), wpnCurrent(TR::Entity::NONE), wpnNext(TR::Entity::NONE), braid(NULL) { + Lara(IGame *game, int entity) : Character(game, entity, LARA_MAX_HEALTH), wpnCurrent(TR::Entity::NONE), wpnNext(TR::Entity::NONE) { camera = new Camera(game, this); + braid[0] = braid[1] = NULL; + itemHolster = TR::Entity::NONE; hitTimer = 0.0f; networkInput = -1; + dozy = false; + canJump = true; + if (level->extra.laraSkin > -1) level->entities[entity].modelIndex = level->extra.laraSkin + 1; - jointChest = JOINT_CHEST; + jointChest = level->isCutsceneLevel() ? 0 : JOINT_CHEST; jointHead = JOINT_HEAD; rangeChest = vec4(-0.50f, 0.50f, -0.95f, 0.95f) * PI; rangeHead = vec4(-0.30f, 0.30f, -0.55f, 0.55f) * PI; @@ -539,8 +549,26 @@ struct Lara : Character { arms[i].rotAbs = quat(0, 0, 0, 1); } - if (level->extra.braid > -1) - braid = new Braid(this, (level->version & (TR::VER_TR2 | TR::VER_TR3)) ? vec3(-2.0f, -16.0f, -48.0f) : vec3(-4.0f, 24.0f, -48.0f)); + if (level->extra.braid > -1) { + vec3 offset(0.0f); + switch (level->version & TR::VER_VERSION) { + case TR::VER_TR1 : + //braid[0] = new Braid(this, vec3(-4.0f, 24.0f, -48.0f)); // it's just ugly :) + break; + case TR::VER_TR2 : + case TR::VER_TR3 : + braid[0] = new Braid(this, vec3(0.0f, -23.0f, -55.0f)); + break; + case TR::VER_TR4 : + if (isYoung()) { + braid[0] = new Braid(this, vec3(-32.0f, -48.0f, -32.0f)); + braid[1] = new Braid(this, vec3( 32.0f, -48.0f, -32.0f)); + } else { + braid[0] = new Braid(this, vec3(0.0f, -23.0f, -32.0f)); + } + break; + } + } // TR1 //reset(14, vec3(40448, 3584, 60928), PI * 0.5f, STAND_ONWATER); // gym (pool) @@ -618,10 +646,15 @@ struct Lara : Character { virtual ~Lara() { delete camera; - delete braid; + delete braid[0]; + delete braid[1]; delete environment; } + bool isYoung() { + return level->id == TR::LVL_TR4_ANGKOR1 || level->id == TR::LVL_TR4_ANG_RACE; + } + bool canSaveGame() { return health > 0.0f && !burn && state != STATE_USE_KEY @@ -793,7 +826,7 @@ struct Lara : Character { float wpnGetDamage() { switch (wpnCurrent) { case TR::Entity::PISTOLS : return 1; - case TR::Entity::SHOTGUN : return 1; + case TR::Entity::SHOTGUN : return 3; case TR::Entity::MAGNUMS : return 2; case TR::Entity::UZIS : return 1; default : ; @@ -1268,7 +1301,7 @@ struct Lara : Character { updateTargets(); Controller *lookTarget = canLookAt() ? target : NULL; - if (camera->mode == Camera::MODE_LOOK) { + if (canLookAt() && (camera->mode == Camera::MODE_LOOK || (lookTarget == NULL && (camera->viewAngle.x != 0.0f || camera->viewAngle.y != 0.0f)))) { vec3 p = pos + vec3(camera->targetAngle.x, camera->targetAngle.y) * 8192.0f; Character::lookAtPos(&p); } else @@ -1389,7 +1422,7 @@ struct Lara : Character { // flip left and right by relative target direction if (count > 1) { - int side[2] = { 0, 0 }; + float side[2] = { 0, 0 }; vec3 dir = getDir(); dir.y = 0.0f; @@ -1498,7 +1531,7 @@ struct Lara : Character { if (box.intersect(m, from, v, t)) { t *= v.length(); v = v.normal(); - Sphere spheres[MAX_SPHERES]; + Sphere spheres[MAX_JOINTS]; int count = target->getSpheres(spheres); for (int i = 0; i < count; i++) { float st; @@ -1523,11 +1556,12 @@ struct Lara : Character { virtual void cmdJump(const vec3 &vel) { vec3 v = vel; if (state == STATE_HANG_UP) - v.y = (3.0f - sqrtf(-2.0f * GRAVITY / 30.0f * (collision.info[Collision::FRONT].floor - pos.y + 800.0f - 128.0f))); + v.y = (3.0f - sqrtf(-2.0f * GRAVITY * (collision.info[Collision::FRONT].floor - pos.y + 800.0f - 128.0f))); Character::cmdJump(v); } void drawGun(int right) { + wpnCurrent = TR::Entity::PISTOLS; int mask = (right ? JOINT_MASK_ARM_R3 : JOINT_MASK_ARM_L3); // unholster if (layers[1].mask & mask) mask = (layers[1].mask & ~mask) | (right ? JOINT_MASK_LEG_R1 : JOINT_MASK_LEG_L1); // holster @@ -1537,6 +1571,9 @@ struct Lara : Character { } void doBubbles() { + if ((level->version & TR::VER_VERSION) > TR::VER_TR2) { + return; // TODO + } int count = rand() % 3; if (!count) return; game->playSound(TR::SND_BUBBLE, pos, Sound::PAN); @@ -1563,15 +1600,6 @@ struct Lara : Character { } } - void bakeEnvironment() { - flags.invisible = true; - if (!environment) - environment = new Texture(256, 256, FMT_RGBA, OPT_CUBEMAP | OPT_MIPMAPS | OPT_TARGET); - game->renderEnvironment(getRoomIndex(), pos - vec3(0.0f, 384.0f, 0.0f), &environment); - environment->generateMipMap(); - flags.invisible = false; - } - virtual void hit(float damage, Controller *enemy = NULL, TR::HitType hitType = TR::HIT_DEFAULT) { if (dozy || level->isCutsceneLevel()) return; @@ -1650,7 +1678,7 @@ struct Lara : Character { } case TR::HIT_MIDAS : { // generate environment map for reflections - bakeEnvironment(); + bakeEnvironment(environment); // set death animation animation.setAnim(level->models[TR::MODEL_LARA_SPEC].animation + 1); camera->doCutscene(pos, angle.y); @@ -1676,7 +1704,8 @@ struct Lara : Character { } if (hitType == TR::HIT_LAVA) { - for (int i = 0; i < 10; i++) + Flame::add(game, this, 0); + for (int i = 1; i < 10; i++) Flame::add(game, this, rand() % getModel()->mCount); } @@ -1929,6 +1958,53 @@ struct Lara : Character { return false; } + void refreshCamera(const TR::Level::FloorInfo &info) { + const TR::FloorData::TriggerCommand *cameraCmdSwitch = NULL; + const TR::FloorData::TriggerCommand *cameraCmdTarget = NULL; + + int cmdIndex = 0; + + while (cmdIndex < info.trigCmdCount) { + const TR::FloorData::TriggerCommand &cmd = info.trigCmd[cmdIndex++]; + + switch (cmd.action) { + case TR::Action::CAMERA_SWITCH : + ASSERT(!cameraCmdSwitch); + cameraCmdSwitch = &cmd; + cmdIndex++; // skip camera info cmd + break; + case TR::Action::CAMERA_TARGET : + ASSERT(!cameraCmdTarget); + cameraCmdTarget = &cmd; + break; + default : ; + } + } + + if (cameraCmdTarget && camera->mode != Camera::MODE_LOOK && camera->mode != Camera::MODE_COMBAT) { + camera->viewTarget = (Controller*)level->entities[cameraCmdTarget->args].controller; + } + + if (cameraCmdSwitch) { + if (cameraCmdSwitch->args == camera->viewIndexLast) { + camera->viewIndex = camera->viewIndexLast; + + if (camera->mode == Camera::MODE_LOOK || camera->mode == Camera::MODE_COMBAT || camera->timer < 0) { + camera->timer = -1.0f; + camera->viewTarget = NULL; + } else { + camera->mode = Camera::MODE_STATIC; + } + } else { + camera->viewTarget = NULL; + } + } else { + if (viewTarget && camera->viewTarget != camera->viewTargetLast) { + camera->viewTarget = NULL; + } + } + } + void checkTrigger(Controller *controller, bool heavy) { TR::Level::FloorInfo info; getFloorInfo(controller->getRoomIndex(), controller->pos, info); @@ -1940,6 +2016,10 @@ struct Lara : Character { if (!info.trigCmdCount) return; // has no trigger + if (camera->mode != Camera::MODE_HEAVY) { + refreshCamera(info); + } + TR::Limits::Limit *limit = NULL; bool switchIsDown = false; float timer = info.trigInfo.timer == 1 ? EPS : float(info.trigInfo.timer); @@ -2049,14 +2129,14 @@ struct Lara : Character { bool needFlip = false; TR::Effect::Type effect = TR::Effect::NONE; - int cameraIndex = -1; - Controller *cameraTarget = NULL; - while (cmdIndex < info.trigCmdCount) { TR::FloorData::TriggerCommand &cmd = info.trigCmd[cmdIndex++]; switch (cmd.action) { case TR::Action::ACTIVATE : { + if (cmd.args >= level->entitiesBaseCount) { + break; + } TR::Entity &e = level->entities[cmd.args]; Controller *controller = (Controller*)e.controller; ASSERT(controller); @@ -2083,22 +2163,22 @@ struct Lara : Character { } case TR::Action::CAMERA_SWITCH : { TR::FloorData::TriggerCommand &cam = info.trigCmd[cmdIndex++]; - if (level->cameras[cmd.args].flags.once) - break; - if (info.trigger == TR::Level::Trigger::COMBAT) - break; - if (info.trigger == TR::Level::Trigger::SWITCH && info.trigInfo.timer && !switchIsDown) - break; - - if (info.trigger == TR::Level::Trigger::SWITCH || cmd.args != camera->viewIndexLast) { - level->cameras[cmd.args].flags.once |= cam.once; - camera->setView(cmd.args, cam.timer == 1 ? EPS : float(cam.timer), cam.speed); - } + if (!level->cameras[cmd.args].flags.once) { + camera->viewIndex = cmd.args; - if (cmd.args == camera->viewIndexLast) - cameraIndex = cmd.args; + if (!(info.trigger == TR::Level::Trigger::COMBAT) && + !(info.trigger == TR::Level::Trigger::SWITCH && info.trigInfo.timer && !switchIsDown) && + (info.trigger == TR::Level::Trigger::SWITCH || camera->viewIndex != camera->viewIndexLast)) + { + camera->smooth = cam.speed > 0; + camera->mode = heavy ? Camera::MODE_HEAVY : Camera::MODE_STATIC; + camera->timer = cam.timer == 1 ? EPS : float(cam.timer); + camera->speed = cam.speed * 8; + level->cameras[camera->viewIndex].flags.once |= cam.once; + } + } break; } case TR::Action::FLOW : @@ -2132,7 +2212,9 @@ struct Lara : Character { needFlip = true; break; case TR::Action::CAMERA_TARGET : - cameraTarget = (Controller*)level->entities[cmd.args].controller; + if (camera->mode == Camera::MODE_STATIC || camera->mode == Camera::MODE_HEAVY) { + camera->viewTarget = (Controller*)level->entities[cmd.args].controller; + } break; case TR::Action::END : game->loadNextLevel(); @@ -2173,15 +2255,17 @@ struct Lara : Character { game->playTrack(TR::TRACK_TR1_SECRET, true); } break; + case TR::Action::CLEAR_BODIES : + break; + case TR::Action::FLYBY : + cmdIndex++; // TODO + break; + case TR::Action::CUTSCENE : + cmdIndex++; // TODO + break; } } - if (cameraTarget && (camera->mode == Camera::MODE_STATIC || cameraIndex == -1)) - camera->viewTarget = cameraTarget; - - if (!cameraTarget && cameraIndex > -1) - camera->viewIndex = cameraIndex; - if (needFlip) { game->flipMap(); game->setEffect(this, effect); @@ -2220,7 +2304,7 @@ struct Lara : Character { if (stand == STAND_UNDERWATER || stand == STAND_ONWATER) return stand; if (stand == STAND_AIR) { - if (velocity.y > 0.0f && pos.y - waterLevel > 300.0) { + if (velocity.y > 0.0f && pos.y - waterLevel > 300.0f) { stopScreaming(); return STAND_UNDERWATER; } @@ -2242,7 +2326,7 @@ struct Lara : Character { return STAND_AIR; if (stand == STAND_AIR) { - if (velocity.y > 0.0f && pos.y - waterLevel > 300.0) { + if (velocity.y > 0.0f && pos.y - waterLevel > 300.0f) { waterSplash(); pos.y = waterLevel + waterDepth; game->playSound(TR::SND_WATER_SPLASH, pos, Sound::PAN); @@ -2426,7 +2510,7 @@ struct Lara : Character { Block *block = (Block*)e.controller; float oldAngle = block->angle.y; - block->angle.y = angleQuadrant(angle.y) * (PI * 0.5f); + block->angle.y = angleQuadrant(angle.y, 0.25f) * (PI * 0.5f); if (!checkInteraction(block, &TR::Limits::BLOCK, (input & ACTION) != 0)) { block->angle.y = oldAngle; @@ -2452,22 +2536,22 @@ struct Lara : Character { } bool checkClimb() { - if ((input & (FORTH | ACTION)) == (FORTH | ACTION) && (animation.index == ANIM_STAND || animation.index == ANIM_STAND_NORMAL) && emptyHands() && collision.side == Collision::FRONT) { // TODO: get rid of animation.index + if ((input & (FORTH | ACTION)) == (FORTH | ACTION) && !(input & (LEFT | RIGHT)) && (animation.index == ANIM_STAND || animation.index == ANIM_STAND_NORMAL) && emptyHands() && collision.side == Collision::FRONT) { // TODO: get rid of animation.index float floor = collision.info[Collision::FRONT].floor; float ceiling = collision.info[Collision::FRONT].ceiling; float h = pos.y - floor; int aIndex = animation.index; - if (floor == ceiling || h < 256) - ;// do nothing - else if (h <= 2 * 256 + 128) { + bool canClimb = (floor - ceiling >= LARA_HEIGHT) && (h >= 256); + + if (canClimb && h <= 2 * 256 + 128) { aIndex = ANIM_CLIMB_2; pos.y = floor + 512.0f; - } else if (h <= 3 * 256 + 128) { + } else if (canClimb && h <= 3 * 256 + 128) { aIndex = ANIM_CLIMB_3; pos.y = floor + 768.0f; - } else if (h <= 7 * 256 + 128) + } else if (h > 3 * 128 + 128 && h <= 7 * 256 + 128) aIndex = ANIM_CLIMB_JUMP; if (aIndex != animation.index) { @@ -2518,11 +2602,23 @@ struct Lara : Character { return res; } + if (state == STATE_RUN) { + if (animation.index == ANIM_RUN_START) { + canJump = false; + } else if (animation.index == ANIM_RUN) { + if (animation.frameIndex >= 4 && animation.frameIndex <= 5) { + canJump = true; + } + } else { + canJump = true; + } + } + // jump button is pressed if (input & JUMP) { if ((input & FORTH) && state == STATE_FORWARD_JUMP) return STATE_RUN; - if (state == STATE_RUN) + if (state == STATE_RUN && canJump) return STATE_FORWARD_JUMP; if (animation.index == ANIM_SLIDE_BACK) // TODO: animation index? %) return STATE_SLIDE_BACK; @@ -2911,6 +3007,15 @@ struct Lara : Character { } } + void setDozy(bool enable) { + if (enable) { + reset(getRoomIndex(), pos - vec3(0, 512, 0), angle.y, STAND_UNDERWATER); + } else { + stand = getRoom().flags.water ? STAND_UNDERWATER : STAND_AIR; + } + dozy = enable; + } + virtual int getInput() { // TODO: updateInput if (level->isCutsceneLevel()) return 0; @@ -2921,14 +3026,12 @@ struct Lara : Character { int pid = camera->cameraIndex; if (!dozy && ((Input::state[pid][cAction] && Input::state[pid][cJump] && Input::state[pid][cLook] && Input::state[pid][cDash]) || Input::down[ikO])) { - reset(getRoomIndex(), pos - vec3(0, 512, 0), angle.y, STAND_UNDERWATER); - dozy = true; + setDozy(true); return input; } if (dozy && Input::state[pid][cWalk]) { - dozy = false; - stand = getRoom().flags.water ? STAND_UNDERWATER : STAND_AIR; + setDozy(false); return input; } @@ -2952,11 +3055,6 @@ struct Lara : Character { //if (Input::state[pid][cStepRight]) input = WALK | RIGHT; //if (Input::state[pid][cStepLeft]) input = WALK | LEFT; - // scion debug (TODO: remove) - if (Input::down[ikU]) { - // 203 Water roll - animation.setAnim(ANIM_WADE_STAND); - } if (Input::down[ikP]) { switch (level->id) { @@ -2978,6 +3076,9 @@ struct Lara : Character { case TR::LVL_TR1_4 : reset(18, vec3(34914, 11008, 41315), 90 * DEG2RAD); // main hall break; + case TR::LVL_TR1_5 : + reset(74, vec3(52549, -3584, 60871), -150 * DEG2RAD); // main hall + break; case TR::LVL_TR1_6 : reset(73, vec3(73372, 122, 51687), PI * 0.5f); // level 6 (midas hand) break; @@ -3008,55 +3109,50 @@ struct Lara : Character { if (input & LOOK) return input; + if (camera->spectator) + return input; + Input::Joystick &joy = Input::joy[Core::settings.controls[pid].joyIndex]; - if (!((state == STATE_STOP || state == STATE_SURF_TREAD || state == STATE_HANG) && fabsf(joy.L.x) < 0.5f && fabsf(joy.L.y) < 0.5f)) { + vec2 L = joy.L; + + if (!((state == STATE_STOP || state == STATE_SURF_TREAD || state == STATE_HANG) && fabsf(L.x) < 0.5f && fabsf(L.y) < 0.5f)) { bool moving = state == STATE_RUN || state == STATE_WALK || state == STATE_BACK || state == STATE_FAST_BACK || state == STATE_SURF_SWIM || state == STATE_SURF_BACK || state == STATE_FORWARD_JUMP; if (!moving) { - if (fabsf(joy.L.x) < fabsf(joy.L.y)) - joy.L.x = 0.0f; + if (fabsf(L.x) < fabsf(L.y)) + L.x = 0.0f; else - joy.L.y = 0.0f; + L.y = 0.0f; } - if (joy.L.x != 0.0f) { - input |= (joy.L.x < 0.0f) ? LEFT : RIGHT; + if (fabsf(L.x) > INPUT_JOY_DZ_STICK) { + input |= (L.x < 0.0f) ? LEFT : RIGHT; if (moving || stand == STAND_UNDERWATER || stand == STAND_ONWATER) - rotFactor.y = min(fabsf(joy.L.x) / 0.9f, 1.0f); + rotFactor.y = min(fabsf(L.x) / 0.9f, 1.0f); } - if (joy.L.y != 0.0f) { - input |= (joy.L.y < 0.0f) ? FORTH : BACK; + if (fabsf(L.y) > INPUT_JOY_DZ_STICK) { + input |= (L.y < 0.0f) ? FORTH : BACK; if (stand == STAND_UNDERWATER) - rotFactor.x = min(fabsf(joy.L.y) / 0.9f, 1.0f); + rotFactor.x = min(fabsf(L.y) / 0.9f, 1.0f); } } // VR control if (Core::settings.detail.stereo == Core::Settings::STEREO_VR && camera->firstPerson && canFreeRotate()) { + if (!(input & WALK)) { input &= ~(LEFT | RIGHT); } vec3 ang = getAngleAbs(Input::hmd.head.dir().xyz()); - angle.y = ang.y; -// rotFactor = vec2(1.0f); -// ang.y = shortAngle(angle.y, ang.y); -// if (fabsf(ang.y) > 5 * DEG2RAD) -// input |= ang.y < 0.0f ? LEFT : RIGHT; - if (stand == STAND_UNDERWATER) { input &= ~(FORTH | BACK); - angle.x = ang.x; -// ang.x = shortAngle(angle.x, ang.x); -// if (fabsf(ang.x) > 5 * DEG2RAD) -// input |= ang.x < 0.0f ? FORTH : BACK; } } - return input; } @@ -3085,10 +3181,6 @@ struct Lara : Character { || state == STATE_ROLL_END || state == STATE_MIDAS_USE || state == STATE_MIDAS_DEATH - // make me sick! - // || state == STATE_BACK_JUMP - // || state == STATE_LEFT_JUMP - // || state == STATE_RIGHT_JUMP || animation.index == ANIM_CLIMB_2 || animation.index == ANIM_CLIMB_3 || animation.index == ANIM_CLIMB_JUMP; @@ -3114,14 +3206,22 @@ struct Lara : Character { item->flags.invisible = true; game->invAdd(item->getEntity().type, 1); - vec4 p = Core::mViewProj * vec4(item->pos, 1.0f); + vec4 p = game->projectPoint(vec4(item->pos, 1.0f)); + + #ifdef _OS_WP8 + swap(p.x, p.y); + #endif + if (p.w != 0.0f) { p.x = ( p.x / p.w * 0.5f + 0.5f) * UI::width; p.y = (-p.y / p.w * 0.5f + 0.5f) * UI::height; + if (game->getLara(1)) { + p.x *= 0.5f; + } } else p = vec4(UI::width * 0.5f, UI::height * 0.5f, 0.0f, 0.0f); - UI::addPickup(item->getEntity().type, vec2(p.x, p.y)); + UI::addPickup(item->getEntity().type, camera->cameraIndex, vec2(p.x, p.y)); saveStats.pickups++; } pickupListCount = 0; @@ -3158,8 +3258,13 @@ struct Lara : Character { updateLights(); - if (fixRoomIndex() && braid) - braid->update(); + if (fixRoomIndex()) { + for (int i = 0; i < COUNT(braid); i++) { + if (braid[i]) { + braid[i]->update(); + } + } + } } else { switch (usedItem) { case TR::Entity::INV_MEDIKIT_SMALL : @@ -3175,8 +3280,11 @@ struct Lara : Character { } Character::update(); - if (braid) - braid->update(); + for (int i = 0; i < COUNT(braid); i++) { + if (braid[i]) { + braid[i]->update(); + } + } } camera->update(); @@ -3452,7 +3560,7 @@ struct Lara : Character { Controller *controller = (Controller*)e.controller; - if (!controller || !controller->isCollider()) continue; + if (!controller || controller->flags.invisible || !controller->isCollider()) continue; if (e.type == TR::Entity::TRAP_DOOR_1 || e.type == TR::Entity::TRAP_DOOR_2) continue; @@ -3461,24 +3569,29 @@ struct Lara : Character { } else { // fast distance check for object if (e.type != TR::Entity::HAMMER_HANDLE && e.type != TR::Entity::HAMMER_BLOCK && e.type != TR::Entity::SCION_HOLDER) - if (fabsf(pos.x - controller->pos.x) > 2048 || fabsf(pos.z - controller->pos.z) > 2048 || fabsf(pos.y - controller->pos.y) > 2048) continue; + if (fabsf(pos.x - controller->pos.x) > COLLIDE_MAX_RANGE || + fabsf(pos.z - controller->pos.z) > COLLIDE_MAX_RANGE || + fabsf(pos.y - controller->pos.y) > COLLIDE_MAX_RANGE) continue; } + if (e.type == TR::Entity::TRAP_BOULDER && !controller->flags.unused) continue; // boulder should stay still + vec3 dir = pos - vec3(0.0f, 128.0f, 0.0f) - controller->pos; vec3 p = dir.rotateY(controller->angle.y); Box box = controller->getBoundingBoxLocal(); box.expand(vec3(LARA_RADIUS + 50.0f, 0.0f, LARA_RADIUS + 50.0f)); - box.max.y += 768; + box.max.y += LARA_HEIGHT; if (!box.contains(p)) // TODO: Box vs Box or check Lara's head point? (check thor hammer handle) continue; + if (!collide(controller, false)) + continue; + if (e.isEnemy()) { // enemy collision - if (!collide(controller, false)) - continue; // velocity.x = velocity.y = 0.0f; - } else { // door collision + } else { p += box.pushOut2D(p); p = (p.rotateY(-controller->angle.y) + controller->pos) - pos; collisionOffset += vec3(p.x, 0.0f, p.z); @@ -3498,7 +3611,7 @@ struct Lara : Character { } if (level->version & TR::VER_TR1) // TODO: check hit animation indices for TR2 and TR3 - hitDir = angleQuadrant(dir.rotateY(angle.y + PI * 0.5f).angleY()); + hitDir = angleQuadrant(dir.rotateY(angle.y + PI * 0.5f).angleY(), 0.25f); return true; } }; @@ -3506,7 +3619,7 @@ struct Lara : Character { if (lightning && lightning->flash && !lightning->armed) { if (hitDir == -1) hitTime = 0.0f; - hitDir = int(randf() * 4); + hitDir = rand() % 4; } else { hitDir = -1; lightning = NULL; @@ -3514,6 +3627,11 @@ struct Lara : Character { return false; } + #ifdef _OS_3DS // for some reason move() math works incorrect on 3DS + #pragma GCC push_options + #pragma GCC optimize ("O0") + #endif + void move() { vec3 vel = (velocity + flowVelocity) * Core::deltaTime * 30.0f + collisionOffset; vec3 opos(pos), offset(0.0f); @@ -3581,7 +3699,7 @@ struct Lara : Character { if (collision.side == Collision::FRONT) { float floor = collision.info[Collision::FRONT].floor; /* - switch (angleQuadrant(angleExt - angle.y)) { + switch (angleQuadrant(angleExt - angle.y), 0.25f) { case 0 : collision.side = Collision::FRONT; LOG("FRONT\n"); break; case 1 : collision.side = Collision::RIGHT; LOG("RIGHT\n"); break; case 2 : collision.side = Collision::BACK; LOG("BACK\n"); break; @@ -3608,9 +3726,13 @@ struct Lara : Character { case STAND_GROUND : case STAND_HANG : case STAND_WADE : - if (opos.y - floor > (256 * 3 - 128) && state == STATE_RUN) - animation.setAnim(isLeftFoot ? ANIM_SMASH_RUN_LEFT : ANIM_SMASH_RUN_RIGHT); - else if (stand == STAND_HANG) + if (opos.y - floor > (256 * 3 - 128) && state == STATE_RUN) { + if (input & ACTION) { + animation.setAnim(isLeftFoot ? ANIM_STAND_LEFT : ANIM_STAND_RIGHT); + } else { + animation.setAnim(isLeftFoot ? ANIM_SMASH_RUN_LEFT : ANIM_SMASH_RUN_RIGHT); + } + } else if (stand == STAND_HANG) animation.setAnim(ANIM_HANG, -21); else if (state != STATE_ROLL_START && state != STATE_ROLL_END) animation.setAnim((state == STATE_RUN || state == STATE_WALK) ? (isLeftFoot ? ANIM_STAND_LEFT : ANIM_STAND_RIGHT) : ANIM_STAND); @@ -3660,6 +3782,10 @@ struct Lara : Character { if (dozy) stand = STAND_UNDERWATER; } + #ifdef _OS_3DS + #pragma GCC pop_options + #endif + virtual void applyFlow(TR::Camera &sink) { if (stand != STAND_UNDERWATER && stand != STAND_ONWATER) return; @@ -3726,10 +3852,23 @@ struct Lara : Character { if (Core::pass != Core::passShadow && camera->firstPerson && camera->viewIndex == -1 && game->getCamera() == camera) // hide head in first person view // TODO: fix for firstPerson with viewIndex always == -1 visibleMask &= ~JOINT_MASK_HEAD; Controller::render(frustum, mesh, type, caustics); + + if (level->extra.laraJoints > -1) { + const TR::Model *model = getModel(); + for (int i = 0; i < model->mCount; i++) { + joints[i].w = 1.0f; + } + Core::setBasis(joints, model->mCount); + mesh->renderModel(level->extra.laraJoints, caustics); + } + visibleMask = visMask; - if (braid) - braid->render(mesh); + for (int i = 0; i < COUNT(braid); i++) { + if (braid[i]) { + braid[i]->render(mesh); + } + } if (state == STATE_MIDAS_DEATH /* && Core::pass == Core::passCompose */) { game->setRoomParams(getRoomIndex(), Shader::MIRROR, 1.2f, 1.0f, 0.2f, 1.0f, false); @@ -3737,12 +3876,14 @@ struct Lara : Character { game->setRoomParams(getRoomIndex(), Shader::MIRROR, 0.3f, 0.3f, 0.3f, 1.0f, false); Core::updateLights(); */ - environment->bind(sEnvironment); - Core::setBlendMode(bmAlpha); + GAPI::Texture *dtex = Core::active.textures[sDiffuse]; + + environment->bind(sDiffuse); visibleMask ^= 0xFFFFFFFF; Controller::render(frustum, mesh, type, caustics); visibleMask ^= 0xFFFFFFFF; - Core::setBlendMode(bmNone); + + if (dtex) dtex->bind(sDiffuse); } } }; diff --git a/src/level.h b/src/level.h index 7e748898..809333ab 100644 --- a/src/level.h +++ b/src/level.h @@ -8,10 +8,11 @@ #include "enemy.h" #include "camera.h" #include "lara.h" -#include "trigger.h" +#include "objects.h" #include "inventory.h" #include "savegame.h" #include "network.h" +#include "extension.h" #if defined(_DEBUG) && defined(_GAPI_GL) && !defined(_GAPI_GLES) #define DEBUG_RENDER @@ -22,6 +23,7 @@ #endif #define ANIM_TEX_TIMESTEP (10.0f / 30.0f) +#define SKY_TIME_PERIOD (1.0f / 0.005f) extern void loadLevelAsync(Stream *stream, void *userData); @@ -32,18 +34,21 @@ extern int loadSlot; struct Level : IGame { TR::Level level; - Texture *atlas; + Texture *atlasRooms; + Texture *atlasObjects; + Texture *atlasSprites; + Texture *atlasGlyphs; MeshBuilder *mesh; Lara *players[2], *player; Camera *camera; - Texture *shadow; + Texture *shadow[2]; + Texture *scaleTex; struct Params { float time; float waterHeight; - float clipSign; - float clipHeight; + float reserved[2]; } *params; ZoneCache *zoneCache; @@ -58,7 +63,10 @@ struct Level : IGame { bool needRedrawTitleBG; bool needRedrawReflections; bool needRenderGame; + bool needRenderInventory; bool showStats; + bool skyIsVisible; + bool paused; TR::LevelID nextLevel; @@ -69,6 +77,12 @@ struct Level : IGame { float animTexTimer; float statsTimeDelta; + vec3 underwaterColor; + vec4 underwaterFogParams; + vec4 levelFogParams; + + mat4 mLightProj[2]; + // IGame implementation ======== virtual void loadLevel(TR::LevelID id) { sndWater = sndTrack = NULL; @@ -80,13 +94,15 @@ struct Level : IGame { if (nextLevel != TR::LVL_MAX) return; TR::LevelID id = TR::LVL_MAX; - #ifdef _OS_WEB - if (level.id == TR::LVL_TR1_2 && level.version != TR::VER_TR1_PC) - id = TR::LVL_TR1_TITLE; - else - #endif + //#ifdef _OS_WEB + // if (level.id == TR::LVL_TR1_2 && level.version != TR::VER_TR1_PC) + // id = TR::LVL_TR1_TITLE; + // else + //#endif id = (level.isEnd() || level.isHome()) ? level.getTitleId() : TR::LevelID(level.id + 1); + TR::isGameEnded = level.isEnd(); + if (!level.isTitle() && loadSlot == -1) { // update statistics info for current level if (!TR::isCutsceneLevel(level.id) && !level.isHome()) @@ -330,6 +346,11 @@ struct Level : IGame { controller->next = NULL; controller->flags.state = TR::Entity::asNone; if (i >= level.entitiesBaseCount) { + + if (e.type == TR::Entity::ENEMY_SKATEBOARD) { + continue; + } + delete controller; e.controller = NULL; } @@ -338,19 +359,25 @@ struct Level : IGame { } void initShadow() { - delete shadow; + delete shadow[0]; + delete shadow[1]; + shadow[0] = shadow[1] = NULL; + #ifndef FFP if (Core::settings.detail.shadows > Core::Settings::LOW) { if (level.isTitle()) - shadow = new Texture(32, 32, FMT_SHADOW); // init dummy shadow map + shadow[0] = new Texture(32, 32, 1, FMT_SHADOW); // init dummy shadow map else - shadow = new Texture(SHADOW_TEX_SIZE, SHADOW_TEX_SIZE, FMT_SHADOW, OPT_TARGET); - } else - shadow = NULL; + shadow[0] = new Texture(SHADOW_TEX_SIZE, SHADOW_TEX_SIZE, 1, FMT_SHADOW, OPT_TARGET); + } + #endif } virtual void applySettings(const Core::Settings &settings) { - if (settings.detail.filter != Core::settings.detail.filter) - atlas->setFilterQuality(settings.detail.filter); + if (settings.detail.filter != Core::settings.detail.filter) { + atlasRooms->setFilterQuality(settings.detail.filter); + atlasObjects->setFilterQuality(settings.detail.filter); + atlasSprites->setFilterQuality(settings.detail.filter); + } bool rebuildMesh = settings.detail.water != Core::settings.detail.water; bool rebuildAmbient = settings.detail.lighting != Core::settings.detail.lighting; @@ -362,25 +389,28 @@ struct Level : IGame { bool redraw = memcmp(&settings.detail, &Core::settings.detail, sizeof(settings.detail)) != 0; - #ifdef _OS_ANDROID - if ((settings.detail.stereo == Core::Settings::STEREO_VR) ^ (Core::settings.detail.stereo == Core::Settings::STEREO_VR)) - osToggleVR(settings.detail.stereo == Core::Settings::STEREO_VR); - #endif + bool toggleVR = (settings.detail.stereo == Core::Settings::STEREO_VR) ^ (Core::settings.detail.stereo == Core::Settings::STEREO_VR); Core::settings = settings; + if (toggleVR) { + osToggleVR(Core::settings.detail.stereo == Core::Settings::STEREO_VR); + } + Core::setVSync(Core::settings.detail.vsync != 0); Stream::cacheWrite("settings", (char*)&settings, sizeof(settings)); if (rebuildShaders) { + #if !defined(_GAPI_D3D8) && !defined(_GAPI_D3D9) && !defined(_GAPI_D3D11) && !defined(_GAPI_GXM) delete shaderCache; shaderCache = new ShaderCache(); + #endif } if (rebuildMesh) { delete mesh; - mesh = new MeshBuilder(&level, atlas); + mesh = new MeshBuilder(&level, atlasRooms); } if (rebuildAmbient) { @@ -411,10 +441,6 @@ struct Level : IGame { return mesh; } - virtual Texture* getAtlas() { - return atlas; - } - virtual ICamera* getCamera(int index = -1) { if (index == -1) return camera; @@ -444,7 +470,7 @@ struct Level : IGame { virtual uint16 getRandomBox(uint16 zone, uint16 *zones) { ZoneCache::Item *item = zoneCache->getBoxes(zone, zones); - return item->boxes[int(randf() * item->count)]; + return item->boxes[rand() % item->count]; } virtual uint16 findPath(int ascend, int descend, bool big, int boxStart, int boxEnd, uint16 *zones, uint16 **boxes) { @@ -459,6 +485,7 @@ struct Level : IGame { case TR::Entity::BLOCK_2 : case TR::Entity::BLOCK_3 : case TR::Entity::BLOCK_4 : + case TR::Entity::BLOCK_5 : ((Block*)controller)->updateFloor(rise); break; case TR::Entity::MOVING_BLOCK : @@ -477,11 +504,6 @@ struct Level : IGame { updateBlocks(true); } - virtual void setClipParams(float clipSign, float clipHeight) { - params->clipSign = clipSign; - params->clipHeight = clipHeight; - } - virtual void setWaterParams(float height) { params->waterHeight = height; } @@ -492,7 +514,7 @@ struct Level : IGame { } virtual void setShader(Core::Pass pass, Shader::Type type, bool underwater = false, bool alphaTest = false) { - shaderCache->bind(pass, type, (underwater ? ShaderCache::FX_UNDERWATER : 0) | (alphaTest ? ShaderCache::FX_ALPHA_TEST : 0) | ((params->clipHeight != NO_CLIP_PLANE && pass == Core::passCompose) ? ShaderCache::FX_CLIP_PLANE : 0)); + shaderCache->bind(pass, type, (underwater ? ShaderCache::FX_UNDERWATER : 0) | (alphaTest ? ShaderCache::FX_ALPHA_TEST : 0)); } virtual void setRoomParams(int roomIndex, Shader::Type type, float diffuse, float ambient, float specular, float alpha, bool alphaTest = false) { @@ -515,17 +537,6 @@ struct Level : IGame { alphaTest = true; } - setShader(Core::pass, type, room.flags.water, alphaTest); - - if (room.flags.water) { - if (waterCache) - waterCache->bindCaustics(roomIndex); - setWaterParams(float(room.waterLevel[level.state.flags.flipped])); - } else - setWaterParams(NO_CLIP_PLANE); - - Core::active.shader->setParam(uParam, Core::params); - #ifdef FFP switch (type) { case Shader::SPRITE : @@ -545,24 +556,81 @@ struct Level : IGame { } #endif - Core::setMaterial(diffuse, ambient, specular, alpha); + vec4 material; + if (Core::pass == Core::passAmbient) { + if (room.flags.water) { + material = vec4(underwaterColor, 1.0f); + } else { + material = vec4(1.0f); + } + } else { + material = vec4(diffuse, ambient, specular, alpha); + } + + setShader(Core::pass, type, (Core::pass == Core::passAmbient) ? false : room.flags.water, alphaTest); + + if (room.flags.water) { + Core::setFog(underwaterFogParams); + } else { + Core::setFog(levelFogParams); + } + + #ifdef _GAPI_SW + GAPI::setPalette(room.flags.water ? GAPI::swPaletteWater : GAPI::swPaletteColor); + GAPI::setShading(true); + #endif + + Core::setMaterial(material.x, material.y, material.z, material.w); + + if (room.flags.water) { + if (waterCache) { + waterCache->bindCaustics(roomIndex); + } + setWaterParams(float(room.waterLevel[level.state.flags.flipped])); + } else { + setWaterParams(NO_WATER_HEIGHT); + } + + Core::active.shader->setParam(uParam, Core::params); + Core::updateLights(); - if (Core::settings.detail.shadows > Core::Settings::MEDIUM) + if (Core::settings.detail.shadows > Core::Settings::MEDIUM) { Core::active.shader->setParam(uContacts, Core::contacts[0], MAX_CONTACTS); + } } virtual void setupBinding() { - atlas->bind(sDiffuse); Core::whiteTex->bind(sNormal); Core::whiteTex->bind(sMask); Core::whiteTex->bind(sReflect); - Core::whiteCube->bind(sEnvironment); - if (shadow) shadow->bind(sShadow); + atlasRooms->bind(sDiffuse); + + if (Core::pass != Core::passShadow) { + Texture *shadowMap = shadow[player ? player->camera->cameraIndex : 0]; + if (shadowMap) shadowMap->bind(sShadow); + } + Core::basis.identity(); } virtual void renderEnvironment(int roomIndex, const vec3 &pos, Texture **targets, int stride = 0, Core::Pass pass = Core::passAmbient) { + #ifdef FFP + return; + #endif + + #ifdef _GAPI_SW + return; + #endif + + #ifdef _GAPI_C3D + GAPI::rotate90 = false; + #endif + + #ifdef _GAPI_D3D8 + GAPI::setFrontFace(false); + #endif + PROFILE_MARKER("ENVIRONMENT"); setupBinding(); float tmpEye = Core::eye; @@ -576,14 +644,63 @@ struct Level : IGame { for (int i = 0; i < 6; i++) { setupCubeCamera(pos, i); Core::pass = pass; - Texture *target = (targets[0]->opt & OPT_CUBEMAP) ? targets[0] : targets[i * stride]; - Core::setTarget(target, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR, i); - renderView(rIndex, false); + if (targets[0]->opt & OPT_CUBEMAP) { + Core::setTarget(targets[0], NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR, i); + } else { + Core::setTarget(targets[i * stride], NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); + } + renderView(rIndex, false, false); } + #ifdef _GAPI_D3D8 + GAPI::setFrontFace(true); + #endif + + #ifdef _GAPI_C3D + GAPI::rotate90 = true; + #endif + Core::pass = tmpPass; Core::eye = tmpEye; } + + virtual void renderModelFull(int modelIndex, bool underwater, Basis *joints) { + vec4 ambient[6] = { vec4(0), vec4(0), vec4(0), vec4(0), vec4(0), vec4(0) }; + + // opaque + Core::setBlendMode(bmPremult); // inventory items has fade-out/in alpha + mesh->transparent = 0; + setShader(Core::passCompose, Shader::ENTITY, underwater, false); + Core::setBasis(joints, level.models[modelIndex].mCount); + Core::active.shader->setParam(uMaterial, Core::active.material); + Core::active.shader->setParam(uAmbient, ambient[0], 6); + Core::setFog(FOG_NONE); + Core::updateLights(); + mesh->renderModel(modelIndex, underwater); + // transparent + mesh->transparent = 1; + setShader(Core::passCompose, Shader::ENTITY, underwater, true); + Core::setBasis(joints, level.models[modelIndex].mCount); + Core::active.shader->setParam(uMaterial, Core::active.material); + Core::active.shader->setParam(uAmbient, ambient[0], 6); + Core::setFog(FOG_NONE); + Core::updateLights(); + mesh->renderModel(modelIndex, underwater); + // additive + Core::setBlendMode(bmAdd); + Core::setDepthWrite(false); + mesh->transparent = 2; + setShader(Core::passCompose, Shader::ENTITY, underwater, false); + Core::setBasis(joints, level.models[modelIndex].mCount); + Core::active.shader->setParam(uMaterial, Core::active.material); + Core::active.shader->setParam(uAmbient, ambient[0], 6); + Core::setFog(FOG_NONE); + Core::updateLights(); + mesh->renderModel(modelIndex, underwater); + Core::setDepthWrite(true); + Core::setBlendMode(bmNone); + mesh->transparent = 0; + } virtual void setEffect(Controller *controller, TR::Effect::Type effect) { this->effect = effect; @@ -708,6 +825,8 @@ struct Level : IGame { if (level.version == TR::VER_TR1_PSX && id == TR::SND_SECRET) return NULL; + if (!level.soundsInfo) return NULL; + int16 a = level.soundsMap[id]; if (a == -1) return NULL; @@ -738,7 +857,7 @@ struct Level : IGame { void stopChannel(Sound::Sample *channel) { if (channel == sndTrack) { sndTrack = NULL; - if (level.state.flags.track != TR::LEVEL_INFO[level.id].track) // play ambient track + if (level.state.flags.track != TR::LEVEL_INFO[level.id].track && TR::LEVEL_INFO[level.id].track != TR::NO_TRACK) // play ambient track playTrack(0); } } @@ -808,6 +927,8 @@ struct Level : IGame { waitTrack = true; TR::getGameTrack(level.version, track, playAsync, new TrackRequest(this, flags)); + + UI::showSubs(TR::getSubs(level.version, track)); } virtual void stopTrack() { @@ -816,10 +937,12 @@ struct Level : IGame { //============================== Level(Stream &stream) : level(stream), waitTrack(false), isEnded(false), cutsceneWaitTimer(0.0f), animTexTimer(0.0f), statsTimeDelta(0.0f) { + paused = false; + level.simpleItems = Core::settings.detail.simple == 1; level.initModelIndices(); - #ifdef _OS_PSP + #ifdef _GAPI_GU GAPI::freeEDRAM(); #endif nextLevel = TR::LVL_MAX; @@ -831,7 +954,9 @@ struct Level : IGame { memset(players, 0, sizeof(players)); player = NULL; - Core::fogParams = TR::getFogParams(level.id); + underwaterColor = vec3(0.6f, 0.9f, 0.9f); + underwaterFogParams = vec4(underwaterColor * 0.2f, 1.0f / (6 * 1024)); + levelFogParams = TR::getFogParams(level.id); inventory->game = this; @@ -842,10 +967,11 @@ struct Level : IGame { } initTextures(); - mesh = new MeshBuilder(&level, atlas); + mesh = new MeshBuilder(&level, atlasRooms); initEntities(); - shadow = NULL; + shadow[0] = shadow[1] = NULL; + scaleTex = NULL; camera = NULL; ambientCache = NULL; waterCache = NULL; @@ -880,11 +1006,10 @@ struct Level : IGame { } - setClipParams(1.0f, NO_CLIP_PLANE); - effect = TR::Effect::NONE; sndWater = sndTrack = NULL; + UI::init(this); /* if (level.id == TR::LVL_TR2_RIG) { @@ -893,6 +1018,27 @@ struct Level : IGame { } */ + #if DUMP_SAMPLES + for (int i = 0; i < 256; i++) { + int16 a = level.soundsMap[i]; + if (a == -1) continue; + ASSERT(a < level.soundsInfoCount); + TR::SoundInfo &b = level.soundsInfo[a]; + for (int j = 0; j < b.flags.count; j++) { + //ASSERT((b.index + j) < level.soundOffsetsCount); + if ((b.index + j) < level.soundOffsetsCount) { + Debug::Level::dumpSample(&level, b.index + j, i, j); + } + } + } + loadNextLevel(); + #endif + + #if DUMP_PALETTE + Debug::Level::dumpPalette(&level, level.id); + loadNextLevel(); + #endif + saveResult = SAVE_RESULT_SUCCESS; if (loadSlot != -1 && saveSlots[loadSlot].getLevelID() == level.id) { parseSaveSlot(saveSlots[loadSlot]); @@ -905,17 +1051,26 @@ struct Level : IGame { } virtual ~Level() { + UI::init(NULL); + Network::stop(); for (int i = 0; i < level.entitiesCount; i++) delete (Controller*)level.entities[i].controller; - delete shadow; + delete shadow[0]; + delete shadow[1]; + delete scaleTex; delete ambientCache; delete waterCache; delete zoneCache; - delete atlas; + delete atlasRooms; + #ifndef SPLIT_BY_TILE + delete atlasObjects; + delete atlasSprites; + delete atlasGlyphs; + #endif delete mesh; Sound::stopAll(); @@ -950,6 +1105,14 @@ struct Level : IGame { void addPlayer(int index) { if (level.isCutsceneLevel()) return; + Controller *c = Controller::first; + while (c) { + Controller *next = c->next; + if (c->getEntity().type == TR::Entity::FLAME && ((Flame*)c)->owner == players[index]) + removeEntity(c); + c = next; + } + if (!players[index]) { players[index] = (Lara*)addEntity(TR::Entity::LARA, 0, vec3(0.0f), 0.0f); players[index]->camera->cameraIndex = index; @@ -963,14 +1126,6 @@ struct Level : IGame { Lara *lead = players[index ^ 1]; if (!lead) return; - Controller *c = Controller::first; - while (c) { - Controller *next = c->next; - if (c->getEntity().type == TR::Entity::FLAME && ((Flame*)c)->owner == players[index]) - removeEntity(c); - c = next; - } - players[index]->reset(lead->getRoomIndex(), lead->pos, lead->angle.y, lead->stand); } @@ -983,6 +1138,7 @@ struct Level : IGame { } } } + removeEntity(players[index]); players[index] = NULL; } @@ -1051,7 +1207,8 @@ struct Level : IGame { case TR::Entity::BLOCK_1 : case TR::Entity::BLOCK_2 : case TR::Entity::BLOCK_3 : - case TR::Entity::BLOCK_4 : return new Block(this, index); + case TR::Entity::BLOCK_4 : + case TR::Entity::BLOCK_5 : return new Block(this, index); case TR::Entity::MOVING_BLOCK : return new MovingBlock(this, index); case TR::Entity::TRAP_CEILING_1 : case TR::Entity::TRAP_CEILING_2 : return new TrapCeiling(this, index); @@ -1137,6 +1294,7 @@ struct Level : IGame { case TR::Entity::ENEMY_MERCENARY_SNOWMOBILE : case TR::Entity::ENEMY_MONK_1 : case TR::Entity::ENEMY_MONK_2 : return new Enemy(this, index, 100, 10, 0.0f, 0.0f); + case TR::Entity::ENEMY_WINSTON : return new Winston(this, index); case TR::Entity::CRYSTAL_PICKUP : return new CrystalPickup(this, index); case TR::Entity::STONE_ITEM_1 : @@ -1147,14 +1305,44 @@ struct Level : IGame { case TR::Entity::WINDOW_1 : case TR::Entity::WINDOW_2 : return new BreakableWindow(this, index); + case TR::Entity::HELICOPTER_FLYING : return new HelicopterFlying(this, index); + + case TR::Entity::FISH_EMITTER : return new DummyController(this, index); + default : return new Controller(this, index); } } - TR::Tile32 *tileData; + #define ATLAS_PAGE_BARS 4096 + #define ATLAS_PAGE_GLYPHS 8192 + + AtlasTile *tileData; + uint8 *glyphsRU; + uint8 *glyphsJA; + uint8 *glyphsGR; + uint8 *glyphsCN; - static void fillCallback(int id, int tileX, int tileY, int atlasWidth, int atlasHeight, Atlas::Tile &tile, void *userData, void *data) { - static const uint32 barColor[UI::BAR_MAX][25] = { + static int getAdvGlyphPage(int index) { + index -= UI::advGlyphsStart; + if (index >= RU_GLYPH_COUNT) { + index -= RU_GLYPH_COUNT; + if (index >= JA_GLYPH_COUNT) { + index -= JA_GLYPH_COUNT; + if (index >= GR_GLYPH_COUNT) { + index -= GR_GLYPH_COUNT; + return 4 + index / 256; // CN + } else { + return 3; // GR + } + } else { + return 1 + index / 256; // JA + } + } + return 0; // RU + } + + static void fillCallback(Atlas *atlas, int id, int tileX, int tileY, int atlasWidth, int atlasHeight, Atlas::Tile &tile, void *userData, void *data) { + static const uint32 CommonTexData[CTEX_MAX][25] = { // flash bar { 0x00000000, 0xFFA20058, 0xFFFFFFFF, 0xFFA20058, 0x00000000 }, // health bar @@ -1167,7 +1355,11 @@ struct Level : IGame { 0x00000000, 0x80808080, 0x80808080, 0x80808080, 0x00000000, 0x00000000, 0x60606060, 0x60606060, 0x60606060, 0x00000000, 0x00000000, 0x20202020, 0x20202020, 0x20202020, 0x00000000 }, - // white bar (white tile) + // white room + { 0xFFFFFFFF }, + // white object + { 0xFFFFFFFF }, + // white sprite { 0xFFFFFFFF }, }; @@ -1177,28 +1369,56 @@ struct Level : IGame { Level *owner = (Level*)userData; TR::Level *level = &owner->level; - Color32 *src, *dst = (Color32*)data; + AtlasColor *src, *dst = (AtlasColor*)data; short4 mm; - + + bool isSprite = false; + if (id < level->objectTexturesCount) { // textures TR::TextureInfo &t = level->objectTextures[id]; mm = t.getMinMax(); src = owner->tileData->color; uv = t.texCoordAtlas; uvCount = 4; - if (data) + if (data) { level->fillObjectTexture(owner->tileData, tile.uv, tile.tex); + } } else { id -= level->objectTexturesCount; if (id < level->spriteTexturesCount) { // sprites TR::TextureInfo &t = level->spriteTextures[id]; - mm = t.getMinMax(); - src = owner->tileData->color; - uv = t.texCoordAtlas; - uvCount = 2; - if (data) - level->fillObjectTexture(owner->tileData, tile.uv, tile.tex); + mm = t.getMinMax(); + src = owner->tileData->color; + uv = t.texCoordAtlas; + uvCount = 2; + isSprite = true; + if (data) { + if (id < UI::advGlyphsStart) { + level->fillObjectTexture(owner->tileData, tile.uv, tile.tex); + } else { + int page = getAdvGlyphPage(id); + int offset = ATLAS_PAGE_GLYPHS + page * 256; + short4 uv = tile.uv; + uv.y -= offset; + uv.w -= offset; + Color32 *glyphsData = NULL; + + switch (page) { + case 0 : glyphsData = (Color32*)owner->glyphsRU; break; + case 1 : + case 2 : glyphsData = (Color32*)owner->glyphsJA + (page - 1) * 256 * 256; break; + case 3 : glyphsData = (Color32*)owner->glyphsGR; break; + case 4 : + case 5 : + case 6 : + case 7 : glyphsData = (Color32*)owner->glyphsCN + (page - 4) * 256 * 256; break; + default : ASSERT(false); + } + + level->fillObjectTexture32(owner->tileData, glyphsData, uv, tile.tex); + } + } } else { // common (generated) textures id -= level->spriteTexturesCount; @@ -1208,25 +1428,30 @@ struct Level : IGame { uvCount = 4; switch (id) { - case UI::BAR_FLASH : - case UI::BAR_HEALTH : - case UI::BAR_OXYGEN : - case UI::BAR_OPTION : - case UI::BAR_WHITE : - src = (Color32*)&barColor[id][0]; - tex = &barTile[id]; - if (id != UI::BAR_WHITE) { + case CTEX_FLASH : + case CTEX_HEALTH : + case CTEX_OXYGEN : + case CTEX_OPTION : + case CTEX_WHITE_ROOM : + case CTEX_WHITE_OBJECT : + case CTEX_WHITE_SPRITE : + src = owner->tileData->color; + tex = &CommonTex[id]; + if (id != CTEX_WHITE_ROOM && id != CTEX_WHITE_OBJECT && id != CTEX_WHITE_SPRITE) { mm.w = 4; // height - 1 - if (id == UI::BAR_OPTION) { + if (id == CTEX_OPTION) { stride = 5; mm.z = 4; } } + + for (int i = 0; i < (mm.z + 1) * (mm.w + 1); i++) { + src[i] = ((Color32*)&CommonTexData[id])[i]; + } break; default : return; } - memset(tex, 0, sizeof(*tex)); uv = tex->texCoordAtlas; uv[2].y += mm.w; uv[3].y += mm.w; @@ -1241,20 +1466,25 @@ struct Level : IGame { int w = mm.z - mm.x + 1; int h = mm.w - mm.y + 1; dst += tileY * atlasWidth + tileX; - for (int y = -ATLAS_BORDER; y < h + ATLAS_BORDER; y++) { - for (int x = -ATLAS_BORDER; x < w + ATLAS_BORDER; x++) { - Color32 *p = &src[mm.y * stride + mm.x]; - ASSERT((x + ATLAS_BORDER + tileX) >= 0 && (x + ATLAS_BORDER + tileX) < atlasWidth); - ASSERT((y + ATLAS_BORDER + tileY) >= 0 && (y + ATLAS_BORDER + tileY) < atlasHeight); + for (int y = -atlas->border.y; y < h + atlas->border.w; y++) { + for (int x = -atlas->border.x; x < w + atlas->border.z; x++) { + AtlasColor *p = &src[mm.y * stride + mm.x]; + ASSERT((x + atlas->border.x + tileX) >= 0 && (x + atlas->border.x + tileX) < atlasWidth); + ASSERT((y + atlas->border.y + tileY) >= 0 && (y + atlas->border.y + tileY) < atlasHeight); p += clamp(x, 0, w - 1); p += clamp(y, 0, h - 1) * stride; - dst[x + ATLAS_BORDER] = *p; + + if (isSprite && (y < 0 || y >= h || x < 0 || x >= w)) { + dst[x + atlas->border.x].value = 0; + } else { + dst[x + atlas->border.x] = *p; + } } dst += atlasWidth; } - cx += tileX + ATLAS_BORDER; - cy += tileY + ATLAS_BORDER; + cx += tileX + atlas->border.x; + cy += tileY + atlas->border.y; } for (int i = 0; i < uvCount; i++) { @@ -1275,10 +1505,11 @@ struct Level : IGame { mm = level->objectTextures[ref].getMinMaxAtlas(); } else { ref -= level->objectTexturesCount; - if (ref < level->spriteTexturesCount) // sprites + if (ref < level->spriteTexturesCount) { // sprites mm = level->spriteTextures[ref].getMinMaxAtlas(); - else - ASSERT(false); // only object textures and sprites may be instanced + } else { + ASSERT(!"only object textures and sprites can be instanced"); + } } for (int i = 0; i < uvCount; i++) { @@ -1286,8 +1517,11 @@ struct Level : IGame { uv[i].y += mm.y; } } -/* + +#ifdef _DEBUG void dumpGlyphs() { + ASSERT(level.tiles8); + TR::SpriteSequence &seq = level.spriteSequences[level.extra.glyphs]; short2 size = short2(0, 0); for (int i = 0; i < seq.sCount; i++) { @@ -1311,28 +1545,92 @@ struct Level : IGame { for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { - TR::Tile32 &tile = level.tiles[sprite.tile]; - - data[pos.x + x + (pos.y + y) * size.x] = tile.color[sprite.texCoord[0].x + x + (sprite.texCoord[0].y + y) * 256]; + Tile8 &tile = level.tiles8[sprite.tile]; + + data[pos.x + x + (pos.y + y) * size.x] = level.getColor(tile.index[sprite.texCoord[0].x + x + (sprite.texCoord[0].y + y) * 256]); } pos.y += h + 1; } - Texture::SaveBMP("psx_glyph.bmp", (char*)data, size.x, size.y); + Texture::SaveBMP("pc_glyph.bmp", (char*)data, size.x, size.y); delete[] data; } -*/ + + void dumpKanji() { + Stream stream("DATA/KANJI.PSX"); + int size = stream.readLE32() / 2; + ColorIndex4 *buffer = new ColorIndex4[size]; + stream.raw(buffer, size); + int width = 256; + int height = size / width * 2; + + Color32 *image = new Color32[width * height]; + + Tile4 *tile = (Tile4*)buffer; + CLUT &clut = level.cluts[level.spriteTextures[level.kanjiSprite].clut]; + + ColorIndex4 *idx = buffer; + Color32 *ptr = image; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x += 2) { + *ptr++ = clut.color[idx->a]; + *ptr++ = clut.color[idx->b]; + idx++; + } + } + + Texture::SaveBMP("kanji", (char*)image, width, height); + + delete[] buffer; + delete[] image; + } +#endif + void initTextures() { #ifndef SPLIT_BY_TILE - #ifdef _OS_PSP + #if defined(_GAPI_SW) || defined(_GAPI_GU) #error atlas packing is not allowed for this platform #endif - //dumpGlyphs(); + #ifdef _DEBUG + //dumpGlyphs(); + //dumpKanji(); + #endif + + UI::patchGlyphs(level); + + { + uint32 glyphsW, glyphsH; + Stream stream(NULL, GLYPH_RU, size_GLYPH_RU); + glyphsRU = Texture::LoadPNG(stream, glyphsW, glyphsH); + } + + { + uint32 glyphsW, glyphsH; + Stream stream(NULL, GLYPH_JA, size_GLYPH_JA); + glyphsJA = Texture::LoadBMP(stream, glyphsW, glyphsH); + } + + { + uint32 glyphsW, glyphsH; + Stream stream(NULL, GLYPH_GR, size_GLYPH_GR); + glyphsGR = Texture::LoadBMP(stream, glyphsW, glyphsH); + } + + { + uint32 glyphsW, glyphsH; + Stream stream(NULL, GLYPH_CN, size_GLYPH_CN); + glyphsCN = Texture::LoadBMP(stream, glyphsW, glyphsH); + } // repack texture tiles - Atlas *tiles = new Atlas(level.objectTexturesCount + level.spriteTexturesCount + UI::BAR_MAX, this, fillCallback); + int maxTiles = level.objectTexturesCount + level.spriteTexturesCount + CTEX_MAX; + Atlas *rAtlas = new Atlas(maxTiles, short4(4, 4, 4, 4), this, fillCallback); + Atlas *oAtlas = new Atlas(maxTiles, short4(4, 4, 4, 4), this, fillCallback); + Atlas *sAtlas = new Atlas(maxTiles, short4(4, 4, 4, 4), this, fillCallback); + Atlas *gAtlas = new Atlas(maxTiles, short4(0, 0, 1, 1), this, fillCallback); // add textures for (int i = 0; i < level.objectTexturesCount; i++) { TR::TextureInfo &t = level.objectTextures[i]; @@ -1344,7 +1642,10 @@ struct Level : IGame { uv.z = max(max(t.texCoord[0].x, t.texCoord[1].x), t.texCoord[2].x) + 1; uv.w = max(max(t.texCoord[0].y, t.texCoord[1].y), t.texCoord[2].y) + 1; - tiles->add(i, uv, &t); + if (t.type == TR::TEX_TYPE_ROOM) + rAtlas->add(i, uv, &t); + else + oAtlas->add(i, uv, &t); } // add sprites for (int i = 0; i < level.spriteTexturesCount; i++) { @@ -1357,34 +1658,92 @@ struct Level : IGame { uv.z = t.texCoord[1].x + 1; uv.w = t.texCoord[1].y + 1; - tiles->add(level.objectTexturesCount + i, uv, &t); + if (i >= UI::advGlyphsStart) { + // add virtual UV offset for additional glyph sprites + int offset = ATLAS_PAGE_GLYPHS + getAdvGlyphPage(i) * 256; + uv.y += offset; + uv.w += offset; + } + + if (level.extra.glyphs != -1) { + TR::SpriteSequence &seq = level.spriteSequences[level.extra.glyphs]; + if ((i >= seq.sStart && i < seq.sStart + seq.sCount) || i >= UI::advGlyphsStart) { + gAtlas->add(level.objectTexturesCount + i, uv, &t); + continue; + } + } + sAtlas->add(level.objectTexturesCount + i, uv, &t); } // add common textures - const short2 bar[UI::BAR_MAX] = { short2(0, 4), short2(0, 4), short2(0, 4), short2(4, 4), short2(0, 0) }; - for (int i = 0; i < UI::BAR_MAX; i++) { - barTile[i].type = TR::TEX_TYPE_SPRITE; - tiles->add(level.objectTexturesCount + level.spriteTexturesCount + i, short4(i * 32, 4096, i * 32 + bar[i].x, 4096 + bar[i].y), &barTile[i]); + const short2 CommonTexOffset[] = { short2(1, 5), short2(1, 5), short2(1, 5), short2(5, 5), short2(1, 1), short2(1, 1), short2(1, 1) }; + ASSERT(COUNT(CommonTexOffset) == CTEX_MAX); + memset(CommonTex, 0, sizeof(CommonTex)); + for (int i = 0; i < CTEX_MAX; i++) { + CommonTex[i].type = CommonTex[i].dataType = TR::TEX_TYPE_SPRITE; + Atlas *dst = (i == CTEX_FLASH || i == CTEX_WHITE_OBJECT) ? oAtlas : ((i == CTEX_WHITE_ROOM) ? rAtlas : gAtlas); + dst->add(level.objectTexturesCount + level.spriteTexturesCount + i, short4(i * 32, ATLAS_PAGE_BARS, i * 32 + CommonTexOffset[i].x, ATLAS_PAGE_BARS + CommonTexOffset[i].y), &CommonTex[i]); } // get result texture - tileData = new TR::Tile32(); + tileData = new AtlasTile(); - atlas = tiles->pack(); + atlasRooms = rAtlas->pack(OPT_MIPMAPS | OPT_VRAM_3DS); + atlasObjects = oAtlas->pack(OPT_MIPMAPS); + atlasSprites = sAtlas->pack(OPT_MIPMAPS); + atlasGlyphs = gAtlas->pack(0); + + #ifdef _OS_3DS + ASSERT(atlasRooms->width <= 1024 && atlasRooms->height <= 1024); + ASSERT(atlasObjects->width <= 1024 && atlasObjects->height <= 1024); + ASSERT(atlasSprites->width <= 1024 && atlasSprites->height <= 1024); + #endif + delete[] tileData; tileData = NULL; - atlas->setFilterQuality(Core::settings.detail.filter); - - delete tiles; - - LOG("atlas: %d x %d\n", atlas->width, atlas->height); - PROFILE_LABEL(TEXTURE, atlas->ID, "atlas"); + delete[] glyphsRU; + delete[] glyphsJA; + delete[] glyphsGR; + delete[] glyphsCN; + + glyphsRU = NULL; + glyphsJA = NULL; + glyphsGR = NULL; + glyphsCN = NULL; + + atlasRooms->setFilterQuality(Core::settings.detail.filter); + atlasObjects->setFilterQuality(Core::settings.detail.filter); + atlasSprites->setFilterQuality(Core::settings.detail.filter); + atlasGlyphs->setFilterQuality(Core::Settings::MEDIUM); + + delete rAtlas; + delete oAtlas; + delete sAtlas; + delete gAtlas; + + LOG("rooms : %d x %d\n", atlasRooms->width, atlasRooms->height); + LOG("objects : %d x %d\n", atlasObjects->width, atlasObjects->height); + LOG("sprites : %d x %d\n", atlasSprites->width, atlasSprites->height); + LOG("glyphs : %d x %d\n", atlasGlyphs->width, atlasGlyphs->height); + PROFILE_LABEL(TEXTURE, atlasRooms->ID, "atlas_rooms"); + PROFILE_LABEL(TEXTURE, atlasObjects->ID, "atlas_objects"); + PROFILE_LABEL(TEXTURE, atlasSprites->ID, "atlas_sprites"); + PROFILE_LABEL(TEXTURE, atlasGlyphs->ID, "atlas_glyphs"); #else ASSERT(level.tilesCount); - #ifdef _OS_PSP - atlas = new Texture(level.tiles4, level.tilesCount, level.cluts, level.clutsCount); + #if defined(_GAPI_SW) + atlasRooms = + atlasObjects = + atlasSprites = + atlasGlyphs = new Texture(level.tiles8, level.tilesCount); + GAPI::initPalette(level.palette, level.lightmap); + #elif defined(_GAPI_GU) + atlasRooms = + atlasObjects = + atlasSprites = + atlasGlyphs = new Texture(level.tiles4, level.tilesCount, level.cluts, level.clutsCount); #else Texture::Tile *tiles = new Texture::Tile[level.tilesCount]; for (int i = 0; i < level.tilesCount; i++) { @@ -1397,7 +1756,7 @@ struct Level : IGame { short4 uv = t.getMinMax(); uv.z++; uv.w++; - level.fillObjectTexture((TR::Tile32*)tiles[t.tile].data, uv, &t); + level.fillObjectTexture((AtlasTile*)tiles[t.tile].data, uv, &t); } for (int i = 0; i < level.spriteTexturesCount; i++) { @@ -1405,25 +1764,30 @@ struct Level : IGame { short4 uv = t.getMinMax(); uv.z++; uv.w++; - level.fillObjectTexture((TR::Tile32*)tiles[t.tile].data, uv, &t); + level.fillObjectTexture((AtlasTile*)tiles[t.tile].data, uv, &t); } for (int i = 0; i < level.tilesCount; i++) { char buf[256]; sprintf(buf, "texture/%s_%d.png", TR::LEVEL_INFO[level.id].name, i); if (Stream::exists(buf)) { + Stream stream(buf); delete[] tiles[i].data; - tiles[i].data = (uint32*)Texture::LoadPNG(Stream(buf), tiles[i].width, tiles[i].height); + tiles[i].data = (uint32*)Texture::LoadPNG(stream, tiles[i].width, tiles[i].height); } } - atlas = new Texture(tiles, level.tilesCount); + atlasRooms = + atlasObjects = + atlasSprites = + atlasGlyphs = new Texture(tiles, level.tilesCount); for (int i = 0; i < level.tilesCount; i++) delete[] tiles[i].data; delete[] tiles; #endif + #ifndef _GAPI_SW for (int i = 0; i < level.objectTexturesCount; i++) { TR::TextureInfo &t = level.objectTextures[i]; @@ -1460,6 +1824,7 @@ struct Level : IGame { t.texCoord[1].y += 16; */ } + #endif #endif } @@ -1468,10 +1833,18 @@ struct Level : IGame { TR::Entity &e = level.entities[i]; if (e.type == TR::Entity::CRYSTAL) { Crystal *c = (Crystal*)e.controller; - renderEnvironment(c->getRoomIndex(), c->pos - vec3(0, 512, 0), &c->environment); - c->environment->generateMipMap(); + if (c->environment) { // already initialized and baked + continue; + } + c->bake(); + + #ifdef _GAPI_C3D + // C3D has a limit of GX commands for buffers clearing (GX_MemoryFill), so we limit render to one cubemap per frame + return; + #endif } } + needRedrawReflections = false; } void setMainLight(Controller *controller) { @@ -1480,46 +1853,86 @@ struct Level : IGame { } void renderSky() { - if (level.extra.sky == -1) return; + #if !defined(_GAPI_GL) && !defined(_GAPI_D3D11) + return; + #endif + ASSERT(mesh->transparent == 0); - mat4 m = Core::mViewProj; + Shader::Type type; + TR::SkyParams skyParams; + + if (level.version & TR::VER_TR1) { + if (Core::settings.detail.lighting < Core::Settings::HIGH || !Core::support.tex3D || !TR::getSkyParams(level.id, skyParams)) + return; + type = Shader::SKY_AZURE; + } else { // TR2, TR3 + if (level.extra.sky == -1) + return; + + if (Core::settings.detail.lighting < Core::Settings::HIGH || !Core::support.tex3D) { + type = Shader::DEFAULT; + } else { + type = Shader::SKY_CLOUDS; + if (!TR::getSkyParams(level.id, skyParams)) { + type = Shader::DEFAULT; + } + } + } + + if (type != Shader::DEFAULT && !Core::perlinTex) { + type = Shader::DEFAULT; + if (level.version & TR::VER_TR1) { + return; + } + } + + Core::Pass pass = Core::pass; mat4 mView = Core::mView; - mView.setPos(vec3(0)); - Core::mViewProj = Core::mProj * mView; + mat4 mProj = Core::mProj; - //Animation anim(&level, &level.models[level.extra.sky]); + Core::mView.setPos(vec3(0)); + Core::setViewProj(Core::mView, Core::mProj); - // TODO TR2 TR3 use animation frame to get skydome rotation - Basis b; - if (level.version & TR::VER_TR2) - b = Basis(quat(vec3(1, 0, 0), PI * 0.5f), vec3(0)); - else - b = Basis(quat(0, 0, 0, 1), vec3(0)); + setShader(Core::passSky, type, false, false); - Core::setBlendMode(bmNone); - Core::setDepthTest(false); - setShader(Core::pass, Shader::FLASH, false, false); - Core::setMaterial(1.0f / 1.8f, 0.0f, 0.0f, 0.0f); + if (type != Shader::DEFAULT) { + float time = Core::params.x; + if (time > SKY_TIME_PERIOD) { + time /= SKY_TIME_PERIOD; + time = (time - int(time)) * SKY_TIME_PERIOD; + } - // anim.getJoints(Basis(quat(0, 0, 0, 1), vec3(0)), 0, false));//Basis(anim.getJointRot(0), vec3(0))); - Core::setBasis(&b, 1); + Core::active.shader->setParam(uParam, vec4(skyParams.wind * time * 2.0f, 1.0)); + Core::active.shader->setParam(uLightProj, *(mat4*)&skyParams); + Core::active.shader->setParam(uPosScale, skyParams.cloudDownColor, 2); - mesh->transparent = 0; - mesh->renderModel(level.extra.sky); + Core::perlinTex->bind(sNormal); + Core::ditherTex->bind(sMask); + } - Core::setDepthTest(true); - Core::mViewProj = m; + if (level.version & TR::VER_TR1) { + Core::setCullMode(cmNone); + mesh->renderBox(); + Core::setCullMode(cmFront); + } else { + Basis b; + Core::setBasis(&b, 1); // unused + mesh->renderModel(level.extra.sky); + } + + Core::setViewProj(mView, mProj); + Core::pass = pass; } - void prepareRooms(int *roomsList, int roomsCount) { - bool hasSky = false; + void prepareRooms(RoomDesc *roomsList, int roomsCount) { + skyIsVisible = (level.version & TR::VER_TR1); for (int i = 0; i < level.roomsCount; i++) level.rooms[i].flags.visible = false; for (int i = 0; i < roomsCount; i++) { - TR::Room &r = level.rooms[roomsList[i]]; - hasSky |= r.flags.sky; + TR::Room &r = level.rooms[roomsList[i].index]; + skyIsVisible |= r.flags.sky; r.flags.visible = true; } @@ -1538,12 +1951,41 @@ struct Level : IGame { } setMainLight(player); + } - if (hasSky) - renderSky(); + short4 getPortalRect(const vec4 &v, short4 vp) { + //vec4 s = vec4(v.x, -v.w, v.z, -v.y); + vec4 sp = (v * 0.5 + 0.5) * vec4(float(vp.z), float(vp.w), float(vp.z), float(vp.w)); + + short4 s(short(sp.x) + vp.x, short(sp.y) + vp.y, short(sp.z)+ vp.x, short(sp.w) + vp.y); + + // expand + s.x -= 2; + s.y -= 2; + s.z += 2; + s.w += 2; + + // clamp + s.x = max(s.x, vp.x); + s.y = max(s.y, vp.y); + s.z = min(s.z, short(vp.x + vp.z)); + s.w = min(s.w, short(vp.y + vp.w)); + + // convert from bounds to x,y,w,h + s.z -= s.x; + s.w -= s.y; + + // Use the viewport rect if one of the dimensions is the same size + // as the viewport. This may fix clipping bugs while still allowing + // impossible geometry tricks. + if (s.z - s.x >= vp.z - vp.x || s.w - s.y >= vp.w - vp.y) { + return vp; + } + + return s; } - void renderRooms(int *roomsList, int roomsCount, int transp) { + void renderRooms(RoomDesc *roomsList, int roomsCount, int transp) { PROFILE_MARKER("ROOMS"); if (Core::pass == Core::passShadow) @@ -1570,8 +2012,12 @@ struct Level : IGame { dir = -1; } + atlasRooms->bind(sDiffuse); + + short4 vp = Core::scissor; + while (i != end) { - int roomIndex = roomsList[i]; + int roomIndex = roomsList[i].index; MeshBuilder::RoomRange &range = mesh->rooms[roomIndex]; if (!range.geometry[transp].count && !range.dynamic[transp].count) { @@ -1579,9 +2025,16 @@ struct Level : IGame { continue; } - setRoomParams(roomIndex, Shader::ROOM, 1.0f, intensityf(level.rooms[roomIndex].ambient), 0.0f, 1.0f, transp == 1); + Core::setScissor(getPortalRect(roomsList[i].portal, vp)); + + const TR::Room &room = level.rooms[roomIndex]; - basis.pos = level.rooms[roomIndex].getOffset(); + vec3 center = room.getCenter(); + int ambient = room.getAmbient(int(center.x), int(center.y), int(center.z)); + + setRoomParams(roomIndex, Shader::ROOM, 1.0f, intensityf(ambient), 0.0f, 1.0f, transp == 1); + + basis.pos = room.getOffset(); Core::setBasis(&basis, 1); Core::mModel.setPos(basis.pos); @@ -1595,6 +2048,8 @@ struct Level : IGame { Core::setDepthWrite(true); if (transp == 1) { + atlasSprites->bind(sDiffuse); + Core::setBlendMode(bmPremult); #ifdef MERGE_SPRITES @@ -1604,14 +2059,16 @@ struct Level : IGame { #endif for (int i = 0; i < roomsCount; i++) { - level.rooms[roomsList[i]].flags.visible = true; + int roomIndex = roomsList[i].index; + level.rooms[roomIndex].flags.visible = true; - int roomIndex = roomsList[i]; MeshBuilder::RoomRange &range = mesh->rooms[roomIndex]; if (!range.sprites.iCount) continue; + Core::setScissor(getPortalRect(roomsList[i].portal, vp)); + setRoomParams(roomIndex, Shader::SPRITE, 1.0f, 1.0f, 0.0f, 1.0f, true); basis.pos = level.rooms[roomIndex].getOffset(); @@ -1621,6 +2078,7 @@ struct Level : IGame { } } + Core::setScissor(vp); Core::setBlendMode(bmNone); } @@ -1659,25 +2117,35 @@ struct Level : IGame { type = Shader::MIRROR; if (isModel) { // model - float intensity = controller->intensity < 0.0f ? intensityf(room.ambient) : controller->intensity; + ASSERT(controller->intensity >= 0.0f); - setMainLight(controller); - setRoomParams(roomIndex, type, 1.0f, intensity, controller->specular, 1.0f, mesh->transparent == 1); + setMainLight(level.isCutsceneLevel() ? player : controller); + setRoomParams(roomIndex, type, 1.0f, controller->intensity, controller->specular, 1.0f, mesh->transparent == 1); vec3 pos = controller->getPos(); if (ambientCache) { - if (!controller->getEntity().isDoor() && !controller->getEntity().isBlock()) { // no advanced ambient lighting for secret (all) doors and blocks + if (!entity.isDoor() && !entity.isBlock() && !entity.isPickup()) { // no advanced ambient lighting for secret (all) doors and blocks AmbientCache::Cube cube; ambientCache->getAmbient(roomIndex, pos, cube); - if (cube.status == AmbientCache::Cube::READY) + if (cube.status == AmbientCache::Cube::READY) { memcpy(controller->ambient, cube.colors, sizeof(cube.colors)); // store last calculated ambient into controller + } } else { - controller->ambient[0] = - controller->ambient[1] = - controller->ambient[2] = - controller->ambient[3] = - controller->ambient[4] = - controller->ambient[5] = vec4(Core::active.material.y); + if (entity.isPickup()) { + controller->ambient[0] = + controller->ambient[1] = + controller->ambient[5] = + controller->ambient[4] = vec4(Core::active.material.y * 0.8f); + controller->ambient[2] = vec4(Core::active.material.y * 0.1f); + controller->ambient[3] = vec4(Core::active.material.y); + } else { + controller->ambient[0] = + controller->ambient[1] = + controller->ambient[2] = + controller->ambient[3] = + controller->ambient[4] = + controller->ambient[5] = vec4(Core::active.material.y); + } } Core::active.shader->setParam(uAmbient, controller->ambient[0], 6); } @@ -1686,6 +2154,14 @@ struct Level : IGame { controller->render(camera->frustum, mesh, type, room.flags.water); } + void loadNextLevelData() { + isEnded = true; + char buf[64]; + TR::getGameLevelFile(buf, level.version, nextLevel); + nextLevel = TR::LVL_MAX; + new Stream(buf, loadLevelAsync); + } + void update() { if (isEnded) return; @@ -1703,6 +2179,7 @@ struct Level : IGame { if (inventory->video) { inventory->update(); + UI::update(); return; } @@ -1729,15 +2206,17 @@ struct Level : IGame { if ((Input::lastState[0] == cInventory || Input::lastState[1] == cInventory) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active) { int playerIndex = (Input::lastState[0] == cInventory) ? 0 : 1; - if (level.isCutsceneLevel()) { // skip cutscene level - loadNextLevel(); - return; - } + if (getLara(playerIndex)) { + if (level.isCutsceneLevel()) { // skip cutscene level + loadNextLevel(); + return; + } - if (player->health <= 0.0f) - inventory->toggle(playerIndex, Inventory::PAGE_OPTION, TR::Entity::INV_PASSPORT); - else - inventory->toggle(playerIndex); + if (player->health <= 0.0f) + inventory->toggle(playerIndex, Inventory::PAGE_OPTION, TR::Entity::INV_PASSPORT); + else + inventory->toggle(playerIndex); + } } bool invActive = inventory->isActive(); @@ -1753,11 +2232,7 @@ struct Level : IGame { showStats = false; return; } - isEnded = true; - char buf[64]; - TR::getGameLevelFile(buf, level.version, nextLevel); - nextLevel = TR::LVL_MAX; - new Stream(buf, loadLevelAsync); + loadNextLevelData(); return; } @@ -1769,12 +2244,15 @@ struct Level : IGame { return; } - UI::update(); + if (!inventory->isActive()) { + UI::update(); + } float volWater, volTrack; if (invActive || level.isTitle()) { Sound::reverb.setRoomSize(vec3(1.0f)); + Sound::listener[0].underwater = false; volWater = 0.0f; volTrack = level.isTitle() ? 0.9f : 0.0f; } else { @@ -1787,25 +2265,35 @@ struct Level : IGame { } } - params->time += Core::deltaTime; - animTexTimer += Core::deltaTime; + if (camera->spectator && Input::lastState[0] == cStart) { + paused = !paused; + } - float timeStep = ANIM_TEX_TIMESTEP; - if (level.version & TR::VER_TR1) - timeStep *= 0.5f; + if (!paused) { + params->time += Core::deltaTime; + animTexTimer += Core::deltaTime; - if (animTexTimer > timeStep) { - level.shiftAnimTex(); - animTexTimer -= timeStep; - } + float timeStep = ANIM_TEX_TIMESTEP; + if (level.version & TR::VER_TR1) + timeStep *= 0.5f; - updateEffect(); + if (animTexTimer > timeStep) { + level.shiftAnimTex(); + animTexTimer -= timeStep; + } - Controller *c = Controller::first; - while (c) { - Controller *next = c->next; - c->update(); - c = next; + updateEffect(); + + Controller *c = Controller::first; + while (c) { + Controller *next = c->next; + c->update(); + c = next; + } + } else { + if (camera->spectator) { + camera->update(); + } } if (waterCache) @@ -1821,8 +2309,11 @@ struct Level : IGame { sndWater->volume = sndWater->volumeTarget = 0.0f; } volWater = 1.0f; - } else + } else { volWater = 0.0f; + } + + Sound::listener[0].underwater = (volWater == 1.0f); volTrack = 1.0f; } @@ -1850,6 +2341,13 @@ struct Level : IGame { } #endif #endif + + #ifdef GEOMETRY_EXPORT + if (Input::down[ikF1]) { + Extension::exportGeometry(this, atlasRooms, atlasObjects, atlasSprites); + Input::down[ikF1] = false; + } + #endif } void updateEffect() { @@ -1895,6 +2393,8 @@ struct Level : IGame { void renderEntitiesTransp(int transp) { mesh->dynBegin(); mesh->transparent = transp; + + atlasObjects->bind(sDiffuse); for (int i = 0; i < level.entitiesCount; i++) { TR::Entity &e = level.entities[i]; if (!e.controller || e.modelIndex == 0) continue; @@ -1905,9 +2405,10 @@ struct Level : IGame { PROFILE_MARKER("ENTITY_SPRITES"); if (mesh->dynICount) { + atlasSprites->bind(sDiffuse); Core::lightPos[0] = vec4(0, 0, 0, 0); Core::lightColor[0] = vec4(0, 0, 0, 1); - setRoomParams(0, Shader::SPRITE, 1.0f, 1.0f, 0.0f, 1.0f, mesh->transparent == 1); + setRoomParams(getLara()->getRoomIndex(), Shader::SPRITE, 1.0f, 1.0f, 0.0f, 1.0f, mesh->transparent == 1); Basis b; b.w = 1.0f; @@ -1939,10 +2440,9 @@ struct Level : IGame { Core::setBlendMode(bmPremult); renderEntitiesTransp(transp); - #ifdef FFP - Core::whiteTex->bind(0); - #endif - + #ifndef FFP + Core::setFog(FOG_NONE); + Core::whiteTex->bind(sDiffuse); Core::setBlendMode(bmMult); for (int i = 0; i < level.entitiesCount; i++) { TR::Entity &entity = level.entities[i]; @@ -1951,10 +2451,7 @@ struct Level : IGame { controller->renderShadow(mesh); } Core::setBlendMode(bmNone); - - #ifdef FFP - atlas->bind(0); - #endif + #endif } if (transp == 2) { @@ -1965,6 +2462,20 @@ struct Level : IGame { } } + virtual vec4 projectPoint(const vec4 &p) { + vec4 res; + res = Core::mViewProj * p; + + #ifdef _OS_3DS + if (GAPI::rotate90) { + res.y = -res.y; + swap(res.x, res.y); + } + #endif + + return res; + } + bool checkPortal(const TR::Room &room, const TR::Room::Portal &portal, const vec4 &viewPort, vec4 &clipPort) { vec3 n = portal.normal; vec3 v = Core::viewPos.xyz() - (room.getOffset() + portal.vertices[0]); @@ -1978,10 +2489,10 @@ struct Level : IGame { clipPort = vec4(INF, INF, -INF, -INF); for (int i = 0; i < 4; i++) { - p[i] = Core::mViewProj * vec4(vec3(portal.vertices[i]) + room.getOffset(), 1.0f); + p[i] = projectPoint(vec4(vec3(portal.vertices[i]) + room.getOffset(), 1.0f)); if (p[i].w > 0.0f) { - p[i].xyz() *= (1.0f / p[i].w); + p[i].xy() *= (1.0f / p[i].w); clipPort.x = min(clipPort.x, p[i].x); clipPort.y = min(clipPort.y, p[i].y); @@ -2036,21 +2547,19 @@ struct Level : IGame { return true; } - virtual void getVisibleRooms(int *roomsList, int &roomsCount, int from, int to, const vec4 &viewPort, bool water, int count = 0) { - if (count > 16) { + virtual void getVisibleRooms(RoomDesc *roomsList, int &roomsCount, int from, int to, const vec4 &viewPort, bool water, int count = 0) { + if (roomsCount >= 255 || count > 16) { //ASSERT(false); return; } TR::Room &room = level.rooms[to]; - if (!room.flags.visible) { - if (Core::pass == Core::passCompose && water && waterCache && from != TR::NO_ROOM && (level.rooms[from].flags.water ^ level.rooms[to].flags.water)) - waterCache->setVisible(from, to); + if (Core::pass == Core::passCompose && water && waterCache && from != TR::NO_ROOM && (level.rooms[from].flags.water ^ level.rooms[to].flags.water)) + waterCache->setVisible(from, to); - room.flags.visible = true; - roomsList[roomsCount++] = to; - } + room.flags.visible = true; + roomsList[roomsCount++] = RoomDesc(to, viewPort); vec4 clipPort; for (int i = 0; i < room.portalsCount; i++) { @@ -2064,31 +2573,40 @@ struct Level : IGame { } } - void renderOpaque(int *roomsList, int roomsCount) { + void renderOpaque(RoomDesc *roomsList, int roomsCount) { renderRooms(roomsList, roomsCount, 0); renderEntities(0); + if (Core::pass != Core::passShadow && skyIsVisible) { + renderSky(); + } } - void renderTransparent(int *roomsList, int roomsCount) { + void renderTransparent(RoomDesc *roomsList, int roomsCount) { renderRooms(roomsList, roomsCount, 1); renderEntities(1); } - void renderAdditive(int *roomsList, int roomsCount) { - vec4 oldFog = Core::fogParams; - Core::fogParams = FOG_BLACK; // don't apply fog for additive + void renderAdditive(RoomDesc *roomsList, int roomsCount) { + // don't apply fog for additive geometry + vec4 oldLevelFogParams = levelFogParams; + vec4 oldUnderwaterFogParams = underwaterFogParams; + levelFogParams = FOG_NONE; + underwaterFogParams = FOG_NONE; + renderRooms(roomsList, roomsCount, 2); renderEntities(2); - Core::fogParams = oldFog; + + levelFogParams = oldLevelFogParams; + underwaterFogParams = oldUnderwaterFogParams; } - virtual void renderView(int roomIndex, bool water, int roomsCount = 0, int *roomsList = NULL) { + virtual void renderView(int roomIndex, bool water, bool showUI, int roomsCount = 0, RoomDesc *roomsList = NULL) { PROFILE_MARKER("VIEW"); if (water && waterCache) waterCache->reset(); - int rList[256]; + RoomDesc rList[256]; if (!roomsList) { roomsList = rList; @@ -2111,21 +2629,21 @@ struct Level : IGame { // add other non-alternative rooms for (int i = 0; i < level.roomsCount; i++) if (!level.rooms[i].flags.visible) - roomsList[roomsCount++] = i; + roomsList[roomsCount++] = RoomDesc(i, vec4(-1.0f, -1.0f, 1.0f, 1.0f)); // refresh visible flag for (int i = 0; i < level.roomsCount; i++) level.rooms[i].flags.visible = false; for (int i = 0; i < roomsCount; i++) - level.rooms[roomsList[i]].flags.visible = true; + level.rooms[roomsList[i].index].flags.visible = true; } else getVisibleRooms(roomsList, roomsCount, TR::NO_ROOM, roomIndex, vec4(-1.0f, -1.0f, 1.0f, 1.0f), water); } if (water && waterCache) { for (int i = 0; i < roomsCount; i++) - waterCache->setVisible(roomsList[i]); + waterCache->setVisible(roomsList[i].index); waterCache->renderReflection(); @@ -2145,19 +2663,32 @@ struct Level : IGame { Texture *screen = NULL; if (water) { screen = (waterCache && waterCache->visible) ? waterCache->getScreenTex() : NULL; - Core::setTarget(screen, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR | (screen ? RT_STORE_DEPTH : 0)); // render to screen texture (FUCK YOU iOS!) or back buffer + + int clearFlags = RT_STORE_COLOR; + + if (screen) { + clearFlags |= RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_DEPTH; + } + + #ifndef EARLY_CLEAR + clearFlags |= RT_CLEAR_COLOR | RT_CLEAR_DEPTH; + #endif + + Core::setTarget(screen, NULL, clearFlags); // render to screen texture or back buffer + Core::validateRenderState(); setupBinding(); } prepareRooms(roomsList, roomsCount); - renderOpaque(roomsList, roomsCount); renderTransparent(roomsList, roomsCount); if (camera->isUnderwater()) renderAdditive(roomsList, roomsCount); + Core::setFog(FOG_NONE); + Core::setBlendMode(bmNone); if (water && waterCache && waterCache->visible) { Core::Pass pass = Core::pass; @@ -2177,15 +2708,22 @@ struct Level : IGame { if (!camera->isUnderwater()) renderAdditive(roomsList, roomsCount); + Core::setFog(FOG_NONE); + Core::setBlendMode(bmNone); Core::Pass pass = Core::pass; if (water && waterCache && waterCache->visible && screen) { - Core::setTarget(NULL, RT_STORE_COLOR); + Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR); + Core::validateRenderState(); waterCache->blitTexture(screen); } + if (showUI) { + renderUI(); + } + Core::pass = pass; } @@ -2203,7 +2741,12 @@ struct Level : IGame { Core::mViewInv = mat4(pos, pos + dir, up); Core::mView = Core::mViewInv.inverseOrtho(); - Core::mProj = GAPI::perspective(90, 1.0f, camera->znear, camera->zfar); + Core::mProj = GAPI::perspective(90, 1.0f, 32.0f, 45.0f * 1024.0f, 0.0f); + + #ifdef _GAPI_D3D8 + Core::mProj.scale(vec3(1.0f, -1.0f, 1.0f)); + #endif + Core::mViewProj = Core::mProj * Core::mView; Core::viewPos = Core::mViewInv.offset().xyz(); @@ -2218,23 +2761,42 @@ struct Level : IGame { Core::mViewInv = mat4(player->mainLightPos, pos, vec3(0, -1, 0)); Core::mView = Core::mViewInv.inverseOrtho(); - Core::mProj = GAPI::perspective(90.0f, 1.0f, znear, zfar); + Core::mProj = GAPI::perspective(90.0f, 1.0f, znear, zfar, 0.0f); - Core::mLightProj = Core::mProj * Core::mView; + mat4 &m = mLightProj[player->camera->cameraIndex]; + m = Core::mProj * Core::mView; mat4 bias; - bias.identity(); - bias.e03 = bias.e13 = bias.e23 = bias.e00 = bias.e11 = bias.e22 = 0.5f; - #if defined(_GAPI_D3D9) || defined(_GAPI_GXM) - bias.e11 = -bias.e11; + + if (GAPI::getProjRange() == mat4::PROJ_ZERO_POS) + bias = mat4( + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.0f, 1.0f + ); + else { + bias = mat4( + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f + ); + } + + #if defined(_GAPI_D3D8) || defined(_GAPI_D3D9) || defined(_GAPI_D3D11) || defined(_GAPI_GXM) + bias.e11 = -bias.e11; // vertical flip for UVs #endif - Core::mLightProj = bias * Core::mLightProj; + + m = bias * m; + + Core::mLightProj = m; camera->frustum->pos = Core::viewPos.xyz(); camera->frustum->calcPlanes(Core::mViewProj); setup(); - renderView(roomIndex, false); + renderView(roomIndex, false, false); } /* void renderShadowEntity(int index, Controller *controller, Controller *player) { @@ -2336,7 +2898,7 @@ struct Level : IGame { return count; } */ - void renderShadows(int roomIndex) { + void renderShadows(int roomIndex, Texture *shadowMap) { PROFILE_MARKER("PASS_SHADOW"); if (Core::settings.detail.shadows == Core::Settings::LOW) @@ -2348,16 +2910,16 @@ struct Level : IGame { Core::eye = 0.0f; Core::pass = Core::passShadow; - shadow->unbind(sShadow); - bool colorShadow = shadow->fmt == FMT_RGBA ? true : false; + shadowMap->unbind(sShadow); + bool colorShadow = shadowMap->fmt == FMT_RGBA ? true : false; if (colorShadow) Core::setClearColor(vec4(1.0f)); - Core::setTarget(shadow, RT_CLEAR_DEPTH | (colorShadow ? (RT_CLEAR_COLOR | RT_STORE_COLOR) : RT_STORE_DEPTH)); + Core::setTarget(shadowMap, NULL, RT_CLEAR_DEPTH | (colorShadow ? (RT_CLEAR_COLOR | RT_STORE_COLOR) : RT_STORE_DEPTH)); //Core::setCullMode(cmBack); Core::validateRenderState(); /* - if (Core::settings.detail.shadows > Core::Settings::Quality::MEDIUM) { // per-object shadow map (atlas) + if (Core::settings.detail.shadows > Core::Settings::MEDIUM) { // per-object shadow map (atlas) NearObj nearObj[SHADOW_OBJ_MAX]; int nearCount = getNearObjects(nearObj, SHADOW_OBJ_MAX); @@ -2376,6 +2938,11 @@ struct Level : IGame { if (colorShadow) Core::setClearColor(vec4(0.0f)); + #ifdef _GAPI_D3D11 // TODO render pass + Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_CLEAR_COLOR | RT_STORE_COLOR | RT_STORE_DEPTH); + Core::validateRenderState(); + #endif + Core::eye = oldEye; } @@ -2476,17 +3043,17 @@ struct Level : IGame { Core::setDepthTest(false); Core::validateRenderState(); // Debug::Level::rooms(level, lara->pos, lara->getEntity().room); - // Debug::Level::lights(level, player->getRoomIndex(), player); + // Debug::Level::lights(level, player->getRoomIndex(), player); // Debug::Level::sectors(this, players[0]->getRoomIndex(), (int)players[0]->pos.y); // Core::setDepthTest(false); // Debug::Level::portals(level); // Core::setDepthTest(true); // Debug::Level::meshes(level); // Debug::Level::entities(level); - // Debug::Level::zones(level, lara); + // Debug::Level::zones(this, players[0]); // Debug::Level::blocks(level); - // Debug::Level::path(level, (Enemy*)level.entities[105].controller); - // Debug::Level::debugOverlaps(level, lara->box); + // Debug::Level::path(level, (Enemy*)level.entities[21].controller); + // Debug::Level::debugOverlaps(level, players[0]->box); // Debug::Level::debugBoxes(level, lara->dbgBoxes, lara->dbgBoxesCount); Core::setDepthTest(true); Core::setBlendMode(bmNone); @@ -2580,13 +3147,13 @@ struct Level : IGame { } #endif - void setViewport(int view, int eye, bool isUI) { + float setViewport(int view, int eye) { int vX = Core::x; int vY = Core::y; int vW = Core::width; int vH = Core::height; - float aspect = float(vW) / float(vH); + float aspect = float(vW) / float(vH) * Core::aspectFix; if (Core::defaultTarget) { vX = 0; @@ -2595,298 +3162,388 @@ struct Level : IGame { vH = Core::defaultTarget->height; } - Viewport &vp = Core::viewportDef; + short4 &vp = Core::viewportDef; + vp = short4(vX, vY, vW, vH); - if (players[1] != NULL) { - vp = Viewport(vX + vW / 2 * view, vY, vW / 2, vH); - if (Core::settings.detail.stereo != Core::Settings::STEREO_SPLIT) + if (players[1] != NULL && view >= 0) { + vp = short4(vX + vW / 2 * view, vY, vW / 2, vH); + + if (Core::settings.detail.stereo != Core::Settings::STEREO_SPLIT) { aspect *= 0.5f; - } else - vp = Viewport(vX, vY, vW, vH); - - if (Core::settings.detail.stereo != Core::Settings::STEREO_VR) { + } + } + + if (Core::settings.detail.stereo == Core::Settings::STEREO_SBS) { switch (eye) { - case -1 : vp = Viewport(vX + vp.x - vp.x / 2, vY + vp.y, vp.width / 2, vp.height); break; - case +1 : vp = Viewport(vX + vW / 2 + vp.x / 2, vY + vp.y, vp.width / 2, vp.height); break; + case -1 : vp = short4(vX + vp.x - vp.x / 2, vY + vp.y, vp.z / 2, vp.w); break; + case +1 : vp = short4(vX + vW / 2 + vp.x / 2, vY + vp.y, vp.z / 2, vp.w); break; } } - Core::eye = float(eye); - Core::setViewport(vp.x, vp.y, vp.width, vp.height); + Core::setViewport(vp.x, vp.y, vp.z, vp.w); - if (isUI) - UI::updateAspect(aspect); - else - camera->aspect = aspect; + return aspect; } void renderPrepare() { - if (inventory->video) { - inventory->render(1.0); - return; - } + setupBinding(); + + #ifdef _OS_3DS + static float sliderState = -1.0f; + + float slider = osGet3DSliderState(); + bool isStereo = slider > 0.0f && !inventory->video; + + if (gfxIs3D() != isStereo) { + gfxSet3D(isStereo); + needRedrawTitleBG = inventory->active && !level.isTitle(); + } + + Core::settings.detail.stereo = isStereo ? Core::Settings::STEREO_ANAGLYPH : Core::Settings::STEREO_OFF; + + if (slider != sliderState) { + sliderState = slider; + needRedrawTitleBG = inventory->active && !level.isTitle(); + } + #else + if (Core::settings.detail.stereo == Core::Settings::STEREO_ANAGLYPH) { + for (int i = 0; i < 2; i++) { + Texture *&tex = Core::eyeTex[i]; + if (!tex || tex->origWidth != Core::width || tex->origHeight != Core::height) { + delete tex; + tex = new Texture(Core::width, Core::height, 1, FMT_RGBA, OPT_TARGET | OPT_NEAREST); + } + } + } + #endif needRenderGame = !inventory->video && !level.isTitle() && ((inventory->phaseRing < 1.0f && inventory->titleTimer <= 1.0f) || needRedrawTitleBG); + needRenderInventory = inventory->video || level.isTitle() || inventory->phaseRing > 0.0f || inventory->titleTimer > 0.0f; - if (!needRenderGame) + bool title = inventory->isActive() || level.isTitle(); + bool copyBg = title && (lastTitle != title || needRedrawTitleBG); + lastTitle = title; + needRedrawTitleBG = false; + + if (!needRenderGame && !copyBg) return; if (needRedrawReflections) { initReflections(); - needRedrawReflections = false; } - if (ambientCache) + if (ambientCache) { ambientCache->processQueue(); + } - if (shadow && player) - renderShadows(player->getRoomIndex()); - } + #ifndef FFP + if (shadow[0] && players[0]) { + player = players[0]; + renderShadows(player->getRoomIndex(), shadow[0]); - void renderGame(bool showUI) { - //if (Core::settings.detail.stereo || Core::settings.detail.splitscreen) { - // Core::setTarget(NULL, CLEAR_ALL); - // Core::validateRenderState(); - //} + if (players[1]) { + if (!shadow[1]) { + shadow[1] = new Texture(shadow[0]->origWidth, shadow[0]->origHeight, 1, shadow[0]->fmt, shadow[0]->opt); + } -/* // catsuit test - lara->bakeEnvironment(); - lara->visibleMask = Lara::BODY_HEAD | Lara::BODY_ARM_L3 | Lara::BODY_ARM_R3; -*/ + player = players[1]; + renderShadows(player->getRoomIndex(), shadow[1]); + } + } + #endif -/* - // EQUIRECTANGULAR PROJECTION test - if (!cube360) - cube360 = new Texture(1024, 1024, Texture::RGBA, true, NULL, true, false); - renderEnvironment(camera->getRoomIndex(), camera->pos, &cube360, 0, Core::passCompose); - Core::setTarget(NULL, Core::CLEAR_ALL); - setShader(Core::passFilter, Shader::FILTER_EQUIRECTANGULAR); - cube360->bind(sEnvironment); - mesh->renderQuad(); - return; -*/ - Viewport vp = Core::viewportDef; + if (copyBg) { + inventory->prepareBackground(); + } + } - int viewsCount = players[1] ? 2 : 1; - for (int view = 0; view < viewsCount; view++) { - player = players[view]; - camera = player->camera; + void setDefaultTarget(int eye, int view, bool invBG) { + int texIndex = eye <= 0 ? 0 : 1; - setClipParams(1.0f, NO_CLIP_PLANE); - params->waterHeight = params->clipHeight; + if (invBG) { + if (Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT) { + Core::defaultTarget = inventory->getBackgroundTarget(view); + } else { + Core::defaultTarget = inventory->getBackgroundTarget(texIndex); + } + } else { + if (Core::settings.detail.stereo == Core::Settings::STEREO_ANAGLYPH || Core::settings.detail.stereo == Core::Settings::STEREO_VR) { + Core::defaultTarget = Core::eyeTex[texIndex]; + } else { + #ifdef _OS_3DS + Core::defaultTarget = Core::eyeTex[0]; + #endif + } + } - if (shadow) { - if (view > 0/* && Core::settings.detail.shadows < Core::Settings::HIGH*/) - renderShadows(player->getRoomIndex()); // render shadows for player2 for all-in-one shadow technique - shadow->bind(sShadow); + if (Core::defaultTarget) { + Core::viewportDef = short4(0, 0, Core::defaultTarget->origWidth, Core::defaultTarget->origHeight); + } else { + Core::viewportDef = short4(0, 0, Core::width, Core::height); + } + + #ifdef EARLY_CLEAR + if (view == 0 && eye <= 0) { + Core::setTarget(NULL, NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR | RT_STORE_DEPTH); + Core::validateRenderState(); } + #endif + } - Core::pass = Core::passCompose; - /* - if (view == 0 && Input::hmd.ready) { - Core::settings.detail.vr = true; + void renderEye(int eye, bool showUI, bool invBG) { + float oldEye = Core::eye; + GAPI::Texture *oldTarget = Core::defaultTarget; - Texture *oldTarget = Core::defaultTarget; - vec4 vp = Core::viewportDef; + Core::eye = float(eye); - Core::defaultTarget = Core::eyeTex[0]; - Core::viewportDef = vec4(0, 0, float(Core::defaultTarget->width), float(Core::defaultTarget->height)); - Core::setTarget(NULL, CLEAR_ALL); - Core::eye = -1.0f; - setup(); - renderView(camera->getRoomIndex(), true); + #ifdef _OS_3DS + Core::eye *= osGet3DSliderState() * 3.25f; + #endif - Core::defaultTarget = Core::eyeTex[1]; - Core::viewportDef = vec4(0, 0, float(Core::defaultTarget->width), float(Core::defaultTarget->height)); - Core::setTarget(NULL, CLEAR_ALL); - Core::eye = 1.0f; - setup(); - renderView(camera->getRoomIndex(), true); + if (needRenderGame || invBG) { + int viewsCount = players[1] ? 2 : 1; + for (int view = 0; view < viewsCount; view++) { + player = players[view]; + camera = player->camera; - Core::settings.detail.vr = false; + Core::mLightProj = mLightProj[view]; - Core::defaultTarget = oldTarget; - Core::setTarget(NULL, CLEAR_ALL); - Core::viewportDef = vp; - } - */ - if (Core::settings.detail.stereo == Core::Settings::STEREO_ON) { // left/right SBS stereo - float oldEye = Core::eye; + Core::pass = Core::passCompose; - setViewport(view, -1, false); - setup(); - renderView(camera->getRoomIndex(), true); + short4 oldViewport = Core::viewportDef; - setViewport(view, 1, false); - setup(); - renderView(camera->getRoomIndex(), true); + setDefaultTarget(eye, view, invBG); + + if (Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT) { + camera->aspect = setViewport(invBG ? -1 : view, invBG ? 0 : eye); + } else { + camera->aspect = setViewport(view, invBG ? 0 : eye); + } - Core::eye = oldEye; - } else { - setViewport(view, int(Core::eye), false); setup(); - renderView(camera->getRoomIndex(), true); + renderView(camera->getRoomIndex(), true, showUI); + + Core::viewportDef = oldViewport; } } - if (showUI) { - Core::Pass pass = Core::pass; + if (needRenderInventory && !invBG) { + if (players[1] && Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT) { + renderInventoryEye(eye, 0); + renderInventoryEye(eye, 1); + } else { + renderInventoryEye(eye, -1); + } + } - for (int view = 0; view < viewsCount; view++) { - player = players[view]; - camera = player->camera; + Core::defaultTarget = oldTarget; + Core::eye = oldEye; - setClipParams(1.0f, NO_CLIP_PLANE); - params->waterHeight = params->clipHeight; + Core::setViewport(Core::viewportDef); + Core::setScissor(Core::viewportDef); - if (Core::settings.detail.stereo == Core::Settings::STEREO_ON) { // left/right SBS stereo - float oldEye = Core::eye; + player = players[0]; + if (player) { + camera = player->camera; + } + } - setViewport(view, -1, false); - renderUI(); + void renderGame(bool showUI, bool invBG) { + short4 oldViewport = Core::viewportDef; + GAPI::Texture *oldTarget = Core::defaultTarget; - setViewport(view, 1, false); - renderUI(); + bool upscale = !invBG && Core::settings.detail.scale != Core::Settings::SCALE_100; - Core::eye = oldEye; - } else { - setViewport(view, int(Core::eye), false); - renderUI(); - } + if (upscale) { + int scale = (Core::settings.detail.scale + 1) * 25; + int w = Core::width * scale / 100; + int h = Core::height * scale / 100; + if (!scaleTex || scaleTex->width != w || scaleTex->height != h) { + delete scaleTex; + scaleTex = new Texture(w, h, 1, FMT_RGBA, OPT_TARGET); } + Core::defaultTarget = scaleTex; + Core::viewportDef = short4(0, 0, w, h); + } - Core::pass = pass; + if (Core::eye == 0.0f && Core::settings.detail.isStereo()) { + renderEye(-1, showUI, invBG); + renderEye(+1, showUI, invBG); + } else { + renderEye(int(Core::eye), showUI, invBG); } - Core::viewportDef = vp; + #ifndef _OS_3DS + if (!invBG && Core::settings.detail.stereo == Core::Settings::STEREO_ANAGLYPH) { + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / 32767.0f)); + Core::setViewProj(mView, mProj); - player = players[0]; - camera = player->camera; + Core::setDepthTest(false); + Core::setDepthWrite(false); + + Core::setTarget(NULL, NULL, RT_STORE_COLOR); + Core::validateRenderState(); + setShader(Core::passFilter, Shader::FILTER_ANAGLYPH, false, false); + Core::eyeTex[0]->bind(sDiffuse); + Core::eyeTex[1]->bind(sNormal); + Core::setDepthTest(false); + mesh->renderQuad(); + + Core::setDepthTest(true); + Core::setDepthWrite(true); + } + #endif - // lara->visibleMask = 0xFFFFFFFF; // catsuit test + Core::defaultTarget = oldTarget; + Core::viewportDef = oldViewport; + + if (upscale) { + mat4 mProj, mView; + mView.identity(); + mProj = GAPI::ortho(-1, +1, -1, +1, 0, 1); + mProj.scale(vec3(1.0f / 32767.0f)); + Core::setViewProj(mView, mProj); + + Core::setTarget(NULL, NULL, RT_STORE_COLOR); + setShader(Core::passFilter, Shader::FILTER_UPSCALE, false, false); + Core::active.shader->setParam(uParam, vec4(float(scaleTex->width), float(scaleTex->height), 0.0f, 0.0f)); + scaleTex->bind(sDiffuse); + Core::setDepthTest(false); + mesh->renderQuad(); + Core::setDepthTest(true); + Core::setDepthWrite(true); + } + + // TODO render all UI with native resolution here } void renderUI() { - if (level.isCutsceneLevel() || inventory->titleTimer > 1.0f || level.isTitle()) return; + if (inventory->titleTimer > 1.0f || level.isTitle()) return; - UI::begin(); - UI::updateAspect(camera->aspect); + #ifdef _GAPI_SW + GAPI::setPalette(GAPI::swPaletteColor); + GAPI::setShading(false); + #endif + Core::pushLights(); + + UI::begin(camera->aspect); + + atlasObjects->bind(sDiffuse); UI::renderPickups(); + atlasGlyphs->bind(sDiffuse); + Core::resetLights(); - // render health & oxygen bars - vec2 size = vec2(180, 10); + if (!level.isCutsceneLevel() && !camera->spectator) { + // render health & oxygen bars + vec2 size = vec2(180, 10); - float health = player->health / float(LARA_MAX_HEALTH); - float oxygen = player->oxygen / float(LARA_MAX_OXYGEN); + float health = player->health / float(LARA_MAX_HEALTH); + float oxygen = player->oxygen / float(LARA_MAX_OXYGEN); - if ((params->time - int(params->time)) < 0.5f) { // blinking - if (health <= 0.2f) health = 0.0f; - if (oxygen <= 0.2f) oxygen = 0.0f; - } - - float eye = inventory->active ? 0.0f : UI::width * Core::eye * 0.02f; + if ((params->time - int(params->time)) < 0.5f) { // blinking + if (health <= 0.2f) health = 0.0f; + if (oxygen <= 0.2f) oxygen = 0.0f; + } - vec2 pos; - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) - pos = vec2((UI::width - size.x) * 0.5f - eye * 4.0f, 96); - else - pos = vec2(UI::width - 32 - size.x - eye, 32); + vec2 pos; + if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) + pos = vec2((UI::width - size.x) * 0.5f, 96); + else + pos = vec2(UI::width - 32 - size.x, 32); - if (!player->dozy && (player->stand == Lara::STAND_ONWATER || player->stand == Character::STAND_UNDERWATER)) { - UI::renderBar(UI::BAR_OXYGEN, pos, size, oxygen); - pos.y += 16.0f; - } + if (!player->dozy && (player->stand == Lara::STAND_ONWATER || player->stand == Character::STAND_UNDERWATER)) { + UI::renderBar(CTEX_OXYGEN, pos, size, oxygen); + pos.y += 16.0f; + } - if ((!inventory->active && ((player->wpnReady() && !player->emptyHands()) || player->damageTime > 0.0f || health <= 0.2f))) { - UI::renderBar(UI::BAR_HEALTH, pos, size, health); - pos.y += 32.0f; + if ((!inventory->active && ((player->wpnReady() && !player->emptyHands()) || player->damageTime > 0.0f || health <= 0.2f))) { + UI::renderBar(CTEX_HEALTH, pos, size, health); + pos.y += 32.0f; - if (!inventory->active && !player->emptyHands()) { // ammo - int index = inventory->contains(player->wpnCurrent); - if (index > -1) - inventory->renderItemCount(inventory->items[index], pos, size.x); + if (!inventory->active && !player->emptyHands()) { // ammo + int index = inventory->contains(player->wpnCurrent); + if (index > -1) + inventory->renderItemCount(inventory->items[index], pos, size.x); + } } + + UI::renderHelp(); } - UI::renderHelp(); + if (!camera->spectator) { + UI::renderSubs(); + } UI::end(); - } - void renderInventoryEye(int eye) { - float aspect = float(Core::width) / float(Core::height); + Core::popLights(); + } - if (Core::settings.detail.stereo != Core::Settings::STEREO_VR) - switch (eye) { - case -1 : Core::setViewport(Core::x, Core::y, Core::width / 2, Core::height); break; - case 0 : Core::setViewport(Core::x, Core::y, Core::width, Core::height); break; - case +1 : Core::setViewport(Core::x + Core::width / 2, Core::y, Core::width / 2, Core::height); break; - } + void renderInventoryEye(int eye, int view) { + short4 oldViewport = Core::viewportDef; - if (Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT) - eye = 0; + setDefaultTarget(eye, view, false); + #ifdef FFP //fixme: psp framebuffer error? + Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_CLEAR_COLOR | RT_STORE_COLOR); + #else + Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR); + #endif - Core::eye = float(eye); + float aspect = setViewport(view, eye); - if (level.isTitle() || inventory->titleTimer > 0.0f) - inventory->renderBackground(); - inventory->render(aspect); + Core::pushLights(); + Core::resetLights(); - UI::begin(); - UI::updateAspect(aspect); - inventory->renderUI(); - UI::end(); - } + if (inventory->video) { + inventory->render(1.0); - void renderInventory() { - Core::setTarget(NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR); + if (UI::subsStr != STR_EMPTY) { + UI::begin(float(Core::width) / float(Core::height)); + atlasGlyphs->bind(sDiffuse); + UI::renderSubs(); + UI::end(); + } + } - Core::resetLights(); + if (!inventory->video) { + inventory->renderBackground(max(0, view)); + } - if (!(level.isTitle() || inventory->titleTimer > 0.0f)) - inventory->renderBackground(); + setupBinding(); + atlasObjects->bind(sDiffuse); + inventory->render(aspect); - float oldEye = Core::eye; + UI::begin(aspect); + atlasGlyphs->bind(sDiffuse); + if (!inventory->video) { + inventory->renderUI(); + } else { + UI::renderSubs(); + } + UI::end(); - if ((Core::settings.detail.stereo == Core::Settings::STEREO_ON) || (Core::settings.detail.stereo == Core::Settings::STEREO_SPLIT && players[1])) { - renderInventoryEye(-1); - renderInventoryEye(+1); - } else - renderInventoryEye(int(Core::eye)); + Core::popLights(); - Core::setViewport(Core::x, Core::y, Core::width, Core::height); - Core::eye = oldEye; + Core::viewportDef = oldViewport; } void render() { - if (inventory->video) - return; - - bool title = inventory->isActive() || level.isTitle(); - bool copyBg = title && (lastTitle != title || needRedrawTitleBG); - lastTitle = title; - needRedrawTitleBG = false; - - if (isEnded) { - Core::setTarget(NULL, RT_CLEAR_COLOR | RT_STORE_COLOR); - UI::begin(); - UI::updateAspect(float(Core::width) / float(Core::height)); + if (isEnded && !inventory->video) { + Core::setTarget(NULL, NULL, RT_CLEAR_COLOR | RT_STORE_COLOR); + UI::begin(float(Core::width) / float(Core::height)); + atlasGlyphs->bind(sDiffuse); UI::textOut(vec2(0, 480 - 16), STR_LOADING, UI::aCenter, UI::width); UI::end(); return; } - if (copyBg) { - inventory->prepareBackground(); - } - - if (needRenderGame) - renderGame(true); - - renderInventory(); + renderGame(true, false); } }; diff --git a/src/libs/gl/glext.h b/src/libs/gl/glext.h new file mode 100644 index 00000000..08ff32c1 --- /dev/null +++ b/src/libs/gl/glext.h @@ -0,0 +1,12537 @@ +#ifndef __glext_h_ +#define __glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2017 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20180114 + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef unsigned short GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef uint64_t GLuint64; +typedef int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef unsigned short GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufsize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/libs/gl/wglext.h b/src/libs/gl/wglext.h new file mode 100644 index 00000000..1f447dcb --- /dev/null +++ b/src/libs/gl/wglext.h @@ -0,0 +1,840 @@ +#ifndef __wglext_h_ +#define __wglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#define WGL_WGLEXT_VERSION 20150623 + +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef WGL_WGLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif +#endif /* WGL_ARB_extensions_string */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); +#endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif +#endif /* WGL_EXT_display_color_table */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); +#endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_EXT_pbuffer */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); +#endif +#endif /* WGL_EXT_swap_control */ + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif +#endif /* WGL_I3D_digital_video_control */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif +#endif /* WGL_I3D_gamma */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif +#endif /* WGL_I3D_image_buffer */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif +#endif /* WGL_I3D_swap_frame_lock */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 +typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); +#endif +#endif /* WGL_NV_delay_before_swap */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +DECLARE_HANDLE(HGPUNV); +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/src/libs/minimp3/libc.h b/src/libs/minimp3/libc.h deleted file mode 100644 index 0e021e0b..00000000 --- a/src/libs/minimp3/libc.h +++ /dev/null @@ -1,92 +0,0 @@ -// a libc replacement (more or less) for the Microsoft Visual C compiler -// this file is public domain -- do with it whatever you want! -#ifndef __LIBC_H_INCLUDED__ -#define __LIBC_H_INCLUDED__ - -#ifdef _MSC_VER - #define INLINE __forceinline - #define FASTCALL __fastcall - #ifdef NOLIBC - #ifdef MAIN_PROGRAM - int _fltused=0; - #endif - #endif -#else - #define INLINE inline - #define FASTCALL __attribute__((fastcall)) - #include -#endif - -#ifdef _WIN32 - #ifndef WIN32 - #define WIN32 - #endif -#endif -#ifdef WIN32 - #include -#endif - -#if !NEED_MINILIBC - #include - #include - #include -#endif -#include - -#ifndef __int8_t_defined - #define __int8_t_defined - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned short uint16_t; - typedef signed short int16_t; - typedef unsigned int uint32_t; - typedef signed int int32_t; - #ifdef _MSC_VER - typedef unsigned __int64 uint64_t; - typedef signed __int64 int64_t; - #elif defined(__x86_64__) && defined(__linux__) - #include - #else - typedef unsigned long long uint64_t; - typedef signed long long int64_t; - #endif -#endif - -#ifndef NULL - #define NULL 0 -#endif - -#ifndef M_PI - #define M_PI 3.14159265358979 -#endif - -#define libc_malloc malloc -#define libc_calloc calloc -#define libc_realloc realloc -#define libc_free free - -#define libc_memset memset -#define libc_memcpy memcpy -#define libc_memmove memmove - -#if defined(_MSC_VER) && !defined(_DEBUG) -static INLINE double libc_frexp(double x, int *e) { - double res = -9999.999; - unsigned __int64 i = *(unsigned __int64*)(&x); - if (!(i & 0x7F00000000000000UL)) { - *e = 0; - return x; - } - *e = ((i << 1) >> 53) - 1022; - i &= 0x800FFFFFFFFFFFFFUL; - i |= 0x3FF0000000000000UL; - return *(double*)(&i) * 0.5; -} -#else - #define libc_frexp frexp -#endif - -#define libc_exp exp -#define libc_pow pow - -#endif//__LIBC_H_INCLUDED__ diff --git a/src/libs/minimp3/minimp3.cpp b/src/libs/minimp3/minimp3.cpp index d8e2fe7e..b78faeb8 100644 --- a/src/libs/minimp3/minimp3.cpp +++ b/src/libs/minimp3/minimp3.cpp @@ -21,7 +21,65 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libc.h" +#include +#include +#include +#include + +#ifdef _MSC_VER + #define INLINE __forceinline + #define FASTCALL __fastcall + #ifdef NOLIBC + #ifdef MAIN_PROGRAM + int _fltused=0; + #endif + #endif +#else + #define INLINE inline + #define FASTCALL __attribute__((fastcall)) + #include +#endif + +typedef unsigned char uint8; +typedef signed char int8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned int uint32; +typedef signed int int32; +typedef unsigned long long uint64; +typedef signed long long int64; + +#define PI 3.14159265358979 + +#define libc_malloc malloc +#define libc_calloc calloc +#define libc_realloc realloc +#define libc_free free + +#define libc_memset memset +#define libc_memcpy memcpy +#define libc_memmove memmove + +#define libc_exp exp +#define libc_pow pow + +#if defined(_MSC_VER) && !defined(_DEBUG) +static INLINE double libc_frexp(double x, int *e) { + double res = -9999.999; + unsigned __int64 i = *(unsigned __int64*)(&x); + if (!(i & 0x7F00000000000000UL)) { + *e = 0; + return x; + } + *e = ((i << 1) >> 53) - 1022; + i &= 0x800FFFFFFFFFFFFFUL; + i |= 0x3FF0000000000000UL; + return *(double*)(&i) * 0.5; +} +#else + #define libc_frexp frexp +#endif + #include "minimp3.h" #define MP3_FRAME_SIZE 1152 @@ -53,32 +111,8 @@ #define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS) #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) -#ifndef _MSC_VER - #define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) - #define MULH(a,b) (((int64_t)(a) * (int64_t)(b)) >> 32) -#else - static INLINE int MULL(int a, int b) { - int res; - __asm { - mov eax, a - imul b - shr eax, 15 - shl edx, 17 - or eax, edx - mov res, eax - } - return res; - } - static INLINE int MULH(int a, int b) { - int res; - __asm { - mov eax, a - imul b - mov res, edx - } - return res; - } -#endif +#define MULL(a,b) int32(((int64)(a) * (int64)(b)) >> FRAC_BITS) +#define MULH(a,b) int32(((int64)(a) * (int64)(b)) >> 32) #define MULS(ra, rb) ((ra) * (rb)) #define ISQRT2 FIXR(0.70710678118654752440) @@ -87,14 +121,14 @@ #define BACKSTEP_SIZE 512 #define EXTRABYTES 24 -#define VLC_TYPE int16_t +#define VLC_TYPE int16 //////////////////////////////////////////////////////////////////////////////// struct _granule; typedef struct _bitstream { - const uint8_t *buffer, *buffer_end; + const uint8 *buffer, *buffer_end; int index; int size_in_bits; } bitstream_t; @@ -106,10 +140,10 @@ typedef struct _vlc { } vlc_t; typedef struct _mp3_context { - uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; + uint8 last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; int last_buf_size; int frame_size; - uint32_t free_format_next_header; + uint32 free_format_next_header; int error_protection; int sample_rate; int sample_rate_index; @@ -120,63 +154,63 @@ typedef struct _mp3_context { int mode; int mode_ext; int lsf; - int16_t synth_buf[MP3_MAX_CHANNELS][512 * 2]; + int16 synth_buf[MP3_MAX_CHANNELS][512 * 2]; int synth_buf_offset[MP3_MAX_CHANNELS]; - int32_t sb_samples[MP3_MAX_CHANNELS][36][SBLIMIT]; - int32_t mdct_buf[MP3_MAX_CHANNELS][SBLIMIT * 18]; + int32 sb_samples[MP3_MAX_CHANNELS][36][SBLIMIT]; + int32 mdct_buf[MP3_MAX_CHANNELS][SBLIMIT * 18]; int dither_state; } mp3_context_t; typedef struct _granule { - uint8_t scfsi; + uint8 scfsi; int part2_3_length; int big_values; int global_gain; int scalefac_compress; - uint8_t block_type; - uint8_t switch_point; + uint8 block_type; + uint8 switch_point; int table_select[3]; int subblock_gain[3]; - uint8_t scalefac_scale; - uint8_t count1table_select; + uint8 scalefac_scale; + uint8 count1table_select; int region_size[3]; int preflag; int short_start, long_end; - uint8_t scale_factors[40]; - int32_t sb_hybrid[SBLIMIT * 18]; + uint8 scale_factors[40]; + int32 sb_hybrid[SBLIMIT * 18]; } granule_t; typedef struct _huff_table { int xsize; - const uint8_t *bits; - const uint16_t *codes; + const uint8 *bits; + const uint16 *codes; } huff_table_t; static vlc_t huff_vlc[16]; static vlc_t huff_quad_vlc[2]; -static uint16_t band_index_long[9][23]; +static uint16 band_index_long[9][23]; #define TABLE_4_3_SIZE (8191 + 16)*4 -static int8_t *table_4_3_exp; -static uint32_t *table_4_3_value; -static uint32_t exp_table[512]; -static uint32_t expval_table[512][16]; -static int32_t is_table[2][16]; -static int32_t is_table_lsf[2][2][16]; -static int32_t csa_table[8][4]; +static int8 *table_4_3_exp; +static uint32 *table_4_3_value; +static uint32 exp_table[512]; +static uint32 expval_table[512][16]; +static int32 is_table[2][16]; +static int32 is_table_lsf[2][2][16]; +static int32 csa_table[8][4]; static float csa_table_float[8][4]; -static int32_t mdct_win[8][36]; -static int16_t window[512]; +static int32 mdct_win[8][36]; +static int16 window[512]; //////////////////////////////////////////////////////////////////////////////// -static const uint16_t mp3_bitrate_tab[2][15] = { +static const uint16 mp3_bitrate_tab[2][15] = { {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 }, {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} }; -static const uint16_t mp3_freq_tab[3] = { 44100, 48000, 32000 }; +static const uint16 mp3_freq_tab[3] = { 44100, 48000, 32000 }; -static const int32_t mp3_enwindow[257] = { +static const int32 mp3_enwindow[257] = { 0, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -3, -3, -4, -4, -5, -5, -6, -7, -7, -8, -9, -10, -11, @@ -212,12 +246,12 @@ static const int32_t mp3_enwindow[257] = { 75038, }; -static const uint8_t slen_table[2][16] = { +static const uint8 slen_table[2][16] = { { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 }, { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 }, }; -static const uint8_t lsf_nsf_table[6][3][4] = { +static const uint8 lsf_nsf_table[6][3][4] = { { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } }, { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } }, { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } }, @@ -226,55 +260,55 @@ static const uint8_t lsf_nsf_table[6][3][4] = { { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } }, }; -static const uint16_t mp3_huffcodes_1[4] = { +static const uint16 mp3_huffcodes_1[4] = { 0x0001, 0x0001, 0x0001, 0x0000, }; -static const uint8_t mp3_huffbits_1[4] = { +static const uint8 mp3_huffbits_1[4] = { 1, 3, 2, 3, }; -static const uint16_t mp3_huffcodes_2[9] = { +static const uint16 mp3_huffcodes_2[9] = { 0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_2[9] = { +static const uint8 mp3_huffbits_2[9] = { 1, 3, 6, 3, 3, 5, 5, 5, 6, }; -static const uint16_t mp3_huffcodes_3[9] = { +static const uint16 mp3_huffcodes_3[9] = { 0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_3[9] = { +static const uint8 mp3_huffbits_3[9] = { 2, 2, 6, 3, 2, 5, 5, 5, 6, }; -static const uint16_t mp3_huffcodes_5[16] = { +static const uint16 mp3_huffcodes_5[16] = { 0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004, 0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000, }; -static const uint8_t mp3_huffbits_5[16] = { +static const uint8 mp3_huffbits_5[16] = { 1, 3, 6, 7, 3, 3, 6, 7, 6, 6, 7, 8, 7, 6, 7, 8, }; -static const uint16_t mp3_huffcodes_6[16] = { +static const uint16 mp3_huffcodes_6[16] = { 0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002, 0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_6[16] = { +static const uint8 mp3_huffbits_6[16] = { 3, 3, 5, 7, 3, 2, 4, 5, 4, 4, 5, 6, 6, 5, 6, 7, }; -static const uint16_t mp3_huffcodes_7[36] = { +static const uint16 mp3_huffcodes_7[36] = { 0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003, 0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011, 0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002, @@ -282,7 +316,7 @@ static const uint16_t mp3_huffcodes_7[36] = { 0x0005, 0x0003, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_7[36] = { +static const uint8 mp3_huffbits_7[36] = { 1, 3, 6, 8, 8, 9, 3, 4, 6, 7, 7, 8, 6, 5, 7, 8, 8, 9, 7, 7, 8, 9, 9, 9, @@ -290,7 +324,7 @@ static const uint8_t mp3_huffbits_7[36] = { 9, 10, 10, 10, }; -static const uint16_t mp3_huffcodes_8[36] = { +static const uint16 mp3_huffcodes_8[36] = { 0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001, 0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e, 0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004, @@ -298,7 +332,7 @@ static const uint16_t mp3_huffcodes_8[36] = { 0x0004, 0x0001, 0x0001, 0x0000, }; -static const uint8_t mp3_huffbits_8[36] = { +static const uint8 mp3_huffbits_8[36] = { 2, 3, 6, 8, 8, 9, 3, 2, 4, 8, 8, 8, 6, 4, 6, 8, 8, 9, 8, 8, 8, 9, 9, 10, @@ -306,7 +340,7 @@ static const uint8_t mp3_huffbits_8[36] = { 9, 9, 11, 11, }; -static const uint16_t mp3_huffcodes_9[36] = { +static const uint16 mp3_huffcodes_9[36] = { 0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004, 0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008, 0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001, @@ -314,7 +348,7 @@ static const uint16_t mp3_huffcodes_9[36] = { 0x0006, 0x0002, 0x0006, 0x0000, }; -static const uint8_t mp3_huffbits_9[36] = { +static const uint8 mp3_huffbits_9[36] = { 3, 3, 5, 6, 8, 9, 3, 3, 4, 5, 6, 8, 4, 4, 5, 6, 7, 8, 6, 5, 6, 7, 7, 8, @@ -322,7 +356,7 @@ static const uint8_t mp3_huffbits_9[36] = { 8, 8, 9, 9, }; -static const uint16_t mp3_huffcodes_10[64] = { +static const uint16 mp3_huffcodes_10[64] = { 0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011, 0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007, 0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006, @@ -333,7 +367,7 @@ static const uint16_t mp3_huffcodes_10[64] = { 0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_10[64] = { +static const uint8 mp3_huffbits_10[64] = { 1, 3, 6, 8, 9, 9, 9, 10, 3, 4, 6, 7, 8, 9, 8, 8, 6, 6, 7, 8, 9, 10, 9, 9, @@ -344,7 +378,7 @@ static const uint8_t mp3_huffbits_10[64] = { 9, 8, 9, 10, 10, 11, 11, 11, }; -static const uint16_t mp3_huffcodes_11[64] = { +static const uint16 mp3_huffcodes_11[64] = { 0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f, 0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a, 0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005, @@ -355,7 +389,7 @@ static const uint16_t mp3_huffcodes_11[64] = { 0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_11[64] = { +static const uint8 mp3_huffbits_11[64] = { 2, 3, 5, 7, 8, 9, 8, 9, 3, 3, 4, 6, 8, 8, 7, 8, 5, 5, 6, 7, 8, 9, 8, 8, @@ -366,7 +400,7 @@ static const uint8_t mp3_huffbits_11[64] = { 8, 7, 8, 9, 10, 10, 10, 10, }; -static const uint16_t mp3_huffcodes_12[64] = { +static const uint16 mp3_huffcodes_12[64] = { 0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a, 0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b, 0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007, @@ -377,7 +411,7 @@ static const uint16_t mp3_huffcodes_12[64] = { 0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000, }; -static const uint8_t mp3_huffbits_12[64] = { +static const uint8 mp3_huffbits_12[64] = { 4, 3, 5, 7, 8, 9, 9, 9, 3, 3, 4, 5, 7, 7, 8, 8, 5, 4, 5, 6, 7, 8, 7, 8, @@ -388,7 +422,7 @@ static const uint8_t mp3_huffbits_12[64] = { 9, 8, 8, 9, 9, 9, 9, 10, }; -static const uint16_t mp3_huffcodes_13[256] = { +static const uint16 mp3_huffcodes_13[256] = { 0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047, 0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013, 0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021, @@ -423,7 +457,7 @@ static const uint16_t mp3_huffcodes_13[256] = { 0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001, }; -static const uint8_t mp3_huffbits_13[256] = { +static const uint8 mp3_huffbits_13[256] = { 1, 4, 6, 7, 8, 9, 9, 10, 9, 10, 11, 11, 12, 12, 13, 13, 3, 4, 6, 7, 8, 8, 9, 9, @@ -458,7 +492,7 @@ static const uint8_t mp3_huffbits_13[256] = { 15, 15, 16, 16, 19, 18, 19, 16, }; -static const uint16_t mp3_huffcodes_15[256] = { +static const uint16 mp3_huffcodes_15[256] = { 0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c, 0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f, 0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033, @@ -493,7 +527,7 @@ static const uint16_t mp3_huffcodes_15[256] = { 0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000, }; -static const uint8_t mp3_huffbits_15[256] = { +static const uint8 mp3_huffbits_15[256] = { 3, 4, 5, 7, 7, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 13, 4, 3, 5, 6, 7, 7, 8, 8, @@ -528,7 +562,7 @@ static const uint8_t mp3_huffbits_15[256] = { 12, 12, 12, 12, 13, 13, 13, 13, }; -static const uint16_t mp3_huffcodes_16[256] = { +static const uint16 mp3_huffcodes_16[256] = { 0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d, 0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011, 0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f, @@ -563,7 +597,7 @@ static const uint16_t mp3_huffcodes_16[256] = { 0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, }; -static const uint8_t mp3_huffbits_16[256] = { +static const uint8 mp3_huffbits_16[256] = { 1, 4, 6, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 13, 9, 3, 4, 6, 7, 8, 9, 9, 9, @@ -598,7 +632,7 @@ static const uint8_t mp3_huffbits_16[256] = { 11, 11, 11, 11, 11, 11, 11, 8, }; -static const uint16_t mp3_huffcodes_24[256] = { +static const uint16 mp3_huffcodes_24[256] = { 0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2, 0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058, 0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8, @@ -633,7 +667,7 @@ static const uint16_t mp3_huffcodes_24[256] = { 0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, }; -static const uint8_t mp3_huffbits_24[256] = { +static const uint8 mp3_huffbits_24[256] = { 4, 4, 6, 7, 8, 9, 9, 10, 10, 11, 11, 11, 11, 11, 12, 9, 4, 4, 5, 6, 7, 8, 8, 9, @@ -687,7 +721,7 @@ static const huff_table_t mp3_huff_tables[16] = { { 16, mp3_huffbits_24, mp3_huffcodes_24 }, }; -static const uint8_t mp3_huff_data[32][2] = { +static const uint8 mp3_huff_data[32][2] = { { 0, 0 }, { 1, 0 }, { 2, 0 }, @@ -722,17 +756,17 @@ static const uint8_t mp3_huff_data[32][2] = { { 15, 13 }, }; -static const uint8_t mp3_quad_codes[2][16] = { +static const uint8 mp3_quad_codes[2][16] = { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1, }, { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, }, }; -static const uint8_t mp3_quad_bits[2][16] = { +static const uint8 mp3_quad_bits[2][16] = { { 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, }, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }, }; -static const uint8_t band_size_long[9][22] = { +static const uint8 band_size_long[9][22] = { { 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */ { 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, @@ -753,7 +787,7 @@ static const uint8_t band_size_long[9][22] = { 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */ }; -static const uint8_t band_size_short[9][13] = { +static const uint8 band_size_short[9][13] = { { 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */ { 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */ { 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */ @@ -765,7 +799,7 @@ static const uint8_t band_size_short[9][13] = { { 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */ }; -static const uint8_t mp3_pretab[2][22] = { +static const uint8 mp3_pretab[2][22] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 }, }; @@ -809,15 +843,15 @@ static const int icos36h[9] = { //////////////////////////////////////////////////////////////////////////////// -static INLINE int unaligned32_be(const uint8_t *p) +static INLINE int unaligned32_be(const uint8 *p) { return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); } #define MIN_CACHE_BITS 25 -#define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#define NEG_SSR32(a,s) ((( int32)(a))>>(32-(s))) +#define NEG_USR32(a,s) (((uint32)(a))>>(32-(s))) #define OPEN_READER(name, gb) \ int name##_index= (gb)->index;\ @@ -851,7 +885,7 @@ static INLINE int unaligned32_be(const uint8_t *p) NEG_SSR32(name##_cache, num) #define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) + ((uint32)name##_cache) static INLINE int get_bits_count(bitstream_t *s){ return s->index; @@ -862,7 +896,7 @@ static INLINE void skip_bits_long(bitstream_t *s, int n){ } #define skip_bits skip_bits_long -static void init_get_bits(bitstream_t *s, const uint8_t *buffer, int bit_size) { +static void init_get_bits(bitstream_t *s, const uint8 *buffer, int bit_size) { int buffer_size= (bit_size+7)>>3; if(buffer_size < 0 || bit_size < 0) { buffer_size = bit_size = 0; @@ -894,7 +928,7 @@ static INLINE int get_bitsz(bitstream_t *s, int n) static INLINE unsigned int get_bits1(bitstream_t *s){ int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; + uint8 result= s->buffer[ index>>3 ]; result<<= (index&0x07); result>>= 8 - 1; index++; @@ -910,16 +944,16 @@ static INLINE void align_get_bits(bitstream_t *s) #define GET_DATA(v, table, i, wrap, size) \ {\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ + const uint8 *ptr = (const uint8 *)table + i * wrap;\ switch(size) {\ case 1:\ - v = *(const uint8_t *)ptr;\ + v = *(const uint8 *)ptr;\ break;\ case 2:\ - v = *(const uint16_t *)ptr;\ + v = *(const uint16 *)ptr;\ break;\ default:\ - v = *(const uint32_t *)ptr;\ + v = *(const uint32 *)ptr;\ break;\ }\ } @@ -942,10 +976,10 @@ static int build_table( int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, - uint32_t code_prefix, int n_prefix + uint32 code_prefix, int n_prefix ) { int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2; - uint32_t code; + uint32 code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; @@ -1082,7 +1116,7 @@ static void switch_buffer(mp3_context_t *s, int *pos, int *end_pos, int *end_pos //////////////////////////////////////////////////////////////////////////////// -static INLINE int mp3_check_header(uint32_t header){ +static INLINE int mp3_check_header(uint32 header){ /* header */ if ((header & 0xffe00000) != 0xffe00000) return -1; @@ -1146,11 +1180,11 @@ static INLINE int round_sample(int *sum) { } static void exponents_from_scale_factors( - mp3_context_t *s, granule_t *g, int16_t *exponents + mp3_context_t *s, granule_t *g, int16 *exponents ) { - const uint8_t *bstab, *pretab; + const uint8 *bstab, *pretab; int len, i, j, k, l, v0, shift, gain, gains[3]; - int16_t *exp_ptr; + int16 *exp_ptr; exp_ptr = exponents; gain = g->global_gain - 210; @@ -1185,8 +1219,8 @@ static void exponents_from_scale_factors( static void reorder_block(mp3_context_t *s, granule_t *g) { int i, j, len; - int32_t *ptr, *dst, *ptr1; - int32_t tmp[576]; + int32 *ptr, *dst, *ptr1; + int32 tmp[576]; if (g->block_type != 2) return; @@ -1217,7 +1251,7 @@ static void reorder_block(mp3_context_t *s, granule_t *g) } static void compute_antialias(mp3_context_t *s, granule_t *g) { - int32_t *ptr, *csa; + int32 *ptr, *csa; int n, i; /* we antialias only "long" bands */ @@ -1258,10 +1292,10 @@ static void compute_stereo( mp3_context_t *s, granule_t *g0, granule_t *g1 ) { int i, j, k, l; - int32_t v1, v2; + int32 v1, v2; int sf_max, tmp0, tmp1, sf, len, non_zero_found; - int32_t (*is_tab)[16]; - int32_t *tab0, *tab1; + int32 (*is_tab)[16]; + int32 *tab0, *tab1; int non_zero_found_short[3]; if (s->mode_ext & MODE_EXT_I_STEREO) { @@ -1381,7 +1415,7 @@ static void compute_stereo( } static int huffman_decode( - mp3_context_t *s, granule_t *g, int16_t *exponents, int end_pos2 + mp3_context_t *s, granule_t *g, int16 *exponents, int end_pos2 ) { int s_index; int i; @@ -1644,10 +1678,10 @@ static void imdct36(int *out, int *buf, int *in, int *win) } static void compute_imdct( - mp3_context_t *s, granule_t *g, int32_t *sb_samples, int32_t *mdct_buf + mp3_context_t *s, granule_t *g, int32 *sb_samples, int32 *mdct_buf ) { - int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; - int32_t out2[12]; + int32 *ptr, *win, *win1, *buf, *out_ptr, *ptr1; + int32 out2[12]; int i, j, mdct_long_end, v, sblimit; /* find last non zero block */ @@ -1659,7 +1693,7 @@ static void compute_imdct( if (v != 0) break; } - sblimit = ((ptr - g->sb_hybrid) / 18) + 1; + sblimit = int((ptr - g->sb_hybrid) / 18) + 1; if (g->block_type == 2) { /* XXX: check for 8000 Hz */ @@ -1835,7 +1869,7 @@ static void compute_imdct( #define ADD(a, b) tab[a] += tab[b] -static void dct32(int32_t *out, int32_t *tab) +static void dct32(int32 *out, int32 *tab) { int tmp0, tmp1; @@ -1994,16 +2028,16 @@ static void dct32(int32_t *out, int32_t *tab) } static void mp3_synth_filter( - int16_t *synth_buf_ptr, int *synth_buf_offset, - int16_t *window, int *dither_state, - int16_t *samples, int incr, - int32_t sb_samples[SBLIMIT] + int16 *synth_buf_ptr, int *synth_buf_offset, + int16 *window, int *dither_state, + int16 *samples, int incr, + int32 sb_samples[SBLIMIT] ) { - int32_t tmp[32]; - int16_t *synth_buf; - const int16_t *w, *w2, *p; + int32 tmp[32]; + int16 *synth_buf; + const int16 *w, *w2, *p; int j, offset, v; - int16_t *samples2; + int16 *samples2; int sum, sum2; dct32(tmp, sb_samples); @@ -2022,7 +2056,7 @@ static void mp3_synth_filter( synth_buf[j] = v; } /* copy to avoid wrap */ - libc_memcpy(synth_buf + 512, synth_buf, 32 * sizeof(int16_t)); + libc_memcpy(synth_buf + 512, synth_buf, 32 * sizeof(int16)); samples2 = samples + 31 * incr; w = window; @@ -2066,7 +2100,7 @@ static void mp3_synth_filter( //////////////////////////////////////////////////////////////////////////////// -static int decode_header(mp3_context_t *s, uint32_t header) { +static int decode_header(mp3_context_t *s, uint32 header) { int sample_rate, frame_size, mpeg25, padding; int sample_rate_index, bitrate_index; if (header & (1<<20)) { @@ -2106,8 +2140,8 @@ static int mp_decode_layer3(mp3_context_t *s) { int gr, ch, blocksplit_flag, i, j, k, n, bits_pos; granule_t *g; static granule_t granules[2][2]; - static int16_t exponents[576]; - const uint8_t *ptr; + static int16 exponents[576]; + const uint8 *ptr; if (s->lsf) { main_data_begin = get_bits(&s->gb, 8); @@ -2240,7 +2274,7 @@ static int mp_decode_layer3(mp3_context_t *s) { bits_pos = get_bits_count(&s->gb); if (!s->lsf) { - uint8_t *sc; + uint8 *sc; int slen, slen1, slen2; /* MPEG1 scale factors */ @@ -2374,10 +2408,10 @@ static int mp_decode_layer3(mp3_context_t *s) { static int mp3_decode_main( mp3_context_t *s, - int16_t *samples, const uint8_t *buf, int buf_size + int16 *samples, const uint8 *buf, int buf_size ) { int i, nb_frames, ch; - int16_t *samples_ptr; + int16 *samples_ptr; init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); @@ -2420,7 +2454,7 @@ static int mp3_decode_main( samples_ptr += 32 * s->nb_channels; } } - return nb_frames * 32 * sizeof(uint16_t) * s->nb_channels; + return nb_frames * 32 * sizeof(uint16) * s->nb_channels; } //////////////////////////////////////////////////////////////////////////////// @@ -2449,8 +2483,8 @@ int mp3_decode_init() { const huff_table_t *h = &mp3_huff_tables[i]; int xsize, x, y; unsigned int n; - uint8_t tmp_bits [512]; - uint16_t tmp_codes[512]; + uint8 tmp_bits [512]; + uint16 tmp_codes[512]; libc_memset(tmp_bits , 0, sizeof(tmp_bits )); libc_memset(tmp_codes, 0, sizeof(tmp_codes)); @@ -2484,10 +2518,10 @@ int mp3_decode_init() { } /* compute n ^ (4/3) and store it in mantissa/exp format */ - table_4_3_exp = (int8_t*)libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); + table_4_3_exp = (int8*)libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); if(!table_4_3_exp) return -1; - table_4_3_value = (uint32_t*)libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); + table_4_3_value = (uint32*)libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); if(!table_4_3_value) return -1; @@ -2496,7 +2530,7 @@ int mp3_decode_init() { int e, m; f = libc_pow((double)(i/4), 4.0 / 3.0) * libc_pow(2, (i&3)*0.25); fm = libc_frexp(f, &e); - m = (uint32_t)(fm*(1LL<<31) + 0.5); + m = (uint32)(fm*(1LL<<31) + 0.5); e+= FRAC_BITS - 31 + 5 - 100; table_4_3_value[i] = m; table_4_3_exp[i] = -e; @@ -2504,16 +2538,16 @@ int mp3_decode_init() { for(i=0; i<512*16; i++){ int exponent= (i>>4); double f= libc_pow(i&15, 4.0 / 3.0) * libc_pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); - expval_table[exponent][i&15]= uint32_t(f); + expval_table[exponent][i&15]= uint32(f); if((i&15)==1) - exp_table[exponent]= uint32_t(f); + exp_table[exponent]= uint32(f); } for(i=0;i<7;i++) { float f; int v; if (i != 6) { - f = float(tan((double)i * M_PI / 12.0)); + f = float(tan((double)i * PI / 12.0)); v = FIXR(f / (1.0 + f)); } else { v = FIXR(1.0); @@ -2560,17 +2594,17 @@ int mp3_decode_init() { if(j==2 && i%3 != 1) continue; - d= sin(M_PI * (i + 0.5) / 36.0); + d= sin(PI * (i + 0.5) / 36.0); if(j==1){ if (i>=30) d= 0; - else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); + else if(i>=24) d= sin(PI * (i - 18 + 0.5) / 12.0); else if(i>=18) d= 1; }else if(j==3){ if (i< 6) d= 0; - else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); + else if(i< 12) d= sin(PI * (i - 6 + 0.5) / 12.0); else if(i< 18) d= 1; } - d*= 0.5 / cos(M_PI*(2*i + 19)/72); + d*= 0.5 / cos(PI*(2*i + 19)/72); if(j==2) mdct_win[j][i/3] = FIXHR((d / (1<<5))); else @@ -2598,10 +2632,10 @@ void mp3_decode_free() { static int mp3_decode_frame( mp3_context_t *s, - int16_t *out_samples, int *data_size, - uint8_t *buf, int buf_size + int16 *out_samples, int *data_size, + uint8 *buf, int buf_size ) { - uint32_t header; + uint32 header; int out_size; int extra_bytes = 0; @@ -2654,7 +2688,7 @@ int mp3_decode(mp3_decoder_t dec, void *buf, int bytes, signed short *out, mp3_i int res, size = -1; mp3_context_t *s = (mp3_context_t*) dec; if (!s) return 0; - res = mp3_decode_frame(s, (int16_t*) out, &size, (uint8_t*)buf, bytes); + res = mp3_decode_frame(s, (int16*) out, &size, (uint8*)buf, bytes); if (res < 0) return 0; if (info) { info->sample_rate = s->sample_rate; diff --git a/src/libs/openvr/openvr.h b/src/libs/openvr/openvr.h index 4ad9486b..d30d7d08 100644 --- a/src/libs/openvr/openvr.h +++ b/src/libs/openvr/openvr.h @@ -11,6 +11,14 @@ +// version.h +namespace vr +{ + static const uint32_t k_nSteamVRVersionMajor = 1; + static const uint32_t k_nSteamVRVersionMinor = 1; + static const uint32_t k_nSteamVRVersionBuild = 3; +} // namespace vr + // vrtypes.h #ifndef _INCLUDE_VRTYPES_H #define _INCLUDE_VRTYPES_H @@ -29,6 +37,10 @@ namespace vr { #pragma pack( push, 8 ) +/** A handle for a spatial anchor. This handle is only valid during the session it was created in. +* Anchors that live beyond one session should be saved by their string descriptors. */ +typedef uint32_t SpatialAnchorHandle_t; + typedef void* glSharedTextureHandle_t; typedef int32_t glInt_t; typedef uint32_t glUInt_t; @@ -36,13 +48,18 @@ typedef uint32_t glUInt_t; // right-handed system // +y is up // +x is to the right -// -z is going away from you +// -z is forward // Distance unit is meters struct HmdMatrix34_t { float m[3][4]; }; +struct HmdMatrix33_t +{ + float m[3][3]; +}; + struct HmdMatrix44_t { float m[4][4]; @@ -73,6 +90,11 @@ struct HmdQuaternion_t double w, x, y, z; }; +struct HmdQuaternionf_t +{ + float w, x, y, z; +}; + struct HmdColor_t { float r, g, b, a; @@ -107,11 +129,17 @@ enum EVREye enum ETextureType { + TextureType_Invalid = -1, // Handle has been invalidated TextureType_DirectX = 0, // Handle is an ID3D11Texture TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure - TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef + TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef, deprecated in favor of TextureType_Metal on supported platforms TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure + TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets. + // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it + TextureType_Metal = 6, // Handle is a MTLTexture conforming to the MTLSharedTexture protocol. Textures submitted to IVRCompositor::Submit which + // are of type MTLTextureType2DArray assume layer 0 is the left eye texture (vr::EVREye::Eye_left), layer 1 is the right + // eye texture (vr::EVREye::Eye_Right) }; enum EColorSpace @@ -141,6 +169,8 @@ enum ETrackingResult TrackingResult_Running_OK = 200, TrackingResult_Running_OutOfRange = 201, + + TrackingResult_Fallback_RotationOnly = 300, }; typedef uint32_t DriverId_t; @@ -164,6 +194,8 @@ enum ETrackedDeviceClass TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices + + TrackedDeviceClass_Max }; @@ -173,9 +205,27 @@ enum ETrackedControllerRole TrackedControllerRole_Invalid = 0, // Invalid value for controller type TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand + TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection + TrackedControllerRole_Treadmill = 4, // Tracked device is a treadmill + TrackedControllerRole_Max = 4 }; +/** Returns true if the tracked controller role is allowed to be a hand */ +inline bool IsRoleAllowedAsHand( ETrackedControllerRole eRole ) +{ + switch ( eRole ) + { + case TrackedControllerRole_Invalid: + case TrackedControllerRole_LeftHand: + case TrackedControllerRole_RightHand: + return true; + default: + return false; + } +} + + /** describes a single pose for a tracked object */ struct TrackedDevicePose_t { @@ -199,6 +249,9 @@ enum ETrackingUniverseOrigin TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one. }; +typedef uint64_t WebConsoleHandle_t; +#define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0) + // Refers to a single container of properties typedef uint64_t PropertyContainerHandle_t; typedef uint32_t PropertyTypeTag_t; @@ -206,6 +259,9 @@ typedef uint32_t PropertyTypeTag_t; static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0; static const PropertyTypeTag_t k_unInvalidPropertyTag = 0; +typedef PropertyContainerHandle_t DriverHandle_t; +static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0; + // Use these tags to set/get common types as struct properties static const PropertyTypeTag_t k_unFloatPropertyTag = 1; static const PropertyTypeTag_t k_unInt32PropertyTag = 2; @@ -217,12 +273,19 @@ static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20; static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21; static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22; static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23; +static const PropertyTypeTag_t k_unHmdVector2PropertyTag = 24; +static const PropertyTypeTag_t k_unHmdQuadPropertyTag = 25; static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30; static const PropertyTypeTag_t k_unPathHandleInfoTag = 31; static const PropertyTypeTag_t k_unActionPropertyTag = 32; static const PropertyTypeTag_t k_unInputValuePropertyTag = 33; static const PropertyTypeTag_t k_unWildcardPropertyTag = 34; +static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35; +static const PropertyTypeTag_t k_unSkeletonPropertyTag = 36; + +static const PropertyTypeTag_t k_unSpatialAnchorPosePropertyTag = 40; +static const PropertyTypeTag_t k_unJsonPropertyTag = 41; static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; @@ -272,7 +335,13 @@ enum ETrackedDeviceProperty Prop_ParentDriver_Uint64 = 1034, Prop_ResourceRoot_String = 1035, Prop_RegisteredDeviceType_String = 1036, - Prop_InputProfileName_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided + Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided + Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design + Prop_NumCameras_Int32 = 1039, + Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value + Prop_CameraStreamFormat_Int32 = 1041, // ECameraVideoStreamFormat value + Prop_AdditionalDeviceSettingsPath_String = 1042, // driver-relative path to additional device and global configuration settings + Prop_Identifiable_Bool = 1043, // Whether device supports being identified from vrmonitor (e.g. blink LED, vibrate haptics, etc) // Properties that are unique to TrackedDeviceClass_HMD Prop_ReportsTimeSinceVSync_Bool = 2000, @@ -328,6 +397,32 @@ enum ETrackedDeviceProperty Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded Prop_DoNotApplyPrediction_Bool = 2054, + Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion + Prop_DriverIsDrawingControllers_Bool = 2057, + Prop_DriverRequestsApplicationPause_Bool = 2058, + Prop_DriverRequestsReducedRendering_Bool = 2059, + Prop_MinimumIpdStepMeters_Float = 2060, + Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, + Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + Prop_ImuToHeadTransform_Matrix34 = 2063, + Prop_ImuFactoryGyroBias_Vector3 = 2064, + Prop_ImuFactoryGyroScale_Vector3 = 2065, + Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, + // reserved 2068 + Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069, + + // Driver requested mura correction properties + Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, // Properties that are unique to TrackedDeviceClass_Controller Prop_AttachedDeviceId_String = 3000, @@ -372,10 +467,18 @@ enum ETrackedDeviceProperty Prop_HasCameraComponent_Bool = 6004, Prop_HasDriverDirectModeComponent_Bool = 6005, Prop_HasVirtualDisplayComponent_Bool = 6006, + Prop_HasSpatialAnchorsSupport_Bool = 6007, + + // Properties that are set internally based on other information provided by drivers + Prop_ControllerType_String = 7000, + Prop_LegacyInputProfile_String = 7001, + Prop_ControllerHandSelectionPriority_Int32 = 7002, // Allows hand assignments to prefer some controllers over others. High numbers are selected over low numbers // Vendors are free to expose private debug data in this reserved region Prop_VendorSpecific_Reserved_Start = 10000, Prop_VendorSpecific_Reserved_End = 10999, + + Prop_TrackedDeviceProperty_Max = 1000000, }; /** No string property will ever be longer than this length */ @@ -397,8 +500,19 @@ enum ETrackedPropertyError TrackedProp_PermissionDenied = 10, TrackedProp_InvalidOperation = 11, TrackedProp_CannotWriteToWildcards = 12, + TrackedProp_IPCReadFailure = 13, }; + +typedef uint64_t VRActionHandle_t; +typedef uint64_t VRActionSetHandle_t; +typedef uint64_t VRInputValueHandle_t; + +static const VRActionHandle_t k_ulInvalidActionHandle = 0; +static const VRActionSetHandle_t k_ulInvalidActionSetHandle = 0; +static const VRInputValueHandle_t k_ulInvalidInputValueHandle = 0; + + /** Allows the application to control what part of the provided texture will be used in the * frame buffer. */ struct VRTextureBounds_t @@ -413,6 +527,23 @@ struct VRTextureWithPose_t : public Texture_t HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures. }; +struct VRTextureDepthInfo_t +{ + void* handle; // See ETextureType definition above + HmdMatrix44_t mProjection; + HmdVector2_t vRange; // 0..1 +}; + +struct VRTextureWithDepth_t : public Texture_t +{ + VRTextureDepthInfo_t depth; +}; + +struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t +{ + VRTextureDepthInfo_t depth; +}; + /** Allows the application to control how scene textures are used by the compositor when calling Submit. */ enum EVRSubmitFlags { @@ -431,11 +562,17 @@ enum EVRSubmitFlags Submit_Reserved = 0x04, // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t. + // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t. Submit_TextureWithPose = 0x08, + + // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t. + // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t. + Submit_TextureWithDepth = 0x10, }; /** Data required for passing Vulkan textures to IVRCompositor::Submit. -* Be sure to call OpenVR_Shutdown before destroying these resources. */ +* Be sure to call OpenVR_Shutdown before destroying these resources. +* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */ struct VRVulkanTextureData_t { uint64_t m_nImage; // VkImage @@ -512,6 +649,7 @@ enum EVREventType VREvent_Scroll = 305, // data is mouse VREvent_TouchPadMove = 306, // data is mouse VREvent_OverlayFocusChanged = 307, // data is overlay, global event + VREvent_ReloadOverlays = 308, VREvent_InputFocusCaptured = 400, // data is process DEPRECATED VREvent_InputFocusReleased = 401, // data is process DEPRECATED @@ -521,6 +659,8 @@ enum EVREventType VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene VREvent_InputFocusChanged = 406, // data is process VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process + VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility @@ -542,11 +682,12 @@ enum EVREventType VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else VREvent_OverlaySharedTextureChanged = 513, - VREvent_DashboardGuideButtonDown = 514, - VREvent_DashboardGuideButtonUp = 515, + //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent + //VREvent_DashboardGuideButtonUp = 515, VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load VREvent_DashboardOverlayCreated = 518, + VREvent_SwitchGamepadFocus = 519, // Screenshot API VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot @@ -556,6 +697,9 @@ enum EVREventType VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted VREvent_PrimaryDashboardDeviceChanged = 525, + VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled + VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled + VREvent_ShowUI = 528, // data is showUi VREvent_Notification_Shown = 600, VREvent_Notification_Hidden = 601, @@ -568,11 +712,12 @@ enum EVREventType VREvent_QuitAcknowledged = 703, // data is process VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down - VREvent_ChaperoneDataHasChanged = 800, + VREvent_ChaperoneDataHasChanged = 800, // Sent when the process needs to call VRChaperone()->ReloadInfo() VREvent_ChaperoneUniverseHasChanged = 801, VREvent_ChaperoneTempDataHasChanged = 802, VREvent_ChaperoneSettingsHaveChanged = 803, VREvent_SeatedZeroPoseReset = 804, + VREvent_ChaperoneFlushCache = 805, // Sent when the process needs to reload any cached data it retrieved from VRChaperone() VREvent_AudioSettingsHaveChanged = 820, @@ -591,9 +736,14 @@ enum EVREventType VREvent_KeyboardSectionSettingChanged = 862, VREvent_PerfSectionSettingChanged = 863, VREvent_DashboardSectionSettingChanged = 864, + VREvent_WebInterfaceSectionSettingChanged = 865, + VREvent_TrackersSectionSettingChanged = 866, + VREvent_LastKnownSectionSettingChanged = 867, VREvent_StatusUpdate = 900, + VREvent_WebInterface_InstallDriverCompleted = 950, + VREvent_MCImageUpdated = 1000, VREvent_FirmwareUpdateStarted = 1100, @@ -630,6 +780,19 @@ enum EVREventType VREvent_MessageOverlay_Closed = 1650, VREvent_MessageOverlayCloseRequested = 1651, + VREvent_Input_HapticVibration = 1700, // data is hapticVibration + VREvent_Input_BindingLoadFailed = 1701, // data is inputBinding + VREvent_Input_BindingLoadSuccessful = 1702, // data is inputBinding + VREvent_Input_ActionManifestReloaded = 1703, // no data + VREvent_Input_ActionManifestLoadFailed = 1704, // data is actionManifest + VREvent_Input_ProgressUpdate = 1705, // data is progressUpdate + VREvent_Input_TrackerActivated = 1706, + + VREvent_SpatialAnchors_PoseUpdated = 1800, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_DescriptorUpdated = 1801, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_RequestPoseUpdate = 1802, // data is spatialAnchor. sent to specific driver + VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, // data is spatialAnchor. sent to specific driver + // Vendors are free to expose private events in this reserved region VREvent_VendorSpecific_Reserved_Start = 10000, VREvent_VendorSpecific_Reserved_End = 19999, @@ -677,6 +840,10 @@ enum EVRButtonId k_EButton_Dashboard_Back = k_EButton_Grip, + k_EButton_Knuckles_A = k_EButton_Grip, + k_EButton_Knuckles_B = k_EButton_ApplicationMenu, + k_EButton_Knuckles_JoyStick = k_EButton_Axis3, + k_EButton_Max = 64 }; @@ -753,6 +920,7 @@ struct VREvent_Process_t struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; }; @@ -785,6 +953,10 @@ struct VREvent_Reserved_t { uint64_t reserved0; uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; }; struct VREvent_PerformanceTest_t @@ -844,8 +1016,63 @@ struct VREvent_DualAnalog_t EDualAnalogWhich which; }; +struct VREvent_HapticVibration_t +{ + uint64_t containerHandle; // property container handle of the device with the haptic component + uint64_t componentHandle; // Which haptic component needs to vibrate + float fDurationSeconds; + float fFrequency; + float fAmplitude; +}; + +struct VREvent_WebConsole_t +{ + WebConsoleHandle_t webConsoleHandle; +}; + +struct VREvent_InputBindingLoad_t +{ + vr::PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; + uint64_t pathControllerType; +}; + +struct VREvent_InputActionManifestLoad_t +{ + uint64_t pathAppKey; + uint64_t pathMessage; + uint64_t pathMessageParam; + uint64_t pathManifestPath; +}; + +struct VREvent_SpatialAnchor_t +{ + SpatialAnchorHandle_t unHandle; +}; + +struct VREvent_ProgressUpdate_t +{ + uint64_t ulApplicationPropertyContainer; + uint64_t pathDevice; + uint64_t pathInputSource; + uint64_t pathProgressAction; + uint64_t pathIcon; + float fProgress; +}; + +enum EShowUIType +{ + ShowUI_ControllerBinding = 0, + ShowUI_ManageTrackers = 1, + ShowUI_QuickStart = 2, +}; + +struct VREvent_ShowUI_t +{ + EShowUIType eType; +}; -/** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ typedef union { VREvent_Reserved_t reserved; @@ -869,6 +1096,14 @@ typedef union VREvent_MessageOverlay_t messageOverlay; VREvent_Property_t property; VREvent_DualAnalog_t dualAnalog; + VREvent_HapticVibration_t hapticVibration; + VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; + VREvent_InputActionManifestLoad_t actionManifest; + VREvent_SpatialAnchor_t spatialAnchor; + VREvent_ProgressUpdate_t progressUpdate; + VREvent_ShowUI_t showUi; + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ } VREvent_Data_t; @@ -892,6 +1127,46 @@ struct VREvent_t #pragma pack( pop ) #endif +enum EVRInputError +{ + VRInputError_None = 0, + VRInputError_NameNotFound = 1, + VRInputError_WrongType = 2, + VRInputError_InvalidHandle = 3, + VRInputError_InvalidParam = 4, + VRInputError_NoSteam = 5, + VRInputError_MaxCapacityReached = 6, + VRInputError_IPCError = 7, + VRInputError_NoActiveActionSet = 8, + VRInputError_InvalidDevice = 9, + VRInputError_InvalidSkeleton = 10, + VRInputError_InvalidBoneCount = 11, + VRInputError_InvalidCompressedData = 12, + VRInputError_NoData = 13, + VRInputError_BufferTooSmall = 14, + VRInputError_MismatchedActionManifest = 15, + VRInputError_MissingSkeletonData = 16, + VRInputError_InvalidBoneIndex = 17, +}; + +enum EVRSpatialAnchorError +{ + VRSpatialAnchorError_Success = 0, + VRSpatialAnchorError_Internal = 1, + VRSpatialAnchorError_UnknownHandle = 2, + VRSpatialAnchorError_ArrayTooSmall = 3, + VRSpatialAnchorError_InvalidDescriptorChar = 4, + VRSpatialAnchorError_NotYetAvailable = 5, + VRSpatialAnchorError_NotAvailableInThisUniverse = 6, + VRSpatialAnchorError_PermanentlyUnavailable = 7, + VRSpatialAnchorError_WrongDriver = 8, + VRSpatialAnchorError_DescriptorTooLong = 9, + VRSpatialAnchorError_Unknown = 10, + VRSpatialAnchorError_NoRoomCalibration = 11, + VRSpatialAnchorError_InvalidArgument = 12, + VRSpatialAnchorError_UnknownDriver = 13, +}; + /** The mesh to draw into the stencil (or depth) buffer to perform * early stencil (or depth) kills of pixels that will never appear on the HMD. * This mesh draws on all the pixels that will be hidden after distortion. @@ -1029,6 +1304,9 @@ enum EVROverlayError VROverlayError_NoNeighbor = 27, VROverlayError_TooManyMaskPrimitives = 29, VROverlayError_BadMaskPrimitive = 30, + VROverlayError_TextureAlreadyLocked = 31, + VROverlayError_TextureLockCapacityReached = 32, + VROverlayError_TextureNotLocked = 33, }; /** enum values to pass in to VR_Init to identify whether the application will @@ -1044,7 +1322,8 @@ enum EVRApplicationType // interfaces (like IVRSettings and IVRApplications) but not hardware. VRApplication_VRMonitor = 5, // Reserved for vrmonitor VRApplication_SteamWatchdog = 6,// Reserved for Steam - VRApplication_Bootstrapper = 7, // Start up SteamVR + VRApplication_Bootstrapper = 7, // reserved for vrstartup + VRApplication_WebHelper = 8, // reserved for vrwebhelper VRApplication_Max }; @@ -1070,6 +1349,53 @@ enum EVRNotificationError }; +enum EVRSkeletalMotionRange +{ + // The range of motion of the skeleton takes into account any physical limits imposed by + // the controller itself. This will tend to be the most accurate pose compared to the user's + // actual hand pose, but might not allow a closed fist for example + VRSkeletalMotionRange_WithController = 0, + + // Retarget the range of motion provided by the input device to make the hand appear to move + // as if it was not holding a controller. eg: map "hand grasping controller" to "closed fist" + VRSkeletalMotionRange_WithoutController = 1, +}; + +enum EVRSkeletalTrackingLevel +{ + // body part location can’t be directly determined by the device. Any skeletal pose provided by + // the device is estimated by assuming the position required to active buttons, triggers, joysticks, + // or other input sensors. + // E.g. Vive Controller, Gamepad + VRSkeletalTracking_Estimated = 0, + + // body part location can be measured directly but with fewer degrees of freedom than the actual body + // part. Certain body part positions may be unmeasured by the device and estimated from other input data. + // E.g. Knuckles, gloves that only measure finger curl + VRSkeletalTracking_Partial, + + // Body part location can be measured directly throughout the entire range of motion of the body part. + // E.g. Mocap suit for the full body, gloves that measure rotation of each finger segment + VRSkeletalTracking_Full, + + VRSkeletalTrackingLevel_Count, + VRSkeletalTrackingLevel_Max = VRSkeletalTrackingLevel_Count - 1 +}; + + + +/** Holds the transform for a single bone */ +struct VRBoneTransform_t +{ + HmdVector4_t position; + HmdQuaternionf_t orientation; +}; + +/** Type used for referring to bones by their index */ +typedef int32_t BoneIndex_t; +const BoneIndex_t k_unInvalidBoneIndex = -1; + + /** error codes returned by Vr_Init */ // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp @@ -1119,6 +1445,8 @@ enum EVRInitError VRInitError_Init_FirmwareUpdateBusy = 138, VRInitError_Init_FirmwareRecoveryBusy = 139, VRInitError_Init_USBServiceBusy = 140, + VRInitError_Init_VRWebHelperStartupFailed = 141, + VRInitError_Init_TrackerManagerInitFailed = 142, VRInitError_Driver_Failed = 200, VRInitError_Driver_Unknown = 201, @@ -1208,6 +1536,14 @@ enum EVRTrackedCameraError VRTrackedCameraError_InvalidFrameBufferSize = 115, }; +enum EVRTrackedCameraFrameLayout +{ + EVRTrackedCameraFrameLayout_Mono = 0x0001, + EVRTrackedCameraFrameLayout_Stereo = 0x0002, + EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right) + EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right +}; + enum EVRTrackedCameraFrameType { VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted. @@ -1216,6 +1552,16 @@ enum EVRTrackedCameraFrameType MAX_CAMERA_FRAME_TYPES }; +enum EVRDistortionFunctionType +{ + VRDistortionFunctionType_None, + VRDistortionFunctionType_FTheta, + VRDistortionFucntionType_Extended_FTheta, + MAX_DISTORTION_FUNCTION_TYPES, +}; + +static const uint32_t k_unMaxDistortionFunctionParameters = 8; + typedef uint64_t TrackedCameraHandle_t; #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0) @@ -1230,6 +1576,8 @@ struct CameraVideoStreamFrameHeader_t uint32_t nFrameSequence; TrackedDevicePose_t standingTrackedDevicePose; + + uint64_t ulFrameExposureTime; // mid-point of the exposure of the image in host system ticks }; // Screenshot types @@ -1247,8 +1595,42 @@ struct DriverDirectMode_FrameTiming uint32_t m_nReprojectionFlags; }; +enum EVSync +{ + VSync_None, + VSync_WaitRender, // block following render work until vsync + VSync_NoWaitRender, // do not block following render work (allow to get started early) +}; + +enum EVRMuraCorrectionMode +{ + EVRMuraCorrectionMode_Default = 0, + EVRMuraCorrectionMode_NoCorrection +}; + +/** raw IMU data provided by IVRIOBuffer from paths to tracked devices with IMUs */ +enum Imu_OffScaleFlags +{ + OffScale_AccelX = 0x01, + OffScale_AccelY = 0x02, + OffScale_AccelZ = 0x04, + OffScale_GyroX = 0x08, + OffScale_GyroY = 0x10, + OffScale_GyroZ = 0x20, +}; + +struct ImuSample_t +{ + double fSampleTime; + HmdVector3d_t vAccel; + HmdVector3d_t vGyro; + uint32_t unOffScaleFlags; +}; + #pragma pack( pop ) +#define LINK_DYNAMIC + // figure out how to import from the VR API dll #if defined(_WIN32) @@ -1368,7 +1750,12 @@ class IVRSystem * pInstance must be the instance the application will use to query for the VkPhysicalDevice. The application * must create the VkInstance with extensions returned by IVRCompositor::GetVulkanInstanceExtensionsRequired enabled. * [macOS Only] - * Returns an id that should be used by the application. + * For TextureType_IOSurface returns the id that should be used by the application. + * On 10.13+ for TextureType_OpenGL returns the 'registryId' of the renderer which should be used + * by the application. See Apple Technical Q&A QA1168 for information on enumerating GL Renderers, and the + * new kCGLRPRegistryIDLow and kCGLRPRegistryIDHigh CGLRendererProperty values in the 10.13 SDK. + * Pre 10.13 for TextureType_OpenGL returns 0, as there is no dependable way to correlate the HMDs MTLDevice + * with a GL Renderer. */ virtual void GetOutputDevice( uint64_t *pnDevice, ETextureType textureType, VkInstance_T *pInstance = nullptr ) = 0; @@ -1441,10 +1828,10 @@ class IVRSystem */ virtual void ApplyTransform( TrackedDevicePose_t *pOutputPose, const TrackedDevicePose_t *pTrackedDevicePose, const HmdMatrix34_t *pTransform ) = 0; - /** Returns the device index associated with a specific role, for example the left hand or the right hand. */ + /** Returns the device index associated with a specific role, for example the left hand or the right hand. This function is deprecated in favor of the new IVRInput system. */ virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole( vr::ETrackedControllerRole unDeviceType ) = 0; - /** Returns the controller type associated with a device index. */ + /** Returns the controller type associated with a device index. This function is deprecated in favor of the new IVRInput system. */ virtual vr::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0; // ------------------------------------ @@ -1477,6 +1864,11 @@ class IVRSystem /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */ virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; + + /** Returns an array of one type of property. If the device index is not valid or the property is not a single value or an array of the specified type, + * this function will return 0. Otherwise it returns the number of bytes necessary to hold the array of properties. If unBufferSize is + * greater than the returned size and pBuffer is non-NULL, pBuffer is filled with the contents of array of properties. */ + virtual uint32_t GetArrayTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, PropertyTypeTag_t propType, void *pBuffer, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0; /** Returns a string property. If the device index is not valid or the property is not a string type this function will * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing @@ -1523,35 +1915,39 @@ class IVRSystem // ------------------------------------ /** Fills the supplied struct with the current state of the controller. Returns false if the controller index - * is invalid. */ + * is invalid. This function is deprecated in favor of the new IVRInput system. */ virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize ) = 0; /** fills the supplied struct with the current state of the controller and the provided pose with the pose of * the controller when the controller state was updated most recently. Use this form if you need a precise controller - * pose as input to your application when the user presses or releases a button. */ + * pose as input to your application when the user presses or releases a button. This function is deprecated in favor of the new IVRInput system. */ virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize, TrackedDevicePose_t *pTrackedDevicePose ) = 0; /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller - * and axis combination for 5ms. */ + * and axis combination for 5ms. This function is deprecated in favor of the new IVRInput system. */ virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0; - /** returns the name of an EVRButtonId enum value */ + /** returns the name of an EVRButtonId enum value. This function is deprecated in favor of the new IVRInput system. */ virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0; - /** returns the name of an EVRControllerAxisType enum value */ + /** returns the name of an EVRControllerAxisType enum value. This function is deprecated in favor of the new IVRInput system. */ virtual const char *GetControllerAxisTypeNameFromEnum( EVRControllerAxisType eAxisType ) = 0; - /** Tells OpenVR that this process wants exclusive access to controller button states and button events. Other apps will be notified that - * they have lost input focus with a VREvent_InputFocusCaptured event. Returns false if input focus could not be captured for - * some reason. */ - virtual bool CaptureInputFocus() = 0; + /** Returns true if this application is receiving input from the system. This would return false if + * system-related functionality is consuming the input stream. */ + virtual bool IsInputAvailable() = 0; - /** Tells OpenVR that this process no longer wants exclusive access to button states and button events. Other apps will be notified - * that input focus has been released with a VREvent_InputFocusReleased event. */ - virtual void ReleaseInputFocus() = 0; + /** Returns true SteamVR is drawing controllers on top of the application. Applications should consider + * not drawing anything attached to the user's hands in this case. */ + virtual bool IsSteamVRDrawingControllers() = 0; - /** Returns true if input focus is captured by another process. */ - virtual bool IsInputFocusCapturedByAnotherProcess() = 0; + /** Returns true if the user has put SteamVR into a mode that is distracting them from the application. + * For applications where this is appropriate, the application should pause ongoing activity. */ + virtual bool ShouldApplicationPause() = 0; + + /** Returns true if SteamVR is doing significant rendering work and the game should do what it can to reduce + * its own workload. One common way to do this is to reduce the size of the render target provided for each eye. */ + virtual bool ShouldApplicationReduceRenderingWork() = 0; // ------------------------------------ // Debug Methods @@ -1560,7 +1956,7 @@ class IVRSystem /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k, * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated. * The size of the response including its terminating null is returned. */ - virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; + virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, VR_OUT_STRING() char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; // ------------------------------------ // Firmware methods @@ -1588,7 +1984,7 @@ class IVRSystem }; -static const char * const IVRSystem_Version = "IVRSystem_017"; +static const char * const IVRSystem_Version = "IVRSystem_019"; } @@ -1643,8 +2039,7 @@ namespace vr VRApplicationProperty_NewsURL_String = 51, VRApplicationProperty_ImagePath_String = 52, VRApplicationProperty_Source_String = 53, - VRApplicationProperty_ActionManifestPath_String = 54, - VRApplicationProperty_ActionBindingPath_String = 55, + VRApplicationProperty_ActionManifestURL_String = 54, VRApplicationProperty_IsDashboardOverlay_Bool = 60, VRApplicationProperty_IsTemplate_Bool = 61, @@ -1702,7 +2097,7 @@ namespace vr /** Returns the key of the application for the specified Process Id. The buffer should be at least * k_unMaxApplicationKeyLength in order to fit the key. */ - virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Launches the application. The existing scene application will exit and then the new application will start. * This call is not valid for dashboard overlay applications. */ @@ -1756,21 +2151,21 @@ namespace vr virtual EVRApplicationError SetDefaultApplicationForMimeType( const char *pchAppKey, const char *pchMimeType ) = 0; /** return the app key that will open this mime type */ - virtual bool GetDefaultApplicationForMimeType( const char *pchMimeType, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual bool GetDefaultApplicationForMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Get the list of supported mime types for this application, comma-delimited */ - virtual bool GetApplicationSupportedMimeTypes( const char *pchAppKey, char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer ) = 0; + virtual bool GetApplicationSupportedMimeTypes( const char *pchAppKey, VR_OUT_STRING() char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer ) = 0; /** Get the list of app-keys that support this mime type, comma-delimited, the return value is number of bytes you need to return the full string */ - virtual uint32_t GetApplicationsThatSupportMimeType( const char *pchMimeType, char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer ) = 0; + virtual uint32_t GetApplicationsThatSupportMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer ) = 0; /** Get the args list from an app launch that had the process already running, you call this when you get a VREvent_ApplicationMimeTypeLoad */ - virtual uint32_t GetApplicationLaunchArguments( uint32_t unHandle, char *pchArgs, uint32_t unArgs ) = 0; + virtual uint32_t GetApplicationLaunchArguments( uint32_t unHandle, VR_OUT_STRING() char *pchArgs, uint32_t unArgs ) = 0; // --------------- Transition methods --------------- // /** Returns the app key for the application that is starting up */ - virtual EVRApplicationError GetStartingApplication( char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual EVRApplicationError GetStartingApplication( VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Returns the application transition state */ virtual EVRApplicationTransitionState GetTransitionState() = 0; @@ -1810,6 +2205,8 @@ namespace vr } // namespace vr // ivrsettings.h +#include + namespace vr { enum EVRSettingsError @@ -1852,6 +2249,88 @@ namespace vr //----------------------------------------------------------------------------- static const char * const IVRSettings_Version = "IVRSettings_002"; + class CVRSettingHelper + { + IVRSettings *m_pSettings; + public: + CVRSettingHelper( IVRSettings *pSettings ) + { + m_pSettings = pSettings; + } + + const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) + { + return m_pSettings->GetSettingsErrorNameFromEnum( eError ); + } + + // Returns true if file sync occurred (force or settings dirty) + bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->Sync( bForce, peError ); + } + + void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetBool( pchSection, pchSettingsKey, bValue, peError ); + } + + void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetInt32( pchSection, pchSettingsKey, nValue, peError ); + } + void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetFloat( pchSection, pchSettingsKey, flValue, peError ); + } + void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( pchSection, pchSettingsKey, pchValue, peError ); + } + void SetString( const std::string & sSection, const std::string & sSettingsKey, const std::string & sValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( sSection.c_str(), sSettingsKey.c_str(), sValue.c_str(), peError ); + } + + bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetBool( pchSection, pchSettingsKey, peError ); + } + int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetInt32( pchSection, pchSettingsKey, peError ); + } + float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetFloat( pchSection, pchSettingsKey, peError ); + } + void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) + { + m_pSettings->GetString( pchSection, pchSettingsKey, pchValue, unValueLen, peError ); + } + std::string GetString( const std::string & sSection, const std::string & sSettingsKey, EVRSettingsError *peError = nullptr ) + { + char buf[4096]; + vr::EVRSettingsError eError; + m_pSettings->GetString( sSection.c_str(), sSettingsKey.c_str(), buf, sizeof( buf ), &eError ); + if ( peError ) + *peError = eError; + if ( eError == vr::VRSettingsError_None ) + return buf; + else + return ""; + } + + void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveSection( pchSection, peError ); + } + void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveKeyInSection( pchSection, pchSettingsKey, peError ); + } + }; + + //----------------------------------------------------------------------------- // steamvr keys static const char * const k_pch_SteamVR_Section = "steamvr"; @@ -1873,21 +2352,19 @@ namespace vr static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage"; static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; - static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode"; - static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; - static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; - static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; - static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; - static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + static const char * const k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; + static const char * const k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; + static const char * const k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; - static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; + static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; + static const char * const k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; @@ -1897,18 +2374,41 @@ namespace vr static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; + static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; + static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; + static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; + static const char * const k_pch_SteamVR_DebugInput = "debugInput"; + static const char * const k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; + static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; + static const char * const k_pch_SteamVR_InputBindingUIBlock = "inputBindingUI"; + static const char * const k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; + static const char * const k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; + static const char * const k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; + static const char * const k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; + + //----------------------------------------------------------------------------- + // direct mode keys + static const char * const k_pch_DirectMode_Section = "direct_mode"; + static const char * const k_pch_DirectMode_Enable_Bool = "enable"; + static const char * const k_pch_DirectMode_Count_Int32 = "count"; + static const char * const k_pch_DirectMode_EdidVid_Int32 = "edidVid"; + static const char * const k_pch_DirectMode_EdidPid_Int32 = "edidPid"; //----------------------------------------------------------------------------- // lighthouse keys static const char * const k_pch_Lighthouse_Section = "driver_lighthouse"; static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; + static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; + static const char * const k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; //----------------------------------------------------------------------------- // null keys @@ -1929,6 +2429,7 @@ namespace vr static const char * const k_pch_UserInterface_Section = "userinterface"; static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; + static const char * const k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots"; static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; @@ -1951,9 +2452,7 @@ namespace vr //----------------------------------------------------------------------------- // perf keys static const char * const k_pch_Perf_Section = "perfcheck"; - static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; - static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; - static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; + static const char * const k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; static const char * const k_pch_Perf_TestData_Float = "perfTestData"; @@ -1984,6 +2483,7 @@ namespace vr static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; + static const char * const k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; //----------------------------------------------------------------------------- // audio keys @@ -2010,6 +2510,9 @@ namespace vr static const char * const k_pch_Dashboard_Section = "dashboard"; static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; + static const char * const k_pch_Dashboard_EnableWebUI = "webUI"; + static const char * const k_pch_Dashboard_EnableWebUIDevTools = "webUIDevTools"; + static const char * const k_pch_Dashboard_EnableWebUIDashboardReplacement = "webUIDashboard"; //----------------------------------------------------------------------------- // model skin keys @@ -2019,6 +2522,44 @@ namespace vr // driver keys - These could be checked in any driver_ section static const char * const k_pch_Driver_Enable_Bool = "enable"; + //----------------------------------------------------------------------------- + // web interface keys + static const char* const k_pch_WebInterface_Section = "WebInterface"; + static const char* const k_pch_WebInterface_WebEnable_Bool = "WebEnable"; + static const char* const k_pch_WebInterface_WebPort_String = "WebPort"; + + //----------------------------------------------------------------------------- + // vrwebhelper keys + static const char* const k_pch_VRWebHelper_Section = "VRWebHelper"; + static const char* const k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; + static const char* const k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; + + //----------------------------------------------------------------------------- + // tracking overrides - keys are device paths, values are the device paths their + // tracking/pose information overrides + static const char* const k_pch_TrackingOverride_Section = "TrackingOverrides"; + + //----------------------------------------------------------------------------- + // per-app keys - the section name for these is the app key itself. Some of these are prefixed by the controller type + static const char* const k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + static const char* const k_pch_App_ActionManifestURL_String = "ActionManifestURL"; + + //----------------------------------------------------------------------------- + // configuration for trackers + static const char * const k_pch_Trackers_Section = "trackers"; + + //----------------------------------------------------------------------------- + // configuration for desktop UI windows + static const char * const k_pch_DesktopUI_Section = "DesktopUI"; + + //----------------------------------------------------------------------------- + // Last known keys for righting recovery + static const char * const k_pch_LastKnown_Section = "LastKnown"; + static const char* const k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; + static const char* const k_pch_LastKnown_HMDModel_String = "HMDModel"; + } // namespace vr // ivrchaperone.h @@ -2155,6 +2696,9 @@ class IVRChaperoneSetup /** Sets the Collision Bounds in the working copy. */ virtual void SetWorkingCollisionBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0; + /** Sets the Collision Bounds in the working copy. */ + virtual void SetWorkingPerimeter( VR_ARRAY_COUNT( unPointCount ) HmdVector2_t *pPointBuffer, uint32_t unPointCount ) = 0; + /** Sets the preferred seated position in the working copy. */ virtual void SetWorkingSeatedZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatSeatedZeroPoseToRawTrackingPose ) = 0; @@ -2167,17 +2711,17 @@ class IVRChaperoneSetup /** Returns the preferred seated position. */ virtual bool GetLiveSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0; - virtual void SetWorkingCollisionBoundsTagsInfo( VR_ARRAY_COUNT(unTagCount) uint8_t *pTagsBuffer, uint32_t unTagCount ) = 0; - virtual bool GetLiveCollisionBoundsTagsInfo( VR_OUT_ARRAY_COUNT(punTagCount) uint8_t *pTagsBuffer, uint32_t *punTagCount ) = 0; - - virtual bool SetWorkingPhysicalBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0; - virtual bool GetLivePhysicalBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0; - virtual bool ExportLiveToBuffer( VR_OUT_STRING() char *pBuffer, uint32_t *pnBufferLength ) = 0; virtual bool ImportFromBufferToWorking( const char *pBuffer, uint32_t nImportFlags ) = 0; + + /** Shows the chaperone data in the working set to preview in the compositor.*/ + virtual void ShowWorkingSetPreview() = 0; + + /** Hides the chaperone data in the working set to preview in the compositor (if it was visible).*/ + virtual void HideWorkingSetPreview() = 0; }; -static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; +static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_006"; } @@ -2222,6 +2766,21 @@ const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicate // NumFramePresents > 1 also indicates the scene texture was reused, // and also the number of times that it was presented in total. +const uint32_t VRCompositor_ReprojectionMotion = 0x08; // This flag indicates whether or not motion smoothing was triggered for this frame + +const uint32_t VRCompositor_PredictionMask = 0x30; // The runtime may predict more than one frame (up to four) ahead if + // it detects the application is taking too long to render. These two + // bits will contain the count of additional frames (normally zero). + // Use the VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES macro to read from + // the latest frame timing entry. + +const uint32_t VRCompositor_ThrottleMask = 0xC0; // Number of frames the compositor is throttling the application. + // Use the VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES macro to read from + // the latest frame timing entry. + +#define VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_PredictionMask ) >> 4 ) +#define VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_ThrottleMask ) >> 6 ) + /** Provides a single frame's timing information to the app */ struct Compositor_FrameTiming { @@ -2261,6 +2820,9 @@ struct Compositor_FrameTiming float m_flCompositorRenderStartMs; vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame + + uint32_t m_nNumVSyncsReadyForUse; + uint32_t m_nNumVSyncsToFirstView; }; /** Cumulative stats for current application. These are not cleared until a new app connects, @@ -2423,7 +2985,7 @@ class IVRCompositor /** Returns true if the mirror window is shown. */ virtual bool IsMirrorWindowVisible() = 0; - /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */ + /** Writes back buffer and stereo left/right pair from the application to a 'screenshots' folder in the SteamVR runtime root. */ virtual void CompositorDumpImages() = 0; /** Let an app know it should be rendering with low resources. */ @@ -2486,6 +3048,11 @@ class IVRCompositor * will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread. * Returns VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled. */ virtual EVRCompositorError SubmitExplicitTimingData() = 0; + + /** Indicates whether or not motion smoothing is enabled by the user settings. + * If you want to know if motion smoothing actually triggered due to a late frame, check Compositor_FrameTiming + * m_nReprojectionFlags & VRCompositor_ReprojectionMotion instead. */ + virtual bool IsMotionSmoothingEnabled() = 0; }; static const char * const IVRCompositor_Version = "IVRCompositor_022"; @@ -2659,6 +3226,10 @@ namespace vr // If set, the overlay will be shown in the dashboard, otherwise it will be hidden. VROverlayFlags_VisibleInDashboard = 15, + + // If this is set and the overlay's input method is not none, the system-wide laser mouse + // mode will be activated whenever this overlay is visible. + VROverlayFlags_MakeOverlaysInteractiveIfVisible = 16, }; enum VRMessageOverlayResponse @@ -2872,7 +3443,7 @@ namespace vr virtual EVROverlayError GetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, VRTextureBounds_t *pOverlayTextureBounds ) = 0; /** Gets render model to draw behind this overlay */ - virtual uint32_t GetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, char *pchValue, uint32_t unBufferSize, HmdColor_t *pColor, vr::EVROverlayError *pError ) = 0; + virtual uint32_t GetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, HmdColor_t *pColor, vr::EVROverlayError *pError ) = 0; /** Sets render model to draw behind this overlay and the vertex color to use, pass null for pColor to match the overlays vertex color. The model is scaled by the same amount as the overlay, with a default of 1m. */ @@ -2898,7 +3469,7 @@ namespace vr virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, const char *pchComponentName ) = 0; /** Gets the transform information when the overlay is rendering on a component. */ - virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, char *pchComponentName, uint32_t unComponentNameSize ) = 0; + virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, VR_OUT_STRING() char *pchComponentName, uint32_t unComponentNameSize ) = 0; /** Gets the transform if it is relative to another overlay. Returns an error if the transform is some other type. */ virtual vr::EVROverlayError GetOverlayTransformOverlayRelative( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t *ulOverlayHandleParent, HmdMatrix34_t *pmatParentOverlayToOverlayTransform ) = 0; @@ -2944,13 +3515,6 @@ namespace vr * specified settings. Returns false if there is no intersection. */ virtual bool ComputeOverlayIntersection( VROverlayHandle_t ulOverlayHandle, const VROverlayIntersectionParams_t *pParams, VROverlayIntersectionResults_t *pResults ) = 0; - /** Processes mouse input from the specified controller as though it were a mouse pointed at a compositor overlay with the - * specified settings. The controller is treated like a laser pointer on the -z axis. The point where the laser pointer would - * intersect with the overlay is the mouse position, the trigger is left mouse, and the track pad is right mouse. - * - * Return true if the controller is pointed at the overlay and an event was generated. */ - virtual bool HandleControllerOverlayInteractionAsMouse( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unControllerDeviceIndex ) = 0; - /** Returns true if the specified overlay is the hover target. An overlay is the hover target when it is the last overlay "moused over" * by the virtual mouse pointer */ virtual bool IsHoverTargetOverlay( VROverlayHandle_t ulOverlayHandle ) = 0; @@ -2971,7 +3535,7 @@ namespace vr virtual EVROverlayError MoveGamepadFocusToNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom ) = 0; /** Sets the analog input to Dual Analog coordinate scale for the specified overlay. */ - virtual EVROverlayError SetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, const HmdVector2_t & vCenter, float fRadius ) = 0; + virtual EVROverlayError SetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, const HmdVector2_t *pvCenter, float fRadius ) = 0; /** Gets the analog input to Dual Analog coordinate scale for the specified overlay. */ virtual EVROverlayError GetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, HmdVector2_t *pvCenter, float *pfRadius ) = 0; @@ -3085,7 +3649,7 @@ namespace vr virtual void CloseMessageOverlay() = 0; }; - static const char * const IVROverlay_Version = "IVROverlay_017"; + static const char * const IVROverlay_Version = "IVROverlay_019"; } // namespace vr @@ -3273,6 +3837,9 @@ class IVRRenderModels * If the pchRenderModelName or pchComponentName is invalid, this will return false (and transforms will be set to identity). * Otherwise, return true * Note: For dynamic objects, visibility may be dynamic. (I.e., true/false will be returned based on controller state and controller mode state ) */ + virtual bool GetComponentStateForDevicePath( const char *pchRenderModelName, const char *pchComponentName, vr::VRInputValueHandle_t devicePath, const vr::RenderModel_ControllerMode_State_t *pState, vr::RenderModel_ComponentState_t *pComponentState ) = 0; + + /** This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead. */ virtual bool GetComponentState( const char *pchRenderModelName, const char *pchComponentName, const vr::VRControllerState_t *pControllerState, const RenderModel_ControllerMode_State_t *pState, RenderModel_ComponentState_t *pComponentState ) = 0; /** Returns true if the render model has a component with the specified name */ @@ -3290,7 +3857,7 @@ class IVRRenderModels virtual const char *GetRenderModelErrorNameFromEnum( vr::EVRRenderModelError error ) = 0; }; -static const char * const IVRRenderModels_Version = "IVRRenderModels_005"; +static const char * const IVRRenderModels_Version = "IVRRenderModels_006"; } @@ -3340,9 +3907,9 @@ class IVRTrackedCamera /** Gets size of the image frame. */ virtual vr::EVRTrackedCameraError GetCameraFrameSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pnWidth, uint32_t *pnHeight, uint32_t *pnFrameBufferSize ) = 0; - virtual vr::EVRTrackedCameraError GetCameraIntrinsics( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0; + virtual vr::EVRTrackedCameraError GetCameraIntrinsics( vr::TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0; - virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; + virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; /** Acquiring streaming service permits video streaming for the caller. Releasing hints the system that video services do not need to be maintained for this client. * If the camera has not already been activated, a one time spin up may incur some auto exposure as well as initial streaming frame delays. @@ -3374,7 +3941,7 @@ class IVRTrackedCamera virtual vr::EVRTrackedCameraError ReleaseVideoStreamTextureGL( vr::TrackedCameraHandle_t hTrackedCamera, vr::glUInt_t glTextureId ) = 0; }; -static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_003"; +static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_005"; } // namespace vr @@ -3505,7 +4072,7 @@ class IVRResources /** Provides the full path to the specified resource. Resource names can include named directories for * drivers and other things, and this resolves all of those and returns the actual physical path. * pchResourceTypeDirectory is the subdirectory of resources to look in. */ - virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, char *pchPathBuffer, uint32_t unBufferLen ) = 0; + virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0; }; static const char * const IVRResources_Version = "IVRResources_001"; @@ -3523,6 +4090,8 @@ class IVRDriverManager /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */ virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; + + virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0; }; static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; @@ -3530,6 +4099,368 @@ static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; } // namespace vr + +// ivrinput.h +namespace vr +{ + static const uint32_t k_unMaxActionNameLength = 64; + static const uint32_t k_unMaxActionSetNameLength = 64; + static const uint32_t k_unMaxActionOriginCount = 16; + static const uint32_t k_unMaxBoneNameLength = 32; + + enum EVRSkeletalTransformSpace + { + VRSkeletalTransformSpace_Model = 0, + VRSkeletalTransformSpace_Parent = 1 + }; + + enum EVRSkeletalReferencePose + { + VRSkeletalReferencePose_BindPose = 0, + VRSkeletalReferencePose_OpenHand, + VRSkeletalReferencePose_Fist, + VRSkeletalReferencePose_GripLimit + }; + + enum EVRFinger + { + VRFinger_Thumb = 0, + VRFinger_Index, + VRFinger_Middle, + VRFinger_Ring, + VRFinger_Pinky, + VRFinger_Count + }; + + enum EVRFingerSplay + { + VRFingerSplay_Thumb_Index = 0, + VRFingerSplay_Index_Middle, + VRFingerSplay_Middle_Ring, + VRFingerSplay_Ring_Pinky, + VRFingerSplay_Count + }; + + enum EVRInputFilterCancelType + { + VRInputFilterCancel_Timers = 0, + VRInputFilterCancel_Momentum = 1, + }; + + enum EVRInputStringBits + { + VRInputString_Hand = 0x01, + VRInputString_ControllerType = 0x02, + VRInputString_InputSource = 0x04, + + VRInputString_All = 0xFFFFFFFF + }; + + struct InputAnalogActionData_t + { + /** Whether or not this action is currently available to be bound in the active action set */ + bool bActive; + + /** The origin that caused this action's current state */ + VRInputValueHandle_t activeOrigin; + + /** The current state of this action; will be delta updates for mouse actions */ + float x, y, z; + + /** Deltas since the previous call to UpdateActionState() */ + float deltaX, deltaY, deltaZ; + + /** Time relative to now when this event happened. Will be negative to indicate a past time. */ + float fUpdateTime; + }; + + struct InputDigitalActionData_t + { + /** Whether or not this action is currently available to be bound in the active action set */ + bool bActive; + + /** The origin that caused this action's current state */ + VRInputValueHandle_t activeOrigin; + + /** The current state of this action; will be true if currently pressed */ + bool bState; + + /** This is true if the state has changed since the last frame */ + bool bChanged; + + /** Time relative to now when this event happened. Will be negative to indicate a past time. */ + float fUpdateTime; + }; + + struct InputPoseActionData_t + { + /** Whether or not this action is currently available to be bound in the active action set */ + bool bActive; + + /** The origin that caused this action's current state */ + VRInputValueHandle_t activeOrigin; + + /** The current state of this action */ + TrackedDevicePose_t pose; + }; + + struct InputSkeletalActionData_t + { + /** Whether or not this action is currently available to be bound in the active action set */ + bool bActive; + + /** The origin that caused this action's current state */ + VRInputValueHandle_t activeOrigin; + }; + + struct InputOriginInfo_t + { + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char rchRenderModelComponentName[128]; + }; + + struct VRActiveActionSet_t + { + /** This is the handle of the action set to activate for this frame. */ + VRActionSetHandle_t ulActionSet; + + /** This is the handle of a device path that this action set should be active for. To + * activate for all devices, set this to k_ulInvalidInputValueHandle. */ + VRInputValueHandle_t ulRestrictedToDevice; + + /** The action set to activate for all devices other than ulRestrictedDevice. If + * ulRestrictedToDevice is set to k_ulInvalidInputValueHandle, this parameter is + * ignored. */ + VRActionSetHandle_t ulSecondaryActionSet; + + // This field is ignored + uint32_t unPadding; + + /** The priority of this action set relative to other action sets. Any inputs + * bound to a source (e.g. trackpad, joystick, trigger) will disable bindings in + * other active action sets with a smaller priority. */ + int32_t nPriority; + }; + + /** Contains summary information about the current skeletal pose */ + struct VRSkeletalSummaryData_t + { + /** The amount that each finger is 'curled' inwards towards the palm. In the case of the thumb, + * this represents how much the thumb is wrapped around the fist. + * 0 means straight, 1 means fully curled */ + float flFingerCurl[ VRFinger_Count ]; + + /** The amount that each pair of adjacent fingers are separated. + * 0 means the digits are touching, 1 means they are fully separated. + */ + float flFingerSplay[ VRFingerSplay_Count ]; + }; + + + class IVRInput + { + public: + + // --------------- Handle management --------------- // + + /** Sets the path to the action manifest JSON file that is used by this application. If this information + * was set on the Steam partner site, calls to this function are ignored. If the Steam partner site + * setting and the path provided by this call are different, VRInputError_MismatchedActionManifest is returned. + * This call must be made before the first call to UpdateActionState or IVRSystem::PollNextEvent. */ + virtual EVRInputError SetActionManifestPath( const char *pchActionManifestPath ) = 0; + + /** Returns a handle for an action set. This handle is used for all performance-sensitive calls. */ + virtual EVRInputError GetActionSetHandle( const char *pchActionSetName, VRActionSetHandle_t *pHandle ) = 0; + + /** Returns a handle for an action. This handle is used for all performance-sensitive calls. */ + virtual EVRInputError GetActionHandle( const char *pchActionName, VRActionHandle_t *pHandle ) = 0; + + /** Returns a handle for any path in the input system. E.g. /user/hand/right */ + virtual EVRInputError GetInputSourceHandle( const char *pchInputSourcePath, VRInputValueHandle_t *pHandle ) = 0; + + // --------------- Reading action state ------------------- // + + /** Reads the current state into all actions. After this call, the results of Get*Action calls + * will be the same until the next call to UpdateActionState. */ + virtual EVRInputError UpdateActionState( VR_ARRAY_COUNT( unSetCount ) VRActiveActionSet_t *pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount ) = 0; + + /** Reads the state of a digital action given its handle. This will return VRInputError_WrongType if the type of + * action is something other than digital */ + virtual EVRInputError GetDigitalActionData( VRActionHandle_t action, InputDigitalActionData_t *pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of an analog action given its handle. This will return VRInputError_WrongType if the type of + * action is something other than analog */ + virtual EVRInputError GetAnalogActionData( VRActionHandle_t action, InputAnalogActionData_t *pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of a pose action given its handle. */ + virtual EVRInputError GetPoseActionData( VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t *pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of a skeletal action given its handle. */ + virtual EVRInputError GetSkeletalActionData( VRActionHandle_t action, InputSkeletalActionData_t *pActionData, uint32_t unActionDataSize ) = 0; + + // --------------- Static Skeletal Data ------------------- // + + /** Reads the number of bones in skeleton associated with the given action */ + virtual EVRInputError GetBoneCount( VRActionHandle_t action, uint32_t* pBoneCount ) = 0; + + /** Fills the given array with the index of each bone's parent in the skeleton associated with the given action */ + virtual EVRInputError GetBoneHierarchy( VRActionHandle_t action, VR_ARRAY_COUNT( unIndexArayCount ) BoneIndex_t* pParentIndices, uint32_t unIndexArayCount ) = 0; + + /** Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action */ + virtual EVRInputError GetBoneName( VRActionHandle_t action, BoneIndex_t nBoneIndex, VR_OUT_STRING() char* pchBoneName, uint32_t unNameBufferSize ) = 0; + + /** Fills the given buffer with the transforms for a specific static skeletal reference pose */ + virtual EVRInputError GetSkeletalReferenceTransforms( VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + /** Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose */ + virtual EVRInputError GetSkeletalTrackingLevel( VRActionHandle_t action, EVRSkeletalTrackingLevel* pSkeletalTrackingLevel ) = 0; + + // --------------- Dynamic Skeletal Data ------------------- // + + /** Reads the state of the skeletal bone data associated with this action and copies it into the given buffer. */ + virtual EVRInputError GetSkeletalBoneData( VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + /** Reads summary information about the current pose of the skeleton associated with the given action. */ + virtual EVRInputError GetSkeletalSummaryData( VRActionHandle_t action, VRSkeletalSummaryData_t * pSkeletalSummaryData ) = 0; + + /** Reads the state of the skeletal bone data in a compressed form that is suitable for + * sending over the network. The required buffer size will never exceed ( sizeof(VR_BoneTransform_t)*boneCount + 2). + * Usually the size will be much smaller. */ + virtual EVRInputError GetSkeletalBoneDataCompressed( VRActionHandle_t action, EVRSkeletalMotionRange eMotionRange, VR_OUT_BUFFER_COUNT( unCompressedSize ) void *pvCompressedData, uint32_t unCompressedSize, uint32_t *punRequiredCompressedSize ) = 0; + + /** Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array. */ + virtual EVRInputError DecompressSkeletalBoneData( const void *pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + // --------------- Haptics ------------------- // + + /** Triggers a haptic event as described by the specified action */ + virtual EVRInputError TriggerHapticVibrationAction( VRActionHandle_t action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + // --------------- Action Origins ---------------- // + + /** Retrieve origin handles for an action */ + virtual EVRInputError GetActionOrigins( VRActionSetHandle_t actionSetHandle, VRActionHandle_t digitalActionHandle, VR_ARRAY_COUNT( originOutCount ) VRInputValueHandle_t *originsOut, uint32_t originOutCount ) = 0; + + /** Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the + application to specify which parts of the origin's information it wants a string for. */ + virtual EVRInputError GetOriginLocalizedName( VRInputValueHandle_t origin, VR_OUT_STRING() char *pchNameArray, uint32_t unNameArraySize, int32_t unStringSectionsToInclude ) = 0; + + /** Retrieves useful information for the origin of this action */ + virtual EVRInputError GetOriginTrackedDeviceInfo( VRInputValueHandle_t origin, InputOriginInfo_t *pOriginInfo, uint32_t unOriginInfoSize ) = 0; + + /** Shows the current binding for the action in-headset */ + virtual EVRInputError ShowActionOrigins( VRActionSetHandle_t actionSetHandle, VRActionHandle_t ulActionHandle ) = 0; + + /** Shows the current binding all the actions in the specified action sets */ + virtual EVRInputError ShowBindingsForActionSet( VR_ARRAY_COUNT( unSetCount ) VRActiveActionSet_t *pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount, VRInputValueHandle_t originToHighlight ) = 0; + }; + + static const char * const IVRInput_Version = "IVRInput_005"; + +} // namespace vr + +// ivriobuffer.h +namespace vr +{ + +typedef uint64_t IOBufferHandle_t; +static const uint64_t k_ulInvalidIOBufferHandle = 0; + + enum EIOBufferError + { + IOBuffer_Success = 0, + IOBuffer_OperationFailed = 100, + IOBuffer_InvalidHandle = 101, + IOBuffer_InvalidArgument = 102, + IOBuffer_PathExists = 103, + IOBuffer_PathDoesNotExist = 104, + IOBuffer_Permission = 105, + }; + + enum EIOBufferMode + { + IOBufferMode_Read = 0x0001, + IOBufferMode_Write = 0x0002, + IOBufferMode_Create = 0x0200, + }; + + // ---------------------------------------------------------------------------------------------- + // Purpose: + // ---------------------------------------------------------------------------------------------- + class IVRIOBuffer + { + public: + /** opens an existing or creates a new IOBuffer of unSize bytes */ + virtual vr::EIOBufferError Open( const char *pchPath, vr::EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, vr::IOBufferHandle_t *pulBuffer ) = 0; + + /** closes a previously opened or created buffer */ + virtual vr::EIOBufferError Close( vr::IOBufferHandle_t ulBuffer ) = 0; + + /** reads up to unBytes from buffer into *pDst, returning number of bytes read in *punRead */ + virtual vr::EIOBufferError Read( vr::IOBufferHandle_t ulBuffer, void *pDst, uint32_t unBytes, uint32_t *punRead ) = 0; + + /** writes unBytes of data from *pSrc into a buffer. */ + virtual vr::EIOBufferError Write( vr::IOBufferHandle_t ulBuffer, void *pSrc, uint32_t unBytes ) = 0; + + /** retrieves the property container of an buffer. */ + virtual vr::PropertyContainerHandle_t PropertyContainer( vr::IOBufferHandle_t ulBuffer ) = 0; + }; + + static const char *IVRIOBuffer_Version = "IVRIOBuffer_001"; +} + +// ivrspatialanchors.h +namespace vr +{ + static const SpatialAnchorHandle_t k_ulInvalidSpatialAnchorHandle = 0; + + struct SpatialAnchorPose_t + { + HmdMatrix34_t mAnchorToAbsoluteTracking; + }; + + class IVRSpatialAnchors + { + public: + + /** Returns a handle for an spatial anchor described by "descriptor". On success, pHandle + * will contain a handle valid for this session. Caller can wait for an event or occasionally + * poll GetSpatialAnchorPose() to find the virtual coordinate associated with this anchor. */ + virtual EVRSpatialAnchorError CreateSpatialAnchorFromDescriptor( const char *pchDescriptor, SpatialAnchorHandle_t *pHandleOut ) = 0; + + /** Returns a handle for an new spatial anchor at pPose. On success, pHandle + * will contain a handle valid for this session. Caller can wait for an event or occasionally + * poll GetSpatialAnchorDescriptor() to find the permanent descriptor for this pose. + * The result of GetSpatialAnchorPose() may evolve from this initial position if the driver chooses + * to update it. + * The anchor will be associated with the driver that provides unDeviceIndex, and the driver may use that specific + * device as a hint for how to best create the anchor. + * The eOrigin must match whatever tracking origin you are working in (seated/standing/raw). + * This should be called when the user is close to (and ideally looking at/interacting with) the target physical + * location. At that moment, the driver will have the most information about how to recover that physical point + * in the future, and the quality of the anchor (when the descriptor is re-used) will be highest. + * The caller may decide to apply offsets from this initial pose, but is advised to stay relatively close to the + * original pose location for highest fidelity. */ + virtual EVRSpatialAnchorError CreateSpatialAnchorFromPose( TrackedDeviceIndex_t unDeviceIndex, ETrackingUniverseOrigin eOrigin, SpatialAnchorPose_t *pPose, SpatialAnchorHandle_t *pHandleOut ) = 0; + + /** Get the pose for a given handle. This is intended to be cheap enough to call every frame (or fairly often) + * so that the driver can refine this position when it has more information available. */ + virtual EVRSpatialAnchorError GetSpatialAnchorPose( SpatialAnchorHandle_t unHandle, ETrackingUniverseOrigin eOrigin, SpatialAnchorPose_t *pPoseOut ) = 0; + + /** Get the descriptor for a given handle. This will be empty for handles where the driver has not + * yet built a descriptor. It will be the application-supplied descriptor for previously saved anchors + * that the application is requesting poses for. If the driver has called UpdateSpatialAnchorDescriptor() + * already in this session, it will be the descriptor provided by the driver. + * Returns true if the descriptor fits into the buffer, else false. Buffer size should be at least + * k_unMaxSpatialAnchorDescriptorSize. */ + virtual EVRSpatialAnchorError GetSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, VR_OUT_STRING() char *pchDescriptorOut, uint32_t *punDescriptorBufferLenInOut ) = 0; + + }; + + static const char * const IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; + +} // namespace vr // End #endif // _OPENVR_API @@ -3537,6 +4468,8 @@ static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; namespace vr { +#if !defined( OPENVR_INTERFACE_INTERNAL ) + /** Finds the active installation of the VR API and initializes it. The provided path must be absolute * or relative to the current working directory. These are the local install versions of the equivalent * functions in steamvr.h and will work without a local Steam install. @@ -3556,6 +4489,63 @@ namespace vr * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants * to know if initializing VR is a possibility but isn't ready to take that step yet. */ +#ifdef LINK_DYNAMIC + bool (VR_CALLTYPE *VR_IsHmdPresent)(); + bool (VR_CALLTYPE *VR_IsRuntimeInstalled)(); + const char *(VR_CALLTYPE *VR_RuntimePath)(); + const char *(VR_CALLTYPE *VR_GetVRInitErrorAsSymbol)( EVRInitError error ); + const char *(VR_CALLTYPE *VR_GetVRInitErrorAsEnglishDescription)( EVRInitError error ); + void *(VR_CALLTYPE *VR_GetGenericInterface)( const char *pchInterfaceVersion, EVRInitError *peError ); + bool (VR_CALLTYPE *VR_IsInterfaceVersionValid)( const char *pchInterfaceVersion ); + uint32_t (VR_CALLTYPE *VR_GetInitToken)(); + uint32_t (VR_CALLTYPE *VR_InitInternal2)( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); + void (VR_CALLTYPE *VR_ShutdownInternal)(); + +// dummy + uint32_t VR_CALLTYPE def_VR_InitInternal2(vr::EVRInitError *peError, vr::EVRApplicationType eApplicationType, const char *pStartupInfo) { + *peError = vr::VRInitError_None; + return 0; + } + + void VR_CALLTYPE def_VR_ShutdownInternal() { + // + } + + bool VR_CALLTYPE def_VR_IsInterfaceVersionValid(const char *pchInterfaceVersion) { + return false; + } + + const char* VR_CALLTYPE def_VR_GetVRInitErrorAsEnglishDescription( vr::EVRInitError error) { + return "openvr_api.dll not found"; + } + + void VR_InitLibrary(const char *name) { + #define VR_GetProc(x) (x = (decltype(x))GetProcAddress(h, #x)) + + if (!VR_GetGenericInterface) { + HMODULE h = LoadLibrary(name); + VR_GetProc(VR_IsHmdPresent); + VR_GetProc(VR_IsRuntimeInstalled); + VR_GetProc(VR_RuntimePath); + VR_GetProc(VR_GetVRInitErrorAsSymbol); + VR_GetProc(VR_GetVRInitErrorAsEnglishDescription); + VR_GetProc(VR_GetGenericInterface); + VR_GetProc(VR_IsInterfaceVersionValid); + VR_GetProc(VR_GetInitToken); + VR_GetProc(VR_InitInternal2); + VR_GetProc(VR_ShutdownInternal); + } + + if (!VR_InitInternal2) { + VR_InitInternal2 = def_VR_InitInternal2; + VR_ShutdownInternal = def_VR_ShutdownInternal; + VR_IsInterfaceVersionValid = def_VR_IsInterfaceVersionValid; + VR_GetVRInitErrorAsEnglishDescription = def_VR_GetVRInitErrorAsEnglishDescription; + } + + #undef GetProc + } +#else VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent(); /** Returns true if the OpenVR runtime is installed. */ @@ -3583,6 +4573,10 @@ namespace vr /** Returns a token that represents whether the VR interface handles need to be reloaded */ VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken(); + VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); + VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal(); +#endif + // These typedefs allow old enum names from SDK 0.9.11 to be used in applications. // They will go away in the future. typedef EVRInitError HmdError; @@ -3764,6 +4758,38 @@ namespace vr return m_pVRDriverManager; } + IVRInput *VRInput() + { + CheckClear(); + if ( !m_pVRInput ) + { + EVRInitError eError; + m_pVRInput = (IVRInput *)VR_GetGenericInterface( IVRInput_Version, &eError ); + } + return m_pVRInput; + } + + IVRSpatialAnchors *VRSpatialAnchors() + { + CheckClear(); + if ( !m_pVRSpatialAnchors ) + { + EVRInitError eError; + m_pVRSpatialAnchors = (IVRSpatialAnchors *)VR_GetGenericInterface( IVRSpatialAnchors_Version, &eError ); + } + return m_pVRSpatialAnchors; + } + + IVRIOBuffer *VRIOBuffer() + { + if ( !m_pVRIOBuffer ) + { + EVRInitError eError; + m_pVRIOBuffer = ( IVRIOBuffer * )VR_GetGenericInterface( IVRIOBuffer_Version, &eError ); + } + return m_pVRIOBuffer; + } + private: IVRSystem *m_pVRSystem; IVRChaperone *m_pVRChaperone; @@ -3778,6 +4804,9 @@ namespace vr IVRTrackedCamera *m_pVRTrackedCamera; IVRScreenshots *m_pVRScreenshots; IVRDriverManager *m_pVRDriverManager; + IVRInput *m_pVRInput; + IVRIOBuffer *m_pVRIOBuffer; + IVRSpatialAnchors *m_pVRSpatialAnchors; }; inline COpenVRContext &OpenVRInternal_ModuleContext() @@ -3799,6 +4828,9 @@ namespace vr inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); } inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); } inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleContext().VRDriverManager(); } + inline IVRInput *VR_CALLTYPE VRInput() { return OpenVRInternal_ModuleContext().VRInput(); } + inline IVRIOBuffer *VR_CALLTYPE VRIOBuffer() { return OpenVRInternal_ModuleContext().VRIOBuffer(); } + inline IVRSpatialAnchors *VR_CALLTYPE VRSpatialAnchors() { return OpenVRInternal_ModuleContext().VRSpatialAnchors(); } inline void COpenVRContext::Clear() { @@ -3815,10 +4847,10 @@ namespace vr m_pVRResources = nullptr; m_pVRScreenshots = nullptr; m_pVRDriverManager = nullptr; + m_pVRInput = nullptr; + m_pVRIOBuffer = nullptr; + m_pVRSpatialAnchors = nullptr; } - - VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); - VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal(); /** Finds the active installation of vrclient.dll and initializes it */ inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ) @@ -3854,4 +4886,6 @@ namespace vr { VR_ShutdownInternal(); } + +#endif // OPENVR_INTERFACE_INTERNAL } diff --git a/src/libs/openvr/openvr_api.lib b/src/libs/openvr/openvr_api.lib deleted file mode 100644 index 2ae7254d..00000000 Binary files a/src/libs/openvr/openvr_api.lib and /dev/null differ diff --git a/src/libs/stb_vorbis/stb_vorbis.c b/src/libs/stb_vorbis/stb_vorbis.c index 759065b0..3e5c2504 100644 --- a/src/libs/stb_vorbis/stb_vorbis.c +++ b/src/libs/stb_vorbis/stb_vorbis.c @@ -1,4 +1,4 @@ -// Ogg Vorbis audio decoder - v1.14 - public domain +// Ogg Vorbis audio decoder - v1.22 - public domain // http://nothings.org/stb_vorbis/ // // Original version written by Sean Barrett in 2007. @@ -26,17 +26,28 @@ // Terje Mathisen Niklas Frykholm Andy Hill // Casey Muratori John Bolton Gargaj // Laurent Gomila Marc LeBlanc Ronny Chevalier -// Bernhard Wodo Evan Balster alxprd@github +// Bernhard Wodo Evan Balster github:alxprd // Tom Beaumont Ingo Leitgeb Nicolas Guillemot // Phillip Bennefall Rohit Thiago Goulart -// manxorist@github saga musix github:infatum -// Timur Gagiev +// github:manxorist Saga Musix github:infatum +// Timur Gagiev Maxwell Koo Peter Waller +// github:audinowho Dougall Johnson David Reid +// github:Clownacy Pedro J. Estebanez Remi Verschelde +// AnthoFoxo github:morlat Gabriel Ravier // // Partial history: +// 1.22 - 2021-07-11 - various small fixes +// 1.21 - 2021-07-02 - fix bug for files with no comments +// 1.20 - 2020-07-11 - several small fixes +// 1.19 - 2020-02-05 - warnings +// 1.18 - 2020-02-02 - fix seek bugs; parse header comments; misc warnings etc. +// 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure) +// 1.16 - 2019-03-04 - fix warnings +// 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found // 1.14 - 2018-02-11 - delete bogus dealloca usage // 1.13 - 2018-01-29 - fix truncation of last frame (hopefully) // 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files -// 1.11 - 2017-07-23 - fix MinGW compilation +// 1.11 - 2017-07-23 - fix MinGW compilation // 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory // 1.09 - 2016-04-04 - back out 'truncation of last frame' fix from previous version // 1.08 - 2016-04-02 - warnings; setup memory leaks; truncation of last frame @@ -127,9 +138,20 @@ typedef struct int max_frame_size; } stb_vorbis_info; +typedef struct +{ + char *vendor; + + int comment_list_length; + char **comment_list; +} stb_vorbis_comment; + // get general information about the file extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); +// get ogg comments +extern stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f); + // get the last error detected (clears it, too) extern int stb_vorbis_get_error(stb_vorbis *f); @@ -201,6 +223,12 @@ extern int stb_vorbis_decode_frame_pushdata( // channel. In other words, (*output)[0][0] contains the first sample from // the first channel, and (*output)[1][0] contains the first sample from // the second channel. +// +// *output points into stb_vorbis's internal output buffer storage; these +// buffers are owned by stb_vorbis and application code should not free +// them or modify their contents. They are transient and will be overwritten +// once you ask for more data to get decoded, so be sure to grab any data +// you need before then. extern void stb_vorbis_flush_pushdata(stb_vorbis *f); // inform stb_vorbis that your next datablock will not be contiguous with @@ -253,7 +281,7 @@ extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell). on failure, returns NULL and sets *error. // note that stb_vorbis must "own" this stream; if you seek it in between -// calls to stb_vorbis, it will become confused. Morever, if you attempt to +// calls to stb_vorbis, it will become confused. Moreover, if you attempt to // perform stb_vorbis_seek_*() operations on this file, it will assume it // owns the _entire_ rest of the file after the start point. Use the next // function, stb_vorbis_open_file_section(), to limit it. @@ -374,7 +402,8 @@ enum STBVorbisError VORBIS_invalid_first_page, VORBIS_bad_packet_type, VORBIS_cant_find_last_page, - VORBIS_seek_failed + VORBIS_seek_failed, + VORBIS_ogg_skeleton_not_supported }; @@ -559,7 +588,7 @@ enum STBVorbisError #if defined(_MSC_VER) || defined(__MINGW32__) #include #endif - #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) + #if defined(__linux__) || defined(__linux) || defined(__sun__) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__) #include #endif #else // STB_VORBIS_NO_CRT @@ -582,7 +611,7 @@ enum STBVorbisError #endif #define __forceinline #ifndef alloca - #define alloca __builtin_alloca + #define alloca __builtin_alloca #endif #elif !defined(_MSC_VER) #if __GNUC__ @@ -626,6 +655,12 @@ typedef signed int int32; typedef float codetype; +#ifdef _MSC_VER +#define STBV_NOTUSED(v) (void)(v) +#else +#define STBV_NOTUSED(v) (void)sizeof(v) +#endif + // @NOTE // // Some arrays below are tagged "//varies", which means it's actually @@ -757,6 +792,10 @@ struct stb_vorbis unsigned int temp_memory_required; unsigned int setup_temp_memory_required; + char *vendor; + int comment_list_length; + char **comment_list; + // input config #ifndef STB_VORBIS_NO_STDIO FILE *f; @@ -772,8 +811,11 @@ struct stb_vorbis uint8 push_mode; + // the page to seek to when seeking to start, may be zero uint32 first_audio_page_offset; + // p_first is the page on which the first audio packet ends + // (but not necessarily the page on which it starts) ProbedPage p_first, p_last; // memory management @@ -822,7 +864,7 @@ struct stb_vorbis int current_loc_valid; // per-blocksize precomputed data - + // twiddle factors float *A[2],*B[2],*C[2]; float *window[2]; @@ -885,8 +927,8 @@ static int error(vorb *f, enum STBVorbisError e) #define array_size_required(count,size) (count*(sizeof(void *)+(size))) -#define temp_alloc(f,size) setup_temp_malloc(f,size)//(f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) -#define temp_free(f,p) 0 +#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) +#define temp_free(f,p) (void)0 #define temp_alloc_save(f) ((f)->temp_offset) #define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) @@ -907,7 +949,7 @@ static void *make_block_array(void *mem, int count, int size) static void *setup_malloc(vorb *f, int sz) { - sz = (sz+3) & ~3; + sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs. f->setup_memory_required += sz; if (f->alloc.alloc_buffer) { void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; @@ -926,7 +968,7 @@ static void setup_free(vorb *f, void *p) static void *setup_temp_malloc(vorb *f, int sz) { - sz = (sz+3) & ~3; + sz = (sz+7) & ~7; // round up to nearest 8 for alignment of future allocs. if (f->alloc.alloc_buffer) { if (f->temp_offset - sz < f->setup_offset) return NULL; f->temp_offset -= sz; @@ -938,7 +980,7 @@ static void *setup_temp_malloc(vorb *f, int sz) static void setup_temp_free(vorb *f, void *p, int sz) { if (f->alloc.alloc_buffer) { - f->temp_offset += (sz+3)&~3; + f->temp_offset += (sz+7)&~7; return; } free(p); @@ -974,6 +1016,11 @@ static unsigned int bit_reverse(unsigned int n) return (n >> 16) | (n << 16); } +static float square(float x) +{ + return x*x; +} + // this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 // as required by the specification. fast(?) implementation from stb.h // @OPTIMIZE: called multiple times per-packet with "constants"; move to setup @@ -1006,7 +1053,7 @@ static int ilog(int32 n) // // these functions are only called at setup, and only a few times // per file -/* + static float float32_unpack(uint32 x) { // from the specification @@ -1014,20 +1061,9 @@ static float float32_unpack(uint32 x) uint32 sign = x & 0x80000000; uint32 exp = (x & 0x7fe00000) >> 21; double res = sign ? -(double)mantissa : (double)mantissa; - return (float) ldexp((float)res, exp-788); -} -*/ -float ldexpi(int m, int e) { - return (float)(m * pow(2, e)); + return (float) ldexp((float)res, (int)exp-788); } -static float float32_unpack(uint32 x) { - // from the specification - uint32 s = x & 0x80000000; - int32 m = x & 0x1fffff; - int32 e = (x & 0x7fe00000) >> 21; - return ldexpi(s ? -m : m, e - 788); -} // zlib & jpeg huffman tables assume that the output symbols // can either be arbitrarily arranged, or have monotonically @@ -1056,6 +1092,7 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) // find the first entry for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; if (k == n) { assert(c->sorted_entries == 0); return TRUE; } + assert(len[k] < 32); // no error return required, code reading lens checks this // add to the list add_entry(c, 0, k, m++, len[k], values); // add all available leaves @@ -1069,6 +1106,7 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) uint32 res; int z = len[i], y; if (z == NO_CODE) continue; + assert(z < 32); // no error return required, code reading lens checks this // find lowest available leaf (should always be earliest, // which is what the specification calls for) // note that this property, and the fact we can never have @@ -1078,12 +1116,10 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) while (z > 0 && !available[z]) --z; if (z == 0) { return FALSE; } res = available[z]; - assert(z >= 0 && z < 32); available[z] = 0; add_entry(c, bit_reverse(res), i, m++, len[i], values); - // propogate availability up the tree + // propagate availability up the tree if (z != len[i]) { - assert(len[i] >= 0 && len[i] < 32); for (y=len[i]; y > z; --y) { assert(available[y] == 0); available[y] = res + (1 << (32-y)); @@ -1098,7 +1134,8 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) static void compute_accelerated_huffman(Codebook *c) { int i, len; - memset(c->fast_huffman, 0xFF, sizeof(c->fast_huffman)); // fill by -1 + for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) + c->fast_huffman[i] = -1; len = c->sparse ? c->sorted_entries : c->entries; #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT @@ -1149,7 +1186,7 @@ static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) if (!c->sparse) { int k = 0; for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) + if (include_in_sort(c, lengths[i])) c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); assert(k == c->sorted_entries); } else { @@ -1206,99 +1243,36 @@ static int lookup1_values(int entries, int dim) int r = (int) floor(exp((float) log((float) entries) / dim)); if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; ++r; // floor() to avoid _ftol() when non-CRT - assert(pow((float) r+1, dim) > entries); - assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above + if (pow((float) r+1, dim) <= entries) + return -1; + if ((int) floor(pow((float) r, dim)) > entries) + return -1; return r; } -#ifdef _PSP -// pspmath.h - extern float vfpu_sinf(float x); - extern float vfpu_cosf(float x); - extern void vfpu_sincos(float r, float *s, float *c); - - #define sinf(x) vfpu_sinf(x) - #define cosf(x) vfpu_cosf(x) - - void sincosd(double x, double *s, double *c) { - float fs, fc; - vfpu_sincos((float)x, &fs, &fc); - *s = (double)fs; - *c = (double)fc; - } -#else - void sincosd(double x, double *s, double *c) { - *s = sin(x); - *c = cos(x); - } -#endif - -#define rotate(x, y, s, c) {\ - double t = x*c - y*s;\ - y = x*s + y*c;\ - x = t;\ - } - // called twice per file static void compute_twiddle_factors(int n, float *A, float *B, float *C) { int n4 = n >> 2, n8 = n >> 3; - int k, k2; - - double sA, cA, sB, cB, sC, cC; - double xA, yA, xB, yB, xC, yC; - - sincosd(4*M_PI/n, &sA, &cA); - sincosd(M_PI/n/2, &sB, &cB); - sincosd(2*M_PI/n, &sC, &cC); - - xA = 1.0; - yA = 0.0; - A[0] = 1.0f; - A[1] = 0.0f; - xB = cB; - yB = sB; - B[0] = (float)(xB * 0.5); - B[1] = (float)(yB * 0.5); - rotate(cB, sB, sB, cB); - - for (k=1, k2=2; k < n4; ++k,k2+=2) { - rotate(xA, yA, sA, cA); - A[k2 ] = (float) xA; - A[k2+1] = (float)-yA; - rotate(xB, yB, sB, cB); - B[k2 ] = (float)(xB * 0.5); - B[k2+1] = (float)(yB * 0.5); - } - - xC = cC; - yC = sC; - C[0] = (float) xC; - C[1] = (float)-yC; - - rotate(cC, sC, sC, cC); - - for (k=1, k2=2; k < n8; ++k,k2+=2) { - rotate(xC, yC, sC, cC); - C[k2 ] = (float) xC; - C[k2+1] = (float)-yC; + int k,k2; + + for (k=k2=0; k < n4; ++k,k2+=2) { + A[k2 ] = (float) cos(4*k*M_PI/n); + A[k2+1] = (float) -sin(4*k*M_PI/n); + B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; + B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; + } + for (k=k2=0; k < n8; ++k,k2+=2) { + C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); + C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); } } static void compute_window(int n, float *window) { int n2 = n >> 1, i; - double s, c, x, y; - - sincosd(0.5f / n2 * 0.5f * M_PI, &s, &c); - x = c; - y = s; - rotate(c, s, s, c); - - for (i=0; i < n2; ++i) { - window[i] = sinf((float)(0.5 * M_PI * (y * y))); - rotate(x, y, s, c); - } + for (i=0; i < n2; ++i) + window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); } static void compute_bitreverse(int n, uint16 *rev) @@ -1395,7 +1369,7 @@ static int getn(vorb *z, uint8 *data, int n) return 1; } - #ifndef STB_VORBIS_NO_STDIO + #ifndef STB_VORBIS_NO_STDIO if (fread(data, n, 1, z->f) == 1) return 1; else { @@ -1470,12 +1444,15 @@ static int capture_pattern(vorb *f) static int start_page_no_capturepattern(vorb *f) { uint32 loc0,loc1,n; + if (f->first_decode && !IS_PUSH_MODE(f)) { + f->p_first.page_start = stb_vorbis_get_file_offset(f) - 4; + } // stream structure version if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); // header flag f->page_flag = get8(f); // absolute granule position - loc0 = get32(f); + loc0 = get32(f); loc1 = get32(f); // @TODO: validate loc0,loc1 as valid positions? // stream serial number -- vorbis doesn't interleave, so discard @@ -1506,15 +1483,12 @@ static int start_page_no_capturepattern(vorb *f) } if (f->first_decode) { int i,len; - ProbedPage p; len = 0; for (i=0; i < f->segment_count; ++i) len += f->segments[i]; len += 27 + f->segment_count; - p.page_start = f->first_audio_page_offset; - p.page_end = p.page_start + len; - p.last_decoded_sample = loc0; - f->p_first = p; + f->p_first.page_end = f->p_first.page_start + len; + f->p_first.last_decoded_sample = loc0; } f->next_seg = 0; return TRUE; @@ -1605,6 +1579,16 @@ static int get8_packet(vorb *f) return x; } +static int get32_packet(vorb *f) +{ + uint32 x; + x = get8_packet(f); + x += get8_packet(f) << 8; + x += get8_packet(f) << 16; + x += (uint32) get8_packet(f) << 24; + return x; +} + static void flush_packet(vorb *f) { while (get8_packet_raw(f) != EOP); @@ -1635,7 +1619,8 @@ static uint32 get_bits(vorb *f, int n) f->valid_bits += 8; } } - if (f->valid_bits < 0) return 0; + + assert(f->valid_bits >= n); z = f->acc & ((1 << n)-1); f->acc >>= n; f->valid_bits -= n; @@ -1960,69 +1945,69 @@ static int predict_point(int x, int x0, int x1, int y0, int y1) // the following table is block-copied from the specification static float inverse_db_table[256] = { - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, + 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, + 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, + 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, + 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, + 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, + 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, + 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, + 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, + 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, + 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, + 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, + 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, + 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, + 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, + 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, + 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, + 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, + 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, + 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, + 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, + 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, + 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, + 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, + 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, + 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, + 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, + 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, + 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, + 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, + 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, + 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, + 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, + 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, + 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, + 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, + 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, + 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, + 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, + 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, + 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, + 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, + 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, + 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, + 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, + 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, + 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, + 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, + 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, + 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, + 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, + 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, + 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, + 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, + 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, + 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, + 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, + 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, + 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, + 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, + 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, + 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, + 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, + 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, 0.82788260f, 0.88168307f, 0.9389798f, 1.0f }; @@ -2082,7 +2067,7 @@ static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y ady -= abs(base) * adx; if (x1 > n) x1 = n; if (x < x1) { - LINE_OP(output[x], inverse_db_table[y]); + LINE_OP(output[x], inverse_db_table[y&255]); for (++x; x < x1; ++x) { err += ady; if (err >= adx) { @@ -2090,7 +2075,7 @@ static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y y += sy; } else y += base; - LINE_OP(output[x], inverse_db_table[y]); + LINE_OP(output[x], inverse_db_table[y&255]); } } } @@ -2196,47 +2181,7 @@ static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int ++class_set; #endif } - } else if (ch == 1) { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = 0, p_inter = z; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - } else { - z += r->part_size; - c_inter = 0; - p_inter = z; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else { + } else if (ch > 2) { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = z % ch, p_inter = z/ch; @@ -2423,11 +2368,11 @@ void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) #if LIBVORBIS_MDCT // directly call the vorbis MDCT using an interface documented // by Jeff Roberts... useful for performance comparison -typedef struct +typedef struct { int n; int log2n; - + float *trig; int *bitrev; @@ -2446,7 +2391,7 @@ void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) if (M1.n == n) M = &M1; else if (M2.n == n) M = &M2; else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } - else { + else { if (M2.n) __asm int 3; mdct_init(&M2, n); M = &M2; @@ -2647,34 +2592,33 @@ static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, while (z > base) { float k00,k11; - - k00 = z[-0] - z[-8]; - k11 = z[-1] - z[-9]; - z[-0] = z[-0] + z[-8]; - z[-1] = z[-1] + z[-9]; - z[-8] = k00; - z[-9] = k11 ; - - k00 = z[ -2] - z[-10]; - k11 = z[ -3] - z[-11]; - z[ -2] = z[ -2] + z[-10]; - z[ -3] = z[ -3] + z[-11]; - z[-10] = (k00+k11) * A2; - z[-11] = (k11-k00) * A2; - - k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation + float l00,l11; + + k00 = z[-0] - z[ -8]; + k11 = z[-1] - z[ -9]; + l00 = z[-2] - z[-10]; + l11 = z[-3] - z[-11]; + z[ -0] = z[-0] + z[ -8]; + z[ -1] = z[-1] + z[ -9]; + z[ -2] = z[-2] + z[-10]; + z[ -3] = z[-3] + z[-11]; + z[ -8] = k00; + z[ -9] = k11; + z[-10] = (l00+l11) * A2; + z[-11] = (l11-l00) * A2; + + k00 = z[ -4] - z[-12]; k11 = z[ -5] - z[-13]; + l00 = z[ -6] - z[-14]; + l11 = z[ -7] - z[-15]; z[ -4] = z[ -4] + z[-12]; z[ -5] = z[ -5] + z[-13]; - z[-12] = k11; - z[-13] = k00; - - k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation - k11 = z[ -7] - z[-15]; z[ -6] = z[ -6] + z[-14]; z[ -7] = z[ -7] + z[-15]; - z[-14] = (k00+k11) * A2; - z[-15] = (k00-k11) * A2; + z[-12] = k11; + z[-13] = -k00; + z[-14] = (l11-l00) * A2; + z[-15] = (l00+l11) * -A2; iter_54(z); iter_54(z-8); @@ -2709,7 +2653,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) // once I combined the passes. // so there's a missing 'times 2' here (for adding X to itself). - // this propogates through linearly to the end, where the numbers + // this propagates through linearly to the end, where the numbers // are 1/2 too small, and need to be compensated for. { @@ -2859,7 +2803,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d1[0] = u[k4+1]; d0[1] = u[k4+2]; d0[0] = u[k4+3]; - + d0 -= 4; d1 -= 4; bitrev += 2; @@ -2940,7 +2884,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) float p0,p1,p2,p3; p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; + p2 = -e[6]*B[6] - e[7]*B[7]; d0[0] = p3; d1[3] = - p3; @@ -2948,7 +2892,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[3] = p2; p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; + p0 = -e[4]*B[4] - e[5]*B[5]; d0[1] = p1; d1[2] = - p1; @@ -2956,7 +2900,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[2] = p0; p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; + p2 = -e[2]*B[2] - e[3]*B[3]; d0[2] = p3; d1[1] = - p3; @@ -2964,7 +2908,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[1] = p2; p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; + p0 = -e[0]*B[0] - e[1]*B[1]; d0[3] = p1; d1[0] = - p1; @@ -3117,7 +3061,6 @@ static float *get_window(vorb *f, int len) len <<= 1; if (len == f->blocksize_0) return f->window[0]; if (len == f->blocksize_1) return f->window[1]; - assert(0); return NULL; } @@ -3140,6 +3083,7 @@ static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *f for (q=1; q < g->values; ++q) { j = g->sorted_order[q]; #ifndef STB_VORBIS_NO_DEFER_FLOOR + STBV_NOTUSED(step2_flag); if (finalY[j] >= 0) #else if (step2_flag[j]) @@ -3242,6 +3186,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, // WINDOWING + STBV_NOTUSED(left_end); n = f->blocksize[m->blockflag]; map = &f->mapping[m->mapping]; @@ -3439,7 +3384,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, // this isn't to spec, but spec would require us to read ahead // and decode the size of all current frames--could be done, // but presumably it's not a commonly used feature - f->current_loc = -n2; // start of first frame is positioned for discard + f->current_loc = 0u - n2; // start of first frame is positioned for discard (NB this is an intentional unsigned overflow/wrap-around) // we might have to discard samples "from" the next frame too, // if we're lapping a large block then a small at the start? f->discard_samples_deferred = n - right_end; @@ -3523,6 +3468,7 @@ static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) if (f->previous_length) { int i,j, n = f->previous_length; float *w = get_window(f, n); + if (w == NULL) return 0; for (i=0; i < f->channels; ++i) { for (j=0; j < n; ++j) f->channel_buffers[i][left+j] = @@ -3570,7 +3516,7 @@ static int vorbis_pump_first_frame(stb_vorbis *f) } #ifndef STB_VORBIS_NO_PUSHDATA_API -static int is_whole_packet_present(stb_vorbis *f, int end_page) +static int is_whole_packet_present(stb_vorbis *f) { // make sure that we have the packet available before continuing... // this requires a full ogg parse, but we know we can fetch from f->stream @@ -3590,15 +3536,13 @@ static int is_whole_packet_present(stb_vorbis *f, int end_page) break; } // either this continues, or it ends it... - if (end_page) - if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); if (s == f->segment_count) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); first = FALSE; } for (; s == -1;) { - uint8 *q; + uint8 *q; int n; // check that we have the page header ready @@ -3624,8 +3568,6 @@ static int is_whole_packet_present(stb_vorbis *f, int end_page) if (q[s] < 255) break; } - if (end_page) - if (s < n-1) return error(f, VORBIS_invalid_stream); if (s == n) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); @@ -3642,6 +3584,7 @@ static int start_decoder(vorb *f) int longest_floorlist=0; // first page, first packet + f->first_decode = TRUE; if (!start_page(f)) return FALSE; // validate page flag @@ -3650,7 +3593,22 @@ static int start_decoder(vorb *f) if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); // check for expected packet length if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); - if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); + if (f->segments[0] != 30) { + // check for the Ogg skeleton fishead identifying header to refine our error + if (f->segments[0] == 64 && + getn(f, header, 6) && + header[0] == 'f' && + header[1] == 'i' && + header[2] == 's' && + header[3] == 'h' && + header[4] == 'e' && + header[5] == 'a' && + get8(f) == 'd' && + get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported); + else + return error(f, VORBIS_invalid_first_page); + } + // read packet // check packet header if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); @@ -3684,6 +3642,48 @@ static int start_decoder(vorb *f) if (!start_page(f)) return FALSE; if (!start_packet(f)) return FALSE; + + if (!next_segment(f)) return FALSE; + + if (get8_packet(f) != VORBIS_packet_comment) return error(f, VORBIS_invalid_setup); + for (i=0; i < 6; ++i) header[i] = get8_packet(f); + if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); + //file vendor + len = get32_packet(f); + f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1)); + if (f->vendor == NULL) return error(f, VORBIS_outofmem); + for(i=0; i < len; ++i) { + f->vendor[i] = get8_packet(f); + } + f->vendor[len] = (char)'\0'; + //user comments + f->comment_list_length = get32_packet(f); + f->comment_list = NULL; + if (f->comment_list_length > 0) + { + f->comment_list = (char**) setup_malloc(f, sizeof(char*) * (f->comment_list_length)); + if (f->comment_list == NULL) return error(f, VORBIS_outofmem); + } + + for(i=0; i < f->comment_list_length; ++i) { + len = get32_packet(f); + f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1)); + if (f->comment_list[i] == NULL) return error(f, VORBIS_outofmem); + + for(j=0; j < len; ++j) { + f->comment_list[i][j] = get8_packet(f); + } + f->comment_list[i][len] = (char)'\0'; + } + + // framing_flag + x = get8_packet(f); + if (!(x & 1)) return error(f, VORBIS_invalid_setup); + + + skip(f, f->bytes_in_seg); + f->bytes_in_seg = 0; + do { len = next_segment(f); skip(f, len); @@ -3695,7 +3695,7 @@ static int start_decoder(vorb *f) #ifndef STB_VORBIS_NO_PUSHDATA_API if (IS_PUSH_MODE(f)) { - if (!is_whole_packet_present(f, TRUE)) { + if (!is_whole_packet_present(f)) { // convert error in ogg header to write type if (f->error == VORBIS_invalid_stream) f->error = VORBIS_invalid_setup; @@ -3749,6 +3749,7 @@ static int start_decoder(vorb *f) while (current_entry < c->entries) { int limit = c->entries - current_entry; int n = get_bits(f, ilog(limit)); + if (current_length >= 32) return error(f, VORBIS_invalid_setup); if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } memset(lengths + current_entry, current_length, n); current_entry += n; @@ -3852,7 +3853,9 @@ static int start_decoder(vorb *f) c->value_bits = get_bits(f, 4)+1; c->sequence_p = get_bits(f,1); if (c->lookup_type == 1) { - c->lookup_values = lookup1_values(c->entries, c->dimensions); + int values = lookup1_values(c->entries, c->dimensions); + if (values < 0) return error(f, VORBIS_invalid_setup); + c->lookup_values = (uint32) values; } else { c->lookup_values = c->entries * c->dimensions; } @@ -3882,8 +3885,7 @@ static int start_decoder(vorb *f) unsigned int div=1; for (k=0; k < c->dimensions; ++k) { int off = (z / div) % c->lookup_values; - float val = mults[off]; - val = mults[off]*c->delta_value + c->minimum_value + last; + float val = mults[off]*c->delta_value + c->minimum_value + last; c->multiplicands[j*c->dimensions + k] = val; if (c->sequence_p) last = val; @@ -3951,7 +3953,7 @@ static int start_decoder(vorb *f) } else { stbv__floor_ordering p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; + int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); @@ -3966,7 +3968,7 @@ static int start_decoder(vorb *f) if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } for (k=0; k < 1 << g->class_subclasses[j]; ++k) { - g->subclass_books[j][k] = get_bits(f,8)-1; + g->subclass_books[j][k] = (int16)get_bits(f,8)-1; if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } } @@ -3988,11 +3990,14 @@ static int start_decoder(vorb *f) p[j].id = j; } qsort(p, g->values, sizeof(p[0]), point_compare); + for (j=0; j < g->values-1; ++j) + if (p[j].x == p[j+1].x) + return error(f, VORBIS_invalid_setup); for (j=0; j < g->values; ++j) g->sorted_order[j] = (uint8) p[j].id; // precompute the neighbors for (j=2; j < g->values; ++j) { - int low,hi; + int low = 0,hi = 0; neighbors(g->Xlist, j, &low,&hi); g->neighbors[j][0] = low; g->neighbors[j][1] = hi; @@ -4061,7 +4066,7 @@ static int start_decoder(vorb *f) if (f->mapping == NULL) return error(f, VORBIS_outofmem); memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; + Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); @@ -4074,6 +4079,7 @@ static int start_decoder(vorb *f) max_submaps = m->submaps; if (get_bits(f,1)) { m->coupling_steps = get_bits(f,8)+1; + if (m->coupling_steps > f->channels) return error(f, VORBIS_invalid_setup); for (k=0; k < m->coupling_steps; ++k) { m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); m->chan[k].angle = get_bits(f, ilog(f->channels-1)); @@ -4176,7 +4182,6 @@ static int start_decoder(vorb *f) f->temp_memory_required = imdct_mem; } - f->first_decode = TRUE; if (f->alloc.alloc_buffer) { assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); @@ -4185,7 +4190,17 @@ static int start_decoder(vorb *f) return error(f, VORBIS_outofmem); } - f->first_audio_page_offset = stb_vorbis_get_file_offset(f); + // @TODO: stb_vorbis_seek_start expects first_audio_page_offset to point to a page + // without PAGEFLAG_continued_packet, so this either points to the first page, or + // the page after the end of the headers. It might be cleaner to point to a page + // in the middle of the headers, when that's the page where the first audio packet + // starts, but we'd have to also correctly skip the end of any continued packet in + // stb_vorbis_seek_start. + if (f->next_seg == -1) { + f->first_audio_page_offset = stb_vorbis_get_file_offset(f); + } else { + f->first_audio_page_offset = 0; + } return TRUE; } @@ -4193,6 +4208,13 @@ static int start_decoder(vorb *f) static void vorbis_deinit(stb_vorbis *p) { int i,j; + + setup_free(p, p->vendor); + for (i=0; i < p->comment_list_length; ++i) { + setup_free(p, p->comment_list[i]); + } + setup_free(p, p->comment_list); + if (p->residue_config) { for (i=0; i < p->residue_count; ++i) { Residue *r = p->residue_config+i; @@ -4258,7 +4280,7 @@ static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start if (z) { p->alloc = *z; - p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; + p->alloc.alloc_buffer_length_in_bytes &= ~7; p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; } p->eof = 0; @@ -4292,6 +4314,15 @@ stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) return d; } +stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f) +{ + stb_vorbis_comment d; + d.vendor = f->vendor; + d.comment_list_length = f->comment_list_length; + d.comment_list = f->comment_list; + return d; +} + int stb_vorbis_get_error(stb_vorbis *f) { int e = f->error; @@ -4433,7 +4464,7 @@ int stb_vorbis_decode_frame_pushdata( f->error = VORBIS__no_error; // check that we have the entire packet in memory - if (!is_whole_packet_present(f, FALSE)) { + if (!is_whole_packet_present(f)) { *samples = 0; return 0; } @@ -4495,6 +4526,7 @@ stb_vorbis *stb_vorbis_open_pushdata( *error = VORBIS_need_more_data; else *error = p.error; + vorbis_deinit(&p); return NULL; } f = vorbis_alloc(&p); @@ -4552,7 +4584,7 @@ static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) header[i] = get8(f); if (f->eof) return 0; if (header[4] != 0) goto invalid; - goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); + goal = header[22] + (header[23] << 8) + (header[24]<<16) + ((uint32)header[25]<<24); for (i=22; i < 26; ++i) header[i] = 0; crc = 0; @@ -4638,7 +4670,7 @@ static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) return 1; } -// rarely used function to seek back to the preceeding page while finding the +// rarely used function to seek back to the preceding page while finding the // start of a packet static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) { @@ -4669,8 +4701,8 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) { ProbedPage left, right, mid; int i, start_seg_with_known_loc, end_pos, page_start; - uint32 delta, stream_length, padding; - double offset, bytes_per_sample; + uint32 delta, stream_length, padding, last_sample_limit; + double offset = 0.0, bytes_per_sample = 0.0; int probe = 0; // find the last page and validate the target sample @@ -4683,9 +4715,9 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) // indicates should be the granule position (give or take one)). padding = ((f->blocksize_1 - f->blocksize_0) >> 2); if (sample_number < padding) - sample_number = 0; + last_sample_limit = 0; else - sample_number -= padding; + last_sample_limit = sample_number - padding; left = f->p_first; while (left.last_decoded_sample == ~0U) { @@ -4698,9 +4730,12 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) assert(right.last_decoded_sample != ~0U); // starting from the start is handled differently - if (sample_number <= left.last_decoded_sample) { - if (stb_vorbis_seek_start(f)) + if (last_sample_limit <= left.last_decoded_sample) { + if (stb_vorbis_seek_start(f)) { + if (f->current_loc > sample_number) + return error(f, VORBIS_seek_failed); return 1; + } return 0; } @@ -4717,10 +4752,10 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) // first probe (interpolate) double data_bytes = right.page_end - left.page_start; bytes_per_sample = data_bytes / right.last_decoded_sample; - offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample); + offset = left.page_start + bytes_per_sample * (last_sample_limit - left.last_decoded_sample); } else { // second probe (try to bound the other side) - double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample; + double error = ((double) last_sample_limit - mid.last_decoded_sample) * bytes_per_sample; if (error >= 0 && error < 8000) error = 8000; if (error < 0 && error > -8000) error = -8000; offset += error * 2; @@ -4751,14 +4786,16 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) } // if we've just found the last page again then we're in a tricky file, - // and we're close enough. - if (mid.page_start == right.page_start) - break; - - if (sample_number < mid.last_decoded_sample) - right = mid; - else - left = mid; + // and we're close enough (if it wasn't an interpolation probe). + if (mid.page_start == right.page_start) { + if (probe >= 2 || delta <= 65536) + break; + } else { + if (last_sample_limit < mid.last_decoded_sample) + right = mid; + else + left = mid; + } ++probe; } @@ -4874,8 +4911,8 @@ int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) flush_packet(f); } } - // the next frame will start with the sample - assert(f->current_loc == sample_number); + // the next frame should start with the sample + if (f->current_loc != sample_number) return error(f, VORBIS_seek_failed); return 1; } @@ -4951,7 +4988,7 @@ unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) // set. whoops! break; } - previous_safe = last_page_loc+1; + //previous_safe = last_page_loc+1; // NOTE: not used after this point, but note for debugging last_page_loc = stb_vorbis_get_file_offset(f); } @@ -5045,8 +5082,14 @@ stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, con stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) { - FILE *f = fopen(filename, "rb"); - if (f) + FILE *f; +#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__) + if (0 != fopen_s(&f, filename, "rb")) + f = NULL; +#else + f = fopen(filename, "rb"); +#endif + if (f) return stb_vorbis_open_file(f, TRUE, error, alloc); if (error) *error = VORBIS_file_open_failure; return NULL; @@ -5056,7 +5099,10 @@ stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const st stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; - if (data == NULL) return NULL; + if (!data) { + if (error) *error = VORBIS_unexpected_eof; + return NULL; + } vorbis_init(&p, alloc); p.stream = (uint8 *) data; p.stream_end = (uint8 *) data + len; @@ -5109,7 +5155,7 @@ static int8 channel_position[7][6] = #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) - #define check_endianness() + #define check_endianness() #else #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) #define check_endianness() @@ -5131,11 +5177,11 @@ static void copy_samples(short *dest, float *src, int len) static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) { - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE; + #define STB_BUFFER_SIZE 32 + float buffer[STB_BUFFER_SIZE]; + int i,j,o,n = STB_BUFFER_SIZE; check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE) { + for (o = 0; o < len; o += STB_BUFFER_SIZE) { memset(buffer, 0, sizeof(buffer)); if (o + n > len) n = len - o; for (j=0; j < num_c; ++j) { @@ -5152,16 +5198,17 @@ static void compute_samples(int mask, short *output, int num_c, float **data, in output[o+i] = v; } } + #undef STB_BUFFER_SIZE } static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) { - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE >> 1; + #define STB_BUFFER_SIZE 32 + float buffer[STB_BUFFER_SIZE]; + int i,j,o,n = STB_BUFFER_SIZE >> 1; // o is the offset in the source data check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE >> 1) { + for (o = 0; o < len; o += STB_BUFFER_SIZE >> 1) { // o2 is the offset in the output data int o2 = o << 1; memset(buffer, 0, sizeof(buffer)); @@ -5191,6 +5238,7 @@ static void compute_stereo_samples(short *output, int num_c, float **data, int d output[o2+i] = v; } } + #undef STB_BUFFER_SIZE } static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) @@ -5211,7 +5259,7 @@ static void convert_samples_short(int buf_c, short **buffer, int b_offset, int d int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) { - float **output; + float **output = NULL; int len = stb_vorbis_get_frame_float(f, NULL, &output); if (len > num_samples) len = num_samples; if (len) @@ -5263,8 +5311,6 @@ int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short float **outputs; int len = num_shorts / channels; int n=0; - int z = f->channels; - if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; @@ -5283,8 +5329,6 @@ int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, in { float **outputs; int n=0; - int z = f->channels; - if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; @@ -5434,14 +5478,20 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in #endif // STB_VORBIS_NO_PULLDATA_API /* Version history + 1.17 - 2019-07-08 - fix CVE-2019-13217, -13218, -13219, -13220, -13221, -13222, -13223 + found with Mayhem by ForAllSecure + 1.16 - 2019-03-04 - fix warnings + 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found + 1.14 - 2018-02-11 - delete bogus dealloca usage + 1.13 - 2018-01-29 - fix truncation of last frame (hopefully) 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files - 1.11 - 2017-07-23 - fix MinGW compilation + 1.11 - 2017-07-23 - fix MinGW compilation 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory 1.09 - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version 1.08 - 2016-04-02 - fixed multiple warnings; fix setup memory leaks; avoid discarding last frame of audio data 1.07 - 2015-01-16 - fixed some warnings, fix mingw, const-correct API - some more crash fixes when out of memory or with corrupt files + some more crash fixes when out of memory or with corrupt files 1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson) some crash fixes when out of memory or with corrupt files 1.05 - 2015-04-19 - don't define __forceinline if it's redundant @@ -5497,38 +5547,38 @@ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ diff --git a/src/libs/tinf/tinflate.c b/src/libs/tinf/tinflate.c index b2bec565..8de5f73c 100644 --- a/src/libs/tinf/tinflate.c +++ b/src/libs/tinf/tinflate.c @@ -303,7 +303,7 @@ static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) /* check for end of block */ if (sym == 256) { - *d->destLen += d->dest - start; + *d->destLen += (unsigned int)(d->dest - start); return TINF_OK; } diff --git a/src/mesh.h b/src/mesh.h index aab130b2..20d7edf7 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -4,8 +4,21 @@ #include "core.h" #include "format.h" -TR::TextureInfo barTile[5 /* UI::BAR_MAX */]; -TR::TextureInfo &whiteTile = barTile[4]; // BAR_WHITE +enum CommonTexType { + CTEX_FLASH, + CTEX_HEALTH, + CTEX_OXYGEN, + CTEX_OPTION, + CTEX_WHITE_ROOM, + CTEX_WHITE_OBJECT, + CTEX_WHITE_SPRITE, + CTEX_MAX, +}; + +TR::TextureInfo CommonTex[CTEX_MAX]; +TR::TextureInfo &whiteRoom = CommonTex[CTEX_WHITE_ROOM]; +TR::TextureInfo &whiteObject = CommonTex[CTEX_WHITE_OBJECT]; +TR::TextureInfo &whiteSprite = CommonTex[CTEX_WHITE_SPRITE]; #define PLANE_DETAIL 48 #define CIRCLE_SEGS 16 @@ -57,17 +70,16 @@ struct Mesh : GAPI::Mesh { TR::Room::Data::Vertex &v = d.vertices[f.vertices[k]];\ Vertex &rv = _vertices[vCount++];\ rv.coord = short4( v.pos.x, v.pos.y, v.pos.z, 0 );\ - rv.normal = short4( f.normal.x, f.normal.y, f.normal.z, 0 );\ + rv.normal = short4( f.normal.x, f.normal.y, f.normal.z, f.triangle ? 1 : 0 );\ rv.color = ubyte4( 255, 255, 255, 255 );\ rv.light = ubyte4( v.color.r, v.color.g, v.color.b, 255 );\ } float intensityf(uint16 lighting) { - if (lighting > 0x1FFF) return 1.0f; - float lum = 1.0f - (lighting >> 5) / 255.0f; - //return powf(lum, 2.2f); // gamma to linear space - return lum;// * lum; // gamma to "linear" space +// ASSERT(lighting >= 0 && lighting <= 0x1FFF); + lighting = min(lighting, uint16(0x1FFF)); + return (0x1FFF - lighting) / float(0x1FFF); } uint8 intensity(int lighting) { @@ -154,6 +166,8 @@ struct MeshBuilder { struct ModelRange { int parts[3][32]; Geometry geometry[3]; + int vStart; + int vCount; } *models; // procedured @@ -174,7 +188,7 @@ struct MeshBuilder { }; MeshBuilder(TR::Level *level, Texture *atlas) : atlas(atlas), level(level) { - dynMesh = new Mesh(NULL, DYN_MESH_FACES * 3, NULL, DYN_MESH_FACES * 3, 1, true); + dynMesh = new Mesh(NULL, COUNT(dynIndices), NULL, COUNT(dynVertices), 1, true); dynRange.vStart = 0; dynRange.iStart = 0; dynMesh->initRange(dynRange); @@ -248,8 +262,10 @@ struct MeshBuilder { } // get models info + int vStartModel = vCount; models = new ModelRange[level->modelsCount]; for (int i = 0; i < level->modelsCount; i++) { + models[i].vStart = vCount; TR::Model &model = level->models[i]; for (int j = 0; j < model.mCount; j++) { int index = level->meshOffsets[model.mStart + j]; @@ -259,6 +275,8 @@ struct MeshBuilder { iCount += (mesh.rCount * 6 + mesh.tCount * 3) * DOUBLE_SIDED; vCount += (mesh.rCount * 4 + mesh.tCount * 3); } + models[i].vCount = vCount - models[i].vStart; + models[i].vStart -= vStartModel; } // shadow blob mesh (8 triangles, 8 vertices) @@ -273,6 +291,28 @@ struct MeshBuilder { iCount += CIRCLE_SEGS * 3; vCount += CIRCLE_SEGS + 1; + // box + const Index boxIndices[] = { + 2, 1, 0, 3, 2, 0, + 4, 5, 6, 4, 6, 7, + 8, 9, 10, 8, 10, 11, + 14, 13, 12, 15, 14, 12, + 16, 17, 18, 16, 18, 19, + 22, 21, 20, 23, 22, 20, + }; + + const short4 boxCoords[] = { + short4(-1, -1, 1, 0), short4( 1, -1, 1, 0), short4( 1, 1, 1, 0), short4(-1, 1, 1, 0), + short4( 1, 1, 1, 0), short4( 1, 1, -1, 0), short4( 1, -1, -1, 0), short4( 1, -1, 1, 0), + short4(-1, -1, -1, 0), short4( 1, -1, -1, 0), short4( 1, 1, -1, 0), short4(-1, 1, -1, 0), + short4(-1, -1, -1, 0), short4(-1, -1, 1, 0), short4(-1, 1, 1, 0), short4(-1, 1, -1, 0), + short4( 1, 1, 1, 0), short4(-1, 1, 1, 0), short4(-1, 1, -1, 0), short4( 1, 1, -1, 0), + short4(-1, -1, -1, 0), short4( 1, -1, -1, 0), short4( 1, -1, 1, 0), short4(-1, -1, 1, 0), + }; + + iCount += COUNT(boxIndices); + vCount += COUNT(boxCoords); + // detailed plane #ifdef GENERATE_WATER_PLANE iCount += SQR(PLANE_DETAIL * 2) * 6; @@ -308,8 +348,8 @@ struct MeshBuilder { Geometry &geom = range.geometry[transp]; - // rooms geometry - buildRoom(geom, range.dynamic[transp], blendMask, room, level, indices, vertices, iCount, vCount, vStartRoom); + // room geometry + buildRoom(geom, range.dynamic + transp, blendMask, room, level, indices, vertices, iCount, vCount, vStartRoom); // static meshes for (int j = 0; j < room.meshesCount; j++) { @@ -322,7 +362,7 @@ struct MeshBuilder { int y = m.y; int z = m.z - room.info.z; int d = m.rotation.value / 0x4000; - buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartRoom, 0, x, y, z, d, m.color); + buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartRoom, 0, x, y, z, d, m.color, true, false); } geom.finish(iCount); @@ -337,7 +377,7 @@ struct MeshBuilder { TR::Room::Data::Vertex &v = d.vertices[f.vertexIndex]; TR::TextureInfo &sprite = level->spriteTextures[f.texture]; - addSprite(indices, vertices, iCount, vCount, vStartRoom, v.pos.x, v.pos.y, v.pos.z, sprite, v.color, v.color); + addSprite(indices, vertices, iCount, vCount, vStartRoom, v.pos.x, v.pos.y, v.pos.z, false, false, sprite, v.color, v.color); } range.sprites.iCount = iCount - range.sprites.iStart; #else @@ -347,11 +387,12 @@ struct MeshBuilder { ASSERT(vCount - vStartRoom <= 0xFFFF); // build models geometry - int vStartModel = vCount; + vStartModel = vCount; aCount++; for (int i = 0; i < level->modelsCount; i++) { TR::Model &model = level->models[i]; + int vCountStart = vCount; for (int transp = 0; transp < 3; transp++) { Geometry &geom = models[i].geometry[transp]; @@ -363,13 +404,16 @@ struct MeshBuilder { models[i].parts[transp][j] = geom.count; #endif + bool forceOpaque = false; + TR::Entity::fixOpaque(model.type, forceOpaque); + int index = level->meshOffsets[model.mStart + j]; if (index || model.mStart + j <= 0) { TR::Mesh &mesh = level->meshes[index]; #ifndef MERGE_MODELS geom.getNextRange(vStartModel, iCount, 0xFFFF, 0xFFFF); #endif - buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartModel, j, 0, 0, 0, 0, COLOR_WHITE); + buildMesh(geom, blendMask, mesh, level, indices, vertices, iCount, vCount, vStartModel, j, 0, 0, 0, 0, COLOR_WHITE, false, forceOpaque); } #ifndef MERGE_MODELS @@ -394,9 +438,20 @@ struct MeshBuilder { // remove bottom triangles from skybox //if (m.geometry[0].ranges[0].iCount && ((level.version & TR::VER_TR3))) // m.geometry[0].ranges[0].iCount -= 16 * 3; + // rotate TR2 skybox + if (level->version & TR::VER_TR2) { + for (int j = vCountStart; j < vCount; j++) { + short4 &c = vertices[j].coord; + c = short4(c.x, -c.z, c.y, c.w); + } + } } } - ASSERT(vCount - vStartModel <= 0xFFFF); + + weldSkinJoints(vertices + vStartModel, level->extra.laraSkin, level->extra.laraJoints); + weldSkinJoints(vertices + vStartModel, level->extra.braid, level->extra.braid); + + //ASSERT(vCount - vStartModel <= 0xFFFF); // build common primitives int vStartCommon = vCount; @@ -407,8 +462,8 @@ struct MeshBuilder { shadowBlob.iCount = 8 * 3 * 3; for (int i = 0; i < 9; i++) { Vertex &v0 = vertices[vCount + i * 2 + 0]; - v0.normal = short4( 0, -1, 0, 32767 ); - v0.texCoord = short4( whiteTile.texCoordAtlas[0].x, whiteTile.texCoordAtlas[0].y, 32767, 32767 ); + v0.normal = short4( 0, -1, 0, 1 ); + v0.texCoord = short4( whiteObject.texCoordAtlas[0].x, whiteObject.texCoordAtlas[0].y, 32767, 32767 ); v0.color = v0.light = ubyte4( 0, 0, 0, 0 ); if (i == 8) { @@ -452,11 +507,11 @@ struct MeshBuilder { quad.iStart = iCount; quad.iCount = 2 * 3; - addQuad(indices, iCount, vCount, vStartCommon, vertices, &whiteTile, false, false); + addQuad(indices, iCount, vCount, vStartCommon, vertices, &whiteSprite, false, false); vertices[vCount + 0].coord = short4( -32767, 32767, 0, 1 ); - vertices[vCount + 1].coord = short4( 32767, 32767, 1, 1 ); - vertices[vCount + 2].coord = short4( 32767, -32767, 1, 0 ); - vertices[vCount + 3].coord = short4( -32767, -32767, 0, 0 ); + vertices[vCount + 1].coord = short4( 32767, 32767, 0, 1 ); + vertices[vCount + 2].coord = short4( 32767, -32767, 0, 1 ); + vertices[vCount + 3].coord = short4( -32767, -32767, 0, 1 ); vertices[vCount + 0].texCoord = short4( 0, 32767, 0, 0 ); vertices[vCount + 1].texCoord = short4( 32767, 32767, 0, 0 ); @@ -482,9 +537,9 @@ struct MeshBuilder { for (int i = 0; i < CIRCLE_SEGS; i++) { Vertex &v = vertices[vCount + i]; pos.rotate(cs); - v.coord = short4( short(pos.x), short(pos.y), 0, 0 ); - v.normal = short4( 0, 0, 0, 32767 ); - v.texCoord = short4( whiteTile.texCoordAtlas[0].x, whiteTile.texCoordAtlas[0].y, 32767, 32767 ); + v.coord = short4( short(pos.x), short(pos.y), 0, 1 ); + v.normal = short4( 0, 0, 0, 1 ); + v.texCoord = short4( whiteSprite.texCoordAtlas[0].x, whiteSprite.texCoordAtlas[0].y, 32767, 32767 ); v.color = ubyte4( 255, 255, 255, 255 ); v.light = ubyte4( 255, 255, 255, 255 ); @@ -493,9 +548,28 @@ struct MeshBuilder { indices[iCount++] = baseIdx + CIRCLE_SEGS; } vertices[vCount + CIRCLE_SEGS] = vertices[vCount]; - vertices[vCount + CIRCLE_SEGS].coord = short4( 0, 0, 0, 0 ); + vertices[vCount + CIRCLE_SEGS].coord = short4( 0, 0, 0, 1 ); vCount += CIRCLE_SEGS + 1; + // box + box.vStart = vStartCommon; + box.iStart = iCount; + box.iCount = COUNT(boxIndices); + + baseIdx = vCount - vStartCommon; + + for (int i = 0; i < COUNT(boxIndices); i++) + indices[iCount++] = baseIdx + boxIndices[i]; + + for (int i = 0; i < COUNT(boxCoords); i++) { + Vertex &v = vertices[vCount++]; + v.coord = boxCoords[i]; + v.normal = short4(0, 0, 0, 0); + v.texCoord = short4(0, 0, 0, 0); + v.color = ubyte4(255, 255, 255, 255); + v.light = ubyte4(255, 255, 255, 255); + } + // plane #ifdef GENERATE_WATER_PLANE plane.vStart = vStartCommon; @@ -505,7 +579,7 @@ struct MeshBuilder { baseIdx = vCount - vStartCommon; for (int16 j = -PLANE_DETAIL; j <= PLANE_DETAIL; j++) for (int16 i = -PLANE_DETAIL; i <= PLANE_DETAIL; i++) { - vertices[vCount++].coord = short4( i, j, 0, 0 ); + vertices[vCount++].coord = short4( i, j, 0, 1 ); if (j < PLANE_DETAIL && i < PLANE_DETAIL) { int idx = baseIdx + (j + PLANE_DETAIL) * (PLANE_DETAIL * 2 + 1) + i + PLANE_DETAIL; indices[iCount + 0] = idx + PLANE_DETAIL * 2 + 1; @@ -570,6 +644,7 @@ struct MeshBuilder { quad.aIndex = rangeCommon.aIndex; circle.aIndex = rangeCommon.aIndex; plane.aIndex = rangeCommon.aIndex; + box.aIndex = rangeCommon.aIndex; } ~MeshBuilder() { @@ -607,7 +682,7 @@ struct MeshBuilder { res.x += x; res.y += y; res.z += z; - res.w = joint; + res.w = joint * 2; return res; } @@ -622,6 +697,69 @@ struct MeshBuilder { return false; } + void weldSkinJoints(Vertex *vertices, int16 skinIndex, int16 jointsIndex) { + if (skinIndex == -1 || jointsIndex == -1) { + return; + } + + ASSERT(level->models[skinIndex].mCount == level->models[jointsIndex].mCount); + + const TR::Model *model = level->models + skinIndex; + const TR::Node *node = (TR::Node*)&level->nodesData[model->node];//(TR::Node*)level->nodesData + model->node; + + int sIndex = 0; + short4 stack[16]; + short4 pos(0, 0, 0, 0); + short4 jointsPos[MAX_JOINTS]; + + for (int i = 0; i < model->mCount; i++) { + if (i > 0 && node) { + const TR::Node &t = node[i - 1]; + if (t.flags & 0x01) pos = stack[--sIndex]; + if (t.flags & 0x02) stack[sIndex++] = pos; + pos.x += t.x; + pos.y += t.y; + pos.z += t.z; + } + jointsPos[i] = pos; + } + + const ModelRange &rangeSkin = models[skinIndex]; + const ModelRange &rangeJoints = models[jointsIndex]; + + #define COORD_FILL(VAR,RANGE)\ + short4 *VAR = new short4[RANGE.vCount];\ + for (int i = 0; i < RANGE.vCount; i++) {\ + VAR[i] = vertices[RANGE.vStart + i].coord;\ + int index = VAR[i].w / 2;\ + VAR[i].x += jointsPos[index].x;\ + VAR[i].y += jointsPos[index].y;\ + VAR[i].z += jointsPos[index].z;\ + } + + COORD_FILL(vSkin, rangeSkin); + COORD_FILL(vJoints, rangeJoints); + + // bruteforce :( + for (int j = 0; j < rangeJoints.vCount; j++) { + for (int i = 0; i < rangeSkin.vCount; i++) { + if (//vSkin[i].w < vJoints[j].w && + abs(vSkin[i].x - vJoints[j].x) <= 1 && + abs(vSkin[i].y - vJoints[j].y) <= 1 && + abs(vSkin[i].z - vJoints[j].z) <= 1) { // compare position + vertices[rangeJoints.vStart + j].coord = vertices[rangeSkin.vStart + i].coord; // set bone index + vertices[rangeJoints.vStart + j].normal = vertices[rangeSkin.vStart + i].normal; + break; + } + } + } + + delete[] vSkin; + delete[] vJoints; + + #undef COORD_FILL + } + int calcWaterLevel(int16 roomIndex, bool flip) { TR::Room &room = level->rooms[roomIndex]; @@ -819,7 +957,7 @@ struct MeshBuilder { for (int i = 0; i < wVertices.length; i++) { short3 &v = wVertices[i]; - short3 &o = wOffsets[i]; + short3 &o = wOffsets[i]; v.x += o.x; v.y += o.y; @@ -831,6 +969,8 @@ struct MeshBuilder { for (int i = 0; i < wVertices.length; i++) { short3 &v = wVertices[i]; + int16 base = v.y; + v.y += WATER_VOLUME_HEIGHT - WATER_VOLUME_OFFSET - WATER_VOLUME_OFFSET; const vec3 sectorOffsets[] = { @@ -851,7 +991,9 @@ struct MeshBuilder { floor -= WATER_VOLUME_OFFSET * 3; - v.y = min(v.y, floor); + if (floor > base) { + v.y = min(v.y, floor); + } vertices[vCount++].coord = short4(v.x, v.y, v.z, 0); } @@ -862,11 +1004,13 @@ struct MeshBuilder { return 1 << texAttribute; } - void buildRoom(Geometry &geom, Dynamic &dyn, int blendMask, const TR::Room &room, TR::Level *level, Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart) { + void buildRoom(Geometry &geom, Dynamic *dyn, int blendMask, const TR::Room &room, TR::Level *level, Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart) { const TR::Room::Data &d = room.data; - dyn.count = 0; - dyn.faces = NULL; + if (dyn) { + dyn->count = 0; + dyn->faces = NULL; + } for (int j = 0; j < d.fCount; j++) { TR::Face &f = d.faces[j]; @@ -881,9 +1025,9 @@ struct MeshBuilder { if (!(blendMask & getBlendMask(t.attribute))) continue; - if (t.animated) { - ASSERT(dyn.count < 0xFFFF); - dyn.count++; + if (dyn && t.animated) { + ASSERT(dyn->count < 0xFFFF); + dyn->count++; continue; } @@ -894,9 +1038,9 @@ struct MeshBuilder { } // if room has non-static polygons, fill the list of dynamic faces - if (dyn.count) { - dyn.faces = new uint16[dyn.count]; - dyn.count = 0; + if (dyn && dyn->count) { + dyn->faces = new uint16[dyn->count]; + dyn->count = 0; for (int j = 0; j < d.fCount; j++) { TR::Face &f = d.faces[j]; TR::TextureInfo &t = level->objectTextures[f.flags.texture]; @@ -907,23 +1051,32 @@ struct MeshBuilder { continue; if (t.animated) - dyn.faces[dyn.count++] = j; + dyn->faces[dyn->count++] = j; } } } - bool buildMesh(Geometry &geom, int blendMask, const TR::Mesh &mesh, TR::Level *level, Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart, int16 joint, int x, int y, int z, int dir, const Color32 &light) { + bool buildMesh(Geometry &geom, int blendMask, const TR::Mesh &mesh, TR::Level *level, Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart, int16 joint, int x, int y, int z, int dir, const Color32 &light, bool useRoomTex, bool forceOpaque) { bool isOpaque = true; for (int j = 0; j < mesh.fCount; j++) { TR::Face &f = mesh.faces[j]; ASSERT(f.colored || f.flags.texture < level->objectTexturesCount); - TR::TextureInfo &t = f.colored ? whiteTile : level->objectTextures[f.flags.texture]; + //if (level->version & TR::VER_PSX) { + // f.colored = false; // PSX version has colored textures... not yet :) + //} + TR::TextureInfo &t = f.colored ? (useRoomTex ? whiteRoom : whiteObject) : level->objectTextures[f.flags.texture]; + + int texAttrib = forceOpaque ? 0 : t.attribute; - if (t.attribute != 0) + if (f.effects.additive) { + texAttrib = 2; + } + + if (texAttrib != 0) isOpaque = false; - if (!(blendMask & getBlendMask(t.attribute))) + if (!(blendMask & getBlendMask(texAttrib))) continue; if (!geom.validForTile(t.tile, t.clut)) @@ -942,9 +1095,9 @@ struct MeshBuilder { vertices[vCount].coord = transform(v.coord, joint, x, y, z, dir); vec3 n = vec3(v.normal.x, v.normal.y, v.normal.z).normal() * 32767.0f; - v.normal = short4(short(n.x), short(n.y), short(n.z), 0); + v.normal = short4(short(n.x), short(n.y), short(n.z), f.triangle ? 1 : 0); vertices[vCount].normal = rotate(v.normal, dir); - vertices[vCount].color = ubyte4( c.r, c.g, c.b, 255 ); + vertices[vCount].color = ubyte4( c.r, c.g, c.b, c.a ); vertices[vCount].light = ubyte4( light.r, light.g, light.b, 255 ); vCount++; @@ -1102,7 +1255,7 @@ struct MeshBuilder { return short4(int16(coord.x), int16(coord.y), int16(coord.z), 0); } - void addSprite(Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart, int16 x, int16 y, int16 z, const TR::TextureInfo &sprite, const Color32 &tColor, const Color32 &bColor, bool expand = false) { + void addSprite(Index *indices, Vertex *vertices, int &iCount, int &vCount, int vStart, int16 x, int16 y, int16 z, bool invertX, bool invertY, const TR::TextureInfo &sprite, const Color32 &tColor, const Color32 &bColor, bool expand = false) { addQuad(indices, iCount, vCount, vStart, NULL, NULL, false, false); Vertex *quad = &vertices[vCount]; @@ -1110,10 +1263,21 @@ struct MeshBuilder { int16 x0, y0, x1, y1; if (expand) { - x0 = x + int16(sprite.l); - y0 = y + int16(sprite.t); - x1 = x + int16(sprite.r); - y1 = y + int16(sprite.b); + if (invertX) { + x0 = x - int16(sprite.l); + x1 = x - int16(sprite.r); + } else { + x0 = x + int16(sprite.l); + x1 = x + int16(sprite.r); + } + + if (invertY) { + y0 = y - int16(sprite.t); + y1 = y - int16(sprite.b); + } else { + y0 = y + int16(sprite.t); + y1 = y + int16(sprite.b); + } } else { x0 = x1 = x; y0 = y1 = y; @@ -1122,17 +1286,17 @@ struct MeshBuilder { #ifndef MERGE_SPRITES if (!expand) { vec3 pos = vec3(float(x), float(y), float(z)); - quad[0].coord = coordTransform(pos, vec3( float(sprite.l), float(-sprite.t), 0 )); - quad[1].coord = coordTransform(pos, vec3( float(sprite.r), float(-sprite.t), 0 )); - quad[2].coord = coordTransform(pos, vec3( float(sprite.r), float(-sprite.b), 0 )); - quad[3].coord = coordTransform(pos, vec3( float(sprite.l), float(-sprite.b), 0 )); + quad[0].coord = coordTransform(pos, vec3( float(sprite.l), float(-sprite.t), 1 )); + quad[1].coord = coordTransform(pos, vec3( float(sprite.r), float(-sprite.t), 1 )); + quad[2].coord = coordTransform(pos, vec3( float(sprite.r), float(-sprite.b), 1 )); + quad[3].coord = coordTransform(pos, vec3( float(sprite.l), float(-sprite.b), 1 )); } else #endif { - quad[0].coord = short4( x0, y0, z, 0 ); - quad[1].coord = short4( x1, y0, z, 0 ); - quad[2].coord = short4( x1, y1, z, 0 ); - quad[3].coord = short4( x0, y1, z, 0 ); + quad[0].coord = short4( x0, y0, z, 1 ); + quad[1].coord = short4( x1, y0, z, 1 ); + quad[2].coord = short4( x1, y1, z, 1 ); + quad[3].coord = short4( x0, y1, z, 1 ); } quad[0].normal = quad[1].normal = quad[2].normal = quad[3].normal = short4( 0, 0, 0, 0 ); @@ -1164,10 +1328,10 @@ struct MeshBuilder { int16 maxX = int16(size.x) + minX; int16 maxY = int16(size.y) + minY; - vertices[vCount + 0].coord = short4( minX, minY, 0, 0 ); - vertices[vCount + 1].coord = short4( maxX, minY, 0, 0 ); - vertices[vCount + 2].coord = short4( maxX, maxY, 0, 0 ); - vertices[vCount + 3].coord = short4( minX, maxY, 0, 0 ); + vertices[vCount + 0].coord = short4( minX, minY, 0, 1 ); + vertices[vCount + 1].coord = short4( maxX, minY, 0, 1 ); + vertices[vCount + 2].coord = short4( maxX, maxY, 0, 1 ); + vertices[vCount + 3].coord = short4( minX, maxY, 0, 1 ); for (int i = 0; i < 4; i++) { Vertex &v = vertices[vCount + i]; @@ -1193,22 +1357,23 @@ struct MeshBuilder { int &iCount = dynICount; int &vCount = dynVCount; - short4 uv = short4( whiteTile.texCoordAtlas[0].x, whiteTile.texCoordAtlas[0].y, 32767, 32767 ); + short4 uv = short4( whiteSprite.texCoordAtlas[0].x, whiteSprite.texCoordAtlas[0].y, 32767, 32767 ); int16 minX = int16(pos.x); int16 minY = int16(pos.y); int16 maxX = int16(size.x) + minX; int16 maxY = int16(size.y) + minY; + int16 s = 1; - vertices[vCount + 0].coord = short4( minX, minY, 0, 0 ); - vertices[vCount + 1].coord = short4( maxX, minY, 0, 0 ); - vertices[vCount + 2].coord = short4( maxX, int16(minY + 1), 0, 0 ); - vertices[vCount + 3].coord = short4( minX, int16(minY + 1), 0, 0 ); + vertices[vCount + 0].coord = short4( minX - s, minY - s, 0, 1 ); + vertices[vCount + 1].coord = short4( maxX + s, minY - s, 0, 1 ); + vertices[vCount + 2].coord = short4( maxX + s, minY + s, 0, 1 ); + vertices[vCount + 3].coord = short4( minX - s, minY + s, 0, 1 ); - vertices[vCount + 4].coord = short4( minX, minY, 0, 0 ); - vertices[vCount + 5].coord = short4( int16(minX + 1), minY, 0, 0 ); - vertices[vCount + 6].coord = short4( int16(minX + 1), maxY, 0, 0 ); - vertices[vCount + 7].coord = short4( minX, maxY, 0, 0 ); + vertices[vCount + 4].coord = short4( minX - s, minY - s, 0, 1 ); + vertices[vCount + 5].coord = short4( minX + s, minY - s, 0, 1 ); + vertices[vCount + 6].coord = short4( minX + s, maxY + s, 0, 1 ); + vertices[vCount + 7].coord = short4( minX - s, maxY + s, 0, 1 ); for (int i = 0; i < 8; i++) { Vertex &v = vertices[vCount + i]; @@ -1220,15 +1385,15 @@ struct MeshBuilder { addQuad(indices, iCount, vCount, 0, vertices, NULL, false, false); vCount += 4; addQuad(indices, iCount, vCount, 0, vertices, NULL, false, false); vCount += 4; - vertices[vCount + 0].coord = short4( minX, int16(maxY - 1), 0, 0 ); - vertices[vCount + 1].coord = short4( maxX, int16(maxY - 1), 0, 0 ); - vertices[vCount + 2].coord = short4( maxX, maxY, 0, 0 ); - vertices[vCount + 3].coord = short4( minX, maxY, 0, 0 ); + vertices[vCount + 0].coord = short4( minX + s, maxY - s, 0, 1 ); + vertices[vCount + 1].coord = short4( maxX + s, maxY - s, 0, 1 ); + vertices[vCount + 2].coord = short4( maxX + s, maxY + s, 0, 1 ); + vertices[vCount + 3].coord = short4( minX + s, maxY + s, 0, 1 ); - vertices[vCount + 4].coord = short4( int16(maxX - 1), minY, 0, 0 ); - vertices[vCount + 5].coord = short4( maxX, minY, 0, 0 ); - vertices[vCount + 6].coord = short4( maxX, maxY, 0, 0 ); - vertices[vCount + 7].coord = short4( int16(maxX - 1), maxY, 0, 0 ); + vertices[vCount + 4].coord = short4( maxX - s, minY + s, 0, 1 ); + vertices[vCount + 5].coord = short4( maxX + s, minY + s, 0, 1 ); + vertices[vCount + 6].coord = short4( maxX + s, maxY + s, 0, 1 ); + vertices[vCount + 7].coord = short4( maxX - s, maxY + s, 0, 1 ); for (int i = 0; i < 8; i++) { Vertex &v = vertices[vCount + i]; @@ -1242,8 +1407,7 @@ struct MeshBuilder { } void renderBuffer(Index *indices, int iCount, Vertex *vertices, int vCount) { - if (!iCount) return; - ASSERT(vCount > 0); + if (iCount <= 0) return; dynRange.iStart = 0; dynRange.iCount = iCount; @@ -1320,18 +1484,19 @@ struct MeshBuilder { } void dynEnd() { - if (dynICount) + if (dynICount) { renderBuffer(dynIndices, dynICount, dynVertices, dynVCount); + } } void dynCheck(int freeIndicesCount) { - if (dynICount + freeIndicesCount > DYN_MESH_FACES * 3) { + if (dynICount + freeIndicesCount > COUNT(dynIndices)) { dynEnd(); dynBegin(); } } - void addDynSprite(int spriteIndex, const short3 ¢er, const Color32 &tColor, const Color32 &bColor, bool expand = false) { + void addDynSprite(int spriteIndex, const short3 ¢er, bool invertX, bool invertY, const Color32 &tColor, const Color32 &bColor, bool expand = false) { dynCheck(1 * 6); TR::TextureInfo &sprite = level->spriteTextures[spriteIndex]; @@ -1350,7 +1515,7 @@ struct MeshBuilder { } #endif - addSprite(dynIndices, dynVertices, dynICount, dynVCount, 0, center.x, center.y, center.z, sprite, tColor, bColor, expand); + addSprite(dynIndices, dynVertices, dynICount, dynVCount, 0, center.x, center.y, center.z, invertX, invertY, sprite, tColor, bColor, expand); } void renderRoomSprites(int roomIndex) { @@ -1363,7 +1528,8 @@ struct MeshBuilder { TR::Room::Data &d = level->rooms[roomIndex].data; for (int j = 0; j < d.sCount; j++) { TR::Room::Data::Sprite &f = d.sprites[j]; - addDynSprite(f.texture, d.vertices[f.vertexIndex].pos, COLOR_WHITE, COLOR_WHITE); + TR::Room::Data::Vertex &v = d.vertices[f.vertexIndex]; + addDynSprite(f.texture, d.vertices[f.vertexIndex].pos, false, false, v.color, v.color); } dynEnd(); @@ -1377,7 +1543,8 @@ struct MeshBuilder { } void renderModel(int modelIndex, bool underwater = false) { - ASSERT(level->models[modelIndex].mCount == Core::active.basisCount); + ASSERT((Core::pass != Core::passCompose && Core::pass != Core::passShadow && Core::pass != Core::passAmbient) || + level->models[modelIndex].mCount == Core::active.basisCount); int part = 0; @@ -1401,6 +1568,8 @@ struct MeshBuilder { Core::mModel.identity(); Core::mModel.setRot(basis.rot); Core::mModel.setPos(basis.pos); + #else + Core::active.shader->setParam(uBasis, *(vec4*)&basis, 2); #endif #endif @@ -1419,21 +1588,6 @@ struct MeshBuilder { } } - void renderModelFull(int modelIndex, bool underwater = false) { - Core::setBlendMode(bmPremult); - transparent = 0; - renderModel(modelIndex, underwater); - transparent = 1; - renderModel(modelIndex, underwater); - Core::setBlendMode(bmAdd); - Core::setDepthWrite(false); - transparent = 2; - renderModel(modelIndex, underwater); - Core::setDepthWrite(true); - Core::setBlendMode(bmNone); - transparent = 0; - } - void renderShadowBlob() { mesh->render(shadowBlob); } @@ -1450,6 +1604,10 @@ struct MeshBuilder { mesh->render(plane); } + void renderBox() { + mesh->render(box); + } + void renderWaterVolume(int roomIndex) { MeshRange &range = rooms[roomIndex].waterVolume; if (range.iCount) diff --git a/src/napi_socket.h b/src/napi_socket.h index bc86e5ae..7a3d8f54 100644 --- a/src/napi_socket.h +++ b/src/napi_socket.h @@ -59,8 +59,8 @@ namespace NAPI { void init() { sock = INVALID_SOCKET; - WSAData wData; - WSAStartup(0x0101, &wData); + WSAData wData; + WSAStartup(0x0101, &wData); } void deinit() { diff --git a/src/network.h b/src/network.h index 55728f20..19348af4 100644 --- a/src/network.h +++ b/src/network.h @@ -111,7 +111,7 @@ namespace Network { void start(IGame *game) { Network::game = game; NAPI::listen(NET_PORT); - syncInputTime = syncStateTime = osGetTime(); + syncInputTime = syncStateTime = Core::getTime(); } void stop() { @@ -216,7 +216,7 @@ namespace Network { NAPI::Peer from; Packet packet, response; - int time = osGetTime(); + int time = Core::getTime(); while ( (count = recvPacket(from, packet)) > 0 ) { Player *player = getPlayerByPeer(from); diff --git a/src/trigger.h b/src/objects.h similarity index 87% rename from src/trigger.h rename to src/objects.h index 91d8e839..ce631f1c 100644 --- a/src/trigger.h +++ b/src/objects.h @@ -153,9 +153,9 @@ struct Flame : Sprite { Controller *owner; int32 jointIndex; - float sleep; + float sleepTime; - Flame(IGame *game, int entity) : Sprite(game, entity, false, Sprite::FRAME_ANIMATED), owner(NULL), jointIndex(0), sleep(0.0f) { + Flame(IGame *game, int entity) : Sprite(game, entity, false, Sprite::FRAME_ANIMATED), owner(NULL), jointIndex(0), sleepTime(0.0f) { time = randf() * 3.0f; activate(); } @@ -166,7 +166,10 @@ struct Flame : Sprite { virtual void update() { Sprite::update(); - game->playSound(TR::SND_FLAME, pos, Sound::PAN); + + if (jointIndex <= 0) { + game->playSound(TR::SND_FLAME, pos, Sound::PAN); + } Character *lara = (Character*)((owner && owner->getEntity().isLara()) ? owner : game->getLara(pos)); @@ -183,15 +186,15 @@ struct Flame : Sprite { lara->hit(FLAME_BURN_DAMAGE * Core::deltaTime, this); } else if (lara->health > 0.0f) { - if (sleep > 0.0f) - sleep = max(0.0f, sleep - Core::deltaTime); + if (sleepTime > 0.0f) + sleepTime = max(0.0f, sleepTime - Core::deltaTime); - if (sleep == 0.0f && !lara->burn && lara->collide(Sphere(pos, 600.0f))) { + if (sleepTime == 0.0f && !lara->burn && lara->collide(Sphere(pos, 600.0f))) { lara->hit(FLAME_HEAT_DAMAGE * Core::deltaTime, this); if (lara->collide(Sphere(pos, 300.0f))) { Flame::add(game, lara, 0); - sleep = 3.0f; // stay inactive for 3 seconds + sleepTime = 3.0f; // stay inactive for 3 seconds } } } @@ -234,26 +237,41 @@ struct MuzzleFlash : Controller { timer = 0.0f; } + virtual bool getSaveData(SaveEntity &data) { + return false; + } + virtual void update() { + if (!owner) { + game->removeEntity(this); + return; + } + timer += Core::deltaTime; if (timer < MUZZLE_FLASH_TIME) { float intensity = clamp((MUZZLE_FLASH_TIME - timer) * 20.0f, EPS, 1.0f); vec4 lightPos = vec4(owner->getJoint(joint).pos, 0); vec4 lightColor = FLASH_LIGHT_COLOR * vec4(intensity, intensity, intensity, 1.0f / sqrtf(intensity)); + if (lightIndex > -1) { ASSERT(lightIndex + 1 < MAX_LIGHTS); Core::lightPos[lightIndex] = lightPos; Core::lightColor[lightIndex] = lightColor; - } else + } else { getRoom().addDynLight(owner->entity, lightPos, lightColor, true); + } + } else { + if (lightIndex > -1) { ASSERT(lightIndex < MAX_LIGHTS); Core::lightPos[lightIndex] = vec4(0); Core::lightColor[lightIndex] = vec4(0, 0, 0, 1); - } else + } else { getRoom().removeDynLight(owner->entity); + } + game->removeEntity(this); } } @@ -280,7 +298,6 @@ struct MuzzleFlash : Controller { } }; -#define LAVA_PARTICLE_BOUNCES 4 #define LAVA_PARTICLE_DAMAGE 10 #define LAVA_V_SPEED -165 #define LAVA_H_SPEED 32 @@ -293,16 +310,21 @@ struct TrapLavaEmitter : Controller { vec3 velocity; int16 roomIndex; int8 frame; - int8 bounces; void update(TR::Level *level, Controller *lara) { Controller::applyGravity(velocity.y); + vec3 opos = pos; pos += velocity * (30.0f * Core::deltaTime); - bool hit = false; - if (!bounces && lara->collide(Sphere(pos, 0.0f))) { + if (lara->collide(Sphere(pos, 0.0f))) { lara->hit(LAVA_PARTICLE_DAMAGE); - bounces = LAVA_PARTICLE_BOUNCES + 1; + frame = -1; + return; + } + + if (level->rooms[roomIndex].flags.water) { + frame = -1; + return; } TR::Room::Sector *sector = level->getSector(roomIndex, pos); @@ -310,12 +332,29 @@ struct TrapLavaEmitter : Controller { float ceiling = level->getCeiling(sector, pos); if (pos.y > floor || pos.y < ceiling) { - bounces++; + vec3 n; + + if (pos.y - floor > 128) { + int ix = int(pos.x); + int iz = int(pos.z); + ix -= ix / 1024 * 1024 + 512; + iz -= iz / 1024 * 1024 + 512; + + if (abs(ix) > abs(iz)) { + n = vec3(ix < 0 ? -1.0f : 1.0f, 0, 0); + } else { + n = vec3(0, 0, iz < 0 ? -1.0f : 1.0f); + } - if (pos.y > floor) pos.y = floor; - if (pos.y < ceiling) pos.y = ceiling; + } else if (pos.y > floor) { + n = vec3(0, -1, 0); + } else if (pos.y < ceiling) { + n = vec3(0, 1, 0); + } - velocity = velocity.reflect(vec3(0, 1, 0)) * 0.5f; + velocity = velocity.reflect(n) * 0.5f; + pos = opos; + frame--; } } }; @@ -324,9 +363,9 @@ struct TrapLavaEmitter : Controller { int spriteIndex; TrapLavaEmitter(IGame *game, int entity) : Controller(game, entity) { - spriteIndex = game->getLevel()->getModelIndex(TR::Entity::LAVA_PARTICLE); + spriteIndex = level->getModelIndex(TR::Entity::LAVA_PARTICLE); if (spriteIndex) { - game->getLevel()->spriteSequences[-(spriteIndex + 1)].transp = 2; // fix blending mode to additive + level->spriteSequences[-(spriteIndex + 1)].transp = 2; // fix blending mode to additive } particles.capacity = 128; } @@ -335,34 +374,34 @@ struct TrapLavaEmitter : Controller { if (!spriteIndex) return; - Controller *lara = game->getLara(); + Controller *lara = game->getLara(pos); vec3 d = (lara->pos - pos).abs(); - if (!isActive() || max(d.x, d.y, d.z) > LAVA_EMITTER_RANGE) return; + if (isActive() && max(d.x, d.z) < LAVA_EMITTER_RANGE) { + if (timer <= 0.0f) { + vec2 d; + sincos(PI * 2.0f * randf(), &d.x, &d.y); + d *= randf() * LAVA_H_SPEED; - if (timer <= 0.0f) { - float speed = randf() * LAVA_H_SPEED; - float angle = PI * 2.0f * randf(); + Particle part; + part.pos = pos; + part.velocity = vec3(d.x, randf() * LAVA_V_SPEED, d.y); + part.roomIndex = getRoomIndex(); + part.frame = rand() % level->spriteSequences[-(spriteIndex + 1)].sCount; + particles.push(part); - Particle part; - part.pos = pos; - part.velocity = vec3(cosf(angle) * speed, randf() * LAVA_V_SPEED, sinf(angle) * speed); - part.roomIndex = getRoomIndex(); - part.bounces = 0; - part.frame = rand() % level->spriteSequences[-(spriteIndex + 1)].sCount; - particles.push(part); + game->playSound(TR::SND_LAVA, pos, Sound::PAN); + timer += 1.0f / 30.0f; - game->playSound(TR::SND_LAVA, pos, Sound::PAN); - timer += 1.0f / 30.0f; - } else { - timer -= Core::deltaTime; + } else { + timer -= Core::deltaTime; + } } - TR::Level *level = game->getLevel(); for (int i = 0; i < particles.length; i++) { particles[i].update(level, lara); - if (particles[i].bounces > LAVA_PARTICLE_BOUNCES) { + if (particles[i].frame < 0) { particles.removeFast(i); i--; } @@ -373,12 +412,12 @@ struct TrapLavaEmitter : Controller { for (int i = 0; i < particles.length; i++) { Particle &part = particles[i]; - uint8 intensity = clamp(int(max(0.0f, 1.0f - part.bounces * 0.25f) * 0.5f * 255.0f), 0, 255); + uint8 intensity = clamp(int(part.frame * 0.18f * 255.0f), 0, 255); Color32 color(intensity, intensity, intensity, 255); vec3 p = part.pos - Core::viewPos.xyz(); - mesh->addDynSprite(level->spriteSequences[-(spriteIndex + 1)].sStart + part.frame, short3(int16(p.x), int16(p.y), int16(p.z)), color, color); + mesh->addDynSprite(level->spriteSequences[-(spriteIndex + 1)].sStart + part.frame, short3(int16(p.x), int16(p.y), int16(p.z)), false, false, color, color); } } }; @@ -396,54 +435,68 @@ struct TrapBoulder : Controller { vec3 velocity; - TrapBoulder(IGame *game, int entity) : Controller(game, entity), velocity(0) {} + TrapBoulder(IGame *game, int entity) : Controller(game, entity), velocity(0) { + flags.unused = false; + } virtual void update() { - TR::Level::FloorInfo info; - getFloorInfo(getRoomIndex(), pos, info); + if (flags.active == 0) { + if (state != STATE_FALL) { + const TR::Entity &e = getEntity(); + roomIndex = e.room; + pos = vec3(float(e.x), float(e.y), float(e.z)); + velocity = vec3(0.0f); + animation.setAnim(0); + flags.unused = false; + } + return; + } - vec3 dir = getDir(); + if (flags.unused) { + return; + } - bool onGround = false; + vec3 p = pos; - if (pos.y >= info.floor - 256) { - onGround = true; - pos.y = info.floor; - velocity = dir * animation.getSpeed(); - if (state != STATE_ROLL) - animation.setState(STATE_ROLL); - } else { - if (velocity.y == 0.0f) - velocity.y = 10.0f; + if (velocity.y != 0.0f) { applyGravity(velocity.y); - animation.setState(STATE_FALL); } - - vec3 p = pos; pos += velocity * (30.0f * Core::deltaTime); - if (info.roomNext != TR::NO_ROOM) - roomIndex = info.roomNext; + TR::Room::Sector *sector = level->getSector(roomIndex, pos); + p.y = level->getFloor(sector, pos); - if (onGround) { - game->checkTrigger(this, true); + if (pos.y < p.y) { + if (velocity.y == 0.0f) { + velocity.y = -10.0f; + } + } else { + if (state != STATE_ROLL) { + animation.setState(STATE_ROLL); + velocity = getDir() * animation.getSpeed(); + } + } + + if (pos.y >= p.y - 256.0f) { + velocity.y = 0.0f; + pos.y = p.y; } + int16 roomIdx = this->roomIndex; vec3 v = pos + getDir() * 512.0f; - getFloorInfo(getRoomIndex(), v, info); - if (pos.y > info.floor) { - if (onGround) { - pos = p; - deactivate(true); - game->checkTrigger(this, true); - return; - } else { - pos.x = p.x; - pos.z = p.z; - velocity.x = velocity.z = 0.0f; - } + sector = level->getSector(roomIdx, v); + if (pos.y > level->getFloor(sector, v)) { + flags.unused = true; + + pos.x = int(pos.x / 1024.0f) * 1024.0f + 512.0f; + pos.z = int(pos.z / 1024.0f) * 1024.0f + 512.0f; + sector = level->getSector(roomIndex, pos); + pos.y = level->getFloor(sector, pos); } + game->checkTrigger(this, true); + updateAnimation(true); + Character *lara = (Character*)game->getLara(pos); if (lara->health > 0.0f && collide(lara)) { if (lara->stand == Character::STAND_GROUND) @@ -451,8 +504,6 @@ struct TrapBoulder : Controller { if (lara->stand == Character::STAND_AIR) lara->hit(BOULDER_DAMAGE_AIR * 30.0f * Core::deltaTime, this); } - - updateAnimation(true); } }; @@ -574,7 +625,7 @@ struct MovingBlock : Controller { virtual void setSaveData(const SaveEntity &data) { updateFloor(false); Controller::setSaveData(data); - if (flags.state == TR::Entity::asNone) + if (state != STATE_MOVE) updateFloor(true); } @@ -809,12 +860,12 @@ struct Drawbridge : Controller { #define CRYSTAL_LIGHT_RADIUS 1024.0f #define CRYSTAL_LIGHT_COLOR vec4(0.1f, 0.1f, 3.0f, 1.0f / CRYSTAL_LIGHT_RADIUS) +#define CRYSTAL_CUBEMAP_SIZE 64 struct Crystal : Controller { Texture *environment; - Crystal(IGame *game, int entity) : Controller(game, entity) { - environment = new Texture(64, 64, FMT_RGBA, OPT_CUBEMAP | OPT_MIPMAPS | OPT_TARGET); + Crystal(IGame *game, int entity) : Controller(game, entity), environment(NULL) { activate(); } @@ -839,9 +890,30 @@ struct Crystal : Controller { } virtual void render(Frustum *frustum, MeshBuilder *mesh, Shader::Type type, bool caustics) { - Core::setMaterial(0.5, 0.5, 3.0, 1.0f); // blue color dodge for crystal - environment->bind(sEnvironment); + Core::setMaterial(0.5, 0.5, 3.0, 0.0f); // 0.0f - use vertex normal as texcoord + GAPI::Texture *dtex = Core::active.textures[sDiffuse]; + if (environment) { + environment->bind(sDiffuse); + } else { + Core::whiteCube->bind(sDiffuse); + } Controller::render(frustum, mesh, type, caustics); + if (dtex) dtex->bind(sDiffuse); + } + + void bake() { + ASSERT(!environment); + + uint32 opt = OPT_CUBEMAP | OPT_TARGET; + #ifdef USE_CUBEMAP_MIPS + opt |= OPT_MIPMAPS; + #endif + + environment = new Texture(CRYSTAL_CUBEMAP_SIZE, CRYSTAL_CUBEMAP_SIZE, 1, FMT_RGB16, opt); + game->renderEnvironment(getRoomIndex(), pos - vec3(0, 512, 0), &environment); + if (opt & OPT_MIPMAPS) { + environment->generateMipMap(); + } } }; @@ -1157,7 +1229,7 @@ struct Lightning : Controller { } else if (!hasTargets) { target = pos + vec3(0.0f, 1024.0f, 0.0f); } else - target = getJoint(1 + int(randf() * 5)).pos; + target = getJoint(1 + rand() % 5).pos; } game->playSound(TR::SND_LIGHTNING, pos, Sound::PAN); } @@ -1184,9 +1256,10 @@ struct Lightning : Controller { } void setVertex(Vertex &v, const vec3 &coord, int16 joint, int idx) { + TR::TextureInfo &tex = CommonTex[CTEX_FLASH]; v.coord = toCoord(coord, joint); v.normal = short4( 0, -1, 0, 0 ); - v.texCoord = short4( barTile[0].texCoordAtlas[idx].x, barTile[0].texCoordAtlas[idx].y, 32767, 32767 ); + v.texCoord = short4( tex.texCoordAtlas[idx].x, tex.texCoordAtlas[idx].y, 32767, 32767 ); v.color = ubyte4( 255, 255, 255, 255 ); } @@ -1233,7 +1306,7 @@ struct Lightning : Controller { if (depth > 0) { for (int i = 0; i < 2; i++) { - vec3 a = points[int(randf() * (count - 1))]; + vec3 a = points[rand() % (count - 1)]; vec3 b = a; b.x += (randf() - 0.5f) * spread; b.y = points[count - 1].y; @@ -1257,7 +1330,7 @@ struct Lightning : Controller { game->setShader(Core::pass, Shader::FLASH, false, false); Core::setMaterial(0.0f, 0.0f, 0.0f, 1.0f); - Core::active.shader->setParam(uBasis, b); + Core::setBasis(&b, 1); Core::setCullMode(cmNone); Core::setBlendMode(bmAdd); @@ -1289,7 +1362,6 @@ struct MidasHand : Controller { if (d.x < 512.0f && d.z < 512.0f) { // check for same sector lara->hit(1001.0f, this, TR::HIT_MIDAS); - deactivate(true); return; } @@ -1360,7 +1432,13 @@ struct MovingObject : Controller { struct CentaurStatue : Controller { - CentaurStatue(IGame *game, int entity) : Controller(game, entity) {} + CentaurStatue(IGame *game, int entity) : Controller(game, entity) { + flags.unused = false; + } + + virtual bool activate() { + return (flags.unused ? false : Controller::activate()); + } virtual void update() { if (explodeMask) { @@ -1371,6 +1449,7 @@ struct CentaurStatue : Controller { } if ((pos - game->getLara(pos)->pos).length() < CENTAUR_STATUE_RANGE) { + flags.unused = true; explode(0xFFFFFFFF, 0.0f); game->playSound(TR::SND_EXPLOSION, pos, Sound::PAN); Controller *enemy = game->addEntity(TR::Entity::ENEMY_CENTAUR, getRoomIndex(), pos, angle.y); @@ -1600,7 +1679,7 @@ struct Explosion : Sprite { Explosion(IGame *game, int entity) : Sprite(game, entity, true, Sprite::FRAME_ANIMATED) { game->playSound(TR::SND_EXPLOSION, pos, Sound::PAN); - game->getLevel()->spriteSequences[-(getEntity().modelIndex + 1)].transp = 2; // fix blending mode to additive + level->spriteSequences[-(getEntity().modelIndex + 1)].transp = 2; // fix blending mode to additive } virtual bool getSaveData(SaveEntity &data) { @@ -1618,6 +1697,36 @@ struct BreakableWindow : Controller { }; +#define HELICOPTER_SPEED 3000 +#define HELICOPTER_RANGE (1024 * 30) + +struct HelicopterFlying : Controller { + + HelicopterFlying(IGame *game, int entity) : Controller(game, entity) {} + + virtual void update() { + pos.z += HELICOPTER_SPEED * Core::deltaTime; + updateAnimation(false); + updateRoom(); + + Controller *lara = game->getLara(pos); + + float dist = pos.z - lara->pos.z; + + Sound::Sample *sample = game->playSound(TR::SND_HELICOPTER, vec3(0.0), 0); + if (sample) { + sample->volume = (1.0f - dist / HELICOPTER_RANGE) * 0.8f; + } + + if (fabsf(dist) > HELICOPTER_RANGE) { + Sound::stop(TR::SND_HELICOPTER); + flags.invisible = true; + deactivate(true); + } + } +}; + + #define STONE_ITEM_LIGHT_RADIUS 2048.0f struct StoneItem : Controller { @@ -1679,7 +1788,7 @@ struct Bullet : Controller { //getRoom().removeDynLight(entity); pos = pos + velocity * Core::deltaTime; - game->getLevel()->getSector(roomIndex, pos); + level->getSector(roomIndex, pos); Controller::update(); //getRoom().addDynLight(entity, pos, vec4(1, 1, 0, 1.0f / 1024.0f)); @@ -1729,4 +1838,4 @@ struct Bullet : Controller { } }; -#endif \ No newline at end of file +#endif diff --git a/src/platform/32x/32x.h b/src/platform/32x/32x.h new file mode 100644 index 00000000..c06d4b3b --- /dev/null +++ b/src/platform/32x/32x.h @@ -0,0 +1,160 @@ +#ifndef __32X_H__ +#define __32X_H__ + +#define MARS_CRAM (*(volatile unsigned short *)0x20004200) +#define MARS_FRAMEBUFFER (*(volatile unsigned short *)0x24000000) +#define MARS_OVERWRITE_IMG (*(volatile unsigned short *)0x24020000) +#define MARS_SDRAM (*(volatile unsigned short *)0x26000000) + +#define MARS_SYS_INTMSK (*(volatile unsigned short *)0x20004000) +#define MARS_SYS_DMACTR (*(volatile unsigned short *)0x20004006) +#define MARS_SYS_DMASAR (*(volatile unsigned long *)0x20004008) +#define MARS_SYS_DMADAR (*(volatile unsigned long *)0x2000400C) +#define MARS_SYS_DMALEN (*(volatile unsigned short *)0x20004010) +#define MARS_SYS_DMAFIFO (*(volatile unsigned short *)0x20004012) +#define MARS_SYS_VRESI_CLR (*(volatile unsigned short *)0x20004014) +#define MARS_SYS_VINT_CLR (*(volatile unsigned short *)0x20004016) +#define MARS_SYS_HINT_CLR (*(volatile unsigned short *)0x20004018) +#define MARS_SYS_CMDI_CLR (*(volatile unsigned short *)0x2000401A) +#define MARS_SYS_PWMI_CLR (*(volatile unsigned short *)0x2000401C) +#define MARS_SYS_COMM0 (*(volatile unsigned short *)0x20004020) /* Master SH2 communication */ +#define MARS_SYS_COMM2 (*(volatile unsigned short *)0x20004022) +#define MARS_SYS_COMM4 (*(volatile unsigned short *)0x20004024) /* Slave SH2 communication */ +#define MARS_SYS_COMM6 (*(volatile unsigned short *)0x20004026) +#define MARS_SYS_COMM8 (*(volatile unsigned short *)0x20004028) /* controller 1 current value */ +#define MARS_SYS_COMM10 (*(volatile unsigned short *)0x2000402A) /* controller 2 current value */ +#define MARS_SYS_COMM12 (*(volatile unsigned long *)0x2000402C) /* vcount current value */ + +#define MARS_PWM_CTRL (*(volatile unsigned short *)0x20004030) +#define MARS_PWM_CYCLE (*(volatile unsigned short *)0x20004032) +#define MARS_PWM_LEFT (*(volatile unsigned short *)0x20004034) +#define MARS_PWM_RIGHT (*(volatile unsigned short *)0x20004036) +#define MARS_PWM_MONO (*(volatile unsigned short *)0x20004038) + +#define MARS_VDP_DISPMODE (*(volatile unsigned short *)0x20004100) +#define MARS_VDP_FILLEN (*(volatile unsigned short *)0x20004104) +#define MARS_VDP_FILADR (*(volatile unsigned short *)0x20004106) +#define MARS_VDP_FILDAT (*(volatile unsigned short *)0x20004108) +#define MARS_VDP_FBCTL (*(volatile unsigned short *)0x2000410A) + +#define MARS_SH2_ACCESS_VDP 0x8000 +#define MARS_68K_ACCESS_VDP 0x0000 + +#define MARS_PAL_FORMAT 0x0000 +#define MARS_NTSC_FORMAT 0x8000 + +#define MARS_VDP_PRIO_68K 0x0000 +#define MARS_VDP_PRIO_32X 0x0080 + +#define MARS_224_LINES 0x0000 +#define MARS_240_LINES 0x0040 + +#define MARS_VDP_MODE_OFF 0x0000 +#define MARS_VDP_MODE_256 0x0001 +#define MARS_VDP_MODE_32K 0x0002 +#define MARS_VDP_MODE_RLE 0x0003 + +#define MARS_VDP_VBLK 0x8000 +#define MARS_VDP_HBLK 0x4000 +#define MARS_VDP_PEN 0x2000 +#define MARS_VDP_FEN 0x0002 +#define MARS_VDP_FS 0x0001 + +#define SH2_CCTL_W1 0x80 +#define SH2_CCTL_W0 0x40 +#define SH2_CCTL_CP 0x10 +#define SH2_CCTL_TW 0x08 +#define SH2_CCTL_OD 0x04 +#define SH2_CCTL_ID 0x02 +#define SH2_CCTL_CE 0x01 + +#define SH2_FRT_TIER (*(volatile unsigned char *)0xFFFFFE10) +#define SH2_FRT_FTCSR (*(volatile unsigned char *)0xFFFFFE11) +#define SH2_FRT_FRCH (*(volatile unsigned char *)0xFFFFFE12) +#define SH2_FRT_FRCL (*(volatile unsigned char *)0xFFFFFE13) +#define SH2_FRT_OCRH (*(volatile unsigned char *)0xFFFFFE14) +#define SH2_FRT_OCRL (*(volatile unsigned char *)0xFFFFFE15) +#define SH2_FRT_TCR (*(volatile unsigned char *)0xFFFFFE16) +#define SH2_FRT_TOCR (*(volatile unsigned char *)0xFFFFFE17) +#define SH2_FRT_ICRH (*(volatile unsigned char *)0xFFFFFE18) +#define SH2_FRT_ICRL (*(volatile unsigned char *)0xFFFFFE19) + +#define SH2_DMA_SAR0 (*(volatile unsigned long *)0xFFFFFF80) +#define SH2_DMA_DAR0 (*(volatile unsigned long *)0xFFFFFF84) +#define SH2_DMA_TCR0 (*(volatile unsigned long *)0xFFFFFF88) +#define SH2_DMA_CHCR0 (*(volatile unsigned long *)0xFFFFFF8C) +#define SH2_DMA_VCR0 (*(volatile unsigned long *)0xFFFFFFA0) +#define SH2_DMA_DRCR0 (*(volatile unsigned char *)0xFFFFFE71) + +#define SH2_DMA_SAR1 (*(volatile unsigned long *)0xFFFFFF90) +#define SH2_DMA_DAR1 (*(volatile unsigned long *)0xFFFFFF94) +#define SH2_DMA_TCR1 (*(volatile unsigned long *)0xFFFFFF98) +#define SH2_DMA_CHCR1 (*(volatile unsigned long *)0xFFFFFF9C) +#define SH2_DMA_VCR1 (*(volatile unsigned long *)0xFFFFFFA8) +#define SH2_DMA_DRCR1 (*(volatile unsigned char *)0xFFFFFE72) + +#define SH2_DMA_DMAOR (*(volatile unsigned long *)0xFFFFFFB0) + +#define SH2_INT_ICR (*(volatile unsigned short *)0xFFFFFEE0) +#define SH2_INT_IPRA (*(volatile unsigned short *)0xFFFFFEE2) +#define SH2_INT_IPRB (*(volatile unsigned short *)0xFFFFFE60) +#define SH2_INT_VCRA (*(volatile unsigned short *)0xFFFFFE62) +#define SH2_INT_VCRB (*(volatile unsigned short *)0xFFFFFE64) +#define SH2_INT_VCRC (*(volatile unsigned short *)0xFFFFFE66) +#define SH2_INT_VCRD (*(volatile unsigned short *)0xFFFFFE68) +#define SH2_INT_VCRWDT (*(volatile unsigned short *)0xFFFFFEE4) +#define SH2_INT_VCRDIV (*(volatile unsigned long *)0xFFFFFF0C) + +#define SEGA_CTRL_UP 0x0001 +#define SEGA_CTRL_DOWN 0x0002 +#define SEGA_CTRL_LEFT 0x0004 +#define SEGA_CTRL_RIGHT 0x0008 +#define SEGA_CTRL_B 0x0010 +#define SEGA_CTRL_C 0x0020 +#define SEGA_CTRL_A 0x0040 +#define SEGA_CTRL_START 0x0080 +#define SEGA_CTRL_Z 0x0100 +#define SEGA_CTRL_Y 0x0200 +#define SEGA_CTRL_X 0x0400 +#define SEGA_CTRL_MODE 0x0800 + +#define SEGA_CTRL_TYPE 0xF000 +#define SEGA_CTRL_THREE 0x0000 +#define SEGA_CTRL_SIX 0x1000 +#define SEGA_CTRL_NONE 0xF000 + +#define MASTER_STATUS_OK 1 +#define SLAVE_STATUS_OK 2 +#define MASTER_LOCK 4 +#define SLAVE_LOCK 8 + +#define SH2_WDT_WTCNT 0x5A00 +#define SH2_WDT_WTCSR (0xA500 | (1 << 3) | (1 << 4)) +#define SH2_WDT_WTCSR_CKS_2 0 +#define SH2_WDT_WTCSR_CKS_64 1 +#define SH2_WDT_WTCSR_CKS_128 2 +#define SH2_WDT_WTCSR_CKS_256 3 +#define SH2_WDT_WTCSR_CKS_512 4 +#define SH2_WDT_WTCSR_CKS_1024 5 +#define SH2_WDT_WTCSR_CKS_4096 6 +#define SH2_WDT_WTCSR_CKS_8192 7 +#define SH2_WDT_WTCSR_TME (1 << 5) +#define SH2_WDT_WTCSR_WTIT (1 << 6) +#define SH2_WDT_WTCSR_OVF (1 << 7) + +/* global functions in sh2_crt0.s */ +extern "C" +{ + void fast_memcpy(void *dst, const void *src, int len); + void fast_memset(void *dst, int value, int len); + void CacheControl(int mode); + void CacheClearLine(void* ptr); +} + +#define CacheClear()\ + CacheControl(0);\ + CacheControl(SH2_CCTL_CP | SH2_CCTL_CE); + +#define MARS_WAIT() {while (MARS_SYS_COMM4);} + +#endif diff --git a/src/platform/32x/Makefile b/src/platform/32x/Makefile new file mode 100644 index 00000000..bbc4d909 --- /dev/null +++ b/src/platform/32x/Makefile @@ -0,0 +1,92 @@ +ifdef $(GENDEV) +ROOTDIR = $(GENDEV) +else +ROOTDIR = /opt/toolchains/sega +endif + +TARGET = OpenLara +BUILD = build +SOURCES = . asm ../../fixed + +LDSCRIPTSDIR = $(ROOTDIR)/ldscripts + +SHPREFIX = $(ROOTDIR)/sh-elf/bin/sh-elf- +SHCC = $(SHPREFIX)gcc +SHXX = $(SHPREFIX)g++ +SHPP = $(SHPREFIX)cpp +SHAS = $(SHPREFIX)as +SHLD = $(SHPREFIX)ld +SHOBJC = $(SHPREFIX)objcopy + +CC_VER := $(shell $(SHCC) -dumpversion) + +MDPREFIX = $(ROOTDIR)/m68k-elf/bin/m68k-elf- +MDAS = $(MDPREFIX)as +MDLD = $(MDPREFIX)ld + +LIBPATH = -L$(ROOTDIR)/sh-elf/lib -L$(ROOTDIR)/sh-elf/lib/gcc/sh-elf/$(CC_VER) -L$(ROOTDIR)/sh-elf/sh-elf/lib +INCPATH = -I. -I../../fixed -I$(ROOTDIR)/sh-elf/include -I$(ROOTDIR)/sh-elf/sh-elf/include + +SHCCFLAGS = -D__32X__ -m2 -mb -O2 -Wall -Wno-class-memaccess -g -c -fno-rtti -fno-exceptions -fomit-frame-pointer -fshort-enums -frandom-seed=0 +SHLDFLAGS = -T $(LDSCRIPTSDIR)/mars.ld -Wl,-Map=$(BUILD)/output.map -nostdlib +SHASFLAGS = --big + +MDLDFLAGS = -T $(LDSCRIPTSDIR)/md.ld --oformat binary +MDASFLAGS = -m68000 --register-prefix-optional + +DD = dd +RM = rm -f + +FILES_AS = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.s)) +FILES_CC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) +FILES_XX = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp)) + +LIBS = $(LIBPATH) -lm -lc -lgcc -lgcc-Os-4-200 -lnosys +OBJS = $(addprefix $(BUILD)/, $(notdir $(FILES_AS:%.s=%.o))) +OBJS += $(addprefix $(BUILD)/, $(notdir $(FILES_CC:%.c=%.o))) +OBJS += $(addprefix $(BUILD)/, $(notdir $(FILES_XX:%.cpp=%.o))) + +.PHONY: dump clean + +all: $(BUILD) m68k.bin $(TARGET).32x + +dump: + @[ -d dump ] || mkdir -p dump + $(SHXX) $(SHCCFLAGS) $(INCPATH) -S -o dump/main.s main.cpp + $(SHXX) $(SHCCFLAGS) $(INCPATH) -S -o dump/render.s render.cpp + $(SHXX) $(SHCCFLAGS) $(INCPATH) -S -o dump/sound.s sound.cpp + $(SHXX) $(SHCCFLAGS) $(INCPATH) -S -o dump/common.s ../../fixed/common.cpp + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + +$(TARGET).32x: $(TARGET).elf + $(SHOBJC) -O binary $< temp.bin + $(DD) if=temp.bin of=$@ bs=1024K conv=sync + $(RM) -f temp.bin + +$(TARGET).elf: $(OBJS) + $(SHCC) $(SHLDFLAGS) $(OBJS) $(LIBS) -o $(TARGET).elf + +m68k.bin: + make -C src-md + +$(BUILD)/%.o: %.s + $(SHAS) $(SHASFLAGS) $(INCPATH) -o $@ $< + +$(BUILD)/%.o: asm/%.s + $(SHPP) $(INCPATH) -o $(BUILD)/$(notdir $<) $< + $(SHAS) $(SHASFLAGS) $(INCPATH) -o $@ $(BUILD)/$(notdir $<) + +$(BUILD)/%.o: %.c + $(SHCC) $(SHCCFLAGS) $(INCPATH) -o $@ $< + +$(BUILD)/%.o: %.cpp + $(SHXX) $(SHCCFLAGS) $(INCPATH) -o $@ $< + +$(BUILD)/%.o: ../../fixed/%.cpp + $(SHXX) $(SHCCFLAGS) $(INCPATH) -o $@ $< + +clean: + make clean -C src-md + $(RM) $(BUILD)/* $(TARGET).32x $(TARGET).elf diff --git a/src/platform/32x/asm/block_prepare.s b/src/platform/32x/asm/block_prepare.s new file mode 100644 index 00000000..84c2abca --- /dev/null +++ b/src/platform/32x/asm/block_prepare.s @@ -0,0 +1,61 @@ +#include "common.i" +.data + +.global _block_prepare_start +.global _block_prepare_end + +.align 4 +_block_prepare_start: + +#include "transformMesh.i" +#include "transformRoom.i" + +.align 2 +var_gVerticesBase: + .long _gVerticesBase +var_gMatrixPtr: + .long _gMatrixPtr +var_gLightAmbient: + .long _gLightAmbient +var_divTable: + .long _divTable +var_viewportRel: + .long _viewportRel + +#include "faceAddMeshQuads.i" +#include "faceAddMeshTriangles.i" + +.align 2 +var_gVertices_fam: + .long _gVertices +var_gFacesBase_fam: + .long _gFacesBase +var_gVerticesBase_fam: + .long _gVerticesBase +const_FACE_CLIPPED_fam: + .long FACE_CLIPPED +const_FACE_TRIANGLE_fam: + .long FACE_TRIANGLE +var_gOT_fam: + .long _gOT + +#include "faceAddRoomQuads.i" +#include "faceAddRoomTriangles.i" + +.align 2 +var_gVertices_far: + .long _gVertices +var_gFacesBase_far: + .long _gFacesBase +var_gVerticesBase_far: + .long _gVerticesBase +const_FACE_CLIPPED_far: + .long FACE_CLIPPED +const_FACE_GOURAUD_far: + .long FACE_GOURAUD +const_FACE_TRIANGLE_far: + .long FACE_TRIANGLE +var_gOT_far: + .long _gOT + +_block_prepare_end: diff --git a/src/platform/32x/asm/block_render.s b/src/platform/32x/asm/block_render.s new file mode 100644 index 00000000..e8d5c09e --- /dev/null +++ b/src/platform/32x/asm/block_render.s @@ -0,0 +1,36 @@ +#include "common.i" +.data + +.global _block_render_start +.global _block_render_end + +.align 4 +_block_render_start: + +#include "rasterize.i" +//#include "rasterize_dummy.i" +#include "rasterizeS.i" +#include "rasterizeF.i" + +.align 2 +var_LMAP_ADDR_fs: + .long _gLightmap_base +var_divTable_fs: + .long _divTable +var_frameWidth_fs: + .word FRAME_WIDTH + +#include "rasterizeFT.i" +#include "rasterizeGT.i" + +.align 2 +var_LMAP_ADDR: + .long _gLightmap_base +var_divTable: + .long _divTable +var_mask: + .word 0xFF00 +var_frameWidth: + .word FRAME_WIDTH + +_block_render_end: diff --git a/src/platform/32x/asm/common.i b/src/platform/32x/asm/common.i new file mode 100644 index 00000000..e9b85b5e --- /dev/null +++ b/src/platform/32x/asm/common.i @@ -0,0 +1,153 @@ +#ifndef H_COMMON_ASM +#define H_COMMON_ASM + +#define SEG_MATH .data +#define SEG_PHYSICS .data + +//#define ON_CHIP_RENDER + +// Matrix: +// int16 e00, e01, e02 // rotation +// int16 e10, e11, e12 // rotation +// int16 e20, e21, e22 // rotation +// int16 e03, e13, e23 // translation + +// row[0] rotation +#define M00 0 +#define M01 2 +#define M02 4 +// row[1] rotation +#define M10 6 +#define M11 8 +#define M12 10 +// row[2] rotation +#define M20 12 +#define M21 14 +#define M22 16 +// row[3] translation +#define M03 18 +#define M13 20 +#define M23 22 + +#define MATRIX_SIZEOF 24 + +#define FIXED_SHIFT 14 + +#define FACE_TYPE_F 1 +#define FACE_TYPE_SHIFT 14 +#define FACE_CLIPPED (1 << 30) +#define FACE_TRIANGLE (1 << 31) +#define FACE_GOURAUD (2 << FACE_TYPE_SHIFT) + +#define VERTEX_X 0 +#define VERTEX_Y 2 +#define VERTEX_Z 4 +#define VERTEX_G 6 +#define VERTEX_CLIP 7 +#define VERTEX_T 8 +#define VERTEX_PREV 12 +#define VERTEX_NEXT 13 +#define VERTEX_PADDING 14 + +#define VERTEX_SIZEOF_SHIFT 4 +#define VERTEX_SIZEOF (1 << VERTEX_SIZEOF_SHIFT) + +#define FACE_SIZEOF 16 + +#define VIEW_MIN 64 +#define VIEW_MAX (10 << 10) +#define FOG_SHIFT 4 +#define FOG_MIN (VIEW_MAX - 2048) + +#define OT_SHIFT 4 + +#define CLIP_FRAME (1 << 0) +#define CLIP_LEFT (1 << 1) +#define CLIP_RIGHT (1 << 2) +#define CLIP_TOP (1 << 3) +#define CLIP_BOTTOM (1 << 4) +#define CLIP_PLANE (1 << 5) +#define CLIP_DISCARD (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM + CLIP_PLANE) + +#define VP_MINX 0 +#define VP_MINY 4 +#define VP_MAXX 8 +#define VP_MAXY 12 + +#define FRAME_WIDTH 320 +#define FRAME_HEIGHT 224 + +.macro align_fetch + .p2alignw 2, 0x0009 +.endm + +.macro shlr14 x + shll2 \x + shlr16 \x + //exts.w x, x // skip this because of mov.w +.endm + +// int32 >> 12 +// 1. shar x 12 => 12 op +// 2. (int32(int16(x >> 16)) << 4) | (x >> 12) => 8 op (require an extra register) +.macro shar12 x, t + swap.w \x, \t + exts.w \t, \t + shll2 \t + shll2 \t + shlr8 \x + shlr2 \x + shlr2 \x + or \t, \x +.endm + +// out = uv * f +// uv and out regs must be different +// destructive for uv reg +.macro scaleUV uv, out, f + muls.w \uv, \f + shlr16 \uv + sts MACL, \out // v = int16(uv) * f (16-bit shift) + muls.w \uv, \f + sts MACL, \uv // u = int16(uv >> 16) * f (16-bit shift) + shlr16 \uv + xtrct \uv, \out // out = uint16(v >> 16) | (u & 0xFFFF0000) +.endm + +// UUuuVVvv -> 0000VVUU +.macro getUV uv, index + swap.b \uv, \index // UUuuvvVV + swap.w \index, \index // vvVVUUuu + shll8 \index // VVUUuu00 + shlr16 \index // 0000VVUU +.endm + +// index (r0) = gLightmap[index] +// in index 0..255 +// in lightmap one of 32 gLightmap slices +.macro lit lightmap, index + mov.b @(\index, \lightmap), \index +.endm + +// (vy1 - vy0) * (vx0 - vx2) <= (vx1 - vx0) * (vy0 - vy2) +.macro ccw vp0, vp1, vp2, vx0, vy0, vx1, vy1, vx2, vy2 + mov.w @\vp0+, \vx0 + mov.w @\vp0+, \vy0 + mov.w @\vp1+, \vx1 + mov.w @\vp1+, \vy1 + sub \vx0, \vx1 // vx1 -= vx0 + sub \vy0, \vy1 // vy1 -= vy0 + mov.w @\vp2+, \vx2 + sub \vx2, \vx0 // vx0 -= vx2 + mov.w @\vp2+, \vy2 + sub \vy2, \vy0 // vy0 -= vy2 + + muls.w \vy1, \vx0 + sts MACL, \vx0 // vx0 *= vy1 + muls.w \vx1, \vy0 + sts MACL, \vy0 // vy0 *= vx1 + + cmp/ge \vx0, \vy0 // T = (vy0 >= vx0) +.endm + +#endif // H_COMMON_ASM diff --git a/src/platform/32x/asm/data.s b/src/platform/32x/asm/data.s new file mode 100644 index 00000000..dcd12eef --- /dev/null +++ b/src/platform/32x/asm/data.s @@ -0,0 +1,17 @@ + .text +/* + .global _TITLE_PKD + .align 4 +_TITLE_PKD: + .long TITLE +TITLE: + .incbin "data/TITLE.PKD" +*/ + .global _LEVEL1_PKD + .align 4 +_LEVEL1_PKD: + .long LEVEL1 +LEVEL1: + .incbin "data/LEVEL1.PKD" + + .align 4 diff --git a/src/platform/32x/asm/faceAddMeshQuads.i b/src/platform/32x/asm/faceAddMeshQuads.i new file mode 100644 index 00000000..ca67756f --- /dev/null +++ b/src/platform/32x/asm/faceAddMeshQuads.i @@ -0,0 +1,196 @@ +#define tmp r0 +#define face r1 +#define vp r2 +#define flags r3 +#define polys r4 // arg +#define count r5 // arg +#define vp0 r6 +#define vp1 r7 +#define vp2 r8 +#define vp3 r9 +#define vg0 r10 +#define vg1 r11 +#define vg2 r12 +#define vg3 r13 +#define vertices r14 + +#define vx0 vg0 +#define vy0 vg1 +#define vx1 vg2 +#define vy1 vg3 +#define vx2 tmp +#define vy2 tmp + +#define vz0 vg0 +#define vz1 vg1 +#define vz2 vg2 +#define vz3 vg3 + +#define depth tmp +#define next vg1 +#define ot vg0 + +.align 4 +.global _faceAddMeshQuads_asm +_faceAddMeshQuads_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_gVertices_fam, vertices + add #VERTEX_Z, vertices + + mov.l var_gVerticesBase_fam, vp + mov.l @vp, vp + + mov.l var_gFacesBase_fam, face + mov.l @face, face + nop + +.loop_famq: + // read flags and indices + mov.w @polys+, flags + mov.w @polys+, vp0 + mov.w @polys+, vp2 + + extu.w flags, flags // TODO packer free high bit + + extu.b vp0, vp1 + shlr8 vp0 + extu.b vp0, vp0 + + extu.b vp2, vp3 + shlr8 vp2 + extu.b vp2, vp2 + + // p = gVerticesBase + index * VERTEX_SIZEOF + shll2 vp0 + shll2 vp1 + shll2 vp2 + shll2 vp3 + shll vp0 + shll vp1 + shll vp2 + shll vp3 + + // get vertex address + add vp, vp0 + add vp, vp1 + add vp, vp2 + add vp, vp3 + + // check_backface + ccw vp0, vp1, vp2, vx0, vy0, vx1, vy1, vx2, vy2 + bt/s .skip_famq + add #VERTEX_Z, vp3 // [delay slot] ccw shifts p[0..2] address to VERTEX_Z, shift p3 too + + // fetch clip masks + mov #(VERTEX_CLIP - 4), tmp + mov.b @(tmp, vp0), vg0 + mov.b @(tmp, vp1), vg1 + mov.b @(tmp, vp2), vg2 + mov.b @(tmp, vp3), vg3 + + // check clipping + mov vg0, tmp + and vg1, tmp + and vg2, tmp + and vg3, tmp + tst #CLIP_DISCARD, tmp + bf/s .skip_famq + + // mark if should be clipped by frame + mov vg0, tmp // [delay slot] + or vg1, tmp + or vg2, tmp + or vg3, tmp + tst #CLIP_FRAME, tmp + bt/s .avg_z4_famq + mov.l const_FACE_CLIPPED_fam, tmp // [delay slot] + or tmp, flags + +.avg_z4_famq: + mov.w @vp0, depth + mov.w @vp1, vz1 + mov.w @vp2, vz2 + mov.w @vp3, vz3 + add vz1, depth + add vz2, depth + add vz3, depth + shlr2 depth // depth /= 4 + + mov.l var_gOT_fam, ot + + .face_add_famq: + // offset = (p - vertices) + sub vertices, vp0 + sub vertices, vp1 + sub vertices, vp2 + sub vertices, vp3 + + shll2 depth + mov.l @(depth, ot), next + mov.l face, @(depth, ot) + + shll16 vp3 + xtrct vp2, vp3 + shll16 vp1 + xtrct vp0, vp1 + + mov.l flags, @(0, face) + mov.l next, @(4, face) + mov.l vp1, @(8, face) + mov.l vp3, @(12, face) + add #FACE_SIZEOF, face + nop + +.skip_famq: + dt count + bf .loop_famq + + mov.l var_gFacesBase_fam, tmp + mov.l face, @tmp + + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef face +#undef vp +#undef flags +#undef polys +#undef count +#undef vp0 +#undef vp1 +#undef vp2 +#undef vp3 +#undef vg0 +#undef vg1 +#undef vg2 +#undef vg3 +#undef vertices +#undef vx0 +#undef vy0 +#undef vx1 +#undef vy1 +#undef vx2 +#undef vy2 +#undef vz0 +#undef vz1 +#undef vz2 +#undef vz3 +#undef depth +#undef next +#undef ot diff --git a/src/platform/32x/asm/faceAddMeshTriangles.i b/src/platform/32x/asm/faceAddMeshTriangles.i new file mode 100644 index 00000000..fe4d8690 --- /dev/null +++ b/src/platform/32x/asm/faceAddMeshTriangles.i @@ -0,0 +1,182 @@ +#define tmp r0 +#define face r1 +#define vp r2 +#define flags r3 +#define polys r4 // arg +#define count r5 // arg +#define vp0 r6 +#define vp1 r7 +#define vp2 r8 +#define ot r9 +#define vg0 r10 +#define vg1 r11 +#define vg2 r12 +#define vg3 r13 +#define vertices r14 + +#define vx0 vg0 +#define vy0 vg1 +#define vx1 vg2 +#define vy1 vg3 +#define vx2 tmp +#define vy2 tmp + +#define vz0 vg0 +#define vz1 vg1 +#define vz2 vg2 + +#define depth tmp +#define next vg1 + +.align 4 +.global _faceAddMeshTriangles_asm +_faceAddMeshTriangles_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_gVertices_fam, vertices + add #VERTEX_Z, vertices + + mov.l var_gVerticesBase_fam, vp + mov.l @vp, vp + + mov.l var_gFacesBase_fam, face + mov.l @face, face + + mov.l var_gOT_fam, ot + +.loop_famt: + // read flags and indices + mov.w @polys+, flags + mov.w @polys+, vp0 + mov.w @polys+, vp2 + + extu.w flags, flags // TODO packer free high bit + + extu.b vp0, vp1 + shlr8 vp0 + extu.b vp0, vp0 + + shlr8 vp2 + extu.b vp2, vp2 + + // p = gVerticesBase + index * VERTEX_SIZEOF + shll2 vp0 + shll2 vp1 + shll2 vp2 + shll vp0 + shll vp1 + shll vp2 + + // get vertex address + add vp, vp0 + add vp, vp1 + add vp, vp2 + + // check_backface + ccw vp0, vp1, vp2, vx0, vy0, vx1, vy1, vx2, vy2 + bt/s .skip_famt + + // fetch clip masks + mov #(VERTEX_CLIP - 4), tmp // [delay slot] + mov.b @(tmp, vp0), vg0 + mov.b @(tmp, vp1), vg1 + mov.b @(tmp, vp2), vg2 + + mov vg0, tmp + and vg1, tmp + and vg2, tmp + tst #CLIP_DISCARD, tmp + bf/s .skip_famt + + mov.l const_FACE_TRIANGLE_fam, tmp // [delay slot] + or tmp, flags + + // mark if should be clipped by frame + mov vg0, tmp + or vg1, tmp + or vg2, tmp + tst #CLIP_FRAME, tmp + bt/s .avg_z3_famt + mov.l const_FACE_CLIPPED_fam, tmp // [delay slot] + or tmp, flags + +.avg_z3_famt: + mov.w @vp0, depth + mov.w @vp1, vz1 + mov.w @vp2, vz2 + add vz1, depth + add vz2, depth + add vz2, depth // approx. + shlr2 depth // depth /= 4 + +.face_add_famt: + // offset = (p - vertices) + sub vertices, vp0 + sub vertices, vp1 + sub vertices, vp2 + + shll2 depth + mov.l @(depth, ot), next + mov.l face, @(depth, ot) + + shll16 vp2 + shll16 vp1 + xtrct vp0, vp1 + + mov.l flags, @(0, face) + mov.l next, @(4, face) + mov.l vp1, @(8, face) + mov.l vp2, @(12, face) + add #FACE_SIZEOF, face + nop + +.skip_famt: + dt count + bf .loop_famt + + mov.l var_gFacesBase_fam, tmp + mov.l face, @tmp + + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef face +#undef vp +#undef flags +#undef polys +#undef count +#undef vp0 +#undef vp1 +#undef vp2 +#undef ot +#undef vg0 +#undef vg1 +#undef vg2 +#undef vg3 +#undef vertices +#undef vx0 +#undef vy0 +#undef vx1 +#undef vy1 +#undef vx2 +#undef vy2 +#undef vz0 +#undef vz1 +#undef vz2 +#undef depth +#undef next diff --git a/src/platform/32x/asm/faceAddRoomQuads.i b/src/platform/32x/asm/faceAddRoomQuads.i new file mode 100644 index 00000000..5897a7a1 --- /dev/null +++ b/src/platform/32x/asm/faceAddRoomQuads.i @@ -0,0 +1,212 @@ +#define tmp r0 +#define face r1 +#define vp r2 +#define flags r3 +#define polys r4 // arg +#define count r5 // arg +#define vp0 r6 +#define vp1 r7 +#define vp2 r8 +#define vp3 r9 +#define vg0 r10 +#define vg1 r11 +#define vg2 r12 +#define vg3 r13 +#define vertices r14 + +#define vx0 vg0 +#define vy0 vg1 +#define vx1 vg2 +#define vy1 vg3 +#define vx2 tmp +#define vy2 tmp + +#define vz0 vg0 +#define vz1 vg1 +#define vz2 vg2 +#define vz3 vg3 + +#define depth tmp +#define next vg1 +#define ot vg0 + +.align 4 +.global _faceAddRoomQuads_asm +_faceAddRoomQuads_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_gVertices_far, vertices + add #VERTEX_Z, vertices + + mov.l var_gVerticesBase_far, vp + mov.l @vp, vp + + mov.l var_gFacesBase_far, face + mov.l @face, face + nop + +.loop_farq: + // read flags and indices + mov.l @polys+, flags + mov.l @polys+, vp0 + + exts.b vp0, vp3 + shlr8 vp0 + exts.b vp0, vp2 + shlr8 vp0 + exts.b vp0, vp1 + shlr8 vp0 + exts.b vp0, vp0 + + // index *= 8 (VERTEX_SIZEOF) + shll2 vp0 + shll2 vp1 + shll2 vp2 + shll2 vp3 + shll vp0 + shll vp1 + shll vp2 + shll vp3 + + // get vertex address + add vp, vp0 + add vp0, vp1 + add vp1, vp2 + add vp2, vp3 + mov vp3, vp + + // fetch ((g << 8) | clip) + mov #VERTEX_G, tmp + mov.w @(tmp, vp0), vg0 + mov.w @(tmp, vp1), vg1 + mov.w @(tmp, vp2), vg2 + mov.w @(tmp, vp3), vg3 + // g on high-byte is 5 bits long, no need for extu.w + + // check_clipping + mov vg0, tmp + and vg1, tmp + and vg2, tmp + and vg3, tmp + tst #CLIP_DISCARD, tmp + bf/s .skip_farq + + // mark if should be clipped by frame + mov vg0, tmp // [delay slot] + or vg1, tmp + or vg2, tmp + or vg3, tmp + tst #CLIP_FRAME, tmp + bt/s 1f + mov.l const_FACE_CLIPPED_far, tmp // [delay slot] + or tmp, flags + +1: // compare VERTEX_G for gouraud rasterization + xor vg0, vg1 + xor vg0, vg2 + xor vg0, vg3 + or vg2, vg1 + or vg3, vg1 + shlr8 vg1 // shift down for g only + tst vg1, vg1 + bt/s 2f + mov.l const_FACE_GOURAUD_far, tmp // [delay slot] + add tmp, flags + +2: // check_backface + ccw vp0, vp1, vp2, vx0, vy0, vx1, vy1, vx2, vy2 + bt/s .skip_farq + add #VERTEX_Z, vp3 // [delay slot] ccw shifts p[0..2] address to VERTEX_Z, shift p3 too + + // max_z4 + mov.w @vp0, depth + mov.w @vp1, vz1 + // check_z1 + cmp/gt depth, vz1 + bf/s 3f + mov.w @vp2, vz2 // [delay slot] + mov vz1, depth // if (z1 > z0) z0 = z1 +3: // check_z2 + cmp/gt depth, vz2 + bf/s 4f + mov.w @vp3, vz3 // [delay slot] + mov vz2, depth // if (z2 > z0) z0 = z2 +4: // check_z3 + cmp/gt depth, vz3 + bf/s .face_add_farq + sub vertices, vp0 // [delay slot] get the first offset + mov vz3, depth // if (z3 > z0) z0 = z3 + +.face_add_farq: + mov.l var_gOT_far, ot + // offset = (p - vertices) + sub vertices, vp1 + sub vertices, vp2 + sub vertices, vp3 + + shll2 depth + mov.l @(depth, ot), next + mov.l face, @(depth, ot) + + shll16 vp3 + xtrct vp2, vp3 + shll16 vp1 + xtrct vp0, vp1 + + mov.l flags, @(0, face) + mov.l next, @(4, face) + mov.l vp1, @(8, face) + mov.l vp3, @(12, face) + add #FACE_SIZEOF, face +.skip_farq: + dt count + bf .loop_farq + + mov.l var_gFacesBase_far, tmp + mov.l face, @tmp + + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef face +#undef vp +#undef flags +#undef polys +#undef count +#undef vp0 +#undef vp1 +#undef vp2 +#undef vp3 +#undef vg0 +#undef vg1 +#undef vg2 +#undef vg3 +#undef vertices +#undef vx0 +#undef vy0 +#undef vx1 +#undef vy1 +#undef vx2 +#undef vy2 +#undef vz0 +#undef vz1 +#undef vz2 +#undef vz3 +#undef depth +#undef next +#undef ot \ No newline at end of file diff --git a/src/platform/32x/asm/faceAddRoomTriangles.i b/src/platform/32x/asm/faceAddRoomTriangles.i new file mode 100644 index 00000000..6ad484bf --- /dev/null +++ b/src/platform/32x/asm/faceAddRoomTriangles.i @@ -0,0 +1,185 @@ +#define tmp r0 +#define face r1 +#define vp r2 +#define flags r3 +#define polys r4 // arg +#define count r5 // arg +#define vp0 r6 +#define vp1 r7 +#define vp2 r8 +#define ot r9 +#define vg0 r10 +#define vg1 r11 +#define vg2 r12 +#define vg3 r13 +#define vertices r14 + +#define vx0 vg0 +#define vy0 vg1 +#define vx1 vg2 +#define vy1 vg3 +#define vx2 tmp +#define vy2 tmp + +#define vz0 vg0 +#define vz1 vg1 +#define vz2 vg2 + +#define depth tmp +#define next vg1 + +.align 4 +.global _faceAddRoomTriangles_asm +_faceAddRoomTriangles_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_gVertices_far, vertices + add #VERTEX_Z, vertices + + mov.l var_gVerticesBase_far, vp + mov.l @vp, vp + + mov.l var_gFacesBase_far, face + mov.l @face, face + + mov.l var_gOT_far, ot + +.loop_fart: + // read flags and indices + mov.l @polys+, flags + mov.l @polys+, vp1 + + extu.w flags, vp0 + shlr16 flags + + extu.w vp1, vp2 + shlr16 vp1 + + // vp[0..2] alreay multiplied by VERTEX_SIZEOF + + // get vertex address + add vp, vp0 + add vp, vp1 + add vp, vp2 + + // fetch ((g << 8) | clip) + mov #VERTEX_G, tmp + mov.w @(tmp, vp0), vg0 + mov.w @(tmp, vp1), vg1 + mov.w @(tmp, vp2), vg2 + // g on high-byte is 5 bits long, no need for extu.w + + // check_clipping + mov vg0, tmp + and vg1, tmp + and vg2, tmp + tst #CLIP_DISCARD, tmp + bf/s .skip_fart + + // mark if should be clipped by frame + mov vg0, tmp // [delay slot] + or vg1, tmp + or vg2, tmp + tst #CLIP_FRAME, tmp + bt/s 1f + mov.l const_FACE_CLIPPED_far, tmp // [delay slot] mov #1, tmp; rotr x2 + or tmp, flags + +1: // compare VERTEX_G for gouraud rasterization + xor vg0, vg1 + xor vg0, vg2 + or vg2, vg1 + shlr8 vg1 // shift down for g only + tst vg1, vg1 + bt/s 2f + mov.l const_FACE_GOURAUD_far, tmp // [delay slot] mov #128, tmp; shll8 + add tmp, flags + +2: // check_backface + ccw vp0, vp1, vp2, vx0, vy0, vx1, vy1, vx2, vy2 + bt/s .skip_fart + mov.l const_FACE_TRIANGLE_far, tmp // [delay slot] mov #1, tmp; rotr + or tmp, flags + + // max_z3 + mov.w @vp0, depth // depth = vz0 + mov.w @vp1, vz1 + // check_z1 + cmp/gt depth, vz1 + bf/s 3f + mov.w @vp2, vz2 // [delay slot] + mov vz1, depth // if (z1 > depth) depth = z1 +3: // check_z2 + cmp/gt depth, vz2 + bf/s .face_add_fart // TODO use delay slot but not for OT! ) + sub vertices, vp0 // [delay slot] get the first offset + mov vz2, depth // if (z2 > depth) depth = z2 + +.face_add_fart: + // offset = (p - vertices) + sub vertices, vp1 + sub vertices, vp2 + + shll2 depth + mov.l @(depth, ot), next + mov.l face, @(depth, ot) + + shll16 vp2 + shll16 vp1 + xtrct vp0, vp1 + + mov.l flags, @(0, face) + mov.l next, @(4, face) + mov.l vp1, @(8, face) + mov.l vp2, @(12, face) + add #FACE_SIZEOF, face +.skip_fart: + dt count + bf .loop_fart + + mov.l var_gFacesBase_far, tmp + mov.l face, @tmp + + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef face +#undef vp +#undef flags +#undef polys +#undef count +#undef vp0 +#undef vp1 +#undef vp2 +#undef ot +#undef vg0 +#undef vg1 +#undef vg2 +#undef vg3 +#undef vertices +#undef vx0 +#undef vy0 +#undef vx1 +#undef vy1 +#undef vx2 +#undef vy2 +#undef vz0 +#undef vz1 +#undef vz2 +#undef depth +#undef next \ No newline at end of file diff --git a/src/platform/32x/asm/getSector.s b/src/platform/32x/asm/getSector.s new file mode 100644 index 00000000..309ae1e9 --- /dev/null +++ b/src/platform/32x/asm/getSector.s @@ -0,0 +1,63 @@ +#include "common.i" +SEG_PHYSICS + +#define sectors r0 +#define info r1 +#define roomX r2 +#define roomZ r3 +#define this r4 // arg +#define x r5 // arg +#define z r6 // arg +#define mask r7 +#define sectorsX roomX +#define sectorsZ roomZ +#define offset sectorsZ + +.text +.align 4 +.global __ZNK4Room9getSectorEii +__ZNK4Room9getSectorEii: + mov.l @(4, this), info + mov.w @info+, roomX + mov.w @info+, roomZ + + add #16, info // offset to [sectorsX, sectorsZ] + +.getX: // x = MIN(MAX(x - (roomX << 8), 0) >> 10, sectorsX - 1) + shll8 roomX + sub roomX, x + mov.b @info+, sectorsX + cmp/pz x + subc mask, mask + and mask, x + shlr8 x + shlr2 x + cmp/ge sectorsX, x + bf/s .getZ + add #-1, sectorsX + mov sectorsX, x + +.getZ: // z = MIN(MAX(z - (roomZ << 8), 0) >> 10, sectorsZ - 1) + shll8 roomZ + sub roomZ, z + mov.b @info+, sectorsZ + cmp/pz z + subc mask, mask + and mask, z + shlr8 z + shlr2 z + cmp/ge sectorsZ, z + bf/s .getPtr + mov.l @(8, this), sectors + mov sectorsZ, z + add #-1, z + +.getPtr: + // offset = sectors + ((x * sectorsZ + z) << 3) + mulu.w sectorsZ, x + sts MACL, x + add x, z + shll2 z + shll z + rts + add z, sectors diff --git a/src/platform/32x/asm/matrixLerp.s b/src/platform/32x/asm/matrixLerp.s new file mode 100644 index 00000000..37b836b1 --- /dev/null +++ b/src/platform/32x/asm/matrixLerp.s @@ -0,0 +1,162 @@ +#include "common.i" +SEG_MATH + +#define m0 r0 +#define m1 r1 +#define m2 r2 +#define n0 r3 +#define n r4 // arg +#define pmul r5 // arg +#define pdiv r6 // arg +#define n1 pdiv +#define n2 r7 +#define m r8 +#define tmp m0 +#define divLUT m1 + +.macro load + mov.w @m+, m0 + mov.w @m+, m1 + mov.w @m+, m2 + mov.w @n+, n0 + mov.w @n+, n1 + mov.w @n+, n2 +.endm + +.macro store + mov.w m2, @-m + mov.w m1, @-m + mov.w m0, @-m +.endm + +.macro next + add #6, m +.endm + +.macro _1_2 // a = (a + b) / 2 + load + add n0, m0 + add n1, m1 + add n2, m2 + shar m0 + shar m1 + shar m2 + store +.endm + +.macro _1_4 // a = a + (b - a) / 4 + load + sub m0, n0 + sub m1, n1 + sub m2, n2 + shar n0 + shar n1 + shar n2 + shar n0 + shar n1 + shar n2 + add n0, m0 + add n1, m1 + add n2, m2 + store +.endm + +.macro _3_4 // a = b - (b - a) / 4 = b + (a - b) / 4 + load + sub n0, m0 + sub n1, m1 + sub n2, m2 + shar m0 + shar m1 + shar m2 + shar m0 + shar m1 + shar m2 + add n0, m0 + add n1, m1 + add n2, m2 + store +.endm + +.macro masr_8 x + muls.w \x, pmul + sts MACL, \x + shlr8 \x + exts.w \x, \x +.endm + +.macro _X_Y // a = a + (b - a) * mul / div + load + sub m0, n0 + sub m1, n1 + sub m2, n2 + + masr_8 n0 + masr_8 n1 + masr_8 n2 + + add n0, m0 + add n1, m1 + add n2, m2 + store +.endm + +.macro lerp func + \func // e00, e01, e02 + next + \func // e10, e11, e12 + next + \func // e20, e21, e22 +.endm + + +.align 4 +.global _matrixLerp_asm +_matrixLerp_asm: + mov.l r8, @-sp + mov.l var_gMatrixPtr, m + mov.l @m, m + mov pdiv, tmp +.check_2: + cmp/eq #2, tmp + bf/s .check_XY + cmp/eq #4, tmp +.m1_d2: + lerp _1_2 + rts + mov.l @sp+, r8 +.check_XY: + bt .check_4 + bra .mX_dY + nop +.check_4: + mov pmul, tmp + cmp/eq #2, tmp + bt .m1_d2 // 2/4 = 1/2 + cmp/eq #1, tmp + bt .m1_d4 +.m3_d4: + lerp _3_4 + rts + mov.l @sp+, r8 +.m1_d4: + lerp _1_4 + rts + mov.l @sp+, r8 +.mX_dY: + mov.l var_divTable, divLUT + shll tmp + mov.w @(tmp, divLUT), tmp // tmp = pdiv + mulu.w tmp, pmul + sts MACL, pmul + shlr8 pmul + + lerp _X_Y + rts + mov.l @sp+, r8 + nop + +var_gMatrixPtr: + .long _gMatrixPtr // skip e03 +var_divTable: + .long _divTable diff --git a/src/platform/32x/asm/matrixPush.s b/src/platform/32x/asm/matrixPush.s new file mode 100644 index 00000000..22dc514b --- /dev/null +++ b/src/platform/32x/asm/matrixPush.s @@ -0,0 +1,37 @@ +#include "common.i" +SEG_MATH + +#define ptr r0 +#define m r1 +#define e0 r2 +#define e1 r3 +#define e2 r4 +#define e3 r5 +#define e4 r6 +#define e5 r7 + +.align 4 +.global _matrixPush_asm +_matrixPush_asm: + mov.l var_gMatrixPtr, ptr + mov.l @ptr, m + + mov.l @m+, e0 + mov.l @m+, e1 + mov.l @m+, e2 + mov.l @m+, e3 + mov.l @m+, e4 + mov.l @m+, e5 + + mov.l e0, @( 0, m) + mov.l e1, @( 4, m) + mov.l e2, @( 8, m) + mov.l e3, @(12, m) + mov.l e4, @(16, m) + mov.l e5, @(20, m) + + rts + mov.l m, @ptr + +var_gMatrixPtr: + .long _gMatrixPtr diff --git a/src/platform/32x/asm/matrixRotate.s b/src/platform/32x/asm/matrixRotate.s new file mode 100644 index 00000000..7f4ebf2a --- /dev/null +++ b/src/platform/32x/asm/matrixRotate.s @@ -0,0 +1,265 @@ +#include "common.i" +SEG_MATH + +// r0 is required +.macro sincos angle, sin, cos + extu.w \angle, r0 + shlr2 r0 + shlr2 r0 + shll2 r0 + mov.l var_gSinCosTable, \cos + mov.l @(r0, \cos), \cos + swap.w \cos, \sin + // we don't need to exts.w's of sin & cos because of muls.w +.endm + +.macro rotxy x, y, sin, cos, tx, ty + muls.w \x, \sin + sts MACL, \tx + muls.w \y, \sin + sts MACL, \ty + muls.w \x, \cos + sts MACL, \x + muls.w \y, \cos + sts MACL, \y + sub \ty, \x + add \tx, \y + shlr14 \x // int(x) >> (FIXED_SHIFT = 14) + shlr14 \y // int(y) >> (FIXED_SHIFT = 14) +.endm + + +#define angleX r4 // arg +#define angleY r5 // arg +#define angleZ r6 // arg +#define tmpX r7 // unused in subroutines +#define tmpZ r8 +#define arg angleX + +.align 4 +.global _matrixRotateYXZ_asm +_matrixRotateYXZ_asm: + mov.l r8, @-sp + sts.l pr, @-sp + mov angleX, tmpX + mov angleZ, tmpZ +.rotY: + tst angleY, angleY + bt .rotX + bsr _matrixRotateY_asm + mov angleY, arg +.rotX: + tst tmpX, tmpX + bt .rotZ + bsr _matrixRotateX_asm + mov tmpX, arg +.rotZ: + tst tmpZ, tmpZ + bt .done + bsr _matrixRotateZ_asm + mov tmpZ, arg +.done: + lds.l @sp+, pr + rts + mov.l @sp+, r8 + +#define m r0 +#define e1 r1 +#define sin r2 +#define cos r3 +#define angle r4 // arg +#define tx r5 +#define ty r6 +#define e0 angle + +.align 2 +.global _matrixRotateX_asm +_matrixRotateX_asm: + sincos angle, sin, cos + + mov.l var_gMatrixPtr, m + mov.l @m, m + add #M01, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + rts + mov.w e0, @-m + +.align 2 +.global _matrixRotateY_asm +_matrixRotateY_asm: + sincos angle, sin, cos + + mov.l var_gMatrixPtr, m + mov.l @m, m + + mov.w @m+, e0 + add #2, m + mov.w @m+, e1 + rotxy e0, e1, sin, cos, tx, ty + mov.w e1, @-m + add #-2, m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + add #2, m + mov.w @m+, e1 + rotxy e0, e1, sin, cos, tx, ty + mov.w e1, @-m + add #-2, m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + add #2, m + mov.w @m+, e1 + rotxy e0, e1, sin, cos, tx, ty + mov.w e1, @-m + add #-2, m + rts + mov.w e0, @-m + +.align 2 +.global _matrixRotateZ_asm +_matrixRotateZ_asm: + sincos angle, sin, cos + + mov.l var_gMatrixPtr, m + mov.l @m, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + mov.w e0, @-m + + add #6, m + + mov.w @m+, e0 + mov.w @m+, e1 + rotxy e1, e0, sin, cos, tx, ty + mov.w e1, @-m + rts + mov.w e0, @-m + +.align 2 +var_gMatrixPtr: + .long _gMatrixPtr +var_gSinCosTable: + .long _gSinCosTable + +#define q r0 +#define n r1 +#define e00 r2 +#define e02 r3 +#define qarg r4 // arg +#define e10 r5 +#define e12 r6 +#define e20 r7 +#define e22 qarg + +.align 4 +.global _matrixRotateYQ_asm +_matrixRotateYQ_asm: + mov qarg, q + cmp/eq #2, q + bt/s .q_2 + cmp/eq #1, q + + mov.l var_gMatrixPtr_YQ, n + mov.l @n, n + + mov.w @n+, e00 + add #2, n + mov.w @n+, e02 + + mov.w @n+, e10 + add #2, n + mov.w @n+, e12 + + mov.w @n+, e20 + add #2, n + bt/s .q_1 + mov.w @n+, e22 + + tst q, q + bt/s .q_0 + neg e22, e22 // for q_0 and q_3 +.q_3: + neg e02, e02 + neg e12, e12 + mov.w e20, @-n + add #-2, n + mov.w e22, @-n + mov.w e10, @-n + add #-2, n + mov.w e12, @-n + mov.w e00, @-n + add #-2, n + mov.w e02, @-n +.q_2: + rts +.q_0: + neg e00, e00 + neg e02, e02 + neg e10, e10 + neg e12, e12 + neg e20, e20 + mov.w e22, @-n + add #-2, n + mov.w e20, @-n + mov.w e12, @-n + add #-2, n + mov.w e10, @-n + mov.w e02, @-n + add #-2, n + rts + mov.w e00, @-n +.q_1: + neg e00, e00 + neg e10, e10 + neg e20, e20 + mov.w e20, @-n + add #-2, n + mov.w e22, @-n + mov.w e10, @-n + add #-2, n + mov.w e12, @-n + mov.w e00, @-n + add #-2, n + rts + mov.w e02, @-n + +.align 2 +var_gMatrixPtr_YQ: + .long _gMatrixPtr \ No newline at end of file diff --git a/src/platform/32x/asm/matrixSetBasis.s b/src/platform/32x/asm/matrixSetBasis.s new file mode 100644 index 00000000..cb19b5d5 --- /dev/null +++ b/src/platform/32x/asm/matrixSetBasis.s @@ -0,0 +1,26 @@ +#include "common.i" +SEG_MATH + +#define e8 r0 // [ e22 ] +#define e01 r1 // [ e00, e01 ] +#define e23 r2 // [ e02, e10 ] +#define e45 r3 // [ e11, e12 ] +#define dst r4 // arg +#define src r5 // arg +#define e67 r6 // [ e20, e21 ] + +.align 4 +.global _matrixSetBasis_asm +_matrixSetBasis_asm: + mov.l @(M00, src), e01 + mov.l @(M02, src), e23 + mov.l @(M11, src), e45 + mov.l @(M20, src), e67 + mov.w @(M22, src), e8 + + mov.l e01, @(M00, dst) + mov.l e23, @(M02, dst) + mov.l e45, @(M11, dst) + mov.l e67, @(M20, dst) + rts + mov.w e8, @(M22, dst) diff --git a/src/platform/32x/asm/matrixSetIdentity.s b/src/platform/32x/asm/matrixSetIdentity.s new file mode 100644 index 00000000..81c036bc --- /dev/null +++ b/src/platform/32x/asm/matrixSetIdentity.s @@ -0,0 +1,38 @@ +#include "common.i" +SEG_MATH + +#define m r0 +#define ZZ r1 +#define NZ r2 + +// word [ N Z Z ] // rot +// [ Z N Z ] // rot +// [ Z Z N ] // rot +// [ Z Z Z ] // trans +// long [ NZ ZZ NZ ZZ NZ ZZ ] + +.align 4 +.global _matrixSetIdentity_asm +_matrixSetIdentity_asm: + mov.l var_gMatrixPtr, m + mov.l @m, m + + // ZZ = 0x 0000 0000 + mov #0, ZZ + + // NZ = 0x 4000 0000 + mov #64, NZ + shll8 NZ + shll16 NZ + + mov.l NZ, @( 0, m) + mov.l ZZ, @( 4, m) + mov.l NZ, @( 8, m) + mov.l ZZ, @(12, m) + mov.l NZ, @(16, m) + rts + mov.l ZZ, @(20, m) + nop + +var_gMatrixPtr: + .long _gMatrixPtr diff --git a/src/platform/32x/asm/matrixTranslate.s b/src/platform/32x/asm/matrixTranslate.s new file mode 100644 index 00000000..d8f0a3d3 --- /dev/null +++ b/src/platform/32x/asm/matrixTranslate.s @@ -0,0 +1,101 @@ +#include "common.i" +SEG_MATH + +#define v r0 +#define e0 r1 +#define e1 r2 +#define e2 r3 +#define x r4 // arg +#define y r5 // arg +#define z r6 // arg +#define m r7 +#define e e0 +#define tmp e1 + +.macro push + // store xyz_ to the stack + shll16 z + xtrct y, z + mov.l z, @-sp +.endm + +.macro pop + add #4, sp +.endm + +.macro Inc offset + mov.w @m+, v + mov sp, tmp + muls.w x, v + mac.w @m+, @tmp+ + mac.w @m+, @tmp+ + mov.w @(\offset, m), v + sts MACL, tmp + shlr14 tmp + add tmp, v // trash in high word, that's fine! + mov.w v, @(\offset, m) +.endm + +.macro Set offset + mov.w @m+, v + mov sp, tmp + muls.w x, v + mac.w @m+, @tmp+ + mac.w @m+, @tmp+ + sts MACL, v + shlr14 v + mov.w v, @(\offset, m) +.endm + +.macro transform func + \func (M03 - 6) // x + \func (M13 - 12) // y + \func (M23 - 18) // z +.endm + +.align 4 +.global _matrixTranslateRel_asm +_matrixTranslateRel_asm: + mov.l var_gMatrixPtr, m + mov.l @m, m + + push + transform Inc + rts + pop + +.align 2 +.global _matrixTranslateAbs_asm +_matrixTranslateAbs_asm: + mov.l var_gCameraViewPos, v + mov.l @v+, e0 + mov.l @v+, e1 + mov.l @v+, e2 + sub e0, x + sub e1, y + sub e2, z + + mov.l var_gMatrixPtr, m + mov.l @m, m + + push + transform Set + rts + pop + +.align 2 +.global _matrixTranslateSet_asm +_matrixTranslateSet_asm: + mov.l var_gMatrixPtr, m + mov.l @m, m + + push + transform Set + rts + pop + +.align 2 +var_gMatrixPtr: + .long _gMatrixPtr +var_gCameraViewPos: + .long _gCameraViewPos diff --git a/src/platform/32x/asm/rasterize.i b/src/platform/32x/asm/rasterize.i new file mode 100644 index 00000000..c3e64f2e --- /dev/null +++ b/src/platform/32x/asm/rasterize.i @@ -0,0 +1,73 @@ +#define type r0 +#define proc r1 + +#define flags r4 // arg +#define L r5 // arg +#define tile r6 // arg +#define R tile +#define pixel flags +#define y type + +.align 4 +.global _rasterize_asm +_rasterize_asm: + mov tile, r7 // set 4th arg for proc + mov flags, type + shll2 type + shlr16 type + extu.b type, proc + + cmp/eq #FACE_TYPE_F, type // cmp/eq #imm is 8-bit + bf/s .getProc + mov L, R // [delay slot] + extu.b flags, R + +.getProc: // proc = table[type] + mova var_table, type + shll2 proc + mov.l @(type, proc), proc + + // pixel = fb + y * 320 = fb + y * 256 + y * 64 + mov.w @(VERTEX_Y, L), y + // FRAME_WIDTH = 320 = 256 + 64 + mov.l var_fb, pixel + shll8 y + add y, pixel // pixel += y * 256 + shar y + shar y + jmp @proc + add y, pixel // [delay slot] pixel += y * 64 + +.align 2 +var_fb: + // overwrite image frame buffer address, it has the same + // write latency but allow transparent write for byte & word + .long 0x24020200 +var_table: +#ifdef ON_CHIP_RENDER + .long 0xC0000000 + _rasterizeS_asm - _block_render_start + .long 0xC0000000 + _rasterizeF_asm - _block_render_start + .long 0xC0000000 + _rasterizeFT_asm - _block_render_start + .long 0xC0000000 + _rasterizeFT_asm - _block_render_start + .long 0xC0000000 + _rasterizeGT_asm - _block_render_start + .long 0xC0000000 + _rasterizeGT_asm - _block_render_start +#else + .long _rasterizeS_asm + .long _rasterizeF_asm + .long _rasterizeFT_asm + .long _rasterizeFT_asm + .long _rasterizeGT_asm + .long _rasterizeGT_asm +#endif + .long _rasterizeSprite_c + .long _rasterizeFillS_c + .long _rasterizeLineH_c + .long _rasterizeLineV_c + +#undef type +#undef proc +#undef flags +#undef L +#undef R +#undef pixel +#undef y \ No newline at end of file diff --git a/src/platform/32x/asm/rasterizeF.i b/src/platform/32x/asm/rasterizeF.i new file mode 100644 index 00000000..102560a6 --- /dev/null +++ b/src/platform/32x/asm/rasterizeF.i @@ -0,0 +1,210 @@ +#define tmp r0 +#define Lh r1 +#define Rh r2 +#define Lptr r3 +#define pixel r4 // arg +#define L r5 // arg +#define index r6 // arg +#define h r7 +#define Lx r8 +#define Rx r9 +#define Ldx r10 +#define Rdx r11 +#define dup r12 // const +#define inv r13 +#define R r14 + +#define divLUT inv + +#define Ry inv +#define Ly inv + +#define Rptr index + +#define ih inv +#define LMAP inv + +.align 4 +.exit_f: + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +.global _rasterizeF_asm +_rasterizeF_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_LMAP_ADDR_fs, LMAP + mov.b @(VERTEX_G, L), tmp + shll8 tmp + add index, tmp + or tmp, LMAP + mov.b @LMAP, dup + extu.b dup, dup + swap.b dup, index + or index, dup // dup = index | (index << 8) + + mov L, R + + mov #0, Rh + +.calc_left_start_f: + mov.b @(VERTEX_PREV, L), tmp // [delay slot] + add L, tmp // tmp = L + (L->prev << VERTEX_SIZEOF_SHIFT) + + mov.l @L, Lx + extu.w Lx, Ly + shlr16 Lx + + mov.l @tmp, Ldx + extu.w Ldx, Lh + shlr16 Ldx + + cmp/ge Ly, Lh + bf/s .exit_f + cmp/eq Ly, Lh // [delay slot] + bt/s .calc_left_start_f // if (L->v.y == N->v.y) check next vertex + mov tmp, L // [delay slot] + + sub Lx, Ldx + sub Ly, Lh + + mov.l var_divTable_fs, divLUT + mov Lh, tmp + shll tmp + mov.w @(tmp, divLUT), ih + + muls.w ih, Ldx + shll16 Lx // [delay slot] + sts MACL, Ldx +.calc_left_end_f: + + tst Rh, Rh + bf .calc_right_end_f + +.calc_right_start_f: + mov.b @(VERTEX_NEXT, R), tmp + add R, tmp // tmp = R + (R->next << VERTEX_SIZEOF_SHIFT) + + mov.l @R, Rx + extu.w Rx, Ry + shlr16 Rx + + mov.l @tmp, Rdx + extu.w Rdx, Rh + shlr16 Rdx + + cmp/ge Ry, Rh + bf/s .exit_f + cmp/eq Ry, Rh // [delay slot] + bt/s .calc_right_start_f // if (R->v.y == N->v.y) check next vertex + mov tmp, R // [delay slot] + + sub Rx, Rdx + sub Ry, Rh + + mov.l var_divTable_fs, divLUT + mov Rh, tmp + shll tmp + mov.w @(tmp, divLUT), ih + + muls.w ih, Rdx + shll16 Rx // [delay slot] + sts MACL, Rdx +.calc_right_end_f: + + // h = min(Lh, Rh) + cmp/gt Rh, Lh + bf/s .scanline_prepare_f + mov Lh, h // [delay slot] + mov Rh, h + +.scanline_prepare_f: + sub h, Lh + sub h, Rh + +.scanline_start_f: + mov Lx, Lptr + mov Rx, Rptr + add Ldx, Lx + add Rdx, Rx + shlr16 Lptr // Lptr = (Lx >> 16) + shlr16 Rptr // Rptr = (Rx >> 16) + cmp/gt Lptr, Rptr // if (!(Rptr > Lptr)) skip zero length scanline + bf/s .scanline_end_f + + add pixel, Lptr // Lptr = pixel + (Lx >> 16) + add pixel, Rptr // Rptr = pixel + (Rx >> 16) + +.align_left_f: + mov #1, tmp + tst tmp, Lptr + bt/s .align_right_f + tst tmp, Rptr // [delay slot] + + mov.b dup, @Lptr + add #1, Lptr + + cmp/gt Lptr, Rptr + bf/s .scanline_end_f + tst tmp, Rptr + nop + +.align_right_f: + bt .block_2px_f + mov.b dup, @-Rptr + cmp/gt Lptr, Rptr + bf .scanline_end_f + +.block_2px_f: + mov.w dup, @-Rptr + cmp/gt Lptr, Rptr + bt/s .block_2px_f + nop + +.scanline_end_f: + dt h + + mov.w var_frameWidth_fs, tmp + bf/s .scanline_start_f + add tmp, pixel // [delay slot] pixel += FRAME_WIDTH + + tst Lh, Lh + bf .calc_right_start_f + bra .calc_left_start_f + nop + +#undef tmp +#undef Lh +#undef Rh +#undef Lptr +#undef pixel +#undef L +#undef index +#undef Lx +#undef Rx +#undef Ldx +#undef Rdx +#undef dup +#undef inv +#undef divLUT +#undef R +#undef h +#undef Ry +#undef Ly +#undef Rptr +#undef ih +#undef LMAP diff --git a/src/platform/32x/asm/rasterizeFT.i b/src/platform/32x/asm/rasterizeFT.i new file mode 100644 index 00000000..48d5e052 --- /dev/null +++ b/src/platform/32x/asm/rasterizeFT.i @@ -0,0 +1,355 @@ +#define tmp r0 +#define Lh r1 +#define Rh r2 +#define LMAP r3 // const +#define pixel r4 // arg +#define L r5 // arg +#define R r6 // arg +#define gtile r7 // arg +#define N gtile +#define Lx r8 +#define Rx r9 +#define Lt r10 +#define Rt r11 +#define dup r12 +#define TILE r13 // const +#define divLUT r14 + +#define h N + +#define Ldx h +#define Rdx h + +#define Ldt h +#define Rdt h + +#define Ry Rx +#define Ly Lx + +#define Rv Rx +#define Lv Lx + +#define Lptr L +#define Rptr R + +#define t Lh +#define dtdx Rh + +#define index tmp + +#define iw dup +#define ih dup + +#define sLdx L +#define sRdx R +#define sLdt Lh +#define sRdt Rh + +#define SP_LDX 0 +#define SP_RDX 4 +#define SP_LDT 8 +#define SP_RDT 12 +#define SP_H 16 +#define SP_L 20 +#define SP_R 24 +#define SP_SIZE 28 + +.align 4 +.exit_ft: + // pop + add #SP_SIZE, sp + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + nop + +.global _rasterizeFT_asm +_rasterizeFT_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + add #-SP_SIZE, sp + + mov.l var_LMAP_ADDR, LMAP + mov.b @(VERTEX_G, L), tmp + shll8 tmp + or tmp, LMAP + + mov.l var_divTable, divLUT + + mov gtile, TILE + nop + + mov #0, Rh +.loop_ft: + extu.w Rh, Lh // Lh = int16(Rh) + + tst Lh, Lh + bf/s .calc_left_end_ft + nop + +.calc_left_start_ft: + mov.b @(VERTEX_PREV, L), tmp // [delay slot] + mov tmp, N + + mov.w @(VERTEX_Y, L), tmp + add L, N // N = L + (L->prev << VERTEX_SIZEOF_SHIFT) + mov tmp, Ly + mov.w @(VERTEX_Y, N), tmp + sub Ly, tmp + cmp/pz tmp + bf/s .exit_ft + tst tmp, tmp + mov L, Lv // Lv = L + bt/s .calc_left_start_ft // if (Lh == 0) check next vertex + mov N, L // [delay slot] + + mov tmp, Lh + mov.l @(VERTEX_T, Lv), Lt + mov.w @(VERTEX_X, Lv), tmp + swap.w tmp, Lx // Lx = L->v.x << 16 + + mov Lh, tmp + cmp/eq #1, tmp + bt/s .calc_left_end_ft + shll tmp // [delay slot] + + mov.w @(tmp, divLUT), ih + + // calc Ldx + mov.w @(VERTEX_X, L), tmp + swap.w Lx, Ldx + sub Ldx, tmp + muls.w ih, tmp + mov.l @(VERTEX_T, L), Ldt + sts MACL, tmp + sub Lt, Ldt + mov.l tmp, @(SP_LDX, sp) + + // calc Ldt + scaleUV Ldt, tmp, ih + mov.l tmp, @(SP_LDT, sp) +.calc_left_end_ft: + + shlr16 Rh // Rh = (Rh >> 16) + tst Rh, Rh + bf/s .calc_right_end_ft + nop + +.calc_right_start_ft: + mov.b @(VERTEX_NEXT, R), tmp // [delay slot] + mov tmp, N + + mov.w @(VERTEX_Y, R), tmp + add R, N // N = R + (R->next << VERTEX_SIZEOF_SHIFT) + mov tmp, Ry + mov.w @(VERTEX_Y, N), tmp + sub Ry, tmp + cmp/pz tmp + bf/s .exit_ft + tst tmp, tmp + mov R, Rv // Rv = R + bt/s .calc_right_start_ft // if (Rh == 0) check next vertex + mov N, R // [delay slot] + + mov tmp, Rh + mov.l @(VERTEX_T, Rv), Rt + mov.w @(VERTEX_X, Rv), tmp + swap.w tmp, Rx // Rx = R->v.x << 16 + + mov Rh, tmp + cmp/eq #1, tmp + bt/s .calc_right_end_ft + shll tmp // [delay slot] + + mov.w @(tmp, divLUT), ih + + // calc Rdx + mov.w @(VERTEX_X, R), tmp + swap.w Rx, Rdx + sub Rdx, tmp + muls.w ih, tmp + mov.l @(VERTEX_T, R), Rdt + sts MACL, tmp + sub Rt, Rdt + mov.l tmp, @(SP_RDX, sp) + + // calc Rdt + scaleUV Rdt, tmp, ih + mov.l tmp, @(SP_RDT, sp) +.calc_right_end_ft: + + // h = min(Lh, Rh) + cmp/gt Rh, Lh + bf/s .scanline_prepare_ft + mov Lh, h // [delay slot] + mov Rh, h + +.scanline_prepare_ft: + sub h, Lh + sub h, Rh + + swap.w Rh, tmp + or Lh, tmp + + mov.l tmp, @(SP_H, sp) + mov.l L, @(SP_L, sp) + mov.l R, @(SP_R, sp) + nop + +.scanline_start_ft: + mov Lx, Lptr + mov Rx, Rptr + shlr16 Lptr // Lptr = (Lx >> 16) + shlr16 Rptr // Rptr = (Rx >> 16) + cmp/gt Lptr, Rptr // if (!(Rptr > Lptr)) skip zero length scanline + bf/s .scanline_end_ft + + // iw = divTable[Rptr - Lptr] + mov Rptr, tmp // [delay slot] + sub Lptr, tmp + shll tmp + mov.w @(tmp, divLUT), iw + + // calc dtdx + mov Rt, tmp + sub Lt, tmp + muls.w tmp, iw + add pixel, Lptr // Lptr = pixel + (Lx >> 16) + sts MACL, dtdx // v = int16(uv) * f (16-bit shift) + shlr16 tmp + muls.w tmp, iw + add pixel, Rptr // Rptr = pixel + (Rx >> 16) + sts MACL, tmp // u = int16(uv >> 16) * f (16-bit shift) + mov Rt, t + shlr16 tmp + xtrct tmp, dtdx // out = uint16(v >> 16) | (u & 0xFFFF0000) + +.align_left_ft: + mov #1, tmp + tst tmp, Lptr + bt/s .align_right_ft + tst tmp, Rptr // [delay slot] + + getUV Lt, index + mov.b @(index, TILE), index + mov.b @(index, LMAP), index + mov.b index, @Lptr + add #1, Lptr + + mov #1, tmp // tmp = 1 (for align_right) + cmp/gt Lptr, Rptr + bf/s .scanline_end_ft + tst tmp, Rptr + +.align_right_ft: + bt/s .block_prepare_ft + + getUV t, index + mov.b @(index, TILE), index + mov.b @(index, LMAP), index + sub dtdx, t + mov.b index, @-Rptr + + cmp/gt Lptr, Rptr + bf/s .scanline_end_ft + nop + +.block_prepare_ft: + shll dtdx // [delay slot] optional + nop + +.block_2px_ft: + getUV t, index + + mov.b @(index, TILE), index + mov.b @(index, LMAP), index + + extu.b index, index + swap.b index, dup + or index, dup // dup = index | (index << 8) + mov.w dup, @-Rptr + + cmp/gt Lptr, Rptr + bt/s .block_2px_ft + sub dtdx, t // [delay slot] t -= dtdx + nop + +.scanline_end_ft: + mov.l @(SP_LDX, sp), sLdx + mov.l @(SP_RDX, sp), sRdx + mov.l @(SP_LDT, sp), sLdt + mov.l @(SP_RDT, sp), sRdt + + add sLdx, Lx + add sRdx, Rx + add sLdt, Lt + add sRdt, Rt + + dt h + + mov.w var_frameWidth_ft, tmp + bf/s .scanline_start_ft + add tmp, pixel // [delay slot] pixel += 120 + 120 + 80 + + mov.l @(SP_L, sp), L + mov.l @(SP_R, sp), R + bra .loop_ft + mov.l @(SP_H, sp), Rh + +var_frameWidth_ft: + .word FRAME_WIDTH + +#undef tmp +#undef Lh +#undef Rh +#undef LMAP +#undef pixel +#undef L +#undef R +#undef N +#undef Lx +#undef Rx +#undef Lt +#undef Rt +#undef dup +#undef TILE +#undef divLUT +#undef h +#undef Ldx +#undef Rdx +#undef Ldt +#undef Rdt +#undef Ry +#undef Ly +#undef Rv +#undef Lv +#undef Lptr +#undef Rptr +#undef t +#undef dtdx +#undef index +#undef iw +#undef ih +#undef sLdx +#undef sRdx +#undef sLdt +#undef sRdt +#undef SP_LDX +#undef SP_RDX +#undef SP_LDT +#undef SP_RDT +#undef SP_H +#undef SP_L +#undef SP_R +#undef SP_SIZE diff --git a/src/platform/32x/asm/rasterizeGT.i b/src/platform/32x/asm/rasterizeGT.i new file mode 100644 index 00000000..f149a330 --- /dev/null +++ b/src/platform/32x/asm/rasterizeGT.i @@ -0,0 +1,437 @@ +#define tmp r0 +#define Lh r1 +#define Rh r2 +#define dup r3 +#define pixel r4 // arg +#define L r5 // arg +#define R r6 // arg +#define gtile r7 // arg +#define N gtile +#define Lx r8 +#define Rx r9 +#define Lg r10 +#define Rg r11 +#define Lt r12 +#define Rt r13 +#define TILE r14 // const + +#define h N + +#define Ldx h +#define Rdx h + +#define Ldt h +#define Rdt h + +#define Ry Rx +#define Ly Lx + +#define Rv Rx +#define Lv Lx + +#define Lptr Lh +#define Rptr Rx + +#define g Rg +#define dgdx R + +#define t Rt +#define dtdx L + +#define index tmp +#define LMAP dup + +#define divLUT dup +#define iw dup +#define ih dup + +#define dx dgdx +#define mask Rh + +#define sLdx L +#define sRdx R +#define sLdt L +#define sRdt R +#define sLdg L +#define sRdg R + +#define SP_LDX 0 +#define SP_RDX 4 +#define SP_LDT 8 +#define SP_RDT 12 +#define SP_LDG 16 +#define SP_RDG 18 +#define SP_H 20 +#define SP_L 24 +#define SP_R 28 +#define SP_SIZE 32 + +.align 4 +.exit_gt: + // pop + add #SP_SIZE, sp + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + nop + +.global _rasterizeGT_asm +_rasterizeGT_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + add #-SP_SIZE, sp + + mov gtile, TILE + mov #0, Rh + +.loop_gt: + extu.w Rh, Lh // Lh = int16(Rh) + + tst Lh, Lh + bf/s .calc_left_end_gt + shlr16 Rh // [delay slot] Rh = (Rh >> 16) + +.calc_left_start_gt: + mov.b @(VERTEX_PREV, L), tmp + mov tmp, N + + mov.w @(VERTEX_Y, L), tmp + add L, N // N = L + (L->prev << VERTEX_SIZEOF_SHIFT) + mov tmp, Ly + mov.w @(VERTEX_Y, N), tmp + sub Ly, tmp + cmp/pz tmp + bf/s .exit_gt + tst tmp, tmp + mov L, Lv // Lv = L + bt/s .calc_left_start_gt // if (Lh == 0) check next vertex + mov N, L // [delay slot] + + mov tmp, Lh + mov.b @(VERTEX_G, Lv), tmp + mov.l @(VERTEX_T, Lv), Lt + mov tmp, Lg + mov.w @(VERTEX_X, Lv), tmp + shll8 Lg + swap.w tmp, Lx // Lx = L->v.x << 16 + + mov Lh, tmp + cmp/eq #1, tmp + bt/s .calc_left_end_gt + shll tmp // [delay slot] + + mov.l var_divTable, divLUT + mov.w @(tmp, divLUT), ih + + // calc Ldx + mov.w @(VERTEX_X, L), tmp + swap.w Lx, Ldx + sub Ldx, tmp + muls.w ih, tmp + mov.b @(VERTEX_G, L), tmp + sts MACL, Ldx + shll8 tmp + mov.l Ldx, @(SP_LDX, sp) + + // calc Ldg + sub Lg, tmp + muls.w ih, tmp + mov.l @(VERTEX_T, L), Ldt + sts MACL, tmp + sub Lt, Ldt + shlr16 tmp + mov.w tmp, @(SP_LDG, sp) + + // calc Ldt + scaleUV Ldt, tmp, ih + mov.l tmp, @(SP_LDT, sp) + nop +.calc_left_end_gt: + + tst Rh, Rh + bf/s .calc_right_end_gt + +.calc_right_start_gt: + mov.b @(VERTEX_NEXT, R), tmp // [delay slot] + mov tmp, N + + mov.w @(VERTEX_Y, R), tmp + add R, N // N = R + (R->next << VERTEX_SIZEOF_SHIFT) + mov tmp, Ry + mov.w @(VERTEX_Y, N), tmp + sub Ry, tmp + cmp/pz tmp + bf/s .exit_gt + tst tmp, tmp + mov R, Rv // Rv = R + bt/s .calc_right_start_gt // if (Rh == 0) check next vertex + mov N, R // [delay slot] + + mov tmp, Rh + mov.b @(VERTEX_G, Rv), tmp + mov.l @(VERTEX_T, Rv), Rt + mov tmp, Rg + mov.w @(VERTEX_X, Rv), tmp + shll8 Rg + swap.w tmp, Rx // Rx = R->v.x << 16 + + mov Rh, tmp + cmp/eq #1, tmp + bt/s .calc_right_end_gt + shll tmp // [delay slot] + + mov.l var_divTable, divLUT + mov.w @(tmp, divLUT), ih + + // calc Rdx + mov.w @(VERTEX_X, R), tmp + swap.w Rx, Rdx + sub Rdx, tmp + muls.w ih, tmp + mov.b @(VERTEX_G, R), tmp + sts MACL, Rdx + shll8 tmp + mov.l Rdx, @(SP_RDX, sp) + + // calc Rdg + sub Rg, tmp + muls.w ih, tmp + mov.l @(VERTEX_T, R), Rdt + sts MACL, tmp + sub Rt, Rdt + shlr16 tmp + mov.w tmp, @(SP_RDG, sp) + + // calc Rdt + scaleUV Rdt, tmp, ih + mov.l tmp, @(SP_RDT, sp) + nop +.calc_right_end_gt: + + // bake gLightmap address into g value + mov.l var_LMAP_ADDR, tmp + or tmp, Lg + or tmp, Rg + + // h = min(Lh, Rh) + cmp/gt Rh, Lh + bf/s .scanline_prepare_gt + mov Lh, h // [delay slot] + mov Rh, h + nop + +.scanline_prepare_gt: + sub h, Lh + sub h, Rh + + swap.w Rh, tmp + or Lh, tmp + + mov.l tmp, @(SP_H, sp) + mov.l L, @(SP_L, sp) + mov.l R, @(SP_R, sp) + + mov.w var_mask, mask + +.scanline_start_gt: + mov.l Rx, @-sp // alias Rptr + + mov Lx, Lptr + shlr16 Lptr // Lptr = (Lx >> 16) + shlr16 Rptr // Rptr = (Rx >> 16) + cmp/gt Lptr, Rptr // if (!(Rptr > Lptr)) skip zero length scanline + bf/s .scanline_end_fast_gt + + // iw = divTable[Rptr - Lptr] + mov Rptr, tmp // [delay slot] + sub Lptr, tmp + mov.l var_divTable, divLUT + shll tmp + mov.w @(tmp, divLUT), iw + + add pixel, Lptr // Lptr = pixel + (Lx >> 16) + add pixel, Rptr // Rptr = pixel + (Rx >> 16) + + mov.l Rt, @-sp // alias t + mov.l Rg, @-sp // alias g + + // calc dtdx + mov Rt, tmp + sub Lt, tmp + muls.w tmp, iw + shlr16 tmp + sts MACL, dtdx // v = int16(uv) * f (16-bit shift) + muls.w tmp, iw + mov Rg, tmp + sts MACL, dx // u = int16(uv >> 16) * f (16-bit shift) + sub Lg, tmp + shlr16 dx + xtrct dx, dtdx // out = uint16(v >> 16) | (u & 0xFFFF0000) + + // calc dgdx + muls.w tmp, iw + mov #1, tmp + sts MACL, dgdx + tst tmp, Lptr + shlr16 dgdx + exts.w dgdx, dgdx + +.align_left_gt: + bt/s .align_right_gt + tst tmp, Rptr // [delay slot] + + getUV Lt, index + mov.b @(index, TILE), index + mov Lg, LMAP + and mask, LMAP + mov.b @(index, LMAP), index + + mov.b index, @Lptr + add #1, Lptr + + mov #1, tmp // tmp = 1 (for align_right) + cmp/gt Lptr, Rptr + bf/s .scanline_end_gt + tst tmp, Rptr + +.align_right_gt: + bt/s .block_prepare_gt + mov g, LMAP + + getUV t, index + mov.b @(index, TILE), index + and mask, LMAP + sub dgdx, g + mov.b @(index, LMAP), index + + sub dtdx, t + + mov.b index, @-Rptr + + cmp/gt Lptr, Rptr + bf/s .scanline_end_gt + +.block_prepare_gt: + shll dtdx // [delay slot] optional + shll dgdx + +.block_2px_gt: + getUV t, index + + mov.b @(index, TILE), index + + mov g, LMAP + and mask, LMAP // LMAP = (g & 0xFFFFFF00) + mov.b @(index, LMAP), index + sub dgdx, g // g -= dgdx + + extu.b index, index + swap.b index, dup + or index, dup // dup = index | (index << 8) + mov.w dup, @-Rptr + + cmp/gt Lptr, Rptr + bt/s .block_2px_gt + sub dtdx, t // [delay slot] t -= dtdx + +.scanline_end_gt: + mov.l @sp+, Rg + mov.l @sp+, Rt +.scanline_end_fast_gt: + mov.l @sp+, Rx + + mov sp, tmp + + mov.l @tmp+, sLdx + mov.l @tmp+, sRdx + + add sLdx, Lx + add sRdx, Rx + + mov.l @tmp+, sLdt + mov.l @tmp+, sRdt + + add sLdt, Lt + add sRdt, Rt + + mov.w @tmp+, sLdg + mov.w @tmp+, sRdg + + add sLdg, Lg + add sRdg, Rg + + dt h + + mov.w var_frameWidth, tmp + bf/s .scanline_start_gt + add tmp, pixel // [delay slot] pixel += 120 + 120 + 80 + + mov.l @(SP_L, sp), L + mov.l @(SP_R, sp), R + bra .loop_gt + mov.l @(SP_H, sp), Rh + +#undef tmp +#undef Lh +#undef Rh +#undef dup +#undef pixel +#undef L +#undef R +#undef N +#undef Lx +#undef Rx +#undef Lg +#undef Rg +#undef Lt +#undef Rt +#undef TILE +#undef h +#undef Ldx +#undef Rdx +#undef Ldt +#undef Rdt +#undef Ry +#undef Ly +#undef Rv +#undef Lv +#undef Lptr +#undef Rptr +#undef g +#undef dgdx +#undef t +#undef dtdx +#undef index +#undef LMAP +#undef divLUT +#undef iw +#undef ih +#undef dx +#undef mask +#undef sLdx +#undef sRdx +#undef sLdt +#undef sRdt +#undef sLdg +#undef sRdg +#undef SP_LDX +#undef SP_RDX +#undef SP_LDT +#undef SP_RDT +#undef SP_LDG +#undef SP_RDG +#undef SP_H +#undef SP_L +#undef SP_R +#undef SP_SIZE diff --git a/src/platform/32x/asm/rasterizeS.i b/src/platform/32x/asm/rasterizeS.i new file mode 100644 index 00000000..985b41cf --- /dev/null +++ b/src/platform/32x/asm/rasterizeS.i @@ -0,0 +1,186 @@ +#define tmp r0 +#define Lh r1 +#define Rh r2 +#define Lptr r3 +#define pixel r4 // arg +#define L r5 // arg +#define R r6 // arg +#define h r7 +#define Lx r8 +#define Rx r9 +#define Ldx r10 +#define Rdx r11 +#define LMAP r12 // const +#define inv r13 +#define divLUT r14 + +#define index tmp + +#define Ry inv +#define Ly inv + +#define Rptr inv + +#define ih inv + +.align 4 +.exit_s: + // pop + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +.global _rasterizeS_asm +_rasterizeS_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + + mov.l var_LMAP_ADDR_fs, LMAP + mov #27, tmp + shll8 tmp + or tmp, LMAP + + mov.l var_divTable_fs, divLUT + + mov #0, Rh + nop + +.calc_left_start_s: + mov.b @(VERTEX_PREV, L), tmp // [delay slot] + add L, tmp // tmp = L + (L->prev << VERTEX_SIZEOF_SHIFT) + + mov.l @L, Lx + extu.w Lx, Ly + shlr16 Lx + + mov.l @tmp, Ldx + extu.w Ldx, Lh + shlr16 Ldx + + cmp/ge Ly, Lh + bf/s .exit_s + cmp/eq Ly, Lh // [delay slot] + bt/s .calc_left_start_s // if (L->v.y == N->v.y) check next vertex + mov tmp, L // [delay slot] + + sub Lx, Ldx + sub Ly, Lh + + mov Lh, tmp + shll tmp + mov.w @(tmp, divLUT), ih + + muls.w ih, Ldx + shll16 Lx // [delay slot] + sts MACL, Ldx +.calc_left_end_s: + + tst Rh, Rh + bf .calc_right_end_s + nop + +.calc_right_start_s: + mov.b @(VERTEX_NEXT, R), tmp + add R, tmp // tmp = R + (R->next << VERTEX_SIZEOF_SHIFT) + + mov.l @R, Rx + extu.w Rx, Ry + shlr16 Rx + + mov.l @tmp, Rdx + extu.w Rdx, Rh + shlr16 Rdx + + cmp/ge Ry, Rh + bf/s .exit_s + cmp/eq Ry, Rh // [delay slot] + bt/s .calc_right_start_s // if (R->v.y == N->v.y) check next vertex + mov tmp, R // [delay slot] + + sub Rx, Rdx + sub Ry, Rh + + mov Rh, tmp + shll tmp + mov.w @(tmp, divLUT), ih + + muls.w ih, Rdx + shll16 Rx // [delay slot] + sts MACL, Rdx +.calc_right_end_s: + + // h = min(Lh, Rh) + cmp/gt Rh, Lh + bf/s .scanline_prepare_s + mov Lh, h // [delay slot] + mov Rh, h + nop + +.scanline_prepare_s: + sub h, Lh + sub h, Rh + +.scanline_start_s: + mov Lx, Lptr + mov Rx, Rptr + add Ldx, Lx + add Rdx, Rx + shlr16 Lptr // Lptr = (Lx >> 16) + shlr16 Rptr // Rptr = (Rx >> 16) + cmp/gt Lptr, Rptr // if (!(Rptr > Lptr)) skip zero length scanline + bf/s .scanline_end_s + + add pixel, Lptr // Lptr = pixel + (Lx >> 16) + add pixel, Rptr // Rptr = pixel + (Rx >> 16) + +.shade_pixel_s: + mov.b @Lptr, index + mov.b @(index, LMAP), index + mov.b index, @Lptr + add #1, Lptr + cmp/gt Lptr, Rptr + bt .shade_pixel_s + +.scanline_end_s: + dt h + + mov.w var_frameWidth_fs, tmp + bf/s .scanline_start_s + add tmp, pixel // [delay slot] pixel += FRAME_WIDTH + + tst Lh, Lh + bf .calc_right_start_s + bra .calc_left_start_s + nop + +#undef tmp +#undef Lh +#undef Rh +#undef Lptr +#undef pixel +#undef L +#undef R +#undef Lx +#undef Rx +#undef Ldx +#undef Rdx +#undef LMAP +#undef inv +#undef divLUT +#undef index +#undef h +#undef Ry +#undef Ly +#undef Rptr +#undef ih diff --git a/src/platform/32x/asm/rasterize_dummy.i b/src/platform/32x/asm/rasterize_dummy.i new file mode 100644 index 00000000..a80b2ff8 --- /dev/null +++ b/src/platform/32x/asm/rasterize_dummy.i @@ -0,0 +1,5 @@ +.align 4 +.global _rasterize_dummy +_rasterize_dummy: + rts + nop diff --git a/src/platform/32x/asm/transformMesh.i b/src/platform/32x/asm/transformMesh.i new file mode 100644 index 00000000..d0da8dc0 --- /dev/null +++ b/src/platform/32x/asm/transformMesh.i @@ -0,0 +1,194 @@ +#define tmp r0 +#define maxZ r1 +#define divLUT r2 +#define res r3 +#define vertices r4 // arg +#define count r5 // arg +#define intensity r6 // arg +#define m r7 +#define x r8 +#define y r9 +#define z r10 +#define mx r11 +#define my r12 +#define mz r13 + +#define vg intensity +#define ambient tmp +#define dz tmp +#define minZ tmp + +.macro transform v, offset + lds \offset, MACL + mac.w @vertices+, @m+ + mac.w @vertices+, @m+ + mac.w @vertices+, @m+ + sts MACL, tmp + // v += tmp >> (FIXED_SHIFT + FP16_SHIFT) + shlr16 tmp + exts.w tmp, \v +.endm + +.align 4 +.global _transformMesh_asm +_transformMesh_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + + mov.l var_gVerticesBase, tmp + mov.l @tmp, res + + mov.l var_gMatrixPtr, tmp + mov.l @tmp, m + + mov.l var_gLightAmbient, tmp + mov.l @tmp, ambient + + mov.l var_divTable, divLUT + + // maxZ = VIEW_MAX = (1024 * 10) = (40 << 8) + mov #40, maxZ + shll8 maxZ + + add intensity, ambient + shlr8 ambient + exts.b ambient, vg + + // vg = clamp(vg, 0, 31) + 1 +.vg_max_m: + mov #31, tmp + cmp/gt tmp, vg + bf/s .vg_min_m + cmp/pz vg // [delay slot] T = vg >= 0 + mov tmp, vg +.vg_min_m: + subc tmp, tmp // tmp = -T + and tmp, vg + + add #1, vg // +1 for signed lightmap fetch + + shll8 vg // lower 8 bits = vertex.clip flags + add #8, res // extra offset for @-Rn + + // pre-transform the matrix offset + add #M03, m + mov.w @m+, mx + mov.w @m+, my + mov.w @m+, mz + shll16 mx + shll16 my + shll16 mz + add #-MATRIX_SIZEOF, m + +.loop_m: + // clear clipping flags + shlr8 vg + shll8 vg + + // transform to view space + transform x, mx + add #-6, vertices // reset vertex ptr + transform y, my + add #-6, vertices // reset vertex ptr + transform z, mz + + // z clipping +.clip_z_near_m: + mov #VIEW_MIN, minZ + cmp/gt z, minZ + bf/s .clip_z_far_m + cmp/ge maxZ, z // [delay slot] + mov minZ, z + add #CLIP_PLANE, vg +.clip_z_far_m: + bf .project_m + mov maxZ, z + add #CLIP_PLANE, vg + +.project_m: + // z >>= OT_SHIFT + shlr2 z + shlr2 z + + // dz = divTable[z] + mov z, dz + shll dz + mov.w @(dz, divLUT), dz + + // x = x * dz >> 12 + // y = y * dz >> 12 + muls.w dz, x + sts MACL, x + add #-M03, m // reset matrix ptr + muls.w dz, y + shll2 x + shll2 x + shlr16 x + sts MACL, y + exts.w x, x + shll2 y + shll2 y + shlr16 y + exts.w y, y + + // apply_offset + // x += FRAME_WIDTH / 2 (160) + add #100, x // x += 100 + add #60, x // x += 60 + // y += FRAME_HEIGHT / 2 (112) + add #112, y // y += 112 + + // 0 < x > FRAME_WIDTH + mov #80, tmp + shll2 tmp // tmp = 80 * 4 = 320 = FRAME_WIDTH + cmp/hi tmp, x + bt/s .clip_frame_m + add #-96, tmp // [delay slot] tmp = 320 - 96 = 224 = FRAME_HEIGHT + // 0 < y > FRAME_HEIGHT + cmp/hi tmp, y +.clip_frame_m: + movt tmp + or tmp, vg // vg |= CLIP_FRAME + + // store_vertex + mov.w vg, @-res + mov.w z, @-res + mov.w y, @-res + mov.w x, @-res + + dt count + bf/s .loop_m + add #16, res // [delay slot] + + // pop + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef maxZ +#undef divLUT +#undef res +#undef vertices +#undef count +#undef intensity +#undef m +#undef x +#undef y +#undef z +#undef mx +#undef my +#undef mz +#undef vg +#undef ambient +#undef dz +#undef minZ \ No newline at end of file diff --git a/src/platform/32x/asm/transformRoom.i b/src/platform/32x/asm/transformRoom.i new file mode 100644 index 00000000..f7379761 --- /dev/null +++ b/src/platform/32x/asm/transformRoom.i @@ -0,0 +1,256 @@ +#define tmp r0 +#define maxZ r1 +#define divLUT r2 +#define res r3 +#define vertices r4 // arg +#define count r5 // arg +#define vp r6 +#define m r7 +#define vg r8 +#define x r9 +#define y r10 +#define z r11 +#define mx r12 // const +#define my r13 // const +#define mz r14 // const + +#define minX tmp +#define minY tmp +#define maxX tmp +#define maxY tmp +#define minZ x +#define dz tmp +#define stackVtx tmp +#define fog x +#define minFog y +#define maxG y + +#define SP_SIZE (8) // vec3s + padding + +.align 4 +.global _transformRoom_asm +_transformRoom_asm: + // push + mov.l r8, @-sp + mov.l r9, @-sp + mov.l r10, @-sp + mov.l r11, @-sp + mov.l r12, @-sp + mov.l r13, @-sp + mov.l r14, @-sp + add #-SP_SIZE, sp + + mov.l var_viewportRel, vp + + mov.l var_gVerticesBase, tmp + mov.l @tmp, res + + mov.l var_divTable, divLUT + + // store matrix into stack (in reverse order) + mov.l var_gMatrixPtr, tmp + mov.l @tmp, m + + // pre-transform the matrix offset + add #M03, m + mov.w @m+, mx + mov.w @m+, my + mov.w @m+, mz + shll8 mx + shll8 my + shll8 mz + add #-12, m // offset to z-row + + // maxZ = VIEW_MAX = (1024 * 10) >> OT_SHIFT = (40 << 8) >> OT_SHIFT + mov #40, maxZ + shll2 maxZ + shll2 maxZ + + add #8, res // extra offset for @-Rn + +.loop_r: + // unpack vertex + mov.b @vertices+, x + mov.b @vertices+, y + mov.b @vertices+, z + shll2 x + shll2 y + shll2 z + + // upload vertex coords into stack + mov sp, stackVtx + add #6, stackVtx + + mov.w z, @-stackVtx + mov.w y, @-stackVtx + mov.w x, @-stackVtx + +.transform_z: + lds mz, MACL + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + sts MACL, z + add #-6, stackVtx + add #-18, m // offset to x-row + shlr8 z + + // z >>= OT_SHIFT + shlr2 z + shlr2 z + + exts.w z, z + +.calc_fog: + // if z <= FOG_MIN -> skip fog calc + mov #(32 >> OT_SHIFT), minFog // minFog = FOG_MIN >> OT_SHIFT + shll8 minFog + mov z, fog + subc minFog, fog // TODO need to clear T before? + bt/s .clip_z_near_r + mov.b @vertices+, vg // [delay slot] + shlr2 fog + shlr fog // shift down to 0..31 range + add fog, vg + // vg = min(vg, 31) + mov #31, maxG + cmp/gt maxG, vg + bf .clip_z_near_r + mov #31, vg + + // z clipping +.clip_z_near_r: + add #1, vg // +1 for signed lightmap fetch + mov #(VIEW_MIN >> OT_SHIFT), minZ + cmp/gt z, minZ + bf/s .clip_z_far_r + shll8 vg // [delay slot] clear lower 8-bits of vg for clipping flags + mov minZ, z + add #CLIP_PLANE, vg +.clip_z_far_r: + cmp/ge maxZ, z + bf .transform_x + mov maxZ, z + add #CLIP_PLANE, vg + +.transform_x: + lds mx, MACL + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + sts MACL, x + add #-6, stackVtx + shlr8 x + exts.w x, x + +.transform_y: + lds my, MACL + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + mac.w @stackVtx+, @m+ + sts MACL, y + mov z, dz // [delay slot] + shlr8 y + exts.w y, y + +.project_r: // dz = divTable[z] + shll dz + mov.w @(dz, divLUT), dz + + // x = x * dz >> 12 + muls.w dz, x + sts MACL, x + + // y = y * dz >> 12 + muls.w dz, y + sts MACL, y + + shar12 x, tmp + shar12 y, tmp + + // portal rect clipping +.clip_vp_minX_r: + mov.w @(0, vp), minX + cmp/gt x, minX + bf/s .clip_vp_minY_r + mov.w @(2, vp), minY // [delay slot] + add #CLIP_LEFT, vg +.clip_vp_minY_r: + cmp/ge y, minY + bf/s .clip_vp_maxX_r + mov.w @(4, vp), maxX // [delay slot] + add #CLIP_TOP, vg +.clip_vp_maxX_r: + cmp/gt maxX, x + bf/s .clip_vp_maxY_r + mov.w @(6, vp), maxY // [delay slot] + add #CLIP_RIGHT, vg +.clip_vp_maxY_r: + cmp/ge maxY, y + bf/s .apply_offset_r + mov #80, tmp // [delay slot] tmp = 80 + add #CLIP_BOTTOM, vg + +.apply_offset_r: + // x += FRAME_WIDTH / 2 (160) + add #100, x // x += 100 + add #60, x // x += 60 + // y += FRAME_HEIGHT / 2 (112) + add #112, y // y += 112 + + // frame rect clipping + // 0 < x > FRAME_WIDTH + shll2 tmp // tmp = 80 * 4 = 320 = FRAME_WIDTH + cmp/hi tmp, x + bt/s .clip_frame_r + add #-96, tmp // [delay slot] tmp = 320 - 96 = 224 = FRAME_HEIGHT + // 0 < y > FRAME_HEIGHT + cmp/hi tmp, y +.clip_frame_r: + movt tmp + or tmp, vg // vg |= CLIP_FRAME + + // store_vertex + mov.w vg, @-res + mov.w z, @-res + mov.w y, @-res + mov.w x, @-res + + dt count + bf/s .loop_r + add #16, res // [delay slot] +.done_r: + // pop + add #SP_SIZE, sp + mov.l @sp+, r14 + mov.l @sp+, r13 + mov.l @sp+, r12 + mov.l @sp+, r11 + mov.l @sp+, r10 + mov.l @sp+, r9 + rts + mov.l @sp+, r8 + +#undef tmp +#undef maxZ +#undef divLUT +#undef res +#undef vertices +#undef count +#undef stackVtx +#undef vp +#undef x +#undef y +#undef z +#undef mx +#undef my +#undef mz +#undef minX +#undef minY +#undef maxX +#undef maxY +#undef minZ +#undef dz +#undef vg +#undef fog +#undef SP_SIZE \ No newline at end of file diff --git a/src/platform/32x/crt0.s b/src/platform/32x/crt0.s new file mode 100644 index 00000000..0a768406 --- /dev/null +++ b/src/platform/32x/crt0.s @@ -0,0 +1,1280 @@ +!----------------------------------------------------------------------- +! SEGA 32X support code for SH2 +! by Chilly Willy +! Rom header and SH2 init/exception code - must be first in object list +!----------------------------------------------------------------------- + + .text + +! 68000 exception vector table at 0x000 + +!----------------------------------------------------------------------- +! Initial exception vectors - when the console is first turned on, it is +! in MegaDrive mode. All vectors just point to the code to start up the +! Mars adapter. After the adapter is enabled, none of these vectors will +! appear as the adapter uses its own vector table to route exceptions to +! the jump table at 0x200. +!----------------------------------------------------------------------- + + .long 0x01000000,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 + +! Standard MegaDrive ROM header at 0x100 + + .ascii "SEGA 32X " /* First 4 bytes must be "SEGA" */ + .ascii "XProger (c)2022 " /* Copyright and date */ + .ascii "OpenLara Alpha " /* JP Name */ + .ascii "OpenLara Alpha " /* EN Name */ + .ascii "GM 14021968-01" /* Serial No. */ + .word 0x0000 + .ascii "J6 " + .long 0x00000000,0x005FFFFF /* ROM start, end */ + .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ + +! 2KB of save ram on odd byte lane + .ascii "RA" /* External RAM */ + .byte 0xF8 /* don't clear + odd bytes */ + .byte 0x20 /* SRAM */ + .long 0x00200001,0x00200FFF /* SRAM start, end */ + +! .ascii " " /* no SRAM */ + + .ascii " " + .ascii " " + .ascii " " + .ascii " " + .ascii "F " /* enable any hardware configuration */ + +! Mars 68000 exception jump table at 0x200 + + .macro jump address + .word 0x4EF9,\address>>16,\address&0xFFFF + .endm + + .macro call address + .word 0x4EB9,\address>>16,\address&0xFFFF + .endm + + jump 0x880800 /* reset = hot start */ + call 0x880840 /* EX_BusError */ + call 0x880840 /* EX_AddrError */ + call 0x880840 /* EX_IllInstr */ + call 0x880840 /* EX_DivByZero */ + call 0x880840 /* EX_CHK */ + call 0x880840 /* EX_TrapV */ + call 0x880840 /* EX_Priviledge */ + call 0x880840 /* EX_Trace */ + call 0x880840 /* EX_LineA */ + call 0x880840 /* EX_LineF */ + .space 72 /* reserved */ + call 0x880840 /* EX_Spurious */ + call 0x880840 /* EX_Level1 */ + call 0x880840 /* EX_Level2 */ + call 0x880840 /* EX_Level3 */ + jump 0x880880 /* EX_Level4 HBlank */ + call 0x880840 /* EX_Level5 */ + jump 0x8808C0 /* EX_Level6 VBlank */ + call 0x880840 /* EX_Level7 */ + call 0x880840 /* EX_Trap0 */ + call 0x880840 /* EX_Trap1 */ + call 0x880840 /* EX_Trap2 */ + call 0x880840 /* EX_Trap3 */ + call 0x880840 /* EX_Trap4 */ + call 0x880840 /* EX_Trap5 */ + call 0x880840 /* EX_Trap6 */ + call 0x880840 /* EX_Trap7 */ + call 0x880840 /* EX_Trap8 */ + call 0x880840 /* EX_Trap9 */ + call 0x880840 /* EX_TrapA */ + call 0x880840 /* EX_TrapB */ + call 0x880840 /* EX_TrapC */ + call 0x880840 /* EX_TrapD */ + call 0x880840 /* EX_TrapE */ + call 0x880840 /* EX_TrapF */ + .space 166 /* reserved */ + +! Standard Mars Header at 0x3C0 + + .ascii "OpenLara " /* module name */ + .long 0x00000000 /* version */ + .long __text_end-0x02000000 /* Source (in ROM) */ + .long 0x00000000 /* Destination (in SDRAM) */ + .long __data_size /* Size */ + .long pri_start /* Primary SH2 Jump */ + .long sec_start /* Secondary SH2 Jump */ + .long pri_vbr /* Primary SH2 VBR */ + .long sec_vbr /* Secondary SH2 VBR */ + +! Standard 32X startup code for MD side at 0x3F0 + + .word 0x287C,0xFFFF,0xFFC0,0x23FC,0x0000,0x0000,0x00A1,0x5128 + .word 0x46FC,0x2700,0x4BF9,0x00A1,0x0000,0x7001,0x0CAD,0x4D41 + .word 0x5253,0x30EC,0x6600,0x03E6,0x082D,0x0007,0x5101,0x67F8 + .word 0x4AAD,0x0008,0x6710,0x4A6D,0x000C,0x670A,0x082D,0x0000 + .word 0x5101,0x6600,0x03B8,0x102D,0x0001,0x0200,0x000F,0x6706 + .word 0x2B78,0x055A,0x4000,0x7200,0x2C41,0x4E66,0x41F9,0x0000 + .word 0x04D4,0x6100,0x0152,0x6100,0x0176,0x47F9,0x0000,0x04E8 + .word 0x43F9,0x00A0,0x0000,0x45F9,0x00C0,0x0011,0x3E3C,0x0100 + .word 0x7000,0x3B47,0x1100,0x3B47,0x1200,0x012D,0x1100,0x66FA + .word 0x7425,0x12DB,0x51CA,0xFFFC,0x3B40,0x1200,0x3B40,0x1100 + .word 0x3B47,0x1200,0x149B,0x149B,0x149B,0x149B,0x41F9,0x0000 + .word 0x04C0,0x43F9,0x00FF,0x0000,0x22D8,0x22D8,0x22D8,0x22D8 + .word 0x22D8,0x22D8,0x22D8,0x22D8,0x41F9,0x00FF,0x0000,0x4ED0 + .word 0x1B7C,0x0001,0x5101,0x41F9,0x0000,0x06BC,0xD1FC,0x0088 + .word 0x0000,0x4ED0,0x0404,0x303C,0x076C,0x0000,0x0000,0xFF00 + .word 0x8137,0x0002,0x0100,0x0000,0xAF01,0xD91F,0x1127,0x0021 + .word 0x2600,0xF977,0xEDB0,0xDDE1,0xFDE1,0xED47,0xED4F,0xD1E1 + .word 0xF108,0xD9C1,0xD1E1,0xF1F9,0xF3ED,0x5636,0xE9E9,0x9FBF + .word 0xDFFF,0x4D41,0x5253,0x2049,0x6E69,0x7469,0x616C,0x2026 + .word 0x2053,0x6563,0x7572,0x6974,0x7920,0x5072,0x6F67,0x7261 + .word 0x6D20,0x2020,0x2020,0x2020,0x2020,0x2043,0x6172,0x7472 + .word 0x6964,0x6765,0x2056,0x6572,0x7369,0x6F6E,0x2020,0x2020 + .word 0x436F,0x7079,0x7269,0x6768,0x7420,0x5345,0x4741,0x2045 + .word 0x4E54,0x4552,0x5052,0x4953,0x4553,0x2C4C,0x5444,0x2E20 + .word 0x3139,0x3934,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020 + .word 0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020 + .word 0x2020,0x2020,0x2020,0x524F,0x4D20,0x5665,0x7273,0x696F + .word 0x6E20,0x312E,0x3000,0x48E7,0xC040,0x43F9,0x00C0,0x0004 + .word 0x3011,0x303C,0x8000,0x323C,0x0100,0x3E3C,0x0012,0x1018 + .word 0x3280,0xD041,0x51CF,0xFFF8,0x4CDF,0x0203,0x4E75,0x48E7 + .word 0x81C0,0x41F9,0x0000,0x063E,0x43F9,0x00C0,0x0004,0x3298 + .word 0x3298,0x3298,0x3298,0x3298,0x3298,0x3298,0x2298,0x3341 + .word 0xFFFC,0x3011,0x0800,0x0001,0x66F8,0x3298,0x3298,0x7000 + .word 0x22BC,0xC000,0x0000,0x7E0F,0x3340,0xFFFC,0x3340,0xFFFC + .word 0x3340,0xFFFC,0x3340,0xFFFC,0x51CF,0xFFEE,0x22BC,0x4000 + .word 0x0010,0x7E09,0x3340,0xFFFC,0x3340,0xFFFC,0x3340,0xFFFC + .word 0x3340,0xFFFC,0x51CF,0xFFEE,0x4CDF,0x0381,0x4E75,0x8114 + .word 0x8F01,0x93FF,0x94FF,0x9500,0x9600,0x9780,0x4000,0x0080 + .word 0x8104,0x8F02,0x48E7,0xC140,0x43F9,0x00A1,0x5180,0x08A9 + .word 0x0007,0xFF80,0x66F8,0x3E3C,0x00FF,0x7000,0x7200,0x337C + .word 0x00FF,0x0004,0x3341,0x0006,0x3340,0x0008,0x4E71,0x0829 + .word 0x0001,0x000B,0x66F8,0x0641,0x0100,0x51CF,0xFFE8,0x4CDF + .word 0x0283,0x4E75,0x48E7,0x8180,0x41F9,0x00A1,0x5200,0x08A8 + .word 0x0007,0xFF00,0x66F8,0x3E3C,0x001F,0x20C0,0x20C0,0x20C0 + .word 0x20C0,0x51CF,0xFFF6,0x4CDF,0x0181,0x4E75,0x41F9,0x00FF + .word 0x0000,0x3E3C,0x07FF,0x7000,0x20C0,0x20C0,0x20C0,0x20C0 + .word 0x20C0,0x20C0,0x20C0,0x20C0,0x51CF,0xFFEE,0x3B7C,0x0000 + .word 0x1200,0x7E0A,0x51CF,0xFFFE,0x43F9,0x00A1,0x5100,0x7000 + .word 0x2340,0x0020,0x2340,0x0024,0x1B7C,0x0003,0x5101,0x2E79 + .word 0x0088,0x0000,0x0891,0x0007,0x66FA,0x7000,0x3340,0x0002 + .word 0x3340,0x0004,0x3340,0x0006,0x2340,0x0008,0x2340,0x000C + .word 0x3340,0x0010,0x3340,0x0030,0x3340,0x0032,0x3340,0x0038 + .word 0x3340,0x0080,0x3340,0x0082,0x08A9,0x0000,0x008B,0x66F8 + .word 0x6100,0xFF12,0x08E9,0x0000,0x008B,0x67F8,0x6100,0xFF06 + .word 0x08A9,0x0000,0x008B,0x6100,0xFF3C,0x303C,0x0040,0x2229 + .word 0x0020,0x0C81,0x5351,0x4552,0x6700,0x0092,0x303C,0x0080 + .word 0x2229,0x0020,0x0C81,0x5344,0x4552,0x6700,0x0080,0x21FC + .word 0x0088,0x02A2,0x0070,0x303C,0x0002,0x7200,0x122D,0x0001 + .word 0x1429,0x0080,0xE14A,0x8242,0x0801,0x000F,0x660A,0x0801 + .word 0x0006,0x6700,0x0058,0x6008,0x0801,0x0006,0x6600,0x004E + .word 0x7020,0x41F9,0x0088,0x0000,0x3C28,0x018E,0x4A46,0x6700 + .word 0x0010,0x3429,0x0028,0x0C42,0x0000,0x67F6,0xB446,0x662C + .word 0x7000,0x2340,0x0028,0x2340,0x002C,0x3E14,0x2C7C,0xFFFF + .word 0xFFC0,0x4CD6,0x7FF9,0x44FC,0x0000,0x6014,0x43F9,0x00A1 + .word 0x5100,0x3340,0x0006,0x303C,0x8000,0x6004,0x44FC,0x0001 + +!----------------------------------------------------------------------- +! At this point (0x800), the Work RAM is clear, the VDP initialized, the +! VRAM/VSRAM/CRAM cleared, the Z80 initialized, the 32X initialized, +! both 32X framebuffers cleared, the 32X palette cleared, the SH2s +! checked for a startup error, the adapter TV mode matches the MD TV +! mode, and the ROM checksum checked. If any error is detected, the +! carry is set, otherwise it is cleared. The 68000 main code is now +! entered. +!----------------------------------------------------------------------- + + .incbin "src-md/m68k.bin" /* all 68000 code & data, compiled to 0x880800/0xFF0000 */ + + + .global _gLightmap_base + .global _gLightmap + + .data +_gLightmap_base: + .space 128 +_gLightmap: + .space 256 * 32 + +!----------------------------------------------------------------------- +! Primary Vector Base Table +!----------------------------------------------------------------------- + + .equ pri_stack, 0x0603F800 + .equ sec_stack, 0x06040000 + + .align 4 +pri_vbr: + .long pri_start /* Cold Start PC */ + .long pri_stack /* Cold Start SP */ + .long pri_start /* Manual Reset PC */ + .long pri_stack /* Manual Reset SP */ + .long pri_err /* Illegal instruction */ + .long 0x00000000 /* reserved */ + .long pri_err /* Invalid slot instruction */ + .long 0x00000000 /* reserved */ + .long 0x00000000 /* reserved */ + .long pri_err /* CPU address error */ + .long pri_err /* DMA address error */ + .long pri_err /* NMI vector */ + .long pri_err /* User break vector */ + .space 76 /* reserved */ + .long pri_err /* TRAPA #32 */ + .long pri_err /* TRAPA #33 */ + .long pri_err /* TRAPA #34 */ + .long pri_err /* TRAPA #35 */ + .long pri_err /* TRAPA #36 */ + .long pri_err /* TRAPA #37 */ + .long pri_err /* TRAPA #38 */ + .long pri_err /* TRAPA #39 */ + .long pri_err /* TRAPA #40 */ + .long pri_err /* TRAPA #41 */ + .long pri_err /* TRAPA #42 */ + .long pri_err /* TRAPA #43 */ + .long pri_err /* TRAPA #44 */ + .long pri_err /* TRAPA #45 */ + .long pri_err /* TRAPA #46 */ + .long pri_err /* TRAPA #47 */ + .long pri_err /* TRAPA #48 */ + .long pri_err /* TRAPA #49 */ + .long pri_err /* TRAPA #50 */ + .long pri_err /* TRAPA #51 */ + .long pri_err /* TRAPA #52 */ + .long pri_err /* TRAPA #53 */ + .long pri_err /* TRAPA #54 */ + .long pri_err /* TRAPA #55 */ + .long pri_err /* TRAPA #56 */ + .long pri_err /* TRAPA #57 */ + .long pri_err /* TRAPA #58 */ + .long pri_err /* TRAPA #59 */ + .long pri_err /* TRAPA #60 */ + .long pri_err /* TRAPA #61 */ + .long pri_err /* TRAPA #62 */ + .long pri_err /* TRAPA #63 */ + .long pri_irq /* FRT interrupt (Level 1) */ + .long pri_irq /* WDT interrupt (Level 2 & 3) */ + .long pri_irq /* DMA interrupt (Level 4 & 5) */ + .long pri_irq /* PWM interupt (Level 6 & 7) */ + .long pri_irq /* Command interupt (Level 8 & 9) */ + .long pri_irq /* H Blank interupt (Level 10 & 11) */ + .long pri_irq /* V Blank interupt (Level 12 & 13) */ + .long pri_irq /* Reset Button (Level 14 & 15) */ + +!----------------------------------------------------------------------- +! Secondary Vector Base Table +!----------------------------------------------------------------------- + +sec_vbr: + .long sec_start /* Cold Start PC */ + .long sec_stack /* Cold Start SP */ + .long sec_start /* Manual Reset PC */ + .long sec_stack /* Manual Reset SP */ + .long sec_err /* Illegal instruction */ + .long 0x00000000 /* reserved */ + .long sec_err /* Invalid slot instruction */ + .long 0x00000000 /* reserved */ + .long 0x00000000 /* reserved */ + .long sec_err /* CPU address error */ + .long sec_err /* DMA address error */ + .long sec_err /* NMI vector */ + .long sec_err /* User break vector */ + .space 76 /* reserved */ + .long sec_err /* TRAPA #32 */ + .long sec_err /* TRAPA #33 */ + .long sec_err /* TRAPA #34 */ + .long sec_err /* TRAPA #35 */ + .long sec_err /* TRAPA #36 */ + .long sec_err /* TRAPA #37 */ + .long sec_err /* TRAPA #38 */ + .long sec_err /* TRAPA #39 */ + .long sec_err /* TRAPA #40 */ + .long sec_err /* TRAPA #41 */ + .long sec_err /* TRAPA #42 */ + .long sec_err /* TRAPA #43 */ + .long sec_err /* TRAPA #44 */ + .long sec_err /* TRAPA #45 */ + .long sec_err /* TRAPA #46 */ + .long sec_err /* TRAPA #47 */ + .long sec_err /* TRAPA #48 */ + .long sec_err /* TRAPA #49 */ + .long sec_err /* TRAPA #50 */ + .long sec_err /* TRAPA #51 */ + .long sec_err /* TRAPA #52 */ + .long sec_err /* TRAPA #53 */ + .long sec_err /* TRAPA #54 */ + .long sec_err /* TRAPA #55 */ + .long sec_err /* TRAPA #56 */ + .long sec_err /* TRAPA #57 */ + .long sec_err /* TRAPA #58 */ + .long sec_err /* TRAPA #59 */ + .long sec_err /* TRAPA #60 */ + .long sec_err /* TRAPA #61 */ + .long sec_err /* TRAPA #62 */ + .long sec_err /* TRAPA #63 */ + .long sec_irq /* FRT interrupt (Level 1) */ + .long sec_irq /* WDT interrupt (Level 2 & 3) */ + .long sec_irq /* DMA interrupt (Level 4 & 5) */ + .long sec_irq /* PWM interupt (Level 6 & 7) */ + .long sec_irq /* Command interupt (Level 8 & 9) */ + .long sec_irq /* H Blank interupt (Level 10 & 11 */ + .long sec_irq /* V Blank interupt (Level 12 & 13) */ + .long sec_irq /* Reset Button (Level 14 & 15) */ + +!----------------------------------------------------------------------- +! The Primary SH2 starts here +!----------------------------------------------------------------------- + +pri_start: + ! clear interrupt flags + mov.l _pri_int_clr,r1 + mov.w r0,@-r1 /* PWM INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* CMD INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* H INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* V INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* VRES INT clear */ + mov.w r0,@r1 + + mov.l _pri_sh2_frtctl,r1 /* Set Free Run Timer */ + mov #0x00,r0 + mov.b r0,@(0x00,r1) /* TIER = ints disabled */ + mov #0xE2,r0 + mov.b r0,@(0x07,r1) /* TOCR = select OCRA, output 1 on compare match */ + mov #0x00,r0 + mov.b r0,@(0x04,r1) /* OCR_H */ + mov #0x01,r0 + mov.b r0,@(0x05,r1) /* OCR_L => OCRA = 0x0001 */ + mov #0,r0 + mov.b r0,@(0x06,r1) /* TCR = input captured on falling edge, CKS = Fs/8 */ + mov #1,r0 + mov.b r0,@(0x01,r1) /* TCSR = clear FRC on match OCRA */ + mov #0x00,r0 + mov.b r0,@(0x03,r1) /* FRC_L */ + mov.b r0,@(0x02,r1) /* FRC_H => clear FRC */ + + mov.l _pri_stk,r15 + + ! purge cache and turn it off + mov.l _pri_cctl,r0 + mov #0x10,r1 /* CP = cache purge, /CE = cache disabled */ + mov.b r1,@r0 + + ! clear bss + mov #0,r0 + mov.l _bss_dst,r1 + mov.l _bss_end,r2 +0: + mov.b r0,@r1 + add #1,r1 + cmp/eq r1,r2 + bf 0b + + ! wait for 68000 to finish init + mov.l _pri_sts,r0 + mov.l _pri_ok,r1 +1: + mov.l @r0,r2 + nop + nop + cmp/eq r1,r2 + bt 1b + + ! let Secondary SH2 run + mov #0,r1 + mov.l r1,@(4,r0) /* clear secondary status */ + + mov #0x80,r0 + mov.l _pri_adapter,r1 + mov.b r0,@r1 /* set FM */ + mov #0x08,r0 /* vbi enabled */ + mov.b r0,@(1,r1) /* set int enables */ + mov #0x10,r0 + ldc r0,sr /* allow ints */ + + ! purge cache, turn it on, and run main() + mov.l _pri_cctl,r0 + mov #0x11,r1 /* CP = cache purge, CE = cache enabled */ + mov.b r1,@r0 + + mov.l _pri_go,r0 + jmp @r0 + nop + + .align 2 +_pri_int_clr: + .long 0x2000401E /* one word passed last int clr reg */ +_pri_stk: + .long pri_stack /* Cold Start SP */ +_pri_sts: + .long 0x20004020 +_pri_sh2_frtctl: + .long 0xfffffe10 +_pri_ok: + .ascii "M_OK" +_pri_adapter: + .long 0x20004000 +_pri_cctl: + .long 0xFFFFFE92 +_pri_go: + .long _main + +_bss_dst: + .long __bss_start +_bss_end: + .long __bss_end + +!----------------------------------------------------------------------- +! Primary exception handler +!----------------------------------------------------------------------- + +pri_err: + rte + nop + +!----------------------------------------------------------------------- +! Primary IRQ handler +!----------------------------------------------------------------------- + +pri_irq: + mov.l r0,@-r15 + mov.l r1,@-r15 + mov.l r2,@-r15 + + stc sr,r1 /* SR holds IRQ level in I3-I0 */ + mov.w p_int_off,r2 + ldc r2,sr /* disallow ints */ + + mov.l p_sys_frt_tocr,r2 + mov #0xE0,r0 /* TOCR = select OCRA, output 0 on compare match */ + mov.b r0,@r2 + mov.b @r2,r0 + + sts.l pr,@-r15 + mov r1,r0 + shlr2 r0 + and #0x3C,r0 /* int level to table offset */ + mov.l p_int_jtable,r1 + mov.l @(r0,r1),r0 + jsr @r0 + nop + + lds.l @r15+,pr + mov.l @r15+,r2 + mov.l @r15+,r1 + mov.l @r15+,r0 + rte + nop + + .align 2 +p_sys_frt_tocr: + .long 0xFFFFFE17 +p_int_jtable: + .long _p_int_jtable +p_int_off: + .word 0x00F0 + + .align 4 +_p_int_jtable: + .long pri_no_irq /* level 0 (ILL) */ + .long pri_no_irq /* level 1 (FRT) */ + .long pri_wdt_irq /* level 2 (WDT) */ + .long pri_wdt_irq /* level 3 (WDT) */ + .long pri_dma_irq /* level 4 (DMA) */ + .long pri_dma_irq /* level 5 (DMA) */ + .long pri_pwm_irq /* level 6 (PWM) */ + .long pri_pwm_irq /* level 7 (PWM) */ + .long pri_cmd_irq /* level 8 (CMD) */ + .long pri_cmd_irq /* level 9 (CMD) */ + .long pri_h_irq /* level 10 (HBI) */ + .long pri_h_irq /* level 11 (HBI) */ + .long pri_v_irq /* level 12 (VBI) */ + .long pri_v_irq /* level 13 (VBI) */ + .long pri_vres_irq /* level 14 (VRES) */ + .long pri_vres_irq /* level 15 (VRES) */ + +!----------------------------------------------------------------------- +! Primary No IRQ handler +!----------------------------------------------------------------------- + +pri_no_irq: + rts + nop + +!----------------------------------------------------------------------- +! Primary V Blank IRQ handler +!----------------------------------------------------------------------- + +pri_v_irq: + ! bump ints if necessary + mov.l pvi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l pvi_mars_adapter,r1 + mov.w r0,@(0x16,r1) /* clear V IRQ */ + + ! handle V IRQ - save registers + sts.l pr,@-r15 + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + sts.l mach,@-r15 + sts.l macl,@-r15 + + mov.l pvbi_handler_ptr,r0 + jsr @r0 + nop + + ! restore registers + lds.l @r15+,macl + lds.l @r15+,mach + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + mov.l @r15+,r3 + lds.l @r15+,pr + rts + nop + + .align 2 +pvi_mars_adapter: + .long 0x20004000 +pvbi_handler_ptr: + .long _pri_vbi_handler +pvi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Primary H Blank IRQ handler +!----------------------------------------------------------------------- + +pri_h_irq: + ! bump ints if necessary + mov.l phi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l phi_mars_adapter,r1 + mov.w r0,@(0x18,r1) /* clear H IRQ */ + nop + nop + nop + nop + + ! handle H IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +phi_mars_adapter: + .long 0x20004000 +phi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Primary Command IRQ handler +!----------------------------------------------------------------------- + +pri_cmd_irq: + ! bump ints if necessary + mov.l pci_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l pci_mars_adapter,r1 + mov.w r0,@(0x1A,r1) /* clear CMD IRQ */ + nop + nop + nop + nop + + ! handle CMD IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +pci_mars_adapter: + .long 0x20004000 +pci_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Primary PWM IRQ handler +!----------------------------------------------------------------------- + +pri_pwm_irq: + ! bump ints if necessary + mov.l ppi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l ppi_mars_adapter,r1 + mov.w r0,@(0x1C,r1) /* clear PWM IRQ */ + nop + nop + nop + nop + + ! handle PWM IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +ppi_mars_adapter: + .long 0x20004000 +ppi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Primary DMA IRQ handler +!----------------------------------------------------------------------- + +pri_dma_irq: + ! bump ints if necessary + mov.l pdi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + ! handle DMA IRQ + + rts + nop + + .align 2 +pdi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Primary WDT IRQ handler +!----------------------------------------------------------------------- + +pri_wdt_irq: + ! bump ints if necessary + mov.l pwi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l pwi_sh2_wdtctl,r1 + mov.b @r1,r0 /* read WTCSR */ + tst #0x80,r0 /* check OVF */ + bt 1f /* no overflow */ + mov.w pwi_clr_ovf,r0 + mov.w r0,@r1 /* clear OVF */ + + ! handle WDT overflow + mov.l pwi_ovf_count,r1 + mov.l @r1,r0 + add #1,r0 + mov.l r0,@r1 +1: + rts + nop + + .align 2 +pwi_sh2_frtctl: + .long 0xfffffe10 +pwi_sh2_wdtctl: + .long 0xfffffe80 +pwi_ovf_count: + .long _mars_pwdt_ovf_count +pwi_clr_ovf: + .word 0xa53e /* A5 = sel WTCSR, 3E = clr OVF, IT mode, timer enabled, clksel = Fs/4096 */ + +!----------------------------------------------------------------------- +! Primary RESET IRQ handler +!----------------------------------------------------------------------- + +pri_vres_irq: + mov.l pvri_mars_adapter,r1 + mov.w r0,@(0x14,r1) /* clear VRES IRQ */ + + mov #0x0F,r0 + shll2 r0 + shll2 r0 + ldc r0,sr /* disallow ints */ + + mov.l pvri_pri_stk,r15 + mov.l pvri_pri_vres,r0 + jmp @r0 + nop + + .align 2 +pvri_mars_adapter: + .long 0x20004000 +pvri_pri_stk: + .long pri_stack /* Cold Start SP */ +pvri_pri_vres: + .long pri_reset + +!----------------------------------------------------------------------- +! The Secondary SH2 starts here +!----------------------------------------------------------------------- + +sec_start: + ! clear interrupt flags + mov.l _sec_int_clr,r1 + mov.w r0,@-r1 /* PWM INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* CMD INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* H INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* V INT clear */ + mov.w r0,@r1 + mov.w r0,@-r1 /* VRES INT clear */ + mov.w r0,@r1 + + mov.l _sec_sh2_frtctl,r1 /* Set Free Run Timer */ + mov #0x00,r0 + mov.b r0,@(0x00,r1) /* TIER = ints disabled */ + mov #0xE2,r0 + mov.b r0,@(0x07,r1) /* TOCR = select OCRA, output 1 on compare match */ + mov #0x00,r0 + mov.b r0,@(0x04,r1) /* OCR_H */ + mov #0x01,r0 + mov.b r0,@(0x05,r1) /* OCR_L => OCRA = 0x0001 */ + mov #0,r0 + mov.b r0,@(0x06,r1) /* TCR = input captured on falling edge, CKS = Fs/8 */ + mov #1,r0 + mov.b r0,@(0x01,r1) /* TCSR = clear FRC on match OCRA */ + mov #0x00,r0 + mov.b r0,@(0x03,r1) /* FRC_L */ + mov.b r0,@(0x02,r1) /* FRC_H => clear FRC */ + + mov.l _sec_stk,r15 + + ! wait for Primary SH2 and 68000 to finish init + mov.l _sec_sts,r0 + mov.l _sec_ok,r1 +1: + mov.l @r0,r2 + nop + nop + cmp/eq r1,r2 + bt 1b + + mov.l _sec_adapter,r1 + mov #0x00,r0 + mov.b r0,@(1,r1) /* set int enables (different from primary despite same address!) */ + mov #0x0D,r0 + shll2 r0 + shll2 r0 + ldc r0,sr /* disallow ints */ + +! purge cache, turn it on, and run secondary() + mov.l _sec_cctl,r0 + mov #0x11,r1 /* CP = cache purge, CE = cache enabled */ + mov.b r1,@r0 + + mov.l _sec_go,r0 + jmp @r0 + nop + + .align 2 +_sec_int_clr: + .long 0x2000401E /* one word passed last int clr reg */ +_sec_stk: + .long sec_stack /* Cold Start SP */ +_sec_sts: + .long 0x20004024 +_sec_sh2_frtctl: + .long 0xfffffe10 +_sec_ok: + .ascii "S_OK" +_sec_adapter: + .long 0x20004000 +_sec_cctl: + .long 0xFFFFFE92 +_sec_go: + .long _secondary + +!----------------------------------------------------------------------- +! Secondary exception handler +!----------------------------------------------------------------------- + +sec_err: + rte + nop + +!----------------------------------------------------------------------- +! Secondary IRQ handler +!----------------------------------------------------------------------- + +sec_irq: + mov.l r0,@-r15 + mov.l r1,@-r15 + mov.l r2,@-r15 + + stc sr,r1 /* SR holds IRQ level in I3-I0 */ + mov.w s_int_off,r2 + ldc r2,sr /* disallow ints */ + + mov.l s_sys_frt_tocr,r2 + mov #0xE0,r0 /* TOCR = select OCRA, output 0 on compare match */ + mov.b r0,@r2 + mov.b @r2,r0 + + sts.l pr,@-r15 + mov r1,r0 + shlr2 r0 + and #0x3C,r0 /* int level to table offset */ + mov.l s_int_jtable,r1 + mov.l @(r0,r1),r0 + jsr @r0 + nop + + lds.l @r15+,pr + mov.l @r15+,r2 + mov.l @r15+,r1 + mov.l @r15+,r0 + rte + nop + + .align 2 +s_sys_frt_tocr: + .long 0xFFFFFE17 +s_int_jtable: + .long _s_int_jtable +s_int_off: + .word 0x00F0 + + .align 4 +_s_int_jtable: + .long sec_no_irq /* level 0 (ILL) */ + .long sec_no_irq /* level 1 (FRT) */ + .long sec_wdt_irq /* level 2 (WDT) */ + .long sec_wdt_irq /* level 3 (WDT) */ + .long sec_dma_irq /* level 4 (DMA) */ + .long sec_dma_irq /* level 5 (DMA) */ + .long sec_pwm_irq /* level 6 (PWM) */ + .long sec_pwm_irq /* level 7 (PWM) */ + .long sec_cmd_irq /* level 8 (CMD) */ + .long sec_cmd_irq /* level 9 (CMD) */ + .long sec_h_irq /* level 10 (HBI) */ + .long sec_h_irq /* level 11 (HBI) */ + .long sec_v_irq /* level 12 (VBI) */ + .long sec_v_irq /* level 13 (VBI) */ + .long sec_vres_irq /* level 14 (VRES) */ + .long sec_vres_irq /* level 15 (VRES) */ + +!----------------------------------------------------------------------- +! Secondary No IRQ handler +!----------------------------------------------------------------------- + +sec_no_irq: + rts + nop + +!----------------------------------------------------------------------- +! Secondary V Blank IRQ handler +!----------------------------------------------------------------------- + +sec_v_irq: + ! bump ints if necessary + mov.l svi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l svi_mars_adapter,r1 + mov.w r0,@(0x16,r1) /* clear V IRQ */ + nop + nop + nop + nop + + ! handle V IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +svi_mars_adapter: + .long 0x20004000 +svi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Secondary H Blank IRQ handler +!----------------------------------------------------------------------- + +sec_h_irq: + ! bump ints if necessary + mov.l shi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l shi_mars_adapter,r1 + mov.w r0,@(0x18,r1) /* clear H IRQ */ + nop + nop + nop + nop + + ! handle H IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +shi_mars_adapter: + .long 0x20004000 +shi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Secondary Command IRQ handler +!----------------------------------------------------------------------- + +sec_cmd_irq: + ! bump ints if necessary + mov.l sci_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l sci_mars_adapter,r1 + mov.w r0,@(0x1A,r1) /* clear CMD IRQ */ + nop + nop + nop + nop + + ! handle CMD IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +sci_mars_adapter: + .long 0x20004000 +sci_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Secondary PWM IRQ handler +!----------------------------------------------------------------------- + +sec_pwm_irq: + ! bump ints if necessary + mov.l spi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l spi_mars_adapter,r1 + mov.w r0,@(0x1C,r1) /* clear PWM IRQ */ + nop + nop + nop + nop + + ! handle PWM IRQ (remove nops if more than 8 cycles) + + rts + nop + + .align 2 +spi_mars_adapter: + .long 0x20004000 +spi_sh2_frtctl: + .long 0xfffffe10 + +!----------------------------------------------------------------------- +! Secondary DMA IRQ handler +!----------------------------------------------------------------------- + +sec_dma_irq: + ! bump ints if necessary + mov.l sdi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + ! handle DMA IRQ + sts.l pr,@-r15 + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + sts.l mach,@-r15 + sts.l macl,@-r15 + + mov.l sdi_dma_handler,r0 + jsr @r0 + nop + + ! restore registers + lds.l @r15+,macl + lds.l @r15+,mach + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + mov.l @r15+,r3 + lds.l @r15+,pr + + rts + nop + + .align 2 +sdi_sh2_frtctl: + .long 0xfffffe10 +sdi_dma_handler: + .long _sec_dma1_handler + +!----------------------------------------------------------------------- +! Secondary WDT IRQ handler +!----------------------------------------------------------------------- + +sec_wdt_irq: + ! bump ints if necessary + mov.l swi_sh2_frtctl,r1 + mov #0xE2,r0 /* TOCR = select OCRA, output 1 on compare match */ + mov.b r0,@(0x07,r1) /* write TOCR */ + mov.b @(0x07,r1),r0 /* read TOCR */ + + mov.l swi_sh2_wdtctl,r1 + mov.b @r1,r0 /* read WTCSR */ + tst #0x80,r0 /* check OVF */ + bt 1f /* no overflow */ + mov.w swi_clr_ovf,r0 + mov.w r0,@r1 /* clear OVF */ + + ! handle WDT overflow + mov.l swi_ovf_count,r1 + mov.l @r1,r0 + add #1,r0 + mov.l r0,@r1 +1: + rts + nop + + .align 2 +swi_sh2_frtctl: + .long 0xfffffe10 +swi_sh2_wdtctl: + .long 0xfffffe80 +swi_ovf_count: + .long _mars_swdt_ovf_count +swi_clr_ovf: + .word 0xa53e /* A5 = sel WTCSR, 3E = clr OVF, IT mode, timer enabled, clksel = Fs/4096 */ + +!----------------------------------------------------------------------- +! Secondary RESET IRQ handler +!----------------------------------------------------------------------- + +sec_vres_irq: + mov.l svri_mars_adapter,r1 + mov.w r0,@(0x14,r1) /* clear VRES IRQ */ + + mov #0x0F,r0 + shll2 r0 + shll2 r0 + ldc r0,sr /* disallow ints */ + + mov.l svri_sec_stk,r15 + mov.l svri_sec_vres,r0 + jmp @r0 + nop + + .align 2 +svri_mars_adapter: + .long 0x20004000 +svri_sec_stk: + .long sec_stack /* Cold Start SP */ +svri_sec_vres: + .long sec_reset + + +!----------------------------------------------------------------------- +!----------------------------------------------------------------------- +! Support Functions +!----------------------------------------------------------------------- +!----------------------------------------------------------------------- + +! void fast_memcpy(int *dst, int *src, int len); +! Fast memcpy function - copies longs, runs from sdram for speed +! On entry: r4 = dst, r5 = src, r6 = len (in longs) + + .align 4 + .global _fast_memcpy +_fast_memcpy: + mov.l @r5+,r3 + mov.l r3,@r4 + dt r6 + bf/s _fast_memcpy + add #4,r4 + rts + nop + + +! Fast memset function - sets long values, runs from sdram for speed +! On entry: r4 = dst, r5 = value, r6 = len (in longs) + + .align 4 + .global _fast_memset +_fast_memset: + mov.l r5,@r4 + dt r6 + bf/s _fast_memset + add #4,r4 + rts + nop + + +! void CacheControl(int mode); +! Cache control function +! On entry: r4 = cache mode => 0x10 = CP, 0x08 = TW, 0x01 = CE + + .align 4 + .global _CacheControl +_CacheControl: + mov.l _sh2_cctl,r0 + mov.b r4,@r0 + rts + nop + + .align 2 + +_sh2_cctl: + .long 0xFFFFFE92 + + +! int SetSH2SR(int level); +! On entry: r4 = new irq level +! On exit: r0 = old irq level + .align 4 + .global _SetSH2SR +_SetSH2SR: + stc sr,r1 + mov #0x0F,r0 + shll2 r0 + shll2 r0 + and r0,r1 /* just the irq mask */ + shlr2 r1 + shlr2 r1 + not r0,r0 + stc sr,r2 + and r0,r2 + shll2 r4 + shll2 r4 + or r4,r2 + ldc r2,sr + rts + mov r1,r0 + +!----------------------------------------------------------------------- +! Primary and Secondary RESET code +!----------------------------------------------------------------------- + + .align 2 + + .text + +pri_reset: + ! do any primary SH2 specific reset code here + + mov.l sec_st,r0 + mov.l sec_ok,r1 +0: + mov.l @r0,r2 + nop + nop + cmp/eq r1,r2 + bf 0b /* wait for secondary sh2 */ + + ! recopy rom data to sdram + mov.l rom_header,r1 + mov.l @r1,r2 /* src relative to start of rom */ + mov.l @(4,r1),r3 /* dst relative to start of sdram */ + mov.l @(8,r1),r4 /* size (longword aligned) */ + mov.l rom_start,r1 + add r1,r2 + mov.l sdram_start,r1 + add r1,r3 + shlr2 r4 /* number of longs */ + add #-1,r4 +1: + mov.l @r2+,r0 + mov.l r0,@r3 + add #4,r3 + dt r4 + bf 1b + + mov.l pri_st,r0 + mov.l pri_ok,r1 + mov.l r1,@r0 /* tell everyone reset complete */ + + mov.l pri_go,r0 + jmp @r0 + nop + +sec_reset: + ! do any secondary SH2 specific reset code here + + mov.l sec_st,r0 + mov.l sec_ok,r1 + mov.l r1,@r0 /* tell primary to start reset */ + + mov.l pri_st,r0 + mov.l pri_ok,r1 +0: + mov.l @r0,r2 + nop + nop + cmp/eq r1,r2 + bf 0b /* wait for primary to do the work */ + + mov.l sec_go,r0 + jmp @r0 + nop + + .align 2 +pri_st: + .long 0x20004020 +pri_ok: + .ascii "M_OK" +pri_go: + .long pri_start +rom_header: + .long 0x220003D4 +rom_start: + .long 0x22000000 +sdram_start: + .long 0x26000000 + +sec_st: + .long 0x20004024 +sec_ok: + .ascii "S_OK" +sec_go: + .long sec_start + + +! this suppresses a warning in the linker about missing start() + + .global _start +_start: diff --git a/src/platform/32x/data/GYM.PKD b/src/platform/32x/data/GYM.PKD new file mode 100644 index 00000000..1afe9b90 Binary files /dev/null and b/src/platform/32x/data/GYM.PKD differ diff --git a/src/platform/32x/data/LEVEL1.PKD b/src/platform/32x/data/LEVEL1.PKD new file mode 100644 index 00000000..46a3ff3f Binary files /dev/null and b/src/platform/32x/data/LEVEL1.PKD differ diff --git a/src/platform/32x/data/LEVEL2.PKD b/src/platform/32x/data/LEVEL2.PKD new file mode 100644 index 00000000..bddaf9a8 Binary files /dev/null and b/src/platform/32x/data/LEVEL2.PKD differ diff --git a/src/platform/32x/deploy.sh b/src/platform/32x/deploy.sh new file mode 100644 index 00000000..285a2344 --- /dev/null +++ b/src/platform/32x/deploy.sh @@ -0,0 +1,3 @@ +make clean +make +/c/RetroArch/retroarch.exe -L C:\\RetroArch\\cores\\picodrive_libretro.dll OpenLara.32x diff --git a/src/platform/32x/main.cpp b/src/platform/32x/main.cpp new file mode 100644 index 00000000..42f1f7e8 --- /dev/null +++ b/src/platform/32x/main.cpp @@ -0,0 +1,245 @@ +const void* TRACKS_IMA; +const void* TITLE_SCR; + +extern void* LEVEL1_PKD; + +#include "game.h" + +volatile unsigned mars_frt_ovf_count = 0; + +extern "C" { + volatile uint32 mars_pwdt_ovf_count = 0; + volatile uint32 mars_swdt_ovf_count = 0; +} + +int32 gFrameIndex = 0; + +#define SH2_WDT_RTCSR (*(volatile unsigned char *)0xFFFFFE80) +#define SH2_WDT_RTCNT (*(volatile unsigned char *)0xFFFFFE81) +#define SH2_WDT_RRSTCSR (*(volatile unsigned char *)0xFFFFFE83) +#define SH2_WDT_WTCSR_TCNT (*(volatile unsigned short *)0xFFFFFE80) +#define SH2_WDT_WRWOVF_RST (*(volatile unsigned short *)0xFFFFFE82) +#define SH2_WDT_VCR (*(volatile unsigned short *)0xFFFFFEE4) + +int32 g_timer; +int32 fps; + +void osSetPalette(const uint16* palette) +{ + void *dst = (void*)&MARS_CRAM; + memcpy(dst, palette, 256 * 2); +} + +int32 osGetSystemTimeMS() +{ + return int32((mars_pwdt_ovf_count << 8) | SH2_WDT_RTCNT); +} + +bool osSaveSettings() +{ + return false; +} + +bool osLoadSettings() +{ + return false; +} + +bool osCheckSave() +{ + return false; +} + +bool osSaveGame() +{ + return false; +} + +bool osLoadGame() +{ + return false; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) +{ + // nope +} + +void updateInput() +{ + keys = 0; + + uint16 mask = MARS_SYS_COMM8; + if (mask & SEGA_CTRL_UP) keys |= IK_UP; + if (mask & SEGA_CTRL_RIGHT) keys |= IK_RIGHT; + if (mask & SEGA_CTRL_DOWN) keys |= IK_DOWN; + if (mask & SEGA_CTRL_LEFT) keys |= IK_LEFT; + if (mask & SEGA_CTRL_A) keys |= IK_A; + if (mask & SEGA_CTRL_B) keys |= IK_B; + if (mask & SEGA_CTRL_C) keys |= IK_C; + if (mask & SEGA_CTRL_X) keys |= IK_X; + if (mask & SEGA_CTRL_Y) keys |= IK_Y; + if (mask & SEGA_CTRL_Z) keys |= IK_Z; + if (mask & SEGA_CTRL_START) keys |= IK_START; + if (mask & SEGA_CTRL_MODE) keys |= IK_SELECT; +} + +const void* osLoadScreen(LevelID id) +{ + return TITLE_SCR; +} + +const void* osLoadLevel(LevelID id) +{ + return (void*)LEVEL1_PKD; // TODO +} + +uint16 pageIndex = 0; + +void pageWait() +{ + while ((MARS_VDP_FBCTL & MARS_VDP_FS) != pageIndex); +} + +void pageFlip() +{ + pageIndex ^= 1; + MARS_VDP_FBCTL = pageIndex; +} + +void pageClear() +{ + dmaFill((uint8*)&MARS_FRAMEBUFFER + 0x200, 0, FRAME_WIDTH * FRAME_HEIGHT); +} + +extern "C" void pri_vbi_handler() +{ + gFrameIndex++; +} + +extern void flush_ot(int32 bit); + +extern "C" void secondary() +{ + // init DMA + SH2_DMA_SAR0 = 0; + SH2_DMA_DAR0 = 0; + SH2_DMA_TCR0 = 0; + SH2_DMA_CHCR0 = 0; + SH2_DMA_DRCR0 = 0; + SH2_DMA_SAR1 = 0; + SH2_DMA_DAR1 = 0; + SH2_DMA_TCR1 = 0; + SH2_DMA_CHCR1 = 0; + SH2_DMA_DRCR1 = 0; + SH2_DMA_DMAOR = 1; // enable DMA + + SH2_DMA_VCR1 = 66; // set exception vector for DMA channel 1 + SH2_INT_IPRA = (SH2_INT_IPRA & 0xF0FF) | 0x0400; // set DMA INT to priority 4 + + while (1) + { + int cmd; + while ((cmd = MARS_SYS_COMM4) == 0); + + switch (cmd) + { + case MARS_CMD_CLEAR: + pageClear(); + break; + case MARS_CMD_FLUSH: + flush_ot(1); + break; + } + + MARS_SYS_COMM4 = 0; + } +} + +extern "C" void sec_dma1_handler() +{ + SH2_DMA_CHCR1; // read TE + SH2_DMA_CHCR1 = 0; // clear TE +} + +int main() +{ + while ((MARS_SYS_INTMSK & MARS_SH2_ACCESS_VDP) == 0); + MARS_VDP_DISPMODE = MARS_224_LINES | MARS_VDP_MODE_256; + + for (int32 page = 0; page < 2; page++) + { + pageFlip(); + pageWait(); + + volatile uint16* lineTable = &MARS_FRAMEBUFFER; + uint16 wordOffset = 0x100; + + for (int32 i = 0; i < 256; i++) + { + lineTable[i] = wordOffset; + + if (i < FRAME_HEIGHT - 1) { + wordOffset += FRAME_WIDTH / 2; + } + } + + pageClear(); + } + + SH2_WDT_VCR = (65<<8) | (SH2_WDT_VCR & 0x00FF); // set exception vector for WDT + SH2_INT_IPRA = (SH2_INT_IPRA & 0xFF0F) | 0x0020; // set WDT INT to priority 2 + + SH2_WDT_WTCSR_TCNT = 0x5A00; + SH2_WDT_WTCSR_TCNT = 0xA53E; + + MARS_SYS_COMM4 = 0; + + gameInit(); + + int32 lastFrame = (gFrameIndex >> 1) - 1; + int32 fpsCounter = 0; + int32 fpsFrame = gFrameIndex; + int32 vsyncRate = (MARS_VDP_DISPMODE & MARS_NTSC_FORMAT) ? 60 : 50; + + while (1) + { + int32 frame = *(volatile int32 *)&gFrameIndex; + + if (frame - fpsFrame >= vsyncRate) + { + fpsFrame += vsyncRate; + fps = fpsCounter; + fpsCounter = 0; + } + + if (vsyncRate == 50) + { + frame = frame * 6 / 5; // PAL fix + } + + frame >>= 1; + + int32 delta = frame - lastFrame; + + if (!delta) + continue; + + lastFrame = frame; + + updateInput(); + + gameUpdate(delta); + + pageWait(); + + gameRender(); + + pageFlip(); + + fpsCounter++; + } + + return 0; +} + diff --git a/src/platform/32x/rasterizer.h b/src/platform/32x/rasterizer.h new file mode 100644 index 00000000..4a893347 --- /dev/null +++ b/src/platform/32x/rasterizer.h @@ -0,0 +1,773 @@ +#ifndef H_RASTERIZER_MODE13 +#define H_RASTERIZER_MODE13 + +#include "common.h" + +#ifdef ALIGNED_LIGHTMAP + #ifdef __32X__ + #define LIGHTMAP_ADDR (0x06000000) + #else + #define LIGHTMAP_ADDR intptr_t(gLightmap) + #endif +#endif + +#define CACHE_ON(ptr) ptr = &ptr[-0x20000000 / sizeof(ptr[0])]; +#define CACHE_OFF(ptr) ptr = &ptr[0x20000000 / sizeof(ptr[0])]; + +extern uint8 gLightmap[256 * 32]; + +extern "C" { + void rasterize_dummy_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeS_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeF_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeFT_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeGT_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeFTA_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeGTA_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeLineH_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeLineV_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + void rasterizeFillS_asm(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); +} + +#define rasterize_dummy rasterize_dummy_asm +#define rasterizeS rasterizeS_c +#define rasterizeF rasterizeF_c +#define rasterizeFT rasterizeFT_c +#define rasterizeGT rasterizeGT_c +#define rasterizeFTA rasterizeFTA_c +#define rasterizeGTA rasterizeGTA_c +#define rasterizeSprite rasterizeSprite_c +#define rasterizeLineH rasterizeLineH_c +#define rasterizeLineV rasterizeLineV_c +#define rasterizeFillS rasterizeFillS_c + +extern "C" void rasterizeS_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + const uint8* ft_lightmap = &gLightmap[0x1A00]; + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile ColorIndex* ptr = (ColorIndex*)pixel + x1; + + if (x1 & 1) + { + ptr[0] = ft_lightmap[ptr[0]]; + ptr++; + width--; + } + + if (width & 1) + { + width--; + ptr[width] = ft_lightmap[ptr[width]]; + } + + while (width) + { + uint16 p = *(uint16*)ptr; + + uint16 index = ft_lightmap[p & 0xFF]; + index |= ft_lightmap[p >> 8] << 8; + + *(uint16*)ptr = index; + ptr += 2; + width -= 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + } + } +} + +extern "C" void rasterizeF_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + uint32 color = gLightmap[(L->v.g << 8) | (uint32)R]; + color |= (color << 8); + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + R = L; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + ASSERT(L->v.y >= 0); + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + ASSERT(R->v.y >= 0); + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + *ptr++ = uint8(color); + width--; + } + + if (width & 1) + { + ptr[width - 1] = uint8(color); + } + + if (width & 2) + { + *(uint16*)ptr = color; + ptr += 2; + } + + width >>= 2; + while (width--) + { + *(uint16*)ptr = color; + ptr += 2; + *(uint16*)ptr = color; + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + } + } +} + +extern "C" void rasterizeFT_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Ldx = 0, Rdx = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + uint32 tmp = FixedInvU(width); + + uint32 duv = Rt - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + uint32 dtdx = (du & 0xFFFF0000) | (dv >> 16); + + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + *ptr++ = ft_lightmap[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + ptr[width - 1] = ft_lightmap[tile[(tmp & 0xFF00) | (tmp >> 24)]]; + } + + width >>= 1; + + #ifdef TEX_2PX + dtdx <<= 1; + + while (width--) + { + uint8 indexA = ft_lightmap[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + + *(uint16*)ptr = indexA | (indexA << 8); + + ptr += 2; + } + #else + width >>= 1; + while (width--) + { + uint8 indexA = ft_lightmap[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = ft_lightmap[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + + #ifdef CPU_BIG_ENDIAN + *(uint16*)ptr = indexB | (indexA << 8); + #else + *(uint16*)ptr = indexA | (indexB << 8); + #endif + + ptr += 2; + } + #endif + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lt += Ldt; + Rt += Rdt; + } + } +} + +extern "C" void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ +#ifdef ALIGNED_LIGHTMAP + ASSERT((intptr_t(gLightmap) & 0xFFFF) == 0); // lightmap should be 64k aligned +#endif + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Lg, Rg, Ldx = 0, Rdx = 0, Ldg = 0, Rdg = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + // 8-bit fractional part precision for Gouraud component + // has some artifacts but allow to save one reg for inner loop + // for aligned by 64k address of lightmap array + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lg = L->v.g; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + Ldg = tmp * (N->v.g - Lg) >> 8; + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + Lg <<= 8; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rg = R->v.g; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + Rdg = tmp * (N->v.g - Rg) >> 8; + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + Rg <<= 8; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + #ifdef ALIGNED_LIGHTMAP + Lg |= LIGHTMAP_ADDR; + Rg |= LIGHTMAP_ADDR; + #endif + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + int32 tmp = FixedInvU(width); + + int32 dgdx = tmp * (Rg - Lg) >> 15; + + uint32 duv = Rt - Lt; + uint32 u = tmp * int16(duv >> 16); + uint32 v = tmp * int16(duv); + uint32 dtdx = (u & 0xFFFF0000) | (v >> 16); + + int32 g = Lg; + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(g >> 8 << 8); + uint8 indexA = LMAP[tile[(t & 0xFF00) | (t >> 24)]]; + #else + uint8 indexA = gLightmap[(g >> 8 << 8) | tile[(t & 0xFF00) | (t >> 24)]]; + #endif + *ptr++ = indexA; + t += dtdx; + g += dgdx >> 1; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(Rg >> 8 << 8); + uint8 indexA = LMAP[tile[(tmp & 0xFF00) | (tmp >> 24)]]; + #else + uint8 indexA = gLightmap[(Rg >> 8 << 8) | tile[(tmp & 0xFF00) | (tmp >> 24)]]; + #endif + ptr[width - 1] = indexA; + } + + width >>= 1; + + #ifdef TEX_2PX + dtdx <<= 1; + + while (width--) + { + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(g >> 8 << 8); + uint8 indexA = LMAP[tile[(t & 0xFF00) | (t >> 24)]]; + #else + uint8 indexA = gLightmap[(g >> 8 << 8) | tile[(t & 0xFF00) | (t >> 24)]]; + #endif + *(uint16*)ptr = indexA | (indexA << 8); + ptr += 2; + t += dtdx; + g += dgdx; + } + #else + while (width--) + { + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(g >> 8 << 8); + + uint8 indexA = LMAP[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = LMAP[tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + g += dgdx; + #else + uint8 indexA = gLightmap[(g >> 8 << 8) | tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = gLightmap[(g >> 8 << 8) | tile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + g += dgdx; + #endif + + #ifdef CPU_BIG_ENDIAN + *(uint16*)ptr = indexB | (indexA << 8); + #else + *(uint16*)ptr = indexA | (indexB << 8); + #endif + + ptr += 2; + } + #endif + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lg += Ldg; + Rg += Rdg; + Lt += Ldt; + Rt += Rdt; + } + } +} + +extern "C" void rasterizeSprite_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + R++; + const uint8* ft_lightmap = &gLightmap[L->v.g << 8] + 128; + + int32 w = R->v.x - L->v.x; + if (w <= 0 || w >= DIV_TABLE_SIZE) return; + + int32 h = R->v.y - L->v.y; + if (h <= 0 || h >= DIV_TABLE_SIZE) return; + + int32 u = L->t.uv.v; + int32 v = L->t.uv.u; + + int32 iw = FixedInvU(w); + int32 ih = FixedInvU(h); + + int32 du = R->t.uv.v * iw >> 8; + int32 dv = R->t.uv.u * ih >> 8; + + if (L->v.y < 0) + { + pixel -= L->v.y * (FRAME_WIDTH >> 1); + v -= L->v.y * dv; + h += L->v.y; + } + + if (R->v.y > FRAME_HEIGHT) + { + h -= R->v.y - FRAME_HEIGHT; + } + + uint8* ptr = (uint8*)pixel; + + if (h <= 0) return; + + ptr += L->v.x; + + if (L->v.x < 0) + { + ptr -= L->v.x; + u -= L->v.x * du; + w += L->v.x; + } + + if (R->v.x > FRAME_WIDTH) + { + w -= R->v.x - FRAME_WIDTH; + } + + if (w <= 0) return; + + bool alignL = intptr_t(ptr) & 1; + if (alignL) + { + w--; + } + + bool alignR = w & 1; + + w >>= 1; + + for (int32 y = 0; y < h; y++) + { + const ColorIndex* xtile = tile + (v & 0xFF00); + + volatile uint8* xptr = ptr; + + uint32 xu = uint32(u); + + if (alignL) + { + ColorIndex indexB = xtile[xu >> 8]; + xu += du; + if (indexB) xptr[0] = ft_lightmap[indexB]; + xptr++; + } + + for (int32 x = 0; x < w; x++) + { + ColorIndex indexA = xtile[xu >> 8]; + xu += du; + if (indexA) xptr[0] = ft_lightmap[indexA]; + + ColorIndex indexB = xtile[xu >> 8]; + xu += du; + if (indexB) xptr[1] = ft_lightmap[indexB]; + + xptr += 2; + } + + if (alignR) + { + ColorIndex indexA = xtile[xu >> 8]; + if (indexA) xptr[0] = ft_lightmap[indexA]; + } + + v += dv; + + ptr += FRAME_WIDTH; + } +} + +extern "C" void rasterizeLineH_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + R++; + int32 x = L->v.x; + int32 index = L->v.g; + int32 width = R->v.x; + + volatile uint8* ptr = (uint8*)pixel + x; + + if (intptr_t(ptr) & 1) + { + *ptr++ = index; + width--; + } + + if (width & 1) + { + width--; + ptr[width] = index; + } + + index |= (index << 8); + + for (int32 i = 0; i < width / 2; i++) + { + *(uint16*)ptr = index; + ptr += 2; + } +} + +extern "C" void rasterizeLineV_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + R++; + int32 x = L->v.x; + int32 index = L->v.g; + int32 height = R->v.y; + + volatile uint8* ptr = (uint8*)pixel + x; + + for (int32 i = 0; i < height; i++) + { + *ptr = index; + ptr += FRAME_WIDTH; + } +} + +extern "C" void rasterizeFillS_c(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile) +{ + R++; + int32 x = L->v.x; + int32 shade = L->v.g; + int32 width = R->v.x; + int32 height = R->v.y; + + const uint8* lm = &gLightmap[shade << 8]; + + for (int32 i = 0; i < height; i++) + { + volatile uint8* ptr = (uint8*)pixel + x; + int32 w = width; + + if (intptr_t(ptr) & 1) + { + ptr[0] = lm[ptr[0]]; + ptr++; + w--; + } + + if (w & 1) + { + w--; + ptr[w] = lm[ptr[w]]; + } + + for (int32 i = 0; i < w / 2; i++) + { + uint16 p = *(uint16*)ptr; + *(uint16*)ptr = lm[p & 0xFF] | (lm[p >> 8] << 8); + ptr += 2; + } + + pixel += FRAME_WIDTH / 2; + } +} + +#endif diff --git a/src/platform/32x/render.cpp b/src/platform/32x/render.cpp new file mode 100644 index 00000000..a0c5c887 --- /dev/null +++ b/src/platform/32x/render.cpp @@ -0,0 +1,1287 @@ +#include "common.h" + +struct Vertex +{ + int16 x; + int16 y; + int16 z; + uint8 g; + uint8 clip; +}; + +struct VertexLink +{ + Vertex v; + TexCoord t; + int8 prev; + int8 next; + uint16 padding; +}; + +struct ViewportRel { + int32 minXY; + int32 maxXY; +}; + +#define fb ((uint8*)&MARS_FRAMEBUFFER + 0x200) + +enum FaceType { + FACE_TYPE_SHADOW, + FACE_TYPE_F, + FACE_TYPE_FT, + FACE_TYPE_FTA, + FACE_TYPE_GT, + FACE_TYPE_GTA, + FACE_TYPE_SPRITE, + FACE_TYPE_FILL_S, + FACE_TYPE_LINE_H, + FACE_TYPE_LINE_V, + FACE_TYPE_MAX +}; + +#define FACE_TRIANGLE (1 << 31) +#define FACE_CLIPPED (1 << 30) +#define FACE_TYPE_SHIFT 14 +#define FACE_TYPE_MASK 15 +#define FACE_GOURAUD (2 << FACE_TYPE_SHIFT) +#define FACE_TEXTURE 0x3FFF + +#include "rasterizer.h" + +extern Level level; + +ViewportRel viewportRel; +Vertex* gVerticesBase; +Face* gFacesBase; + +//EWRAM_DATA uint8 gBackgroundCopy[FRAME_WIDTH * FRAME_HEIGHT]; // EWRAM 37.5k +EWRAM_DATA ALIGN16 Vertex gVertices[MAX_VERTICES]; // EWRAM 16k +EWRAM_DATA ALIGN16 Face gFaces[MAX_FACES]; // EWRAM 30k +Face* gOT[OT_SIZE]; // IWRAM 2.5k + +enum ClipFlags { + CLIP_FRAME = 1 << 0, + CLIP_LEFT = 1 << 1, + CLIP_RIGHT = 1 << 2, + CLIP_TOP = 1 << 3, + CLIP_BOTTOM = 1 << 4, + CLIP_PLANE = 1 << 5, + CLIP_DISCARD = (CLIP_LEFT | CLIP_RIGHT | CLIP_TOP | CLIP_BOTTOM | CLIP_PLANE) +}; + +const MeshQuad gShadowQuads[] = { + { (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT), {0, 1, 2, 7} }, + { (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT), {7, 2, 3, 6} }, + { (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT), {6, 3, 4, 5} } +}; + + +// TODO: remove +// just a dummy function to align functions below >_< +uint16 test(uint16 g0, uint16 g1, uint16 g2, uint16 g3) +{ + return X_MAX(g0, X_MAX(g1, X_MAX(g2, g3))); +} + + +void setViewport(const RectMinMax &vp) +{ + viewport = vp; + + int32 minX = vp.x0 - (FRAME_WIDTH >> 1); + int32 minY = vp.y0 - (FRAME_HEIGHT >> 1); + int32 maxX = vp.x1 - (FRAME_WIDTH >> 1); + int32 maxY = vp.y1 - (FRAME_HEIGHT >> 1); + + viewportRel.minXY = (minX << 16) | (minY & 0xFFFF); + viewportRel.maxXY = (maxX << 16) | (maxY & 0xFFFF); +} + +void setPaletteIndex(int32 index) +{ + // TODO +} + +X_INLINE Face* faceAdd(int32 depth) +{ + ASSERT(depth >= 0 && depth < OT_SIZE); + + Face* face = gFacesBase++; + face->next = gOT[depth]; + gOT[depth] = face; + + return face; +} + +extern "C" { + X_NOINLINE void drawPoly(uint32 flags, VertexLink* v, const ColorIndex* tile); + X_INLINE void drawTriangle(uint32 flags, VertexLink* v, const ColorIndex* tile); + X_INLINE void drawQuad(uint32 flags, VertexLink* v, const ColorIndex* tile); +} + +extern "C" { + void transformRoom_asm(const RoomVertex* vertices, int32 count); + void transformRoomUW_asm(const RoomVertex* vertices, int32 count); + void transformMesh_asm(const MeshVertex* vertices, int32 count, int32 intensity); + void faceAddRoomQuads_asm(const RoomQuad* polys, int32 count); + void faceAddRoomTriangles_asm(const RoomTriangle* polys, int32 count); + void faceAddMeshQuads_asm(const MeshQuad* polys, int32 count); + void faceAddMeshTriangles_asm(const MeshTriangle* polys, int32 count); + void rasterize_asm(uint32 flags, VertexLink* top, const ColorIndex* tile); +} + +#if 1 //USE_ASM + #define transformRoom transformRoom_asm + #define transformRoomUW transformRoom_asm + #define transformMesh transformMesh_asm + #define faceAddRoomQuads faceAddRoomQuads_asm + #define faceAddRoomTriangles faceAddRoomTriangles_asm + #define faceAddMeshQuads faceAddMeshQuads_asm + #define faceAddMeshTriangles faceAddMeshTriangles_asm + #define rasterize rasterize_asm +#else + #define transformRoom transformRoom_c + #define transformRoomUW transformRoomUW_c + #define transformMesh transformMesh_c + #define faceAddRoomQuads faceAddRoomQuads_c + #define faceAddRoomTriangles faceAddRoomTriangles_c + #define faceAddMeshQuads faceAddMeshQuads_c + #define faceAddMeshTriangles faceAddMeshTriangles_c + #define rasterize rasterize_c + +X_INLINE bool checkBackface(const Vertex *a, const Vertex *b, const Vertex *c) +{ + return (b->x - a->x) * (c->y - a->y) <= (c->x - a->x) * (b->y - a->y); +} + +void transformRoom_c(const RoomVertex* vertices, int32 count) +{ + Vertex* res = gVerticesBase; + + for (int32 i = 0; i < count; i++, res++) + { + #ifdef __32X__ + int32 vx = vertices->x << 8; + int32 vy = vertices->y << 8; + int32 vz = vertices->z << 8; + int32 vg = vertices->g << 8; + vertices++; + #else + uint32 value = *(uint32*)(vertices++); + int32 vx = (value & (0xFF)) << 10; + int32 vy = (value & (0xFF << 8)); + int32 vz = (value & (0xFF << 16)) >> 6; + int32 vg = (value & (0xFF << 24)) >> (24 - 5); + #endif + + const Matrix &m = matrixGet(); + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, vx, vy, vz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, vx, vy, vz); + + uint32 clip = 0; + + if (z <= VIEW_MIN_F) { + clip = CLIP_PLANE; + z = VIEW_MIN_F; + } + + if (z >= VIEW_MAX_F) { + clip = CLIP_PLANE; + z = VIEW_MAX_F; + } + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + if (z > FOG_MIN) + { + vg += (z - FOG_MIN) << FOG_SHIFT; + if (vg > 8191) { + vg = 8191; + } + } + + PERSPECTIVE(x, y, z); + + // use this in case of overflow + //x = X_CLAMP(x, -512, 512); + //y = X_CLAMP(y, -512, 512); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + if (x < viewport.x0) clip |= CLIP_LEFT; + if (x > viewport.x1) clip |= CLIP_RIGHT; + if (y < viewport.y0) clip |= CLIP_TOP; + if (y > viewport.y1) clip |= CLIP_BOTTOM; + + res->x = x; + res->y = y; + res->z = z; + res->g = vg >> 8; + res->clip = clip; + } +} + +void transformRoomUW_c(const RoomVertex* vertices, int32 count) +{ + Vertex* res = gVerticesBase; + + for (int32 i = 0; i < count; i++, res++) + { + #ifdef __32X__ + int32 vx = vertices->x << 8; + int32 vy = vertices->y << 8; + int32 vz = vertices->z << 8; + int32 vg = vertices->g << 8; + vertices++; + #else + uint32 value = *(uint32*)(vertices++); + int32 vx = (value & (0xFF)) << 10; + int32 vy = (value & (0xFF << 8)); + int32 vz = (value & (0xFF << 16)) >> 6; + int32 vg = (value & (0xFF << 24)) >> (24 - 5); + #endif + + const Matrix &m = matrixGet(); + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, vx, vy, vz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, vx, vy, vz); + + uint32 clip = 0; + + if (z <= VIEW_MIN_F) { + clip = CLIP_NEAR; + z = VIEW_MIN_F; + } + + if (z >= VIEW_MAX_F) { + clip = CLIP_FAR; + z = VIEW_MAX_F; + } + + int32 causticsValue = gCaustics[(gRandTable[i & (MAX_RAND_TABLE - 1)] + gCausticsFrame) & (MAX_CAUSTICS - 1)]; + vg = X_CLAMP(vg + causticsValue, 0, 8191); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + if (z > FOG_MIN) + { + vg += (z - FOG_MIN) << FOG_SHIFT; + if (vg > 8191) { + vg = 8191; + } + } + + PERSPECTIVE(x, y, z); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + if (x < viewport.x0) clip |= CLIP_LEFT; + if (x > viewport.x1) clip |= CLIP_RIGHT; + if (y < viewport.y0) clip |= CLIP_TOP; + if (y > viewport.y1) clip |= CLIP_BOTTOM; + + res->x = x; + res->y = y; + res->z = z; + res->g = vg >> 8; + res->clip = clip; + } +} + +void transformMesh_c(const MeshVertex* vertices, int32 count, int32 intensity) +{ + Vertex* res = gVerticesBase; + + int32 vg = X_CLAMP((intensity + gLightAmbient) >> 8, 0, 31); + + for (int32 i = 0; i < count; i++, res++) + { + int32 vx = vertices->x; + int32 vy = vertices->y; + int32 vz = vertices->z; + vertices++; + + const Matrix &m = matrixGet(); + + int32 x = m.e03; + int32 y = m.e13; + int32 z = m.e23; + + x += DP33(m.e00, m.e01, m.e02, vx, vy, vz) >> (FIXED_SHIFT + F16_SHIFT); + y += DP33(m.e10, m.e11, m.e12, vx, vy, vz) >> (FIXED_SHIFT + F16_SHIFT); + z += DP33(m.e20, m.e21, m.e22, vx, vy, vz) >> (FIXED_SHIFT + F16_SHIFT); + + uint32 clip = 0; + + if (z <= (VIEW_MIN_F >> FIXED_SHIFT)) { + clip = CLIP_PLANE; + z = VIEW_MIN_F >> FIXED_SHIFT; + } + + if (z >= (VIEW_MAX_F >> FIXED_SHIFT)) { + clip = CLIP_PLANE; + z = VIEW_MAX_F >> FIXED_SHIFT; + } + + PERSPECTIVE(x, y, z); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + if (x < viewport.x0) clip |= CLIP_LEFT; + if (x > viewport.x1) clip |= CLIP_RIGHT; + if (y < viewport.y0) clip |= CLIP_TOP; + if (y > viewport.y1) clip |= CLIP_BOTTOM; + + res->x = x; + res->y = y; + res->z = z; + res->g = vg; + res->clip = clip; + } +} + +void faceAddRoomQuads_c(const RoomQuad* polys, int32 count) +{ + const uint8* v = (uint8*)gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + const Vertex* v0 = (Vertex*)(v + (polys->indices[0] << 2)); + const Vertex* v1 = (Vertex*)(v + (polys->indices[1] << 2)); + const Vertex* v2 = (Vertex*)(v + (polys->indices[2] << 2)); + const Vertex* v3 = (Vertex*)(v + (polys->indices[3] << 2)); + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + uint32 c3 = v3->clip; + + if (c0 & c1 & c2 & c3 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2 | c3) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + uint32 g0 = v0->g; + uint32 g1 = v1->g; + uint32 g2 = v2->g; + uint32 g3 = v3->g; + + if (g0 != g1 || g0 != g2 || g0 != g3) { + flags += FACE_GOURAUD; + } + + if (checkBackface(v0, v1, v2)) + continue; + + int32 depth = X_MAX(v0->z, X_MAX(v1->z, X_MAX(v2->z, v3->z))) >> OT_SHIFT; + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + f->indices[3] = v3 - gVertices; + } +} + +void faceAddRoomTriangles_c(const RoomTriangle* polys, int32 count) +{ + const uint8* v = (uint8*)gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + const Vertex* v0 = (Vertex*)(v + (polys->indices[0] << 2)); + const Vertex* v1 = (Vertex*)(v + (polys->indices[1] << 2)); + const Vertex* v2 = (Vertex*)(v + (polys->indices[2] << 2)); + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + + if (c0 & c1 & c2 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + uint32 g0 = v0->g; + uint32 g1 = v1->g; + uint32 g2 = v2->g; + + if (g0 != g1 || g0 != g2) { + flags += FACE_GOURAUD; + } + + if (checkBackface(v0, v1, v2)) + continue; + + flags |= FACE_TRIANGLE; + + int32 depth = X_MAX(v0->z, X_MAX(v1->z, v2->z)) >> OT_SHIFT; + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + } +} + +void faceAddMeshQuads_c(const MeshQuad* polys, int32 count) +{ + const Vertex* v = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + const Vertex* v0 = v + polys->indices[0]; + const Vertex* v1 = v + polys->indices[1]; + const Vertex* v2 = v + polys->indices[2]; + const Vertex* v3 = v + polys->indices[3]; + + if (checkBackface(v0, v1, v2)) + continue; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + uint32 c3 = v3->clip; + + if (c0 & c1 & c2 & c3 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2 | c3) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + int32 depth = (v0->z + v1->z + v2->z + v3->z) >> (2 + OT_SHIFT); + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + f->indices[3] = v3 - gVertices; + } +} + +void faceAddMeshTriangles_c(const MeshTriangle* polys, int32 count) +{ + const Vertex* v = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + const Vertex* v0 = v + polys->indices[0]; + const Vertex* v1 = v + polys->indices[1]; + const Vertex* v2 = v + polys->indices[2]; + + if (checkBackface(v0, v1, v2)) + continue; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + + if (c0 & c1 & c2 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + flags |= FACE_TRIANGLE; + + int32 depth = (v0->z + v1->z + v2->z + v2->z) >> (2 + OT_SHIFT); + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + } +} + +typedef void (*RasterProc)(uint16* pixel, const VertexLink* L, const VertexLink* R, const ColorIndex* tile); + +extern "C" const RasterProc gRasterProc[FACE_TYPE_MAX] = { + rasterizeS, + rasterizeF, + rasterizeFT, + rasterizeFT, + rasterizeGT, + rasterizeGT, + rasterizeSprite, + rasterizeFillS, + rasterizeLineH, + rasterizeLineV +}; + +X_NOINLINE void rasterize_c(uint32 flags, VertexLink* top, const ColorIndex* tile) +{ + uint8* pixel = (uint8*)fb + top->v.y * FRAME_WIDTH; + + uint32 type = (flags >> FACE_TYPE_SHIFT) & FACE_TYPE_MASK; + + VertexLink* R = (type == FACE_TYPE_F) ? (VertexLink*)(flags & 0xFF) : top; + + gRasterProc[type]((uint16*)pixel, top, R, tile); +} +#endif + +int32 sphereIsVisible_c(int32 sx, int32 sy, int32 sz, int32 r) +{ + Matrix &m = matrixGet(); + + if (abs(sx) < r && abs(sy) < r && abs(sz) < r) + return 1; + + int32 z = DP33(m.e20, m.e21, m.e22, sx, sy, sz); + + if (z < 0) + return 0; + + int32 x = DP33(m.e00, m.e01, m.e02, sx, sy, sz); + int32 y = DP33(m.e10, m.e11, m.e12, sx, sy, sz); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + z = PERSPECTIVE_DZ(z); + if (z >= DIV_TABLE_SIZE) z = DIV_TABLE_SIZE - 1; + int32 d = FixedInvU(z); + x = (x * d) >> 12; + y = (y * d) >> 12; + r = (r * d) >> 12; + + x += (FRAME_WIDTH / 2); + y += (FRAME_HEIGHT / 2); + + int32 rMinX = x - r; + int32 rMinY = y - r; + int32 rMaxX = x + r; + int32 rMaxY = y + r; + + if (rMinX > viewport.x1 || + rMaxX < viewport.x0 || + rMinY > viewport.y1 || + rMaxY < viewport.y0) return 0; // not visible + + return 1; +} + +void flush_ot(int32 bit) +{ + VertexLink v[4 + 4]; + VertexLink* q = v; + VertexLink* t = v + 4; + // quad + q[0].prev = (3 << 4); + q[0].next = (1 << 4); + q[1].prev = -(1 << 4); + q[1].next = (1 << 4); + q[2].prev = -(1 << 4); + q[2].next = (1 << 4); + q[3].prev = -(1 << 4); + q[3].next = -(3 << 4); + // triangle + t[0].prev = (2 << 4); + t[0].next = (1 << 4); + t[1].prev = -(1 << 4); + t[1].next = (1 << 4); + t[2].prev = -(1 << 4); + t[2].next = -(2 << 4); + + int32 index = 0; + const ColorIndex* tile = NULL; + + for (int32 i = OT_SIZE - 1; i >= 0; i--) + { + if (!gOT[i]) continue; + + Face *face = gOT[i]; + + do { + index++; + + if ((index & 1) != bit) { + face = face->next; + continue; + } + + uint32 flags = face->flags; + + uint32 type = (flags >> FACE_TYPE_SHIFT) & FACE_TYPE_MASK; + + if (type <= FACE_TYPE_GTA) + { + VertexLink* ptr = (flags & FACE_TRIANGLE) ? t : q; + + if (type > FACE_TYPE_F) + { + const Texture &tex = level.textures[flags & FACE_TEXTURE]; + tile = (ColorIndex*)tex.tile; + + ptr[0].t.t = 0xFF00FF00 & (tex.uv01); + ptr[1].t.t = 0xFF00FF00 & (tex.uv01 << 8); + ptr[2].t.t = 0xFF00FF00 & (tex.uv23); + ptr[3].t.t = 0xFF00FF00 & (tex.uv23 << 8); + } + + #if 1 + uint8* vPtr = (uint8*)gVertices; + ((uint32*)&ptr[0].v)[0] = ((uint32*)(vPtr + face->indices[0]))[0]; + ((uint32*)&ptr[0].v)[1] = ((uint32*)(vPtr + face->indices[0]))[1]; + + ((uint32*)&ptr[1].v)[0] = ((uint32*)(vPtr + face->indices[1]))[0]; + ((uint32*)&ptr[1].v)[1] = ((uint32*)(vPtr + face->indices[1]))[1]; + + ((uint32*)&ptr[2].v)[0] = ((uint32*)(vPtr + face->indices[2]))[0]; + ((uint32*)&ptr[2].v)[1] = ((uint32*)(vPtr + face->indices[2]))[1]; + + if (!(flags & FACE_TRIANGLE)) { + ((uint32*)&ptr[3].v)[0] = ((uint32*)(vPtr + face->indices[3]))[0]; + ((uint32*)&ptr[3].v)[1] = ((uint32*)(vPtr + face->indices[3]))[1]; + } + #else + ptr[0].v = gVertices[face->indices[0] >> 3]; + ptr[1].v = gVertices[face->indices[1] >> 3]; + ptr[2].v = gVertices[face->indices[2] >> 3]; + if (!(flags & FACE_TRIANGLE)) { + ptr[3].v = gVertices[face->indices[3] >> 3]; + } + #endif + + if (flags & FACE_CLIPPED) { + drawPoly(flags, ptr, tile); + } else { + if (flags & FACE_TRIANGLE) { + drawTriangle(flags, ptr, tile); + } else { + drawQuad(flags, ptr, tile); + } + } + } + else + { + const Vertex *vert = gVertices + face->indices[0]; + v[0].v = vert[0]; + v[1].v = vert[1]; + + if (type == FACE_TYPE_SPRITE) + { + const Sprite &sprite = level.sprites[flags & FACE_TEXTURE]; + tile = (ColorIndex*)sprite.tile; + v[0].t.t = (sprite.uwvh) & (0xFF00FF00); + v[1].t.t = (sprite.uwvh) & (0xFF00FF00 >> 8); + } + + rasterize(flags, v, tile); + } + + face = face->next; + + } while (face); +#if 1 + // sync + if (bit) { + MARS_SYS_COMM6 = i; + while (MARS_SYS_COMM2 > i); + } else { + MARS_SYS_COMM2 = i; + while (MARS_SYS_COMM6 > i); + } +#endif + } + CacheClear(); +} + +void flush_c() +{ +#ifdef PROFILING + #if !defined(PROFILE_FRAMETIME) && !defined(PROFILE_SOUNDTIME) + gCounters[CNT_VERT] += gVerticesBase - gVertices; + gCounters[CNT_POLY] += gFacesBase - gFaces; + #endif +#endif + + gVerticesBase = gVertices; + + if (gFacesBase == gFaces) + return; + + gFacesBase = gFaces; + +//#define ON_CHIP_RENDER + +#ifdef ON_CHIP_RENDER + CacheControl(0); + CacheControl(SH2_CCTL_CP | SH2_CCTL_CE | SH2_CCTL_TW); + + extern int32 block_render_start; + extern int32 block_render_end; + + int32 size = intptr_t(&block_render_end) - intptr_t(&block_render_start); + fast_memcpy((void*)0xC0000000, &block_render_start, size >> 2); +#endif + PROFILE(CNT_FLUSH); + + MARS_WAIT(); + CacheClear(); + + MARS_SYS_COMM2 = OT_SIZE; + MARS_SYS_COMM6 = OT_SIZE; + MARS_SYS_COMM4 = MARS_CMD_FLUSH; + + flush_ot(0); + + MARS_WAIT(); + + dmaFill(gOT, 0, OT_SIZE * sizeof(gOT[0])); + +#ifdef ON_CHIP_RENDER + CacheControl(0); + CacheControl(SH2_CCTL_CP | SH2_CCTL_CE); +#endif +} + +void renderInit() +{ + gVerticesBase = gVertices; + gFacesBase = gFaces; +} + +void renderFree() +{ +} + +void renderLevelInit() +{ +} + +void renderLevelFree() +{ +} + +extern "C" X_INLINE void drawTriangle(uint32 flags, VertexLink* v, const ColorIndex* tile) +{ + VertexLink* top = v; + if (top->v.y > v[1].v.y) top = v + 1; + if (top->v.y > v[2].v.y) top = v + 2; + rasterize(flags, top, tile); +} + +extern "C" X_INLINE void drawQuad(uint32 flags, VertexLink* v, const ColorIndex* tile) +{ + VertexLink* top = v; + if (top->v.y > v[1].v.y) top = v + 1; + if (top->v.y > v[2].v.y) top = v + 2; + if (top->v.y > v[3].v.y) top = v + 3; + rasterize(flags, top, tile); +} + +extern "C" X_NOINLINE void drawPoly(uint32 flags, VertexLink* v, const ColorIndex* tile) +{ + #define LERP_SHIFT 6 + #define LERP(a,b,t) (b + ((a - b) * t >> LERP_SHIFT)) + //#define LERP2(a,b,ta,tb) LERP(a,b,t) + #define LERP2(a,b,ta,tb) (b + (((a - b) * ta / tb) >> LERP_SHIFT) ) // less gaps between clipped polys, but slow + + #define CLIP_AXIS(X, Y, edge, output) {\ + int32 ta = (edge - b->v.X) << LERP_SHIFT;\ + int32 tb = (a->v.X - b->v.X);\ + ASSERT(tb != 0);\ + int32 t = ta / tb;\ + ASSERT(count < 8);\ + VertexLink* p = output + count++;\ + p->v.X = edge;\ + p->v.Y = LERP2(a->v.Y, b->v.Y, ta, tb);\ + p->v.g = LERP(a->v.g, b->v.g, t);\ + p->t.uv.u = LERP(a->t.uv.u, b->t.uv.u, t);\ + p->t.uv.v = LERP(a->t.uv.v, b->t.uv.v, t);\ + } + + #define CLIP_XY(X, Y, X0, X1, input, output) {\ + const VertexLink *a, *b = input + pCount - 1;\ + for (int32 i = 0; i < pCount; i++) {\ + a = b;\ + b = input + i;\ + if (a->v.X < X0) {\ + if (b->v.X < X0) continue;\ + CLIP_AXIS(X, Y, X0, output);\ + } else if (a->v.X > X1) {\ + if (b->v.X > X1) continue;\ + CLIP_AXIS(X, Y, X1, output);\ + }\ + if (b->v.X < X0) {\ + CLIP_AXIS(X, Y, X0, output);\ + } else if (b->v.X > X1) {\ + CLIP_AXIS(X, Y, X1, output);\ + } else {\ + ASSERT(count < 8);\ + output[count++] = *b;\ + }\ + }\ + if (count < 3) return;\ + } + + VertexLink tmp[8]; + VertexLink out[8]; + + int32 pCount = (flags & FACE_TRIANGLE) ? 3 : 4; + int32 count = 0; + + // clip x + CLIP_XY(x, y, 0, FRAME_WIDTH, v, tmp); + + pCount = count; + count = 0; + + // clip y + CLIP_XY(y, x, 0, FRAME_HEIGHT, tmp, out); + + VertexLink* first = out; + VertexLink* last = out + count - 1; + + bool skip = (first->v.y == last->v.y); + + VertexLink* top = (first->v.y < last->v.y) ? first : last; + first->prev = (count - 1) << 4; + first->next = (1 << 4); + last->prev = -(1 << 4); + last->next = (1 - count) << 4; + + for (int32 i = 1; i < count - 1; i++) + { + VertexLink* p = out + i; + + if (p->v.y != top->v.y) + { + if (p->v.y < top->v.y) + { + top = p; + } + skip = false; + } + + p->prev = -(1 << 4); + p->next = (1 << 4); + } + + if (skip) + return; + + rasterize(flags, top, tile); +} + +void faceAddRoom(const Room* room) +{ + if (room->info->quadsCount > 0) { + faceAddRoomQuads(room->data.quads, room->info->quadsCount); + } + + if (room->info->trianglesCount > 0) { + faceAddRoomTriangles(room->data.triangles, room->info->trianglesCount); + } +} + +void faceAddMesh(const MeshQuad* quads, const MeshTriangle* triangles, int32 qCount, int32 tCount) +{ + if (qCount > 0) { + faceAddMeshQuads(quads, qCount); + } + + if (tCount > 0) { + faceAddMeshTriangles(triangles, tCount); + } +} + +void clear() +{ + MARS_SYS_COMM4 = MARS_CMD_CLEAR; +} + +void renderRoom(Room* room) +{ + int32 vCount = room->info->verticesCount; + if (vCount <= 0) + return; + + if ((gVerticesBase - gVertices) + vCount > MAX_VERTICES) + { + ASSERT(false); + return; + } + + { + PROFILE(CNT_TRANSFORM); + if (ROOM_FLAG_WATER(room->info->flags)) { + transformRoomUW(room->data.vertices, vCount); + } else { + transformRoom(room->data.vertices, vCount); + } + } + + { + PROFILE(CNT_ADD); + faceAddRoom(room); + } + + gVerticesBase += vCount; +} + +void renderMesh(const Mesh* mesh) +{ + int32 vCount = mesh->vCount; + if (vCount <= 0) + return; + + if ((gVerticesBase - gVertices) + vCount > MAX_VERTICES) + { + ASSERT(false); + return; + } + + int32 fCount = mesh->rCount + mesh->tCount; + if ((gFacesBase - gFaces) + fCount > MAX_FACES) + { + ASSERT(false); + return; + } + + const uint8* ptr = (uint8*)mesh + sizeof(Mesh); + + const MeshVertex* vertices = (MeshVertex*)ptr; + ptr += vCount * sizeof(vertices[0]); + + MeshQuad* quads = (MeshQuad*)ptr; + ptr += mesh->rCount * sizeof(MeshQuad); + + MeshTriangle* triangles = (MeshTriangle*)ptr; + + { + PROFILE(CNT_TRANSFORM); + transformMesh(vertices, vCount, mesh->intensity); + } + + { + PROFILE(CNT_ADD); + faceAddMesh(quads, triangles, mesh->rCount, mesh->tCount); + } + + gVerticesBase += vCount; +} + +void renderShadow(int32 x, int32 z, int32 sx, int32 sz) +{ + if (gVerticesBase - gVertices + 8 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 3 > MAX_FACES) { + ASSERT(false); + return; + } + + x <<= F16_SHIFT; + z <<= F16_SHIFT; + sx <<= F16_SHIFT; + sz <<= F16_SHIFT; + + int16 xns1 = x - sx; + int16 xps1 = x + sx; + int16 xns2 = xns1 - sx; + int16 xps2 = xps1 + sx; + + int16 zns1 = z - sz; + int16 zps1 = z + sz; + int16 zns2 = zns1 - sz; + int16 zps2 = zps1 + sz; + + MeshVertex v[8]; + v[0].x = xns1; v[0].y = 0; v[0].z = zps2; + v[1].x = xps1; v[1].y = 0; v[1].z = zps2; + v[2].x = xps2; v[2].y = 0; v[2].z = zps1; + v[3].x = xps2; v[3].y = 0; v[3].z = zns1; + v[4].x = xps1; v[4].y = 0; v[4].z = zns2; + v[5].x = xns1; v[5].y = 0; v[5].z = zns2; + v[6].x = xns2; v[6].y = 0; v[6].z = zns1; + v[7].x = xns2; v[7].y = 0; v[7].z = zps1; + + transformMesh(v, 8, 0); + faceAddMeshQuads(gShadowQuads, 3); + + gVerticesBase += 8; +} + +X_NOINLINE void renderFill(int32 x, int32 y, int32 width, int32 height, int32 shade, int32 z) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + gVerticesBase[0].x = x; + gVerticesBase[0].y = y; + gVerticesBase[0].g = shade; + + gVerticesBase[1].x = width; + gVerticesBase[1].y = height; + + Face* f = faceAdd(z); + f->flags = (FACE_TYPE_FILL_S << FACE_TYPE_SHIFT); + f->indices[0] = gVerticesBase - gVertices; + + gVerticesBase += 2; +} + +X_NOINLINE void renderLine(int32 x, int32 y, int32 width, int32 height, int32 index, int32 z) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + ASSERT(width == 1 || height == 1); + ASSERT(width > 0); + ASSERT(height > 0); + + gVerticesBase[0].x = x; + gVerticesBase[0].y = y; + gVerticesBase[0].g = index; + + gVerticesBase[1].x = width; + gVerticesBase[1].y = height; + + int32 idx = gVerticesBase - gVertices; + + Face* f = faceAdd(z); + f->flags = (height == 1) ? (FACE_TYPE_LINE_H << FACE_TYPE_SHIFT) : (FACE_TYPE_LINE_V << FACE_TYPE_SHIFT); + f->indices[0] = idx; + + gVerticesBase += 2; +} + +void renderSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + const Matrix &m = matrixGet(); + + vx -= gCameraViewPos.x; + vy -= gCameraViewPos.y; + vz -= gCameraViewPos.z; + + int32 z = DP33(m.e20, m.e21, m.e22, vx, vy, vz); + + if (z < VIEW_MIN_F || z >= VIEW_MAX_F) + { + return; + } + + int32 x = DP33(m.e00, m.e01, m.e02, vx, vy, vz); + int32 y = DP33(m.e10, m.e11, m.e12, vx, vy, vz); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + const Sprite* sprite = level.sprites + index; + + int32 l = x + sprite->l; + int32 r = x + sprite->r; + int32 t = y + sprite->t; + int32 b = y + sprite->b; + + // TODO one projection + PERSPECTIVE(l, t, z); + + l += (FRAME_WIDTH >> 1); + if (l >= viewport.x1) return; + + t += (FRAME_HEIGHT >> 1); + if (t >= viewport.y1) return; + + PERSPECTIVE(r, b, z); + + r += (FRAME_WIDTH >> 1); + if (r < viewport.x0) return; + + b += (FRAME_HEIGHT >> 1); + if (b < viewport.y0) return; + + if (l == r) return; + if (t == b) return; + + if (z > FOG_MIN) + { + vg += (z - FOG_MIN) << FOG_SHIFT; + if (vg > 8191) { + vg = 8191; + } + } + vg >>= 8; + + Vertex* v1 = gVerticesBase++; + v1->x = l; + v1->y = t; + //v1->z = z; + v1->g = vg; + + Vertex* v2 = gVerticesBase++; + v2->x = r; + v2->y = b; + //v2->z = z; + //v2->g = vg; + + int32 depth = X_MAX(0, z - 128); // depth hack + + Face* f = faceAdd(depth >> OT_SHIFT); + f->flags = (FACE_TYPE_SPRITE << FACE_TYPE_SHIFT) | index; + f->indices[0] = v1 - gVertices; + + gVerticesBase += 2; +} + +void renderGlyph(int32 vx, int32 vy, int32 index) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + const Sprite* sprite = level.sprites + index; + + int32 l = vx + sprite->l; + int32 r = vx + sprite->r; + int32 t = vy + sprite->t; + int32 b = vy + sprite->b; + + if (l == r) return; + if (t == b) return; + if (r < 0) return; + if (b < 0) return; + if (l >= FRAME_WIDTH) return; + if (t >= FRAME_HEIGHT) return; + + Vertex* v1 = gVerticesBase++; + v1->x = l; + v1->y = t; + //v1->z = z; + v1->g = 16; + + Vertex* v2 = gVerticesBase++; + v2->x = r; + v2->y = b; + //v2->z = z; + //v2->g = vg; + + Face* f = faceAdd(0); + f->flags = (FACE_TYPE_SPRITE << FACE_TYPE_SHIFT) | index; + f->indices[0] = v1 - gVertices; + + gVerticesBase += 2; +} + +#define BAR_HEIGHT 5 + +const int32 BAR_COLORS[BAR_MAX][5] = { + { 8, 11, 8, 6, 24 }, + { 32, 41, 32, 19, 21 }, + { 28, 29, 28, 26, 27 }, + { 43, 44, 43, 42, 41 }, +}; + +X_NOINLINE void renderBorder(int32 x, int32 y, int32 width, int32 height, int32 color1, int32 color2, int32 z) +{ + renderLine(x + 1, y, width - 2, 1, color1, z); + renderLine(x + 1, y + height - 1, width - 2, 1, color2, z); + renderLine(x, y, 1, height, color1, z); + renderLine(x + width - 1, y, 1, height, color2, z); +} + +void renderBar(int32 x, int32 y, int32 width, int32 value, BarType type) +{ + // colored bar + int32 ix = x + 1; + int32 iy = y + 1; + int32 w = value* width >> 8; + + if (w > 0) + { + for (int32 i = 0; i < 5; i++) + { + renderLine(ix, iy++, w, 1, BAR_COLORS[type][i], 0); + } + } + + if (w < width) + { + renderFill(x + 1 + w, y + 1, width - w, BAR_HEIGHT, 27, 0); + } + + renderBorder(x, y, width + 2, BAR_HEIGHT + 2, 19, 17, 0); +} + +void renderBackground(const void* background) +{ + clear(); +// dmaCopy(background, (void*)fb, FRAME_WIDTH * FRAME_HEIGHT); +} + +void* copyBackground() +{ +// dmaCopy((void*)fb, gBackgroundCopy, FRAME_WIDTH * FRAME_HEIGHT); +// palGrayRemap(gBackgroundCopy, FRAME_WIDTH * FRAME_HEIGHT); +// return gBackgroundCopy; + return NULL; +} diff --git a/src/platform/32x/sound.cpp b/src/platform/32x/sound.cpp new file mode 100644 index 00000000..2512df5c --- /dev/null +++ b/src/platform/32x/sound.cpp @@ -0,0 +1,51 @@ +#include "common.h" + +void sndInit() +{ + // TODO +} + +void sndInitSamples() +{ + // TODO +} + +void sndFreeSamples() +{ + // TODO +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + return NULL; // TODO +} + +void sndPlayTrack(int32 track) +{ + // TODO +} + +void sndStopTrack() +{ + // TODO +} + +bool sndTrackIsPlaying() +{ + return false; // TODO +} + +void sndStopSample(int32 index) +{ + // TODO +} + +void sndStop() +{ + // TODO +} + +void sndFill(uint8* buffer, int32 count) +{ + // TODO +} diff --git a/src/platform/32x/src-md/Makefile b/src/platform/32x/src-md/Makefile new file mode 100644 index 00000000..b36fe662 --- /dev/null +++ b/src/platform/32x/src-md/Makefile @@ -0,0 +1,46 @@ +ifdef $(GENDEV) +ROOTDIR = $(GENDEV) +else +ROOTDIR = /opt/toolchains/sega +endif + +PREFIX = $(ROOTDIR)/m68k-elf/bin/m68k-elf- +CC = $(PREFIX)gcc +AS = $(PREFIX)as +LD = $(PREFIX)ld +OBJC = $(PREFIX)objcopy + +CC_VER := $(shell $(CC) -dumpversion) + +LDSCRIPTSDIR = $(ROOTDIR)/ldscripts + +LIBPATH = -L$(ROOTDIR)/m68k-elf/lib -L$(ROOTDIR)/m68k-elf/lib/gcc/m68k-elf/$(CC_VER) -L$(ROOTDIR)/m68k-elf/m68k-elf/lib +INCPATH = -I$. -I$(ROOTDIR)/m68k-elf/include -I$(ROOTDIR)/m68k-elf/m68k-elf/include + +CCFLAGS = -m68000 -Wall -O1 -c -fomit-frame-pointer +ASFLAGS = -m68000 --register-prefix-optional +LINKFLAGS = -T $(LDSCRIPTSDIR)/mars-md.ld -Wl,-Map=output.map -nostdlib + +DD = dd +RM = rm -f + +TARGET = m68k +LIBS = $(LIBPATH) -lc -lgcc -lnosys +OBJS = crt0.o main.o kos.o cd.o + +all: $(TARGET).bin + +$(TARGET).bin: $(TARGET).elf + $(OBJC) -O binary $< $(TARGET).bin + +$(TARGET).elf: $(OBJS) + $(CC) $(LINKFLAGS) $(OBJS) $(LIBS) -o $(TARGET).elf + +%.o: %.c + $(CC) $(CCFLAGS) $(INCPATH) $< -o $@ + +%.o: %.s + $(AS) $(ASFLAGS) $(INCPATH) $< -o $@ + +clean: + $(RM) *.o *.bin *.elf output.map diff --git a/src/platform/32x/src-md/cd.s b/src/platform/32x/src-md/cd.s new file mode 100644 index 00000000..ecf0c0e9 --- /dev/null +++ b/src/platform/32x/src-md/cd.s @@ -0,0 +1,183 @@ + + .text + + .global Sub_Start +Sub_Start: + +| Standard MegaCD Sub-CPU Program Header (copied to 0x6000) + +SPHeader: + .asciz "MAIN-SUBCPU" + .word 0x0001,0x0000 + .long 0x00000000 + .long 0x00000000 + .long SPHeaderOffsets-SPHeader + .long 0x00000000 + +SPHeaderOffsets: + .word SPInit-SPHeaderOffsets + .word SPMain-SPHeaderOffsets + .word SPInt2-SPHeaderOffsets + .word SPNull-SPHeaderOffsets + .word 0x0000 + +| Sub-CPU Program Initialization (VBlank not enabled yet) + +SPInit: + move.b #'I,0x800F.w /* sub comm port = INITIALIZING */ + andi.b #0xE2,0x8003.w /* Priority Mode = off, 2M mode, Sub-CPU has access */ + rts + +| Sub-CPU Program Main Entry Point (VBlank now enabled) + +SPMain: + move.w #0x0081,d0 /* CDBSTAT */ + jsr 0x5F22.w /* call CDBIOS function */ + move.w 0(a0),d0 /* BIOS status word */ + bmi.b 1f /* not ready */ + lsr.w #8,d0 + cmpi.b #0x40,d0 + beq.b 9f /* open */ + cmpi.b #0x10,d0 + beq.b 9f /* no disc */ +1: +| Initialize Drive + lea drive_init_parms(pc),a0 + move.w #0x0010,d0 /* DRVINIT */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.w #0x0089,d0 /* CDCSTOP - stop reading data */ + jsr 0x5F22.w /* call CDBIOS function */ +9: + move.b #0,0x800F.w /* sub comm port = READY */ + +| wait for command in main comm port +WaitCmd: + tst.b 0x800E.w + beq.b WaitCmd + cmpi.b #'D,0x800E.w + beq GetDiscInfo + cmpi.b #'T,0x800E.w + beq GetTrackInfo + cmpi.b #'P,0x800E.w + beq PlayTrack + cmpi.b #'S,0x800E.w + beq StopPlaying + cmpi.b #'Z,0x800E.w + beq PauseResume + cmpi.b #'C,0x800E.w + beq CheckDisc + move.b #'E,0x800F.w /* sub comm port = ERROR */ +WaitAck: + tst.b 0x800E.w + bne.b WaitAck /* wait for result acknowledged */ + move.b #0,0x800F.w /* sub comm port = READY */ + bra.b WaitCmd + +GetDiscInfo: + move.w #0x0081,d0 /* CDBSTAT */ + jsr 0x5F22.w /* call CDBIOS function */ + move.w 0(a0),0x8020.w /* BIOS status word */ + move.w 16(a0),0x8022.w /* First song number, Last song number */ + move.w 18(a0),0x8024.w /* Drive version, Flag */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + +GetTrackInfo: + move.w 0x8010.w,d1 /* track number */ + move.w #0x0083,d0 /* CDBTOCREAD */ + jsr 0x5F22.w /* call CDBIOS function */ + move.l d0,0x8020.w /* MMSSFFTN */ + move.b d1,0x8024.w /* track type */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + +PlayTrack: + move.w #0x0002,d0 /* MSCSTOP - stop playing */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.w 0x8010.w,d1 /* track number */ + move.w #0x0011,d0 /* MSCPLAY - play from track on */ + move.b 0x8012.w,d2 /* flag */ + bmi.b 2f + beq.b 1f + move.w #0x0013,d0 /* MSCPLAYR - play with repeat */ + bra.b 2f +1: + move.w #0x0012,d0 /* MSCPLAY1 - play once */ +2: + lea track_number(pc),a0 + move.w d1,(a0) + jsr 0x5F22.w /* call CDBIOS function */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + +StopPlaying: + move.w #0x0002,d0 /* MSCSTOP - stop playing */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + +PauseResume: + move.w #0x0081,d0 /* CDBSTAT */ + jsr 0x5F22.w /* call CDBIOS function */ + move.b (a0),d0 + cmpi.b #1,d0 + beq.b 1f /* playing - pause playback */ + cmpi.b #5,d0 + beq.b 2f /* paused - resume playback */ + + move.b #'E,0x800F.w /* sub comm port = ERROR */ + bra WaitAck +1: + move.w #0x0003,d0 /* MSCPAUSEON - pause playback */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck +2: + move.w #0x0004,d0 /* MSCPAUSEOFF - resume playback */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + +CheckDisc: + lea drive_init_parms(pc),a0 + move.w #0x0010,d0 /* DRVINIT */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.w #0x0089,d0 /* CDCSTOP - stop reading data */ + jsr 0x5F22.w /* call CDBIOS function */ + + move.b #'D,0x800F.w /* sub comm port = DONE */ + bra WaitAck + + +| Sub-CPU Program VBlank (INT02) Service Handler + +SPInt2: + rts + +| Sub-CPU program Reserved Function + +SPNull: + rts + + +| Sub-CPU variables + + .align 2 +drive_init_parms: + .byte 0x01, 0xFF /* first track (1), last track (all) */ + +track_number: + .word 0 + + + .global Sub_End +Sub_End: diff --git a/src/platform/32x/src-md/crt0.s b/src/platform/32x/src-md/crt0.s new file mode 100644 index 00000000..491799cf --- /dev/null +++ b/src/platform/32x/src-md/crt0.s @@ -0,0 +1,607 @@ +| SEGA 32X support code for the 68000 +| by Chilly Willy + + .text + +| 0x880800 - entry point for reset/cold-start + + .global _start +_start: + +| Clear Work RAM + moveq #0,d0 + move.w #0x3FFF,d1 + suba.l a1,a1 +1: + move.l d0,-(a1) + dbra d1,1b + +| Copy initialized variables from ROM to Work RAM + lea __text_end,a0 + move.w #__data_size,d0 + lsr.w #1,d0 + subq.w #1,d0 +2: + move.w (a0)+,(a1)+ + dbra d0,2b + + lea __stack,sp /* set stack pointer to top of Work RAM */ + + bsr init_hardware /* initialize the console hardware */ + + jsr main /* call program main() */ +3: + stop #0x2700 + bra.b 3b + + .align 64 + +| 0x880840 - 68000 General exception handler + + move.l d0,-(sp) + move.l 4(sp),d0 /* jump table return address */ + sub.w #0x206,d0 /* 0 = BusError, 6 = AddrError, etc */ + + /* handle exception here */ + + move.l (sp)+,d0 + addq.l #4,sp /* pop jump table return address */ + rte + + .align 64 + +| 0x880880 - 68000 Level 4 interrupt handler - HBlank IRQ + + rte + + .align 64 + +| 0x8808C0 - 68000 Level 6 interrupt handler - VBlank IRQ + + move.l d0,-(sp) + move.l vblank,d0 + beq.b 1f + move.l a0,-(sp) + movea.l d0,a0 + jmp (a0) +1: + move.l (sp)+,d0 + rte + + +| Initialize the MD side to a known state for the game + +init_hardware: + lea 0xC00004,a0 + move.w #0x8104,(a0) /* display off, vblank disabled */ + move.w (a0),d0 /* read VDP Status reg */ + +| init joyports + move.b #0x40,0xA10009 + move.b #0x40,0xA1000B + move.b #0x40,0xA10003 + move.b #0x40,0xA10005 + +| init MD VDP + move.w #0x8004,(a0) /* reg. 0 - Disable HBL INT */ + move.w #0x8174,(a0) /* reg. 1 - Enable display, VBL INT, DMA + 28 VCell size */ + move.w #0x8230,(a0) /* reg. 2 - Plane A =$30*$400=$C000 */ + move.w #0x832C,(a0) /* reg. 3 - Window =$2C*$400=$B000 */ + move.w #0x8407,(a0) /* reg. 4 - Plane B =$7*$2000=$E000 */ + move.w #0x855E,(a0) /* reg. 5 - sprite table begins at $BC00=$5E*$200 */ + move.w #0x8600,(a0) /* reg. 6 - not used */ + move.w #0x8700,(a0) /* reg. 7 - Background Color number*/ + move.w #0x8800,(a0) /* reg. 8 - not used */ + move.w #0x8900,(a0) /* reg. 9 - not used */ + move.w #0x8A01,(a0) /* reg 10 - HInterrupt timing */ + move.w #0x8B00,(a0) /* reg 11 - $0000abcd a=extr.int b=vscr cd=hscr */ + move.w #0x8C81,(a0) /* reg 12 - hcell mode + shadow/highight + interlaced mode (40 cell, no shadow, no interlace)*/ + move.w #0x8D2E,(a0) /* reg 13 - HScroll Table = $B800 */ + move.w #0x8E00,(a0) /* reg 14 - not used */ + move.w #0x8F02,(a0) /* reg 15 - auto increment data */ + move.w #0x9011,(a0) /* reg 16 - scrl screen v&h size (64x64) */ + move.w #0x9100,(a0) /* reg 17 - window hpos */ + move.w #0x92FF,(a0) /* reg 18 - window vpos */ + + move.w #0,0xA15128 /* controller 1 */ + move.w #0,0xA1512A /* controller 2 */ +| look for mouse + lea 0xA10003,a0 +0: + jsr get_mky + cmpi.l #-2,d0 + beq.b 0b /* timeout */ + cmpi.l #-1,d0 + beq.b 1f /* no mouse */ + move.w #0xF001,0xA15128 /* mouse in port 1 */ +1: + lea 2(a0),a0 +2: + jsr get_mky + cmpi.l #-2,d0 + beq.b 2b /* timeout */ + cmpi.l #-1,d0 + beq.b 3f /* no mouse */ + move.w #0xF001,0xA1512A /* mouse in port 2 */ +3: + +| allow the 68k to access the FM chip + move.w #0x0100,0xA11100 /* Z80 assert bus request */ + move.w #0x0100,0xA11200 /* Z80 deassert reset */ + +| wait on Mars side + move.b #0,0xA15107 /* clear RV - allow SH2 to access ROM */ +0: + cmp.l #0x4D5F4F4B,0xA15120 /* M_OK */ + bne.b 0b /* wait for master ok */ +1: + cmp.l #0x535F4F4B,0xA15124 /* S_OK */ + bne.b 1b /* wait for slave ok */ + + move.l #vert_blank,vblank /* set vertical blank interrupt handler */ + move.w #0x2000,sr /* enable interrupts */ + rts + + +| void write_byte(void *dst, unsigned char val) + .global write_byte +write_byte: + movea.l 4(sp),a0 + move.l 8(sp),d0 + move.b d0,(a0) + rts + +| void write_word(void *dst, unsigned short val) + .global write_word +write_word: + movea.l 4(sp),a0 + move.l 8(sp),d0 + move.w d0,(a0) + rts + +| void write_long(void *dst, unsigned int val) + .global write_long +write_long: + movea.l 4(sp),a0 + move.l 8(sp),d0 + move.l d0,(a0) + rts + +| unsigned char read_byte(void *src) + .global read_byte +read_byte: + movea.l 4(sp),a0 + move.b (a0),d0 + rts + +| unsigned short read_word(void *src) + .global read_word +read_word: + movea.l 4(sp),a0 + move.w (a0),d0 + rts + +| unsigned int read_long(void *src) + .global read_long +read_long: + movea.l 4(sp),a0 + move.l (a0),d0 + rts + + + .data + +| Put remaining code in data section to lower bus contention for the rom. + + .global do_main +do_main: + move.b #1,0xA15107 /* set RV */ + move.b #2,0xA130F1 /* SRAM disabled, write protected */ + move.b #0,0xA15107 /* clear RV */ + + move.w 0xA15100,d0 + or.w #0x8000,d0 + move.w d0,0xA15100 /* set FM - allow SH2 access to MARS hw */ + move.l #0,0xA15120 /* let Master SH2 run */ + +main_loop: + move.w 0xA15120,d0 /* get COMM0 */ + bne.b handle_req + + nop + bra.b main_loop + +| process request from Master SH2 +handle_req: + cmpi.w #0x01FF,d0 + bls read_sram + cmpi.w #0x02FF,d0 + bls write_sram + cmpi.w #0x03FF,d0 + bls start_music + cmpi.w #0x04FF,d0 + bls stop_music + cmpi.w #0x05FF,d0 + bls read_mouse +| unknown command + move.w #0,0xA15120 /* done */ + bra.b main_loop + +read_sram: + move.w #0x2700,sr /* disable ints */ + moveq #0,d1 + moveq #0,d0 + move.w 0xA15122,d0 /* COMM2 holds offset */ + lea 0x200000,a0 + move.b #1,0xA15107 /* set RV */ + move.b #3,0xA130F1 /* SRAM enabled, write protected */ + move.b 1(a0,d0.l),d1 /* read SRAM */ + move.b #2,0xA130F1 /* SRAM disabled, write protected */ + move.b #0,0xA15107 /* clear RV */ + move.w d1,0xA15122 /* COMM2 holds return byte */ + move.w #0,0xA15120 /* done */ + move.w #0x2000,sr /* enable ints */ + bra main_loop + +write_sram: + move.w #0x2700,sr /* disable ints */ + moveq #0,d1 + move.w 0xA15122,d1 /* COMM2 holds offset */ + lea 0x200000,a0 + move.b #1,0xA15107 /* set RV */ + move.b #1,0xA130F1 /* SRAM enabled, write enabled */ + move.b d0,1(a0,d1.l) /* write SRAM */ + move.b #2,0xA130F1 /* SRAM disabled, write protected */ + move.b #0,0xA15107 /* clear RV */ + move.w #0,0xA15120 /* done */ + move.w #0x2000,sr /* enable ints */ + bra main_loop + +set_rom_bank: + move.l a0,d3 + swap d3 + lsr.w #4,d3 + andi.w #3,d3 + move.w d3,0xA15104 /* set ROM bank select */ + move.l a0,d3 + andi.l #0x0FFFFF,d3 + ori.l #0x900000,d3 + movea.l d3,a1 + rts + +start_music: + tst.w cd_ok + beq.b 2f /* couldn't init cd */ + tst.b cd_ok + bne.b 0f /* disc found - try to play track */ + /* check for CD */ +10: + move.b 0xA1200F,d1 + bne.b 10b /* wait until Sub-CPU is ready to receive command */ + move.b #'D,0xA1200E /* set main comm port to GetDiskInfo command */ +11: + move.b 0xA1200F,d0 + beq.b 11b /* wait for acknowledge byte in sub comm port */ + move.b #0x00,0xA1200E /* acknowledge receipt of command result */ + + cmpi.b #'D,d0 + bne.b 2f /* couldn't get disk info */ + move.w 0xA12020,d0 /* BIOS status */ + cmpi.w #0x1000,d0 + bhs.b 2f /* open, busy, or no disc */ + move.b #1,cd_ok /* we have a disc - try to play track */ +0: + move.b 0xA1200F,d1 + bne.b 0b /* wait until Sub-CPU is ready to receive command */ + + move.b d0,0xA12012 /* repeat flag */ + move.w 0xA15122,d0 + addq.w #1,d0 + move.w d0,0xA12010 /* track no. */ + move.b #'P,0xA1200E /* set main comm port to PlayTrack command */ +1: + move.b 0xA1200F,d0 + beq.b 1b /* wait for acknowledge byte in sub comm port */ + move.b #0x00,0xA1200E /* acknowledge receipt of command result */ +2: + move.w #0,0xA15120 /* done */ + bra main_loop + +stop_music: + tst.w cd_ok + beq.b 2f +0: + move.b 0xA1200F,d1 + bne.b 0b /* wait until Sub-CPU is ready to receive command */ + + move.b #'S,0xA1200E /* set main comm port to StopPlayback command */ +1: + move.b 0xA1200F,d0 + beq.b 1b /* wait for acknowledge byte in sub comm port */ + move.b #0x00,0xA1200E /* acknowledge receipt of command result */ +2: + move.w #0,0xA15120 /* done */ + bra main_loop + +read_mouse: + tst.b d0 + bne.b 1f /* skip port 1 */ + + move.w 0xA15128,d0 + andi.w #0xF001,d0 + cmpi.w #0xF001,d0 + bne.b 1f /* no mouse in port 1 */ + lea 0xA10003,a0 + bsr get_mky + bset #31,d0 + move.w d0,0xA15122 + swap d0 + move.w d0,0xA15120 +0: + move.w 0xA15120,d0 + bne.b 0b /* wait for SH2 to read mouse value */ + bra main_loop +1: + move.w 0xA1512A,d0 + andi.w #0xF001,d0 + cmpi.w #0xF001,d0 + bne.b 3f /* no mouse in port 2 */ + lea 0xA10005,a0 + bsr get_mky + bset #31,d0 + move.w d0,0xA15122 + swap d0 + move.w d0,0xA15120 +2: + move.w 0xA15120,d0 + bne.b 2b /* wait for SH2 to read mouse value */ + bra main_loop +3: + move.l #-1,d0 /* no mouse */ + move.w d0,0xA15122 + swap d0 + move.w d0,0xA15120 +4: + move.w 0xA15120,d0 + bne.b 4b /* wait for SH2 to read mouse value */ + bra main_loop + + +vert_blank: + move.l d1,-(sp) + move.l d2,-(sp) + + /* read controllers */ + move.w 0xA15128,d0 + andi.w #0xF000,d0 + cmpi.w #0xF000,d0 + beq.b 0f /* no pad in port 1 (or mouse) */ + lea 0xA10003,a0 + bsr.b get_pad + move.w d2,0xA15128 /* controller 1 current value */ +0: + move.w 0xA1512A,d0 + andi.w #0xF000,d0 + cmpi.w #0xF000,d0 + beq.b 1f /* no pad in port 2 (or mouse) */ + lea 0xA10005,a0 + bsr.b get_pad + move.w d2,0xA1512A /* controller 2 current value */ +1: + + tst.w gen_lvl2 + beq.b 2f + lea 0xA12000,a0 + move.w (a0),d0 + ori.w #0x0100,d0 + move.w d0,(a0) +2: + move.l (sp)+,d2 + move.l (sp)+,d1 + movea.l (sp)+,a0 + move.l (sp)+,d0 + rte + +| get current pad value +| entry: a0 = pad control port +| exit: d2 = pad value (0 0 0 1 M X Y Z S A C B R L D U) or (0 0 0 0 0 0 0 0 S A C B R L D U) +get_pad: + bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */ + move.w d0,d1 + andi.w #0x0C00,d0 + bne.b no_pad + bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */ + bsr.b get_input /* - 0 s a 0 0 0 0 - 1 c b m x y z */ + move.w d0,d2 + bsr.b get_input /* - 0 s a 1 1 1 1 - 1 c b r l d u */ + andi.w #0x0F00,d0 /* 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 */ + cmpi.w #0x0F00,d0 + beq.b common /* six button pad */ + move.w #0x010F,d2 /* three button pad */ +common: + lsl.b #4,d2 /* - 0 s a 0 0 0 0 m x y z 0 0 0 0 */ + lsl.w #4,d2 /* 0 0 0 0 m x y z 0 0 0 0 0 0 0 0 */ + andi.w #0x303F,d1 /* 0 0 s a 0 0 0 0 0 0 c b r l d u */ + move.b d1,d2 /* 0 0 0 0 m x y z 0 0 c b r l d u */ + lsr.w #6,d1 /* 0 0 0 0 0 0 0 0 s a 0 0 0 0 0 0 */ + or.w d1,d2 /* 0 0 0 0 m x y z s a c b r l d u */ + eori.w #0x1FFF,d2 /* 0 0 0 1 M X Y Z S A C B R L D U */ + rts + +no_pad: + move.w #0xF000,d2 + rts + +| read single phase from controller +get_input: + move.b #0x00,(a0) + nop + nop + move.b (a0),d0 + move.b #0x40,(a0) + lsl.w #8,d0 + move.b (a0),d0 + rts + +| get current mouse value +| entry: a0 = mouse control port +| exit: d0 = mouse value (0 0 0 0 0 0 0 0 YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0) or -2 (timeout) or -1 (no mouse) +get_mky: + move.w sr,d2 + move.w #0x2700,sr /* disable ints */ + + move.b #0x60,6(a0) /* set direction bits */ + nop + nop + move.b #0x60,(a0) /* first phase of mouse packet */ + nop + nop +0: + btst #4,(a0) + beq.b 0b /* wait on handshake */ + move.b (a0),d0 + andi.b #15,d0 + bne mky_err /* not 0 means not mouse */ + + move.b #0x20,(a0) /* next phase */ + move.w #254,d1 /* number retries before timeout */ +1: + btst #4,(a0) + bne.b 2f /* handshake */ + dbra d1,1b + bra timeout_err +2: + move.b (a0),d0 + andi.b #15,d0 + move.b #0,(a0) /* next phase */ + cmpi.b #11,d0 + bne mky_err /* not 11 means not mouse */ +3: + btst #4,(a0) + beq.b 4f /* handshake */ + dbra d1,3b + bra timeout_err +4: + move.b (a0),d0 /* specs say should be 15 */ + nop + nop + move.b #0x20,(a0) /* next phase */ + nop + nop +5: + btst #4,(a0) + bne.b 6f + dbra d1,5b + bra timeout_err +6: + move.b (a0),d0 /* specs say should be 15 */ + nop + nop + move.b #0,(a0) /* next phase */ + moveq #0,d0 /* clear reg to hold packet */ + nop +7: + btst #4,(a0) + beq.b 8f /* handshake */ + dbra d1,7b + bra timeout_err +8: + move.b (a0),d0 /* YO XO YS XS */ + move.b #0x20,(a0) /* next phase */ + lsl.w #8,d0 /* save nibble */ +9: + btst #4,(a0) + bne.b 10f /* handshake */ + dbra d1,9b + bra timeout_err +10: + move.b (a0),d0 /* S M R L */ + move.b #0,(a0) /* next phase */ + lsl.b #4,d0 /* YO XO YS XS S M R L 0 0 0 0 */ + lsl.l #4,d0 /* YO XO YS XS S M R L 0 0 0 0 0 0 0 0 */ +11: + btst #4,(a0) + beq.b 12f /* handshake */ + dbra d1,11b + bra timeout_err +12: + move.b (a0),d0 /* X7 X6 X5 X4 */ + move.b #0x20,(a0) /* next phase */ + lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 0 0 0 0 */ + lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 0 0 0 0 0 0 0 0 */ +13: + btst #4,(a0) + bne.b 14f /* handshake */ + dbra d1,13b + bra timeout_err +14: + move.b (a0),d0 /* X3 X2 X1 X0 */ + move.b #0,(a0) /* next phase */ + lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 0 0 0 0 */ + lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 0 0 0 0 0 0 0 0 */ +15: + btst #4,(a0) + beq.b 16f /* handshake */ + dbra d1,15b + bra timeout_err +16: + move.b (a0),d0 /* Y7 Y6 Y5 Y4 */ + move.b #0x20,(a0) /* next phase */ + lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 0 0 0 0 */ + lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 0 0 0 0 0 0 0 0*/ +17: + btst #4,(a0) + beq.b 18f /* handshake */ + dbra d1,17b + bra timeout_err +18: + move.b (a0),d0 /* Y3 Y2 Y1 Y0 */ + move.b #0x60,(a0) /* first phase */ + lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 0 0 0 0 */ + lsr.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ +19: + btst #4,(a0) + beq.b 19b /* wait on handshake */ + + move.w d2,sr /* restore int status */ + rts + +timeout_err: + move.b #0x60,(a0) /* first phase */ + nop + nop +0: + btst #4,(a0) + beq.b 0b /* wait on handshake */ + + move.w d2,sr /* restore int status */ + moveq #-2,d0 + rts + +mky_err: + move.b #0x40,6(a0) /* set direction bits */ + nop + nop + move.b #0x40,(a0) + + move.w d2,sr /* restore int status */ + moveq #-1,d0 + rts + + +| Global variables for 68000 + + .align 4 + +vblank: + dc.l 0 + + .global gen_lvl2 +gen_lvl2: + dc.w 0 + + .global cd_ok +cd_ok: + dc.w 0 + + .align 4 diff --git a/src/platform/32x/src-md/kos.s b/src/platform/32x/src-md/kos.s new file mode 100644 index 00000000..c05f836f --- /dev/null +++ b/src/platform/32x/src-md/kos.s @@ -0,0 +1,110 @@ +| --------------------------------------------------------------------------- +| Kosinski decompression subroutine +| void Kos_Decomp(uint8_t *src, uint8_t *dst) +| Inputs: +| 4(sp) = compressed data location +| 8(sp) = destination +| --------------------------------------------------------------------------- + + .text + + .global Kos_Decomp +Kos_Decomp: + movea.l 4(sp),a0 + movea.l 8(sp),a1 + movem.l d2-d6,-(sp) + subq.l #2,sp /* make space for two bytes on the stack */ + move.b (a0)+,1(sp) + move.b (a0)+,(sp) + move.w (sp),d5 /* copy first description field */ + moveq #15,d4 /* 16 bits in a byte */ + +Kos_Decomp_Loop: + lsr.w #1,d5 /* bit which is shifted out goes into C flag */ + move sr,d6 + dbra d4,Kos_Decomp_ChkBit + move.b (a0)+,1(sp) + move.b (a0)+,(sp) + move.w (sp),d5 /* get next description field if needed */ + moveq #15,d4 /* reset bit counter */ + +Kos_Decomp_ChkBit: + move d6,ccr /* was the bit set? */ + bcc.b Kos_Decomp_RLE /* if not, branch (C flag clear means bit was clear) */ + move.b (a0)+,(a1)+ /* otherwise, copy byte as-is */ + bra.b Kos_Decomp_Loop + +| --------------------------------------------------------------------------- + +Kos_Decomp_RLE: + moveq #0,d3 + lsr.w #1,d5 /* get next bit */ + move sr,d6 + dbra d4,Kos_Decomp_ChkBit2 + move.b (a0)+,1(sp) + move.b (a0)+,(sp) + move.w (sp),d5 + moveq #15,d4 + +Kos_Decomp_ChkBit2: + move d6,ccr /* was the bit set? */ + bcs.b Kos_Decomp_SeparateRLE /* if it was, branch */ + lsr.w #1,d5 /* bit which is shifted out goes into X flag */ + dbra d4,1f + move.b (a0)+,1(sp) + move.b (a0)+,(sp) + move.w (sp),d5 + moveq #15,d4 +1: + roxl.w #1,d3 /* get high repeat count bit (shift X flag in) */ + lsr.w #1,d5 + dbra d4,2f + move.b (a0)+,1(sp) + move.b (a0)+,(sp) + move.w (sp),d5 + moveq #15,d4 +2: + roxl.w #1,d3 /* get low repeat count bit */ + addq.w #1,d3 /* increment repeat count */ + moveq #-1,d2 + move.b (a0)+,d2 /* calculate offset */ + bra.b Kos_Decomp_RLELoop + +| --------------------------------------------------------------------------- + +Kos_Decomp_SeparateRLE: + move.b (a0)+,d0 /* get first byte */ + move.b (a0)+,d1 /* get second byte */ + moveq #-1,d2 + move.b d1,d2 + lsl.w #5,d2 + move.b d0,d2 /* calculate offset */ + andi.w #7,d1 /* does a third byte need to be read? */ + beq.b Kos_Decomp_SeparateRLE2 /* if it does, branch */ + move.b d1,d3 /* copy repeat count */ + addq.w #1,d3 /* and increment it */ + +Kos_Decomp_RLELoop: + move.b (a1,d2.w),d0 + move.b d0,(a1)+ /* copy appropriate byte */ + dbra d3,Kos_Decomp_RLELoop /* and repeat the copying */ + bra.b Kos_Decomp_Loop + +| --------------------------------------------------------------------------- + +Kos_Decomp_SeparateRLE2: + move.b (a0)+,d1 + beq.b Kos_Decomp_Done /* 0 indicates end of compressed data */ + cmpi.b #1,d1 + beq.w Kos_Decomp_Loop /* 1 indicates a new description needs to be read */ + move.b d1,d3 /* otherwise, copy repeat count */ + bra.b Kos_Decomp_RLELoop + +| --------------------------------------------------------------------------- + +Kos_Decomp_Done: + addq.l #2,sp /* restore stack pointer to original state */ + movem.l (sp)+,d2-d6 + rts + +| End of function Kos_Decomp diff --git a/src/platform/32x/src-md/main.c b/src/platform/32x/src-md/main.c new file mode 100644 index 00000000..563c8bef --- /dev/null +++ b/src/platform/32x/src-md/main.c @@ -0,0 +1,130 @@ +/* + * SEGA CD Mode 1 Support + * by Chilly Willy + */ + +#include +#include + +extern uint32_t vblank_vector; +extern uint16_t gen_lvl2; +extern uint16_t cd_ok; + +extern uint32_t Sub_Start; +extern uint32_t Sub_End; + +extern void Kos_Decomp(uint8_t *src, uint8_t *dst); + +extern void write_byte(unsigned int dst, unsigned char val); +extern void write_word(unsigned int dst, unsigned short val); +extern void write_long(unsigned int dst, unsigned int val); +extern unsigned char read_byte(unsigned int src); +extern unsigned short read_word(unsigned int src); +extern unsigned int read_long(unsigned int src); + +extern void do_main(void); + +uint16_t InitCD(void) +{ + char *bios; + + /* + * Check for CD BIOS + * When a cart is inserted in the MD, the CD hardware is mapped to + * 0x400000 instead of 0x000000. So the BIOS ROM is at 0x400000, the + * Program RAM bank is at 0x420000, and the Word RAM is at 0x600000. + */ + bios = (char *)0x415800; + if (memcmp(bios + 0x6D, "SEGA", 4)) + { + bios = (char *)0x416000; + if (memcmp(bios + 0x6D, "SEGA", 4)) + { + // check for WonderMega/X'Eye + if (memcmp(bios + 0x6D, "WONDER", 6)) + { + bios = (char *)0x41AD00; // might also be 0x40D500 + // check for LaserActive + if (memcmp(bios + 0x6D, "SEGA", 4)) + return 0; // no CD + } + } + } + + /* + * Reset the Gate Array - this specific sequence of writes is recognized by + * the gate array as a reset sequence, clearing the entire internal state - + * this is needed for the LaserActive + */ + write_word(0xA12002, 0xFF00); + write_byte(0xA12001, 0x03); + write_byte(0xA12001, 0x02); + write_byte(0xA12001, 0x00); + + /* + * Reset the Sub-CPU, request the bus + */ + write_byte(0xA12001, 0x02); + while (!(read_byte(0xA12001) & 2)) write_byte(0xA12001, 0x02); // wait on bus acknowledge + + /* + * Decompress Sub-CPU BIOS to Program RAM at 0x00000 + */ + write_word(0xA12002, 0x0002); // no write-protection, bank 0, 2M mode, Word RAM assigned to Sub-CPU + memset((char *)0x420000, 0, 0x20000); // clear program ram first bank - needed for the LaserActive + Kos_Decomp((uint8_t *)bios, (uint8_t *)0x420000); + + /* + * Copy Sub-CPU program to Program RAM at 0x06000 + */ + memcpy((char *)0x426000, (char *)&Sub_Start, (int)&Sub_End - (int)&Sub_Start); + + write_byte(0xA1200E, 0x00); // clear main comm port + write_byte(0xA12002, 0x2A); // write-protect up to 0x05400 + write_byte(0xA12001, 0x01); // clear bus request, deassert reset - allow CD Sub-CPU to run + while (!(read_byte(0xA12001) & 1)) write_byte(0xA12001, 0x01); // wait on Sub-CPU running + + /* + * Set the vertical blank handler to generate Sub-CPU level 2 ints. + * The Sub-CPU BIOS needs these in order to run. + */ + gen_lvl2 = 1; // generate Level 2 IRQ to Sub-CPU + + /* + * Wait for Sub-CPU program to set sub comm port indicating it is running - + * note that unless there's something wrong with the hardware, a timeout isn't + * needed... just loop until the Sub-CPU program responds, but 2000000 is about + * ten times what the LaserActive needs, and the LA is the slowest unit to + * initialize + */ + while (read_byte(0xA1200F) != 'I') + { + static int timeout = 0; + timeout++; + if (timeout > 2000000) + { + gen_lvl2 = 0; + return 0; // no CD + } + } + + /* + * Wait for Sub-CPU to indicate it is ready to receive commands + */ + while (read_byte(0xA1200F) != 0x00) ; + + return 1; // CD ready to go! +} + +int main(void) +{ + cd_ok = 0; //InitCD(); + + /* + * Main loop in ram - you need to have it in ram to avoid bus contention + * for the rom with the SH2s. + */ + do_main(); // never returns + + return 0; +} diff --git a/src/platform/3do/CD/AppStartup b/src/platform/3do/CD/AppStartup new file mode 100644 index 00000000..883e48b2 --- /dev/null +++ b/src/platform/3do/CD/AppStartup @@ -0,0 +1,3 @@ +#minmem +# show CPU, DRAM, VRAM and DSP usage +#$c/sysload diff --git a/src/platform/3do/CD/System/Audio/aiff/sinewave.aiff b/src/platform/3do/CD/System/Audio/aiff/sinewave.aiff new file mode 100644 index 00000000..9c0c3142 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/aiff/sinewave.aiff differ diff --git a/src/platform/3do/CD/System/Audio/dsp/add.dsp b/src/platform/3do/CD/System/Audio/dsp/add.dsp new file mode 100644 index 00000000..0f9d9931 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/add.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/adpcmduck22s.dsp b/src/platform/3do/CD/System/Audio/dsp/adpcmduck22s.dsp new file mode 100644 index 00000000..a0bc0963 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/adpcmduck22s.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/adpcmhalfmono.dsp b/src/platform/3do/CD/System/Audio/dsp/adpcmhalfmono.dsp new file mode 100644 index 00000000..d9ce5cfb Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/adpcmhalfmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/adpcmmono.dsp b/src/platform/3do/CD/System/Audio/dsp/adpcmmono.dsp new file mode 100644 index 00000000..8f5ca55d Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/adpcmmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/adpcmvarmono.dsp b/src/platform/3do/CD/System/Audio/dsp/adpcmvarmono.dsp new file mode 100644 index 00000000..d51221d6 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/adpcmvarmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/benchmark.dsp b/src/platform/3do/CD/System/Audio/dsp/benchmark.dsp new file mode 100644 index 00000000..0dee342c Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/benchmark.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfmono.dsp b/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfmono.dsp new file mode 100644 index 00000000..7321d32f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfstereo.dsp b/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfstereo.dsp new file mode 100644 index 00000000..4996231d Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/dcsqxdhalfstereo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/dcsqxdmono.dsp b/src/platform/3do/CD/System/Audio/dsp/dcsqxdmono.dsp new file mode 100644 index 00000000..ea3eb8c3 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/dcsqxdmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/dcsqxdstereo.dsp b/src/platform/3do/CD/System/Audio/dsp/dcsqxdstereo.dsp new file mode 100644 index 00000000..35395e18 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/dcsqxdstereo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/dcsqxdvarmono.dsp b/src/platform/3do/CD/System/Audio/dsp/dcsqxdvarmono.dsp new file mode 100644 index 00000000..7397e108 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/dcsqxdvarmono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/decodeadpcm.dsp b/src/platform/3do/CD/System/Audio/dsp/decodeadpcm.dsp new file mode 100644 index 00000000..0f77f571 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/decodeadpcm.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/deemphcd.dsp b/src/platform/3do/CD/System/Audio/dsp/deemphcd.dsp new file mode 100644 index 00000000..a179e33e Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/deemphcd.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/delay1tap.dsp b/src/platform/3do/CD/System/Audio/dsp/delay1tap.dsp new file mode 100644 index 00000000..8f743204 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/delay1tap.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/delaymono.dsp b/src/platform/3do/CD/System/Audio/dsp/delaymono.dsp new file mode 100644 index 00000000..f42be17a Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/delaymono.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/delaystereo.dsp b/src/platform/3do/CD/System/Audio/dsp/delaystereo.dsp new file mode 100644 index 00000000..e72cdc19 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/delaystereo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/directin.dsp b/src/platform/3do/CD/System/Audio/dsp/directin.dsp new file mode 100644 index 00000000..8d3ff761 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/directin.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/directout.dsp b/src/platform/3do/CD/System/Audio/dsp/directout.dsp new file mode 100644 index 00000000..62a1d758 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/directout.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/envelope.dsp b/src/platform/3do/CD/System/Audio/dsp/envelope.dsp new file mode 100644 index 00000000..4e47ed39 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/envelope.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/envfollower.dsp b/src/platform/3do/CD/System/Audio/dsp/envfollower.dsp new file mode 100644 index 00000000..a47cf3fa Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/envfollower.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/ezflix225.dsp b/src/platform/3do/CD/System/Audio/dsp/ezflix225.dsp new file mode 100644 index 00000000..ae5bd81b Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/ezflix225.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/filterednoise.dsp b/src/platform/3do/CD/System/Audio/dsp/filterednoise.dsp new file mode 100644 index 00000000..0c3c2b53 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/filterednoise.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/fixedmono8.dsp b/src/platform/3do/CD/System/Audio/dsp/fixedmono8.dsp new file mode 100644 index 00000000..d826d995 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/fixedmono8.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/fixedmonosample.dsp b/src/platform/3do/CD/System/Audio/dsp/fixedmonosample.dsp new file mode 100644 index 00000000..afd80250 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/fixedmonosample.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/fixedstereo16swap.dsp b/src/platform/3do/CD/System/Audio/dsp/fixedstereo16swap.dsp new file mode 100644 index 00000000..a4348d02 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/fixedstereo16swap.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/fixedstereo8.dsp b/src/platform/3do/CD/System/Audio/dsp/fixedstereo8.dsp new file mode 100644 index 00000000..e095d934 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/fixedstereo8.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/fixedstereosample.dsp b/src/platform/3do/CD/System/Audio/dsp/fixedstereosample.dsp new file mode 100644 index 00000000..ff1404c5 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/fixedstereosample.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/halfmono8.dsp b/src/platform/3do/CD/System/Audio/dsp/halfmono8.dsp new file mode 100644 index 00000000..06de9088 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/halfmono8.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/halfmonosample.dsp b/src/platform/3do/CD/System/Audio/dsp/halfmonosample.dsp new file mode 100644 index 00000000..6cc58e82 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/halfmonosample.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/halfstereo8.dsp b/src/platform/3do/CD/System/Audio/dsp/halfstereo8.dsp new file mode 100644 index 00000000..1e1b4672 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/halfstereo8.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/halfstereosample.dsp b/src/platform/3do/CD/System/Audio/dsp/halfstereosample.dsp new file mode 100644 index 00000000..93f69ae0 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/halfstereosample.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/head.dsp b/src/platform/3do/CD/System/Audio/dsp/head.dsp new file mode 100644 index 00000000..a2665d08 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/head.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/impulse.dsp b/src/platform/3do/CD/System/Audio/dsp/impulse.dsp new file mode 100644 index 00000000..aeb6362b Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/impulse.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/maximum.dsp b/src/platform/3do/CD/System/Audio/dsp/maximum.dsp new file mode 100644 index 00000000..61b2ae32 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/maximum.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/minimum.dsp b/src/platform/3do/CD/System/Audio/dsp/minimum.dsp new file mode 100644 index 00000000..78563a54 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/minimum.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/mixer12x2.dsp b/src/platform/3do/CD/System/Audio/dsp/mixer12x2.dsp new file mode 100644 index 00000000..23d8b6f8 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/mixer12x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/mixer2x2.dsp b/src/platform/3do/CD/System/Audio/dsp/mixer2x2.dsp new file mode 100644 index 00000000..40831915 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/mixer2x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/mixer4x2.dsp b/src/platform/3do/CD/System/Audio/dsp/mixer4x2.dsp new file mode 100644 index 00000000..2e561690 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/mixer4x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/mixer8x2.dsp b/src/platform/3do/CD/System/Audio/dsp/mixer8x2.dsp new file mode 100644 index 00000000..2de70167 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/mixer8x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/mixer8x2amp.dsp b/src/platform/3do/CD/System/Audio/dsp/mixer8x2amp.dsp new file mode 100644 index 00000000..eeb3f71f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/mixer8x2amp.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/monitor.dsp b/src/platform/3do/CD/System/Audio/dsp/monitor.dsp new file mode 100644 index 00000000..60802e5f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/monitor.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/multiply.dsp b/src/platform/3do/CD/System/Audio/dsp/multiply.dsp new file mode 100644 index 00000000..38ddcd69 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/multiply.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/noise.dsp b/src/platform/3do/CD/System/Audio/dsp/noise.dsp new file mode 100644 index 00000000..1414a933 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/noise.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/oscupdownfp.dsp b/src/platform/3do/CD/System/Audio/dsp/oscupdownfp.dsp new file mode 100644 index 00000000..1429eaf1 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/oscupdownfp.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/probe.dsp b/src/platform/3do/CD/System/Audio/dsp/probe.dsp new file mode 100644 index 00000000..67ff100b Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/probe.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/pulse.dsp b/src/platform/3do/CD/System/Audio/dsp/pulse.dsp new file mode 100644 index 00000000..cabf3983 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/pulse.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/pulse_lfo.dsp b/src/platform/3do/CD/System/Audio/dsp/pulse_lfo.dsp new file mode 100644 index 00000000..9a950cd9 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/pulse_lfo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/pulser.dsp b/src/platform/3do/CD/System/Audio/dsp/pulser.dsp new file mode 100644 index 00000000..1b427677 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/pulser.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/randomhold.dsp b/src/platform/3do/CD/System/Audio/dsp/randomhold.dsp new file mode 100644 index 00000000..8d8c3f14 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/randomhold.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/rednoise.dsp b/src/platform/3do/CD/System/Audio/dsp/rednoise.dsp new file mode 100644 index 00000000..daeced19 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/rednoise.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/romhead.dsp b/src/platform/3do/CD/System/Audio/dsp/romhead.dsp new file mode 100644 index 00000000..8b711413 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/romhead.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/romtail.dsp b/src/platform/3do/CD/System/Audio/dsp/romtail.dsp new file mode 100644 index 00000000..91c7026d Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/romtail.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sampler.dsp b/src/platform/3do/CD/System/Audio/dsp/sampler.dsp new file mode 100644 index 00000000..1a23090f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sampler.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sampler3d.dsp b/src/platform/3do/CD/System/Audio/dsp/sampler3d.dsp new file mode 100644 index 00000000..3e3e6d81 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sampler3d.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/samplerenv.dsp b/src/platform/3do/CD/System/Audio/dsp/samplerenv.dsp new file mode 100644 index 00000000..4a718488 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/samplerenv.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/samplermod.dsp b/src/platform/3do/CD/System/Audio/dsp/samplermod.dsp new file mode 100644 index 00000000..6833a4b7 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/samplermod.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sawenv.dsp b/src/platform/3do/CD/System/Audio/dsp/sawenv.dsp new file mode 100644 index 00000000..49d06288 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sawenv.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sawenvsvfenv.dsp b/src/platform/3do/CD/System/Audio/dsp/sawenvsvfenv.dsp new file mode 100644 index 00000000..c7362185 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sawenvsvfenv.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sawfilterednoise.dsp b/src/platform/3do/CD/System/Audio/dsp/sawfilterednoise.dsp new file mode 100644 index 00000000..2f3ece32 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sawfilterednoise.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sawfilteredsaw.dsp b/src/platform/3do/CD/System/Audio/dsp/sawfilteredsaw.dsp new file mode 100644 index 00000000..9f59903c Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sawfilteredsaw.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/sawtooth.dsp b/src/platform/3do/CD/System/Audio/dsp/sawtooth.dsp new file mode 100644 index 00000000..855d0206 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/sawtooth.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/splitexec.dsp b/src/platform/3do/CD/System/Audio/dsp/splitexec.dsp new file mode 100644 index 00000000..cb8ade67 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/splitexec.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/square.dsp b/src/platform/3do/CD/System/Audio/dsp/square.dsp new file mode 100644 index 00000000..b1c30c9d Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/square.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/square_lfo.dsp b/src/platform/3do/CD/System/Audio/dsp/square_lfo.dsp new file mode 100644 index 00000000..3f14cef5 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/square_lfo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/submixer2x2.dsp b/src/platform/3do/CD/System/Audio/dsp/submixer2x2.dsp new file mode 100644 index 00000000..69ce6d43 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/submixer2x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/submixer4x2.dsp b/src/platform/3do/CD/System/Audio/dsp/submixer4x2.dsp new file mode 100644 index 00000000..1f52d5d6 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/submixer4x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/submixer8x2.dsp b/src/platform/3do/CD/System/Audio/dsp/submixer8x2.dsp new file mode 100644 index 00000000..7f56dac6 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/submixer8x2.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/subtract.dsp b/src/platform/3do/CD/System/Audio/dsp/subtract.dsp new file mode 100644 index 00000000..d82d5170 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/subtract.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/svfilter.dsp b/src/platform/3do/CD/System/Audio/dsp/svfilter.dsp new file mode 100644 index 00000000..87a2fbaa Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/svfilter.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/tail.dsp b/src/platform/3do/CD/System/Audio/dsp/tail.dsp new file mode 100644 index 00000000..e20f2c95 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/tail.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/tapoutput.dsp b/src/platform/3do/CD/System/Audio/dsp/tapoutput.dsp new file mode 100644 index 00000000..e23b4b42 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/tapoutput.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/timesplus.dsp b/src/platform/3do/CD/System/Audio/dsp/timesplus.dsp new file mode 100644 index 00000000..d9a16c40 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/timesplus.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/triangle.dsp b/src/platform/3do/CD/System/Audio/dsp/triangle.dsp new file mode 100644 index 00000000..a747848f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/triangle.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/triangle_lfo.dsp b/src/platform/3do/CD/System/Audio/dsp/triangle_lfo.dsp new file mode 100644 index 00000000..6245ff72 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/triangle_lfo.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/varmono16.dsp b/src/platform/3do/CD/System/Audio/dsp/varmono16.dsp new file mode 100644 index 00000000..52acda78 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/varmono16.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/varmono8.dsp b/src/platform/3do/CD/System/Audio/dsp/varmono8.dsp new file mode 100644 index 00000000..ee572d65 Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/varmono8.dsp differ diff --git a/src/platform/3do/CD/System/Audio/dsp/varmono8_s.dsp b/src/platform/3do/CD/System/Audio/dsp/varmono8_s.dsp new file mode 100644 index 00000000..7e33f58f Binary files /dev/null and b/src/platform/3do/CD/System/Audio/dsp/varmono8_s.dsp differ diff --git a/src/platform/3do/CD/System/Daemons/junk b/src/platform/3do/CD/System/Daemons/junk new file mode 100644 index 00000000..67c32976 --- /dev/null +++ b/src/platform/3do/CD/System/Daemons/junk @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/platform/3do/CD/System/Devices/FMV/CL45016Bit.UCode b/src/platform/3do/CD/System/Devices/FMV/CL45016Bit.UCode new file mode 100644 index 00000000..c28c0e92 Binary files /dev/null and b/src/platform/3do/CD/System/Devices/FMV/CL45016Bit.UCode differ diff --git a/src/platform/3do/CD/System/Devices/FMV/CL45024Bit.UCode b/src/platform/3do/CD/System/Devices/FMV/CL45024Bit.UCode new file mode 100644 index 00000000..00607067 Binary files /dev/null and b/src/platform/3do/CD/System/Devices/FMV/CL45024Bit.UCode differ diff --git a/src/platform/3do/CD/System/Devices/FMV/CL450Boot.UCode b/src/platform/3do/CD/System/Devices/FMV/CL450Boot.UCode new file mode 100644 index 00000000..d437289d Binary files /dev/null and b/src/platform/3do/CD/System/Devices/FMV/CL450Boot.UCode differ diff --git a/src/platform/3do/CD/System/Devices/FMVVIDEODEVICE.PRIVDEVICE b/src/platform/3do/CD/System/Devices/FMVVIDEODEVICE.PRIVDEVICE new file mode 100644 index 00000000..44758444 Binary files /dev/null and b/src/platform/3do/CD/System/Devices/FMVVIDEODEVICE.PRIVDEVICE differ diff --git a/src/platform/3do/CD/System/Devices/ns.privdevice b/src/platform/3do/CD/System/Devices/ns.privdevice new file mode 100644 index 00000000..192d3839 Binary files /dev/null and b/src/platform/3do/CD/System/Devices/ns.privdevice differ diff --git a/src/platform/3do/CD/System/Drivers/cport1.rom b/src/platform/3do/CD/System/Drivers/cport1.rom new file mode 100644 index 00000000..d06af3f2 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/cport1.rom differ diff --git a/src/platform/3do/CD/System/Drivers/cport41.rom b/src/platform/3do/CD/System/Drivers/cport41.rom new file mode 100644 index 00000000..44a5ce9a Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/cport41.rom differ diff --git a/src/platform/3do/CD/System/Drivers/cport49.rom b/src/platform/3do/CD/System/Drivers/cport49.rom new file mode 100644 index 00000000..e09ca1b8 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/cport49.rom differ diff --git a/src/platform/3do/CD/System/Drivers/cport4d.rom b/src/platform/3do/CD/System/Drivers/cport4d.rom new file mode 100644 index 00000000..b1d49270 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/cport4d.rom differ diff --git a/src/platform/3do/CD/System/Drivers/languages/da.language b/src/platform/3do/CD/System/Drivers/languages/da.language new file mode 100644 index 00000000..b5e1012d Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/da.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/de.language b/src/platform/3do/CD/System/Drivers/languages/de.language new file mode 100644 index 00000000..da1c3109 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/de.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/es.language b/src/platform/3do/CD/System/Drivers/languages/es.language new file mode 100644 index 00000000..a5b78fb0 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/es.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/fr.language b/src/platform/3do/CD/System/Drivers/languages/fr.language new file mode 100644 index 00000000..8fd332c2 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/fr.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/it.language b/src/platform/3do/CD/System/Drivers/languages/it.language new file mode 100644 index 00000000..df36d39f Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/it.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/ja.language b/src/platform/3do/CD/System/Drivers/languages/ja.language new file mode 100644 index 00000000..fb86b932 Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/ja.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/nl.language b/src/platform/3do/CD/System/Drivers/languages/nl.language new file mode 100644 index 00000000..4aae529c Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/nl.language differ diff --git a/src/platform/3do/CD/System/Drivers/languages/pt.language b/src/platform/3do/CD/System/Drivers/languages/pt.language new file mode 100644 index 00000000..aa3eb5ea Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/languages/pt.language differ diff --git a/src/platform/3do/CD/System/Drivers/tuners/access.tuner b/src/platform/3do/CD/System/Drivers/tuners/access.tuner new file mode 100644 index 00000000..d6743c4b Binary files /dev/null and b/src/platform/3do/CD/System/Drivers/tuners/access.tuner differ diff --git a/src/platform/3do/CD/System/Folios/audio.privfolio b/src/platform/3do/CD/System/Folios/audio.privfolio new file mode 100644 index 00000000..142f397c Binary files /dev/null and b/src/platform/3do/CD/System/Folios/audio.privfolio differ diff --git a/src/platform/3do/CD/System/Folios/compression.folio b/src/platform/3do/CD/System/Folios/compression.folio new file mode 100644 index 00000000..cb3e0662 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/compression.folio differ diff --git a/src/platform/3do/CD/System/Folios/debugger.privfolio b/src/platform/3do/CD/System/Folios/debugger.privfolio new file mode 100644 index 00000000..5850df16 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/debugger.privfolio differ diff --git a/src/platform/3do/CD/System/Folios/graphics.privfolio b/src/platform/3do/CD/System/Folios/graphics.privfolio new file mode 100644 index 00000000..4db0f5d9 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/graphics.privfolio differ diff --git a/src/platform/3do/CD/System/Folios/international.privfolio b/src/platform/3do/CD/System/Folios/international.privfolio new file mode 100644 index 00000000..195792f2 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/international.privfolio differ diff --git a/src/platform/3do/CD/System/Folios/international/CountryDatabase b/src/platform/3do/CD/System/Folios/international/CountryDatabase new file mode 100644 index 00000000..bfe9d6b1 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/international/CountryDatabase differ diff --git a/src/platform/3do/CD/System/Folios/jstring.folio b/src/platform/3do/CD/System/Folios/jstring.folio new file mode 100644 index 00000000..6c4a5a37 Binary files /dev/null and b/src/platform/3do/CD/System/Folios/jstring.folio differ diff --git a/src/platform/3do/CD/System/Folios/operamath.privfolio b/src/platform/3do/CD/System/Folios/operamath.privfolio new file mode 100644 index 00000000..0a8cacca Binary files /dev/null and b/src/platform/3do/CD/System/Folios/operamath.privfolio differ diff --git a/src/platform/3do/CD/System/Graphics/Fonts/Kanji16.4 b/src/platform/3do/CD/System/Graphics/Fonts/Kanji16.4 new file mode 100644 index 00000000..b91a5314 Binary files /dev/null and b/src/platform/3do/CD/System/Graphics/Fonts/Kanji16.4 differ diff --git a/src/platform/3do/CD/System/Kernel/boot_code b/src/platform/3do/CD/System/Kernel/boot_code new file mode 100644 index 00000000..1983f9f1 Binary files /dev/null and b/src/platform/3do/CD/System/Kernel/boot_code differ diff --git a/src/platform/3do/CD/System/Kernel/misc_code b/src/platform/3do/CD/System/Kernel/misc_code new file mode 100644 index 00000000..ca791f8c Binary files /dev/null and b/src/platform/3do/CD/System/Kernel/misc_code differ diff --git a/src/platform/3do/CD/System/Kernel/os_code b/src/platform/3do/CD/System/Kernel/os_code new file mode 100644 index 00000000..d81ff658 Binary files /dev/null and b/src/platform/3do/CD/System/Kernel/os_code differ diff --git a/src/platform/3do/CD/System/Programs/copy b/src/platform/3do/CD/System/Programs/copy new file mode 100644 index 00000000..3c2a6c9f Binary files /dev/null and b/src/platform/3do/CD/System/Programs/copy differ diff --git a/src/platform/3do/CD/System/Programs/delete b/src/platform/3do/CD/System/Programs/delete new file mode 100644 index 00000000..a31efd75 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/delete differ diff --git a/src/platform/3do/CD/System/Programs/dismount b/src/platform/3do/CD/System/Programs/dismount new file mode 100644 index 00000000..bcdc45d1 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/dismount differ diff --git a/src/platform/3do/CD/System/Programs/eeprom b/src/platform/3do/CD/System/Programs/eeprom new file mode 100644 index 00000000..a4e4bd79 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/eeprom differ diff --git a/src/platform/3do/CD/System/Programs/format b/src/platform/3do/CD/System/Programs/format new file mode 100644 index 00000000..c2a1478e Binary files /dev/null and b/src/platform/3do/CD/System/Programs/format differ diff --git a/src/platform/3do/CD/System/Programs/fscheck b/src/platform/3do/CD/System/Programs/fscheck new file mode 100644 index 00000000..4724e7ce Binary files /dev/null and b/src/platform/3do/CD/System/Programs/fscheck differ diff --git a/src/platform/3do/CD/System/Programs/gdbug b/src/platform/3do/CD/System/Programs/gdbug new file mode 100644 index 00000000..88aee4a3 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/gdbug differ diff --git a/src/platform/3do/CD/System/Programs/lmadm b/src/platform/3do/CD/System/Programs/lmadm new file mode 100644 index 00000000..29f058da Binary files /dev/null and b/src/platform/3do/CD/System/Programs/lmadm differ diff --git a/src/platform/3do/CD/System/Programs/lmdump b/src/platform/3do/CD/System/Programs/lmdump new file mode 100644 index 00000000..b1598dd0 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/lmdump differ diff --git a/src/platform/3do/CD/System/Programs/ls b/src/platform/3do/CD/System/Programs/ls new file mode 100644 index 00000000..12ab0f9e Binary files /dev/null and b/src/platform/3do/CD/System/Programs/ls differ diff --git a/src/platform/3do/CD/System/Programs/mount b/src/platform/3do/CD/System/Programs/mount new file mode 100644 index 00000000..99997381 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/mount differ diff --git a/src/platform/3do/CD/System/Programs/sysload b/src/platform/3do/CD/System/Programs/sysload new file mode 100644 index 00000000..3e705bf2 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/sysload differ diff --git a/src/platform/3do/CD/System/Programs/type b/src/platform/3do/CD/System/Programs/type new file mode 100644 index 00000000..fd8ce90e Binary files /dev/null and b/src/platform/3do/CD/System/Programs/type differ diff --git a/src/platform/3do/CD/System/Programs/walker b/src/platform/3do/CD/System/Programs/walker new file mode 100644 index 00000000..00aa3695 Binary files /dev/null and b/src/platform/3do/CD/System/Programs/walker differ diff --git a/src/platform/3do/CD/System/Programs/what b/src/platform/3do/CD/System/Programs/what new file mode 100644 index 00000000..dce9765b Binary files /dev/null and b/src/platform/3do/CD/System/Programs/what differ diff --git a/src/platform/3do/CD/System/Scripts/startopera b/src/platform/3do/CD/System/Scripts/startopera new file mode 100644 index 00000000..39dd645b --- /dev/null +++ b/src/platform/3do/CD/System/Scripts/startopera @@ -0,0 +1 @@ +# Copyright (C) 1995, an unpublished work by The 3DO Company. All rights reserved. # This material contains confidential information that is the property of The 3DO Company. # Any unauthorized duplication, disclosure or use is prohibited. # $Id: startopera,v 1.27 1994/08/06 00:20:23 peabody Exp $ killkprintf alias aiff $audio/aiff alias dsp $audio/dsp alias languages $drivers/Languages alias tuners $drivers/Tuners alias programs $boot/System/Programs alias fonts {/rom2/System/Graphics/Fonts|$boot/System/Graphics/Fonts} alias c $programs alias s $scripts alias app $boot fg $c/fscheck bg $tasks/eventbroker@ #minmem $boot/AppStartup% \ No newline at end of file diff --git a/src/platform/3do/CD/System/Tasks/eventbroker b/src/platform/3do/CD/System/Tasks/eventbroker new file mode 100644 index 00000000..f07391fc Binary files /dev/null and b/src/platform/3do/CD/System/Tasks/eventbroker differ diff --git a/src/platform/3do/CD/System/Tasks/shell b/src/platform/3do/CD/System/Tasks/shell new file mode 100644 index 00000000..aa860e7e Binary files /dev/null and b/src/platform/3do/CD/System/Tasks/shell differ diff --git a/src/platform/3do/CD/rom_tags b/src/platform/3do/CD/rom_tags new file mode 100644 index 00000000..527822e4 Binary files /dev/null and b/src/platform/3do/CD/rom_tags differ diff --git a/src/platform/3do/CD/signatures b/src/platform/3do/CD/signatures new file mode 100644 index 00000000..a8e3b6da --- /dev/null +++ b/src/platform/3do/CD/signatures @@ -0,0 +1 @@ +UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU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UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU \ No newline at end of file diff --git a/src/platform/3do/Makefile b/src/platform/3do/Makefile new file mode 100644 index 00000000..88838747 --- /dev/null +++ b/src/platform/3do/Makefile @@ -0,0 +1,84 @@ +SDK = C:/Projects/3do-devkit +FILESYSTEM = CD +EXENAME = $(FILESYSTEM)/LaunchMe +ISONAME = OpenLara.iso +STACKSIZE = 4096 +BANNER = banner.bmp + +CC = armcc +CXX = armcpp +AS = armasm +LD = armlink +RM = rm +MODBIN = modbin +MAKEBANNER = MakeBanner +3DOISO = 3doiso +3DOENCRYPT = 3DOEncrypt + +OPT = -O2 +CFLAGS = $(OPT) -bi -za1 -zas1 -wn -ff -fa -d __3DO__=1 -cpu ARM6 +CXXFLAGS = $(CFLAGS) +ASFLAGS = -BI -i $(SDK)/include/3do +INCPATH = -I $(SDK)/include/3do -I $(SDK)/include/ttl -I ../../fixed +LIBPATH = $(SDK)/lib/3do +LDFLAGS = -aif -reloc -ro-base 0 -libpath $(LIBPATH) -nodebug -remove -info Sizes +STARTUP = $(LIBPATH)/cstartup.o + +LIBS = \ + $(LIBPATH)/clib.lib \ + $(LIBPATH)/cpluslib.lib \ + $(LIBPATH)/swi.lib \ + $(LIBPATH)/lib3do.lib \ + $(LIBPATH)/operamath.lib \ + $(LIBPATH)/audio.lib \ + $(LIBPATH)/music.lib \ + $(LIBPATH)/filesystem.lib \ + $(LIBPATH)/graphics.lib \ + $(LIBPATH)/input.lib \ + +SRC_S = $(wildcard *.s) +SRC_C = $(wildcard *.c) +SRC_CXX = $(wildcard *.cpp) + +OBJ += $(SRC_S:%.s=build/%.s.o) +OBJ += $(SRC_C:%.c=build/%.c.o) +OBJ += $(SRC_CXX:%.cpp=build/%.cpp.o) +OBJ += build/common.cpp.o + +all: clean launchme modbin banner iso run + +launchme: builddir $(OBJ) + $(LD) -dupok -o $(EXENAME) $(LDFLAGS) $(STARTUP) $(LIBS) $(OBJ) + +modbin: + $(MODBIN) --stack=$(STACKSIZE) $(EXENAME) $(EXENAME) + +banner: + $(MAKEBANNER) $(BANNER) $(FILESYSTEM)/BannerScreen + +iso: + $(3DOISO) -in $(FILESYSTEM) -out $(ISONAME) + $(3DOENCRYPT) genromtags $(ISONAME) + +run: + /c/RetroArch/retroarch.exe -L C:\RetroArch\cores\opera_libretro.dll C:\Projects\OpenLara\src\platform\3do\OpenLara.iso + +builddir: + mkdir -p build/ + +build/%.s.o: %.s + $(AS) $(INCPATH) $(ASFLAGS) $< -o $@ + +build/%.c.o: %.c + $(CC) $(INCPATH) $(CFLAGS) -c $< -o $@ + +build/%.cpp.o: %.cpp + $(CXX) $(INCPATH) $(CXXFLAGS) -c $< -o $@ + +build/common.cpp.o: ../../fixed/common.cpp + $(CXX) $(INCPATH) $(CXXFLAGS) -c ../../fixed/common.cpp -o build/common.cpp.o + +clean: + $(RM) -vf $(OBJ) $(EXENAME) $(EXENAME).sym $(ISONAME) + +.PHONY: clean modbin banner iso diff --git a/src/platform/3do/banner.bmp b/src/platform/3do/banner.bmp new file mode 100644 index 00000000..fbebb34b Binary files /dev/null and b/src/platform/3do/banner.bmp differ diff --git a/src/platform/3do/boxIsVisible.s b/src/platform/3do/boxIsVisible.s new file mode 100644 index 00000000..cfd9eaf7 --- /dev/null +++ b/src/platform/3do/boxIsVisible.s @@ -0,0 +1,205 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT boxIsVisible_asm + +mx RN r0 +my RN r1 +mz RN r2 +m RN r3 +vx RN r4 +vy RN r5 +vz RN r6 +x RN r7 +y RN r8 +z RN r9 +rMinX RN r10 +rMinY RN r11 +rMaxX RN r12 +rMaxY RN lr + +boxArg RN mx +divLUT RN mz + +bz RN divLUT +offset RN m +xx RN rMinX +yy RN rMinY +zz RN rMaxX +min RN rMaxY +max RN rMaxY +vMinXY RN x +vMaxXY RN y +vp RN x + +minX RN x +minY RN y +minZ RN z +maxX RN mx +maxY RN my +maxZ RN mz + +MAX_X EQU (0 * 3 * 4) +MIN_X EQU (1 * 3 * 4) +MAX_Y EQU (2 * 3 * 4) +MIN_Y EQU (3 * 3 * 4) +MAX_Z EQU (4 * 3 * 4) +MIN_Z EQU (5 * 3 * 4) +SIZE EQU (6 * 3 * 4) + + MACRO +$index project $dx, $dy, $dz + add offset, sp, $dz + ldmia offset, {x, y, z} + + add offset, sp, $dy + ldmia offset, {vx, vy, vz} + add x, x, vx + add y, y, vy + add z, z, vz + + add offset, sp, $dx + ldmia offset, {vx, vy, vz} + add z, z, vz + + ; check z clipping + sub offset, z, #VIEW_MIN_F + cmp offset, #(VIEW_MAX_F - VIEW_MIN_F) + bhi $index.skip + + add x, x, vx + add y, y, vy + + mov z, z, lsr #(FIXED_SHIFT + PROJ_SHIFT) ; z is positive + ldr z, [divLUT, z, lsl #2] + mul x, z, x + mul y, z, y + + cmp x, rMinX + movlt rMinX, x + cmp y, rMinY + movlt rMinY, y + cmp x, rMaxX + movgt rMaxX, x + cmp y, rMaxY + movgt rMaxY, y +$index.skip + MEND + +boxIsVisible_asm + ldr m, =gMatrixPtr + ldr m, [m] + ldr bz, [m, #(11 * 4)] + add bz, bz, #VIEW_OFF_F + cmp bz, #(VIEW_OFF_F + VIEW_MAX_F) + movhi r0, #0 + movhi pc, lr + + stmfd sp!, {r4-r11, lr} + + ldmia boxArg, {xx, yy, zz} + + add m, m, #(12 * 4) + + ; pre-transform min/max Z + ldmdb m!, {mx, my, mz, vx, vy, vz} + mov min, zz, asr #16 + mla minX, min, mx, vx + mla minY, min, my, vy + mla minZ, min, mz, vz + mov minX, minX, asr #FIXED_SHIFT + mov minY, minY, asr #FIXED_SHIFT + + mov max, zz, lsl #16 + mov max, max, asr #16 + mla maxX, max, mx, vx + mla maxY, max, my, vy + mla maxZ, max, mz, vz + mov maxX, maxX, asr #FIXED_SHIFT + mov maxY, maxY, asr #FIXED_SHIFT + stmdb sp!, {maxX, maxY, maxZ, minX, minY, minZ} + + ; pre-transform min/max Y + ldmdb m!, {mx, my, mz} + + mov min, yy, asr #16 + mul minX, mx, min + mul minY, my, min + mul minZ, mz, min + mov minX, minX, asr #FIXED_SHIFT + mov minY, minY, asr #FIXED_SHIFT + + mov max, yy, lsl #16 + mov max, max, asr #16 + mul maxX, max, mx + mul maxY, max, my + mul maxZ, max, mz + mov maxX, maxX, asr #FIXED_SHIFT + mov maxY, maxY, asr #FIXED_SHIFT + stmdb sp!, {maxX, maxY, maxZ, minX, minY, minZ} + + ; pre-transform min/max X + ldmdb m!, {mx, my, mz} + + mov min, xx, asr #16 + mul minX, mx, min + mul minY, my, min + mul minZ, mz, min + mov minX, minX, asr #FIXED_SHIFT + mov minY, minY, asr #FIXED_SHIFT + + mov max, xx, lsl #16 + mov max, max, asr #16 + mul maxX, max, mx + mul maxY, max, my + mul maxZ, max, mz + mov maxX, maxX, asr #FIXED_SHIFT + mov maxY, maxY, asr #FIXED_SHIFT + stmdb sp!, {maxX, maxY, maxZ, minX, minY, minZ} + + ldr divLUT, =divTable + mov rMinX, #MAX_INT32 + mov rMinY, #MAX_INT32 + mov rMaxX, #MIN_INT32 + mov rMaxY, #MIN_INT32 + +_0 project #MIN_X, #MIN_Y, #MIN_Z +_1 project #MAX_X, #MIN_Y, #MIN_Z +_2 project #MIN_X, #MAX_Y, #MIN_Z +_3 project #MAX_X, #MAX_Y, #MIN_Z +_4 project #MIN_X, #MIN_Y, #MAX_Z +_5 project #MAX_X, #MIN_Y, #MAX_Z +_6 project #MIN_X, #MAX_Y, #MAX_Z +_7 project #MAX_X, #MAX_Y, #MAX_Z + + mov r0, #0 + + mov rMinX, rMinX, asr #(16 - PROJ_SHIFT) + mov rMaxX, rMaxX, asr #(16 - PROJ_SHIFT) + + cmp rMinX, rMaxX + beq _done + + ; rect Y must remain shifted up by 16 + mov rMinY, rMinY, lsl #PROJ_SHIFT + mov rMaxY, rMaxY, lsl #PROJ_SHIFT + + ; check xy clipping + ldr vp, =viewportRel + ldmia vp, {vMinXY, vMaxXY} + + cmp rMaxX, vMinXY, asr #16 + blt _done + cmp rMaxY, vMinXY, lsl #16 + blt _done + cmp rMinX, vMaxXY, asr #16 + bgt _done + cmp rMinY, vMaxXY, lsl #16 + bgt _done + + mov r0, #1 +_done add sp, sp, #SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/boxRotateYQ.s b/src/platform/3do/boxRotateYQ.s new file mode 100644 index 00000000..1d83b65a --- /dev/null +++ b/src/platform/3do/boxRotateYQ.s @@ -0,0 +1,58 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT boxRotateYQ_asm + +vx RN r0 +q RN r1 +vz RN r2 + +min RN q +max RN r3 + +minX RN r12 +maxX RN lr +minZ RN minX +maxZ RN maxX + +boxRotateYQ_asm + cmp q, #2 + moveq pc, lr + + stmfd sp!, {lr} + + add vz, vx, #(4 * 4) + + cmp q, #1 + beq q_1 + cmp q, #3 + beq q_3 + +q_0 ldmia vx, {minX, maxX} + rsb min, maxX, #0 + rsb max, minX, #0 + stmia vx, {min, max} + ldmia vz, {minZ, maxZ} + rsb min, maxZ, #0 + rsb max, minZ, #0 + stmia vz, {min, max} + ldmfd sp!, {pc} + +q_1 ldmia vz, {minZ, maxZ} + ldmia vx, {min, max} + stmia vz, {min, max} + rsb min, maxZ, #0 + rsb max, minZ, #0 + stmia vx, {min, max} + ldmfd sp!, {pc} + +q_3 ldmia vx, {minX, maxX} + ldmia vz, {min, max} + stmia vx, {min, max} + rsb min, maxX, #0 + rsb max, minX, #0 + stmia vz, {min, max} + ldmfd sp!, {pc} + END diff --git a/src/platform/3do/boxTranslate.s b/src/platform/3do/boxTranslate.s new file mode 100644 index 00000000..9c7cf0ae --- /dev/null +++ b/src/platform/3do/boxTranslate.s @@ -0,0 +1,32 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT boxTranslate_asm + +aabb RN r0 +x RN r1 +y RN r2 +z RN r3 +minX RN r4 +maxX RN r5 +minY RN r6 +maxY RN r7 +minZ RN r12 +maxZ RN lr + +boxTranslate_asm + stmfd sp!, {r4-r7, lr} + + ldmia aabb, {minX, maxX, minY, maxY, minZ, maxZ} + add minX, minX, x + add maxX, maxX, x + add minY, minY, y + add maxY, maxY, y + add minZ, minZ, z + add maxZ, maxZ, z + stmia aabb, {minX, maxX, minY, maxY, minZ, maxZ} + + ldmfd sp!, {r4-r7, pc} + END diff --git a/src/platform/3do/common_asm.inc b/src/platform/3do/common_asm.inc new file mode 100644 index 00000000..42b56141 --- /dev/null +++ b/src/platform/3do/common_asm.inc @@ -0,0 +1,132 @@ + IMPORT gMatrixPtr + IMPORT viewportRel + IMPORT gVertices + IMPORT gFacesBase + IMPORT gOT + IMPORT gPalette + IMPORT gShadowQuads + IMPORT gCameraViewPos + IMPORT shadeTable + IMPORT divTable + IMPORT gSinCosTable + IMPORT level + +CCB_NOBLK EQU 0x00000010 +CCB_BGND EQU 0x00000020 +CCB_ACE EQU 0x00004000 +CCB_ACCW EQU 0x00020000 +CCB_ACW EQU 0x00040000 +CCB_ALSC EQU 0x00080000 +CCB_ACSC EQU 0x00100000 +CCB_YOXY EQU 0x00200000 +CCB_CCBPRE EQU 0x00400000 +CCB_LDPLUT EQU 0x00800000 +CCB_LDPPMP EQU 0x01000000 +CCB_LDPRS EQU 0x02000000 +CCB_LDSIZE EQU 0x04000000 +CCB_PPABS EQU 0x08000000 +CCB_SPABS EQU 0x10000000 +CCB_NPABS EQU 0x20000000 +SIZE_OF_CCB EQU 60 + +FRAME_WIDTH EQU 320 +FRAME_HEIGHT EQU 240 + +FIXED_SHIFT EQU 14 +F16_SHIFT EQU (16 - FIXED_SHIFT) +PROJ_SHIFT EQU 4 +LVL_TEX_OFFSET EQU (23 * 4) + +CLIP_SHIFT EQU 8 +CLIP_MASK EQU ((1 << CLIP_SHIFT) - 1) +CLIP_LEFT EQU (1 << 0) +CLIP_RIGHT EQU (1 << 1) +CLIP_TOP EQU (1 << 2) +CLIP_BOTTOM EQU (1 << 3) +CLIP_FAR EQU (1 << 4) +CLIP_NEAR EQU (1 << 5) + +FACE_MIP_SHIFT EQU 11 +MIP_DIST EQU (1024 * 5) +VIEW_DIST EQU (1024 * 10) ; max = DIV_TABLE_END << PROJ_SHIFT +FOG_SHIFT EQU 1 +FOG_MAX EQU VIEW_DIST +FOG_MIN EQU (FOG_MAX - (8192 >> FOG_SHIFT)) +VIEW_MIN_F EQU (64 << FIXED_SHIFT) +VIEW_MAX_F EQU (VIEW_DIST << FIXED_SHIFT) +VIEW_OFF_F EQU (1024 << FIXED_SHIFT) +OT_SHIFT EQU 4 +OT_SIZE EQU ((VIEW_MAX_F >> (FIXED_SHIFT + OT_SHIFT)) + 1) + +DIV_TABLE_END EQU (1025 - 1) +VIEW_MIN EQU (256 << CLIP_SHIFT) +VIEW_MAX EQU (VIEW_DIST << CLIP_SHIFT) + +MIN_INT32 EQU 0x80000000 +MAX_INT32 EQU 0x7FFFFFFF + +MulManyVec3Mat33_F16 EQU (0x50000 + 2) + + +; max depth = max(z0, z1, z2, z3) >> (CLIP_SHIFT + OT_SHIFT) + MACRO + MAX_Z4 $depth, $z0, $z1, $z2, $z3 + mov $depth, $z0, asr #(CLIP_SHIFT + OT_SHIFT) + cmp $depth, $z1, asr #(CLIP_SHIFT + OT_SHIFT) + movlt $depth, $z1, asr #(CLIP_SHIFT + OT_SHIFT) + cmp $depth, $z2, asr #(CLIP_SHIFT + OT_SHIFT) + movlt $depth, $z2, asr #(CLIP_SHIFT + OT_SHIFT) + cmp $depth, $z3, asr #(CLIP_SHIFT + OT_SHIFT) + movlt $depth, $z3, asr #(CLIP_SHIFT + OT_SHIFT) + MEND + + +; max depth = max(z0, z1, z2) >> (CLIP_SHIFT + OT_SHIFT) + MACRO + MAX_Z3 $depth, $z0, $z1, $z2, $z3 + mov $depth, $z0, asr #(CLIP_SHIFT + OT_SHIFT) + cmp $depth, $z1, asr #(CLIP_SHIFT + OT_SHIFT) + movlt $depth, $z1, asr #(CLIP_SHIFT + OT_SHIFT) + cmp $depth, $z2, asr #(CLIP_SHIFT + OT_SHIFT) + movlt $depth, $z2, asr #(CLIP_SHIFT + OT_SHIFT) + MEND + + +; average depth = (z0 + z1 + z2 + z2) / 4 >> (CLIP_SHIFT + OT_SHIFT) + MACRO + AVG_Z4 $depth, $z0, $z1, $z2, $z3 + add $depth, $z0, $z1 + add $depth, $depth, $z2 + add $depth, $depth, $z3 + mov $depth, $depth, asr #(2 + CLIP_SHIFT + OT_SHIFT) + MEND + + +; average depth = (z0 + z1 + z2 + z2) / 4 >> (CLIP_SHIFT + OT_SHIFT) + MACRO + AVG_Z3 $depth, $z0, $z1, $z2 + add $depth, $z0, $z1 + add $depth, $depth, $z2, lsl #1 + mov $depth, $depth, asr #(2 + CLIP_SHIFT + OT_SHIFT) + MEND + + +; back facing check + MACRO + CCW $cross, $dx0, $dy0, $dx1, $dy1, $skip + mul $cross, $dy0, $dx1 + rsb $cross, cross, #0 + mlas $cross, $dx0, $dy1, $cross + ble skip + MEND + + +; back/front facing check depending on sign + MACRO + CCW_SIGN $cross, $sign, $dx0, $dy0, $dx1, $dy1, $skip + mul $cross, $dy0, $dx1 + rsb $cross, cross, #0 + mla $cross, $dx0, $dy1, $cross + teq $cross, $sign + bmi skip + MEND diff --git a/src/platform/3do/faceAddMeshQuads.s b/src/platform/3do/faceAddMeshQuads.s new file mode 100644 index 00000000..eed7d228 --- /dev/null +++ b/src/platform/3do/faceAddMeshQuads.s @@ -0,0 +1,234 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddMeshQuads_asm + +polysArg RN r0 +countArg RN r1 +shadeArg RN r2 + +flags RN polysArg + +vx0 RN shadeArg +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx3 RN r6 +vy3 RN r7 + +vx2 RN r8 +vy2 RN r9 + +pixc RN r10 +tex RN r11 + +face RN r12 +depth RN lr + +mask RN depth + +fPolys RN countArg +fLast RN tex +fVertices RN face + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy3 +spOT RN vx2 +spFaceBase RN vy2 +spTextures RN tex +spPalette RN face + +faceBase RN vy2 +cross RN vy2 + +indices RN vy0 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy2 +vz3 RN vy3 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx2 +vp3 RN vx3 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +hdx1 RN vx2 +hdy1 RN vy2 +vdx0 RN vx3 +vdy0 RN vy3 +hddx RN hdx1 +hddy RN hdy1 + +nextPtr RN vy2 +dataPtr RN polysArg +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth +nextFace RN depth + +plutOffset RN vy2 +texIndex RN vy2 + +ws RN tex +hs RN depth +shift RN depth + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_OT EQU 12 +SP_FACEBASE EQU 16 +SP_TEXTURES EQU 20 +SP_PALETTE EQU 24 +SP_SIZE EQU 28 + +faceAddMeshQuads_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + mov pixc, shadeArg + + add spLast, polysArg, countArg, lsl #3 + ldr spVertices, =gVertices + ldr spOT, =gOT + ldr spFaceBase, =gFacesBase + ldr spTextures, =level + ldr spTextures, [spTextures, #LVL_TEX_OFFSET] + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + + stmia sp, {polysArg, spLast, spVertices, spOT, spFaceBase, spTextures, spPalette} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, indices} + + ; get vertex pointers + mov mask, #0xFF + and vp0, mask, indices + and vp1, mask, indices, lsr #8 + and vp2, mask, indices, lsr #16 + and vp3, mask, indices, lsr #24 + + add vp0, vp0, vp0, lsl #1 + add vp1, vp1, vp1, lsl #1 + add vp2, vp2, vp2, lsl #1 + add vp3, vp3, vp3, lsl #1 + + add vp0, fVertices, vp0, lsl #2 + add vp1, fVertices, vp1, lsl #2 + add vp2, fVertices, vp2, lsl #2 + add vp3, fVertices, vp3, lsl #2 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + ldr vz3, [vp3, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + and mask, vz3, mask + tst mask, #CLIP_MASK + bne skip + + AVG_Z4 depth, vz0, vz1, vz2, vz3 + + ; (vx1 - vx0) * (vy3 - vy0) <= (vy1 - vy0) * (vx3 - vx0) + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp3, {vx3, vy3} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx3, vx0 + sub vdy0, vy3, vy0 + + CCW_SIGN cross, flags, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + add tmp, sp, #SP_OT + ldmia tmp, {ot, faceBase, tex} + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + ldr face, [faceBase] + add nextFace, face, #SIZE_OF_CCB + str nextFace, [faceBase] + + ; get texture ptr + mov texIndex, flags, lsl #(32 - FACE_MIP_SHIFT) + add tex, tex, texIndex, lsr #(32 - FACE_MIP_SHIFT - 3) ; sizeof(Texture) = 2^3 + + ; add face to Ordering Table + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccb flags + ands flags, flags, #(1 << 30) + movne flags, #(CCB_BGND) + orr flags, flags, #(CCB_NOBLK) + orr flags, flags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr flags, flags, #(CCB_LDPLUT + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + + ; ccbMap4 + stmia face!, {flags, nextPtr} + ldmia tex, {dataPtr, shift} + + ; plutPtr = plutOffset + (tex->shift >> 16) + ldr plutOffset, [sp, #SP_PALETTE] + add plutPtr, plutOffset, shift, lsr #16 + + ldmia vp2, {vx2, vy2} + sub vx2, vx2, vx0 + sub vy2, vy2, vy0 + sub hdx1, vx2, vx3 + sub hdy1, vy2, vy3 + + and ws, shift, #0xFF + mov hs, shift, lsr #8 + and hs, hs, #0xFF + + mov hdx0, hdx0, lsl ws + mov hdy0, hdy0, lsl ws + + mov vdx0, vdx0, lsl hs + mov vdy0, vdy0, lsl hs + + rsb hs, hs, #16 + rsb hddx, hdx0, hdx1, lsl ws + rsb hddy, hdy0, hdy1, lsl ws + mov hddx, hddx, asr hs + mov hddy, hddy, asr hs + + add xpos, vx0, #(FRAME_WIDTH >> 1) + add ypos, vy0, #(FRAME_HEIGHT >> 1) + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + + stmia face, {dataPtr, plutPtr, xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/faceAddMeshQuadsFlat.s b/src/platform/3do/faceAddMeshQuadsFlat.s new file mode 100644 index 00000000..f554e615 --- /dev/null +++ b/src/platform/3do/faceAddMeshQuadsFlat.s @@ -0,0 +1,216 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddMeshQuadsFlat_asm + +polysArg RN r0 +countArg RN r1 +shadeArg RN r2 + +flags RN polysArg + +vx0 RN shadeArg +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx3 RN r6 +vy3 RN r7 + +vx2 RN r8 +vy2 RN r9 + +pixc RN r10 +color RN r11 + +face RN r12 +depth RN lr + +mask RN depth + +fPolys RN countArg +fLast RN color +fVertices RN face + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy3 +spFlags RN vx2 +spOT RN vy2 +spFaceBase RN color +spPalette RN face + +faceBase RN vy2 +cross RN vy2 + +indices RN vy0 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy2 +vz3 RN vy3 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx2 +vp3 RN vx3 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +hdx1 RN vx2 +hdy1 RN vy2 +vdx0 RN vx3 +vdy0 RN vy3 +hddx RN hdx1 +hddy RN hdy1 + +nextPtr RN vy2 +dataPtr RN color +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth +nextFace RN depth + +plutOffset RN color +colorIndex RN face + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_FLAGS EQU 12 +SP_OT EQU 16 +SP_FACEBASE EQU 20 +SP_PALETTE EQU 24 +SP_SIZE EQU 28 + +faceAddMeshQuadsFlat_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + mov pixc, shadeArg + + add spLast, polysArg, countArg, lsl #3 + ldr spVertices, =gVertices + mov spFlags, #(CCB_NOBLK + CCB_BGND) + orr spFlags, spFlags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr spFlags, spFlags, #(CCB_CCBPRE + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + ldr spOT, =gOT + ldr spFaceBase, =gFacesBase + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + + stmia sp, {polysArg, spLast, spVertices, spFlags, spOT, spFaceBase, spPalette} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, indices} + + ; get vertex pointers + mov mask, #0xFF + and vp0, mask, indices + and vp1, mask, indices, lsr #8 + and vp2, mask, indices, lsr #16 + and vp3, mask, indices, lsr #24 + + add vp0, vp0, vp0, lsl #1 + add vp1, vp1, vp1, lsl #1 + add vp2, vp2, vp2, lsl #1 + add vp3, vp3, vp3, lsl #1 + + add vp0, fVertices, vp0, lsl #2 + add vp1, fVertices, vp1, lsl #2 + add vp2, fVertices, vp2, lsl #2 + add vp3, fVertices, vp3, lsl #2 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + ldr vz3, [vp3, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + and mask, vz3, mask + tst mask, #CLIP_MASK + bne skip + + AVG_Z4 depth, vz0, vz1, vz2, vz3 + + ; (vx1 - vx0) * (vy3 - vy0) <= (vy1 - vy0) * (vx3 - vx0) + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp3, {vx3, vy3} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx3, vx0 + sub vdy0, vy3, vy0 + + CCW cross, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + ; get color index from flags + and colorIndex, flags, #0xFF + + add tmp, sp, #SP_FLAGS + ldmia tmp, {flags, ot, faceBase, plutOffset} + + ; get color ptr + add dataPtr, plutOffset, colorIndex, lsl #1 + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + ldr face, [faceBase] + add nextFace, face, #SIZE_OF_CCB + str nextFace, [faceBase] + + ; add face to Ordering Table + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccbMap4 (colored) + stmia face, {flags, nextPtr, dataPtr} + + ldmia vp2, {vx2, vy2} + sub vx2, vx2, vx0 + sub vy2, vy2, vy0 + sub hdx1, vx2, vx3 + sub hdy1, vy2, vy3 + + mov hdx0, hdx0, lsl #20 + mov hdy0, hdy0, lsl #20 + + mov vdx0, vdx0, lsl #16 + mov vdy0, vdy0, lsl #16 + + rsb hddx, hdx0, hdx1, lsl #20 + rsb hddy, hdy0, hdy1, lsl #20 + + add xpos, vx0, #(FRAME_WIDTH >> 1) + add ypos, vy0, #(FRAME_HEIGHT >> 1) + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + + add face, face, #16 ; skip flags, nextPtr, dataPtr, plutPtr + + stmia face, {xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/faceAddMeshTriangles.s b/src/platform/3do/faceAddMeshTriangles.s new file mode 100644 index 00000000..42ba3ee1 --- /dev/null +++ b/src/platform/3do/faceAddMeshTriangles.s @@ -0,0 +1,218 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddMeshTriangles_asm + +polysArg RN r0 +countArg RN r1 +shadeArg RN r2 + +flags RN polysArg + +vx0 RN shadeArg +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx2 RN r6 +vy2 RN r7 + +vx3 RN r8 +vy3 RN r9 + +pixc RN r10 +tex RN r11 + +face RN r12 +depth RN lr + +mask RN depth + +fPolys RN countArg +fLast RN tex +fVertices RN face + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy2 +spOT RN vx3 +spPalette RN vy3 +spFaceBase RN tex +spTextures RN face + +faceBase RN vy3 +cross RN vy3 + +indices RN vy0 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy2 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx2 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +vdx0 RN vx2 +vdy0 RN vy2 +hddx RN vx3 +hddy RN vy3 + +nextPtr RN vy3 +dataPtr RN polysArg +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth +nextFace RN depth + +plutOffset RN vx3 +texIndex RN vy3 + +ws RN tex +hs RN depth +shift RN depth + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_OT EQU 12 +SP_PALETTE EQU 16 +SP_FACEBASE EQU 20 +SP_TEXTURES EQU 24 +SP_SIZE EQU 28 + +faceAddMeshTriangles_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + mov pixc, shadeArg + + add spLast, polysArg, countArg, lsl #3 + ldr spVertices, =gVertices + ldr spOT, =gOT + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + ldr spFaceBase, =gFacesBase + ldr spTextures, =level + ldr spTextures, [spTextures, #LVL_TEX_OFFSET] + + stmia sp, {polysArg, spLast, spVertices, spOT, spPalette, spFaceBase, spTextures} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, indices} + + ; get vertex pointers + mov mask, #0xFF + and vp0, mask, indices + and vp1, mask, indices, lsr #8 + and vp2, mask, indices, lsr #16 + + add vp0, vp0, vp0, lsl #1 + add vp1, vp1, vp1, lsl #1 + add vp2, vp2, vp2, lsl #1 + + add vp0, fVertices, vp0, lsl #2 + add vp1, fVertices, vp1, lsl #2 + add vp2, fVertices, vp2, lsl #2 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + tst mask, #CLIP_MASK + bne skip + + AVG_Z3 depth, vz0, vz1, vz2 + + ; (vx1 - vx0) * (vy2 - vy0) - (vy1 - vy0) * (vx2 - vx0) <= 0 + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp2, {vx2, vy2} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx2, vx0 + sub vdy0, vy2, vy0 + + CCW cross, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + add tmp, sp, #SP_OT + ldmia tmp, {ot, plutOffset, faceBase, tex} + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + ldr face, [faceBase] + add nextFace, face, #SIZE_OF_CCB + str nextFace, [faceBase] + + ; get texture ptr + mov texIndex, flags, lsl #(32 - FACE_MIP_SHIFT) + add tex, tex, texIndex, lsr #(32 - FACE_MIP_SHIFT - 3) ; sizeof(Texture) = 2^3 + + ; add face to Ordering Table + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccb flags + ands flags, flags, #(1 << 30) + movne flags, #(CCB_BGND) + orr flags, flags, #(CCB_NOBLK) + orr flags, flags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr flags, flags, #(CCB_LDPLUT + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + + ; ccbMap3 + stmia face!, {flags, nextPtr} + ldmia tex, {dataPtr, shift} + + ; plutPtr = plutOffset + (tex->shift >> 16) + add plutPtr, plutOffset, shift, lsr #16 + + and ws, shift, #0xFF + mov hs, shift, lsr #8 + and hs, hs, #0xFF + + mov hdx0, hdx0, lsl ws + mov hdy0, hdy0, lsl ws + + mov vdx0, vdx0, lsl hs + mov vdy0, vdy0, lsl hs + + rsb hs, hs, #16 + rsb hddx, hdx0, #0 + rsb hddy, hdy0, #0 + mov hddx, hddx, asr hs + mov hddy, hddy, asr hs + + add xpos, vx0, #(FRAME_WIDTH >> 1) + add ypos, vy0, #(FRAME_HEIGHT >> 1) + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + + stmia face, {dataPtr, plutPtr, xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/faceAddMeshTrianglesFlat.s b/src/platform/3do/faceAddMeshTrianglesFlat.s new file mode 100644 index 00000000..c8c8eadf --- /dev/null +++ b/src/platform/3do/faceAddMeshTrianglesFlat.s @@ -0,0 +1,201 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddMeshTrianglesFlat_asm + +polysArg RN r0 +countArg RN r1 +shadeArg RN r2 + +flags RN polysArg + +vx0 RN shadeArg +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx2 RN r6 +vy2 RN r7 + +vx3 RN r8 +vy3 RN r9 + +pixc RN r10 +color RN r11 + +face RN r12 +depth RN lr + +mask RN depth + +fPolys RN countArg +fLast RN color +fVertices RN face + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy2 +spFlags RN vx3 +spOT RN vy3 +spFaceBase RN color +spPalette RN face + +faceBase RN vy3 +cross RN vy3 + +indices RN vy0 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy3 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx3 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +vdx0 RN vx2 +vdy0 RN vy2 +hddx RN vx3 +hddy RN vy3 + +nextPtr RN vy3 +dataPtr RN color +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth +nextFace RN depth + +plutOffset RN color +colorIndex RN face + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_FLAGS EQU 12 +SP_OT EQU 16 +SP_FACEBASE EQU 20 +SP_PALETTE EQU 24 +SP_SIZE EQU 28 + +faceAddMeshTrianglesFlat_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + mov pixc, shadeArg + + add spLast, polysArg, countArg, lsl #3 + ldr spVertices, =gVertices + mov spFlags, #(CCB_NOBLK + CCB_BGND) + orr spFlags, spFlags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr spFlags, spFlags, #(CCB_CCBPRE + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + ldr spOT, =gOT + ldr spFaceBase, =gFacesBase + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + + stmia sp, {polysArg, spLast, spVertices, spFlags, spOT, spFaceBase, spPalette} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, indices} + + ; get vertex pointers + mov mask, #0xFF + and vp0, mask, indices + and vp1, mask, indices, lsr #8 + and vp2, mask, indices, lsr #16 + + add vp0, vp0, vp0, lsl #1 + add vp1, vp1, vp1, lsl #1 + add vp2, vp2, vp2, lsl #1 + + add vp0, fVertices, vp0, lsl #2 + add vp1, fVertices, vp1, lsl #2 + add vp2, fVertices, vp2, lsl #2 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + tst mask, #CLIP_MASK + bne skip + + AVG_Z3 depth, vz0, vz1, vz2 + + ; (vx1 - vx0) * (vy2 - vy0) - (vy1 - vy0) * (vx2 - vx0) <= 0 + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp2, {vx2, vy2} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx2, vx0 + sub vdy0, vy2, vy0 + + CCW cross, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + ; get color index from flags + and colorIndex, flags, #0xFF + + add tmp, sp, #SP_FLAGS + ldmia tmp, {flags, ot, faceBase, plutOffset} + + ; get color ptr + add dataPtr, plutOffset, colorIndex, lsl #1 + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + ldr face, [faceBase] + add nextFace, face, #SIZE_OF_CCB + str nextFace, [faceBase] + + ; add face to Ordering Table + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccbMap3 (colored) + stmia face, {flags, nextPtr, dataPtr} + + mov hdx0, hdx0, lsl #20 + mov hdy0, hdy0, lsl #20 + + mov vdx0, vdx0, lsl #16 + mov vdy0, vdy0, lsl #16 + + rsb hddx, hdx0, #0 + rsb hddy, hdy0, #0 + + add xpos, vx0, #(FRAME_WIDTH >> 1) + add ypos, vy0, #(FRAME_HEIGHT >> 1) + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + + add face, face, #16 ; skip flags, nextPtr, dataPtr, plutPtr + + stmia face, {xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/faceAddRoomQuads.s b/src/platform/3do/faceAddRoomQuads.s new file mode 100644 index 00000000..df760f0c --- /dev/null +++ b/src/platform/3do/faceAddRoomQuads.s @@ -0,0 +1,249 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddRoomQuads_asm + +polysArg RN r0 +countArg RN r1 + +flags RN polysArg + +vx0 RN r2 +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx3 RN r6 +vy3 RN r7 + +vx2 RN r8 +vy2 RN r9 + +pixc RN r10 +tex RN r11 + +mask RN r12 +depth RN lr + +fPolys RN countArg +fLast RN pixc +fVertices RN tex + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy3 +spOT RN vx2 +spShadeLUT RN vy2 +spTextures RN pixc +spFaceBase RN tex +spPalette RN mask + +face RN mask +faceBase RN mask +cross RN mask + +i0 RN vy0 +i1 RN vy1 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy2 +vz3 RN vy3 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx2 +vp3 RN vx3 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +hdx1 RN vx2 +hdy1 RN vy2 +vdx0 RN vx3 +vdy0 RN vy3 +hddx RN hdx1 +hddy RN hdy1 + +nextPtr RN vy2 +dataPtr RN polysArg +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth + +shadeLUT RN pixc +fog RN pixc + +intensity RN vy2 +plutOffset RN vy2 +texIndex RN vy2 + +ws RN tex +hs RN depth +shift RN depth + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_OT EQU 12 +SP_SHADELUT EQU 16 +SP_TEXTURES EQU 20 +SP_FACEBASE EQU 24 +SP_PALETTE EQU 28 +SP_SIZE EQU 32 + +faceAddRoomQuads_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + add countArg, countArg, countArg, lsl #1 + add spLast, polysArg, countArg, lsl #2 + ldr spVertices, =gVertices + ldr spOT, =gOT + ldr spShadeLUT, =shadeTable + ldr spTextures, =level + ldr spTextures, [spTextures, #LVL_TEX_OFFSET] + ldr spFaceBase, =gFacesBase + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + + stmia sp, {polysArg, spLast, spVertices, spOT, spShadeLUT, spTextures, spFaceBase, spPalette} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, i0, i1} + + ; get vertex pointers (indices are pre-multiplied by 12) + add vp0, fVertices, i0, lsr #16 + mov i0, i0, lsl #16 + add vp1, fVertices, i0, lsr #16 + + add vp2, fVertices, i1, lsr #16 + mov i1, i1, lsl #16 + add vp3, fVertices, i1, lsr #16 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + ldr vz3, [vp3, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + and mask, vz3, mask + tst mask, #CLIP_MASK + bne skip + + MAX_Z4 depth, vz0, vz1, vz2, vz3 + + ; (vx1 - vx0) * (vy3 - vy0) <= (vy1 - vy0) * (vx3 - vx0) + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp3, {vx3, vy3} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx3, vx0 + sub vdy0, vy3, vy0 + + CCW cross, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + ; fog = max(0, (depth - (FOG_MIN >> OT_SHIFT)) >> 1) + sub fog, depth, #(FOG_MIN >> OT_SHIFT) + movs fog, fog, asr #1 + movmi fog, #0 + + ; intensity = min(255, fog + ((flags >> (FACE_MIP_SHIFT + FACE_MIP_SHIFT)) & 0xFF)) >> 3 + mov intensity, flags, lsl #(32 - 8 - FACE_MIP_SHIFT - FACE_MIP_SHIFT) + add intensity, fog, intensity, lsr #(32 - 8) + cmp intensity, #255 + movcs intensity, #255 + mov intensity, intensity, lsr #3 + + add tmp, sp, #SP_OT + ldmia tmp, {ot, shadeLUT, tex, faceBase} + + ; pixc = shadeTable[intensity] + ldr pixc, [shadeLUT, intensity, lsl #2] + + ; get texture ptr (base or mip) + mov texIndex, flags + cmp depth, #(MIP_DIST >> OT_SHIFT) + movgt texIndex, texIndex, lsr #FACE_MIP_SHIFT + mov texIndex, texIndex, lsl #(32 - FACE_MIP_SHIFT) + add tex, tex, texIndex, lsr #(32 - FACE_MIP_SHIFT - 3) ; sizeof(Texture) = 2^3 + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + mov depth, faceBase ; use depth reg due face vs faceBase reg collision + + ldr face, [depth] + add nextPtr, face, #SIZE_OF_CCB + str nextPtr, [depth] + + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccb flags + ands flags, flags, #(1 << 30) + movne flags, #(CCB_BGND) + orr flags, flags, #(CCB_NOBLK) + orr flags, flags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr flags, flags, #(CCB_LDPLUT + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + + ; ccbMap4 + stmia face!, {flags, nextPtr} + ldmia tex, {dataPtr, shift} + + ; plutPtr = plutOffset + (tex->shift >> 16) + ldr plutOffset, [sp, #SP_PALETTE] + add plutPtr, plutOffset, shift, lsr #16 + + ldmia vp2, {vx2, vy2} + sub vx2, vx2, vx0 + sub vy2, vy2, vy0 + sub hdx1, vx2, vx3 + sub hdy1, vy2, vy3 + + and ws, shift, #0xFF + mov hs, shift, lsr #8 + and hs, hs, #0xFF + + mov hdx0, hdx0, lsl ws + mov hdy0, hdy0, lsl ws + + mov vdx0, vdx0, lsl hs + mov vdy0, vdy0, lsl hs + + rsb hs, hs, #16 + rsb hddx, hdx0, hdx1, lsl ws + rsb hddy, hdy0, hdy1, lsl ws + mov hddx, hddx, asr hs + mov hddy, hddy, asr hs + + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + add xpos, xpos, #(FRAME_WIDTH << 15) + add ypos, ypos, #(FRAME_HEIGHT << 15) + + stmia face, {dataPtr, plutPtr, xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/faceAddRoomTriangles.s b/src/platform/3do/faceAddRoomTriangles.s new file mode 100644 index 00000000..d5956e4b --- /dev/null +++ b/src/platform/3do/faceAddRoomTriangles.s @@ -0,0 +1,234 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT faceAddRoomTriangles_asm + +polysArg RN r0 +countArg RN r1 + +flags RN polysArg + +vx0 RN r2 +vy0 RN r3 + +vx1 RN r4 +vy1 RN r5 + +vx2 RN r6 +vy2 RN r7 + +vx3 RN r8 +vy3 RN r9 + +pixc RN r10 +tex RN r11 + +mask RN r12 +depth RN lr + +fPolys RN countArg +fLast RN pixc +fVertices RN tex + +spPolys RN vx0 +spLast RN vx1 +spVertices RN vy2 +spOT RN vx3 +spPalette RN vy3 +spShadeLUT RN pixc +spTextures RN tex +spFaceBase RN mask + +face RN mask +faceBase RN mask +cross RN mask + +i0 RN vy0 +i1 RN vy1 + +vz0 RN vy0 +vz1 RN vy1 +vz2 RN vy2 + +vp0 RN vx0 +vp1 RN vx1 +vp2 RN vx2 + +xpos RN vx0 +ypos RN vy0 +hdx0 RN vx1 +hdy0 RN vy1 +vdx0 RN vx2 +vdy0 RN vy2 +hddx RN vx3 +hddy RN vy3 + +nextPtr RN vy3 +dataPtr RN polysArg +plutPtr RN countArg + +tmp RN countArg +ot RN countArg +otTail RN depth + +shadeLUT RN pixc +fog RN pixc + +intensity RN vy3 +plutOffset RN vx3 +texIndex RN vy3 + +ws RN tex +hs RN depth +shift RN depth + +SP_POLYS EQU 0 +SP_LAST EQU 4 +SP_VERTICES EQU 8 +SP_OT EQU 12 +SP_PALETTE EQU 16 +SP_SHADELUT EQU 20 +SP_TEXTURES EQU 24 +SP_FACEBASE EQU 28 +SP_SIZE EQU 32 + +faceAddRoomTriangles_asm + stmfd sp!, {r4-r11, lr} + sub sp, sp, #SP_SIZE + + add countArg, countArg, countArg, lsl #1 + add spLast, polysArg, countArg, lsl #2 + ldr spVertices, =gVertices + ldr spOT, =gOT + ldr spPalette, =gPalette + ldr spPalette, [spPalette] + ldr spShadeLUT, =shadeTable + ldr spTextures, =level + ldr spTextures, [spTextures, #LVL_TEX_OFFSET] + ldr spFaceBase, =gFacesBase + + stmia sp, {polysArg, spLast, spVertices, spOT, spPalette, spShadeLUT, spTextures, spFaceBase} + +loop ldmia sp, {fPolys, fLast, fVertices} +skip cmp fPolys, fLast + bge done + + ldmia fPolys!, {flags, i0, i1} + + ; get vertex pointers (indices are pre-multiplied by 12) + add vp0, fVertices, i0, lsr #16 + mov i0, i0, lsl #16 + add vp1, fVertices, i0, lsr #16 + + add vp2, fVertices, i1, lsr #16 + + ; read z value with clip mask + ldr vz0, [vp0, #8] + ldr vz1, [vp1, #8] + ldr vz2, [vp2, #8] + + ; check clipping + and mask, vz1, vz0 + and mask, vz2, mask + tst mask, #CLIP_MASK + bne skip + + MAX_Z3 depth, vz0, vz1, vz2 + + ; (vx1 - vx0) * (vy2 - vy0) <= (vy1 - vy0) * (vx2 - vx0) + ldmia vp0, {vx0, vy0} + ldmia vp1, {vx1, vy1} + ldmia vp2, {vx2, vy2} + sub hdx0, vx1, vx0 + sub hdy0, vy1, vy0 + sub vdx0, vx2, vx0 + sub vdy0, vy2, vy0 + + CCW cross, hdx0, hdy0, vdx0, vdy0, skip + + ; poly is visible, store fPolys on the stack to reuse the reg + str fPolys, [sp, #SP_POLYS] + + ; fog = max(0, (depth - (FOG_MIN >> OT_SHIFT)) >> 1) + sub fog, depth, #(FOG_MIN >> OT_SHIFT) + movs fog, fog, asr #1 + movmi fog, #0 + + ; intensity = min(255, fog + ((flags >> (FACE_MIP_SHIFT + FACE_MIP_SHIFT)) & 0xFF)) >> 3 + mov intensity, flags, lsl #(32 - 8 - FACE_MIP_SHIFT - FACE_MIP_SHIFT) + add intensity, fog, intensity, lsr #(32 - 8) + cmp intensity, #255 + movcs intensity, #255 + mov intensity, intensity, lsr #3 + + add tmp, sp, #SP_OT + ldmia tmp, {ot, plutOffset, shadeLUT, tex, faceBase} + + ; pixc = shadeTable[intensity] + ldr pixc, [shadeLUT, intensity, lsl #2] + + ; get texture ptr (base or mip) + mov texIndex, flags + cmp depth, #(MIP_DIST >> OT_SHIFT) + movgt texIndex, texIndex, lsr #FACE_MIP_SHIFT + mov texIndex, texIndex, lsl #(32 - FACE_MIP_SHIFT) + add tex, tex, texIndex, lsr #(32 - FACE_MIP_SHIFT - 3) ; sizeof(Texture) = 2^3 + + ; faceAdd + add ot, ot, depth, lsl #3 ; mul by size of OT element + + mov depth, faceBase ; use depth reg due face vs faceBase reg collision + + ldr face, [depth] + add nextPtr, face, #SIZE_OF_CCB + str nextPtr, [depth] + + ldmia ot, {nextPtr, otTail} + cmp nextPtr, #0 + moveq otTail, face + stmia ot, {face, otTail} + + ; ccb flags + ands flags, flags, #(1 << 30) + movne flags, #(CCB_BGND) + orr flags, flags, #(CCB_NOBLK) + orr flags, flags, #(CCB_ACE + CCB_ACCW + CCB_ACW + CCB_ALSC + CCB_ACSC + CCB_YOXY) + orr flags, flags, #(CCB_LDPLUT + CCB_LDPPMP + CCB_LDPRS + CCB_LDSIZE + CCB_PPABS + CCB_SPABS + CCB_NPABS) + + ; ccbMap4 + stmia face!, {flags, nextPtr} + ldmia tex, {dataPtr, shift} + + ; plutPtr = plutOffset + (tex->shift >> 16) + add plutPtr, plutOffset, shift, lsr #16 + + and ws, shift, #0xFF + mov hs, shift, lsr #8 + and hs, hs, #0xFF + + mov hdx0, hdx0, lsl ws + mov hdy0, hdy0, lsl ws + + mov vdx0, vdx0, lsl hs + mov vdy0, vdy0, lsl hs + + rsb hs, hs, #16 + rsb hddx, hdx0, #0 + rsb hddy, hdy0, #0 + mov hddx, hddx, asr hs + mov hddy, hddy, asr hs + + add xpos, vx0, #(FRAME_WIDTH >> 1) + add ypos, vy0, #(FRAME_HEIGHT >> 1) + mov xpos, vx0, lsl #16 + mov ypos, vy0, lsl #16 + + stmia face, {dataPtr, plutPtr, xpos, ypos, hdx0, hdy0, vdx0, vdy0, hddx, hddy, pixc} + + b loop + +done add sp, sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/main.cpp b/src/platform/3do/main.cpp new file mode 100644 index 00000000..48e41734 --- /dev/null +++ b/src/platform/3do/main.cpp @@ -0,0 +1,372 @@ +const void* TRACKS_IMA; +const void* TITLE_SCR; // TODO + +void* RAM_LVL; +void* RAM_TEX; +void* RAM_CEL; +void* RAM_SND; + +#include "game.h" + +Item irqVBL; +Item irqVRAM; +Item irqTimer; + +ScreenContext screen; +int32 screenPage; +Item screenItem; +int32 fps; +int32 g_timer; + +const int chars[10][20] = { + { + 0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0 + }, { + 0,0,1,0, + 0,1,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0 + }, { + 0,1,1,0, + 1,0,0,1, + 0,0,1,1, + 0,1,0,0, + 1,1,1,1 + }, { + 1,1,1,0, + 0,0,0,1, + 0,0,1,0, + 1,0,0,1, + 0,1,1,0 + }, { + 0,0,0,1, + 0,0,1,1, + 0,1,0,1, + 1,1,1,1, + 0,0,0,1 + }, { + 1,1,1,1, + 1,0,0,0, + 1,1,1,0, + 0,0,0,1, + 1,1,1,0 + }, { + 0,1,1,0, + 1,0,0,0, + 1,1,1,0, + 1,0,0,1, + 0,1,1,0 + }, { + 1,1,1,1, + 0,0,0,1, + 0,0,1,0, + 0,1,0,0, + 0,1,0,0 + }, { + 0,1,1,0, + 1,0,0,1, + 0,1,1,0, + 1,0,0,1, + 0,1,1,0 + }, { + 0,1,1,0, + 1,0,0,1, + 0,1,1,1, + 0,0,0,1, + 0,1,1,0 + } +}; + +void drawChar(int32 x, int32 y, int32 c) +{ + uint16* ptr = (uint16*)screen.sc_Bitmaps[screenPage]->bm_Buffer; + + ptr += y / 2 * 2 * FRAME_WIDTH; + ptr += x * 2; + ptr += y & 1; + + for (int32 i = 0; i < 5; i++) + { + for (int32 j = 0; j < 4; j++) + { + if (chars[c][i * 4 + j]) + { + ptr[j * 2] = 0xFFFF; + } + } + + if ((y + i) & 1) { + ptr += FRAME_WIDTH * 2 - 1; + } else { + ptr += 1; + } + } +} + +void drawInt(int32 x, int32 y, int32 number) +{ + while (number) + { + drawChar(x, y, number % 10); + number /= 10; + x -= 6; + } +} + +void osSetPalette(const uint16* palette) +{ + // +} + +int32 osGetSystemTimeMS() +{ + return GetMSecTime(irqTimer); +} + +bool osSaveSettings() +{ + return false; +} + +bool osLoadSettings() +{ + return false; +} + +bool osCheckSave() +{ + return false; +} + +bool osSaveGame() +{ + return false; +} + +bool osLoadGame() +{ + return false; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) +{ + // +} + +IOInfo clearInfo = { + FLASHWRITE_CMD, IO_QUICK, 0, 0, -1, 0, 0, + { NULL, 0 }, + { NULL, FRAME_WIDTH * FRAME_HEIGHT * 2 } +}; + +X_INLINE void clearFast(int32 page) +{ + clearInfo.ioi_Recv.iob_Buffer = screen.sc_Bitmaps[page]->bm_Buffer; + SendIO(irqVRAM, &clearInfo); +} + +uint32 joyMask; + +void updateInput() +{ + ControlPadEventData event; + event.cped_ButtonBits = 0; + if (GetControlPad(1, 0, &event)) { + joyMask = event.cped_ButtonBits; + } + + keys = 0; + + if (joyMask & ControlUp) keys |= IK_UP; + if (joyMask & ControlRight) keys |= IK_RIGHT; + if (joyMask & ControlDown) keys |= IK_DOWN; + if (joyMask & ControlLeft) keys |= IK_LEFT; + if (joyMask & ControlA) keys |= IK_A; + if (joyMask & ControlB) keys |= IK_B; + if (joyMask & ControlC) keys |= IK_C; + if (joyMask & ControlLeftShift) keys |= IK_L; + if (joyMask & ControlRightShift) keys |= IK_R; + if (joyMask & ControlStart) keys |= IK_START; + if (joyMask & ControlX) keys |= IK_SELECT; +} + +#include +void* readFile(char* fileName, void* buffer, int32 bufferSize) +{ + printf("readFile %s\n", fileName); + + Item f = OpenDiskFile(fileName); + + if (f < 0) { + printf("failed to open file %s\n", fileName); + return NULL; + } + + IOInfo params; + DeviceStatus ds; + + Item req = CreateIOReq(NULL, 0, f, 0); + memset(¶ms, 0, sizeof(IOInfo)); + memset(&ds, 0, sizeof(DeviceStatus)); + params.ioi_Command = CMD_STATUS; + params.ioi_Recv.iob_Buffer = &ds; + params.ioi_Recv.iob_Len = sizeof(DeviceStatus); + + void* ptr = buffer; + + if (DoIO(req, ¶ms) >= 0) + { + int32 size = ds.ds_DeviceBlockCount * ds.ds_DeviceBlockSize; + + if (bufferSize < size) + { + printf("not enough buffer size for %s. %d bytes required!\n", fileName, size); + ptr = NULL; + } + + if (ptr != NULL) + { + memset(¶ms, 0, sizeof(IOInfo)); + params.ioi_Command = CMD_READ; + params.ioi_Recv.iob_Len = size; + params.ioi_Recv.iob_Buffer = ptr; + + if (DoIO(req, ¶ms) < 0) + { + printf("can't get file content!\n"); + ptr = NULL; + } + } + } + + DeleteIOReq(req); + CloseDiskFile(f); + + return ptr; +} + +const void* osLoadScreen(LevelID id) +{ + return TITLE_SCR; +} + +const void* osLoadLevel(LevelID id) +{ + char buf[32]; + + sprintf(buf, "data/%s.D", (const char*)gLevelInfo[id].data); + readFile(buf, RAM_LVL, MAX_RAM_LVL); + + sprintf(buf, "data/%s.V", (const char*)gLevelInfo[id].data); + readFile(buf, RAM_TEX, MAX_RAM_TEX); + + return RAM_LVL; +} + +uint32 frame; +uint32 lastFrame; + +int main(int argc, char *argv[]) +{ + printf("OpenLara 3DO\n"); + MemInfo memInfoVRAM; + AvailMem(&memInfoVRAM, MEMTYPE_DRAM); + printf("DRAM: %d\n", memInfoVRAM.minfo_SysFree); + AvailMem(&memInfoVRAM, MEMTYPE_VRAM); + printf("VRAM: %d\n", memInfoVRAM.minfo_SysFree); + + uint32 lastSec = 0; + uint32 frameIndex = 0; + + OpenMathFolio(); + OpenGraphicsFolio(); + OpenAudioFolio(); + InitEventUtility(1, 0, LC_Observer); + CreateBasicDisplay(&screen, DI_TYPE_DEFAULT, 2); + + for (int32 i = 0; i < 2; i++) + { + //SetCEControl(screen.sc_BitmapItems[i], 0xFFFFFFFF, ASCALL); // -5 ms but perf spikes and total blackout :( + //DisableHAVG(screen.sc_BitmapItems[i]); + //DisableVAVG(screen.sc_BitmapItems[i]); + } + + irqVBL = GetVBLIOReq(); + irqVRAM = GetVRAMIOReq(); + irqTimer = GetTimerIOReq(); + + uint8* memVRAM = (uint8*)AllocMem(MAX_RAM_TEX, MEMTYPE_VRAM); + uint8* memDRAM = (uint8*)AllocMem(MAX_RAM_LVL + MAX_RAM_CEL + MAX_RAM_SND, MEMTYPE_DRAM); + + if (!memVRAM) printf("VRAM failed!\n"); + if (!memDRAM) printf("DRAM failed!\n"); + + RAM_TEX = memVRAM; + RAM_LVL = memDRAM; + RAM_CEL = memDRAM + MAX_RAM_LVL; + RAM_SND = memDRAM + MAX_RAM_LVL + MAX_RAM_CEL; + + sndInit(); + + gameInit(); + + AvailMem(&memInfoVRAM, MEMTYPE_DRAM); + printf("DRAM: %d\n", memInfoVRAM.minfo_SysFree); + AvailMem(&memInfoVRAM, MEMTYPE_VRAM); + printf("VRAM: %d\n", memInfoVRAM.minfo_SysFree); + + GetVBLTime(irqVBL, NULL, &lastFrame); + lastFrame /= 2; + lastFrame--; + + while (1) + { + WaitVBL(irqVBL, 1); + clearFast(screenPage); + + updateInput(); + + //GetVBLTime(irqVBL, NULL, &frame); // slower + QueryGraphics(QUERYGRAF_TAG_FIELDCOUNT, &frame); + + if (screen.sc_DisplayType != DI_TYPE_NTSC) + { + frame = frame * 6 / 5; // PAL fix + } + + if (frame/60 != lastSec) { + lastSec = frame/60; + fps = frameIndex; + frameIndex = 0; + } + + frame /= 2; // 30 Hz + +int32 updateTime = osGetSystemTimeMS(); + gameUpdate(frame - lastFrame); +updateTime = osGetSystemTimeMS() - updateTime; + + lastFrame = frame; + + screenItem = screen.sc_ScreenItems[screenPage]; + +int32 renderTime = osGetSystemTimeMS(); + gameRender(); +renderTime = osGetSystemTimeMS() - renderTime; + + drawInt(FRAME_WIDTH - 8, 4 + 16, updateTime); + drawInt(FRAME_WIDTH - 8, 4 + 24, renderTime); + + DisplayScreen(screen.sc_Screens[screenPage], NULL); + screenPage ^= 1; + + frameIndex++; + } + + return 0; +} diff --git a/src/platform/3do/matrixLerp.s b/src/platform/3do/matrixLerp.s new file mode 100644 index 00000000..26fd094a --- /dev/null +++ b/src/platform/3do/matrixLerp.s @@ -0,0 +1,120 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT matrixLerp_asm + +n RN r0 +pmul RN r1 +pdiv RN r2 +m0 RN r3 +m1 RN r4 +m2 RN r5 +n0 RN r6 +n1 RN r7 +n2 RN r12 +m RN lr +tmp RN m0 +divLUT RN m0 + + MACRO + load + ldmia m, {m0, m1, m2} + ldmia n!, {n0, n1, n2} + MEND + + MACRO + store + stmia m!, {m0, m1, m2} + MEND + + MACRO ; a = (a + b) / 2 + _1_2 + load + add m0, m0, n0 + add m1, m1, n1 + add m2, m2, n2 + mov m0, m0, asr #1 + mov m1, m1, asr #1 + mov m2, m2, asr #1 + store + MEND + + MACRO ; a = a + (b - a) / 4 + _1_4 + load + sub n0, n0, m0 + sub n1, n1, m1 + sub n2, n2, m2 + add m0, m0, n0, asr #2 + add m1, m1, n1, asr #2 + add m2, m2, n2, asr #2 + store + MEND + + MACRO ; a = b - (b - a) / 4 + _3_4 + load + sub m0, n0, m0 + sub m1, n1, m1 + sub m2, n2, m2 + sub m0, n0, m0, asr #2 + sub m1, n1, m1, asr #2 + sub m2, n2, m2, asr #2 + store + MEND + + MACRO ; a = a + (b - a) * mul / div + _X_Y + load + sub n0, n0, m0 + sub n1, n1, m1 + sub n2, n2, m2 + mul n0, pmul, n0 + mul n1, pmul, n1 + mul n2, pmul, n2 + add m0, m0, n0, asr #8 + add m1, m1, n1, asr #8 + add m2, m2, n2, asr #8 + store + MEND + + MACRO + lerp $func + $func ; e00, e10, e20 + $func ; e01, e11, e21 + $func ; e02, e12, e22 + MEND + +matrixLerp_asm + stmfd sp!, {r4-r7, lr} + ldr m, =gMatrixPtr + ldr m, [m] +check_2 + cmp pdiv, #2 + beq m1_d2 +check_4 + cmp pdiv, #4 + bne mX_dY + cmp pmul, #1 + beq m1_d4 + cmp pmul, #2 + beq m1_d2 ; 2/4 = 1/2 +m3_d4 + lerp _3_4 + b done +m1_d4 + lerp _1_4 + b done +m1_d2 + lerp _1_2 + b done +mX_dY + ldr divLUT, =divTable + ldr tmp, [divLUT, pdiv, lsl #2] + mul tmp, pmul, tmp + mov pmul, tmp, asr #8 + lerp _X_Y +done ldmfd sp!, {r4-r7, pc} + END diff --git a/src/platform/3do/matrixPush.s b/src/platform/3do/matrixPush.s new file mode 100644 index 00000000..286b727e --- /dev/null +++ b/src/platform/3do/matrixPush.s @@ -0,0 +1,33 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT matrixPush_asm + +e0 RN r0 +e1 RN r1 +e2 RN r2 +e3 RN r3 +m RN e0 +src RN r12 +dst RN lr + +matrixPush_asm + stmfd sp!, {lr} + ldr m, =gMatrixPtr + ldr src, [m] + add dst, src, #(12 * 4) + str dst, [m] + + ldmia src!, {e0, e1, e2, e3} + stmia dst!, {e0, e1, e2, e3} + + ldmia src!, {e0, e1, e2, e3} + stmia dst!, {e0, e1, e2, e3} + + ldmia src!, {e0, e1, e2, e3} + stmia dst!, {e0, e1, e2, e3} + + ldmfd sp!, {pc} + END diff --git a/src/platform/3do/matrixRotate.s b/src/platform/3do/matrixRotate.s new file mode 100644 index 00000000..b8251f84 --- /dev/null +++ b/src/platform/3do/matrixRotate.s @@ -0,0 +1,245 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + IMPORT phd_sin_asm + + EXPORT matrixRotateX_asm + EXPORT matrixRotateY_asm + EXPORT matrixRotateZ_asm + EXPORT matrixRotateYQ_asm + EXPORT matrixRotateYXZ_asm + + MACRO + sincos $angle, $sin, $cos + ldr $sin, =gSinCosTable + ldr $sin, [$sin, $angle, lsl #2] + mov $cos, $sin, lsl #16 + mov $cos, $cos, asr #16 + mov $sin, $sin, asr #16 + MEND + + MACRO + rotxy $x, $y, $sin, $cos, $t + mul $t, $y, $cos + mla $t, $x, $sin, $t + mul $x, $cos, $x + rsb $y, $y, #0 + mla $x, $y, $sin, $x + mov $y, $t, asr #FIXED_SHIFT + mov $x, $x, asr #FIXED_SHIFT + MEND + +angle RN r0 +ex0 RN r1 +ex1 RN r2 +ex2 RN r3 +ey0 RN r4 +ey1 RN r5 +ey2 RN r6 +s RN r7 +c RN r12 +v RN lr +m RN angle + +matrixRotateX_asm + stmfd sp!, {r4-r7, lr} + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + add m, m, #(3 * 4) + + ldmia m, {ex0, ex1, ex2, ey0, ey1, ey2} + + rotxy ey0, ex0, s, c, v + rotxy ey1, ex1, s, c, v + rotxy ey2, ex2, s, c, v + + stmia m, {ex0, ex1, ex2, ey0, ey1, ey2} + + ldmfd sp!, {r4-r7, pc} + + +matrixRotateY_asm + stmfd sp!, {r4-r7, lr} + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m!, {ex0, ex1, ex2} + add m, m, #(3 * 4) + ldmia m!, {ey0, ey1, ey2} + + rotxy ex0, ey0, s, c, v + rotxy ex1, ey1, s, c, v + rotxy ex2, ey2, s, c, v + + stmdb m!, {ey0, ey1, ey2} + sub m, m, #(3 * 4) + stmdb m!, {ex0, ex1, ex2} + + ldmfd sp!, {r4-r7, pc} + + +matrixRotateZ_asm + stmfd sp!, {r4-r7, lr} + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m, {ex0, ex1, ex2, ey0, ey1, ey2} + + rotxy ey0, ex0, s, c, v + rotxy ey1, ex1, s, c, v + rotxy ey2, ex2, s, c, v + + stmia m, {ex0, ex1, ex2, ey0, ey1, ey2} + + ldmfd sp!, {r4-r7, pc} + + +angleX RN r0 +angleY RN r1 +angleZ RN r2 +e00 RN r3 +e10 RN r4 +e20 RN r5 +e01 RN r6 +e11 RN r7 +e21 RN r8 +e02 RN r9 +e12 RN r10 +e22 RN r11 +tmp RN r12 +sinX RN lr +sinY RN sinX +sinZ RN sinX +cosX RN angleX +cosY RN angleY +cosZ RN angleZ +mask RN tmp +mm RN tmp + +matrixRotateYXZ_asm + mov mask, #0xFF + orr mask, mask, #0xF00 ; mask = 0xFFF + + and angleX, mask, angleX, lsr #4 + and angleY, mask, angleY, lsr #4 + and angleZ, mask, angleZ, lsr #4 + + orr mask, angleX, angleY + orrs mask, mask, angleZ + moveq pc, lr + + stmfd sp!, {r4-r11, lr} + + ldr mm, =gMatrixPtr + ldr mm, [mm] + ldmia mm, {e00, e10, e20, e01, e11, e21, e02, e12, e22} + +_rotY cmp angleY, #0 + beq _rotX + + sincos angleY, sinY, cosY + + rotxy e00, e02, sinY, cosY, tmp + rotxy e10, e12, sinY, cosY, tmp + rotxy e20, e22, sinY, cosY, tmp + +_rotX cmp angleX, #0 + beq _rotZ + + sincos angleX, sinX, cosX + + rotxy e02, e01, sinX, cosX, tmp + rotxy e12, e11, sinX, cosX, tmp + rotxy e22, e21, sinX, cosX, tmp + +_rotZ cmp angleZ, #0 + beq _done + + sincos angleZ, sinZ, cosZ + + rotxy e01, e00, sinZ, cosZ, tmp + rotxy e11, e10, sinZ, cosZ, tmp + rotxy e21, e20, sinZ, cosZ, tmp + +_done ldr mm, =gMatrixPtr + ldr mm, [mm] + stmia mm, {e00, e10, e20, e01, e11, e21, e02, e12, e22} + ldmfd sp!, {r4-r11, pc} + +q RN r0 +mx RN r1 +my RN r2 + +mx0 RN r3 +mx1 RN r4 +mx2 RN r5 + +my0 RN q +my1 RN r12 +my2 RN lr + +matrixRotateYQ_asm + cmp q, #2 + moveq pc, lr + + stmfd sp!, {r4-r5, lr} + + ldr mx, =gMatrixPtr + ldr mx, [mx] + add my, mx, #(6 * 4) + + ldmia mx, {mx0, mx1, mx2} + + cmp q, #1 + beq q_1 + cmp q, #3 + beq q_3 + +q_0 ldmia my, {my0, my1, my2} + rsb mx0, mx0, #0 + rsb mx1, mx1, #0 + rsb mx2, mx2, #0 + rsb my0, my0, #0 + rsb my1, my1, #0 + rsb my2, my2, #0 + stmia mx, {mx0, mx1, mx2} + stmia my, {my0, my1, my2} + ldmfd sp!, {r4-r5, pc} + +q_1 ldmia my, {my0, my1, my2} + stmia mx, {my0, my1, my2} + rsb mx0, mx0, #0 + rsb mx1, mx1, #0 + rsb mx2, mx2, #0 + stmia my, {mx0, mx1, mx2} + ldmfd sp!, {r4-r5, pc} + +q_3 ldmia my, {my0, my1, my2} + stmia my, {mx0, mx1, mx2} + rsb my0, my0, #0 + rsb my1, my1, #0 + rsb my2, my2, #0 + stmia mx, {my0, my1, my2} + ldmfd sp!, {r4-r5, pc} + + END diff --git a/src/platform/3do/matrixSetBasis.s b/src/platform/3do/matrixSetBasis.s new file mode 100644 index 00000000..759190a9 --- /dev/null +++ b/src/platform/3do/matrixSetBasis.s @@ -0,0 +1,32 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT matrixSetBasis_asm + +dst RN r0 +src RN r1 + +e0 RN r2 +e1 RN r3 +e2 RN r12 + +matrixSetBasis_asm + ; column-major + ; e0 e1 e2 + ; e0 e1 e2 + ; e0 e1 e2 + ; x y z + + ldmia src!, {e0, e1, e2} + stmia dst!, {e0, e1, e2} + + ldmia src!, {e0, e1, e2} + stmia dst!, {e0, e1, e2} + + ldmia src!, {e0, e1, e2} + stmia dst!, {e0, e1, e2} + + mov pc, lr + END diff --git a/src/platform/3do/matrixSetIdentity.s b/src/platform/3do/matrixSetIdentity.s new file mode 100644 index 00000000..58e789d6 --- /dev/null +++ b/src/platform/3do/matrixSetIdentity.s @@ -0,0 +1,33 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT matrixSetIdentity_asm + +e0 RN r0 +e1 RN r1 +e2 RN r2 +e3 RN r3 +m RN r12 + +matrixSetIdentity_asm + ldr m, =gMatrixPtr + ldr m, [m] + mov e0, #0x4000 + mov e1, #0 + mov e2, #0 + mov e3, #0 + + ; column-major + ; e0 e1 e2 + ; e3 e0 e1 + ; e2 e3 e0 + ; e1 e2 e3 + + stmia m!, {e0, e1, e2, e3} + stmia m!, {e0, e1, e2, e3} + stmia m!, {e0, e1, e2, e3} + + mov pc, lr + END diff --git a/src/platform/3do/matrixTranslate.s b/src/platform/3do/matrixTranslate.s new file mode 100644 index 00000000..da25ed3c --- /dev/null +++ b/src/platform/3do/matrixTranslate.s @@ -0,0 +1,108 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT matrixTranslateRel_asm + EXPORT matrixTranslateAbs_asm + EXPORT matrixTranslateSet_asm + +x RN r0 +y RN r1 +z RN r2 +m RN r3 +e0 RN r4 +e1 RN r5 +e2 RN r6 +dx RN r7 +dy RN r12 +dz RN lr + +matrixTranslateRel_asm + stmfd sp!, {r4-r7, lr} + + ldr m, =gMatrixPtr + ldr m, [m] + add m, m, #(12 * 4) + + ldmdb m!, {dx, dy, dz} + + ldmdb m!, {e0, e1, e2} + mla dx, e0, z, dx + mla dy, e1, z, dy + mla dz, e2, z, dz + + ldmdb m!, {e0, e1, e2} + mla dx, e0, y, dx + mla dy, e1, y, dy + mla dz, e2, y, dz + + ldmdb m!, {e0, e1, e2} + mla dx, e0, x, dx + mla dy, e1, x, dy + mla dz, e2, x, dz + + add m, m, #(9 * 4) + stmia m!, {dx, dy, dz} + + ldmfd sp!, {r4-r7, pc} + + +matrixTranslateAbs_asm + stmfd sp!, {r4-r7, lr} + + ldr m, =gCameraViewPos + ldmia m, {e0, e1, e2} + sub x, x, e0 + sub y, y, e1 + sub z, z, e2 + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m!, {e0, e1, e2} + mul dx, e0, x + mul dy, e1, x + mul dz, e2, x + + ldmia m!, {e0, e1, e2} + mla dx, e0, y, dx + mla dy, e1, y, dy + mla dz, e2, y, dz + + ldmia m!, {e0, e1, e2} + mla dx, e0, z, dx + mla dy, e1, z, dy + mla dz, e2, z, dz + + stmia m!, {dx, dy, dz} + + ldmfd sp!, {r4-r7, pc} + + +matrixTranslateSet_asm + stmfd sp!, {r4-r7, lr} + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m!, {e0, e1, e2} + mul dx, e0, x + mul dy, e1, x + mul dz, e2, x + + ldmia m!, {e0, e1, e2} + mla dx, e0, y, dx + mla dy, e1, y, dy + mla dz, e2, y, dz + + ldmia m!, {e0, e1, e2} + mla dx, e0, z, dx + mla dy, e1, z, dy + mla dz, e2, z, dz + + stmia m, {dx, dy, dz} + + ldmfd sp!, {r4-r7, pc} + + END diff --git a/src/platform/3do/projectVertices.s b/src/platform/3do/projectVertices.s new file mode 100644 index 00000000..48f59573 --- /dev/null +++ b/src/platform/3do/projectVertices.s @@ -0,0 +1,93 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT projectVertices_asm + +vCount RN r0 +mx RN vCount +my RN r1 +mz RN r2 +x RN r3 +y RN r4 +z RN r5 +dz RN r6 +minXY RN r7 +maxXY RN r8 +minZ RN r9 +maxZ RN r12 +m RN dz +vp RN dz +last RN r10 +vertex RN r11 +divLUT RN lr + +projectVertices_asm + stmfd sp!, {r4-r11, lr} + + ldr m, =gMatrixPtr + ldr m, [m] + ldr vertex, =gVertices + mov r3, vCount + add vCount, vCount, vCount, lsl #1 + add last, vertex, vCount, lsl #2 ; last = gVertices + vCount * 12 + + mov r2, m + mov r1, vertex + mov r0, vertex + swi MulManyVec3Mat33_F16 + + add m, m, #36 ; skip 3x3 matrix part + ldmia m, {mx, my, mz} ; get view space offset from matrix + ldr divLUT, =divTable + ldr vp, =viewportRel + ldmia vp, {minXY, maxXY} + + mov minZ, #VIEW_MIN + mov maxZ, #VIEW_MAX + + mov my, my, asr #FIXED_SHIFT + mov my, my, lsl #PROJ_SHIFT + + mov mz, mz, asr #FIXED_SHIFT + mov mz, mz, lsl #CLIP_SHIFT + +loop ldmia vertex, {x, y, z} ; read transformed vertex + + add x, x, mx, asr #FIXED_SHIFT + add y, my, y, lsl #PROJ_SHIFT ; extra shift for min/max cmp with hi half-word + add z, mz, z, lsl #CLIP_SHIFT ; add some bits for the clipping flags + + ; check z clipping + cmp z, minZ + orrle z, minZ, #CLIP_NEAR + cmp z, maxZ + orrge z, maxZ, #CLIP_FAR + + ; projection + mov dz, z, lsr #(PROJ_SHIFT + CLIP_SHIFT) ; z is positive + ldr dz, [divLUT, dz, lsl #2] + mul x, dz, x + mul y, dz, y + mov x, x, asr #(16 - PROJ_SHIFT) + ; keep y shifted by 16 for min/max cmp + + ; check xy clipping + cmp x, minXY, asr #16 + orrle z, z, #CLIP_LEFT + cmp y, minXY, lsl #16 + orrle z, z, #CLIP_TOP + cmp x, maxXY, asr #16 + orrge z, z, #CLIP_RIGHT + cmp y, maxXY, lsl #16 + orrge z, z, #CLIP_BOTTOM + + mov y, y, asr #16 + + stmia vertex!, {x, y, z} ; store projected vertex + cmp vertex, last + blt loop + + ldmfd sp!, {r4-r11, pc} + END diff --git a/src/platform/3do/render_cel.cpp b/src/platform/3do/render_cel.cpp new file mode 100644 index 00000000..76409f06 --- /dev/null +++ b/src/platform/3do/render_cel.cpp @@ -0,0 +1,1076 @@ +#include "common.h" + +//#define DEBUG_CLIPPING +//#define CHECK_LIMITS + +struct Vertex +{ + int32 x, y, z; // for rooms z = (depth << CLIP_SHIFT) | ClipFlags +}; + +uint16* gPalette; // offset to the default or underwater PLUTs + +extern Level level; + +int32 gVerticesCount; +int32 gFacesCount; + +Vertex gVertices[MAX_VERTICES]; + +Face* gFaces; // MAX_FACES +Face* gFacesBase; + +struct ListOT { + Face* head; + Face* tail; +}; + +ListOT gOT[OT_SIZE]; + +struct ViewportRel { + int32 minXY; + int32 maxXY; +}; + +ViewportRel viewportRel; + +#define SHADOW_OPACITY 3 // 50% +#define MIP_DIST (1024 * 5) + +extern Item screenItem; + +#define FACE_CCW (1 << 31) +#define FACE_MIP_SHIFT 11 +#define FACE_TEXTURE 0x07FF + +#define DUP16(value) value | (value << 16) + +enum ShadeValue +{ + SHADE_SHADOW = PPMPC_1S_CFBD | PPMPC_SF_8 | PPMPC_2S_PDC | (SHADOW_OPACITY << PPMPC_MF_SHIFT), // transparent + SHADE_1 = DUP16( PPMPC_MF_1 | PPMPC_SF_8 | PPMPC_2D_2 ), // 1/16 + SHADE_2 = DUP16( PPMPC_MF_2 | PPMPC_SF_8 | PPMPC_2D_2 ), // 2/16 + SHADE_3 = DUP16( PPMPC_MF_3 | PPMPC_SF_8 | PPMPC_2D_2 ), // 3/16 + SHADE_4 = DUP16( PPMPC_MF_4 | PPMPC_SF_8 | PPMPC_2D_2 ), // 4/16 + SHADE_5 = DUP16( PPMPC_MF_5 | PPMPC_SF_8 | PPMPC_2D_2 ), // 5/16 + SHADE_6 = DUP16( PPMPC_MF_6 | PPMPC_SF_8 | PPMPC_2D_2 ), // 6/16 + SHADE_7 = DUP16( PPMPC_MF_7 | PPMPC_SF_8 | PPMPC_2D_2 ), // 7/16 + SHADE_8 = DUP16( PPMPC_MF_8 | PPMPC_SF_8 | PPMPC_2D_2 ), // 8/16 + SHADE_9 = DUP16( PPMPC_MF_1 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 9/16 + SHADE_10 = DUP16( PPMPC_MF_2 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 10/16 + SHADE_11 = DUP16( PPMPC_MF_3 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 11/16 + SHADE_12 = DUP16( PPMPC_MF_4 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 12/16 + SHADE_13 = DUP16( PPMPC_MF_5 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 13/16 + SHADE_14 = DUP16( PPMPC_MF_6 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 14/16 + SHADE_15 = DUP16( PPMPC_MF_7 | PPMPC_SF_8 | PPMPC_2D_2 | PPMPC_2S_PDC ), // 15/16 + SHADE_16 = DUP16( PPMPC_MF_8 | PPMPC_SF_8 ), // 1 + SHADE_17 = DUP16( PPMPC_MF_1 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 1/16 + SHADE_18 = DUP16( PPMPC_MF_2 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 2/16 + SHADE_19 = DUP16( PPMPC_MF_3 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 3/16 + SHADE_20 = DUP16( PPMPC_MF_4 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 4/16 + SHADE_21 = DUP16( PPMPC_MF_5 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 5/16 + SHADE_22 = DUP16( PPMPC_MF_6 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 6/16 + SHADE_23 = DUP16( PPMPC_MF_7 | PPMPC_SF_16 | PPMPC_2S_PDC ), // 1 + 7/16 + SHADE_24 = DUP16( PPMPC_MF_8 | PPMPC_SF_16 | PPMPC_2S_PDC ) // 1 + 8/16 +}; + +extern "C" const uint32 shadeTable[32] = { + SHADE_24, + SHADE_24, + SHADE_23, + SHADE_23, + SHADE_22, + SHADE_22, + SHADE_21, + SHADE_21, + SHADE_20, + SHADE_20, + SHADE_19, + SHADE_19, + SHADE_18, + SHADE_18, + SHADE_17, + SHADE_17, + SHADE_16, + SHADE_15, + SHADE_14, + SHADE_13, + SHADE_12, + SHADE_11, + SHADE_10, + SHADE_9, + SHADE_8, + SHADE_7, + SHADE_6, + SHADE_5, + SHADE_4, + SHADE_3, + SHADE_2, + SHADE_1 +}; + +extern "C" const MeshQuad gShadowQuads[] = { + 0, (0 | (1 << 8) | (2 << 16) | (7 << 24)), + 0, (7 | (2 << 8) | (3 << 16) | (6 << 24)), + 0, (6 | (3 << 8) | (4 << 16) | (5 << 24)), +}; + +void renderInit() +{ + gPalette = (uint16*)RAM_TEX; + gFaces = (Face*)RAM_CEL; + gFacesBase = gFaces; + + Face* face = gFaces; + for (int32 i = 0; i < MAX_FACES; i++, face++) + { + // set preamble for CCB_CCBPRE flag + face->ccb_PRE0 = PRE0_BGND | PRE0_LINEAR | PRE0_BPP_16; + face->ccb_PRE1 = PRE1_TLLSB_PDC0; + } +} + +void renderFree() +{ +} + +void renderLevelInit() +{ +} + +void renderLevelFree() +{ +} + +void setViewport(const RectMinMax &vp) +{ + viewport = vp; + + int32 minX = vp.x0 - (FRAME_WIDTH >> 1); + int32 minY = vp.y0 - (FRAME_HEIGHT >> 1); + int32 maxX = vp.x1 - (FRAME_WIDTH >> 1); + int32 maxY = vp.y1 - (FRAME_HEIGHT >> 1); + + viewportRel.minXY = (minX << 16) | (minY & 0xFFFF); + viewportRel.maxXY = (maxX << 16) | (maxY & 0xFFFF); +} + +void setPaletteIndex(int32 index) +{ + uint32 paletteOffset = *(uint32*)RAM_TEX; + gPalette = (uint16*)(intptr_t(RAM_TEX) + paletteOffset + index * level.tilesCount * sizeof(uint16) * 16); +} + +X_INLINE int32 cross(const Vertex *a, const Vertex *b, const Vertex *c) +{ + return (b->x - a->x) * (c->y - a->y) - + (c->x - a->x) * (b->y - a->y); +} + +enum ClipFlags { + CLIP_SHIFT = 8, + CLIP_MASK = (1 << CLIP_SHIFT) - 1, + CLIP_LEFT = 1 << 0, + CLIP_RIGHT = 1 << 1, + CLIP_TOP = 1 << 2, + CLIP_BOTTOM = 1 << 3, + CLIP_FAR = 1 << 4, + CLIP_NEAR = 1 << 5 +}; + +X_INLINE Face* faceAdd(int32 depth) +{ + Face* face = gFacesBase++; + + if (gOT[depth].head) { + face->ccb_NextPtr = gOT[depth].head; + } else { + gOT[depth].tail = face; + } + + gOT[depth].head = face; + + return face; +} + +X_INLINE void ccbSetTexture(uint32 flags, Face* face, const Texture* texture) +{ + face->ccb_Flags = + CCB_NPABS | + CCB_SPABS | + CCB_PPABS | + CCB_LDSIZE | + CCB_LDPRS | + CCB_LDPPMP | + CCB_LDPLUT | + CCB_YOXY | + CCB_ACSC | CCB_ALSC | + CCB_ACW | CCB_ACCW | + CCB_ACE | + CCB_NOBLK | + (flags >> (8 + FACE_MIP_SHIFT + FACE_MIP_SHIFT) << 5); // set CCB_BGND (0x20 == 1 << 5) + + face->ccb_SourcePtr = (CelData*)texture->data; + face->ccb_PLUTPtr = (uint8*)gPalette + (texture->shift >> 16); +} + +X_INLINE void ccbSetColor(uint32 flags, Face* face) +{ + face->ccb_Flags = + CCB_NPABS | + CCB_SPABS | + CCB_PPABS | + CCB_LDSIZE | + CCB_LDPRS | + CCB_LDPPMP | + CCB_CCBPRE | // use the preamble words set in renderInit + CCB_YOXY | + CCB_ACSC | CCB_ALSC | + CCB_ACW | CCB_ACCW | + CCB_ACE | + CCB_NOBLK | + CCB_BGND; + + face->ccb_SourcePtr = (CelData*)&gPalette[flags & 0xFF]; +} + +#ifdef USE_ASM + #define unpackRoom unpackRoom_asm // -53% + #define unpackMesh unpackMesh_asm // -48% + #define projectVertices projectVertices_asm // -18% + #define faceAddRoomQuads faceAddRoomQuads_asm // -46% + #define faceAddRoomTriangles faceAddRoomTriangles_asm // -30% + #define faceAddMeshQuads faceAddMeshQuads_asm // -36% + #define faceAddMeshTriangles faceAddMeshTriangles_asm // -38% + #define faceAddMeshQuadsFlat faceAddMeshQuadsFlat_asm // -28% + #define faceAddMeshTrianglesFlat faceAddMeshTrianglesFlat_asm // -35% + + extern "C" { + void unpackRoom_asm(const RoomVertex* vertices, int32 vCount); + void unpackMesh_asm(const MeshVertex* vertices, int32 vCount); + void projectVertices_asm(int32 vCount); + void faceAddRoomQuads_asm(const RoomQuad* polys, int32 count); + void faceAddRoomTriangles_asm(const RoomTriangle* polys, int32 count); + void faceAddMeshQuads_asm(const MeshQuad* polys, int32 count, uint32 shade); + void faceAddMeshTriangles_asm(const MeshTriangle* polys, int32 count, uint32 shade); + void faceAddMeshQuadsFlat_asm(const MeshQuad* polys, int32 count, uint32 shade); + void faceAddMeshTrianglesFlat_asm(const MeshTriangle* polys, int32 count, uint32 shade); + } +#else + #define unpackRoom unpackRoom_c + #define unpackMesh unpackMesh_c + #define projectVertices projectVertices_c + #define faceAddRoomQuads faceAddRoomQuads_c + #define faceAddRoomTriangles faceAddRoomTriangles_c + #define faceAddMeshQuads faceAddMeshQuads_c + #define faceAddMeshTriangles faceAddMeshTriangles_c + #define faceAddMeshQuadsFlat faceAddMeshQuadsFlat_c + #define faceAddMeshTrianglesFlat faceAddMeshTrianglesFlat_c + +void unpackRoom_c(const RoomVertex* vertices, int32 vCount) +{ + Vertex* res = gVertices; + + uint32 *v32 = (uint32*)vertices; + + for (int32 i = 0; i < vCount; i += 4) + { + uint32 n0 = *v32++; + uint32 n1 = *v32++; + + res->x = (n0 << 12) & 0x1F000; + res->y = (n0 << 5) & 0xFC00; + res->z = (n0 << 1) & 0x1F000; + res++; + + res->x = (n0 >> 4) & 0x1F000; + res->y = (n0 >> 11) & 0xFC00; + res->z = (n0 >> 15) & 0x1F000; + res++; + + res->x = (n1 << 12) & 0x1F000; + res->y = (n1 << 5) & 0xFC00; + res->z = (n1 << 1) & 0x1F000; + res++; + + res->x = (n1 >> 4) & 0x1F000; + res->y = (n1 >> 11) & 0xFC00; + res->z = (n1 >> 15) & 0x1F000; + res++; + } +} + +void unpackMesh_c(const MeshVertex* vertices, int32 vCount) +{ + uint32 *v32 = (uint32*)vertices; + + Vertex* res = gVertices; + for (int32 i = 0; i < vCount; i += 2) + { + uint32 n0 = *v32++; + uint32 n1 = *v32++; + uint32 n2 = *v32++; + + res->x = int16(n0 >> 16); + res->y = int16(n0); + res->z = int16(n1 >> 16); + res++; + + res->x = int16(n1); + res->y = int16(n2 >> 16); + res->z = int16(n2); + res++; + } +} + +void projectVertices_c(int32 vCount) +{ + Vertex* v = gVertices; + Vertex* last = gVertices + vCount; + + Matrix &m = matrixGet(); + int32 mx = m.e03 >> FIXED_SHIFT; + int32 my = m.e13 >> FIXED_SHIFT; + int32 mz = m.e23 >> FIXED_SHIFT; + + MulManyVec3Mat33_F16((vec3f16*)v, (vec3f16*)v, *(mat33f16*)&m, vCount); + + do + { + int32 x = v->x + mx; + int32 y = v->y + my; + int32 z = v->z + mz; + + int32 clip = 0; + + if (z <= (VIEW_MIN_F >> FIXED_SHIFT)) { + z = (VIEW_MIN_F >> FIXED_SHIFT); + clip = CLIP_NEAR; + } else if (z >= (VIEW_MAX_F >> FIXED_SHIFT)) { + z = (VIEW_MAX_F >> FIXED_SHIFT); + clip = CLIP_FAR; + } + + PERSPECTIVE(x, y, z); + + // Y is shifted left by 16 + y <<= 16; + + int32 vMinXY = viewportRel.minXY; + int32 vMaxXY = viewportRel.maxXY; + + if (x < (vMinXY >> 16)) clip |= CLIP_LEFT; + if (y < (vMinXY << 16)) clip |= CLIP_TOP; + if (x > (vMaxXY >> 16)) clip |= CLIP_RIGHT; + if (y > (vMaxXY << 16)) clip |= CLIP_BOTTOM; + + v->x = x; + v->y = y >> 16; + v->z = (z << CLIP_SHIFT) | clip; + v++; + } while (v < last); +} + +X_INLINE void ccbMap4(Face* f, const Vertex* v0, const Vertex* v1, const Vertex* v2, const Vertex* v3, uint32 shift) +{ + int32 x1 = v1->x; + int32 y1 = v1->y; + int32 x3 = v3->x; + int32 y3 = v3->y; + int32 x2 = v2->x; + int32 y2 = v2->y; + int32 x0 = v0->x; + int32 y0 = v0->y; + + uint32 ws = shift & 0xFF; + uint32 hs = (shift >> 8) & 0xFF; + + int32 hdx0 = (x1 - x0) << ws; + int32 hdy0 = (y1 - y0) << ws; + int32 hdx1 = (x2 - x3) << ws; + int32 hdy1 = (y2 - y3) << ws; + int32 vdx0 = (x3 - x0) << hs; + int32 vdy0 = (y3 - y0) << hs; + + hs = 16 - hs; + int32 hddx = (hdx1 - hdx0) >> hs; + int32 hddy = (hdy1 - hdy0) >> hs; + + f->ccb_XPos = (x0 + (FRAME_WIDTH >> 1)) << 16; + f->ccb_YPos = (y0 + (FRAME_HEIGHT >> 1)) << 16; + f->ccb_HDX = hdx0; + f->ccb_HDY = hdy0; + f->ccb_VDX = vdx0; + f->ccb_VDY = vdy0; + f->ccb_HDDX = hddx; + f->ccb_HDDY = hddy; + +#ifdef DEBUG_CLIPPING + f->ccb_PIXC = SHADE_SHADOW; +#endif +} + +X_INLINE void ccbMap3(Face* f, const Vertex* v0, const Vertex* v1, const Vertex* v2, uint32 shift) +{ + int32 x0 = v0->x; + int32 y0 = v0->y; + int32 x1 = v1->x; + int32 y1 = v1->y; + int32 x2 = v2->x; + int32 y2 = v2->y; + + uint32 ws = shift & 0xFF; + uint32 hs = (shift >> 8) & 0xFF; + + int32 hdx0 = (x1 - x0) << ws; + int32 hdy0 = (y1 - y0) << ws; + int32 vdx0 = (x2 - x0) << hs; + int32 vdy0 = (y2 - y0) << hs; + + f->ccb_XPos = (x0 + (FRAME_WIDTH >> 1)) << 16; + f->ccb_YPos = (y0 + (FRAME_HEIGHT >> 1)) << 16; + f->ccb_HDX = hdx0; + f->ccb_HDY = hdy0; + f->ccb_VDX = vdx0; + f->ccb_VDY = vdy0; + + hs = 16 - hs; + f->ccb_HDDX = -hdx0 >> hs; + f->ccb_HDDY = -hdy0 >> hs; + +#ifdef DEBUG_CLIPPING + f->ccb_PIXC = SHADE_SHADOW; +#endif +} + +#define DEPTH_Q_AVG(z0,z1,z2,z3) ((z0 + z1 + z2 + z3) >> (2 + CLIP_SHIFT + OT_SHIFT)) +#define DEPTH_T_AVG(z0,z1,z2) ((z0 + z1 + z2 + z2) >> (2 + CLIP_SHIFT + OT_SHIFT)) +#define DEPTH_Q_MAX(z0,z1,z2,z3) (X_MAX(z0, X_MAX(z1, X_MAX(z2, z3))) >> (CLIP_SHIFT + OT_SHIFT)) +#define DEPTH_T_MAX(z0,z1,z2) (X_MAX(z0, X_MAX(z1, z2)) >> (CLIP_SHIFT + OT_SHIFT)) + +void faceAddRoomQuads_c(const RoomQuad* polys, int32 count) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + uint32* indices = (uint32*)polys->indices; + + uint32 i01 = indices[0]; + uint32 i23 = indices[1]; + + uint32 i0 = (i01 >> 16); + uint32 i1 = (i01 & 0xFFFF); + uint32 i2 = (i23 >> 16); + uint32 i3 = (i23 & 0xFFFF); + + const Vertex* v0 = (Vertex*)((uint8*)gVertices + i0); + const Vertex* v1 = (Vertex*)((uint8*)gVertices + i1); + const Vertex* v2 = (Vertex*)((uint8*)gVertices + i2); + const Vertex* v3 = (Vertex*)((uint8*)gVertices + i3); + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + uint32 c3 = v3->z; + + if ((c0 & c1 & c2 & c3) & CLIP_MASK) + continue; + + int32 depth = DEPTH_Q_MAX(c0, c1, c2, c3); + + if (cross(v0, v1, v3) <= 0) + continue; + + Face* f = faceAdd(depth); + + int32 fog = X_MAX(0, (depth - (FOG_MIN >> OT_SHIFT)) >> 1); + uint32 intensity = X_MIN(255, fog + ((flags >> (FACE_MIP_SHIFT + FACE_MIP_SHIFT)) & 0xFF)); + + f->ccb_PIXC = shadeTable[intensity >> 3]; + + uint32 texIndex = flags; + if (depth > (MIP_DIST >> OT_SHIFT)) { + texIndex >>= FACE_MIP_SHIFT; + } + const Texture* texture = level.textures + (texIndex & FACE_TEXTURE); + ccbSetTexture(flags, f, texture); + + ccbMap4(f, v0, v1, v2, v3, texture->shift); + } +} + +void faceAddRoomTriangles_c(const RoomTriangle* polys, int32 count) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + uint32* indices = (uint32*)polys->indices; + + uint32 i01 = indices[0]; + uint32 i23 = indices[1]; + + uint32 i0 = (i01 >> 16); + uint32 i1 = (i01 & 0xFFFF); + uint32 i2 = (i23 >> 16); + + const Vertex* v0 = (Vertex*)((uint8*)gVertices + i0); + const Vertex* v1 = (Vertex*)((uint8*)gVertices + i1); + const Vertex* v2 = (Vertex*)((uint8*)gVertices + i2); + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + + if ((c0 & c1 & c2) & CLIP_MASK) + continue; + + int32 depth = DEPTH_T_MAX(c0, c1, c2); + + if (cross(v0, v1, v2) <= 0) + continue; + + Face* f = faceAdd(depth); + + uint32 intensity = (flags >> (FACE_MIP_SHIFT + FACE_MIP_SHIFT)) & 0xFF; + if (depth > (FOG_MIN >> OT_SHIFT)) { + intensity += (depth - (FOG_MIN >> OT_SHIFT)) >> 1; + intensity = X_MIN(intensity, 255); + } + + f->ccb_PIXC = shadeTable[intensity >> 3]; + + uint32 texIndex = flags; + if (depth > (MIP_DIST >> OT_SHIFT)) { + texIndex >>= FACE_MIP_SHIFT; + } + const Texture* texture = level.textures + (texIndex & FACE_TEXTURE); + ccbSetTexture(flags, f, texture); + + ccbMap3(f, v0, v1, v2, texture->shift); + } +} + +void faceAddMeshQuads_c(const MeshQuad* polys, int32 count, uint32 shade) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 indices = polys->indices; + uint32 flags = polys->flags; + + uint32 i0 = indices & 0xFF; indices >>= 8; + uint32 i1 = indices & 0xFF; indices >>= 8; + uint32 i2 = indices & 0xFF; indices >>= 8; + uint32 i3 = indices; + + const Vertex* v0 = gVertices + i0; + const Vertex* v1 = gVertices + i1; + const Vertex* v2 = gVertices + i2; + const Vertex* v3 = gVertices + i3; + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + uint32 c3 = v3->z; + + if ((c0 & c1 & c2 & c3) & CLIP_MASK) + continue; + + int32 depth = DEPTH_Q_AVG(c0, c1, c2, c3); + + if ((cross(v0, v1, v3) ^ flags) & FACE_CCW) + continue; + + Face* f = faceAdd(depth); + f->ccb_PIXC = shade; + + const Texture* texture = level.textures + (flags & FACE_TEXTURE); + ccbSetTexture(flags, f, texture); + + ccbMap4(f, v0, v1, v2, v3, texture->shift); + } +} + +void faceAddMeshTriangles_c(const MeshTriangle* polys, int32 count, uint32 shade) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 indices = polys->indices; + uint32 flags = polys->flags; + + uint32 i0 = indices & 0xFF; indices >>= 8; + uint32 i1 = indices & 0xFF; indices >>= 8; + uint32 i2 = indices; + + const Vertex* v0 = gVertices + i0; + const Vertex* v1 = gVertices + i1; + const Vertex* v2 = gVertices + i2; + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + + if ((c0 & c1 & c2) & CLIP_MASK) + continue; + + int32 depth = DEPTH_T_AVG(v0->z, v1->z, v2->z); + + if (cross(v0, v1, v2) <= 0) + continue; + + Face* f = faceAdd(depth); + f->ccb_PIXC = shade; + + const Texture* texture = level.textures + (flags & FACE_TEXTURE); + ccbSetTexture(flags, f, texture); + + ccbMap3(f, v0, v1, v2, texture->shift); + } +} + +void faceAddMeshQuadsFlat_c(const MeshQuad* polys, int32 count, uint32 shade) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 indices = polys->indices; + uint32 flags = polys->flags; + + uint32 i0 = indices & 0xFF; indices >>= 8; + uint32 i1 = indices & 0xFF; indices >>= 8; + uint32 i2 = indices & 0xFF; indices >>= 8; + uint32 i3 = indices; + + const Vertex* v0 = gVertices + i0; + const Vertex* v1 = gVertices + i1; + const Vertex* v2 = gVertices + i2; + const Vertex* v3 = gVertices + i3; + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + uint32 c3 = v3->z; + + if ((c0 & c1 & c2 & c3) & CLIP_MASK) + continue; + + int32 depth = DEPTH_Q_AVG(v0->z, v1->z, v2->z, v3->z); + + if (cross(v0, v1, v3) <= 0) + continue; + + Face* f = faceAdd(depth); + f->ccb_PIXC = shade; + + ccbSetColor(flags, f); + + ccbMap4(f, v0, v1, v2, v3, 20 | (16 << 8)); + } +} + +void faceAddMeshTrianglesFlat_c(const MeshTriangle* polys, int32 count, uint32 shade) +{ + for (int32 i = 0; i < count; i++, polys++) + { + uint32 indices = polys->indices; + uint32 flags = polys->flags; + + uint32 i0 = indices & 0xFF; indices >>= 8; + uint32 i1 = indices & 0xFF; indices >>= 8; + uint32 i2 = indices; + + const Vertex* v0 = gVertices + i0; + const Vertex* v1 = gVertices + i1; + const Vertex* v2 = gVertices + i2; + + uint32 c0 = v0->z; + uint32 c1 = v1->z; + uint32 c2 = v2->z; + + if ((c0 & c1 & c2) & CLIP_MASK) + continue; + + int32 depth = DEPTH_T_AVG(v0->z, v1->z, v2->z); + + if (cross(v0, v1, v2) <= 0) + continue; + + Face* f = faceAdd(depth); + f->ccb_PIXC = shade; + + ccbSetColor(flags, f); + + ccbMap3(f, v0, v1, v2, 20 | (16 << 8)); + } +} + +int32 sphereIsVisible_c(int32 x, int32 y, int32 z, int32 r) +{ + Matrix &m = matrixGet(); + + //if (abs(x) < r && abs(y) < r && abs(z) < r) + // return 1; + + int32 vx = DP33(m.e00, m.e01, m.e02, x, y, z); + int32 vy = DP33(m.e10, m.e11, m.e12, x, y, z); + int32 vz = DP33(m.e20, m.e21, m.e22, x, y, z); + + if (vz < 0 || vz > VIEW_MAX_F) + return 0; + + x = vx >> FIXED_SHIFT; + y = vy >> FIXED_SHIFT; + z = vz >> FIXED_SHIFT; + + z = PERSPECTIVE_DZ(z); + int32 d = FixedInvU(z); + x = (x * d) >> (16 - PROJ_SHIFT); + y = (y * d) << PROJ_SHIFT; + r = (r * d); + + int32 rMinX = x - (r >> (16 - PROJ_SHIFT)); + int32 rMaxX = x + (r >> (16 - PROJ_SHIFT)); + int32 rMinY = y - (r << PROJ_SHIFT); + int32 rMaxY = y + (r << PROJ_SHIFT); + + int32 vMinXY = viewportRel.minXY; + int32 vMaxXY = viewportRel.maxXY; + + if (rMaxX < (vMinXY >> 16) || + rMaxY < (vMinXY << 16) || + rMinX > (vMaxXY >> 16) || + rMinY > (vMaxXY << 16)) return 0; + + return 1; +} +#endif + +void transformRoom(const Room* room, int32 vCount) +{ + unpackRoom(room->data.vertices, vCount); + projectVertices(vCount); + +#ifdef CHECK_LIMITS + gVerticesCount += vCount; +#endif +} + +void transformMesh(const MeshVertex* vertices, int32 vCount) +{ + if (vCount <= 0) + return; + + unpackMesh(vertices, vCount); + projectVertices(vCount); + +#ifdef CHECK_LIMITS + gVerticesCount += vCount; +#endif +} + +void renderShadow(int32 x, int32 z, int32 sx, int32 sz) +{ +#ifdef CHECK_LIMITS + if (gFacesCount + 3 > MAX_FACES) + return; + gFacesCount += 3; +#endif + x <<= F16_SHIFT; + z <<= F16_SHIFT; + sx <<= F16_SHIFT; + sz <<= F16_SHIFT; + + int32 xns1 = x - sx; + int32 xps1 = x + sx; + int32 xns2 = xns1 - sx; + int32 xps2 = xps1 + sx; + + int32 zns1 = z - sz; + int32 zps1 = z + sz; + int32 zns2 = zns1 - sz; + int32 zps2 = zps1 + sz; + + gVertices[0].x = xns1; gVertices[0].y = 0; gVertices[0].z = zps2; + gVertices[1].x = xps1; gVertices[1].y = 0; gVertices[1].z = zps2; + gVertices[2].x = xps2; gVertices[2].y = 0; gVertices[2].z = zps1; + gVertices[3].x = xps2; gVertices[3].y = 0; gVertices[3].z = zns1; + gVertices[4].x = xps1; gVertices[4].y = 0; gVertices[4].z = zns2; + gVertices[5].x = xns1; gVertices[5].y = 0; gVertices[5].z = zns2; + gVertices[6].x = xns2; gVertices[6].y = 0; gVertices[6].z = zns1; + gVertices[7].x = xns2; gVertices[7].y = 0; gVertices[7].z = zps1; + + projectVertices(8); + faceAddMeshQuadsFlat(gShadowQuads, 3, SHADE_SHADOW); +} + +void renderSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index) +{ +#ifdef CHECK_LIMITS + if (gFacesCount >= MAX_FACES) + return; + gFacesCount++; +#endif + + const Matrix &m = matrixGet(); + + vx -= gCameraViewPos.x; + vy -= gCameraViewPos.y; + vz -= gCameraViewPos.z; + + int32 z = DP33(m.e20, m.e21, m.e22, vx, vy, vz); + + if (z < VIEW_MIN_F || z >= VIEW_MAX_F) + { + return; + } + + int32 x = DP33(m.e00, m.e01, m.e02, vx, vy, vz); + int32 y = DP33(m.e10, m.e11, m.e12, vx, vy, vz); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + PERSPECTIVE(x, y, z); + + const Sprite* sprite = level.sprites + index; + + int32 d = (1 << 20) / z; + int32 x0 = sprite->l * d >> 12; + int32 x1 = sprite->r * d >> 12; + if (x0 == x1) return; + + int32 y0 = sprite->t * d >> 12; + int32 y1 = sprite->b * d >> 12; + if (y0 == y1) return; + + x0 += x; + x1 += x; + y0 += y; + y1 += y; + + int32 vMinXY = viewportRel.minXY; + int32 vMaxXY = viewportRel.maxXY; + + if (x0 > (vMaxXY >> 16) || + x1 < (vMinXY >> 16) || + y0 > (vMaxXY << 16 >> 16) || + y1 < (vMinXY << 16 >> 16)) return; + + int32 depth = X_MAX(0, z - 128) >> OT_SHIFT; // depth hack + + Face* f = faceAdd(depth); + + if (depth > (FOG_MIN >> OT_SHIFT)) { + vg += (depth - (FOG_MIN >> OT_SHIFT)) << 4; + vg = X_MIN(vg, 8191); + } + + vg >>= 8; + f->ccb_PIXC = shadeTable[vg]; + + Texture* texture = level.textures + sprite->texture; + ccbSetTexture(0, f, texture); + + uint32 shift = texture->shift; + uint32 ws = shift & 0xFF; + uint32 hs = shift >> 8; + + f->ccb_HDX = (x1 - x0) << ws; + f->ccb_HDY = 0; + f->ccb_VDX = 0; + f->ccb_VDY = (y1 - y0) << hs; + + f->ccb_XPos = (x0 + (FRAME_WIDTH >> 1)) << 16; + f->ccb_YPos = (y0 + (FRAME_HEIGHT >> 1)) << 16; + + f->ccb_HDDX = 0; + f->ccb_HDDY = 0; +} + +void renderGlyph(int32 vx, int32 vy, int32 index) +{ +#ifdef CHECK_LIMITS + if (gFacesCount >= MAX_FACES) + return; + gFacesCount++; +#endif + + const Sprite* sprite = level.sprites + index; + + Face* f = faceAdd(0); + f->ccb_PIXC = SHADE_16; + + Texture* texture = level.textures + sprite->texture; + ccbSetTexture(0, f, texture); + + uint32 shift = texture->shift; + uint32 ws = shift & 0xFF; + uint32 hs = shift >> 8; + + f->ccb_HDX = (sprite->r - sprite->l) << ws; + f->ccb_HDY = 0; + f->ccb_VDX = 0; + f->ccb_VDY = (sprite->b - sprite->t) << hs; + + f->ccb_XPos = (vx + sprite->l) << 16; + f->ccb_YPos = (vy + sprite->t) << 16; + + f->ccb_HDDX = 0; + f->ccb_HDDY = 0; +} + +void faceAddRoom(const Room* room) +{ + if (room->info->quadsCount) { + faceAddRoomQuads(room->data.quads, room->info->quadsCount); + } + + if (room->info->trianglesCount) { + faceAddRoomTriangles(room->data.triangles, room->info->trianglesCount); + } + +#ifdef CHECK_LIMITS + gFacesCount = gFacesBase - gFaces; +#endif +} + +void faceAddMesh(const MeshQuad* rFaces, const MeshQuad* crFaces, const MeshTriangle* tFaces, const MeshTriangle* ctFaces, int32 rCount, int32 crCount, int32 tCount, int32 ctCount, int32 intensity) +{ + uint32 shade = shadeTable[X_CLAMP((gLightAmbient + intensity) >> 8, 0, 31)]; + + if (rCount) { + faceAddMeshQuads(rFaces, rCount, shade); + } + + if (tCount) { + faceAddMeshTriangles(tFaces, tCount, shade); + } + + if (crCount) { + faceAddMeshQuadsFlat(crFaces, crCount, shade); + } + + if (ctCount) { + faceAddMeshTrianglesFlat(ctFaces, ctCount, shade); + } + +#ifdef CHECK_LIMITS + gFacesCount = gFacesBase - gFaces; +#endif +} + +void flush() +{ + Face* facesHead = NULL; + Face* facesTail = NULL; + + if (gFaces != gFacesBase) + { + PROFILE(CNT_FLUSH); + + for (int32 i = OT_SIZE - 1; i >= 0; i--) + { + if (!gOT[i].head) continue; + + Face *face = gOT[i].head; + gOT[i].head = NULL; + + if (face) + { + if (facesTail) + { + facesTail->ccb_NextPtr = face; + } else if (!facesHead) { + facesHead = face; + } + + facesTail = gOT[i].tail; + } + } + + if (facesHead) + { + LAST_CEL(facesTail); + DrawScreenCels(screenItem, (CCB*)facesHead); + UNLAST_CEL(facesTail); + } + } + +#ifdef PROFILING + #if !defined(PROFILE_FRAMETIME) && !defined(PROFILE_SOUNDTIME) + gCounters[CNT_VERT] += gVerticesCount; + gCounters[CNT_POLY] += gFacesCount; + #endif +#endif + + gVerticesCount = 0; + gFacesCount = 0; + gFacesBase = gFaces; +} + +void clear() +{ + // we use fast clear via SPORT on vblank +} + +void renderRoom(const Room* room) +{ + int32 vCount = room->info->verticesCount; + if (vCount <= 0) + return; + + transformRoom(room, vCount); + faceAddRoom(room); +} + +void renderMesh(const Mesh* mesh) +{ + int32 vCount = mesh->vCount; + if (vCount <= 0) + return; + + const uint8* ptr = (uint8*)mesh + sizeof(Mesh); + + const MeshVertex* vertices = (MeshVertex*)ptr; + ptr += vCount * sizeof(vertices[0]); + + if (vCount & 1) { // data alignment + ptr += sizeof(MeshVertex); + } + + MeshQuad* rFaces = (MeshQuad*)ptr; + ptr += mesh->rCount * sizeof(MeshQuad); + + MeshTriangle* tFaces = (MeshTriangle*)ptr; + ptr += mesh->tCount * sizeof(MeshTriangle); + + MeshQuad* crFaces = (MeshQuad*)ptr; + ptr += mesh->crCount * sizeof(MeshQuad); + + MeshTriangle* ctFaces = (MeshTriangle*)ptr; + ptr += mesh->ctCount * sizeof(MeshTriangle); + + transformMesh(vertices, vCount); + faceAddMesh(rFaces, crFaces, tFaces, ctFaces, mesh->rCount, mesh->crCount, mesh->tCount, mesh->ctCount, mesh->intensity); +} + +void renderBorder(int32 x, int32 y, int32 width, int32 height, int32 shade, int32 color1, int32 color2, int32 z) +{ + // TODO +} + +#define BAR_HEIGHT 5 + +void renderBar(int32 x, int32 y, int32 width, int32 value, BarType type) +{ + // TODO +} + +void renderBackground(const void* background) +{ + // TODO +} + +void* copyBackground() +{ + return NULL; // TODO +} diff --git a/src/platform/3do/sound.cpp b/src/platform/3do/sound.cpp new file mode 100644 index 00000000..e851ee6a --- /dev/null +++ b/src/platform/3do/sound.cpp @@ -0,0 +1,331 @@ +#include "common.h" +#include + +Item sndMixer; + +struct Channel +{ + Item gainL; + Item gainR; + Item sampler; + Item attach; + Item frequency; + Item amplitude; + + int32 index; + bool playing; + + void setPitch(uint32 value) + { + if (frequency >= 0) { + TweakKnob(frequency, value); + } + } + + void setVolume(uint32 value) + { + if (amplitude >= 0) { + TweakKnob(amplitude, value); + } + } +}; + +struct SampleData +{ + Item data; + int32 size; +}; + +Channel channels[SND_CHANNELS]; // [sample, sample, sample, music] +SampleData samples[MAX_SAMPLES]; + +#define MUSIC_CHANNEL (SND_CHANNELS - 1) + +Item musicThread; +SPPlayer* musicPlayer; +SPSound* music; +uint32 musicSignal; +int32 musicTrack; + +void musicProc() +{ + OpenAudioFolio(); + + musicSignal = AllocSignal(0); + + void* buffers[SND_BUFFERS]; + for (int32 i = 0; i < SND_BUFFERS; i++) + { + buffers[i] = (uint8*)RAM_SND + i * SND_BUFFER_SIZE; + } + + spCreatePlayer(&musicPlayer, channels[MUSIC_CHANNEL].sampler, SND_BUFFERS, SND_BUFFER_SIZE, buffers); + + int32 signalMask = spGetPlayerSignalMask(musicPlayer); + + while (1) + { + WaitSignal(musicSignal); + + channels[MUSIC_CHANNEL].playing = true; + + int32 track = musicTrack; + { + char path[32]; + sprintf(path, "audio/%d.aifc", track); + + spAddSoundFile(&music, musicPlayer, path); + } + + spStartReading(music, SP_MARKER_NAME_BEGIN); + + spStartPlayingVA(musicPlayer, + AF_TAG_AMPLITUDE, 0x7FFF, + TAG_END); + + while (spGetPlayerStatus(musicPlayer) & SP_STATUS_F_BUFFER_ACTIVE) + { + int32 signal = WaitSignal(signalMask); + if (spService(musicPlayer, signal) < 0) + break; + + if (track != musicTrack) { + spStop(musicPlayer); + } + } + + spRemoveSound(music); + channels[MUSIC_CHANNEL].playing = false; + } +} + + +void sndInit() +{ + #if SND_CHANNELS != 4 + #error change the sound mixer or channels count + #endif + + sndMixer = LoadInstrument("mixer4x2.dsp", 0, 100); + + LoadInstrument("decodeadpcm.dsp", 0, 100); + + char* LGainName = "LeftGain0"; + char* RGainName = "RightGain0"; + char* InputName = "Input0"; + + for (int32 i = 0; i < SND_CHANNELS; i++) + { + Channel* ch = channels + i; + + LGainName[8] = '0' + i; + RGainName[9] = '0' + i; + InputName[5] = '0' + i; + + ch->gainL = GrabKnob(sndMixer, LGainName); + ch->gainR = GrabKnob(sndMixer, RGainName); + + if (i == MUSIC_CHANNEL) { + ch->sampler = LoadInstrument("dcsqxdhalfmono.dsp", 0, 100); + ConnectInstruments(ch->sampler, "Output", sndMixer, InputName); + } else { + ch->sampler = LoadInstrument("adpcmvarmono.dsp", 0, 100); + ConnectInstruments(ch->sampler, "Output", sndMixer, InputName); + } + + ch->frequency = GrabKnob(ch->sampler, "Frequency"); + ch->amplitude = GrabKnob(ch->sampler, "Amplitude"); + ch->setVolume(0x7FFF); + ch->setPitch(0x2000); + + TweakKnob(ch->gainL, 255 << 6); + TweakKnob(ch->gainR, 255 << 6); + + ch->index = -1; + ch->playing = false; + } + + StartInstrument(sndMixer, NULL); + + musicThread = CreateThread("music", 180, musicProc, 2048); +} + +void sndInitSamples() +{ + for (int32 i = 0; i < level.soundOffsetsCount; i++) + { + uint8* data = (uint8*)level.soundData + level.soundOffsets[i]; + int32 frames = *(uint32*)data; + + samples[i].size = frames >> 1; + samples[i].data = CreateSampleVA( + AF_TAG_FRAMES, frames, + AF_TAG_ADDRESS, (uint8*)data + 4, + AF_TAG_CHANNELS, 1, + AF_TAG_WIDTH, 2, + AF_TAG_COMPRESSIONTYPE, ID_ADP4, + AF_TAG_COMPRESSIONRATIO, 4, + TAG_END); + } +} + +void sndFreeSamples() +{ + if (!level.soundOffsetsCount) + return; + + for (int32 i = 0; i < SND_CHANNELS - 1; i++) + { + Channel* ch = channels + i; + + if (ch->index < 0) + continue; + + StopInstrument(ch->sampler, NULL); + DetachSample(ch->attach); + + ch->index = -1; + ch->playing = false; + } + + for (int32 i = 0; i < level.soundOffsetsCount; i++) + { + UnloadSample(samples[i].data); + } +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + volume = volume * 0x7FFF >> SND_VOL_SHIFT; + pitch = pitch * 0x2000 >> SND_PITCH_SHIFT; + +// update playing status + int32 maxPos = -2; + int32 maxPosIndex = -1; + + for (int32 i = 0; i < SND_CHANNELS; i++) + { + Channel* ch = channels + i; + if (!ch->playing) + continue; + + int32 pos = WhereAttachment(ch->attach); + if (pos == -1 || pos >= samples[ch->index].size) + { + ch->playing = false; + } + + if (maxPos < pos) { + maxPos = pos; + maxPosIndex = i; + } + } + +// get existing channel + if (mode == UNIQUE || mode == REPLAY) + { + for (int32 i = 0; i < SND_CHANNELS - 1; i++) + { + Channel* ch = channels + i; + + if (ch->index != index) + continue; + + ch->setVolume(volume); + ch->setPitch(pitch); + + if (!ch->playing || mode == REPLAY) + { + ch->playing = true; + StartInstrument(ch->sampler, NULL); + } + + return (void*)ch->sampler; + } + } + +// get free channel + for (int32 i = 0; i < SND_CHANNELS - 1; i++) + { + Channel* ch = channels + i; + + if (ch->playing) + continue; + + if (ch->index >= 0) + { + StopInstrument(ch->sampler, NULL); + DetachSample(ch->attach); + } + + ch->setVolume(volume); + ch->setPitch(pitch); + ch->attach = AttachSample(ch->sampler, samples[index].data, NULL); + ch->index = index; + ch->playing = true; + + StartInstrument(ch->sampler, NULL); + + return (void*)ch->sampler; + } + +// stop a longest playing sample + if (maxPosIndex != -1) + { + sndStopSample(maxPosIndex); + + Channel* ch = channels + maxPosIndex; + + ch->setVolume(volume); + ch->setPitch(pitch); + ch->attach = AttachSample(ch->sampler, samples[index].data, NULL); + ch->index = index; + ch->playing = true; + + StartInstrument(ch->sampler, NULL); + + return (void*)ch->sampler; + } + + return NULL; +} + +void sndPlayTrack(int32 track) +{ + musicTrack = track; + + if (track >= 0) { + SendSignal(musicThread, musicSignal); + } +} + +void sndStopTrack() +{ + sndPlayTrack(-1); +} + +bool sndTrackIsPlaying() +{ + return channels[MUSIC_CHANNEL].playing; +} + +void sndStopSample(int32 index) +{ + Channel* ch = channels + index; + if (!ch->playing) + return; + + StopInstrument(ch->sampler, NULL); + DetachSample(ch->attach); + ch->index = -1; + ch->playing = false; +} + +void sndStop() +{ + //sndStopTrack(); // TODO wait for signal? + for (int32 i = 0; i < SND_CHANNELS - 1; i++) + { + sndStopSample(i); + } +} \ No newline at end of file diff --git a/src/platform/3do/sphereIsVisible.s b/src/platform/3do/sphereIsVisible.s new file mode 100644 index 00000000..9245e7ef --- /dev/null +++ b/src/platform/3do/sphereIsVisible.s @@ -0,0 +1,87 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT sphereIsVisible_asm + +x RN r0 +y RN r1 +z RN r2 +r RN r3 +vx RN r4 +vy RN r5 +vz RN r6 +mx RN r7 +my RN r8 +mz RN r12 + +m RN lr +divLUT RN m +vp RN m +vMinXY RN z +vMaxXY RN r + +rMinX RN vx +rMaxX RN x +rMinY RN vy +rMaxY RN y + +sphereIsVisible_asm + stmfd sp!, {r4-r8, lr} + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m!, {mx, my, mz} + mul vx, mx, x + mul vy, my, x + mul vz, mz, x + ldmia m!, {mx, my, mz} + mla vx, mx, y, vx + mla vy, my, y, vy + mla vz, mz, y, vz + ldmia m!, {mx, my, mz} + mla vx, mx, z, vx + mla vy, my, z, vy + mla vz, mz, z, vz + + cmp vz, #VIEW_MAX_F + bhi _fail + + mov x, vx, asr #FIXED_SHIFT + mov y, vy, asr #FIXED_SHIFT + mov z, vz, lsr #(FIXED_SHIFT + PROJ_SHIFT) + + ldr divLUT, =divTable + ldr z, [divLUT, z, lsl #2] + mul x, z, x + mul y, z, y + mul r, z, r + + mov x, x, asr #(16 - PROJ_SHIFT) + mov y, y, lsl #(PROJ_SHIFT) + + sub rMinX, x, r, lsr #(16 - PROJ_SHIFT) + add rMaxX, x, r, lsr #(16 - PROJ_SHIFT) + sub rMinY, y, r, lsl #PROJ_SHIFT + add rMaxY, y, r, lsl #PROJ_SHIFT + + ldr vp, =viewportRel + ldmia vp, {vMinXY, vMaxXY} + + cmp rMaxX, vMinXY, asr #16 + blt _fail + cmp rMaxY, vMinXY, lsl #16 + blt _fail + cmp rMinX, vMaxXY, asr #16 + bgt _fail + cmp rMinY, vMaxXY, lsl #16 + bgt _fail + + mov r0, #1 + ldmfd sp!, {r4-r8, pc} + +_fail mov r0, #0 + ldmfd sp!, {r4-r8, pc} + END diff --git a/src/platform/3do/unpackMesh.s b/src/platform/3do/unpackMesh.s new file mode 100644 index 00000000..da5ee59b --- /dev/null +++ b/src/platform/3do/unpackMesh.s @@ -0,0 +1,48 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT unpackMesh_asm + +unpackMesh_asm + +data RN r0 +vCount RN r1 +vx0 RN vCount +vy0 RN r2 +vz0 RN r3 +vx1 RN r4 +vy1 RN r5 +vz1 RN r6 +n0 RN vy0 +n1 RN vx1 +n2 RN vz1 +vertex RN r12 +last RN lr + + stmfd sp!, {r4-r6, lr} + ldr vertex, =gVertices + add vCount, vCount, vCount, lsl #1 + add last, data, vCount, lsl #1 ; last = data + vCount * 6 + +loop ldmia data!, {n0, n1, n2} ; load two encoded vertices + cmp data, last + + mov vx0, n0, asr #16 ; x + mov n0, n0, lsl #16 + mov vy0, n0, asr #16 ; y + + mov vz0, n1, asr #16 ; z + mov n1, n1, lsl #16 + mov vx1, n1, asr #16 ; x + + mov vy1, n2, asr #16 ; y + mov n2, n2, lsl #16 + mov vz1, n2, asr #16 ; z + + stmia vertex!, {vx0, vy0, vz0, vx1, vy1, vz1} + blt loop + + ldmfd sp!, {r4-r6, pc} + END diff --git a/src/platform/3do/unpackRoom.s b/src/platform/3do/unpackRoom.s new file mode 100644 index 00000000..3d474758 --- /dev/null +++ b/src/platform/3do/unpackRoom.s @@ -0,0 +1,72 @@ + AREA |C$$code|, CODE, READONLY +|x$codeseg| + + INCLUDE common_asm.inc + + EXPORT unpackRoom_asm + +unpackRoom_asm + +data RN r0 +vCount RN r1 +vx0 RN vCount +vy0 RN r2 +vz0 RN r3 +vx1 RN r4 +vy1 RN r5 +vz1 RN r6 +vx2 RN vx0 +vy2 RN vy0 +vz2 RN vz0 +vx3 RN vx1 +vy3 RN vy1 +vz3 RN vz1 +n0 RN vz1 +n1 RN r7 +maskH RN r8 +maskV RN r9 +vertex RN r12 +last RN lr + + stmfd sp!, {r4-r9, lr} + ldr vertex, =gVertices + add last, data, vCount, lsl #1 ; last = data + vCount * 2 + mov maskH, #0x1F000 + mov maskV, #0x0FC00 + +loop ldmia data!, {n0, n1} ; load four encoded vertices + cmp data, last + + ; n0 = z1:5, y1:6, x1:5, z0:5, y0:6, x0:5 + ; n1 = z3:5, y3:6, x3:5, z2:5, y2:6, x2:5 + + ; 1st vertex + and vx0, maskH, n0, lsl #12 ; decode x0 + and vy0, maskV, n0, lsl #5 ; decode y0 + and vz0, maskH, n0, lsl #1 ; decode z0 + + ; 2nd vertex + and vx1, maskH, n0, lsr #4 ; decode x1 + and vy1, maskV, n0, lsr #11 ; decode y1 + and vz1, maskH, n0, lsr #15 ; decode z1 + + ; store + stmia vertex!, {vx0, vy0, vz0, vx1, vy1, vz1} + + ; 3rd vertex + and vx2, maskH, n1, lsl #12 ; decode x2 + and vy2, maskV, n1, lsl #5 ; decode y2 + and vz2, maskH, n1, lsl #1 ; decode z2 + + ; 4th vertex + and vx3, maskH, n1, lsr #4 ; decode x3 + and vy3, maskV, n1, lsr #11 ; decode y3 + and vz3, maskH, n1, lsr #15 ; decode z3 + + ; store + stmia vertex!, {vx2, vy2, vz2, vx3, vy3, vz3} + + blt loop + + ldmfd sp!, {r4-r9, pc} + END diff --git a/src/platform/3ds/Makefile b/src/platform/3ds/Makefile new file mode 100644 index 00000000..7eb7a4a3 --- /dev/null +++ b/src/platform/3ds/Makefile @@ -0,0 +1,253 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +TOPDIR ?= $(CURDIR) +include $(DEVKITARM)/3ds_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +# GRAPHICS is a list of directories containing graphics files +# GFXBUILD is the directory where converted graphics files will be placed +# If set to $(BUILD), it will statically link in the converted +# files as if they were data files. +# +# NO_SMDH: if set to anything, no SMDH file is generated. +# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional) +# APP_TITLE is the name of the app stored in the SMDH file (Optional) +# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) +# APP_AUTHOR is the author of the app stored in the SMDH file (Optional) +# ICON is the filename of the icon (.png), relative to the project folder. +# If not set, it attempts to use one of the following (in this order): +# - .png +# - icon.png +# - /default_icon.png +#--------------------------------------------------------------------------------- +TARGET := OpenLara +BUILD := build +SOURCES := . ../../libs/stb_vorbis ../../libs/tinf ../../shaders/pica +DATA := data +INCLUDES := ../.. +GRAPHICS := gfx +GFXBUILD := $(BUILD) +APP_AUTHOR := XProger +APP_DESCRIPTION := Classic Tomb Raider open-source engine +#ROMFS := romfs +#GFXBUILD := $(ROMFS)/gfx + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft + +CFLAGS := $(ARCH) -g0 -w -Ofast -ffast-math -mword-relocations -fomit-frame-pointer -ffunction-sections +CFLAGS += $(INCLUDE) -DARM11 -D_3DS + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 + +ASFLAGS := -g $(ARCH) +LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +LIBS := -lcitro3d -lctru -lm -lvorbisidec -logg + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CTRULIB) $(PORTLIBS) + + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) +SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist))) +GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +#--------------------------------------------------------------------------------- +ifeq ($(GFXBUILD),$(BUILD)) +#--------------------------------------------------------------------------------- +export T3XFILES := $(GFXFILES:.t3s=.t3x) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- +export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES)) +export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES)) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ + $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \ + $(addsuffix .o,$(T3XFILES)) + +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \ + $(addsuffix .h,$(subst .,_,$(BINFILES))) \ + $(GFXFILES:.t3s=.h) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh) + +ifeq ($(strip $(ICON)),) + icons := $(wildcard *.png) + ifneq (,$(findstring $(TARGET).png,$(icons))) + export APP_ICON := $(TOPDIR)/$(TARGET).png + else + ifneq (,$(findstring icon.png,$(icons))) + export APP_ICON := $(TOPDIR)/icon.png + endif + endif +else + export APP_ICON := $(TOPDIR)/$(ICON) +endif + +ifeq ($(strip $(NO_SMDH)),) + export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh +endif + +ifneq ($(ROMFS),) + export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) +endif + +.PHONY: all clean + +#--------------------------------------------------------------------------------- +all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES) + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +$(BUILD): + @mkdir -p $@ + +ifneq ($(GFXBUILD),$(BUILD)) +$(GFXBUILD): + @mkdir -p $@ +endif + +ifneq ($(DEPSDIR),$(BUILD)) +$(DEPSDIR): + @mkdir -p $@ +endif + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD) + +#--------------------------------------------------------------------------------- +$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS) + +$(OFILES_SOURCES) : $(HFILES) + +$(OUTPUT).elf : $(OFILES) + +#--------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#--------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +#--------------------------------------------------------------------------------- +.PRECIOUS : %.t3x +#--------------------------------------------------------------------------------- +%.t3x.o %_t3x.h : %.t3x +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +#--------------------------------------------------------------------------------- +# rules for assembling GPU shaders +#--------------------------------------------------------------------------------- +define shader-as + $(eval CURBIN := $*.shbin) + $(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d) + echo "$(CURBIN).o: $< $1" > $(DEPSFILE) + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h + echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h + picasso -o $(CURBIN) $1 + bin2s $(CURBIN) | $(AS) -o $*.shbin.o +endef + +%.shbin.o %_shbin.h : %.v.pica %.g.pica + @echo $(notdir $^) + @$(call shader-as,$^) + +%.shbin.o %_shbin.h : %.v.pica + @echo $(notdir $<) + @$(call shader-as,$<) + +%.shbin.o %_shbin.h : %.shlist + @echo $(notdir $<) + @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file))) + +#--------------------------------------------------------------------------------- +%.t3x %.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @tex3ds -i $< -H $*.h -d $*.d -o $*.t3x + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/src/platform/3ds/deploy.sh b/src/platform/3ds/deploy.sh new file mode 100644 index 00000000..d90c6628 --- /dev/null +++ b/src/platform/3ds/deploy.sh @@ -0,0 +1,2 @@ +make +/C/devkitPro/tools/bin/3dslink.exe OpenLara.3dsx -a 192.168.1.68 diff --git a/src/platform/3ds/icon.png b/src/platform/3ds/icon.png new file mode 100644 index 00000000..48a5d3af Binary files /dev/null and b/src/platform/3ds/icon.png differ diff --git a/src/platform/3ds/main.cpp b/src/platform/3ds/main.cpp new file mode 100644 index 00000000..911e5ae7 --- /dev/null +++ b/src/platform/3ds/main.cpp @@ -0,0 +1,259 @@ +#include +#include +#include +#include + +#include "game.h" + +// multi-threading +void* osMutexInit() { + Handle *mutex = new Handle(); + svcCreateMutex(mutex, false); + return mutex; +} + +void osMutexFree(void *obj) { + svcCloseHandle(*(Handle*)obj); + delete (Handle*)obj; +} + +void osMutexLock(void *obj) { + svcWaitSynchronization(*(Handle*)obj, U64_MAX); +} + +void osMutexUnlock(void *obj) { + svcReleaseMutex(*(Handle*)obj); +} + +// timing +u64 osStartTime = 0; + +int osGetTimeMS() { + return int(osGetTime() - osStartTime); +} + +// backlight +bool bottomScreenOn = false; + +void setBottomScreen(bool enable) { + gspLcdInit(); + enable ? GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM) : GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_BOTTOM); + gspLcdExit(); +} + +aptHookCookie(cookie); + +void checkAptHook(APT_HookType hook, void *param) { + if (!bottomScreenOn) { + switch(hook) { + case APTHOOK_ONSUSPEND : setBottomScreen(true); + break; + case APTHOOK_ONRESTORE : + case APTHOOK_ONWAKEUP : setBottomScreen(false); + break; + default: + break; + } + } +} + +// input +bool osJoyReady(int index) { + return index == 0; +} + +void osJoyVibrate(int index, float L, float R) { + // +} + +void inputInit() { + aptHook(&cookie, checkAptHook, NULL); + hidInit(); +} + +void inputUpdate() { + const static u64 keys[jkMAX] = { 0, + KEY_B, KEY_A, KEY_Y, KEY_X, KEY_L, KEY_R, KEY_SELECT, KEY_START, + 0, 0, KEY_ZL, KEY_ZR, + KEY_DLEFT, KEY_DRIGHT, KEY_DUP, KEY_DDOWN, + }; + + hidScanInput(); + + u64 down = hidKeysDown(); + u64 mask = down | hidKeysHeld(); + + for (int i = 1; i < jkMAX; i++) { + Input::setJoyDown(0, JoyKey(jkNone + i), (mask & keys[i]) != 0); + } + + circlePosition circlePos; + hidCircleRead(&circlePos); + + vec2 stickL = vec2(float(circlePos.dx), float(-circlePos.dy)) / 160.0f; + + if (fabsf(stickL.x) < 0.3f && fabsf(stickL.y) < 0.3f) stickL = vec2(0.0f); + Input::setJoyPos(0, jkL, stickL); + + if (down & KEY_TOUCH) { + bottomScreenOn = !bottomScreenOn; + bottomScreenOn ? setBottomScreen(true) : setBottomScreen(false); + } +} + +void inputFree() { + if (!bottomScreenOn) + setBottomScreen(true); + hidExit(); +} + +// sound +#define SND_FRAMES (4704/2) + +ndspWaveBuf sndWaveBuf[2]; +Sound::Frame *sndBuffer; +Thread sndThread; +int sndBufIndex; +bool sndReady; + +void sndFill(void *arg) { + memset(sndWaveBuf, 0, sizeof(sndWaveBuf)); + sndWaveBuf[0].data_vaddr = sndBuffer + 0; + sndWaveBuf[0].nsamples = SND_FRAMES; + sndWaveBuf[1].data_vaddr = sndBuffer + SND_FRAMES; + sndWaveBuf[1].nsamples = SND_FRAMES; + + Sound::fill(sndBuffer, SND_FRAMES * 2); + + sndBufIndex = 0; + ndspChnWaveBufAdd(0, sndWaveBuf + 0); + ndspChnWaveBufAdd(0, sndWaveBuf + 1); + + while (sndReady) { + ndspWaveBuf &buf = sndWaveBuf[sndBufIndex]; + + if (buf.status == NDSP_WBUF_DONE) { + Sound::fill((Sound::Frame*)buf.data_pcm16, buf.nsamples); + DSP_FlushDataCache(buf.data_pcm16, buf.nsamples); + ndspChnWaveBufAdd(0, &buf); + sndBufIndex = !sndBufIndex; + } + + svcSleepThread(1000000ULL); + } +} + +void sndInit() { + sndBuffer = (Sound::Frame*)linearAlloc(SND_FRAMES * sizeof(Sound::Frame) * 2); + + ndspInit(); + ndspSetOutputMode (NDSP_OUTPUT_STEREO); + ndspChnSetFormat (0, NDSP_FORMAT_STEREO_PCM16); + ndspChnSetInterp (0, NDSP_INTERP_LINEAR); + ndspChnSetRate (0, 44100); + + float mix[12]; + memset(mix, 0, sizeof(mix)); + mix[0] = 1.0; + mix[1] = 1.0; + ndspChnSetMix(0, mix); + + sndReady = true; + + s32 priority = 0; + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); + + sndThread = threadCreate(sndFill, NULL, 64 * 1024, priority - 1, -1, false); +} + +void sndFree() { + sndReady = false; + threadJoin(sndThread, U64_MAX); + threadFree(sndThread); + + ndspExit(); + linearFree((uint32*)sndBuffer); +} + +int checkLanguage() +{ + uint8 id; + CFGU_GetSystemLanguage(&id); + + int str = STR_LANG_EN; + switch (id) + { + case CFG_LANGUAGE_EN : str = STR_LANG_EN; break; + case CFG_LANGUAGE_FR : str = STR_LANG_FR; break; + case CFG_LANGUAGE_DE : str = STR_LANG_DE; break; + case CFG_LANGUAGE_ES : str = STR_LANG_ES; break; + case CFG_LANGUAGE_IT : str = STR_LANG_IT; break; + case CFG_LANGUAGE_PT : str = STR_LANG_PT; break; + case CFG_LANGUAGE_RU : str = STR_LANG_RU; break; + case CFG_LANGUAGE_JP : str = STR_LANG_JA; break; + case CFG_LANGUAGE_ZH : str = STR_LANG_CN; break; + } + return str - STR_LANG_EN; +} + +int main() { + cfguInit(); + + setBottomScreen(false); + + { + bool isNew3DS; + APT_CheckNew3DS(&isNew3DS); + if (isNew3DS) { + osSetSpeedupEnable(true); + } + } + + strcpy(cacheDir, "sdmc:/3ds/OpenLara/"); + strcpy(saveDir, "sdmc:/3ds/OpenLara/"); + strcpy(contentDir, "sdmc:/3ds/OpenLara/"); + + Stream::init(); + + Core::defLang = checkLanguage(); + + sndInit(); + inputInit(); + + osStartTime = Core::getTime(); + + Game::init(); + + if (Core::isQuit) { + bottomScreenOn = true; + setBottomScreen(true); + consoleClear(); + LOG("\n\nCopy the original game content to:\n\n %s\n\nPress A to exit", contentDir); + while (aptMainLoop()) { + hidScanInput(); + u64 mask = hidKeysDown() | hidKeysHeld(); + if (mask & KEY_A) { + break; + } + + gfxFlushBuffers(); + gfxSwapBuffers(); + gspWaitForVBlank(); + } + } else { + while (aptMainLoop() && !Core::isQuit) { + inputUpdate(); + + Game::update(); + Game::render(); + + GAPI::present(); + } + } + + inputFree(); + sndFree(); + Game::deinit(); + + return 0; +} \ No newline at end of file diff --git a/src/platform/android/app/CMakeLists.txt b/src/platform/android/app/CMakeLists.txt index bd0efd8e..da2b5cf0 100644 --- a/src/platform/android/app/CMakeLists.txt +++ b/src/platform/android/app/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.4.1) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID -std=c++11 -fno-rtti -fno-exceptions -fvisibility=hidden -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID -std=c++11 -fno-rtti -fno-exceptions -fvisibility=hidden -Wall -Wno-invalid-source-encoding") add_library( game SHARED src/main/cpp/main.cpp @@ -12,4 +12,4 @@ add_library( game SHARED include_directories(../../../) -target_link_libraries( game GLESv2 log ) \ No newline at end of file +target_link_libraries( game GLESv3 OpenSLES log ) \ No newline at end of file diff --git a/src/platform/android/app/build.gradle b/src/platform/android/app/build.gradle index cfe0ce67..c55e5f63 100644 --- a/src/platform/android/app/build.gradle +++ b/src/platform/android/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 26 - buildToolsVersion '26.0.2' + compileSdkVersion 30 + buildToolsVersion '30.0.0' defaultConfig { applicationId "com.xproger.openlara" minSdkVersion 19 - targetSdkVersion 18 + targetSdkVersion 30 versionCode 1 versionName "0.1" ndk { diff --git a/src/platform/android/app/src/main/AndroidManifest.xml b/src/platform/android/app/src/main/AndroidManifest.xml index e4f9c35e..1c8d0b50 100644 --- a/src/platform/android/app/src/main/AndroidManifest.xml +++ b/src/platform/android/app/src/main/AndroidManifest.xml @@ -3,20 +3,21 @@ android:versionCode="1" android:versionName="0.1" > - + + - + android:label="@string/app_name" + android:banner="@drawable/banner" + android:isGame="true"> + diff --git a/src/platform/android/app/src/main/cpp/main.cpp b/src/platform/android/app/src/main/cpp/main.cpp index d3f2ee26..4f7248ad 100644 --- a/src/platform/android/app/src/main/cpp/main.cpp +++ b/src/platform/android/app/src/main/cpp/main.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "game.h" @@ -17,12 +19,94 @@ JavaVM *jvm; // timing time_t startTime; -int osGetTime() { +int osGetTimeMS() { timeval t; gettimeofday(&t, NULL); return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); } +// sound +#define SND_FRAMES 1176 + +Sound::Frame sndBuf[2][SND_FRAMES]; +int sndBufIndex; + +SLObjectItf sndEngine; +SLObjectItf sndOutput; +SLObjectItf sndPlayer; +SLBufferQueueItf sndQueue = NULL; +SLPlayItf sndPlay = NULL; + +void sndFill(SLBufferQueueItf bq, void *context) { + if (!sndQueue) return; + Sound::fill(sndBuf[sndBufIndex ^= 1], SND_FRAMES); + (*sndQueue)->Enqueue(sndQueue, sndBuf[sndBufIndex], SND_FRAMES * sizeof(Sound::Frame)); +} + +void sndSetState(bool active) { + if (!sndPlay) return; + (*sndPlay)->SetPlayState(sndPlay, active ? SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_PAUSED); +} + +void sndInit() { + slCreateEngine(&sndEngine, 0, NULL, 0, NULL, NULL); + (*sndEngine)->Realize(sndEngine, SL_BOOLEAN_FALSE); + + SLEngineItf engine; + + (*sndEngine)->GetInterface(sndEngine, SL_IID_ENGINE, &engine); + (*engine)->CreateOutputMix(engine, &sndOutput, 0, NULL, NULL); + (*sndOutput)->Realize(sndOutput, SL_BOOLEAN_FALSE); + + SLDataFormat_PCM bufFormat; + bufFormat.formatType = SL_DATAFORMAT_PCM; + bufFormat.numChannels = 2; + bufFormat.samplesPerSec = SL_SAMPLINGRATE_44_1; + bufFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; + bufFormat.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; + bufFormat.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT ; + bufFormat.endianness = SL_BYTEORDER_LITTLEENDIAN; + + SLDataLocator_AndroidSimpleBufferQueue bufLocator; + bufLocator.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; + bufLocator.numBuffers = 2; + + SLDataLocator_OutputMix snkLocator; + snkLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX; + snkLocator.outputMix = sndOutput; + + SLDataSource audioSrc; + audioSrc.pLocator = &bufLocator; + audioSrc.pFormat = &bufFormat; + + SLDataSink audioSnk; + audioSnk.pLocator = &snkLocator; + audioSnk.pFormat = NULL; + + SLInterfaceID audioInt[] = { SL_IID_BUFFERQUEUE, SL_IID_PLAY }; + SLboolean audioReq[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; + + (*engine)->CreateAudioPlayer(engine, &sndPlayer, &audioSrc, &audioSnk, 2, audioInt, audioReq); + (*sndPlayer)->Realize(sndPlayer, SL_BOOLEAN_FALSE); + (*sndPlayer)->GetInterface(sndPlayer, SL_IID_BUFFERQUEUE, &sndQueue); + (*sndPlayer)->GetInterface(sndPlayer, SL_IID_PLAY, &sndPlay); + (*sndQueue)->RegisterCallback(sndQueue, sndFill, NULL); + + sndBufIndex = 1; + sndFill(sndQueue, NULL); + sndFill(sndQueue, NULL); +} + +void sndFree() { + if (sndPlayer) (*sndPlayer)->Destroy(sndPlayer); + if (sndOutput) (*sndOutput)->Destroy(sndOutput); + if (sndEngine) (*sndEngine)->Destroy(sndEngine); + sndPlayer = sndOutput = sndEngine = NULL; + sndQueue = NULL; + sndPlay = NULL; +} + + // joystick bool osJoyReady(int index) { return index == 0; @@ -44,7 +128,7 @@ void osToggleVR(bool enable) { extern "C" { -JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstring jcacheDir) { +JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstring jcacheDir, jint langId) { env->GetJavaVM(&jvm); timeval t; @@ -54,6 +138,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr const char* str; cacheDir[0] = saveDir[0] = contentDir[0] = 0; + Core::defLang = langId; str = env->GetStringUTFChars(jcontentDir, NULL); strcat(contentDir, str); @@ -63,7 +148,9 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr strcat(cacheDir, str); env->ReleaseStringUTFChars(jcacheDir, str); - strcpy(saveDir, cacheDir); + strcpy(saveDir, contentDir); + + sndInit(); glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&GAPI::defaultFBO); Game::init(); @@ -71,6 +158,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr JNI_METHOD(void, nativeFree)(JNIEnv* env) { Game::deinit(); + sndFree(); } JNI_METHOD(void, nativeReset)(JNIEnv* env) { @@ -101,7 +189,7 @@ JNI_METHOD(void, nativeFrameRender)(JNIEnv* env) { } JNI_METHOD(void, nativeResize)(JNIEnv* env, jobject obj, jint x, jint y, jint w, jint h) { - Core::viewportDef = Viewport(x, y, w, h); + Core::viewportDef = short4(x, y, w, h); Core::x = x; Core::y = y; Core::width = w; @@ -182,11 +270,8 @@ JNI_METHOD(void, nativeSetEye)(JNIEnv* env, jobject obj, jint eye, jfloatArray p env->ReleaseFloatArrayElements(view, mView, 0); } -JNI_METHOD(void, nativeSoundFill)(JNIEnv* env, jobject obj, jshortArray buffer) { - jshort *frames = env->GetShortArrayElements(buffer, NULL); - jsize count = env->GetArrayLength(buffer) / 2; - Sound::fill((Sound::Frame*)frames, count); - env->ReleaseShortArrayElements(buffer, frames, 0); +JNI_METHOD(void, nativeSoundState)(JNIEnv* env, jobject obj, jboolean active) { + sndSetState(active); } -} \ No newline at end of file +} diff --git a/src/platform/android/app/src/main/java/org/xproger/openlara/MainActivity.java b/src/platform/android/app/src/main/java/org/xproger/openlara/MainActivity.java index 7e9dba4b..8d0f54b1 100644 --- a/src/platform/android/app/src/main/java/org/xproger/openlara/MainActivity.java +++ b/src/platform/android/app/src/main/java/org/xproger/openlara/MainActivity.java @@ -1,10 +1,9 @@ package org.xproger.openlara; import java.util.ArrayList; +import java.util.Locale; + import javax.microedition.khronos.egl.EGLConfig; -import android.media.AudioFormat; -import android.media.AudioManager; -import android.media.AudioTrack; import android.os.Bundle; import android.os.Environment; import android.view.InputDevice; @@ -14,16 +13,12 @@ import android.view.View.OnGenericMotionListener; import android.view.View.OnKeyListener; import android.view.View.OnTouchListener; -import android.view.Window; -import android.view.WindowManager; -import com.google.vr.sdk.base.AndroidCompat; import com.google.vr.sdk.base.Eye; import com.google.vr.sdk.base.GvrActivity; import com.google.vr.sdk.base.GvrView; import com.google.vr.sdk.base.HeadTransform; import com.google.vr.sdk.base.Viewport; -import android.app.Activity; public class MainActivity extends GvrActivity implements OnTouchListener, OnKeyListener, OnGenericMotionListener { static GvrView gvrView; @@ -90,8 +85,8 @@ public void run() { gvrView = view; try { - String content = Environment.getExternalStorageDirectory().getAbsolutePath(); - wrapper.onCreate(content + "/OpenLara/", getCacheDir().getAbsolutePath() + "/"); + String content = getExternalFilesDir(null).getAbsolutePath(); + wrapper.onCreate(content + "/", getCacheDir().getAbsolutePath() + "/"); } catch (Exception e) { e.printStackTrace(); finish(); @@ -218,79 +213,6 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { } } -// @TODO: use native OpenSL ES -class Sound { - private short buffer[]; - private static AudioTrack audioTrack; - - void start(final Wrapper wrapper) { - int rate = 44100; - int size = AudioTrack.getMinBufferSize(rate, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT); - size /= 2; // bytes -> words - while (size % 4704 != 0) size++; - //System.out.println(String.format("sound buffer size: %d", size)); - buffer = new short[size]; - - try { - audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_STEREO, - AudioFormat.ENCODING_PCM_16BIT, size * 2, AudioTrack.MODE_STREAM); - }catch (IllegalArgumentException e){ - System.out.println("Error: buffer size is zero"); - return; - } - - try { - audioTrack.play(); - }catch (NullPointerException e){ - System.out.println("Error: audioTrack null pointer on start()"); - return; - } - - new Thread( new Runnable() { - public void run() { - while ( audioTrack.getPlayState() != AudioTrack.PLAYSTATE_STOPPED ) { - if (audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING && wrapper.ready) { - Wrapper.nativeSoundFill(buffer); - audioTrack.write(buffer, 0, buffer.length); - audioTrack.flush(); - } else - try { - Thread.sleep(10); - } catch(Exception e) { - // - } - } - } - } ).start(); - } - - void stop() { - try { - audioTrack.flush(); - audioTrack.stop(); - audioTrack.release(); - }catch (NullPointerException e){ - System.out.println("Error: audioTrack null pointer on stop()"); - } - } - - void play() { - try { - audioTrack.play(); - }catch (NullPointerException e){ - System.out.println("Error: audioTrack null pointer on play()"); - } - } - - void pause() { - try { - audioTrack.pause(); - }catch (NullPointerException e){ - System.out.println("Error: audioTrack null pointer on pause()"); - }; - } -} - class Touch { int id, state; float x, y; @@ -303,7 +225,7 @@ class Touch { } class Wrapper implements GvrView.StereoRenderer { - public static native void nativeInit(String contentDir, String cacheDir); + public static native void nativeInit(String contentDir, String cacheDir, int langId); public static native void nativeFree(); public static native void nativeReset(); public static native void nativeResize(int x, int y, int w, int h); @@ -315,35 +237,34 @@ class Wrapper implements GvrView.StereoRenderer { public static native void nativeFrameEnd(); public static native void nativeFrameRender(); public static native void nativeTouch(int id, int state, float x, float y); - public static native void nativeSoundFill(short buffer[]); + public static native void nativeSoundState(boolean active); Boolean ready = false; Boolean toggleVR = false; private String contentDir; private String cacheDir; private ArrayList touch = new ArrayList<>(); - private Sound sound; void onCreate(String contentDir, String cacheDir) { this.contentDir = contentDir; this.cacheDir = cacheDir; - - sound = new Sound(); - sound.start(this); } void onDestroy() { - sound.stop(); nativeFree(); } void onPause() { - sound.pause(); + if (ready) { + nativeSoundState(false); + } } void onResume() { - sound.play(); - if (ready) nativeReset(); + if (ready) { + nativeSoundState(true); + nativeReset(); + } } void onTouch(int id, int state, float x, float y) { @@ -357,11 +278,46 @@ public void onSurfaceChanged(int width, int height) { nativeResize(0, 0, width, height); } + int getLanguage() { + String lang = Locale.getDefault().getLanguage(); + int id = 0; + if (lang.startsWith("fr")) { + id = 1; + } else if (lang.startsWith("de")) { + id = 2; + } else if (lang.startsWith("es")) { + id = 3; + } else if (lang.startsWith("it")) { + id = 4; + } else if (lang.startsWith("pl")) { + id = 5; + } else if (lang.startsWith("pt")) { + id = 6; + } else if (lang.startsWith("ru") || lang.startsWith("be") || lang.startsWith("uk")) { + id = 7; + } else if (lang.startsWith("ja")) { + id = 8; + } else if (lang.startsWith("gr")) { + id = 9; + } else if (lang.startsWith("fi")) { + id = 10; + } else if (lang.startsWith("cs")) { + id = 11; + } else if (lang.startsWith("zh")) { + id = 12; + } else if (lang.startsWith("hu")) { + id = 13; + } else if (lang.startsWith("sv")) { + id = 14; + } + return id; + } + @Override public void onSurfaceCreated(EGLConfig config) { if (!ready) { - nativeInit(contentDir, cacheDir); - sound.play(); + nativeInit(contentDir, cacheDir, getLanguage()); + nativeSoundState(true); ready = true; } } diff --git a/src/platform/android/app/src/main/res/drawable/banner.png b/src/platform/android/app/src/main/res/drawable/banner.png new file mode 100644 index 00000000..605013ae Binary files /dev/null and b/src/platform/android/app/src/main/res/drawable/banner.png differ diff --git a/src/platform/android/app/src/main/res/drawable/ic_launcher.png b/src/platform/android/app/src/main/res/drawable/ic_launcher.png index aee44e13..c9963fe2 100644 Binary files a/src/platform/android/app/src/main/res/drawable/ic_launcher.png and b/src/platform/android/app/src/main/res/drawable/ic_launcher.png differ diff --git a/src/platform/android/native_wip/AndroidManifest.xml b/src/platform/android/native_wip/AndroidManifest.xml new file mode 100644 index 00000000..8fab7408 --- /dev/null +++ b/src/platform/android/native_wip/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/platform/android/native_wip/android_native_app_glue.c b/src/platform/android/native_wip/android_native_app_glue.c new file mode 100644 index 00000000..e2deabab --- /dev/null +++ b/src/platform/android/native_wip/android_native_app_glue.c @@ -0,0 +1,438 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include +#include + +#include "android_native_app_glue.h" +#include + + +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__)) +#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "threaded_app", __VA_ARGS__)) + +/* For debug builds, always enable the debug traces in this library */ +#ifndef NDEBUG +# define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "threaded_app", __VA_ARGS__)) +#else +# define LOGV(...) ((void)0) +#endif + +static void free_saved_state(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->savedState != NULL) { + free(android_app->savedState); + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + pthread_mutex_unlock(&android_app->mutex); +} + +int8_t android_app_read_cmd(struct android_app* android_app) { + int8_t cmd; + if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) { + switch (cmd) { + case APP_CMD_SAVE_STATE: + free_saved_state(android_app); + break; + } + return cmd; + } else { + LOGE("No data on command pipe!"); + } + return -1; +} + +static void print_cur_config(struct android_app* android_app) { + char lang[2], country[2]; + AConfiguration_getLanguage(android_app->config, lang); + AConfiguration_getCountry(android_app->config, country); + + LOGV("Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d " + "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d " + "modetype=%d modenight=%d", + AConfiguration_getMcc(android_app->config), + AConfiguration_getMnc(android_app->config), + lang[0], lang[1], country[0], country[1], + AConfiguration_getOrientation(android_app->config), + AConfiguration_getTouchscreen(android_app->config), + AConfiguration_getDensity(android_app->config), + AConfiguration_getKeyboard(android_app->config), + AConfiguration_getNavigation(android_app->config), + AConfiguration_getKeysHidden(android_app->config), + AConfiguration_getNavHidden(android_app->config), + AConfiguration_getSdkVersion(android_app->config), + AConfiguration_getScreenSize(android_app->config), + AConfiguration_getScreenLong(android_app->config), + AConfiguration_getUiModeType(android_app->config), + AConfiguration_getUiModeNight(android_app->config)); +} + +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_INPUT_CHANGED: + LOGV("APP_CMD_INPUT_CHANGED\n"); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + android_app->inputQueue = android_app->pendingInputQueue; + if (android_app->inputQueue != NULL) { + LOGV("Attaching input queue to looper"); + AInputQueue_attachLooper(android_app->inputQueue, + android_app->looper, LOOPER_ID_INPUT, NULL, + &android_app->inputPollSource); + } + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_INIT_WINDOW: + LOGV("APP_CMD_INIT_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = android_app->pendingWindow; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_cond_broadcast(&android_app->cond); + break; + + case APP_CMD_RESUME: + case APP_CMD_START: + case APP_CMD_PAUSE: + case APP_CMD_STOP: + LOGV("activityState=%d\n", cmd); + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_CONFIG_CHANGED: + LOGV("APP_CMD_CONFIG_CHANGED\n"); + AConfiguration_fromAssetManager(android_app->config, + android_app->activity->assetManager); + print_cur_config(android_app); + break; + + case APP_CMD_DESTROY: + LOGV("APP_CMD_DESTROY\n"); + android_app->destroyRequested = 1; + break; + } +} + +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = NULL; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_SAVE_STATE: + LOGV("APP_CMD_SAVE_STATE\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_RESUME: + free_saved_state(android_app); + break; + } +} + +static void android_app_destroy(struct android_app* android_app) { + LOGV("android_app_destroy!"); + free_saved_state(android_app); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + AConfiguration_delete(android_app->config); + android_app->destroyed = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + // Can't touch android_app object after this. +} + +static void process_input(struct android_app* app, struct android_poll_source* source) { + AInputEvent* event = NULL; + while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { + LOGV("New input event: type=%d\n", AInputEvent_getType(event)); + if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { + continue; + } + int32_t handled = 0; + if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); + AInputQueue_finishEvent(app->inputQueue, event, handled); + } +} + +static void process_cmd(struct android_app* app, struct android_poll_source* source) { + int8_t cmd = android_app_read_cmd(app); + android_app_pre_exec_cmd(app, cmd); + if (app->onAppCmd != NULL) app->onAppCmd(app, cmd); + android_app_post_exec_cmd(app, cmd); +} + +static void* android_app_entry(void* param) { + struct android_app* android_app = (struct android_app*)param; + + android_app->config = AConfiguration_new(); + AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); + + print_cur_config(android_app); + + android_app->cmdPollSource.id = LOOPER_ID_MAIN; + android_app->cmdPollSource.app = android_app; + android_app->cmdPollSource.process = process_cmd; + android_app->inputPollSource.id = LOOPER_ID_INPUT; + android_app->inputPollSource.app = android_app; + android_app->inputPollSource.process = process_input; + + ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, + &android_app->cmdPollSource); + android_app->looper = looper; + + pthread_mutex_lock(&android_app->mutex); + android_app->running = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + android_main(android_app); + + android_app_destroy(android_app); + return NULL; +} + +// -------------------------------------------------------------------- +// Native activity interaction (called from main thread) +// -------------------------------------------------------------------- + +static struct android_app* android_app_create(ANativeActivity* activity, + void* savedState, size_t savedStateSize) { + struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app)); + memset(android_app, 0, sizeof(struct android_app)); + android_app->activity = activity; + + pthread_mutex_init(&android_app->mutex, NULL); + pthread_cond_init(&android_app->cond, NULL); + + if (savedState != NULL) { + android_app->savedState = malloc(savedStateSize); + android_app->savedStateSize = savedStateSize; + memcpy(android_app->savedState, savedState, savedStateSize); + } + + int msgpipe[2]; + if (pipe(msgpipe)) { + LOGE("could not create pipe: %s", strerror(errno)); + return NULL; + } + android_app->msgread = msgpipe[0]; + android_app->msgwrite = msgpipe[1]; + + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_create(&android_app->thread, &attr, android_app_entry, android_app); + + // Wait for thread to start. + pthread_mutex_lock(&android_app->mutex); + while (!android_app->running) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + return android_app; +} + +static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { + if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { + LOGE("Failure writing android_app cmd: %s\n", strerror(errno)); + } +} + +static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) { + pthread_mutex_lock(&android_app->mutex); + android_app->pendingInputQueue = inputQueue; + android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); + while (android_app->inputQueue != android_app->pendingInputQueue) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->pendingWindow != NULL) { + android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW); + } + android_app->pendingWindow = window; + if (window != NULL) { + android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW); + } + while (android_app->window != android_app->pendingWindow) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, cmd); + while (android_app->activityState != cmd) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_free(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, APP_CMD_DESTROY); + while (!android_app->destroyed) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + close(android_app->msgread); + close(android_app->msgwrite); + pthread_cond_destroy(&android_app->cond); + pthread_mutex_destroy(&android_app->mutex); + free(android_app); +} + +static void onDestroy(ANativeActivity* activity) { + LOGV("Destroy: %p\n", activity); + android_app_free((struct android_app*)activity->instance); +} + +static void onStart(ANativeActivity* activity) { + LOGV("Start: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START); +} + +static void onResume(ANativeActivity* activity) { + LOGV("Resume: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME); +} + +static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) { + struct android_app* android_app = (struct android_app*)activity->instance; + void* savedState = NULL; + + LOGV("SaveInstanceState: %p\n", activity); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 0; + android_app_write_cmd(android_app, APP_CMD_SAVE_STATE); + while (!android_app->stateSaved) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + + if (android_app->savedState != NULL) { + savedState = android_app->savedState; + *outLen = android_app->savedStateSize; + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + + pthread_mutex_unlock(&android_app->mutex); + + return savedState; +} + +static void onPause(ANativeActivity* activity) { + LOGV("Pause: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE); +} + +static void onStop(ANativeActivity* activity) { + LOGV("Stop: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP); +} + +static void onConfigurationChanged(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("ConfigurationChanged: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); +} + +static void onLowMemory(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("LowMemory: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY); +} + +static void onWindowFocusChanged(ANativeActivity* activity, int focused) { + LOGV("WindowFocusChanged: %p -- %d\n", activity, focused); + android_app_write_cmd((struct android_app*)activity->instance, + focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS); +} + +static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowCreated: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, window); +} + +static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowDestroyed: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, NULL); +} + +static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueCreated: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, queue); +} + +static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueDestroyed: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, NULL); +} + +__attribute__ ((visibility("default"))) +void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) { + LOGV("Creating: %p\n", activity); + activity->callbacks->onDestroy = onDestroy; + activity->callbacks->onStart = onStart; + activity->callbacks->onResume = onResume; + activity->callbacks->onSaveInstanceState = onSaveInstanceState; + activity->callbacks->onPause = onPause; + activity->callbacks->onStop = onStop; + activity->callbacks->onConfigurationChanged = onConfigurationChanged; + activity->callbacks->onLowMemory = onLowMemory; + activity->callbacks->onWindowFocusChanged = onWindowFocusChanged; + activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; + activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; + activity->callbacks->onInputQueueCreated = onInputQueueCreated; + activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; + + activity->instance = android_app_create(activity, savedState, savedStateSize); +} diff --git a/src/platform/android/native_wip/android_native_app_glue.h b/src/platform/android/native_wip/android_native_app_glue.h new file mode 100644 index 00000000..1b390c2d --- /dev/null +++ b/src/platform/android/native_wip/android_native_app_glue.h @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _ANDROID_NATIVE_APP_GLUE_H +#define _ANDROID_NATIVE_APP_GLUE_H + +#include +#include +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The native activity interface provided by + * is based on a set of application-provided callbacks that will be called + * by the Activity's main thread when certain events occur. + * + * This means that each one of this callbacks _should_ _not_ block, or they + * risk having the system force-close the application. This programming + * model is direct, lightweight, but constraining. + * + * The 'threaded_native_app' static library is used to provide a different + * execution model where the application can implement its own main event + * loop in a different thread instead. Here's how it works: + * + * 1/ The application must provide a function named "android_main()" that + * will be called when the activity is created, in a new thread that is + * distinct from the activity's main thread. + * + * 2/ android_main() receives a pointer to a valid "android_app" structure + * that contains references to other important objects, e.g. the + * ANativeActivity obejct instance the application is running in. + * + * 3/ the "android_app" object holds an ALooper instance that already + * listens to two important things: + * + * - activity lifecycle events (e.g. "pause", "resume"). See APP_CMD_XXX + * declarations below. + * + * - input events coming from the AInputQueue attached to the activity. + * + * Each of these correspond to an ALooper identifier returned by + * ALooper_pollOnce with values of LOOPER_ID_MAIN and LOOPER_ID_INPUT, + * respectively. + * + * Your application can use the same ALooper to listen to additional + * file-descriptors. They can either be callback based, or with return + * identifiers starting with LOOPER_ID_USER. + * + * 4/ Whenever you receive a LOOPER_ID_MAIN or LOOPER_ID_INPUT event, + * the returned data will point to an android_poll_source structure. You + * can call the process() function on it, and fill in android_app->onAppCmd + * and android_app->onInputEvent to be called for your own processing + * of the event. + * + * Alternatively, you can call the low-level functions to read and process + * the data directly... look at the process_cmd() and process_input() + * implementations in the glue to see how to do this. + * + * See the sample named "native-activity" that comes with the NDK with a + * full usage example. Also look at the JavaDoc of NativeActivity. + */ + +struct android_app; + +/** + * Data associated with an ALooper fd that will be returned as the "outData" + * when that source has data ready. + */ +struct android_poll_source { + // The identifier of this source. May be LOOPER_ID_MAIN or + // LOOPER_ID_INPUT. + int32_t id; + + // The android_app this ident is associated with. + struct android_app* app; + + // Function to call to perform the standard processing of data from + // this source. + void (*process)(struct android_app* app, struct android_poll_source* source); +}; + +/** + * This is the interface for the standard glue code of a threaded + * application. In this model, the application's code is running + * in its own thread separate from the main thread of the process. + * It is not required that this thread be associated with the Java + * VM, although it will need to be in order to make JNI calls any + * Java objects. + */ +struct android_app { + // The application can place a pointer to its own state object + // here if it likes. + void* userData; + + // Fill this in with the function to process main app commands (APP_CMD_*) + void (*onAppCmd)(struct android_app* app, int32_t cmd); + + // Fill this in with the function to process input events. At this point + // the event has already been pre-dispatched, and it will be finished upon + // return. Return 1 if you have handled the event, 0 for any default + // dispatching. + int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event); + + // The ANativeActivity object instance that this app is running in. + ANativeActivity* activity; + + // The current configuration the app is running in. + AConfiguration* config; + + // This is the last instance's saved state, as provided at creation time. + // It is NULL if there was no state. You can use this as you need; the + // memory will remain around until you call android_app_exec_cmd() for + // APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. + // These variables should only be changed when processing a APP_CMD_SAVE_STATE, + // at which point they will be initialized to NULL and you can malloc your + // state and place the information here. In that case the memory will be + // freed for you later. + void* savedState; + size_t savedStateSize; + + // The ALooper associated with the app's thread. + ALooper* looper; + + // When non-NULL, this is the input queue from which the app will + // receive user input events. + AInputQueue* inputQueue; + + // When non-NULL, this is the window surface that the app can draw in. + ANativeWindow* window; + + // Current content rectangle of the window; this is the area where the + // window's content should be placed to be seen by the user. + ARect contentRect; + + // Current state of the app's activity. May be either APP_CMD_START, + // APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below. + int activityState; + + // This is non-zero when the application's NativeActivity is being + // destroyed and waiting for the app thread to complete. + int destroyRequested; + + // ------------------------------------------------- + // Below are "private" implementation of the glue code. + + pthread_mutex_t mutex; + pthread_cond_t cond; + + int msgread; + int msgwrite; + + pthread_t thread; + + struct android_poll_source cmdPollSource; + struct android_poll_source inputPollSource; + + int running; + int stateSaved; + int destroyed; + int redrawNeeded; + AInputQueue* pendingInputQueue; + ANativeWindow* pendingWindow; + ARect pendingContentRect; +}; + +enum { + /** + * Looper data ID of commands coming from the app's main thread, which + * is returned as an identifier from ALooper_pollOnce(). The data for this + * identifier is a pointer to an android_poll_source structure. + * These can be retrieved and processed with android_app_read_cmd() + * and android_app_exec_cmd(). + */ + LOOPER_ID_MAIN = 1, + + /** + * Looper data ID of events coming from the AInputQueue of the + * application's window, which is returned as an identifier from + * ALooper_pollOnce(). The data for this identifier is a pointer to an + * android_poll_source structure. These can be read via the inputQueue + * object of android_app. + */ + LOOPER_ID_INPUT = 2, + + /** + * Start of user-defined ALooper identifiers. + */ + LOOPER_ID_USER = 3, +}; + +enum { + /** + * Command from main thread: the AInputQueue has changed. Upon processing + * this command, android_app->inputQueue will be updated to the new queue + * (or NULL). + */ + APP_CMD_INPUT_CHANGED, + + /** + * Command from main thread: a new ANativeWindow is ready for use. Upon + * receiving this command, android_app->window will contain the new window + * surface. + */ + APP_CMD_INIT_WINDOW, + + /** + * Command from main thread: the existing ANativeWindow needs to be + * terminated. Upon receiving this command, android_app->window still + * contains the existing window; after calling android_app_exec_cmd + * it will be set to NULL. + */ + APP_CMD_TERM_WINDOW, + + /** + * Command from main thread: the current ANativeWindow has been resized. + * Please redraw with its new size. + */ + APP_CMD_WINDOW_RESIZED, + + /** + * Command from main thread: the system needs that the current ANativeWindow + * be redrawn. You should redraw the window before handing this to + * android_app_exec_cmd() in order to avoid transient drawing glitches. + */ + APP_CMD_WINDOW_REDRAW_NEEDED, + + /** + * Command from main thread: the content area of the window has changed, + * such as from the soft input window being shown or hidden. You can + * find the new content rect in android_app::contentRect. + */ + APP_CMD_CONTENT_RECT_CHANGED, + + /** + * Command from main thread: the app's activity window has gained + * input focus. + */ + APP_CMD_GAINED_FOCUS, + + /** + * Command from main thread: the app's activity window has lost + * input focus. + */ + APP_CMD_LOST_FOCUS, + + /** + * Command from main thread: the current device configuration has changed. + */ + APP_CMD_CONFIG_CHANGED, + + /** + * Command from main thread: the system is running low on memory. + * Try to reduce your memory use. + */ + APP_CMD_LOW_MEMORY, + + /** + * Command from main thread: the app's activity has been started. + */ + APP_CMD_START, + + /** + * Command from main thread: the app's activity has been resumed. + */ + APP_CMD_RESUME, + + /** + * Command from main thread: the app should generate a new saved state + * for itself, to restore from later if needed. If you have saved state, + * allocate it with malloc and place it in android_app.savedState with + * the size in android_app.savedStateSize. The will be freed for you + * later. + */ + APP_CMD_SAVE_STATE, + + /** + * Command from main thread: the app's activity has been paused. + */ + APP_CMD_PAUSE, + + /** + * Command from main thread: the app's activity has been stopped. + */ + APP_CMD_STOP, + + /** + * Command from main thread: the app's activity is being destroyed, + * and waiting for the app thread to clean up and exit before proceeding. + */ + APP_CMD_DESTROY, +}; + +/** + * Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next + * app command message. + */ +int8_t android_app_read_cmd(struct android_app* android_app); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * initial pre-processing of the given command. You can perform your own + * actions for the command after calling this function. + */ +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * final post-processing of the given command. You must have done your own + * actions for the command before calling this function. + */ +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * This is the function that application code must implement, representing + * the main entry to the app. + */ +extern void android_main(struct android_app* app); + +#ifdef __cplusplus +} +#endif + +#endif /* _ANDROID_NATIVE_APP_GLUE_H */ diff --git a/src/platform/android/native_wip/main.cpp b/src/platform/android/native_wip/main.cpp new file mode 100644 index 00000000..93234ca6 --- /dev/null +++ b/src/platform/android/native_wip/main.cpp @@ -0,0 +1,416 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "android_native_app_glue.h" + +#include "game.h" + +JNIEnv *env; + +// timing +time_t startTime; + +int osGetTimeMS() { + timeval t; + gettimeofday(&t, NULL); + return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); +} + +// sound +// 1176 - 26 ms latency +#define SND_FRAMES 1176 + +Sound::Frame sndBuf[2][SND_FRAMES]; +int sndBufIndex; + +SLObjectItf sndEngine; +SLObjectItf sndOutput; +SLObjectItf sndPlayer; +SLBufferQueueItf sndQueue = NULL; +SLPlayItf sndPlay = NULL; + +void sndFill(SLBufferQueueItf bq, void *context) { + if (!sndQueue) return; + Sound::fill(sndBuf[sndBufIndex ^= 1], SND_FRAMES); + (*sndQueue)->Enqueue(sndQueue, sndBuf[sndBufIndex], SND_FRAMES * sizeof(Sound::Frame)); +} + +void sndSetState(bool active) { + if (!sndPlay) return; + (*sndPlay)->SetPlayState(sndPlay, active ? SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_PAUSED); +} + +void sndInit() { + slCreateEngine(&sndEngine, 0, NULL, 0, NULL, NULL); + (*sndEngine)->Realize(sndEngine, SL_BOOLEAN_FALSE); + + SLEngineItf engine; + + (*sndEngine)->GetInterface(sndEngine, SL_IID_ENGINE, &engine); + (*engine)->CreateOutputMix(engine, &sndOutput, 0, NULL, NULL); + (*sndOutput)->Realize(sndOutput, SL_BOOLEAN_FALSE); + + SLDataFormat_PCM bufFormat; + bufFormat.formatType = SL_DATAFORMAT_PCM; + bufFormat.numChannels = 2; + bufFormat.samplesPerSec = SL_SAMPLINGRATE_44_1; + bufFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; + bufFormat.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; + bufFormat.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT ; + bufFormat.endianness = SL_BYTEORDER_LITTLEENDIAN; + + SLDataLocator_AndroidSimpleBufferQueue bufLocator; + bufLocator.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; + bufLocator.numBuffers = 2; + + SLDataLocator_OutputMix snkLocator; + snkLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX; + snkLocator.outputMix = sndOutput; + + SLDataSource audioSrc; + audioSrc.pLocator = &bufLocator; + audioSrc.pFormat = &bufFormat; + + SLDataSink audioSnk; + audioSnk.pLocator = &snkLocator; + audioSnk.pFormat = NULL; + + SLInterfaceID audioInt[] = { SL_IID_BUFFERQUEUE, SL_IID_PLAY }; + SLboolean audioReq[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; + + (*engine)->CreateAudioPlayer(engine, &sndPlayer, &audioSrc, &audioSnk, 2, audioInt, audioReq); + (*sndPlayer)->Realize(sndPlayer, SL_BOOLEAN_FALSE); + (*sndPlayer)->GetInterface(sndPlayer, SL_IID_BUFFERQUEUE, &sndQueue); + (*sndPlayer)->GetInterface(sndPlayer, SL_IID_PLAY, &sndPlay); + (*sndQueue)->RegisterCallback(sndQueue, sndFill, NULL); + + sndBufIndex = 1; + sndFill(sndQueue, NULL); + sndFill(sndQueue, NULL); +} + +void sndFree() { + if (sndPlayer) (*sndPlayer)->Destroy(sndPlayer); + if (sndOutput) (*sndOutput)->Destroy(sndOutput); + if (sndEngine) (*sndEngine)->Destroy(sndEngine); + sndPlayer = sndOutput = sndEngine = NULL; + sndQueue = NULL; + sndPlay = NULL; +} + +// joystick +int joyIndex[INPUT_JOY_COUNT]; +int joyCount = 0; + +static const int joyCodes[] = { + 0, AKEYCODE_BUTTON_A, AKEYCODE_BUTTON_B, AKEYCODE_BUTTON_X, AKEYCODE_BUTTON_Y, AKEYCODE_BUTTON_L1, AKEYCODE_BUTTON_R1, + AKEYCODE_BUTTON_SELECT, AKEYCODE_BUTTON_START, AKEYCODE_BUTTON_THUMBL, AKEYCODE_BUTTON_THUMBR, AKEYCODE_BUTTON_L2, AKEYCODE_BUTTON_R2, + AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_DOWN }; + +static const int keyCodes[] { + 0, 21, 22, 19, 20, 62, 61, 66, 111, 59, 113, 57, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 }; + +int getItemIndex(int value, const int *items, int count) { + for (int i = 0; i < count; i++) + if (items[i] == value) + return i; + return -1; +} + +int getJoyIndex(int id) { + int index = getItemIndex(id, joyIndex, joyCount); + if (index == -1 && joyCount < COUNT(joyIndex)) { + joyIndex[joyCount++] = id; + return joyCount - 1; + } + return index; +} + +float joyDeadZone(float x) { + return x = fabsf(x) < 0.2f ? 0.0f : x; +} + +int32_t onInputEvent(android_app *app, AInputEvent *event) { + int source = AInputEvent_getSource(event); + bool isGamepad = (source & (AINPUT_SOURCE_GAMEPAD | AINPUT_SOURCE_JOYSTICK | AINPUT_SOURCE_DPAD)) != 0; + + switch (AInputEvent_getType(event)) { + case AINPUT_EVENT_TYPE_KEY : { + bool isDown = AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN; + int keyCode = AKeyEvent_getKeyCode(event); + int keyIndex; + + if (keyCode == AKEYCODE_BACK) + keyCode = AKEYCODE_ESCAPE; + + if (isGamepad && (keyIndex = getItemIndex(keyCode, joyCodes, COUNT(joyCodes))) != -1) { + int index = getJoyIndex(AInputEvent_getDeviceId(event)); + if (index == -1) + return 0; + Input::setJoyDown(index, JoyKey(keyIndex), isDown); + return 1; + } else if ((keyIndex = getItemIndex(keyCode, keyCodes, COUNT(keyCodes))) != -1) { + Input::setDown(InputKey(keyIndex), isDown); + return 1; + } + break; + } + case AINPUT_EVENT_TYPE_MOTION : { + int action = AMotionEvent_getAction(event); + int flags = action & AMOTION_EVENT_ACTION_MASK; + + if (isGamepad) { + int index = getJoyIndex(AInputEvent_getDeviceId(event)); + if (index == -1) + return 0; + + Input::setJoyPos(index, jkL, vec2(joyDeadZone(AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_X, 0)), + joyDeadZone(AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_Y, 0)))); + Input::setJoyPos(index, jkR, vec2(joyDeadZone(AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_Z, 0)), + joyDeadZone(AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_RZ, 0)))); + + if (!(source & AINPUT_SOURCE_DPAD)) { + float dx = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HAT_X, 0); + float dy = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HAT_Y, 0); + + Input::setJoyDown(index, jkLeft, dx < -0.9); + Input::setJoyDown(index, jkRight, dx > 0.9); + Input::setJoyDown(index, jkUp, dy < -0.9); + Input::setJoyDown(index, jkDown, dy > 0.9); + } + + return 1; + } + + switch (flags) { + case AMOTION_EVENT_ACTION_DOWN : + case AMOTION_EVENT_ACTION_UP : + case AMOTION_EVENT_ACTION_MOVE : + for (int i = 0; i < AMotionEvent_getPointerCount(event); i++) { + InputKey key = Input::getTouch(AMotionEvent_getPointerId(event, i)); + if (key == ikNone) continue; + Input::setPos(key, vec2(AMotionEvent_getX(event, i), AMotionEvent_getY(event, i))); + if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_UP) + Input::setDown(key, flags == AMOTION_EVENT_ACTION_DOWN); + } + return 1; + + case AMOTION_EVENT_ACTION_POINTER_DOWN : + case AMOTION_EVENT_ACTION_POINTER_UP : + int i = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; + InputKey key = Input::getTouch(AMotionEvent_getPointerId(event, i)); + if (key == ikNone) break; + Input::setPos(key, vec2(AMotionEvent_getX(event, i), AMotionEvent_getY(event, i))); + Input::setDown(key, flags == AMOTION_EVENT_ACTION_POINTER_DOWN); + return 1; + } + + break; + } + } + + return 0; +} + +bool osJoyReady(int index) { + return index < joyCount; +} + +void osJoyVibrate(int index, float L, float R) { + // +} + +// display +android_app *app; + +EGLDisplay display = EGL_NO_DISPLAY; +EGLSurface surface = EGL_NO_SURFACE; +EGLContext context = EGL_NO_CONTEXT; +EGLint format; +EGLConfig config; + +bool isActive = false; + +void osToggleVR(bool enable) { + Core::settings.detail.stereo = Core::Settings::STEREO_OFF; +} + +void eglInitSurface() { + ANativeWindow_setBuffersGeometry(app->window, 0, 0, format); + surface = eglCreateWindowSurface(display, config, app->window, NULL); + + eglMakeCurrent(display, surface, surface, context); + eglQuerySurface(display, surface, EGL_WIDTH, &Core::width); + eglQuerySurface(display, surface, EGL_HEIGHT, &Core::height); +} + +void eglFreeSurface() { + if (display == EGL_NO_DISPLAY || surface == EGL_NO_SURFACE) return; + + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(display, surface); + + surface = EGL_NO_SURFACE; +} + +void eglInit() { + static const EGLint eglAttr[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 24, + EGL_SAMPLES, 0, + EGL_NONE + }; + + static const EGLint ctxAttr[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + EGLint numConfigs; + + display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + eglInitialize(display, 0, 0); + eglChooseConfig(display, eglAttr, &config, 1, &numConfigs); + eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); + + context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctxAttr); + + eglInitSurface(); +} + +void eglFree() { + if (display == EGL_NO_DISPLAY) return; + + eglFreeSurface(); + + if (context != EGL_NO_CONTEXT) + eglDestroyContext(display, context); + + eglTerminate(display); + display = EGL_NO_DISPLAY; + context = EGL_NO_CONTEXT; +} + +void onAppCmd(android_app *app, int32_t cmd) { + LOG("android_app_cmd %d\n", cmd); + + + switch (cmd) { + case APP_CMD_SAVE_STATE: + //app->savedStateSize = ...; + //app->savedState = malloc(app->savedStateSize); + //TODO: fill save state + break; + + case APP_CMD_INIT_WINDOW: + if (app->window == NULL) return; + + LOG("---- init context\n"); + + if (context == EGL_NO_CONTEXT) { + LOG("---- init gl\n"); + eglInit(); + LOG("---- init game\n"); + Game::init(); + LOG("---- init gound\n"); + sndInit(); + } else + eglInitSurface(); + + LOG("---- init done!\n"); + + break; + + case APP_CMD_TERM_WINDOW: + if (app->window == NULL) return; + eglFreeSurface(); + break; + + case APP_CMD_GAINED_FOCUS : + case APP_CMD_LOST_FOCUS : + isActive = cmd == APP_CMD_GAINED_FOCUS; + sndSetState(isActive); + Core::resetTime(); + break; + } +} + +void android_main(android_app *state) { + LOG("android_main\n"); + + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + + state->activity->vm->AttachCurrentThread(&env, 0); + + state->onAppCmd = onAppCmd; + state->onInputEvent = onInputEvent; + app = state; + + + if (state->savedState != NULL) { + // TODO: load level from save state + } + + timeval t; + gettimeofday(&t, NULL); + startTime = t.tv_sec; + + LOG("get content dir: "); + + strcpy(contentDir, getenv("EXTERNAL_STORAGE")); + strcat(contentDir, "/OpenLara/"); // skip /Android/data/com.OpenLara/files + strcpy(cacheDir, contentDir); + strcat(cacheDir, "cache/"); + strcpy(saveDir, contentDir); + + LOG("%s\n", contentDir); + + Core::isQuit = false; + + while (!state->destroyRequested) { + android_poll_source *source; + + while (ALooper_pollAll(isActive ? 0 : -1, NULL, NULL, (void**)&source) >= 0) { + if (source != NULL) + source->process(state, source); + + if (state->destroyRequested != 0) + break; + } + + if (display != EGL_NO_DISPLAY && isActive && Game::update()) { + Game::render(); + eglSwapBuffers(display, surface); + } + + if (Core::isQuit) + ANativeActivity_finish(state->activity); + } + + Game::deinit(); + eglFree(); + sndFree(); + + state->activity->vm->DetachCurrentThread(); +} diff --git a/src/platform/bittboy/build.sh b/src/platform/bittboy/build.sh new file mode 100644 index 00000000..e92ab4bf --- /dev/null +++ b/src/platform/bittboy/build.sh @@ -0,0 +1 @@ +/opt/bittboy-toolchain/bin/arm-buildroot-linux-musleabi-g++ -std=c++11 -O3 -s -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -D__BITTBOY__ -DNDEBUG -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o../../../bin/OpenLara -lm -lpthread -lSDL -lasound diff --git a/src/platform/bittboy/build_miyoo.sh b/src/platform/bittboy/build_miyoo.sh new file mode 100755 index 00000000..7c664644 --- /dev/null +++ b/src/platform/bittboy/build_miyoo.sh @@ -0,0 +1 @@ +/opt/miyoo-toolchain/bin/arm-miyoo-linux-uclibcgnueabi-g++ -std=c++11 -O3 -s -fno-unroll-loops -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -D__MIYOO__ -DNDEBUG -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o../../../bin/OpenLara -lm -lpthread -lSDL -lasound diff --git a/src/platform/bittboy/main.cpp b/src/platform/bittboy/main.cpp new file mode 100644 index 00000000..fb2fe113 --- /dev/null +++ b/src/platform/bittboy/main.cpp @@ -0,0 +1,222 @@ +#include +#include +#include +#include + +#include "game.h" + +SDL_Surface *screen = NULL; + +#define SCREEN_WIDTH (SCREEN_HEIGHT/3)*4 +#define SCREEN_HEIGHT 240 +#ifdef __MIYOO__ +#define BTN_A SDLK_LALT +#define BTN_B SDLK_LCTRL +#define BTN_X SDLK_LSHIFT +#define BTN_Y SDLK_SPACE +#define BTN_L1 SDLK_BACKSPACE +#define BTN_R1 SDLK_TAB +#define BTN_L2 SDLK_RSHIFT +#define BTN_R2 SDLK_RALT +#else +#define BTN_B SDLK_SPACE +#define BTN_A SDLK_LCTRL +#define BTN_TA SDLK_LALT +#define BTN_TB SDLK_LSHIFT +#endif +#define BTN_START SDLK_RETURN +#define BTN_SELECT SDLK_ESCAPE +#define BTN_R SDLK_RCTRL +#define BTN_UP SDLK_UP +#define BTN_DOWN SDLK_DOWN +#define BTN_LEFT SDLK_LEFT +#define BTN_RIGHT SDLK_RIGHT + +// timing +unsigned int startTime; + +int osGetTimeMS() { + timeval t; + gettimeofday(&t, NULL); + return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); +} + +// sound +snd_pcm_uframes_t SND_FRAMES = 512; +snd_pcm_t *sndOut; +Sound::Frame *sndData; +pthread_t sndThread; + +void* sndFill(void *arg) { + while (sndOut) { + Sound::fill(sndData, SND_FRAMES); + + int count = SND_FRAMES; + while (count > 0) { + int frames = snd_pcm_writei(sndOut, &sndData[SND_FRAMES - count], count); + if (frames < 0) { + frames = snd_pcm_recover(sndOut, frames, 0); + if (frames == -EAGAIN) { + LOG("snd_pcm_writei try again\n"); + sleep(1); + continue; + } + if (frames < 0) { + LOG("snd_pcm_writei failed: %s\n", snd_strerror(frames)); + sndOut = NULL; + return NULL; + } + } + count -= frames; + } + + snd_pcm_prepare(sndOut); + } + return NULL; +} + +bool sndInit() { + unsigned int freq = 44100; + + int err; + + for (int i = 0; i < 20; i++) { // 20 * 0.1 = 2 secs + sndOut = NULL; + if ((err = snd_pcm_open(&sndOut, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + LOG("sound: try to snd_pcm_open #%d...\n", i); + usleep(100000); // wait for 100 ms + continue; + } + break; + } + + // I've bad news for you + if (!sndOut) { + LOG("! sound: snd_pcm_open %s\n", snd_strerror(err)); + return false; + } + + snd_pcm_hw_params_t *params; + + snd_pcm_hw_params_alloca(¶ms); + snd_pcm_hw_params_any(sndOut, params); + snd_pcm_hw_params_set_access(sndOut, params, SND_PCM_ACCESS_RW_INTERLEAVED); + + snd_pcm_hw_params_set_channels(sndOut, params, 2); + snd_pcm_hw_params_set_format(sndOut, params, SND_PCM_FORMAT_S16_LE); + snd_pcm_hw_params_set_rate_near(sndOut, params, &freq, NULL); + + snd_pcm_hw_params_set_periods(sndOut, params, 4, 0); + snd_pcm_hw_params_set_period_size_near(sndOut, params, &SND_FRAMES, NULL); + snd_pcm_hw_params_get_period_size(params, &SND_FRAMES, 0); + + snd_pcm_hw_params(sndOut, params); + snd_pcm_prepare(sndOut); + + sndData = new Sound::Frame[SND_FRAMES]; + memset(sndData, 0, SND_FRAMES * sizeof(Sound::Frame)); + if ((err = snd_pcm_writei(sndOut, sndData, SND_FRAMES)) < 0) { + LOG("! sound: write %s\n", snd_strerror(err)); + sndOut = NULL; + } + + snd_pcm_start(sndOut); + pthread_create(&sndThread, NULL, sndFill, NULL); + + return true; +} + +void sndFree() { + pthread_cancel(sndThread); + snd_pcm_drop(sndOut); + snd_pcm_drain(sndOut); + snd_pcm_close(sndOut); + delete[] sndData; +} + +// input +bool osJoyReady(int index) { + return index == 0; +} + +void osJoyVibrate(int index, float L, float R) { + // +} + +JoyKey getJoyKey(int key) { + switch (key) { +#ifdef __MIYOO__ + case BTN_A : return jkA; + case BTN_B : return jkB; + case BTN_X : return jkX; + case BTN_Y : return jkY; + case BTN_L1 : return jkLB; + case BTN_R1 : return jkRB; + case BTN_L2 : return jkLT; + case BTN_R2 : return jkRT; +#else + case BTN_B : return jkX; + case BTN_A : return jkA; + case BTN_TA : return jkRB; + case BTN_TB : return jkY; +#endif + case BTN_START : return jkStart; + case BTN_SELECT : return jkSelect; + case BTN_UP : return jkUp; + case BTN_DOWN : return jkDown; + case BTN_LEFT : return jkLeft; + case BTN_RIGHT : return jkRight; + default : return jkNone; + } +} + +int main() { + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); + SDL_ShowCursor(0); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_SWSURFACE | SDL_NOFRAME); + + timeval t; + gettimeofday(&t, NULL); + startTime = t.tv_sec; + + Core::width = SCREEN_WIDTH; + Core::height = SCREEN_HEIGHT; + + Core::defLang = 0; + + Game::init((const char *)NULL); + + GAPI::resize(); + GAPI::swColor = (uint16*)screen->pixels; + + sndInit(); + + bool isQuit = false; + + while (!isQuit) { + + SDL_Event event; + if (SDL_PollEvent(&event)) { + + if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { + Input::setJoyDown(0, getJoyKey(event.key.keysym.sym), event.type == SDL_KEYDOWN); + } + + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == BTN_R) { + isQuit = true; + } + } else { + if (Game::update()) { + Game::render(); + SDL_Flip(screen); + } + } + + } + + Game::deinit(); + + sndFree(); + + return 0; +} diff --git a/src/platform/clover/build.sh b/src/platform/clover/build.sh index 07e5864c..a0296711 100755 --- a/src/platform/clover/build.sh +++ b/src/platform/clover/build.sh @@ -1,3 +1,3 @@ set -e -clang++ -std=c++11 -Os -s -g -marm -march=armv7ve -mtune=cortex-a7 -mfloat-abi=hard -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__CLOVER__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I/opt/vc/include -I../../ -L/opt/vc/lib/ -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev -o../../../bin/OpenLara +clang++ -std=c++11 -Os -s -g -marm -march=armv7ve -mtune=cortex-a7 -mfloat-abi=hard -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -Wno-invalid-source-encoding -DNDEBUG -D__CLOVER__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I/opt/vc/include -I../../ -L/opt/vc/lib/ -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev -o../../../bin/OpenLara strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note diff --git a/src/platform/clover/main.cpp b/src/platform/clover/main.cpp index cc1fa710..0810d817 100644 --- a/src/platform/clover/main.cpp +++ b/src/platform/clover/main.cpp @@ -20,7 +20,7 @@ // timing unsigned int startTime; -int osGetTime() { +int osGetTimeMS() { timeval t; gettimeofday(&t, NULL); return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); diff --git a/src/platform/dos/DOS4GW.exe b/src/platform/dos/DOS4GW.exe new file mode 100644 index 00000000..79f04ac2 Binary files /dev/null and b/src/platform/dos/DOS4GW.exe differ diff --git a/src/platform/dos/deploy.bat b/src/platform/dos/deploy.bat new file mode 100644 index 00000000..c7f3f32a --- /dev/null +++ b/src/platform/dos/deploy.bat @@ -0,0 +1,4 @@ +rm *.obj *.err +copy ..\gba\render.iwram.cpp render.cpp /Y +wcl386.exe *.cpp ..\..\fixed\*.cpp -fe=OpenLara.exe -i="C:\WATCOM/h" -i="..\..\fixed" -wcd726 -w4 -e25 -zq -ox -d2 -6r -bt=dos -fo=.obj -zmf -xd -l=pmodew +C:\Dosbox\dosbox -conf dosbox.conf OpenLara.exe \ No newline at end of file diff --git a/src/platform/dos/dosbox.conf b/src/platform/dos/dosbox.conf new file mode 100644 index 00000000..2f6596d0 --- /dev/null +++ b/src/platform/dos/dosbox.conf @@ -0,0 +1,10 @@ +[autoexec] +@echo off +mount c: C:\Projects\OpenLara\src\platform\dos +c: + +[cpu] +cycles=fixed 26800 + +[serial] +serial1=directserial realport:COM3 \ No newline at end of file diff --git a/src/platform/dos/main.cpp b/src/platform/dos/main.cpp new file mode 100644 index 00000000..094967f2 --- /dev/null +++ b/src/platform/dos/main.cpp @@ -0,0 +1,270 @@ +#include "game.h" + +EWRAM_DATA int32 fps; +EWRAM_DATA int32 frameIndex = 0; +EWRAM_DATA int32 fpsCounter = 0; +EWRAM_DATA uint32 curSoundBuffer = 0; + +const void* TRACKS_IMA; +const void* TITLE_SCR; +const void* levelData; + +#define KB_ESC 1 +#define KB_A 30 +#define KB_S 31 +#define KB_Z 44 +#define KB_X 45 +#define KB_UP 72 +#define KB_LEFT 75 +#define KB_RIGHT 77 +#define KB_DOWN 80 +#define KB_ENTER 20 +#define KB_TAB 15 + +#define DOS_ISR __interrupt __far + +#define PIT_TIMER 0x08 +#define PIT_KEYBOARD 0x09 + + +void (DOS_ISR *old_timerISR)(); +void (DOS_ISR *old_keyISR)(); + +bool keyState[128]; + +void setVideoMode(); +#pragma aux setVideoMode = \ + "mov ax,13h" \ + "int 10h"; + +void setTextMode(); +#pragma aux setTextMode = \ + "mov ax,03h" \ + "int 10h"; + +void osSetPalette(const uint16* palette) +{ + outp(0x03C8, 0); + for (int32 i = 0; i < 256; i++) + { + uint16 c = *palette++; + outp(0x03C9, (c & 0x1F) << 1); + outp(0x03C9, ((c >> 5) & 0x1F) << 1); + outp(0x03C9, ((c >> 10) & 0x1F) << 1); + } +} + +void DOS_ISR timerISR() +{ + frameIndex++; + + outp(0x20, 0x20); +} + +void videoAcquire() +{ + setVideoMode(); + + old_timerISR = _dos_getvect(PIT_TIMER); + _dos_setvect(PIT_TIMER, timerISR); + + uint32 divisor = 1193182 / 60; + outp(0x43, 0x36); + outp(0x40, divisor & 0xFF); + outp(0x40, divisor >> 8); +} + +void videoRelease() +{ + _dos_setvect(PIT_TIMER, old_timerISR); + setTextMode(); +} + +void waitVBlank() +{ + while ((inp(0x03DA) & 0x08)); + while (!(inp(0x03DA) & 0x08)); +} + +void blit() +{ + memcpy((uint8*)0xA0000, fb, VRAM_WIDTH * FRAME_HEIGHT * 2); +} + +void DOS_ISR keyISR() +{ + uint32 scancode = inp(0x60); + + if (scancode != 0xE0) { + keyState[scancode & 0x7F] = ((scancode & 0x80) == 0); + } + + outp(0x20, 0x20); +} + +void inputAcquire() +{ + old_keyISR = _dos_getvect(PIT_KEYBOARD); + _dos_setvect(PIT_KEYBOARD, keyISR); +} + +void inputRelease() +{ + _dos_setvect(PIT_KEYBOARD, old_keyISR); +} + +void inputUpdate() +{ + keys = 0; + if (keyState[KB_UP]) keys |= IK_UP; + if (keyState[KB_RIGHT]) keys |= IK_RIGHT; + if (keyState[KB_DOWN]) keys |= IK_DOWN; + if (keyState[KB_LEFT]) keys |= IK_LEFT; + if (keyState[KB_X]) keys |= IK_A; + if (keyState[KB_Z]) keys |= IK_B; + if (keyState[KB_A]) keys |= IK_L; + if (keyState[KB_S]) keys |= IK_R; + if (keyState[KB_ENTER]) keys |= IK_START; + if (keyState[KB_TAB]) keys |= IK_SELECT; +} + +int32 osGetSystemTimeMS() +{ + return 0; +} + +bool osSaveSettings() +{ + return false; +} + +bool osLoadSettings() +{ + return false; +} + +bool osCheckSave() +{ + return false; +} + +bool osSaveGame() +{ + return false; +} + +bool osLoadGame() +{ + return false; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) {} + +const void* osLoadScreen(LevelID id) +{ + return TITLE_SCR; +} + +const void* osLoadLevel(LevelID id) +{ + // level1 + char buf[32]; + + delete[] levelData; + + sprintf(buf, "data/%s.PKD", (const char*)gLevelInfo[id].data); + + FILE *f = fopen(buf, "rb"); + + if (!f) + return NULL; + + { + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + levelData = data; + } + +// tracks + if (!TRACKS_IMA) + { + FILE *f = fopen("data/TRACKS.IMA", "rb"); + if (!f) + return NULL; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + TRACKS_IMA = data; + } + + if (!TITLE_SCR) + { + FILE *f = fopen("data/TITLE.SCR", "rb"); + if (!f) + return NULL; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + TITLE_SCR = data; + } + + return (void*)levelData; +} + +int main(void) +{ + videoAcquire(); + inputAcquire(); + + gameInit(); + + int32 lastFrameIndex = -1; + + //int extraFrame = 0; + + while (1) + { + inputUpdate(); + + if (keyState[KB_ESC]) + break; + + int32 frame = frameIndex / 2; + gameUpdate(frame - lastFrameIndex); + lastFrameIndex = frame; + + gameRender(); + + fpsCounter++; + if (frameIndex >= 60) { + frameIndex -= 60; + lastFrameIndex -= 30; + + fps = fpsCounter; + + fpsCounter = 0; + } + + blit(); + } + + inputRelease(); + videoRelease(); + + return 0; +} diff --git a/src/platform/dos/rasterizer.h b/src/platform/dos/rasterizer.h new file mode 100644 index 00000000..c0f83e07 --- /dev/null +++ b/src/platform/dos/rasterizer.h @@ -0,0 +1,694 @@ +#ifndef H_RASTERIZER_MODE13 +#define H_RASTERIZER_MODE13 + +#include "common.h" + +extern uint8 gLightmap[256 * 32]; +extern const uint8* gTile; + +#define rasterizeS rasterizeS_c +#define rasterizeF rasterizeF_c +#define rasterizeG rasterizeG_c +#define rasterizeFT rasterizeFT_c +#define rasterizeGT rasterizeGT_c +#define rasterizeFTA rasterizeFTA_c +#define rasterizeGTA rasterizeGTA_c +#define rasterizeSprite rasterizeSprite_c +#define rasterizeLineH rasterizeLineH_c +#define rasterizeLineV rasterizeLineV_c +#define rasterizeFillS rasterizeFillS_c + +void rasterizeS_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[0x1A00]; + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile uint16* ptr = pixel + (x1 >> 1); + + if (x1 & 1) + { + uint16 p = ptr[0]; + + uint16 index = ft_lightmap[p >> 8]; + + ptr[0] = (p & 0x00FF) | (index << 8); + ptr++; + width--; + } + + if (width & 1) + { + uint16 p = ptr[width >> 1]; + + uint16 index = ft_lightmap[p & 0xFF]; + + ptr[width >> 1] = (p & 0xFF00) | index; + width--; + } + + while (width) + { + uint16 p = *ptr; + + uint16 index = ft_lightmap[p & 0xFF]; + index |= ft_lightmap[p >> 8] << 8; + + *ptr++ = index; + width -= 2; + } + + #undef SHADE + } + + pixel += VRAM_WIDTH; + + Lx += Ldx; + Rx += Rdx; + } + } +} + +void rasterizeF_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + uint32 color = (uint32)R; + color = gLightmap[(L->v.g << 8) | color]; + color |= (color << 8); + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + ASSERT(L->v.y >= 0); + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + ASSERT(R->v.y >= 0); + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + *ptr++ = uint8(color); + width--; + } + + if (width & 1) + { + ptr[width - 1] = uint8(color); + } + + if (width & 2) + { + *(uint16*)ptr = color; + ptr += 2; + } + + width >>= 2; + while (width--) + { + *(uint16*)ptr = color; + ptr += 2; + *(uint16*)ptr = color; + ptr += 2; + } + } + + pixel += VRAM_WIDTH; + + Lx += Ldx; + Rx += Rdx; + } + } +} + +void rasterizeFT_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Ldx = 0, Rdx = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + uint32 tmp = FixedInvU(width); + + uint32 duv = Rt - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + uint32 dtdx = (du & 0xFFFF0000) | (dv >> 16); + + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + *ptr++ = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + ptr[width - 1] = ft_lightmap[gTile[(tmp & 0xFF00) | (tmp >> 24)]]; + } + + width >>= 1; + while (width--) + { + uint8 indexA = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + + #ifdef CPU_BIG_ENDIAN + *(uint16*)ptr = indexB | (indexA << 8); + #else + *(uint16*)ptr = indexA | (indexB << 8); + #endif + + ptr += 2; + } + } + + pixel += VRAM_WIDTH; + + Lx += Ldx; + Rx += Rdx; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ +#ifdef ALIGNED_LIGHTMAP + ASSERT((intptr_t(gLightmap) & 0xFFFF) == 0); // lightmap should be 64k aligned +#endif + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Lg, Rg, Ldx = 0, Rdx = 0, Ldg = 0, Rdg = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + // 8-bit fractional part precision for Gouraud component + // has some artifacts but allow to save one reg for inner loop + // with aligned by 64k address of lightmap array + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lg = L->v.g; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + Ldg = tmp * (N->v.g - Lg) >> 8; + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + Lg <<= 8; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rg = R->v.g; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + Rdg = tmp * (N->v.g - Rg) >> 8; + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + Rg <<= 8; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + int32 tmp = FixedInvU(width); + + int32 dgdx = tmp * (Rg - Lg) >> 15; + + uint32 duv = Rt - Lt; + uint32 u = tmp * int16(duv >> 16); + uint32 v = tmp * int16(duv); + uint32 dtdx = (u & 0xFFFF0000) | (v >> 16); + + int32 g = Lg; + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + *ptr++ = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + g += dgdx >> 1; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + ptr[width - 1] = gLightmap[(Rg >> 8 << 8) | gTile[(tmp & 0xFF00) | (tmp >> 24)]]; + } + + #ifdef ALIGNED_LIGHTMAP + g += intptr_t(gLightmap); + #endif + + width >>= 1; + + while (width--) + { + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(g >> 8 << 8); + + uint8 indexA = LMAP[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = LMAP[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + g += dgdx; + #else + uint8 indexA = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + uint8 indexB = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + g += dgdx; + #endif + + #ifdef CPU_BIG_ENDIAN + *(uint16*)ptr = indexB | (indexA << 8); + #else + *(uint16*)ptr = indexA | (indexB << 8); + #endif + + ptr += 2; + } + } + + pixel += VRAM_WIDTH; + + Lx += Ldx; + Rx += Rdx; + Lg += Ldg; + Rg += Rdg; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeFTA_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Ldx = 0, Rdx = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + uint32 tmp = FixedInvU(width); + + uint32 duv = Rt - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + uint32 dtdx = (du & 0xFFFF0000) | (dv >> 16); + + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + uint8 p = gTile[(t & 0xFF00) | (t >> 24)]; + if (p) { + *ptr = ft_lightmap[p]; + } + ptr++; + t += dtdx; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + uint8 p = gTile[(tmp & 0xFF00) | (tmp >> 24)]; + if (p) { + ptr[width - 1] = ft_lightmap[p]; + } + } + + width >>= 1; + while (width--) + { + uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + uint8 indexB = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + + + if (indexA && indexB) + { + indexA = ft_lightmap[indexA]; + indexB = ft_lightmap[indexB]; + + #ifdef CPU_BIG_ENDIAN + *(uint16*)ptr = indexB | (indexA << 8); + #else + *(uint16*)ptr = indexA | (indexB << 8); + #endif + + }/* else if (indexA) { + *(uint16*)ptr = (*(uint16*)ptr & 0xFF00) | ft_lightmap[indexA]; + } else if (indexB) { + *(uint16*)ptr = (*(uint16*)ptr & 0x00FF) | (ft_lightmap[indexB] << 8); + }*/ + + ptr += 2; + } + } + + pixel += VRAM_WIDTH; + + Lx += Ldx; + Rx += Rdx; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeGTA_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + rasterizeFTA(pixel, L, R); +} + +void rasterizeSprite_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + // TODO +} + +void rasterizeLineH_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + // TODO +} + +void rasterizeLineV_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + // TODO +} + +void rasterizeFillS_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + // TODO +} + +#endif diff --git a/src/platform/dos/sound.cpp b/src/platform/dos/sound.cpp new file mode 100644 index 00000000..2512df5c --- /dev/null +++ b/src/platform/dos/sound.cpp @@ -0,0 +1,51 @@ +#include "common.h" + +void sndInit() +{ + // TODO +} + +void sndInitSamples() +{ + // TODO +} + +void sndFreeSamples() +{ + // TODO +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + return NULL; // TODO +} + +void sndPlayTrack(int32 track) +{ + // TODO +} + +void sndStopTrack() +{ + // TODO +} + +bool sndTrackIsPlaying() +{ + return false; // TODO +} + +void sndStopSample(int32 index) +{ + // TODO +} + +void sndStop() +{ + // TODO +} + +void sndFill(uint8* buffer, int32 count) +{ + // TODO +} diff --git a/src/platform/gba/IMGS/O/P/OPLA.bmp b/src/platform/gba/IMGS/O/P/OPLA.bmp new file mode 100644 index 00000000..732c4a20 Binary files /dev/null and b/src/platform/gba/IMGS/O/P/OPLA.bmp differ diff --git a/src/platform/gba/Makefile b/src/platform/gba/Makefile new file mode 100644 index 00000000..6e3f0895 --- /dev/null +++ b/src/platform/gba/Makefile @@ -0,0 +1,163 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/gba_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +# DATA is a list of directories containing binary data +# GRAPHICS is a list of directories containing files to be processed by grit +# +# All directories are specified relative to the project directory where +# the makefile is found +# +#--------------------------------------------------------------------------------- +TARGET := OpenLara +BUILD := build +SOURCES := ../../fixed . asm +INCLUDES := include . ../../fixed +DATA := data +LIBTONC := $(DEVKITPRO)/libtonc + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -mthumb -mthumb-interwork + +CFLAGS := -g -Wall -O3 -D__GBA__\ + -mcpu=arm7tdmi -mtune=arm7tdmi\ + -fomit-frame-pointer\ + -ffast-math\ + -Wno-class-memaccess\ + $(ARCH) + +CFLAGS += $(INCLUDE) + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lmm -ltonc + + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(LIBGBA) $(LIBTONC) + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- + + +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) + +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + gbafix $(TARGET).gba -tOpenLara -cOPLA + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba + + +#--------------------------------------------------------------------------------- +else + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- + +$(OUTPUT).gba : $(OUTPUT).elf + +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SOURCES) : $(HFILES) + +#--------------------------------------------------------------------------------- +# The bin2o rule should be copied and modified +# for each extension used in the data directories +#--------------------------------------------------------------------------------- + +%.PKD.o %_PKD.h : %.PKD + @echo $(notdir $<) + @$(bin2o) + +%.AD4.o %_AD4.h : %.AD4 + @echo $(notdir $<) + @$(bin2o) + +%.SCR.o %_SCR.h : %.SCR + @echo $(notdir $<) + @$(bin2o) + +%.WAD.o %_WAD.h : %.WAD + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- diff --git a/src/platform/gba/OpenLara.sln b/src/platform/gba/OpenLara.sln new file mode 100644 index 00000000..5cfa43bd --- /dev/null +++ b/src/platform/gba/OpenLara.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{990C6F40-6226-4011-B52C-FF042EBB7F15}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Debug|x64.ActiveCfg = Debug|x64 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Debug|x64.Build.0 = Debug|x64 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Debug|x86.ActiveCfg = Debug|Win32 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Debug|x86.Build.0 = Debug|Win32 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Release|x64.ActiveCfg = Release|x64 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Release|x64.Build.0 = Release|x64 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Release|x86.ActiveCfg = Release|Win32 + {990C6F40-6226-4011-B52C-FF042EBB7F15}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8D133CA9-7AA0-4806-9B61-82E8A3044A15} + EndGlobalSection +EndGlobal diff --git a/src/platform/gba/OpenLara.vcxproj b/src/platform/gba/OpenLara.vcxproj new file mode 100644 index 00000000..af2b6ee5 --- /dev/null +++ b/src/platform/gba/OpenLara.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 + {990C6F40-6226-4011-B52C-FF042EBB7F15} + Win32Proj + OpenLara + 10.0 + + + + Application + true + v142 + NotSet + + + Application + false + v142 + true + NotSet + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + ..\..\fixed;$(IncludePath) + + + true + ..\..\fixed;$(IncludePath) + + + false + ..\..\fixed;$(IncludePath) + + + false + ..\..\fixed;$(IncludePath) + + + + + + Level2 + Disabled + true + __GBA_WIN__;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + 26495 + + + Console + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + true + __GBA_WIN__;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + 26495 + + + Console + true + + + + + + + Level2 + MaxSpeed + true + true + true + __GBA_WIN__;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + 26495 + + + Console + true + true + true + winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + MaxSpeed + true + true + true + __GBA_WIN__;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + 26495 + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/src/platform/gba/asm/boxRotateYQ.s b/src/platform/gba/asm/boxRotateYQ.s new file mode 100644 index 00000000..b284b652 --- /dev/null +++ b/src/platform/gba/asm/boxRotateYQ.s @@ -0,0 +1,57 @@ +#include "common_asm.inc" + +v .req r0 // arg +q .req r1 // arg + +min .req q +max .req r2 + +minX .req r3 +maxX .req r12 +minZ .req minX +maxZ .req maxX + +.global boxRotateYQ_asm +boxRotateYQ_asm: + cmp q, #2 + bxeq lr + + cmp q, #1 + beq .q_1 + cmp q, #3 + beq .q_3 + +.q_0: + ldmia v, {minX, maxX} + rsb min, maxX, #0 + rsb max, minX, #0 + stmia v, {min, max} + add v, #16 + ldmia v, {minZ, maxZ} + rsb min, maxZ, #0 + rsb max, minZ, #0 + stmia v, {min, max} + bx lr + +.q_1: + ldmia v, {min, max} + add v, #16 + ldmia v, {minZ, maxZ} + stmia v, {min, max} + rsb min, maxZ, #0 + rsb max, minZ, #0 + sub v, #16 + stmia v, {min, max} + bx lr + +.q_3: + add v, #16 + ldmia v, {min, max} + sub v, #16 + ldmia v, {minX, maxX} + stmia v, {min, max} + rsb min, maxX, #0 + rsb max, minX, #0 + add v, #16 + stmia v, {min, max} + bx lr diff --git a/src/platform/gba/asm/boxTranslate.s b/src/platform/gba/asm/boxTranslate.s new file mode 100644 index 00000000..4508bddd --- /dev/null +++ b/src/platform/gba/asm/boxTranslate.s @@ -0,0 +1,29 @@ +#include "common_asm.inc" + +aabb .req r0 // arg +x .req r1 // arg +y .req r2 // arg +z .req r3 // arg +// FIQ regs +minX .req r8 +maxX .req r9 +minY .req r10 +maxY .req r11 +minZ .req r12 +maxZ .req r13 + +.global boxTranslate_asm +boxTranslate_asm: + fiq_on + + ldmia aabb, {minX, maxX, minY, maxY, minZ, maxZ} + add minX, minX, x + add maxX, maxX, x + add minY, minY, y + add maxY, maxY, y + add minZ, minZ, z + add maxZ, maxZ, z + stmia aabb, {minX, maxX, minY, maxY, minZ, maxZ} + + fiq_off + bx lr diff --git a/src/platform/gba/asm/clearFB.s b/src/platform/gba/asm/clearFB.s new file mode 100644 index 00000000..ddd956b5 --- /dev/null +++ b/src/platform/gba/asm/clearFB.s @@ -0,0 +1,43 @@ +#include "common_asm.inc" + +dst .req r0 // arg +end .req r14 + +.global clearFB_asm +clearFB_asm: + stmfd sp!, {r4-r6} + fiq_on + + // 12 words + mov r1, #0 + mov r2, #0 + mov r3, #0 + mov r4, #0 + mov r5, #0 + mov r6, #0 + // FIQ regs + mov r8, #0 + mov r9, #0 + mov r10, #0 + mov r11, #0 + mov r12, #0 + mov r13, #0 + add end, dst, #(FRAME_WIDTH * FRAME_HEIGHT) + +.loop: + // fill 12 * 4 * 8 bytes per iteration + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + stmia dst!, {r1-r6, r8-r13} + + cmp dst, end + blt .loop + + fiq_off + ldmfd sp!, {r4-r6} + bx lr diff --git a/src/platform/gba/asm/common_asm.inc b/src/platform/gba/asm/common_asm.inc new file mode 100644 index 00000000..739f48f7 --- /dev/null +++ b/src/platform/gba/asm/common_asm.inc @@ -0,0 +1,160 @@ +.section .iwram +.arm + +#define FRAME_WIDTH 240 +#define FRAME_HEIGHT 160 + +.equ VERTEX_X, 0 +.equ VERTEX_Y, 2 +.equ VERTEX_Z, 4 +.equ VERTEX_G, 6 +.equ VERTEX_CLIP, 7 +.equ VERTEX_T, 8 +.equ VERTEX_PREV, 12 +.equ VERTEX_NEXT, 13 + +.equ VERTEX_SIZEOF_SHIFT, 4 +.equ VERTEX_SIZEOF, (1 << VERTEX_SIZEOF_SHIFT) + +.equ LEVEL_TILES, 40 +.equ LEVEL_TEXTURES, 92 +.equ LEVEL_SPRITES, 96 + +.equ SPRITE_SIZE, 16 + +.equ TEXTURE_TILE, 2 +.equ TEXTURE_UV01, 4 +.equ TEXTURE_UV23, 8 + +.equ EWRAM_START, 0x2000000 +.equ IWRAM_START, 0x3000000 +.equ VRAM_START, 0x6000000 +.equ VRAM_PAGE, 0x000A000 + +.equ DIVLUT_ADDR, EWRAM_START +.equ LMAP_ADDR, IWRAM_START + +.equ CLIP_LEFT, ((1 << 0) << 8) +.equ CLIP_RIGHT, ((1 << 1) << 8) +.equ CLIP_TOP, ((1 << 2) << 8) +.equ CLIP_BOTTOM, ((1 << 3) << 8) +.equ CLIP_PLANE, ((1 << 4) << 8) +.equ CLIP_FRAME, ((1 << 5) << 8) +.equ CLIP_DISCARD, (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM + CLIP_PLANE) +.equ CLIP_MASK, 0xFF00 + +.equ FACE_TYPE_SHIFT, 14 +.equ FACE_TEXTURE_BITS, 14 +.equ FACE_TEXTURE, ((1 << FACE_TYPE_SHIFT) - 1) +.equ FACE_GOURAUD, (2 << FACE_TYPE_SHIFT) +.equ FACE_CLIPPED, (1 << 18) +.equ FACE_TRIANGLE_BIT, 19 +.equ FACE_TRIANGLE, (1 << FACE_TRIANGLE_BIT) + +.equ FACE_FLAGS, 0 +.equ FACE_NEXT, 4 +.equ FACE_INDICES, 8 + +.equ FACE_TYPE_MASK, (15 << FACE_TYPE_SHIFT) + +.equ FACE_TYPE_SHADOW, (0 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_F, (1 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_FT, (2 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_FTA, (3 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_GT, (4 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_GTA, (5 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_SPRITE, (6 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_FILL_S, (7 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_LINE_H, (8 << FACE_TYPE_SHIFT) +.equ FACE_TYPE_LINE_V, (9 << FACE_TYPE_SHIFT) + +.equ FIXED_SHIFT, 14 +.equ PROJ_SHIFT, 4 +.equ MESH_SHIFT, 2 + +.equ VIEW_MIN, 64 +.equ VIEW_MAX, (10 << 10) +.equ VIEW_OFF, 4096 +.equ FOG_SHIFT, 4 +.equ FOG_MIN, (VIEW_MAX - 2048) + +.equ OT_SHIFT, 4 +.equ OT_SIZE, ((VIEW_MAX >> OT_SHIFT) + 1) + +.equ MAX_CAUSTICS, 32 +.equ MAX_RAND_TABLE, 32 +.equ MAX_ANIM_TEX, 128 + +.equ MIN_INT32, 0x80000000 +.equ MAX_INT32, 0x7FFFFFFF + +.equ SND_VOL_SHIFT, 6 +.equ SND_FIXED_SHIFT, 8 + +// res = divTable[x] (uint16) +.macro divLUT res, x + add \res, \x, #DIVLUT_ADDR + ldrh \res, [\res, \x] +.endm + +// vx0 - vg0 +// vy0 - vg1 +// vx1 - vg2 +// vy1 - vg3 +// vx2 - vg2 +// vy2 - vg2 +.macro CCW skip + ldr vy0, [vp0, #VERTEX_X] // yyxx + mov vx0, vy0, lsl #16 + ldrsh vx2, [vp2, #VERTEX_X] + ldrsh vy1, [vp1, #VERTEX_Y] + rsb vx2, vx2, vx0, asr #16 // reverse order for mla + subs vy1, vy1, vy0, asr #16 + mulne vy1, vx2, vy1 + ldrsh vx1, [vp1, #VERTEX_X] + sub vx0, vx1, vx0, asr #16 + ldrsh vy2, [vp2, #VERTEX_Y] + subs vy0, vy2, vy0, asr #16 + mulne vy0, vx0, vy0 + adds vy1, vy0 + ble \skip +.endm + +.macro scaleUV uv, tmp, unused, f + asrs \tmp, \uv, #16 + mulne \tmp, \f, \tmp // u = f * int16(uv >> 16) + lsrne \tmp, #16 + lslne \tmp, #16 + + lsls \uv, \uv, #16 + asrne \uv, #16 + mulne \uv, \f, \uv // v = f * int16(uv) + + orr \uv, \tmp, \uv, lsr #16 // uv = (u & 0xFFFF0000) | (v >> 16) +.endm + +.macro tex index, uv + and \index, \uv, #0xFF00 + orr \index, \uv, lsr #24 // index = v * 256 + u + ldrb \index, [TILE, \index] +.endm + +.macro lit index + ldrb \index, [LMAP, \index] +.endm + +.macro fiq_on + msr cpsr, #0x11 // switch r8-r14 to FIQ (IRQ enabled) +.endm + +.macro fiq_off + msr cpsr, #0x1F // restore r8-r14 +.endm + +.macro fiq_on_ne + msrne cpsr, #0x11 // switch r8-r14 to FIQ (IRQ enabled) +.endm + +.macro fiq_off_ne + msrne cpsr, #0x1F // restore r8-r14 +.endm diff --git a/src/platform/gba/asm/faceAddMeshQuads.s b/src/platform/gba/asm/faceAddMeshQuads.s new file mode 100644 index 00000000..7fd2d130 --- /dev/null +++ b/src/platform/gba/asm/faceAddMeshQuads.s @@ -0,0 +1,124 @@ +#include "common_asm.inc" + +polys .req r0 // arg +count .req r1 // arg +mask .req r2 +vg0 .req r3 +vg1 .req r4 +vg2 .req r5 +vg3 .req r6 +flags .req r7 +// FIQ regs +vp0 .req r8 +vp1 .req r9 +vp2 .req r10 +vp3 .req r11 +ot .req r12 +face .req r13 +vertices .req r14 + +vx0 .req vg0 +vy0 .req vg1 +vx1 .req vg2 +vy1 .req vg3 +vx2 .req vg2 +vy2 .req vg2 + +depth .req vg0 + +i0 .req vp0 +i1 .req vp1 +i2 .req vp2 +i3 .req vg3 // vg to save vp3 value between iterations + +vp01 .req vp1 +vp23 .req vp2 + +tmp .req flags +next .req vp0 + +.global faceAddMeshQuads_asm +faceAddMeshQuads_asm: + stmfd sp!, {r4-r7} + fiq_on + + ldr vp3, =gVerticesBase + ldr vp3, [vp3] + + ldr vertices, =gVertices + lsr vertices, #3 + + ldr face, =gFacesBase + ldr face, [face] + + ldr ot, =gOT + mov mask, #(0xFF << 24) + orr mask, #(3 << 8) // div 4 mul 4 for depth + +.loop: + // sizeof(MeshQuad) == 8 + ldr tmp, [polys], #8 // skip flags + + // unpack index deltas + and vg0, mask, tmp, lsl #24 + and vg1, mask, tmp, lsl #16 + and vg2, mask, tmp, lsl #8 + and vg3, mask, tmp + + // sizeof(Vertex) = (1 << 3) + add vp0, vp3, vg0, asr #(24 - 3) + add vp1, vp0, vg1, asr #(24 - 3) + add vp2, vp1, vg2, asr #(24 - 3) + add vp3, vp2, vg3, asr #(24 - 3) + + CCW .skip + + // fetch [c, g, zz] + ldr vg0, [vp0, #VERTEX_Z] + ldr vg1, [vp1, #VERTEX_Z] + ldr vg2, [vp2, #VERTEX_Z] + ldr vg3, [vp3, #VERTEX_Z] + + // check clipping + and tmp, vg0, vg1 + and tmp, vg2 + and tmp, vg3 + tst tmp, #(CLIP_DISCARD << 16) + bne .skip + + // mark if should be clipped by viewport + orr tmp, vg0, vg1 + orr tmp, vg2 + orr tmp, vg3 + tst tmp, #(CLIP_FRAME << 16) + ldrh flags, [polys, #-4] + orrne flags, #FACE_CLIPPED + + // depth = AVG_Z4 + add depth, vg0, vg1 // depth = vz0 + vz1 + add depth, vg2 // depth += vz2 + add depth, vg3 // depth += vz3 + bic depth, depth, mask, asr #8 // clear high half (g & clip flags) and low 2 bits + + // faceAdd + rsb i0, vertices, vp0, lsr #3 + rsb i1, vertices, vp1, lsr #3 + rsb i2, vertices, vp2, lsr #3 + rsb i3, vertices, vp3, lsr #3 + + orr vp01, i0, i1, lsl #16 + orr vp23, i2, i3, lsl #16 + + ldr next, [ot, depth] + str face, [ot, depth] + stmia face!, {flags, next, vp01, vp23} +.skip: + subs count, #1 + bne .loop + + ldr tmp, =gFacesBase + str face, [tmp] + + fiq_off + ldmfd sp!, {r4-r7} + bx lr diff --git a/src/platform/gba/asm/faceAddMeshTriangles.s b/src/platform/gba/asm/faceAddMeshTriangles.s new file mode 100644 index 00000000..b6efc632 --- /dev/null +++ b/src/platform/gba/asm/faceAddMeshTriangles.s @@ -0,0 +1,114 @@ +#include "common_asm.inc" + +polys .req r0 // arg +count .req r1 // arg +mask .req r2 +flags .req r3 +vp0 .req r4 +vp1 .req r5 +vp2 .req r6 +// FIQ regs +vg0 .req r8 +vg1 .req r9 +vg2 .req r10 +vg3 .req r11 +vertices .req r12 +ot .req r13 +face .req r14 + +vx0 .req vg0 +vy0 .req vg1 +vx1 .req vg2 +vy1 .req vg3 +vx2 .req vg2 +vy2 .req vg2 + +depth .req vg0 + +i0 .req vg1 +i1 .req vg2 +i2 .req vg3 // vg to save vp2 value between iterations + +vp01 .req vp1 + +tmp .req flags +next .req vp0 + +.global faceAddMeshTriangles_asm +faceAddMeshTriangles_asm: + stmfd sp!, {r4-r6} + fiq_on + + ldr vp2, =gVerticesBase + ldr vp2, [vp2] + + ldr vertices, =gVertices + lsr vertices, #3 + + ldr face, =gFacesBase + ldr face, [face] + + ldr ot, =gOT + mov mask, #(0xFF << 24) + orr mask, #(3 << 8) // div 4 mul 4 for depth + +.loop: + // sizeof(MeshTriangle) == 8 + ldr tmp, [polys], #8 // skip flags + + // unpack index deltas + and vg0, mask, tmp, lsl #24 + and vg1, mask, tmp, lsl #16 + + // sizeof(Vertex) = (1 << 3) + add vp0, vp2, vg0, asr #(24 - 3) + add vp1, vp0, vg1, asr #(24 - 3) + add vp2, vp1, tmp, asr #(24 - 3) // 3rd vertex in 4th byte after zero byte to save one masking op + + CCW .skip + + // fetch [c, g, zz] + ldr vg0, [vp0, #VERTEX_Z] + ldr vg1, [vp1, #VERTEX_Z] + ldr vg2, [vp2, #VERTEX_Z] + + // check clipping + and tmp, vg0, vg1 + and tmp, vg2 + tst tmp, #(CLIP_DISCARD << 16) + bne .skip + + // mark if should be clipped by viewport + orr tmp, vg0, vg1 + orr tmp, vg2 + tst tmp, #(CLIP_FRAME << 16) + ldrh flags, [polys, #-4] + orrne flags, #FACE_CLIPPED + + // depth = AVG_Z3 + add depth, vg0, vg1 // depth = vz0 + vz1 + add depth, vg2, lsl #1 // depth += vz2 * 2 + bic depth, depth, mask, asr #8 // clear high half (g & clip flags) and low 2 bits + + // faceAdd + rsb i0, vertices, vp0, lsr #3 + rsb i1, vertices, vp1, lsr #3 + rsb i2, vertices, vp2, lsr #3 + + orr vp01, i0, i1, lsl #16 + + orr flags, #FACE_TRIANGLE + + ldr next, [ot, depth] + str face, [ot, depth] + stmia face!, {flags, next, vp01, i2} +.skip: + subs count, #1 + bne .loop + + ldr tmp, =gFacesBase + str face, [tmp] + + fiq_off + ldmfd sp!, {r4-r6} + bx lr diff --git a/src/platform/gba/asm/faceAddRoomQuads.s b/src/platform/gba/asm/faceAddRoomQuads.s new file mode 100644 index 00000000..6bb1ed28 --- /dev/null +++ b/src/platform/gba/asm/faceAddRoomQuads.s @@ -0,0 +1,140 @@ +#include "common_asm.inc" + +polys .req r0 // arg +count .req r1 // arg +mask .req r2 +vg0 .req r3 +vg1 .req r4 +vg2 .req r5 +vg3 .req r6 +flags .req r7 +// FIQ regs +vp0 .req r8 +vp1 .req r9 +vp2 .req r10 +vp3 .req r11 +ot .req r12 +face .req r13 +vertices .req r14 + +vx0 .req vg0 +vy0 .req vg1 +vx1 .req vg2 +vy1 .req vg3 +vx2 .req vg2 +vy2 .req vg2 + +vz0 .req vg0 +vz1 .req vg1 +vz2 .req vg2 +vz3 .req vg3 +depth .req vg0 + +i0 .req vp0 +i1 .req vp1 +i2 .req vp2 +i3 .req vg3 // vg to save vp3 value between iterations + +vp01 .req vp1 +vp23 .req vp2 + +tmp .req flags +next .req vp0 + +.global faceAddRoomQuads_asm +faceAddRoomQuads_asm: + stmfd sp!, {r4-r7} + fiq_on + + ldr vp3, =gVerticesBase + ldr vp3, [vp3] + + ldr vertices, =gVertices + lsr vertices, #3 + + ldr face, =gFacesBase + ldr face, [face] + + ldr ot, =gOT + mov mask, #(0xFF << 24) + +.loop: + // sizeof(RoomQuad) = 8 + ldr tmp, [polys], #8 // skip flags + + // unpack index deltas + and vg0, mask, tmp, lsl #24 + and vg1, mask, tmp, lsl #16 + and vg2, mask, tmp, lsl #8 + and vg3, mask, tmp + + // sizeof(Vertex) = (1 << 3) + add vp0, vp3, vg0, asr #(24 - 3) + add vp1, vp0, vg1, asr #(24 - 3) + add vp2, vp1, vg2, asr #(24 - 3) + add vp3, vp2, vg3, asr #(24 - 3) + + // fetch ((clip << 8) | g) + ldrh vg0, [vp0, #VERTEX_G] + ldrh vg1, [vp1, #VERTEX_G] + ldrh vg2, [vp2, #VERTEX_G] + ldrh vg3, [vp3, #VERTEX_G] + + // check clipping + and tmp, vg0, vg1 + and tmp, vg2 + and tmp, vg3 + tst tmp, #CLIP_DISCARD + bne .skip + + // mark if should be clipped by viewport + orr tmp, vg0, vg1 + orr tmp, vg2 + orr tmp, vg3 + tst tmp, #CLIP_FRAME + ldrh flags, [polys, #-4] + orrne flags, #FACE_CLIPPED + + // shift and compare VERTEX_G for gouraud rasterization + lsl vg0, #24 + cmp vg0, vg1, lsl #24 + cmpeq vg0, vg2, lsl #24 + cmpeq vg0, vg3, lsl #24 + addne flags, #FACE_GOURAUD + + CCW .skip + + // depth (vz0) = MAX_Z4 + ldrh vz0, [vp0, #VERTEX_Z] + ldrh vz1, [vp1, #VERTEX_Z] + ldrh vz2, [vp2, #VERTEX_Z] + ldrh vz3, [vp3, #VERTEX_Z] + cmp vz0, vz1 + movlt vz0, vz1 + cmp vz0, vz2 + movlt vz0, vz2 + cmp vz0, vz3 + movlt vz0, vz3 + + // faceAdd + rsb i0, vertices, vp0, lsr #3 + rsb i1, vertices, vp1, lsr #3 + rsb i2, vertices, vp2, lsr #3 + rsb i3, vertices, vp3, lsr #3 + + orr vp01, i0, i1, lsl #16 + orr vp23, i2, i3, lsl #16 + + ldr next, [ot, depth, lsl #2] + str face, [ot, depth, lsl #2] + stmia face!, {flags, next, vp01, vp23} +.skip: + subs count, #1 + bne .loop + + ldr tmp, =gFacesBase + str face, [tmp] + + fiq_off + ldmfd sp!, {r4-r7} + bx lr diff --git a/src/platform/gba/asm/faceAddRoomTriangles.s b/src/platform/gba/asm/faceAddRoomTriangles.s new file mode 100644 index 00000000..cb10583a --- /dev/null +++ b/src/platform/gba/asm/faceAddRoomTriangles.s @@ -0,0 +1,121 @@ +#include "common_asm.inc" + +polys .req r0 // arg +count .req r1 // arg +vp .req r2 +vg0 .req r3 +vg1 .req r4 +vg2 .req r5 +vg3 .req r6 +// FIQ regs +flags .req r8 +vp0 .req r9 +vp1 .req r10 +vp2 .req r11 +vp3 .req vg3 +vertices .req r12 +ot .req r13 +face .req r14 + +vx0 .req vg0 +vy0 .req vg1 +vx1 .req vg2 +vy1 .req vg3 +vx2 .req vg2 +vy2 .req vg2 + +vz0 .req vg0 +vz1 .req vg1 +vz2 .req vg2 +depth .req vg0 + +tmp .req flags +next .req vp0 + +.global faceAddRoomTriangles_asm +faceAddRoomTriangles_asm: + stmfd sp!, {r4-r6} + fiq_on + + ldr vp, =gVerticesBase + ldr vp, [vp] + + ldr vertices, =gVertices + lsr vertices, #3 + + ldr face, =gFacesBase + ldr face, [face] + + ldr ot, =gOT + +.loop: + // sizeof(RoomTriangle) = 8 + ldr vp1, [polys], #4 + ldr vp3, [polys], #4 // + flags + + // prepare to unpack indices + lsl vp0, vp1, #16 + lsl vp2, vp3, #16 + + // assume that vertex index will never exceed 8191 + add vp0, vp, vp0, lsr #(16 - 3) + add vp1, vp, vp1, lsr #(16 - 3) + add vp2, vp, vp2, lsr #(16 - 3) + + // fetch ((clip << 8) | g) + ldrh vg0, [vp0, #VERTEX_G] + ldrh vg1, [vp1, #VERTEX_G] + ldrh vg2, [vp2, #VERTEX_G] + + // check clipping + and tmp, vg0, vg1 + and tmp, vg2 + tst tmp, #CLIP_DISCARD + bne .skip + + // mark if should be clipped by viewport + orr tmp, vg0, vg1 + orr tmp, vg2 + tst tmp, #CLIP_FRAME + mov flags, vp3, lsr #16 + orrne flags, #FACE_CLIPPED + + // shift and compare VERTEX_G for gouraud rasterization + lsl vg0, #24 + cmp vg0, vg1, lsl #24 + cmpeq vg0, vg2, lsl #24 + addne flags, #FACE_GOURAUD + + CCW .skip + + // depth (vz0) = MAX_Z3 + ldrh vz0, [vp0, #VERTEX_Z] + ldrh vz1, [vp1, #VERTEX_Z] + ldrh vz2, [vp2, #VERTEX_Z] + cmp vz0, vz1 + movlt vz0, vz1 + cmp vz0, vz2 + movlt vz0, vz2 + + // faceAdd + rsb vp0, vertices, vp0, lsr #3 + rsb vp1, vertices, vp1, lsr #3 + rsb vp2, vertices, vp2, lsr #3 + + orr vp1, vp0, vp1, lsl #16 + + orr flags, #FACE_TRIANGLE + + ldr next, [ot, depth, lsl #2] + str face, [ot, depth, lsl #2] + stmia face!, {flags, next, vp1, vp2} +.skip: + subs count, #1 + bne .loop + + ldr tmp, =gFacesBase + str face, [tmp] + + fiq_off + ldmfd sp!, {r4-r6} + bx lr diff --git a/src/platform/gba/asm/flush.s b/src/platform/gba/asm/flush.s new file mode 100644 index 00000000..999f71a0 --- /dev/null +++ b/src/platform/gba/asm/flush.s @@ -0,0 +1,240 @@ +#include "common_asm.inc" + +flags .req r0 // flags must be in r0 for rasterize & draw* calls +ptr .req r1 // must be in r1 +vXY .req r2 +vZG .req r3 +tmp .req r4 +list .req r5 +face .req r6 +VERTICES .req r7 +TEXTURES .req r8 +OT .req r9 +TILE .req r10 +MASK .req r11 + +index01 .req r12 +index23 .req lr + +faces .req vXY +uv01 .req index01 +uv23 .req index23 +uwvh .req index01 +verticesBase .req vZG +facesBase .req vZG +vertex .req vZG +texture .req tmp +texAnim .req vXY +texIndex .req tmp +texTile .req tmp +sprite .req tmp +sprIndex .req tmp +sprTile .req tmp +type .req tmp +zero .req tmp +uv .req tmp +vXY0 .req vXY +vZG0 .req vZG +vXY1 .req index01 +vZG1 .req index23 + +vA .req vXY +vB .req vZG + +Qs .req ptr +Qe .req TILE +Ts .req MASK +Te .req index01 +PN .req index23 +sprites .req index01 + +SP_SIZE = (8 * VERTEX_SIZEOF) + 4 +SP_SPRITES = SP_SIZE - 4 + +.extern drawPoly + +.global flush_asm +flush_asm: + stmfd sp!, {r4-r11, lr} + + ldr verticesBase, =gVerticesBase + ldr VERTICES, =gVertices + str VERTICES, [verticesBase] + + ldr tmp, =gFacesBase + ldr faces, =gFaces + ldr facesBase, [tmp] + + cmp facesBase, faces + ldmeqfd sp!, {r4-r11, lr} + bxeq lr + + str faces, [tmp] + + // fill VertexLink prev & next indices + sub sp, #SP_SIZE + add tmp, sp, #VERTEX_PREV + mov Qs, #255 + add Qs, #4 + mvn Qe, #512 + sub Ts, Qs, #1 + mvn Te, #256 + mvn PN, #65024 + // quad + strh Qs, [tmp], #VERTEX_SIZEOF + strh PN, [tmp], #VERTEX_SIZEOF + strh PN, [tmp], #VERTEX_SIZEOF + strh Qe, [tmp], #VERTEX_SIZEOF + // triangle + strh Ts, [tmp], #VERTEX_SIZEOF + strh PN, [tmp], #VERTEX_SIZEOF + strh Te, [tmp], #VERTEX_SIZEOF + + ldr tmp, =level + ldr TILE, =gTile + ldr TEXTURES, [tmp, #LEVEL_TEXTURES] + ldr SPRITES, [tmp, #LEVEL_SPRITES] + ldr OT, =gOT + add list, OT, #((OT_SIZE - 1) << 2) + + mov MASK, #0xFF00 + orr MASK, MASK, MASK, lsl #16 + + str SPRITES, [sp, #SP_SPRITES] +.loop_ot: + ldr face, [list], #-4 // read the first face from the list and decrement + cmp face, #0 + beq .next_ot // list is empty, go next + +.loop_list: + ldmia face, {flags, face, index01, index23} // read face params and next face + + and type, flags, #FACE_TYPE_MASK + +.draw_primitive: // shadows, triangles, quads and clipped polys + cmp type, #FACE_TYPE_GTA + bgt .draw_sprite + + tst flags, #FACE_TRIANGLE + moveq ptr, sp // ptr to quad + addne ptr, sp, #(VERTEX_SIZEOF * 4) // ptr to triangle + + .set_vertices: + // 1st vertex + mov vertex, index01, lsl #16 + add vertex, VERTICES, vertex, lsr #(16 - 3) + ldmia vertex, {vXY, vZG} + stmia ptr, {vXY, vZG} + + // 2nd vertex + add vertex, VERTICES, index01, lsr #(16 - 3) // assumption: vertex index will never exceed 8191 + ldmia vertex, {vXY, vZG} + str vXY, [ptr, #(VERTEX_X + VERTEX_SIZEOF * 1)] + str vZG, [ptr, #(VERTEX_Z + VERTEX_SIZEOF * 1)] + + // 3rd vertex + mov vertex, index23, lsl #16 + add vertex, VERTICES, vertex, lsr #(16 - 3) + ldmia vertex, {vXY, vZG} + str vXY, [ptr, #(VERTEX_X + VERTEX_SIZEOF * 2)] + str vZG, [ptr, #(VERTEX_Z + VERTEX_SIZEOF * 2)] + + // 4th vertex (quads only) + addeq vertex, VERTICES, index23, lsr #(16 - 3) + ldmeqia vertex, {vXY, vZG} + streq vXY, [ptr, #(VERTEX_X + VERTEX_SIZEOF * 3)] + streq vZG, [ptr, #(VERTEX_Z + VERTEX_SIZEOF * 3)] + + // skip texturing for FACE_TYPE_SHADOW and FACE_TYPE_F + cmp type, #FACE_TYPE_F + ble .draw + + .set_texture: + mov texIndex, flags, lsl #(32 - FACE_TEXTURE_BITS) + //cmp texIndex, #(MAX_ANIM_TEX << (32 - FACE_TEXTURE_BITS)) // TODO split to animated and static textures arrays + add texIndex, texIndex, texIndex, lsl #1 + add texture, TEXTURES, texIndex, lsr #(32 - FACE_TEXTURE_BITS - 2) + //addge texture, TEXTURES, texIndex, lsr #(32 - FACE_TEXTURE_BITS - 2) + //ldrlt texAnim, =gAnimTextures + //addlt texture, texAnim, texIndex, lsr #(32 - FACE_TEXTURE_BITS - 2) + + ldmia texture, {texTile, uv01, uv23} + str texTile, [TILE] + + and uv, MASK, uv01 + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 0)] + and uv, MASK, uv01, lsl #8 + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 1)] + and uv, MASK, uv23 + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 2)] + and uv, MASK, uv23, lsl #8 + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 3)] + + .draw: + // r0 = flags + // r1 = ptr + tst face, face + adrne lr, .loop_list + adreq lr, .next_ot_zero + + tst flags, #FACE_CLIPPED + bne drawPoly + + // get top vertex for tri or quad rasterization + mov tmp, ptr + ldrsh vA, [tmp, #(VERTEX_Y + VERTEX_SIZEOF * 0)] + ldrsh vB, [tmp, #(VERTEX_Y + VERTEX_SIZEOF * 1)] + cmp vA, vB + addgt ptr, tmp, #(VERTEX_SIZEOF * 1) + movgt vA, vB + ldrsh vB, [tmp, #(VERTEX_Y + VERTEX_SIZEOF * 2)] + cmp vA, vB + addgt ptr, tmp, #(VERTEX_SIZEOF * 2) + movgt vA, vB + lsls vB, flags, #(31 - FACE_TRIANGLE_BIT) // check #FACE_TRIANGLE as sign bit for both pl and gt w/o branch + ldrplsh vB, [tmp, #(VERTEX_Y + VERTEX_SIZEOF * 3)] + cmppl vA, vB + addgt ptr, tmp, #(VERTEX_SIZEOF * 3) + b rasterize_asm + +.draw_sprite: // sprites and gui elements + mov ptr, sp + mov vertex, index01, lsl #16 + add vertex, VERTICES, vertex, lsr #(16 - 3) + ldmia vertex, {vXY0, vZG0, vXY1, vZG1} + stmia ptr, {vXY0, vZG0} + str vXY1, [ptr, #(VERTEX_X + VERTEX_SIZEOF * 1)] + str vZG1, [ptr, #(VERTEX_Z + VERTEX_SIZEOF * 1)] + + // r0 = flags + // r1 = ptr + tst face, face + adrne lr, .loop_list + adreq lr, .next_ot_zero + + // gui + cmp type, #FACE_TYPE_SPRITE + bne rasterize_asm + + // sprite + and sprIndex, flags, #0xFF + ldr sprites, [sp, #SP_SPRITES] + add sprite, sprites, sprIndex, lsl #4 + ldmia sprite, {sprTile, uwvh} + str sprTile, [TILE] + and uv, uwvh, MASK + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 0)] + bic uv, uwvh, MASK + str uv, [ptr, #(VERTEX_T + VERTEX_SIZEOF * 1)] + b rasterize_asm + +.next_ot_zero: + str face, [list, #4] // reset the list pointer in OT + +.next_ot: + cmp list, OT + bge .loop_ot + + add sp, #SP_SIZE + ldmfd sp!, {r4-r11, lr} + bx lr diff --git a/src/platform/gba/asm/getSector.s b/src/platform/gba/asm/getSector.s new file mode 100644 index 00000000..098ac250 --- /dev/null +++ b/src/platform/gba/asm/getSector.s @@ -0,0 +1,44 @@ +#include "common_asm.inc" + +this .req r0 // arg +x .req r1 // arg +z .req r2 // arg +info .req r3 +roomX .req r12 +roomZ .req roomX +sx .req x +sz .req z +sectors .req this +sectorsX .req roomX +sectorsZ .req roomZ +offset .req sectorsZ + +// const Sector* Room::getSector(int32 x, int32 z) const +.global _ZNK4Room9getSectorEii +_ZNK4Room9getSectorEii: + ldr info, [this, #4] + + // sx = X_CLAMP((x - (info->x << 8)) >> 10, 0, info->xSectors - 1); + ldrsh roomX, [info] + subs sx, x, roomX, lsl #8 + movlt sx, #0 + mov sx, sx, lsr #10 + ldrb sectorsX, [info, #20] + cmp sx, sectorsX + subge sx, sectorsX, #1 + + // sz = X_CLAMP((z - (info->z << 8)) >> 10, 0, info->zSectors - 1); + ldrsh roomZ, [info, #2] + subs sz, z, roomZ, lsl #8 + movlt sz, #0 + mov sz, sz, lsr #10 + ldrb sectorsZ, [info, #21] + cmp sz, sectorsZ + subge sz, sectorsZ, #1 + + // return sectors + sx * info->zSectors + sz; + ldr sectors, [this, #8] + mla offset, sx, sectorsZ, sz + add sectors, offset, lsl #3 // sizeof(Sector) == (1 << 3) + + bx lr diff --git a/src/platform/gba/asm/matrixFrame.s b/src/platform/gba/asm/matrixFrame.s new file mode 100644 index 00000000..d4bfdc51 --- /dev/null +++ b/src/platform/gba/asm/matrixFrame.s @@ -0,0 +1,34 @@ +#include "common_asm.inc" + +pos .req r0 // arg +angles .req r1 // arg +x .req pos +y .req angles +z .req r2 +mask .req r3 +packed .req r12 + +.extern matrixTranslateRel_asm, matrixRotateYXZ_fast_asm + +.global matrixFrame_asm +matrixFrame_asm: + stmfd sp!, {lr} + + ldr packed, [angles] + ldrsh z, [pos, #4] + ldrsh y, [pos, #2] + ldrsh x, [pos, #0] + + bl matrixTranslateRel_asm // doesn't affect user mode r12 + + mov mask, #4096 + sub mask, #4 + + and z, mask, packed, lsl #2 + and y, mask, packed, lsr #(10 - 2) + and x, mask, packed, lsr #(20 - 2) + + ldmfd sp!, {lr} + b matrixRotateYXZ_fast_asm + +// TODO matrixFrameLerp \ No newline at end of file diff --git a/src/platform/gba/asm/matrixLerp.s b/src/platform/gba/asm/matrixLerp.s new file mode 100644 index 00000000..41d9fcb3 --- /dev/null +++ b/src/platform/gba/asm/matrixLerp.s @@ -0,0 +1,116 @@ +#include "common_asm.inc" + +n .req r0 // arg +pmul .req r1 // arg +pdiv .req r2 // arg +// FIQ regs +m0 .req r8 +m1 .req r9 +m2 .req r10 +n0 .req r11 +n1 .req r12 +n2 .req r13 +m .req r14 +tmp .req m0 + +.macro load + ldmia m, {m0, m1, m2} + ldmia n, {n0, n1, n2} +.endm + +.macro store + stmia m, {m0, m1, m2} +.endm + +.macro next + add m, m, #16 + add n, n, #16 +.endm + +.macro _1_2 // a = (a + b) / 2 + load + add m0, m0, n0 + add m1, m1, n1 + add m2, m2, n2 + mov m0, m0, asr #1 + mov m1, m1, asr #1 + mov m2, m2, asr #1 + store +.endm + +.macro _1_4 // a = a + (b - a) / 4 + load + sub n0, n0, m0 + sub n1, n1, m1 + sub n2, n2, m2 + add m0, m0, n0, asr #2 + add m1, m1, n1, asr #2 + add m2, m2, n2, asr #2 + store +.endm + +.macro _3_4 // a = b - (b - a) / 4 + load + sub m0, n0, m0 + sub m1, n1, m1 + sub m2, n2, m2 + sub m0, n0, m0, asr #2 + sub m1, n1, m1, asr #2 + sub m2, n2, m2, asr #2 + store +.endm + +.macro _X_Y // a = a + (b - a) * mul / div + load + sub n0, n0, m0 + sub n1, n1, m1 + sub n2, n2, m2 + mul n0, pmul, n0 + mul n1, pmul, n1 + mul n2, pmul, n2 + add m0, m0, n0, asr #8 + add m1, m1, n1, asr #8 + add m2, m2, n2, asr #8 + store +.endm + +.macro lerp func + \func // e00, e01, e02 + next + \func // e10, e11, e12 + next + \func // e20, e21, e22 +.endm + +.global matrixLerp_asm +matrixLerp_asm: + fiq_on + ldr m, =gMatrixPtr + ldr m, [m] +.check_2: + cmp pdiv, #2 + beq .m1_d2 +.check_4: + cmp pdiv, #4 + bne .mX_dY + cmp pmul, #1 + beq .m1_d4 + cmp pmul, #2 + beq .m1_d2 // 2/4 = 1/2 +.m3_d4: + lerp _3_4 + b .done +.m1_d4: + lerp _1_4 + b .done +.m1_d2: + lerp _1_2 + b .done +.mX_dY: + divLUT tmp, pdiv + mul tmp, pmul, tmp + mov pmul, tmp, asr #8 + lerp _X_Y +.done: + fiq_off + bx lr diff --git a/src/platform/gba/asm/matrixPush.s b/src/platform/gba/asm/matrixPush.s new file mode 100644 index 00000000..a4bdc3bf --- /dev/null +++ b/src/platform/gba/asm/matrixPush.s @@ -0,0 +1,30 @@ +#include "common_asm.inc" + +e0 .req r0 +e1 .req r1 +e2 .req r2 +e3 .req r3 +m .req e0 +// FIQ regs +src .req r8 +dst .req r9 +e4 .req r10 +e5 .req r11 + +.global matrixPush_asm +matrixPush_asm: + fiq_on + + ldr m, =gMatrixPtr + ldr src, [m] + add dst, src, #(12 * 4) + str dst, [m] + + ldmia src!, {e0, e1, e2, e3, e4, e5} + stmia dst!, {e0, e1, e2, e3, e4, e5} + + ldmia src!, {e0, e1, e2, e3, e4, e5} + stmia dst!, {e0, e1, e2, e3, e4, e5} + + fiq_off + bx lr diff --git a/src/platform/gba/asm/matrixRotate.s b/src/platform/gba/asm/matrixRotate.s new file mode 100644 index 00000000..114b4fc0 --- /dev/null +++ b/src/platform/gba/asm/matrixRotate.s @@ -0,0 +1,303 @@ +#include "common_asm.inc" + +.macro sincos angle, sin, cos + ldr \sin, =gSinCosTable + ldr \sin, [\sin, \angle, lsl #2] + mov \cos, \sin, lsl #16 + mov \cos, \cos, asr #16 + mov \sin, \sin, asr #16 +.endm + +.macro sincosLUT lut, angle, sin, cos + ldr \sin, [\lut, \angle, lsl #2] + mov \cos, \sin, lsl #16 + mov \cos, \cos, asr #16 + mov \sin, \sin, asr #16 +.endm + +.macro rotxy x, y, sin, cos, t + mul \t, \y, \cos + mla \t, \x, \sin, \t + mul \x, \cos, \x + mul \y, \sin, \y + sub \x, \y + mov \y, \t, asr #FIXED_SHIFT + mov \x, \x, asr #FIXED_SHIFT +.endm + +angle .req r0 // arg +s .req r1 +c .req r2 +v .req r3 +// FIQ regs +e0 .req r8 +e1 .req r9 +m .req angle + +.global matrixRotateX_asm +matrixRotateX_asm: + fiq_on + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + + add m, m, #4 // skip first column + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + add m, #(4 * 4) + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + add m, #(4 * 4) + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + fiq_off + bx lr + +.global matrixRotateY_asm +matrixRotateY_asm: + fiq_on + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + + ldr e0, [m, #0] + ldr e1, [m, #8] + rotxy e0, e1, s, c, v + str e0, [m], #8 + str e1, [m], #8 + + ldr e0, [m, #0] + ldr e1, [m, #8] + rotxy e0, e1, s, c, v + str e0, [m], #8 + str e1, [m], #8 + + ldr e0, [m, #0] + ldr e1, [m, #8] + rotxy e0, e1, s, c, v + str e0, [m], #8 + str e1, [m], #8 + + fiq_off + bx lr + +.global matrixRotateZ_asm +matrixRotateZ_asm: + fiq_on + + mov angle, angle, lsl #16 + mov angle, angle, lsr #20 + + sincos angle, s, c + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + add m, #(4 * 4) + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + add m, #(4 * 4) + ldmia m, {e0, e1} + rotxy e1, e0, s, c, v + stmia m, {e0, e1} + + fiq_off + bx lr + +angleX .req r0 // arg +angleY .req r1 // arg +angleZ .req r2 // arg +e00 .req r3 +e01 .req r4 +e02 .req r5 +e10 .req r6 +scLUT .req r7 +// FIQ regs +e11 .req r8 +e12 .req r9 +e20 .req r10 +e21 .req r11 +tmp .req r12 +e22 .req r13 +sinX .req r14 +sinY .req sinX +sinZ .req sinX +cosX .req angleX +cosY .req angleY +cosZ .req angleZ +mask .req tmp +mm .req tmp + +.global matrixRotateYXZ_asm, matrixRotateYXZ_fast_asm +matrixRotateYXZ_asm: + mov mask, #0xFF + orr mask, mask, #0xF00 ; mask = 0xFFF + + and angleX, mask, angleX, lsr #4 + and angleY, mask, angleY, lsr #4 + and angleZ, mask, angleZ, lsr #4 + +matrixRotateYXZ_fast_asm: // routine for pre-shifted angles + orr mask, angleX, angleY + orrs mask, mask, angleZ + bxeq lr + + stmfd sp!, {r4-r7} + fiq_on + + ldr scLUT, =gSinCosTable + + ldr mm, =gMatrixPtr + ldr mm, [mm] + ldmia mm, {e00, e01, e02} + add mm, #(4 * 4) + ldmia mm, {e10, e11, e12} + add mm, #(4 * 4) + ldmia mm, {e20, e21, e22} + +.rotY: + cmp angleY, #0 + beq .rotX + + sincosLUT scLUT, angleY, sinY, cosY + + rotxy e00, e02, sinY, cosY, tmp + rotxy e10, e12, sinY, cosY, tmp + rotxy e20, e22, sinY, cosY, tmp + +.rotX: + cmp angleX, #0 + beq .rotZ + + sincosLUT scLUT, angleX, sinX, cosX + + rotxy e02, e01, sinX, cosX, tmp + rotxy e12, e11, sinX, cosX, tmp + rotxy e22, e21, sinX, cosX, tmp + +.rotZ: + cmp angleZ, #0 + beq .done + + sincosLUT scLUT, angleZ, sinZ, cosZ + + rotxy e01, e00, sinZ, cosZ, tmp + rotxy e11, e10, sinZ, cosZ, tmp + rotxy e21, e20, sinZ, cosZ, tmp + +.done: + ldr mm, =gMatrixPtr + ldr mm, [mm] + + stmia mm, {e00, e01, e02} + add mm, #(4 * 4) + stmia mm, {e10, e11, e12} + add mm, #(4 * 4) + stmia mm, {e20, e21, e22} + + fiq_off + ldmfd sp!, {r4-r7} + bx lr + +q .req r0 // arg +n .req r1 +mx .req r3 +my .req q + +.global matrixRotateYQ_asm +matrixRotateYQ_asm: + cmp q, #2 + bxeq lr + + ldr n, =gMatrixPtr + ldr n, [n] + + cmp q, #0 + beq .q_0 + cmp q, #1 + beq .q_1 + +.q_3: + ldr mx, [n, #0] + ldr my, [n, #8] + rsb my, my, #0 + str my, [n, #0] + str mx, [n, #8] + + ldr mx, [n, #16] + ldr my, [n, #24] + rsb my, my, #0 + str my, [n, #16] + str mx, [n, #24] + + ldr mx, [n, #32] + ldr my, [n, #40] + rsb my, my, #0 + str my, [n, #32] + str mx, [n, #40] + bx lr + +.q_0: + ldr mx, [n, #0] + ldr my, [n, #8] + rsb mx, mx, #0 + rsb my, my, #0 + str mx, [n, #0] + str my, [n, #8] + + ldr mx, [n, #16] + ldr my, [n, #24] + rsb mx, mx, #0 + rsb my, my, #0 + str mx, [n, #16] + str my, [n, #24] + + ldr mx, [n, #32] + ldr my, [n, #40] + rsb mx, mx, #0 + rsb my, my, #0 + str mx, [n, #32] + str my, [n, #40] + bx lr + +.q_1: + ldr mx, [n, #0] + ldr my, [n, #8] + rsb mx, mx, #0 + str my, [n, #0] + str mx, [n, #8] + + ldr mx, [n, #16] + ldr my, [n, #24] + rsb mx, mx, #0 + str my, [n, #16] + str mx, [n, #24] + + ldr mx, [n, #32] + ldr my, [n, #40] + rsb mx, mx, #0 + str my, [n, #32] + str mx, [n, #40] + bx lr diff --git a/src/platform/gba/asm/matrixSetBasis.s b/src/platform/gba/asm/matrixSetBasis.s new file mode 100644 index 00000000..43159439 --- /dev/null +++ b/src/platform/gba/asm/matrixSetBasis.s @@ -0,0 +1,32 @@ +#include "common_asm.inc" + +dst .req r0 // arg +src .req r1 // arg + +e0 .req r2 +e1 .req r3 +e2 .req r12 + +.global matrixSetBasis_asm +matrixSetBasis_asm: + // row-major + // e0 e1 e2 x + // e0 e1 e2 y + // e0 e1 e2 z + + ldmia src, {e0, e1, e2} + stmia dst, {e0, e1, e2} + add src, #(4 * 4) + add dst, #(4 * 4) + + ldmia src, {e0, e1, e2} + stmia dst, {e0, e1, e2} + add src, #(4 * 4) + add dst, #(4 * 4) + + ldmia src, {e0, e1, e2} + stmia dst, {e0, e1, e2} + add src, #(4 * 4) + add dst, #(4 * 4) + + bx lr diff --git a/src/platform/gba/asm/matrixSetIdentity.s b/src/platform/gba/asm/matrixSetIdentity.s new file mode 100644 index 00000000..82ed435d --- /dev/null +++ b/src/platform/gba/asm/matrixSetIdentity.s @@ -0,0 +1,35 @@ +#include "common_asm.inc" + +e0 .req r0 +e1 .req r1 +e2 .req r2 +e3 .req r3 +// FIQ regs +e4 .req r8 +e5 .req r9 +e6 .req r10 +m .req r11 + +.global matrixSetIdentity_asm +matrixSetIdentity_asm: + fiq_on + ldr m, =gMatrixPtr + ldr m, [m] + mov e0, #0x4000 + mov e1, #0 + mov e2, #0 + mov e3, #0 + mov e4, #0 + mov e5, #0x4000 + mov e6, #0 + + // row-major + // e0 e1 e2 e3 + // e4 e5 e6 e2 + // e3 e4 e5 e6 + + stmia m!, {e0, e1, e2, e3, e4, e5, e6} + stmia m!, {e2, e3, e4, e5, e6} + + fiq_off + bx lr diff --git a/src/platform/gba/asm/matrixTranslate.s b/src/platform/gba/asm/matrixTranslate.s new file mode 100644 index 00000000..f0366c65 --- /dev/null +++ b/src/platform/gba/asm/matrixTranslate.s @@ -0,0 +1,121 @@ +#include "common_asm.inc" + +x .req r0 // arg +y .req r1 // arg +z .req r2 // arg +m .req r3 +// FIQ regs +e0 .req r8 +e1 .req r9 +e2 .req r10 +vx .req r11 +e3 .req r12 +e4 .req r13 +e5 .req r14 + +v .req vx +vy .req e0 +vp .req e1 +e6 .req e2 +e7 .req vx +e8 .req e3 +vz .req e4 + +.global matrixTranslateRel_asm +matrixTranslateRel_asm: + fiq_on + + ldr m, =gMatrixPtr + ldr m, [m] + + // x + ldmia m!, {e0, e1, e2, vx, e3, e4, e5} + mla vx, e0, x, vx + mla vx, e1, y, vx + mla vx, e2, z, vx + str vx, [m, #-16] + + // y + mul vy, e3, x + mla vy, e4, y, vy + mla vy, e5, z, vy + ldmia m, {vp, e6, e7, e8, vz} + add vy, vy, vp + str vy, [m] + + // z + mla vz, e6, x, vz + mla vz, e7, y, vz + mla vz, e8, z, vz + str vz, [m, #16] + + fiq_off + bx lr + +.global matrixTranslateAbs_asm +matrixTranslateAbs_asm: + fiq_on + + ldr v, =gCameraViewPos + ldmia v, {e0, e1, e2} + sub x, x, e0 + sub y, y, e1 + sub z, z, e2 + + ldr m, =gMatrixPtr + ldr m, [m] + + // x + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + // y + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + // z + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + fiq_off + bx lr + +.global matrixTranslateSet_asm +matrixTranslateSet_asm: + fiq_on + + ldr m, =gMatrixPtr + ldr m, [m] + + // x + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + // y + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + // z + ldmia m!, {e0, e1, e2} + mul v, e0, x + mla v, e1, y, v + mla v, e2, z, v + stmia m!, {v} + + fiq_off + bx lr diff --git a/src/platform/gba/asm/rasterize.s b/src/platform/gba/asm/rasterize.s new file mode 100644 index 00000000..08998d80 --- /dev/null +++ b/src/platform/gba/asm/rasterize.s @@ -0,0 +1,49 @@ +#include "common_asm.inc" + +flags .req r0 // arg +L .req r1 // arg +R .req r2 +y .req r3 +type .req r12 +pixel .req flags + +.extern rasterizeS_asm +.extern rasterizeF_asm +.extern rasterizeFT_asm +.extern rasterizeFTA_asm +.extern rasterizeGT_asm +.extern rasterizeGTA_asm +.extern rasterizeSprite_c +.extern rasterizeFillS_asm +.extern rasterizeLineH_asm +.extern rasterizeLineV_asm +.extern rasterize_dummy + +.global rasterize_asm +rasterize_asm: + and type, flags, #FACE_TYPE_MASK + + cmp type, #FACE_TYPE_F + andeq R, flags, #0xFF // R = face color for FACE_TYPE_F + movne R, L // R = L otherwise + + ldr pixel, =fb + ldr pixel, [pixel] + ldrsh y, [L, #VERTEX_Y] + + // pixel += y * 240 -> (y * 16 - y) * 16 + rsb y, y, y, lsl #4 + add pixel, pixel, y, lsl #4 + + add pc, type, lsr #(FACE_TYPE_SHIFT - 2) + nop + b rasterizeS_asm + b rasterizeF_asm + b rasterizeFT_asm + b rasterizeFTA_asm + b rasterizeGT_asm + b rasterizeGTA_asm + b rasterizeSprite_c + b rasterizeFillS_asm + b rasterizeLineH_asm + b rasterizeLineV_asm diff --git a/src/platform/gba/asm/rasterizeF.s b/src/platform/gba/asm/rasterizeF.s new file mode 100644 index 00000000..f04a29c4 --- /dev/null +++ b/src/platform/gba/asm/rasterizeF.s @@ -0,0 +1,139 @@ +#include "common_asm.inc" + +pixel .req r0 // arg +L .req r1 // arg +color .req r2 // arg +index .req r3 +Lh .req r4 +Rh .req r5 +Lx .req r6 + +// FIQ regs +Rx .req r8 +Ldx .req r9 +Rdx .req r10 +N .req r11 +tmp .req r12 +pair .req r13 +width .req r14 + +R .req color +h .req N +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh +LMAP .req Lx +ptr .req tmp + +.global rasterizeF_asm +rasterizeF_asm: + stmfd sp!, {r4-r6} + fiq_on + + add LMAP, color, #LMAP_ADDR + ldrb tmp, [L, #VERTEX_G] + ldrb index, [LMAP, tmp, lsl #8] // index = lightmap[color + L->v.g * 256] + + mov R, L + + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add L, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldrsh Ly2, [L, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + cmp Lh, #1 // if (Lh == 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + ldrsh Ldx, [L, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - L->v.x) + .calc_left_end: + + cmp Rh, #0 + bne .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add R, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldrsh Ry2, [R, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = N->v.y - R->v.y + blt .exit // if (Rh < 0) return + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + cmp Rh, #1 // if (Rh == 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + ldrsh Rdx, [R, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + .calc_right_end: + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + +.scanline_start: + asr tmp, Lx, #16 // x1 = (Lx >> 16) + rsbs width, tmp, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end // if (width <= 0) go next scanline + + add ptr, pixel, tmp // ptr = pixel + x1 + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst ptr, #1 // if (ptr & 1) + beq .align_right + ldrb pair, [ptr, #-1]! // *ptr++ = (*ptr & 0x00FF) | (index << 8) + orr pair, index, lsl #8 + strh pair, [ptr], #2 + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + +.align_right: + tst width, #1 + beq .scanline_block_2px + ldrb pair, [ptr, width] + subs width, #1 // width-- + orr pair, index, pair, lsl #8 + strh pair, [ptr, width] + beq .scanline_end // if (width == 0) + +.scanline_block_2px: + strb index, [ptr], #2 // VRAM one as two bytes write hack + subs width, #2 + bne .scanline_block_2px + +.scanline_end: + add Lx, Ldx // Lx += Ldx + add Rx, Rdx // Rx += Rdx + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + subs h, #1 + bne .scanline_start + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + fiq_off + ldmfd sp!, {r4-r6} + bx lr diff --git a/src/platform/gba/asm/rasterizeFT.s b/src/platform/gba/asm/rasterizeFT.s new file mode 100644 index 00000000..cc18c701 --- /dev/null +++ b/src/platform/gba/asm/rasterizeFT.s @@ -0,0 +1,243 @@ +#include "common_asm.inc" + +arg_pixel .req r0 // arg +arg_L .req r1 // arg +arg_R .req r2 // arg + +N .req r0 +tmp .req r1 +Lx .req r2 +Rx .req r3 +Lt .req r4 +Rt .req r5 +t .req r6 +dtdx .req r7 + +indexA .req r8 +indexB .req r9 +LMAP .req r10 +TILE .req r11 +pixel .req r12 +width .req lr + +// FIQ regs +Ldx .req r8 +Rdx .req r9 +Ldt .req r10 +Rdt .req r11 +LRh .req r12 +L .req r13 +R .req r14 + +Rh .req LRh +Lh .req t + +h .req N + +ptr .req tmp + +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh + +inv .req indexA +duv .req indexB +dtmp .req t +dtmp2 .req indexB + +Ltmp .req N +Rtmp .req N +Ltmp2 .req dtdx +Rtmp2 .req dtdx + +.macro PUT_PIXELS + tex indexA, t + lit indexA + + add t, dtdx, lsl #1 + strb indexA, [ptr], #2 // writing a byte to GBA VRAM will write a half word for free +.endm + +.global rasterizeFT_asm +rasterizeFT_asm: + stmfd sp!, {r4-r11, lr} + + mov pixel, arg_pixel + + mov LMAP, #LMAP_ADDR + ldrb t, [arg_L, #VERTEX_G] + add LMAP, t, lsl #8 // LMAP = (L->v.g << 8) + + ldr TILE, =gTile + ldr TILE, [TILE] + + fiq_on + mov L, arg_L + mov R, arg_R + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add N, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsh Ly2, [N, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + ldrne Lt, [L, #VERTEX_T] // Lt = L->t + mov L, N // L = N + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + cmp Lh, #1 // if (Lh <= 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + ldrsh Ldx, [L, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - Lx) + + ldr Ldt, [L, #VERTEX_T] + subs Ldt, Lt // Ldt = N->v.t - Lt + scaleUV Ldt, Ltmp, Ltmp2, tmp + .calc_left_end: + + cmp Rh, #0 + bgt .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add N, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsh Ry2, [N, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = Ry2 - Rxy + blt .exit // if (Rh < 0) return + ldrne Rt, [R, #VERTEX_T] // Rt = R->t + mov R, N // R = N + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + cmp Rh, #1 // if (Rh <= 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + ldrsh Rdx, [R, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + + ldr Rdt, [R, #VERTEX_T] + subs Rdt, Rt // Rdt = N->v.t - Rt + scaleUV Rdt, Rtmp, Rtmp2, tmp + .calc_right_end: + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + + orr LRh, Rh, Lh, lsl #16 + + fiq_off + +.scanline_start: + asr tmp, Lx, #16 // x1 = (Lx >> 16) + rsbs width, tmp, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end // if (width <= 0) go next scanline + + add ptr, pixel, tmp // ptr = pixel + x1 + + divLUT inv, width // inv = FixedInvU(width) + + subs dtdx, Rt, Lt // duv = Rt - Lt + scaleUV dtdx, dtmp, dtmp2, inv + + mov t, Lt // t = Lt + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst ptr, #1 // if (ptr & 1) + beq .align_right + + tex indexA, t + lit indexA + + ldrb indexB, [ptr, #-1]! // read pal index from VRAM (byte) + orr indexB, indexA, lsl #8 + strh indexB, [ptr], #2 + + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + + add t, dtdx + +.align_right: + tst width, #1 + beq .align_block_4px + + tex indexA, Rt + lit indexA + + ldrb indexB, [ptr, width] + subs width, #1 // width-- + orr indexB, indexA, indexB, lsl #8 + strh indexB, [ptr, width] + + beq .scanline_end // if (width == 0) + +.align_block_4px: + tst width, #2 + beq .align_block_8px + + PUT_PIXELS + + subs width, #2 + beq .scanline_end + +.align_block_8px: + tst width, #4 + beq .scanline_block_8px + + PUT_PIXELS + PUT_PIXELS + + subs width, #4 + beq .scanline_end + +.scanline_block_8px: + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + + subs width, #8 + bne .scanline_block_8px + +.scanline_end: + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + fiq_on + add Lx, Ldx + add Rx, Rdx + add Lt, Ldt + add Rt, Rdt + + subs h, #1 + fiq_off_ne + bne .scanline_start + + lsr Lh, LRh, #16 + lsl Rh, LRh, #16 + lsr Rh, Rh, #16 + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + fiq_off + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/rasterizeFTA.s b/src/platform/gba/asm/rasterizeFTA.s new file mode 100644 index 00000000..0fee0170 --- /dev/null +++ b/src/platform/gba/asm/rasterizeFTA.s @@ -0,0 +1,248 @@ +#include "common_asm.inc" + +arg_pixel .req r0 // arg +arg_L .req r1 // arg +arg_R .req r2 // arg + +N .req r0 +tmp .req r1 +Lx .req r2 +Rx .req r3 +Lt .req r4 +Rt .req r5 +t .req r6 +dtdx .req r7 + +indexA .req r8 +indexB .req r9 +LMAP .req r10 +TILE .req r11 +pixel .req r12 +width .req lr + +// FIQ regs +Ldx .req r8 +Rdx .req r9 +Ldt .req r10 +Rdt .req r11 +LRh .req r12 +L .req r13 +R .req r14 + +Rh .req LRh +Lh .req t + +h .req N + +ptr .req tmp + +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh + +inv .req indexA +duv .req indexB +dtmp .req t +dtmp2 .req indexB + +Ltmp .req N +Rtmp .req N +Ltmp2 .req dtdx +Rtmp2 .req dtdx + +.macro PUT_PIXELS + tex indexA, t + add t, dtdx, lsl #1 + cmp indexA, #0 + ldrneb indexA, [LMAP, indexA] + strneb indexA, [ptr] + add ptr, #2 +.endm + +.global rasterizeFTA_asm +rasterizeFTA_asm: + stmfd sp!, {r4-r11, lr} + + mov pixel, arg_pixel + + mov LMAP, #LMAP_ADDR + ldrb t, [arg_L, #VERTEX_G] + add LMAP, t, lsl #8 // LMAP = (L->v.g << 8) + + ldr TILE, =gTile + ldr TILE, [TILE] + + fiq_on + mov L, arg_L + mov R, arg_R + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add N, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsh Ly2, [N, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + ldrne Lt, [L, #VERTEX_T] // Lt = L->t + mov L, N // L = N + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + cmp Lh, #1 // if (Lh <= 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + ldrsh Ldx, [L, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - Lx) + + ldr Ldt, [L, #VERTEX_T] + subs Ldt, Lt // Ldt = N->v.t - Lt + scaleUV Ldt, Ltmp, Ltmp2, tmp + .calc_left_end: + + cmp Rh, #0 + bgt .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add N, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsh Ry2, [N, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = Ry2 - Rxy + blt .exit // if (Rh < 0) return + ldrne Rt, [R, #VERTEX_T] // Rt = R->t + mov R, N // R = N + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + cmp Rh, #1 // if (Rh <= 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + ldrsh Rdx, [R, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + + ldr Rdt, [R, #VERTEX_T] + subs Rdt, Rt // Rdt = N->v.t - Rt + scaleUV Rdt, Rtmp, Rtmp2, tmp + .calc_right_end: + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + + orr LRh, Rh, Lh, lsl #16 + + fiq_off + +.scanline_start: + asr tmp, Lx, #16 // x1 = (Lx >> 16) + rsbs width, tmp, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end // if (width <= 0) go next scanline + + add ptr, pixel, tmp // ptr = pixel + x1 + + divLUT inv, width // inv = FixedInvU(width) + + subs dtdx, Rt, Lt // duv = Rt - Lt + scaleUV dtdx, dtmp, dtmp2, inv + + mov t, Lt // t = Lt + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst ptr, #1 // if (ptr & 1) + beq .align_right + + tex indexA, t + + cmp indexA, #0 + ldrneb indexB, [ptr, #-1]! // read pal index from VRAM (byte) + ldrneb indexA, [LMAP, indexA] + orrne indexB, indexA, lsl #8 + strneh indexB, [ptr], #2 + addeq ptr, #1 + + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + + add t, dtdx + +.align_right: + tst width, #1 + beq .align_block_4px + + tex indexA, Rt + + cmp indexA, #0 + ldrneb indexA, [LMAP, indexA] + ldrneb indexB, [ptr, width] + orrne indexB, indexA, indexB, lsl #8 + addne indexA, ptr, width + strneh indexB, [indexA, #-1] + + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + +.align_block_4px: + tst width, #2 + beq .align_block_8px + + PUT_PIXELS + + subs width, #2 + beq .scanline_end + +.align_block_8px: + tst width, #4 + beq .scanline_block_8px + + PUT_PIXELS + PUT_PIXELS + + subs width, #4 + beq .scanline_end + +.scanline_block_8px: + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + + subs width, #8 + bne .scanline_block_8px + +.scanline_end: + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + fiq_on + add Lx, Ldx + add Rx, Rdx + add Lt, Ldt + add Rt, Rdt + + subs h, #1 + fiq_off_ne + bne .scanline_start + + lsr Lh, LRh, #16 + lsl Rh, LRh, #16 + lsr Rh, Rh, #16 + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + fiq_off + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/rasterizeFillS.s b/src/platform/gba/asm/rasterizeFillS.s new file mode 100644 index 00000000..eaba805a --- /dev/null +++ b/src/platform/gba/asm/rasterizeFillS.s @@ -0,0 +1,74 @@ +#include "common_asm.inc" + +pixel .req r0 // arg +L .req r1 // arg +R .req r2 // arg +p .req r3 +// FIQ regs +w .req r8 +indexA .req r9 +indexB .req r10 +shade .req r11 + +width .req L +height .req R +LMAP .req shade + +.global rasterizeFillS_asm +rasterizeFillS_asm: + fiq_on + + add R, #VERTEX_SIZEOF + ldrsh p, [L, #VERTEX_X] + add pixel, p + ldrb shade, [L, #VERTEX_G] + ldrsh width, [R, #VERTEX_X] + ldrsh height, [R, #VERTEX_Y] + lsl shade, #8 + add LMAP, shade, #LMAP_ADDR + +.loop: + mov p, pixel + mov w, width + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst p, #1 + beq .align_right + ldrh indexA, [p, #-1]! + ldrb indexB, [LMAP, indexA, lsr #8] + and indexA, indexA, #0xFF + orr indexA, indexB, lsl #8 + strh indexA, [p], #2 + subs w, #1 + beq .scanline_end + +.align_right: + tst w, #1 + beq .scanline_block_2px + subs w, #1 + ldrh indexA, [p, w] + and indexB, indexA, #0xFF + ldrb indexB, [LMAP, indexB] + and indexA, indexA, #0xFF00 + orr indexA, indexA, indexB + strh indexA, [p, w] + beq .scanline_end + +.scanline_block_2px: + ldrh indexA, [p] + and indexB, indexA, #0xFF + ldrb indexA, [LMAP, indexA, lsr #8] + ldrb indexB, [LMAP, indexB] + orr indexA, indexB, indexA, lsl #8 + strh indexA, [p], #2 + subs w, #2 + bne .scanline_block_2px + +.scanline_end: + add pixel, #FRAME_WIDTH + subs height, #1 + bne .loop + + fiq_off + bx lr diff --git a/src/platform/gba/asm/rasterizeGT.s b/src/platform/gba/asm/rasterizeGT.s new file mode 100644 index 00000000..fea32d17 --- /dev/null +++ b/src/platform/gba/asm/rasterizeGT.s @@ -0,0 +1,282 @@ +#include "common_asm.inc" + +arg_pixel .req r0 // arg +arg_L .req r1 // arg +arg_R .req r2 // arg + +N .req r0 +tmp .req r1 +Lx .req r2 +Rx .req r3 +Lg .req r4 +Rg .req r5 +Lt .req r6 +Rt .req r7 + +L .req r8 +R .req r9 +Lh .req r10 +Rh .req r11 +pixel .req r12 +TILE .req lr + +// FIQ regs +Ldx .req r8 +Rdx .req r9 +Ldg .req r10 +Rdg .req r11 +Ldt .req r12 +Rdt .req r13 +spFIQ .req r14 + +h .req N + +LMAP .req tmp + +indexA .req Lh +indexB .req tmp + +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh + +inv .req Lh + +ptr .req Lx +width .req Rh + +g .req Lg +dgdx .req R + +t .req Lt +dtdx .req L +dtmp .req tmp +dtmp2 .req R + +Ltmp .req spFIQ +Rtmp .req spFIQ +Ltmp2 .req N +Rtmp2 .req N + +G_EXTRA = 5 // extra bits of precision for gouraud shading (8 + G_EXTRA) + +.macro PUT_PIXELS + tex indexA, t + + mov LMAP, g, lsr #(8 + G_EXTRA) + ldrb indexA, [indexA, LMAP, lsl #8] + + strb indexA, [ptr], #2 // writing a byte to GBA VRAM will write a half word for free + + add g, dgdx, lsl #1 + add t, dtdx, lsl #1 +.endm + +.global rasterizeGT_asm +rasterizeGT_asm: + stmfd sp!, {r4-r11, lr} + + ldr TILE, =gTile + ldr TILE, [TILE] + + mov pixel, arg_pixel + mov L, arg_L + mov R, arg_R + + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add N, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsh Ly2, [N, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + ldrneb Lg, [L, #VERTEX_G] // Lg = L->v.g + ldrne Lt, [L, #VERTEX_T] // Lt = L->t + mov L, N // L = N + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + lsl Lg, #(8 + G_EXTRA) // Lg <<= 8 + G_EXTRA + cmp Lh, #1 // if (Lh <= 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + fiq_on + ldrsh Ldx, [N, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - Lx) + + ldrb Ldg, [N, #VERTEX_G] + subs Ldg, Lg, lsr #(8 + G_EXTRA) + mulne Ldg, tmp, Ldg // Ldg = tmp * (N->v.g - Lg) + asr Ldg, #(8 - G_EXTRA) // (8 + G_EXTRA)-bit for fractional part + + ldr Ldt, [N, #VERTEX_T] + subs Ldt, Lt // Ldt = N->v.t - Lt + scaleUV Ldt, Ltmp, Ltmp2, tmp + fiq_off + .calc_left_end: + + cmp Rh, #0 + bne .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add N, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsh Ry2, [N, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = N->v.y - R->v.y + blt .exit // if (Rh < 0) return + ldrneb Rg, [R, #VERTEX_G] // Rg = R->v.g + ldrne Rt, [R, #VERTEX_T] // Rt = R->t + mov R, N // R = N + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + lsl Rg, #(8 + G_EXTRA) // Rg <<= 8 + G_EXTRA + cmp Rh, #1 // if (Rh <= 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + fiq_on + ldrsh Rdx, [N, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + + ldrb Rdg, [N, #VERTEX_G] + subs Rdg, Rg, lsr #(8 + G_EXTRA) + mulne Rdg, tmp, Rdg // Rdg = tmp * (N->v.g - Rg) + asr Rdg, #(8 - G_EXTRA) // (8 + G_EXTRA)-bit for fractional part + + ldr Rdt, [N, #VERTEX_T] + subs Rdt, Rt // Rdt = N->v.t - Rt + scaleUV Rdt, Rtmp, Rtmp2, tmp + fiq_off + .calc_right_end: + + orr Lg, #(LMAP_ADDR << G_EXTRA) + orr Rg, #(LMAP_ADDR << G_EXTRA) + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + + stmfd sp!, {L, R, Lh, Rh} + +.scanline_start: + asr Lh, Lx, #16 // x1 = (Lx >> 16) + rsbs width, Lh, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end_fast // if (width <= 0) go next scanline + + stmfd sp!, {Lx, Lg, Lt} + + add ptr, pixel, Lx, asr #16 // ptr = pixel + x1 + + divLUT inv, width // inv = FixedInvU(width) + + subs dtdx, Rt, Lt // dtdx = Rt - Lt + scaleUV dtdx, dtmp, dtmp2, inv + // t == Lt (alias) + + subs dgdx, Rg, Lg // dgdx = Rg - Lg + mulne dgdx, inv // dgdx *= FixedInvU(width) + asr dgdx, #16 // dgdx >>= 16 + // g == Lg (alias) + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst ptr, #1 // if (ptr & 1) + beq .align_right + + tex indexA, t + mov LMAP, g, lsr #(8 + G_EXTRA) + ldrb indexA, [indexA, LMAP, lsl #8] + + ldrb indexB, [ptr, #-1]! // read pal index from VRAM (byte) + orr indexB, indexA, lsl #8 + strh indexB, [ptr], #2 + + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + + add g, dgdx + add t, dtdx + +.align_right: + tst width, #1 + beq .align_block_4px + + tex indexA, Rt + mov LMAP, Rg, lsr #(8 + G_EXTRA) + ldrb indexA, [indexA, LMAP, lsl #8] + + ldrb indexB, [ptr, width] + subs width, #1 // width-- + orr indexB, indexA, indexB, lsl #8 + strh indexB, [ptr, width] + + beq .scanline_end // if (width == 0) + +.align_block_4px: + tst width, #2 + beq .align_block_8px + + PUT_PIXELS + + subs width, #2 + beq .scanline_end + +.align_block_8px: + tst width, #4 + beq .scanline_block_8px + + PUT_PIXELS + PUT_PIXELS + + subs width, #4 + beq .scanline_end + +.scanline_block_8px: + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + + subs width, #8 + bne .scanline_block_8px + +.scanline_end: + ldmfd sp!, {Lx, Lg, Lt} + +.scanline_end_fast: + fiq_on + add Lx, Ldx + add Rx, Rdx + add Lg, Ldg + add Rg, Rdg + add Lt, Ldt + add Rt, Rdt + fiq_off + + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + subs h, #1 + bne .scanline_start + + ldmfd sp!, {L, R, Lh, Rh} + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/rasterizeGTA.s b/src/platform/gba/asm/rasterizeGTA.s new file mode 100644 index 00000000..a1716966 --- /dev/null +++ b/src/platform/gba/asm/rasterizeGTA.s @@ -0,0 +1,294 @@ +#include "common_asm.inc" + +arg_pixel .req r0 // arg +arg_L .req r1 // arg +arg_R .req r2 // arg + +N .req r0 +tmp .req r1 +Lx .req r2 +Rx .req r3 +Lg .req r4 +Rg .req r5 +Lt .req r6 +Rt .req r7 + +L .req r8 +R .req r9 +Lh .req r10 +Rh .req r11 +pixel .req r12 +TILE .req lr + +// FIQ regs +Ldx .req r8 +Rdx .req r9 +Ldg .req r10 +Rdg .req r11 +Ldt .req r12 +Rdt .req r13 +spFIQ .req r14 + +h .req N + +LMAP .req tmp + +indexA .req Lh +indexB .req tmp + +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh + +inv .req Lh + +ptr .req Lx +width .req Rh + +g .req Lg +dgdx .req R + +t .req Lt +dtdx .req L +dtmp .req tmp +dtmp2 .req R + +Ltmp .req spFIQ +Rtmp .req spFIQ +Ltmp2 .req N +Rtmp2 .req N + +.macro PUT_PIXELS + bic LMAP, g, #255 + + tex indexA, t + cmp indexA, #0 + ldrneb indexA, [LMAP, indexA] + strneb indexA, [ptr] + add ptr, #2 + + add g, dgdx, lsl #1 + add t, dtdx, lsl #1 +.endm + +.global rasterizeGTA_asm +rasterizeGTA_asm: + stmfd sp!, {r4-r11, lr} + + ldr TILE, =gTile + ldr TILE, [TILE] + + mov pixel, arg_pixel + mov L, arg_L + mov R, arg_R + + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add N, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsh Ly2, [N, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + ldrneb Lg, [L, #VERTEX_G] // Lg = L->v.g + ldrne Lt, [L, #VERTEX_T] // Lt = L->t + mov L, N // L = N + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + lsl Lg, #8 // Lg <<= 8 + cmp Lh, #1 // if (Lh <= 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + fiq_on + ldrsh Ldx, [N, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - Lx) + + ldrb Ldg, [N, #VERTEX_G] + subs Ldg, Lg, lsr #8 + mulne Ldg, tmp, Ldg // Ldg = tmp * (N->v.g - Lg) + asr Ldg, #8 // 8-bit for fractional part + + ldr Ldt, [N, #VERTEX_T] + subs Ldt, Lt // Ldt = N->v.t - Lt + scaleUV Ldt, Ltmp, Ltmp2, tmp + fiq_off + .calc_left_end: + + cmp Rh, #0 + bne .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add N, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsh Ry2, [N, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = N->v.y - R->v.y + blt .exit // if (Rh < 0) return + ldrb Rg, [R, #VERTEX_G] // Rg = R->v.g + ldr Rt, [R, #VERTEX_T] // Rt = R->t + mov R, N // R = N + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + lsl Rg, #8 // Rg <<= 8 + cmp Rh, #1 // if (Rh <= 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + fiq_on + ldrsh Rdx, [N, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + + ldrb Rdg, [N, #VERTEX_G] + subs Rdg, Rg, lsr #8 + mulne Rdg, tmp, Rdg // Rdg = tmp * (N->v.g - Rg) + asr Rdg, #8 // 8-bit for fractional part + + ldr Rdt, [N, #VERTEX_T] + subs Rdt, Rt // Rdt = N->v.t - Rt + scaleUV Rdt, Rtmp, Rtmp2, tmp + fiq_off + .calc_right_end: + + orr Lg, #LMAP_ADDR + orr Rg, #LMAP_ADDR + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + + stmfd sp!, {L, R, Lh, Rh} + +.scanline_start: + asr Lh, Lx, #16 // x1 = (Lx >> 16) + rsbs width, Lh, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end_fast // if (width <= 0) go next scanline + + stmfd sp!, {Lx, Lg, Lt} + + add ptr, pixel, Lx, asr #16 // ptr = pixel + x1 + + divLUT inv, width // inv = FixedInvU(width) + + subs dtdx, Rt, Lt // dtdx = Rt - Lt + scaleUV dtdx, dtmp, dtmp2, inv + // t == Lt (alias) + + subs dgdx, Rg, Lg // dgdx = Rg - Lg + mulne dgdx, inv // dgdx *= FixedInvU(width) + asr dgdx, #16 // dgdx >>= 16 + // g == Lg (alias) + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst ptr, #1 // if (ptr & 1) + beq .align_right + + tex indexA, t + + cmp indexA, #0 + beq .skip_left + + bic LMAP, g, #255 + ldrb indexA, [LMAP, indexA] + + ldrb indexB, [ptr, #-1]! // read pal index from VRAM (byte) + orr indexB, indexA, lsl #8 + strh indexB, [ptr], #1 + +.skip_left: + add ptr, #1 + add g, dgdx + add t, dtdx + + subs width, #1 // width-- + beq .scanline_end // if (width == 0) + +.align_right: + tst width, #1 + beq .align_block_4px + + tex indexA, Rt + + cmp indexA, #0 + subeq width, #1 + beq .skip_right + + bic LMAP, Rg, #255 + lit indexA + + ldrb indexB, [ptr, width] + sub width, #1 // width-- + orr indexB, indexA, indexB, lsl #8 + strh indexB, [ptr, width] + +.skip_right: + cmp width, #0 + beq .scanline_end // if (width == 0) + +.align_block_4px: + tst width, #2 + beq .align_block_8px + + PUT_PIXELS + + subs width, #2 + beq .scanline_end + +.align_block_8px: + tst width, #4 + beq .scanline_block_8px + + PUT_PIXELS + PUT_PIXELS + + subs width, #4 + beq .scanline_end + +.scanline_block_8px: + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + PUT_PIXELS + + subs width, #8 + bne .scanline_block_8px + +.scanline_end: + ldmfd sp!, {Lx, Lg, Lt} + +.scanline_end_fast: + fiq_on + add Lx, Ldx + add Rx, Rdx + add Lg, Ldg + add Rg, Rdg + add Lt, Ldt + add Rt, Rdt + fiq_off + + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + subs h, #1 + bne .scanline_start + + ldmfd sp!, {L, R, Lh, Rh} + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/rasterizeLineH.s b/src/platform/gba/asm/rasterizeLineH.s new file mode 100644 index 00000000..d246dee2 --- /dev/null +++ b/src/platform/gba/asm/rasterizeLineH.s @@ -0,0 +1,43 @@ +#include "common_asm.inc" + +pixel .req r0 // arg +L .req r1 // arg +R .req r2 // arg +tmp .req r12 +index .req L +width .req R + +.global rasterizeLineH_asm +rasterizeLineH_asm: + add R, #VERTEX_SIZEOF + ldrsh tmp, [L, #VERTEX_X] + add pixel, tmp + ldrb index, [L, #VERTEX_G] + ldrsh width, [R, #VERTEX_X] + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst pixel, #1 + beq .align_right + ldrb tmp, [pixel, #-1]! + orr tmp, index, lsl #8 + strh tmp, [pixel], #2 + subs width, #1 + beq .scanline_end + +.align_right: + tst width, #1 + beq .scanline_block_2px + ldrb tmp, [pixel, width] + subs width, #1 + orr tmp, index, tmp, lsl #8 + strh tmp, [pixel, width] + beq .scanline_end + +.scanline_block_2px: + strb index, [pixel], #2 // VRAM one as two bytes write hack + subs width, #2 + bne .scanline_block_2px + +.scanline_end: + mov pc, lr diff --git a/src/platform/gba/asm/rasterizeLineV.s b/src/platform/gba/asm/rasterizeLineV.s new file mode 100644 index 00000000..c2e6e0b5 --- /dev/null +++ b/src/platform/gba/asm/rasterizeLineV.s @@ -0,0 +1,36 @@ +#include "common_asm.inc" + +pixel .req r0 // arg +L .req r1 // arg +R .req r2 // arg +tmp .req r12 +index .req L +height .req R + +.global rasterizeLineV_asm +rasterizeLineV_asm: + add R, #VERTEX_SIZEOF + ldrsh tmp, [L, #VERTEX_X] + ldrb index, [L, #VERTEX_G] + ldrsh height, [R, #VERTEX_Y] + add pixel, tmp + + tst pixel, #1 + beq .right + + sub pixel, #1 +.left: + ldrb tmp, [pixel] + orr tmp, index, lsl #8 + strh tmp, [pixel], #FRAME_WIDTH + subs height, #1 + bne .left + mov pc, lr + +.right: + ldrb tmp, [pixel, #1] + orr tmp, index, tmp, lsl #8 + strh tmp, [pixel], #FRAME_WIDTH + subs height, #1 + bne .right + mov pc, lr diff --git a/src/platform/gba/asm/rasterizeS.s b/src/platform/gba/asm/rasterizeS.s new file mode 100644 index 00000000..227b9867 --- /dev/null +++ b/src/platform/gba/asm/rasterizeS.s @@ -0,0 +1,147 @@ +#include "common_asm.inc" + +pixel .req r0 // arg +L .req r1 // arg +R .req r2 // arg +LMAP .req r3 +Lh .req r4 +Rh .req r5 +Lx .req r6 +Rx .req r7 +// FIQ regs +Ldx .req r8 +Rdx .req r9 +N .req r10 +tmp .req r11 +pair .req r12 +width .req r13 +indexA .req r14 + +h .req N +Rxy .req tmp +Ry2 .req Rh +Lxy .req tmp +Ly2 .req Lh +indexB .req pair + +.global rasterizeS_asm +rasterizeS_asm: + stmfd sp!, {r4-r7} + fiq_on + + mov LMAP, #LMAP_ADDR + add LMAP, #0x1A00 + + mov Rh, #0 // Rh = 0 + + .calc_left_start: + ldr Lxy, [L, #VERTEX_X] // Lxy = (L->v.y << 16) | (L->v.x) + ldrsb N, [L, #VERTEX_PREV] // N = L + L->prev + add L, L, N, lsl #VERTEX_SIZEOF_SHIFT + ldrsh Ly2, [L, #VERTEX_Y] // Ly2 = N->v.y + + subs Lh, Ly2, Lxy, asr #16 // Lh = N->v.y - L->v.y + blt .exit // if (Lh < 0) return + beq .calc_left_start + + lsl Lx, Lxy, #16 // Lx = L->v.x << 16 + cmp Lh, #1 // if (Lh == 1) skip Ldx calc + beq .calc_left_end + + divLUT tmp, Lh // tmp = FixedInvU(Lh) + + ldrsh Ldx, [L, #VERTEX_X] + subs Ldx, Lx, asr #16 + mulne Ldx, tmp, Ldx // Ldx = tmp * (N->v.x - Lx) + .calc_left_end: + + cmp Rh, #0 + bne .calc_right_end // if (Rh != 0) end with right + + .calc_right_start: + ldr Rxy, [R, #VERTEX_X] // Rxy = (R->v.y << 16) | (R->v.x) + ldrsb N, [R, #VERTEX_NEXT] // N = R + R->next + add R, R, N, lsl #VERTEX_SIZEOF_SHIFT + ldrsh Ry2, [R, #VERTEX_Y] // Ry2 = N->v.y + + subs Rh, Ry2, Rxy, asr #16 // Rh = N->v.y - R->v.y + blt .exit // if (Rh < 0) return + beq .calc_right_start + + lsl Rx, Rxy, #16 // Rx = R->v.x << 16 + cmp Rh, #1 // if (Rh == 1) skip Rdx calc + beq .calc_right_end + + divLUT tmp, Rh // tmp = FixedInvU(Rh) + + ldrsh Rdx, [R, #VERTEX_X] + subs Rdx, Rx, asr #16 + mulne Rdx, tmp, Rdx // Rdx = tmp * (N->v.x - Rx) + .calc_right_end: + + cmp Rh, Lh // if (Rh < Lh) + movlt h, Rh // h = Rh + movge h, Lh // else h = Lh + sub Lh, h // Lh -= h + sub Rh, h // Rh -= h + +.scanline_start: + asr tmp, Lx, #16 // x1 = (Lx >> 16) + rsbs width, tmp, Rx, asr #16 // width = (Rx >> 16) - x1 + ble .scanline_end // if (width <= 0) go next scanline + + add tmp, pixel, tmp // tmp = pixel + x1 + + // 2 bytes alignment (VRAM write requirement) +.align_left: + tst tmp, #1 + beq .align_right + + ldrh pair, [tmp, #-1]! + ldrb indexA, [LMAP, pair, lsr #8] + and pair, #0xFF + orr pair, indexA, lsl #8 + strh pair, [tmp], #2 + + subs width, #1 // width-- + beq .scanline_end + +.align_right: + tst width, #1 + beq .scanline + subs width, #1 // width-- + ldrh pair, [tmp, width] + and indexA, pair, #0xFF + ldrb indexA, [LMAP, indexA] + and pair, #0xFF00 + orr pair, indexA + strh pair, [tmp, width] + beq .scanline_end // width == 0 + +.scanline: + ldrh pair, [tmp] + ldrb indexA, [LMAP, pair, lsr #8] + and pair, #0xFF + ldrb indexB, [LMAP, pair] + orr pair, indexB, indexA, lsl #8 + strh pair, [tmp], #2 + + subs width, #2 + bne .scanline + +.scanline_end: + add Lx, Ldx // Lx += Ldx + add Rx, Rdx // Rx += Rdx + add pixel, #FRAME_WIDTH // pixel += FRAME_WIDTH (240) + + subs h, #1 + bne .scanline_start + + cmp Lh, #0 + bne .calc_right_start + b .calc_left_start + +.exit: + fiq_off + ldmfd sp!, {r4-r7} + bx lr diff --git a/src/platform/gba/asm/rasterize_dummy.s b/src/platform/gba/asm/rasterize_dummy.s new file mode 100644 index 00000000..02224994 --- /dev/null +++ b/src/platform/gba/asm/rasterize_dummy.s @@ -0,0 +1,5 @@ +#include "common_asm.inc" + +.global rasterize_dummy +rasterize_dummy: + bx lr \ No newline at end of file diff --git a/src/platform/gba/asm/sdiv32.s b/src/platform/gba/asm/sdiv32.s new file mode 100644 index 00000000..a28236ee --- /dev/null +++ b/src/platform/gba/asm/sdiv32.s @@ -0,0 +1,51 @@ +@-------------------------------------------------------------------------------- +@ udiv.s +@-------------------------------------------------------------------------------- +@ Provides an implementation of signed division +@-------------------------------------------------------------------------------- + +@ refer to the unsigned division + .extern __aeabi_uidivmod + .extern __aeabi_uidiv + +@ r0: the numerator / r1: the denominator +@ after it, r0 has the quotient and r1 has the modulo + .section .iwram, "ax", %progbits + .align 2 + .arm + .global __aeabi_idivmod + .type __aeabi_idivmod STT_FUNC +__aeabi_idivmod: + + .section .iwram, "ax", %progbits + .align 2 + .arm + .global __aeabi_idiv + .type __aeabi_idiv STT_FUNC +__aeabi_idiv: + + @ Move the lr to r12 and make the numbers positive + mov r12, lr + + cmp r0, #0 + rsblt r0, #0 + orrlt r12, #1 << 30 + + cmp r1, #0 + rsblt r1, #0 + orrlt r12, #1 << 31 + + @ Call the unsigned division + .extern udiv32pastzero + bl udiv32pastzero + + @ Test the old sign bits + tst r12, #1 << 30 + rsbne r0, r0, #0 + rsbne r1, r0, #0 + tst r12, #1 << 31 + rsbne r0, r0, #0 + + @ Erase the sign bits from the return address, and return + bic r12, #3 << 30 + bx r12 diff --git a/src/platform/gba/asm/sndAD4.s b/src/platform/gba/asm/sndAD4.s new file mode 100644 index 00000000..cef5d54b --- /dev/null +++ b/src/platform/gba/asm/sndAD4.s @@ -0,0 +1,70 @@ +#include "common_asm.inc" + +// Clamping is only required if the encoder gives overflow warnings. +// To improve on speed, the music volume has been reduced to avoid this. +#define CLAMP_OUTPUT 0 + +// Unrolling saves 3.75 cycles per sample, but uses a lot more RAM. +#define UNROLL 0 + +state .req r0 +buffer .req r1 +data .req r2 +size .req r3 +zM1 .req r4 +zM2 .req r5 +tap .req r6 +quant .req r7 +n .req r8 +mask .req r9 +adapt .req r10 +stepLUT .req r11 +temp .req r12 + +.macro adpcm4_decode zM1, zM2 + sub tap, tap, tap, asr #3 + add tap, tap, \zM2 + mov temp, tap, asr #8 +#if CLAMP_OUTPUT + teq temp, temp, lsl #32-8 + eormi temp, mask, temp, asr #31 +#endif + strb temp, [buffer], #1 + mov n, n, ror #4 + mov temp, n, asr #32-4 + sub \zM2, \zM1, \zM2 + mla \zM2, quant, temp, \zM2 + // zM1 and zM2 now swapped + ldrb temp, [stepLUT, temp] + mla temp, quant, temp, mask + mov quant, temp, lsr #7 +.endm + +.global sndADPCM4_fill_asm +sndADPCM4_fill_asm: + stmfd sp!, {r4-r11} + + ldmia state, {zM1,zM2,tap,quant} + mov mask, #127 + ldr stepLUT, =ADPCM4_ADAPT+8 + +.loop: + ldr n, [data], #4 +#if UNROLL +.rept 8/2 +#endif +1: adpcm4_decode zM1, zM2 // zM1 and zM2 get swapped... + adpcm4_decode zM2, zM1 // ... and swapped back +#if UNROLL +.endr +#else + adds size, size, #1<<(32-3+1) // Count up the 8 samples + bcc 1b +#endif + subs size, #8/2 // size is provided as number of bytes + bne .loop + + stmia state, {zM1,zM2,tap,quant} + + ldmfd sp!, {r4-r11} + bx lr diff --git a/src/platform/gba/asm/sndPCM.s b/src/platform/gba/asm/sndPCM.s new file mode 100644 index 00000000..bf1754ce --- /dev/null +++ b/src/platform/gba/asm/sndPCM.s @@ -0,0 +1,118 @@ +#include "common_asm.inc" + +pos .req r0 +inc .req r1 +size .req r2 +volume .req r3 + +data .req r4 +buffer .req r5 +tmp .req r6 +mask .req r7 +last .req r12 +tmpSP .req last +out .req size + +.macro clamp + // Aikku93's quick-and-dirty clamp (-128..+127) + // This only works for inputs of -256..+255 + teq out, out, lsl #32-8 // If the sign of 8bit value does not match... + eormi out, mask, out, asr #31 // ... then clip using the real sign +.endm + +.macro calc_last + // last = pos + inc * SND_SAMPLES (176) + add last, inc, inc, lsl #2 // last = inc * 5 + add last, inc, last, lsl #1 // last = inc * 11 + add last, pos, last, lsl #4 // last = pos + (inc * 11) * 16 +.endm + +.macro pcm_sample_fetch + ldrb out, [data, pos, lsr #SND_FIXED_SHIFT] + add pos, inc + subs out, #128 + mulne out, volume +.endm + +.macro pcm_sample_fill + pcm_sample_fetch + asr out, #SND_VOL_SHIFT + strb out, [buffer], #1 +.endm + +.macro pcm_sample_mix + pcm_sample_fetch + ldrsb tmp, [buffer] + add out, tmp, out, asr #SND_VOL_SHIFT + clamp + strb out, [buffer], #1 +.endm + +.global sndPCM_fill_asm +sndPCM_fill_asm: + mov tmpSP, sp + stmfd sp!, {r4-r5} + + ldmia tmpSP, {data, buffer} + + calc_last + + cmp last, size + movgt last, size + +.loop_fill: + pcm_sample_fill + pcm_sample_fill + + cmp pos, last + blt .loop_fill + + ldmfd sp!, {r4-r5} + bx lr + + +.global sndPCM_mix_asm +sndPCM_mix_asm: + mov tmpSP, sp + stmfd sp!, {r4-r7} // tmp reg required + mov mask, #127 + + ldmia tmpSP, {data, buffer} + + calc_last + + cmp last, size + movgt last, size + +.loop_mix: + pcm_sample_mix + pcm_sample_mix + + cmp pos, last + blt .loop_mix + + ldmfd sp!, {r4-r7} + bx lr + +.global sndClear_asm +sndClear_asm: + // 4 words + mov r1, #0 + mov r2, #0 + mov r3, #0 + mov r12, #0 + + // fill 11 * 4 * 4 = 176 bytes + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + stmia r0!, {r1-r3, r12} + + bx lr \ No newline at end of file diff --git a/src/platform/gba/asm/sphereIsVisible.s b/src/platform/gba/asm/sphereIsVisible.s new file mode 100644 index 00000000..a862a930 --- /dev/null +++ b/src/platform/gba/asm/sphereIsVisible.s @@ -0,0 +1,90 @@ +#include "common_asm.inc" + +x .req r0 // arg +y .req r1 // arg +z .req r2 // arg +r .req r3 // arg +// FIQ regs +mx .req r8 +my .req r9 +mz .req r10 +vx .req r11 +vy .req r12 +vz .req r13 +m .req r14 +tmp .req m +vp .req m +dz .req vz +minXY .req z +maxXY .req r + +minX .req vx +maxX .req x +minY .req vy +maxY .req y + +.global sphereIsVisible_asm +sphereIsVisible_asm: + fiq_on + + ldr m, =gMatrixPtr + ldr m, [m] + + ldmia m!, {mx, my, mz, vx} + mla vx, mx, x, vx + mla vx, my, y, vx + mla vx, mz, z, vx + ldmia m!, {mx, my, mz, vy} + mla vy, mx, x, vy + mla vy, my, y, vy + mla vy, mz, z, vy + ldmia m!, {mx, my, mz, vz} + mla vz, mx, x, vz + mla vz, my, y, vz + mla vz, mz, z, vz + + cmp vz, #(VIEW_MAX << FIXED_SHIFT) + bhi .fail + + mov x, vx, asr #FIXED_SHIFT + mov y, vy, asr #FIXED_SHIFT + mov z, vz, asr #(FIXED_SHIFT + OT_SHIFT) + + add dz, z, z, lsr #2 + divLUT tmp, dz + mul x, tmp, x + mul y, tmp, y + mul r, tmp, r + + mov x, x, asr #(16 - PROJ_SHIFT) + mov y, y, asr #(16 - PROJ_SHIFT) + + sub minX, x, r, lsr #(16 - PROJ_SHIFT) + add maxX, x, r, lsr #(16 - PROJ_SHIFT) + sub minY, y, r, lsr #(16 - PROJ_SHIFT) + add maxY, y, r, lsr #(16 - PROJ_SHIFT) + + ldr vp, =viewportRel + ldmia vp, {minXY, maxXY} + + cmp maxX, minXY, asr #16 + ble .fail + cmp minX, maxXY, asr #16 + bge .fail + + lsl minXY, #16 + lsl maxXY, #16 + + cmp maxY, minXY, asr #16 + ble .fail + cmp minY, maxXY, asr #16 + bge .fail + + mov r0, #1 + fiq_off + bx lr + +.fail: + mov r0, #0 + fiq_off + bx lr diff --git a/src/platform/gba/asm/transformMesh.s b/src/platform/gba/asm/transformMesh.s new file mode 100644 index 00000000..1b186c2b --- /dev/null +++ b/src/platform/gba/asm/transformMesh.s @@ -0,0 +1,125 @@ +#include "common_asm.inc" + +vertices .req r0 // arg +count .req r1 // arg +intensity .req r2 // arg +vx .req intensity +vy .req r3 +vz .req r4 +x .req r5 +y .req r6 +z .req vx +mx0 .req r7 + +mx2 .req r8 +my2 .req r9 +mz2 .req r10 +mw2 .req r11 +res .req r12 +vg .req lr + +// FIQ regs +my0 .req r8 +mz0 .req r9 +mw0 .req r10 +mx1 .req r11 +my1 .req r12 +mz1 .req r13 +mw1 .req r14 + +ambient .req vz +tmp .req vy +dx .req vz +dy .req tmp +dz .req vz +m .req vz + +.global transformMesh_asm +transformMesh_asm: + stmfd sp!, {r4-r11, lr} + + ldr res, =gVerticesBase + ldr res, [res] + + ldr ambient, =gLightAmbient + ldr ambient, [ambient] + add vg, ambient, intensity + asr vg, #8 + // clamp spAmbient to 0..31 + cmp vg, #31 + movge vg, #31 + bic vg, vg, asr #31 + + ldr m, =gMatrixPtr + ldr m, [m] + fiq_on + ldmia m!, {mx0, my0, mz0, mw0, mx1, my1, mz1, mw1} + asr mw0, #FIXED_SHIFT + asr mw1, #FIXED_SHIFT + fiq_off + ldmia m, {mx2, my2, mz2, mw2} + asr mw2, #(FIXED_SHIFT + OT_SHIFT) + fiq_on + +.loop: + // unpack vertex + ldrsh vx, [vertices], #2 + ldrsh vy, [vertices], #2 + ldrsh vz, [vertices], #2 + + // transform x + mul x, mx0, vx + mla x, my0, vy, x + mla x, mz0, vz, x + add x, mw0, x, asr #(FIXED_SHIFT - MESH_SHIFT) + + // transform y + mul y, mx1, vx + mla y, my1, vy, y + mla y, mz1, vz, y + add y, mw1, y, asr #(FIXED_SHIFT - MESH_SHIFT) + fiq_off + + // transform z + mul z, mx2, vx + mla z, my2, vy, z + mla z, mz2, vz, z + add z, mw2, z, asr #(FIXED_SHIFT - MESH_SHIFT + OT_SHIFT) + + bic vg, #CLIP_MASK // clear clipping flags + + // z clipping + cmp z, #(VIEW_MIN >> OT_SHIFT) + movle z, #(VIEW_MIN >> OT_SHIFT) + orrle vg, #CLIP_PLANE + cmp z, #(VIEW_MAX >> OT_SHIFT) + movge z, #(VIEW_MAX >> OT_SHIFT) + orrge vg, #CLIP_PLANE + + // project + add dz, z, z, lsr #2 + divLUT tmp, dz + mul dx, x, tmp + mul dy, y, tmp + + asr x, dx, #(16 - PROJ_SHIFT) + asr y, dy, #(16 - PROJ_SHIFT) + add x, #(FRAME_WIDTH >> 1) + add y, #(FRAME_HEIGHT >> 1) + + // frame rect clipping + cmp x, #FRAME_WIDTH + cmpls y, #FRAME_HEIGHT + orrhi vg, #CLIP_FRAME + + // store the result + strh x, [res], #2 + strh y, [res], #2 + strh z, [res], #2 + strh vg, [res], #2 + + subs count, #1 + fiq_on_ne + bne .loop + + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/transformRoom.s b/src/platform/gba/asm/transformRoom.s new file mode 100644 index 00000000..752d6703 --- /dev/null +++ b/src/platform/gba/asm/transformRoom.s @@ -0,0 +1,153 @@ +#include "common_asm.inc" + +vertices .req r0 // arg +count .req r1 // arg +vx .req r2 +vy .req r3 +vz .req r4 +x .req vx +y .req r5 +z .req r6 +mx0 .req r7 + +mx2 .req r8 +my2 .req r9 +mz2 .req r10 +mw2 .req r11 +res .req r12 +vg .req lr + +// FIQ regs +my0 .req r8 +mz0 .req r9 +mw0 .req r10 +mx1 .req r11 +my1 .req r12 +mz1 .req r13 +mw1 .req r14 + +m .req vx +v .req vg +mask .req y + +minXY .req vy +maxXY .req vz + +tmp .req vy +dx .req vz +dy .req vy +dz .req vz +fog .req vz + +SP_MINXY = 0 +SP_MAXXY = 4 +SP_SIZE = 8 + +.global transformRoom_asm +transformRoom_asm: + stmfd sp!, {r4-r11, lr} + + ldr res, =gVerticesBase + ldr res, [res] + + ldr tmp, =viewportRel + ldmia tmp, {minXY, maxXY} + stmfd sp!, {minXY, maxXY} + + ldr m, =gMatrixPtr + ldr m, [m] + fiq_on + ldmia m!, {mx0, my0, mz0, mw0, mx1, my1, mz1, mw1} + asr mw0, #FIXED_SHIFT + asr mw1, #FIXED_SHIFT + fiq_off + ldmia m, {mx2, my2, mz2, mw2} + asr mw2, #(FIXED_SHIFT + OT_SHIFT) + +.loop: + // unpack vertex + ldr v, [vertices], #4 + + mov mask, #0xFF + and vx, mask, v + and vy, mask, v, lsr #8 + and vz, mask, v, lsr #16 + mov vg, v, lsr #(24 + 3) + + // transform z + mul z, mx2, vx + mla z, my2, vy, z + mla z, mz2, vz, z + add z, mw2, z, asr #(FIXED_SHIFT - 8 + OT_SHIFT) + + fiq_on + // transform y + mul y, mx1, vx + mla y, my1, vy, y + mla y, mz1, vz, y + add y, mw1, y, asr #(FIXED_SHIFT - 8) + + // transform x + mul x, mx0, vx + mla x, my0, vy, x + mla x, mz0, vz, x + add x, mw0, x, asr #(FIXED_SHIFT - 8) + fiq_off + + // fog + subs fog, z, #(FOG_MIN >> OT_SHIFT) + addgt vg, fog, lsr #(3 + FOG_SHIFT - OT_SHIFT) + cmpgt vg, #31 + movgt vg, #31 + + // z clipping + cmp z, #(VIEW_MIN >> OT_SHIFT) + movle z, #(VIEW_MIN >> OT_SHIFT) + orrle vg, #CLIP_PLANE + cmp z, #(VIEW_MAX >> OT_SHIFT) + movge z, #(VIEW_MAX >> OT_SHIFT) + orrge vg, #CLIP_PLANE + + // project + add dz, z, z, lsr #2 + divLUT tmp, dz + mul dx, x, tmp + mul dy, y, tmp + asr x, dx, #(16 - PROJ_SHIFT) + asr y, dy, #(16 - PROJ_SHIFT) + + // portal rect clipping + ldmia sp, {minXY, maxXY} + + cmp x, minXY, asr #16 + orrle vg, #CLIP_LEFT + cmp x, maxXY, asr #16 + orrge vg, #CLIP_RIGHT + + lsl minXY, #16 + lsl maxXY, #16 + + cmp y, minXY, asr #16 + orrle vg, #CLIP_TOP + cmp y, maxXY, asr #16 + orrge vg, #CLIP_BOTTOM + + add x, #(FRAME_WIDTH >> 1) + add y, #(FRAME_HEIGHT >> 1) + + // frame rect clipping + cmp x, #FRAME_WIDTH + cmpls y, #FRAME_HEIGHT + orrhi vg, #CLIP_FRAME + + // store the result + strh x, [res], #2 + strh y, [res], #2 + strh z, [res], #2 + strh vg, [res], #2 + + subs count, #1 + bne .loop + + add sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/transformRoomUW.s b/src/platform/gba/asm/transformRoomUW.s new file mode 100644 index 00000000..69d70b8d --- /dev/null +++ b/src/platform/gba/asm/transformRoomUW.s @@ -0,0 +1,184 @@ +#include "common_asm.inc" + +vertices .req r0 // arg +count .req r1 // arg +vx .req r2 +vy .req r3 +vz .req r4 +x .req vx +y .req r5 +z .req r6 +mx0 .req r7 + +mx2 .req r8 +my2 .req r9 +mz2 .req r10 +mw2 .req r11 +res .req r12 +vg .req lr + +// FIQ regs +my0 .req r8 +mz0 .req r9 +mw0 .req r10 +mx1 .req r11 +my1 .req r12 +mz1 .req r13 +mw1 .req r14 + +m .req vx +v .req vg +mask .req y + +minXY .req vy +maxXY .req vz + +tmp .req vy +dx .req vz +dy .req vy +dz .req vz +fog .req vz + +frame .req vy +caust .req vy +rand .req vz + +spMinXY .req vx +spMaxXY .req vy +spRandLUT .req vz +spFrame .req y +spCaustLUT .req z + +SP_MINXY = 0 +SP_MAXXY = 4 +SP_RAND = 8 +SP_FRAME = 12 +SP_CAUST = 16 +SP_SIZE = 20 + +.global transformRoomUW_asm +transformRoomUW_asm: + stmfd sp!, {r4-r11, lr} + + ldr res, =gVerticesBase + ldr res, [res] + + ldr tmp, =viewportRel + ldmia tmp, {spMinXY, spMaxXY} + + ldr spFrame, =gCausticsFrame + ldr spFrame, [spFrame] + + ldr spCaustLUT, =gCaustics + ldr spRandLUT, =gRandTable + + stmfd sp!, {spMinXY, spMaxXY, spRandLUT, spFrame, spCaustLUT} + + ldr m, =gMatrixPtr + ldr m, [m] + fiq_on + ldmia m!, {mx0, my0, mz0, mw0, mx1, my1, mz1, mw1} + asr mw0, #FIXED_SHIFT + asr mw1, #FIXED_SHIFT + fiq_off + ldmia m, {mx2, my2, mz2, mw2} + asr mw2, #(FIXED_SHIFT + OT_SHIFT) + +.loop: + // unpack vertex + ldr v, [vertices], #4 + + mov mask, #0xFF + and vx, mask, v + and vy, mask, v, lsr #8 + and vz, mask, v, lsr #16 + mov vg, v, lsr #(24 + 3) + + // transform z + mul z, mx2, vx + mla z, my2, vy, z + mla z, mz2, vz, z + add z, mw2, z, asr #(FIXED_SHIFT - 8 + OT_SHIFT) + + fiq_on + // transform y + mul y, mx1, vx + mla y, my1, vy, y + mla y, mz1, vz, y + add y, mw1, y, asr #(FIXED_SHIFT - 8) + + // transform x + mul x, mx0, vx + mla x, my0, vy, x + mla x, mz0, vz, x + add x, mw0, x, asr #(FIXED_SHIFT - 8) + fiq_off + + // caustics + ldr rand, [sp, #SP_RAND] + and tmp, count, #(MAX_RAND_TABLE - 1) + ldr rand, [rand, tmp, lsl #2] + ldr frame, [sp, #SP_FRAME] + add rand, frame + and rand, #(MAX_CAUSTICS - 1) + ldr caust, [sp, #SP_CAUST] + ldr caust, [caust, rand, lsl #2] + add vg, caust, asr #8 + + // fog + subs fog, z, #(FOG_MIN >> OT_SHIFT) + addgt vg, fog, lsr #(3 + FOG_SHIFT - OT_SHIFT) + cmpgt vg, #31 + movgt vg, #31 + + // z clipping + cmp z, #(VIEW_MIN >> OT_SHIFT) + movle z, #(VIEW_MIN >> OT_SHIFT) + orrle vg, #CLIP_PLANE + cmp z, #(VIEW_MAX >> OT_SHIFT) + movge z, #(VIEW_MAX >> OT_SHIFT) + orrge vg, #CLIP_PLANE + + // project + add dz, z, z, lsr #2 + divLUT tmp, dz + mul dx, x, tmp + mul dy, y, tmp + asr x, dx, #(16 - PROJ_SHIFT) + asr y, dy, #(16 - PROJ_SHIFT) + + // portal rect clipping + ldmia sp, {minXY, maxXY} + + cmp x, minXY, asr #16 + orrle vg, #CLIP_LEFT + cmp x, maxXY, asr #16 + orrge vg, #CLIP_RIGHT + + lsl minXY, #16 + lsl maxXY, #16 + + cmp y, minXY, asr #16 + orrle vg, #CLIP_TOP + cmp y, maxXY, asr #16 + orrge vg, #CLIP_BOTTOM + + add x, #(FRAME_WIDTH >> 1) + add y, #(FRAME_HEIGHT >> 1) + + // frame rect clipping + cmp x, #FRAME_WIDTH + cmpls y, #FRAME_HEIGHT + orrhi vg, #CLIP_FRAME + + // store the result + strh x, [res], #2 + strh y, [res], #2 + strh z, [res], #2 + strh vg, [res], #2 + + subs count, #1 + bne .loop + + add sp, #SP_SIZE + ldmfd sp!, {r4-r11, pc} diff --git a/src/platform/gba/asm/udiv32.s b/src/platform/gba/asm/udiv32.s new file mode 100644 index 00000000..a2f60ce5 --- /dev/null +++ b/src/platform/gba/asm/udiv32.s @@ -0,0 +1,79 @@ +@-------------------------------------------------------------------------------- +@ udiv.s +@-------------------------------------------------------------------------------- +@ Provides an implementation of unsigned division +@-------------------------------------------------------------------------------- + +@ Source code taken from https://www.chiark.greenend.org.uk/~theom/riscos/docs/ultimate/a252div.txt +@ r0: the numerator / r1: the denominator +@ after it, r0 has the quotient and r1 has the modulo + .section .iwram, "ax", %progbits + .align 2 + .arm + .global __aeabi_uidivmod + .type __aeabi_uidivmod STT_FUNC +__aeabi_uidivmod: + + .section .iwram, "ax", %progbits + .align 2 + .arm + .global __aeabi_uidiv + .type __aeabi_uidiv STT_FUNC +__aeabi_uidiv: + + @ Check for division by zero + cmp r1, #0 + bxeq lr + + .global udiv32pastzero +udiv32pastzero: + @ If n < d, just bail out as well + cmp r0, r1 @ n, d + movlo r1, r0 @ mod = n + movlo r0, #0 @ quot = 0 + bxlo lr + + @ Move the denominator to r2 and start to build a counter that + @ counts the difference on the number of bits on each numerator + @ and denominator + @ From now on: r0 = quot/num, r1 = mod, r2 = denom, r3 = counter + mov r2, r1 + mov r3, #28 @ first guess on difference + mov r1, r0, lsr #4 @ r1 = num >> 4 + + @ Iterate three times to get the counter up to 4-bit precision + cmp r2, r1, lsr #12 + suble r3, r3, #16 + movle r1, r1, lsr #16 + + cmp r2, r1, lsr #4 + suble r3, r3, #8 + movle r1, r1, lsr #8 + + cmp r2, r1 + suble r3, r3, #4 + movle r1, r1, lsr #4 + + @ shift the numerator by the counter and flip the sign of the denom + mov r0, r0, lsl r3 + adds r0, r0, r0 + rsb r2, r2, #0 + + @ dynamically jump to the exact copy of the iteration + add r3, r3, r3, lsl #1 @ counter *= 3 + add pc, pc, r3, lsl #2 @ jump + mov r0, r0 @ pipelining issues + + @ here, r0 = num << (r3 + 1), r1 = num >> (32-r3), r2 = -denom + @ now, the real iteration part + .global divIteration +divIteration: + .rept 32 + adcs r1, r2, r1, lsl #1 + sublo r1, r1, r2 + adcs r0, r0, r0 + .endr + + @ and then finally quit + @ r0 = quotient, r1 = remainder + bx lr diff --git a/src/platform/gba/checkROM.cpp b/src/platform/gba/checkROM.cpp new file mode 100644 index 00000000..8290e8fb --- /dev/null +++ b/src/platform/gba/checkROM.cpp @@ -0,0 +1,52 @@ +#include + +#define MEM_CHECK_MAGIC 14021968 +#define MEM_CHECK_SIZE 16 + +const int ROM_MAGIC[MEM_CHECK_SIZE] = { + MEM_CHECK_MAGIC + 0, + MEM_CHECK_MAGIC + 1, + MEM_CHECK_MAGIC + 2, + MEM_CHECK_MAGIC + 3, + MEM_CHECK_MAGIC + 4, + MEM_CHECK_MAGIC + 5, + MEM_CHECK_MAGIC + 6, + MEM_CHECK_MAGIC + 7, + MEM_CHECK_MAGIC + 8, + MEM_CHECK_MAGIC + 9, + MEM_CHECK_MAGIC + 10, + MEM_CHECK_MAGIC + 11, + MEM_CHECK_MAGIC + 12, + MEM_CHECK_MAGIC + 13, + MEM_CHECK_MAGIC + 14, + MEM_CHECK_MAGIC + 15, +}; + +EWRAM_CODE bool checkROM(unsigned int mask) +{ + REG_WSCNT = mask; + + // check sequential read (S) + for (int i = 0; i < MEM_CHECK_SIZE; i++) + { + if (*(volatile int*)&ROM_MAGIC[i] != (MEM_CHECK_MAGIC + i)) + { + REG_WSCNT = WS_ROM0_N4 | WS_ROM0_S2 | WS_PREFETCH; + return false; + } + } + + // check non-sequential read (N) + for (int i = 0, j = MEM_CHECK_SIZE - 1; i < MEM_CHECK_SIZE; i++, j--) + { + bool L = *(volatile int*)&ROM_MAGIC[i] == (MEM_CHECK_MAGIC + i); + bool R = *(volatile int*)&ROM_MAGIC[j] == (MEM_CHECK_MAGIC + j); + + if (L && R) continue; + + REG_WSCNT = WS_ROM0_N4 | WS_ROM0_S2 | WS_PREFETCH; + return false; + } + + return true; +} \ No newline at end of file diff --git a/src/platform/gba/data/GYM.PKD b/src/platform/gba/data/GYM.PKD new file mode 100644 index 00000000..ecf5b4bc Binary files /dev/null and b/src/platform/gba/data/GYM.PKD differ diff --git a/src/platform/gba/data/LEVEL1.PKD b/src/platform/gba/data/LEVEL1.PKD new file mode 100644 index 00000000..0d6a6540 Binary files /dev/null and b/src/platform/gba/data/LEVEL1.PKD differ diff --git a/src/platform/gba/data/LEVEL2.PKD b/src/platform/gba/data/LEVEL2.PKD new file mode 100644 index 00000000..b78b2e3f Binary files /dev/null and b/src/platform/gba/data/LEVEL2.PKD differ diff --git a/src/platform/gba/data/TITLE.PKD b/src/platform/gba/data/TITLE.PKD new file mode 100644 index 00000000..b191d337 Binary files /dev/null and b/src/platform/gba/data/TITLE.PKD differ diff --git a/src/platform/gba/data/TITLE.SCR b/src/platform/gba/data/TITLE.SCR new file mode 100644 index 00000000..3a25b4a8 Binary files /dev/null and b/src/platform/gba/data/TITLE.SCR differ diff --git a/src/platform/gba/data/TRACKS.AD4 b/src/platform/gba/data/TRACKS.AD4 new file mode 100644 index 00000000..130ac066 Binary files /dev/null and b/src/platform/gba/data/TRACKS.AD4 differ diff --git a/src/platform/gba/deploy.sh b/src/platform/gba/deploy.sh new file mode 100644 index 00000000..3b290301 --- /dev/null +++ b/src/platform/gba/deploy.sh @@ -0,0 +1,2 @@ +make +./mGBA.exe C:\\Projects\\OpenLara\\src\\platform\\gba\\OpenLara.gba diff --git a/src/platform/gba/labels.png b/src/platform/gba/labels.png new file mode 100644 index 00000000..819d2e63 Binary files /dev/null and b/src/platform/gba/labels.png differ diff --git a/src/platform/gba/main.cpp b/src/platform/gba/main.cpp new file mode 100644 index 00000000..e5b55d8d --- /dev/null +++ b/src/platform/gba/main.cpp @@ -0,0 +1,631 @@ +#include "game.h" + +EWRAM_DATA int32 fps; +EWRAM_DATA int32 frameIndex = 0; +EWRAM_DATA int32 fpsCounter = 0; +EWRAM_DATA uint32 curSoundBuffer = 0; + +#ifdef __GBA_WIN__ +const void* TRACKS_AD4; +const void* TITLE_SCR; +const void* levelData; + +HWND hWnd; + +LARGE_INTEGER g_timer; +LARGE_INTEGER g_current; + +#define WND_WIDTH 240*4 +#define WND_HEIGHT 160*4 + +uint16 MEM_PAL_BG[256]; +uint32 SCREEN[FRAME_WIDTH * FRAME_HEIGHT]; + +void osSetPalette(const uint16* palette) +{ + memcpy(MEM_PAL_BG, palette, 256 * 2); +} + +int32 osGetSystemTimeMS() +{ + return GetTickCount(); +} + +bool osSaveSettings() +{ + FILE* f = fopen("settings.dat", "wb"); + if (!f) return false; + fwrite(&gSettings, sizeof(gSettings), 1, f); + fclose(f); + return true; +} + +bool osLoadSettings() +{ + FILE* f = fopen("settings.dat", "rb"); + if (!f) return false; + uint8 version; + fread(&version, 1, 1, f); + if (version != gSettings.version) { + fclose(f); + return false; + } + fread((uint8*)&gSettings + 1, sizeof(gSettings) - 1, 1, f); + fclose(f); + return true; +} + +bool osCheckSave() +{ + FILE* f = fopen("savegame.dat", "rb"); + if (!f) return false; + fclose(f); + return true; +} + +bool osSaveGame() +{ + FILE* f = fopen("savegame.dat", "wb"); + if (!f) return false; + fwrite(&gSaveGame, sizeof(gSaveGame), 1, f); + fwrite(&gSaveData, gSaveGame.dataSize, 1, f); + fclose(f); + return true; +} + +bool osLoadGame() +{ + FILE* f = fopen("savegame.dat", "rb"); + if (!f) return false; + + uint32 version; + fread(&version, sizeof(version), 1, f); + + if (SAVEGAME_VER != version) + { + fclose(f); + return false; + } + + fread(&gSaveGame.dataSize, sizeof(gSaveGame) - sizeof(version), 1, f); + fread(&gSaveData, gSaveGame.dataSize, 1, f); + fclose(f); + return true; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) {} + +extern int8 soundBuffer[2 * SND_SAMPLES + 32]; // 32 bytes of silence for DMA overrun while interrupt + +HWAVEOUT waveOut; +WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 1, SND_OUTPUT_FREQ, SND_OUTPUT_FREQ, 1, 8, sizeof(waveFmt) }; +WAVEHDR waveBuf[2]; + +void soundInit() +{ + sndInit(); + + if (waveOutOpen(&waveOut, WAVE_MAPPER, &waveFmt, (INT_PTR)hWnd, 0, CALLBACK_WINDOW) != MMSYSERR_NOERROR) + return; + + memset(&waveBuf, 0, sizeof(waveBuf)); + for (int i = 0; i < 2; i++) + { + WAVEHDR *waveHdr = waveBuf + i; + waveHdr->dwBufferLength = SND_SAMPLES; + waveHdr->lpData = (LPSTR)(soundBuffer + i * SND_SAMPLES); + waveOutPrepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + waveOutWrite(waveOut, waveHdr, sizeof(WAVEHDR)); + } +} + +void soundFill() +{ + WAVEHDR *waveHdr = waveBuf + curSoundBuffer; + waveOutUnprepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + sndFill((int8*)waveHdr->lpData); + waveOutPrepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + waveOutWrite(waveOut, waveHdr, sizeof(WAVEHDR)); + curSoundBuffer ^= 1; +} + +HDC hDC; + +void blit() +{ + for (int i = 0; i < FRAME_WIDTH * FRAME_HEIGHT; i++) + { + uint16 c = MEM_PAL_BG[((uint8*)fb)[i]]; + SCREEN[i] = (((c << 3) & 0xFF) << 16) | ((((c >> 5) << 3) & 0xFF) << 8) | ((c >> 10 << 3) & 0xFF) | 0xFF000000; + } + const BITMAPINFO bmi = { sizeof(BITMAPINFOHEADER), FRAME_WIDTH, -FRAME_HEIGHT, 1, 32, BI_RGB, 0, 0, 0, 0, 0 }; + StretchDIBits(hDC, 0, 0, WND_WIDTH, WND_HEIGHT, 0, 0, FRAME_WIDTH, FRAME_HEIGHT, SCREEN, &bmi, DIB_RGB_COLORS, SRCCOPY); +} + +LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_ACTIVATE: + { + keys = 0; + break; + } + + case WM_DESTROY : + { + PostQuitMessage(0); + break; + } + + case WM_KEYDOWN : + case WM_KEYUP : + case WM_SYSKEYUP : + case WM_SYSKEYDOWN : + { + InputKey key = IK_NONE; + switch (wParam) { + case VK_UP : key = IK_UP; break; + case VK_RIGHT : key = IK_RIGHT; break; + case VK_DOWN : key = IK_DOWN; break; + case VK_LEFT : key = IK_LEFT; break; + case 'A' : key = IK_B; break; + case 'S' : key = IK_A; break; + case 'Q' : key = IK_L; break; + case 'W' : key = IK_R; break; + case VK_RETURN : key = IK_START; break; + case VK_SPACE : key = IK_SELECT; break; + } + + if (wParam == '1') players[0]->extraL->goalWeapon = WEAPON_PISTOLS; + if (wParam == '2') players[0]->extraL->goalWeapon = WEAPON_MAGNUMS; + if (wParam == '3') players[0]->extraL->goalWeapon = WEAPON_UZIS; + if (wParam == '4') players[0]->extraL->goalWeapon = WEAPON_SHOTGUN; + + if (msg != WM_KEYUP && msg != WM_SYSKEYUP) { + keys |= key; + } else { + keys &= ~key; + } + break; + } + + case MM_WOM_DONE : + { + soundFill(); + break; + } + + default : + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} + +const void* osLoadScreen(LevelID id) +{ + return TITLE_SCR; +} + +const void* osLoadLevel(LevelID id) +{ + // level1 + char buf[32]; + + delete[] levelData; + + sprintf(buf, "data/%s.PKD", (const char*)gLevelInfo[id].data); + + FILE *f = fopen(buf, "rb"); + + if (!f) + return NULL; + + { + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + levelData = data; + } + +// tracks + if (!TRACKS_AD4) + { + FILE *f = fopen("data/TRACKS.AD4", "rb"); + if (!f) + return NULL; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + TRACKS_AD4 = data; + } + + if (!TITLE_SCR) + { + FILE *f = fopen("data/TITLE.SCR", "rb"); + if (!f) + return NULL; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + TITLE_SCR = data; + } + + return (void*)levelData; +} + +int main(void) +{ + RECT r = { 0, 0, WND_WIDTH, WND_HEIGHT }; + + AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false); + int wx = (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2; + int wy = (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2; + + hWnd = CreateWindow("static", "OpenLara GBA", WS_OVERLAPPEDWINDOW, wx + r.left, wy + r.top, r.right - r.left, r.bottom - r.top, 0, 0, 0, 0); + hDC = GetDC(hWnd); + + SetWindowLong(hWnd, GWL_WNDPROC, (LONG)&wndProc); + ShowWindow(hWnd, SW_SHOWDEFAULT); + + soundInit(); + + gameInit(); + + MSG msg; + + int32 startTime = GetTickCount() - 33; + int32 lastFrame = 0; + + do { + if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + #ifdef _DEBUG + Sleep(4); + #endif + int32 frame = (GetTickCount() - startTime) / 33; + if (GetAsyncKeyState('R')) frame /= 10; + + int32 count = frame - lastFrame; + if (GetAsyncKeyState('T')) count *= 10; + gameUpdate(count); + lastFrame = frame; + + gameRender(); + + blit(); + } + } while (msg.message != WM_QUIT); + + return 0; +} +#else +void osSetPalette(const uint16* palette) +{ + memcpy((uint16*)MEM_PAL_BG, palette, 256 * 2); +} + +int32 osGetSystemTimeMS() +{ + return 0; // TODO +} + +const char* SRAM_ID = "SRAM_Vnnn\0\0"; +const uint8 SRAM_MAGIC[4] = { 14, 02, 19, 68 }; + +int32 byteCopy(volatile uint8* dst, const volatile uint8* src, uint32 count) +{ + for (uint32 i = 0; i < count; i++) + { + *dst++ = *src++; + } + return count; +} + +bool checkSRAM(volatile uint8* src) +{ + for (uint32 i = 0; i < sizeof(SRAM_MAGIC); i++) + { + if (SRAM_MAGIC[i] != *src++) + return false; + } + return true; +} + +bool osSaveSettings() +{ + volatile uint8* ptr = (uint8*)MEM_SRAM; + + byteCopy(ptr, SRAM_MAGIC, 4); + if (!checkSRAM(ptr)) + return false; + ptr += 4; + + volatile uint8* data = (uint8*)&gSettings; + byteCopy(ptr, data, sizeof(gSettings)); + + return true; +} + +bool osLoadSettings() +{ + volatile uint8* ptr = (uint8*)MEM_SRAM; + + if (!checkSRAM(ptr)) + return false; + ptr += 4; + + if (SETTINGS_VER != *ptr) + return false; + + volatile uint8* data = (uint8*)&gSettings; + byteCopy(data, ptr, sizeof(gSettings)); + + return true; +} + +bool osCheckSave() +{ + volatile uint8* ptr = (uint8*)MEM_SRAM + SETTINGS_SIZE; + + if (!checkSRAM(ptr)) + return false; + ptr += 4; + + uint32 version; + byteCopy((uint8*)&version, ptr, sizeof(version)); + + return (SAVEGAME_VER == version); +} + +bool osSaveGame() +{ + volatile uint8* ptr = (uint8*)MEM_SRAM + SETTINGS_SIZE; + + byteCopy(ptr, SRAM_MAGIC, 4); + if (!checkSRAM(ptr)) + return false; + + ptr += 4; + ptr += byteCopy(ptr, (uint8*)&gSaveGame, sizeof(gSaveGame)); + byteCopy(ptr, (uint8*)&gSaveData, gSaveGame.dataSize); + return true; +} + +bool osLoadGame() +{ + if (!osCheckSave()) + return false; + + volatile uint8* ptr = (uint8*)MEM_SRAM + SETTINGS_SIZE + 4; // skip magic + + ptr += byteCopy((uint8*)&gSaveGame, ptr, sizeof(gSaveGame)); + byteCopy((uint8*)&gSaveData, ptr, gSaveGame.dataSize); + + return true; +} + +#define GPIO_RUMBLE_DATA (*(vu16*)0x80000C4) +#define GPIO_RUMBLE_DIRECTION (*(vu16*)0x80000C6) +#define GPIO_RUMBLE_CONTROL (*(vu16*)0x80000C8) +#define GPIO_RUMBLE_MASK (1 << 3) + +#define CART_RUMBLE_TICKS 6 + +EWRAM_DATA int32 cartRumbleTick = 0; + +void rumbleInit() +{ + GPIO_RUMBLE_DIRECTION = GPIO_RUMBLE_MASK; + GPIO_RUMBLE_CONTROL = 1; +} + +void rumbleSet(bool enable) +{ + if (enable) { + GPIO_RUMBLE_DATA |= GPIO_RUMBLE_MASK; + cartRumbleTick = CART_RUMBLE_TICKS; + } else { + GPIO_RUMBLE_DATA &= ~GPIO_RUMBLE_MASK; + cartRumbleTick = 0; + } +} + +void rumbleUpdate(int32 frames) +{ + if (!cartRumbleTick) + return; + + cartRumbleTick -= frames; + + if (cartRumbleTick <= 0) { + rumbleSet(false); + } +} + +void osJoyVibrate(int32 index, int32 L, int32 R) +{ + if (!gSettings.controls_vibration) + return; + rumbleSet(X_MAX(L, R) > 0); +} + +void updateInput() +{ + keys = 0; + key_poll(); + if (key_is_down(KEY_UP)) keys |= IK_UP; + if (key_is_down(KEY_RIGHT)) keys |= IK_RIGHT; + if (key_is_down(KEY_DOWN)) keys |= IK_DOWN; + if (key_is_down(KEY_LEFT)) keys |= IK_LEFT; + if (key_is_down(KEY_A)) keys |= IK_A; + if (key_is_down(KEY_B)) keys |= IK_B; + if (key_is_down(KEY_L)) keys |= IK_L; + if (key_is_down(KEY_R)) keys |= IK_R; + if (key_is_down(KEY_START)) keys |= IK_START; + if (key_is_down(KEY_SELECT)) keys |= IK_SELECT; +} + +extern int8 soundBuffer[2 * SND_SAMPLES + 32]; + +void soundInit() +{ + sndInit(); + + REG_SOUNDCNT_X = SSTAT_ENABLE; + REG_SOUNDCNT_H = SDS_ATMR0 | SDS_AL | SDS_AR | SDS_ARESET | SDS_A100; + REG_TM0D = 65536 - (16777216 / SND_OUTPUT_FREQ); + REG_TM0CNT = TM_ENABLE; + REG_DMA1DAD = (u32)®_FIFO_A; +} + +void soundFill() +{ + if (curSoundBuffer) { + REG_DMA1CNT = 0; + REG_DMA1SAD = (u32)soundBuffer; + REG_DMA1CNT = DMA_DST_FIXED | DMA_REPEAT | DMA_16 | DMA_AT_FIFO | DMA_ENABLE; + } + + sndFill(soundBuffer + curSoundBuffer); + curSoundBuffer ^= SND_SAMPLES; +} + +void vblank() +{ + frameIndex++; + soundFill(); +} + +#define MEM_CHECK_MAGIC 14021968 + +extern bool checkROM(uint32 mask); // should be in IWRAM + +const uint32 WSCNT_MASK[] = { + WS_ROM0_N2 | WS_ROM0_S1 | WS_PREFETCH, + WS_ROM0_N3 | WS_ROM0_S1 | WS_PREFETCH, +}; + +void boostROM() +{ + for (int32 i = 0; i < X_COUNT(WSCNT_MASK); i++) + { + if (checkROM(WSCNT_MASK[i])) { + break; + } + } +} + +void boostEWRAM() +{ + // Undocumented - Internal Memory Control (R/W) + vu32& fastAccessReg = *(vu32*)(REG_BASE+0x0800); + + fastAccessReg = 0x0E000020; // fast EWRAM + + vu32* fastAccessMem = (vu32*)gSpheres; // check EWRAM access + // write + for (int32 i = 0; i < 16; i++) + { + fastAccessMem[i] = MEM_CHECK_MAGIC + i; + } + // read + for (int32 i = 0; i < 16; i++) + { + if (fastAccessMem[i] != vu32(MEM_CHECK_MAGIC + i)) + { + fastAccessReg = 0x0D000020; // device doesn't support this feature, revert reg value + } + } +} + +const void* osLoadScreen(LevelID id) +{ + return TITLE_SCR; +} + +const void* osLoadLevel(LevelID id) +{ + return gLevelInfo[id].data; +} + +int main(void) +{ + if (intptr_t(divTable) != MEM_EWRAM) return 0; + if (intptr_t(gLightmap) != MEM_IWRAM) return 0; + + irq_init(NULL); + irq_add(II_VBLANK, vblank); + irq_enable(II_VBLANK); + + boostROM(); + boostEWRAM(); + + rumbleInit(); + soundInit(); + + gameInit(); + + uint16 mode = DCNT_BG2 | DCNT_PAGE | DCNT_MODE4; + + int32 lastFrameIndex = -1; + + while (1) + { + updateInput(); + + int32 frame = frameIndex / 2; + int32 delta = frame - lastFrameIndex; + + if (!delta) + continue; + lastFrameIndex = frame; + + rumbleUpdate(delta); + + gameUpdate(delta); + + #ifdef PROFILING + VBlankIntrWait(); + #else + if (gSettings.video_vsync) { + VBlankIntrWait(); + } + #endif + + REG_DISPCNT = (mode ^= DCNT_PAGE); + fb ^= VRAM_PAGE_SIZE; + + gameRender(); + + fpsCounter++; + if (frameIndex >= 60) + { + frameIndex -= 60; + lastFrameIndex -= 30; + + fps = fpsCounter; + + fpsCounter = 0; + } + } + + return 0; +} +#endif diff --git a/src/platform/gba/packer/IMA.h b/src/platform/gba/packer/IMA.h new file mode 100644 index 00000000..c38b761e --- /dev/null +++ b/src/platform/gba/packer/IMA.h @@ -0,0 +1,163 @@ +#ifndef H_IMA +#define H_IMA + +#include "common.h" + +#define CLIP(x,lo,hi) \ + if ( x < lo ) \ + { \ + x = lo; \ + } \ + else if ( x > hi ) \ + { \ + x = hi; \ + } + +// ADPCM.h - Common ADPCM definitions +static short gIndexDeltas[16] = { + -1,-1,-1,-1, 2, 4, 6, 8, + -1,-1,-1,-1, 2, 4, 6, 8 +}; + +/* DVI ADPCM step table */ +static short gStepSizes[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, + 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, + 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, + 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, + 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, + 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, + 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, +11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, +32767 }; + +// Intel DVI ADPCM (ADP4) encoder based on the original SoundHack code https://github.com/tomerbe/SoundHack +long lastEstimateL, stepSizeL, stepIndexL; +long lastEstimateR, stepSizeR, stepIndexR; + +char EncodeDelta( long stepSize, long delta ) +{ + char encodedSample = 0; + + if ( delta < 0L ) + { + encodedSample = 8; + delta = -delta; + } + if ( delta >= stepSize ) + { + encodedSample |= 4; + delta -= stepSize; + } + stepSize = stepSize >> 1; + if ( delta >= stepSize ) + { + encodedSample |= 2; + delta -= stepSize; + } + stepSize = stepSize >> 1; + if ( delta >= stepSize ) encodedSample |= 1; + + return ( encodedSample ); +} + +long DecodeDelta( long stepSize, char encodedSample ) +{ + long delta = 0; + + if( encodedSample & 4) delta = stepSize; + if( encodedSample & 2) delta += (stepSize >> 1); + if( encodedSample & 1) delta += (stepSize >> 2); + delta += (stepSize >> 3); + if (encodedSample & 8) delta = -delta; + + return( delta ); +} + +char ADDVIEncode(short shortOne, short shortTwo, long channels) +{ + long delta; + unsigned char encodedSample, outputByte; + + outputByte = 0; + +/* First sample or left sample to be packed in first nibble */ +/* calculate delta */ + delta = shortOne - lastEstimateL; + CLIP(delta, -32768L, 32767L); + +/* encode delta relative to the current stepsize */ + encodedSample = EncodeDelta(stepSizeL, delta); + +/* pack first nibble */ + outputByte = 0x00F0 & (encodedSample<<4); + +/* decode ADPCM code value to reproduce delta and generate an estimated InputSample */ + lastEstimateL += DecodeDelta(stepSizeL, encodedSample); + CLIP(lastEstimateL, -32768L, 32767L); + +/* adapt stepsize */ + stepIndexL += gIndexDeltas[encodedSample]; + CLIP(stepIndexL, 0, 88); + stepSizeL = gStepSizes[stepIndexL]; + + if(channels == 2L) + { +/* calculate delta for second sample */ + delta = shortTwo - lastEstimateR; + CLIP(delta, -32768L, 32767L); + +/* encode delta relative to the current stepsize */ + encodedSample = EncodeDelta(stepSizeR, delta); + +/* pack second nibble */ + outputByte |= 0x000F & encodedSample; + +/* decode ADPCM code value to reproduce delta and generate an estimated InputSample */ + lastEstimateR += DecodeDelta(stepSizeR, encodedSample); + CLIP(lastEstimateR, -32768L, 32767L); + +/* adapt stepsize */ + stepIndexR += gIndexDeltas[encodedSample]; + CLIP(stepIndexR, 0, 88); + stepSizeR = gStepSizes[stepIndexR]; + } + else + { +/* calculate delta for second sample */ + delta = shortTwo - lastEstimateL; + CLIP(delta, -32768L, 32767L); + +/* encode delta relative to the current stepsize */ + encodedSample = EncodeDelta(stepSizeL, delta); + +/* pack second nibble */ + outputByte |= 0x000F & encodedSample; + +/* decode ADPCM code value to reproduce delta and generate an estimated InputSample */ + lastEstimateL += DecodeDelta(stepSizeL, encodedSample); + CLIP(lastEstimateL, -32768L, 32767L); + +/* adapt stepsize */ + stepIndexL += gIndexDeltas[encodedSample]; + CLIP(stepIndexL, 0, 88); + stepSizeL = gStepSizes[stepIndexL]; + } + return(outputByte); +} + +void BlockADDVIEncode(uint8 *buffer, short *samples, long numSamples, long channels) +{ + long i, j; + + lastEstimateL = lastEstimateR = 0L; + stepSizeL = stepSizeR = 7L; + stepIndexL = stepIndexR = 0L; + + for(i = j = 0; i < numSamples; i += 2, j++) + { + buffer[j] = ADDVIEncode(samples[i + 0], samples[i + 1], channels); + } +} + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/TR1_PC.h b/src/platform/gba/packer/TR1_PC.h new file mode 100644 index 00000000..f7abe308 --- /dev/null +++ b/src/platform/gba/packer/TR1_PC.h @@ -0,0 +1,1058 @@ +#ifndef H_TR1_PC +#define H_TR1_PC + +#include "common.h" + +#pragma pack(1) +struct TR1_PC +{ + struct Tile + { + uint8 indices[256 * 256]; + }; + + struct Palette + { + uint8 colors[256 * 3]; + }; + + struct Quad + { + uint16 indices[4]; + uint16 flags; + + static int cmp(const Quad* a, const Quad* b) + { + return a->indices[0] - b->indices[0]; + } + }; + + struct Triangle + { + uint16 indices[3]; + uint16 flags; + }; + + struct Room + { + struct Info + { + int32 x; + int32 z; + int32 yBottom; + int32 yTop; + int32 dataSize; + }; + + struct Vertex + { + vec3s pos; + int16 lighting; + }; + + struct Sprite + { + uint16 index; + uint16 texture; + }; + + struct Portal + { + int16 roomIndex; + vec3s normal; + vec3s vertices[4]; + + void write(FileStream &f) const + { + f.write(roomIndex); + f.write(normal.x); + f.write(normal.y); + f.write(normal.z); + for (int32 i = 0; i < 4; i++) + { + f.write(vertices[i].x); + f.write(vertices[i].y); + f.write(vertices[i].z); + } + } + }; + + struct Sector + { + uint16 floorIndex; + uint16 boxIndex; + uint8 roomBelow; + int8 floor; + uint8 roomAbove; + int8 ceiling; + + void write(FileStream &f) const + { + f.write(floorIndex); + f.write(boxIndex); + f.write(roomBelow); + f.write(floor); + f.write(roomAbove); + f.write(ceiling); + } + }; + + struct Light + { + vec3i pos; + uint16 intensity; + int32 radius; + }; + + struct Mesh + { + vec3i pos; + int16 angleY; + uint16 intensity; + uint16 id; + }; + + Info info; + + int16 vCount; + Vertex* vertices; + + int16 qCount; + Quad* quads; + + int16 tCount; + Triangle* triangles; + + int16 sCount; + Sprite* sprites; + + int16 pCount; + Portal* portals; + + uint16 zSectors; + uint16 xSectors; + Sector* sectors; + + uint16 ambient; + + uint16 lCount; + Light* lights; + + uint16 mCount; + Mesh* meshes; + + int16 alternateRoom; + uint16 flags; + }; + + struct FloorData + { + uint16 value; + + void write(FileStream &f) const + { + f.write(value); + } + }; + + struct Animation + { + uint32 frameOffset; + + uint8 frameRate; + uint8 frameSize; + uint16 state; + + uint32 speed; + uint32 accel; + + uint16 frameBegin; + uint16 frameEnd; + + uint16 nextAnimIndex; + uint16 nextFrameIndex; + + uint16 statesCount; + uint16 statesStart; + + uint16 commandsCount; + uint16 commandsStart; + + void write(FileStream &f) const + { + f.write(frameOffset); + f.write(frameRate); + f.write(frameSize); + f.write(state); + f.write(speed); + f.write(accel); + f.write(frameBegin); + f.write(frameEnd); + f.write(nextAnimIndex); + f.write(nextFrameIndex); + f.write(statesCount); + f.write(statesStart); + f.write(commandsCount); + f.write(commandsStart); + } + }; + + struct AnimState + { + uint16 state; + uint16 rangesCount; + uint16 rangesStart; + }; + + struct AnimRange + { + int16 frameBegin; + int16 frameEnd; + int16 nextAnimIndex; + int16 nextFrameIndex; + + void write(FileStream &f) const + { + f.write(frameBegin); + f.write(frameEnd); + f.write(nextAnimIndex); + f.write(nextFrameIndex); + } + }; + + struct Model + { + uint32 type; + uint16 count; + uint16 start; + uint32 nodeIndex; + uint32 frameIndex; + uint16 animIndex; + }; + + struct MinMax + { + int16 minX, maxX; + int16 minY, maxY; + int16 minZ, maxZ; + }; + + struct StaticMesh + { + uint32 id; + uint16 meshIndex; + MinMax vbox; + MinMax cbox; + uint16 flags; + }; + + struct ObjectTexture + { + uint16 attribute; + uint16 tile; + union { + struct { uint8 xh0, x0, yh0, y0; }; + uint32 uv0; + }; + + union { + struct { uint8 xh1, x1, yh1, y1; }; + uint32 uv1; + }; + + union { + struct { uint8 xh2, x2, yh2, y2; }; + uint32 uv2; + }; + + union { + struct { uint8 xh3, x3, yh3, y3; }; + uint32 isQuad; + uint32 uv3; + }; + }; + + struct SpriteTexture + { + uint16 tile; + uint8 u, v; + uint16 w, h; + int16 l, t, r, b; + }; + + struct SpriteSequence + { + uint16 type; + uint16 unused; + int16 count; + uint16 start; + + void write(FileStream &f) const + { + f.write(type); + f.write(unused); + f.write(count); + f.write(start); + } + }; + + struct Camera + { + vec3i pos; + int16 roomIndex; + uint16 flags; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(roomIndex); + f.write(flags); + } + }; + + struct SoundSource + { + vec3i pos; + uint16 id; + uint16 flags; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(id); + f.write(flags); + } + }; + + struct Box + { + int32 minZ, maxZ; + int32 minX, maxX; + int16 floor; + int16 overlap; + }; + + struct Zone + { + uint16* ground1; + uint16* ground2; + uint16* fly; + }; + + struct Item + { + uint16 type; + int16 roomIndex; + vec3i pos; + int16 angleY; + int16 intensity; + uint16 flags; + }; + + struct CameraFrame + { + vec3s target; + vec3s pos; + int16 fov; + int16 roll; + + void write(FileStream &f) const + { + f.write(target.x); + f.write(target.y); + f.write(target.z); + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(fov); + f.write(roll); + } + }; + + struct SoundInfo + { + uint16 index; + uint16 volume; + uint16 chance; + + union { + struct { + uint16 mode:2, count:4, unused:6, camera:1, pitch:1, gain:1, :1; + }; + + uint16 value; + } flags; + + void write(FileStream &f) const + { + f.write(index); + f.write(volume); + f.write(chance); + f.write(flags.value); + } + }; + + enum NodeFlag + { + NODE_FLAG_POP = (1 << 0), + NODE_FLAG_PUSH = (1 << 1), + NODE_FLAG_ROTX = (1 << 2), + NODE_FLAG_ROTY = (1 << 3), + NODE_FLAG_ROTZ = (1 << 4), + }; + + struct Node + { + uint32 flags; + vec3i pos; + }; + + LevelID id; + + int32 tilesCount; + Tile* tiles; + + int16 roomsCount; + Room* rooms; + + int32 floorsCount; + FloorData* floors; + + int32 meshDataSize; + uint16* meshData; + + int32 meshOffsetsCount; + uint32* meshOffsets; + + int32 animsCount; + Animation* anims; + + int32 statesCount; + AnimState* states; + + int32 rangesCount; + AnimRange* ranges; + + int32 commandsCount; + int16* commands; + + int32 nodesDataSize; + uint32* nodesData; + + int32 frameDataSize; + uint16* frameData; + + int32 modelsCount; + Model* models; + + int32 staticMeshesCount; + StaticMesh* staticMeshes; + + int32 objectTexturesCount; + ObjectTexture* objectTextures; + + int32 spriteTexturesCount; + SpriteTexture* spriteTextures; + + int32 spriteSequencesCount; + SpriteSequence* spriteSequences; + + int32 camerasCount; + Camera* cameras; + + int32 soundSourcesCount; + SoundSource* soundSources; + + int32 boxesCount; + Box* boxes; + + int32 overlapsCount; + uint16* overlaps; + + Zone zones[2]; + + int32 animTexDataSize; + uint16* animTexData; + + int32 itemsCount; + Item* items; + + uint8 lightmap[32 * 256]; + Palette palette; + + uint16 cameraFramesCount; + CameraFrame* cameraFrames; + + uint16 demoDataSize; + uint8* demoData; + + int16 soundMap[256]; + int32 soundInfoCount; + SoundInfo* soundInfo; + + int32 soundDataSize; + uint8* soundData; + + int32 soundOffsetsCount; + uint32* soundOffsets; + + TR1_PC(FileStream &f, LevelID id) + { + this->id = id; + tiles = NULL; + + uint32 magic; + f.read(magic); + + if (magic != 0x00000020) + { + printf("Unsupported level format\n"); + return; + } + + f.readArray(tiles, tilesCount); + f.seek(4); + + f.read(roomsCount); + rooms = new Room[roomsCount]; + + for (int32 i = 0; i < roomsCount; i++) + { + Room* room = rooms + i; + + f.read(room->info); + f.readArray(room->vertices, room->vCount); + f.readArray(room->quads, room->qCount); + f.readArray(room->triangles, room->tCount); + f.readArray(room->sprites, room->sCount); + f.readArray(room->portals, room->pCount); + f.read(room->zSectors); + f.read(room->xSectors); + f.read(room->sectors, room->zSectors * room->xSectors); + f.read(room->ambient); + f.readArray(room->lights, room->lCount); + f.readArray(room->meshes, room->mCount); + f.read(room->alternateRoom); + f.read(room->flags); + } + + f.readArray(floors, floorsCount); + + f.readArray(meshData, meshDataSize); + f.readArray(meshOffsets, meshOffsetsCount); + f.readArray(anims, animsCount); + f.readArray(states, statesCount); + f.readArray(ranges, rangesCount); + f.readArray(commands, commandsCount); + f.readArray(nodesData, nodesDataSize); + f.readArray(frameData, frameDataSize); + f.readArray(models, modelsCount); + f.readArray(staticMeshes, staticMeshesCount); + f.readArray(objectTextures, objectTexturesCount); + f.readArray(spriteTextures, spriteTexturesCount); + f.readArray(spriteSequences, spriteSequencesCount); + + f.readArray(cameras, camerasCount); + f.readArray(soundSources, soundSourcesCount); + f.readArray(boxes, boxesCount); + f.readArray(overlaps, overlapsCount); + + for (int32 i = 0; i < 2; i++) + { + f.read(zones[i].ground1, boxesCount); + f.read(zones[i].ground2, boxesCount); + f.read(zones[i].fly, boxesCount); + } + + f.readArray(animTexData, animTexDataSize); + f.readArray(items, itemsCount); + f.read(lightmap); + f.read(palette); + f.readArray(cameraFrames, cameraFramesCount); + f.readArray(demoData, demoDataSize); + + f.read(soundMap); + f.readArray(soundInfo, soundInfoCount); + f.readArray(soundData, soundDataSize); + f.readArray(soundOffsets, soundOffsetsCount); + + palette.colors[0] = 0; + palette.colors[1] = 0; + palette.colors[2] = 0; + } + + ~TR1_PC() + { + delete[] tiles; + + for (int32 i = 0; i < roomsCount; i++) + { + Room* room = rooms + i; + delete[] room->vertices; + delete[] room->quads; + delete[] room->triangles; + delete[] room->sprites; + delete[] room->portals; + delete[] room->sectors; + delete[] room->lights; + delete[] room->meshes; + } + + delete[] rooms; + delete[] floors; + delete[] meshData; + delete[] meshOffsets; + delete[] anims; + delete[] states; + delete[] ranges; + delete[] commands; + delete[] nodesData; + delete[] frameData; + delete[] models; + delete[] staticMeshes; + delete[] objectTextures; + delete[] spriteTextures; + delete[] spriteSequences; + delete[] cameras; + delete[] soundSources; + delete[] boxes; + delete[] overlaps; + + for (int32 i = 0; i < 2; i++) + { + delete[] zones[i].ground1; + delete[] zones[i].ground2; + delete[] zones[i].fly; + } + + delete[] animTexData; + delete[] items; + delete[] cameraFrames; + delete[] demoData; + delete[] soundInfo; + delete[] soundData; + delete[] soundOffsets; + } + + void fixHeadMask() + { + #define SET_ROT(joint, mask) (((Node*)nodesData)[models[i].nodeIndex / 4 + joint]).flags |= mask; + + for (int32 i = 0; i < modelsCount; i++) + { + switch (models[i].type) + { + case ITEM_WOLF : SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_BEAR : SET_ROT(13, NODE_FLAG_ROTY); break; + //case ITEM_BAT : break; + case ITEM_CROCODILE_LAND : SET_ROT(7, NODE_FLAG_ROTY); break; + case ITEM_CROCODILE_WATER : SET_ROT(7, NODE_FLAG_ROTY); break; + case ITEM_LION_MALE : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_LION_FEMALE : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_PUMA : SET_ROT(19, NODE_FLAG_ROTY); break; + case ITEM_GORILLA : SET_ROT(13, NODE_FLAG_ROTY); break; + case ITEM_RAT_LAND : SET_ROT(1, NODE_FLAG_ROTY); break; + case ITEM_RAT_WATER : SET_ROT(1, NODE_FLAG_ROTY); break; + case ITEM_REX : SET_ROT(10, NODE_FLAG_ROTY); SET_ROT(11, NODE_FLAG_ROTY); break; + case ITEM_RAPTOR : SET_ROT(21, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_1 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_2 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_MUTANT_3 : SET_ROT(0, NODE_FLAG_ROTY); SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_CENTAUR : SET_ROT(10, NODE_FLAG_ROTX | NODE_FLAG_ROTY); break; + case ITEM_MUMMY : SET_ROT(2, NODE_FLAG_ROTY); break; + case ITEM_LARSON : SET_ROT(6, NODE_FLAG_ROTY); break; + case ITEM_PIERRE : SET_ROT(6, NODE_FLAG_ROTY); break; + case ITEM_SKATER : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_COWBOY : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_MR_T : SET_ROT(0, NODE_FLAG_ROTY); break; + case ITEM_NATLA : SET_ROT(2, NODE_FLAG_ROTX | NODE_FLAG_ROTZ); break; + case ITEM_ADAM : SET_ROT(1, NODE_FLAG_ROTY); break; + default : break; + } + } + + #undef SET_ROT + } + + int32 getModelIndex(int32 type) + { + for (int32 i = 0; i < modelsCount; i++) + { + if (models[i].type == type) { + return i; + } + } + return -1; + } + + template + T* addElements(T* &a, int32 &count, int32 size) + { + T* ptr = new T[count + size]; + memcpy(ptr, a, sizeof(a[0]) * count); + delete[] a; + a = ptr; + count += size; + return &a[count - size]; + } + + int32 getMeshTexture(uint16* meshPtr) + { + meshPtr += 3 + 1 + 1; // skip center, radius, flags + int16 vCount = *(int16*)meshPtr; + meshPtr += 1; // skip vCount + meshPtr += vCount * 3; // skip vertices + int16 nCount = *(int16*)meshPtr; + meshPtr += 1; // skip nCount + if (nCount > 0) { + meshPtr += nCount * 3; // skip normals + } else { + meshPtr -= nCount; // skip intensity + } + int16 rCount = *(int16*)meshPtr; + meshPtr += 1; // skip rCount + if (rCount > 0) { + meshPtr += 4; // skip indices + return (*(uint16*)meshPtr) & 0x07FF; + } + int16 tCount = *(int16*)meshPtr; + meshPtr += 1; // skip tCount + if (tCount > 0) + { + meshPtr += 3; // skip indices + return (*(uint16*)meshPtr) & 0x07FF; + } + // no textured quads or triangles + ASSERT(false); + return -1; + } + + int32 getMaxTexture(int32 tile, int32 x, int32 y, int32 &minU, int32 &minV, int32 &maxU, int32 &maxV) + { + int32 index = -1; + int32 maxW = 0; + int32 maxH = 0; + + for (int32 i = 0; i < objectTexturesCount; i++) + { + ObjectTexture *tex = objectTextures + i; + + //if (!tex->isQuad) + // continue; + + if (tex->tile != tile) + continue; + + int32 minX = MIN(MIN(tex->x0, tex->x1), tex->x2); + int32 minY = MIN(MIN(tex->y0, tex->y1), tex->y2); + int32 maxX = MAX(MAX(tex->x0, tex->x1), tex->x2); + int32 maxY = MAX(MAX(tex->y0, tex->y1), tex->y2); + + if (tex->isQuad) + { + minX = MIN(minX, tex->x3); + minY = MIN(minY, tex->y3); + maxX = MAX(maxX, tex->x3); + maxY = MAX(maxY, tex->y3); + } + + if (x >= minX && x <= maxX && y >= minY && y <= maxY) + { + int32 w = maxX - minX; + int32 h = maxY - minY; + + if (w >= maxW && h >= maxH) + { + index = i; + maxW = w; + maxH = h; + + minU = minX; + minV = minY; + maxU = maxX; + maxV = maxY; + } + } + } + + ASSERT(index >= 0); + + return index; + } + + void generateLODs() + { + struct Quad { + uint16 indices[4]; + uint16 flags; + }; + + struct Mesh { + vec3s center; + int16 radius; + uint16 flags; + int16 vCount; + vec3s vertices[4]; + int16 nCount; + int16 intensity[4]; + int16 rCount; + Quad rFaces[2]; + int16 tCount; + int16 crCount; + int16 ctCount; + }; + + struct AnimFrame { + MinMax box; + vec3s pos; + uint16 angles[2]; + }; + + AnimFrame meshPlaneFrame; + meshPlaneFrame.box.minX = -512; + meshPlaneFrame.box.maxX = 512; + meshPlaneFrame.box.minY = -512; + meshPlaneFrame.box.maxY = -512; + meshPlaneFrame.box.minZ = -512; + meshPlaneFrame.box.maxZ = 512; + + meshPlaneFrame.pos = vec3s(0, -512, 0); + meshPlaneFrame.angles[0] = meshPlaneFrame.angles[1] = 0; + + Mesh meshPlane; + meshPlane.center = vec3s(-512, 0, 512); + meshPlane.radius = 727; + meshPlane.flags = 1; + meshPlane.vCount = 4; + meshPlane.vertices[0] = vec3s(-512, 0, -512); + meshPlane.vertices[1] = vec3s( 512, 0, -512); + meshPlane.vertices[2] = vec3s( 512, 0, 512); + meshPlane.vertices[3] = vec3s(-512, 0, 512); + meshPlane.nCount = -4; + meshPlane.intensity[0] = 3800; + meshPlane.intensity[1] = 3800; + meshPlane.intensity[2] = 3800; + meshPlane.intensity[3] = 3800; + meshPlane.rCount = 2; + meshPlane.rFaces[0].indices[0] = 3; + meshPlane.rFaces[0].indices[1] = 2; + meshPlane.rFaces[0].indices[2] = 1; + meshPlane.rFaces[0].indices[3] = 0; + meshPlane.rFaces[1].indices[0] = 0; + meshPlane.rFaces[1].indices[1] = 1; + meshPlane.rFaces[1].indices[2] = 2; + meshPlane.rFaces[1].indices[3] = 3; + meshPlane.tCount = 0; + meshPlane.crCount = 0; + meshPlane.ctCount = 0; + + // trap floor lod + int32 index = getModelIndex(ITEM_TRAP_FLOOR); + + if (index > -1) + { + Model* model = addElements(models, modelsCount, 1); + *model = models[index]; + model->type = ITEM_TRAP_FLOOR_LOD; + + int32 texture = getMeshTexture((uint16*)((uint8*)meshData + meshOffsets[model->start])); + ObjectTexture* objTex = objectTextures + texture; + + int32 minU, minV, maxU, maxV; + + texture = getMaxTexture(objTex->tile, (objTex->x0 + objTex->x1 + objTex->x2) / 3, (objTex->y0 + objTex->y1 + objTex->y2) / 3, minU, minV, maxU, maxV); + + objTex = addElements(objectTextures, objectTexturesCount, 1); + *objTex = objectTextures[texture]; + objTex->x0 = minU; + objTex->y0 = minV; + objTex->x1 = maxU; + objTex->y1 = minV; + objTex->x2 = maxU; + objTex->y2 = maxV; + objTex->x3 = minU; + objTex->y3 = maxV; + + meshPlane.rFaces[0].flags = objectTexturesCount - 1; + meshPlane.rFaces[1].flags = objectTexturesCount - 1; + + uint32 *meshOffset = addElements(meshOffsets, meshOffsetsCount, 1); + + uint16* mesh = addElements(meshData, meshDataSize, sizeof(meshPlane) / sizeof(uint16)); + memcpy(mesh, &meshPlane, sizeof(meshPlane)); + + *meshOffset = uint32((mesh - meshData) * sizeof(uint16)); + + uint16* frame = addElements(frameData, frameDataSize, sizeof(meshPlaneFrame) / sizeof(uint16)); + memcpy(frame, &meshPlaneFrame, sizeof(meshPlaneFrame)); + + Animation* anim = addElements(anims, animsCount, 1); + memset(anim, 0, sizeof(anim[0])); + anim->frameRate = 1; + anim->frameOffset = uint32((frame - frameData) << 1); + + Node* node = (Node*)addElements(nodesData, nodesDataSize, sizeof(Node) / sizeof(uint32)); + node->flags = 0; + node->pos.x = 0; + node->pos.y = 0; + node->pos.z = 0; + + model->count = 1; + model->start = meshOffsetsCount - 1; + model->animIndex = animsCount - 1; + model->nodeIndex = uint32((uint32*)node - nodesData); + } + } + + void hideRoom(int32 roomIndex) + { + Room &room = rooms[roomIndex]; + room.vCount = 0; + room.qCount = 0; + room.tCount = 0; + room.sCount = 0; + room.pCount = 0; + room.lCount = 0; + room.mCount = 0; + room.zSectors = 0; + room.xSectors = 0; + room.alternateRoom = -1; + + for (int32 i = 0; i < roomsCount; i++) + { + Room &room = rooms[i]; + + int32 j = room.pCount - 1; + while (j >= 0) + { + if (room.portals[j].roomIndex == roomIndex) + { + room.pCount--; + room.portals[j] = room.portals[room.pCount]; + } + j--; + } + } + } + + void removeSound(int32 id) + { + if (soundMap[id] == -1) + return; + + SoundInfo info = soundInfo[soundMap[id]]; + + for (int32 index = info.index; index < info.index + info.flags.count; index++) + { + int32 offset = soundOffsets[index]; + + int32 size; + if (index == soundOffsetsCount - 1) { + size = soundDataSize - offset; + } else { + size = soundOffsets[index + 1] - offset; + } + + for (int i = index + 1; i < soundOffsetsCount; i++) + { + soundOffsets[i - 1] = soundOffsets[i] - size; + } + soundOffsetsCount--; + + for (int32 i = 0; i < soundInfoCount; i++) + { + if (soundInfo[i].index >= index) + { + soundInfo[i].index--; + } + } + + uint8* data = new uint8[soundDataSize - size]; + memcpy(data, soundData, offset); + memcpy(data + offset, soundData + offset + size, soundDataSize - offset - size); + + delete[] soundData; + soundData = data; + soundDataSize -= size; + } + + soundMap[id] = -1; + } + + void cutData() + { + removeSound(60); // underwater + removeSound(173); // secret + + if (id == LVL_TR1_GYM) + { + hideRoom(0); + hideRoom(1); + hideRoom(2); + hideRoom(3); + hideRoom(4); + hideRoom(5); + hideRoom(6); + hideRoom(15); + hideRoom(16); + hideRoom(17); + hideRoom(18); + + for (int32 i = 174; i <= 204; i++) // remove tutorial sounds (we use sound tracks instead) + removeSound(i); + + // disable transparency + objectTextures[93].attribute = + objectTextures[167].attribute = + objectTextures[175].attribute = + objectTextures[190].attribute = + objectTextures[191].attribute = + objectTextures[211].attribute = + objectTextures[220].attribute = + objectTextures[221].attribute = + objectTextures[580].attribute = + objectTextures[581].attribute = 0; + } + + if (id == LVL_TR1_1) + { + objectTextures[271].attribute = + objectTextures[272].attribute = + objectTextures[331].attribute = + objectTextures[333].attribute = + objectTextures[334].attribute = + objectTextures[335].attribute = + objectTextures[517].attribute = + objectTextures[518].attribute = + objectTextures[569].attribute = + objectTextures[571].attribute = + objectTextures[685].attribute = + objectTextures[686].attribute = 0; + } + + if (id == LVL_TR1_2) + { + objectTextures[247].attribute = + objectTextures[248].attribute = + objectTextures[307].attribute = + objectTextures[309].attribute = + objectTextures[310].attribute = + objectTextures[311].attribute = + objectTextures[547].attribute = + objectTextures[661].attribute = + objectTextures[662].attribute = + objectTextures[688].attribute = + objectTextures[905].attribute = + objectTextures[906].attribute = + objectTextures[923].attribute = 0; + } + + // TODO remove unused textures & models + } +}; + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/TR1_PSX.h b/src/platform/gba/packer/TR1_PSX.h new file mode 100644 index 00000000..a5089764 --- /dev/null +++ b/src/platform/gba/packer/TR1_PSX.h @@ -0,0 +1,9 @@ +#ifndef H_TR1_PSX +#define H_TR1_PSX + +struct TR1_PSX +{ + // +}; + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/ad4/AD4.h b/src/platform/gba/packer/ad4/AD4.h new file mode 100644 index 00000000..944d262e --- /dev/null +++ b/src/platform/gba/packer/ad4/AD4.h @@ -0,0 +1,101 @@ +#pragma once + +//! Uncommenting this line writes the output to Debug.sb as 8bit signed PCM +//#define DEBUG_OUTPUT + +#include +#include + +struct AD4State_t { + int32_t zM1, zM2; + int32_t Quant; + int32_t Output; + uint32_t MaxOutputLevel; +}; + +void AD4_Init(struct AD4State_t *State) { + State->zM1 = 0; + State->zM2 = 0; + State->Quant = 0x0800; + State->Output = 0; + State->MaxOutputLevel = 0; +} + +uint32_t AD4_EncodeFrame(struct AD4State_t *State, const int16_t *Data) { + static const uint8_t AdaptTable[] = { + 192,192,136,136,128,128,128,128, // -8..-1 + 112,128,128,128,128,136,136,192, // 0..+7 + }; + + uint8_t n; + int32_t zM1 = State->zM1; + int32_t zM2 = State->zM2; + int32_t Quant = State->Quant; + int32_t Output = State->Output; + uint32_t MaxOutputLevel = State->MaxOutputLevel; + uint32_t FrameData = 0; +#ifdef DEBUG_OUTPUT + static FILE *DebugFile = NULL; + if(!DebugFile) DebugFile = fopen("Debug.sb", "ab"); +#endif + for(n=0;n<8;n++) { + //! Get input, compute prediction, and quantize residue + //! Note that we minimize error of Output rather than Y, which implies + //! applying the post-filter in the analysis equation to get the residue. + int32_t X = Data[n]; + int32_t P = zM1 - zM2; + int32_t R = X - (P + Output - (Output >> 3)); { +#if 0 //! Lower RMSE, but sounds noisier + R = (2*R + ((R < 0) ? (-Quant) : (+Quant))) / (2*Quant); //! (R + Sign[R]*(Quant/2)) / Quant +#else + //! Round positive residues up, and negative residues towards 0. + //! I have no idea why, but this fixes limit cycles. + if(R > 0) R = (R + (Quant-1)) / Quant; + else R = (R + 0) / Quant; +#endif + if(R < -8) R = -8; + if(R > +7) R = +7; + } + + //! Calculate output value and apply limiting + //! Post-filter: Hpost(z) = 1 / Hpre(z) = 1 / (1 - (7/8)z^-1) + int32_t Y; + Output = Output - (Output >> 3); + for(;;) { + Y = P + R*Quant; + if(Output+Y < -32768) { + if(R < +7) R++; + else break; + } else if(Output+Y > +32767) { + if(R > -8) R--; + else break; + } else break; + } + Output += Y; + + //! Update maximum level after attempted clipping + uint32_t Level = (uint32_t)((Output < 0) ? (-Output) : (+Output)); + if(Level > MaxOutputLevel) MaxOutputLevel = Level; + + //! Write debug output +#ifdef DEBUG_OUTPUT + int8_t DebugSample = Output >> 8; + fwrite(&DebugSample, sizeof(int8_t), 1, DebugFile); +#endif + + //! Update taps and push residue to frame + zM2 = zM1; + zM1 = Y; + FrameData |= (R&0xF) << (n*4); + + //! Adapt quantizer + //! Rounding up means that Quant can never collapse to 0 + Quant = (Quant * AdaptTable[R+8] + 127) >> 7; + } + State->zM1 = zM1; + State->zM2 = zM2; + State->Quant = Quant; + State->Output = Output; + State->MaxOutputLevel = MaxOutputLevel; + return FrameData; +} diff --git a/src/platform/gba/packer/ad4/ad4.c b/src/platform/gba/packer/ad4/ad4.c new file mode 100644 index 00000000..ed54dc5f --- /dev/null +++ b/src/platform/gba/packer/ad4/ad4.c @@ -0,0 +1,61 @@ +#ifndef __GNUC__ +# warning "Compile with GCC-compatible compiler for endianness checking." +#endif + +#include +#include +#include +#include +#include "AD4.h" + +int main(int argc, const char *argv[]) { + if(argc < 3 || argc > 4) { + printf( + "Usage: ad4 Input.raw Output.ad4 [dBGain]\n" + "Input.raw must be mono signed PCM16.\n" + "Output will be aligned to 4 bytes.\n" + ); + return 1; + } + + FILE *InFile = fopen(argv[1], "rb"); + if(!InFile) { printf("Couldn't open input file.\n"); goto Error_InFile; } + FILE *OutFile = fopen(argv[2], "wb"); + if(!OutFile) { printf("Couldn't open output file.\n"); goto Error_OutFile; } + double Volume = 1.0; + if(argc >= 4) Volume = pow(10.0, atof(argv[3]) / 20.0); + + size_t nSamples; { + fseek(InFile, 0, SEEK_END); + nSamples = ftell(InFile) / sizeof(int16_t); + rewind(InFile); + } + + struct AD4State_t AD4State; AD4_Init(&AD4State); + size_t Frame, nFrames = (nSamples + 7) / 8; + for(Frame=0;Frame> 8) | + ((FrameData & 0xFF000000) >> 24) ; +#endif + fwrite(&FrameData, 1, sizeof(FrameData), OutFile); + } + printf("Maximum output level: %u", AD4State.MaxOutputLevel); + if(AD4State.MaxOutputLevel < 32768) putchar('\n'); + else printf(" (overflow by %u)\n", AD4State.MaxOutputLevel - 32767); + + fclose(OutFile); +Error_OutFile: + fclose(InFile); +Error_InFile: + return 0; +} diff --git a/src/platform/gba/packer/common.h b/src/platform/gba/packer/common.h new file mode 100644 index 00000000..9551576b --- /dev/null +++ b/src/platform/gba/packer/common.h @@ -0,0 +1,707 @@ +#ifndef H_COMMON +#define H_COMMON + +#include +#include +#include +#include +#include + +#include "libimagequant.h" + +#define STB_IMAGE_RESIZE_IMPLEMENTATION +#include "stb_image_resize.h" + +#define ASSERT(x) { if (!(x)) { DebugBreak(); } } + +typedef signed char int8; +typedef signed short int16; +typedef signed int int32; +typedef signed long long int64; +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned int uint32; +typedef unsigned long long uint64; + +inline uint16 swap16(uint16 x) { + return ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8); +} + +inline uint32 swap32(uint32 x) { + return ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24); +} + +template +inline void swap(T &a, T &b) { + T tmp = a; + a = b; + b = tmp; +} + +#define SQR(x) ((x) * (x)) +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x))) +#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) + +struct FileStream +{ + FILE* f; + + bool bigEndian; + + FileStream(const char* fileName, bool write) : bigEndian(false) + { + f = fopen(fileName, write ? "wb" : "rb"); + } + + ~FileStream() + { + if (f) fclose(f); + } + + bool isValid() + { + return f != NULL; + } + + void seek(int32 offset) + { + fseek(f, offset, SEEK_CUR); + } + + uint32 getPos() + { + return ftell(f); + } + + void setPos(uint32 pos) + { + fseek(f, pos, SEEK_SET); + } + + uint32 align4() + { + uint32 pos = getPos(); + uint32 aligned = (pos + 3) & ~3; + + if (aligned != pos) { + static const uint32 zero = 0; + fwrite(&zero, 1, aligned - pos, f); + } + + return aligned; + } + + uint32 align16() + { + uint32 pos = getPos(); + uint32 aligned = (pos + 15) & ~15; + + if (aligned != pos) { + static const uint32 zero = 0; + fwrite(&zero, 1, aligned - pos, f); + } + + return aligned; + } + + template + void read(T &result) + { + fread(&result, sizeof(result), 1, f); + } + + template + void read(T* &elements, C count) + { + if (count) { + elements = new T[count]; + fread(&elements[0], sizeof(elements[0]), count, f); + } else { + elements = NULL; + } + } + + template + void readArray(T* &elements, C &count) + { + read(count); + read(elements, count); + } + + void write(int8 value) + { + writeRaw(value); + } + + void write(uint8 value) + { + writeRaw(value); + } + + void write(int16 value) + { + if (bigEndian) { + value = (int16)swap16((uint16)value); + } + writeRaw(value); + } + + void write(uint16 value) + { + if (bigEndian) { + value = swap16(value); + } + writeRaw(value); + } + + void write(int32 value) + { + if (bigEndian) { + value = (int32)swap32((uint32)value); + } + writeRaw(value); + } + + void write(uint32 value) + { + if (bigEndian) { + value = swap32(value); + } + writeRaw(value); + } + + template + void write(const T* elements, C count) + { + if (!elements || !count) + return; + + for (int32 i = 0; i < int32(count); i++) + { + write(elements[i]); + } + } + + template + void writeObj(const T* elements, C count) + { + if (!elements || !count) + return; + + for (int32 i = 0; i < count; i++) + { + elements[i].write(*this); + } + } + + template + void writeRaw(const T &result) + { + fwrite(&result, sizeof(result), 1, f); + } + +private: + template + void writeArray(const T* elements, C count) + { + write(count); + write(elements, count); + } +}; + +template +struct Array +{ + int32 count; + T** items; + + Array() : count(0), items(NULL) {} + + ~Array() + { + delete[] items; + } + + T* operator [] (int index) const { return items[index]; } + + int32 add(T* item) + { + count++; + T** tmp = new T*[count]; + memcpy(tmp, items, (count - 1) * sizeof(T*)); + tmp[count - 1] = item; + delete[] items; + items = tmp; + return count - 1; + } + + int32 find(T* item) + { + for (int32 i = 0; i < count; i++) + { + if (items[i]->isEqual(item)) + return i; + } + return -1; + } + + void qsort(T** v, int L, int R) { + int i = L; + int j = R; + const T* m = v[(L + R) / 2]; + + while (i <= j) { + while (T::cmp(v[i], m) < 0) i++; + while (T::cmp(m, v[j]) < 0) j--; + + if (i <= j) + { + T* tmp = v[i]; + v[i] = v[j]; + v[j] = tmp; + i++; + j--; + } + } + + if (L < j) qsort(v, L, j); + if (i < R) qsort(v, i, R); + } + + void sort() { + if (count) { + qsort(items, 0, count - 1); + } + } +}; + +enum LevelID +{ + LVL_TR1_TITLE, + LVL_TR1_GYM, + LVL_TR1_1, + LVL_TR1_2, + LVL_TR1_3A, + LVL_TR1_3B, + LVL_TR1_CUT_1, + LVL_TR1_4, + LVL_TR1_5, + LVL_TR1_6, + LVL_TR1_7A, + LVL_TR1_7B, + LVL_TR1_CUT_2, + LVL_TR1_8A, + LVL_TR1_8B, + LVL_TR1_8C, + LVL_TR1_10A, + LVL_TR1_CUT_3, + LVL_TR1_10B, + LVL_TR1_CUT_4, + LVL_TR1_10C, + LVL_MAX +}; + +const char* levelNames[LVL_MAX] = { + "TITLE", + "GYM", + "LEVEL1", + "LEVEL2", + "LEVEL3A", + "LEVEL3B", + "CUT1", + "LEVEL4", + "LEVEL5", + "LEVEL6", + "LEVEL7A", + "LEVEL7B", + "CUT2", + "LEVEL8A", + "LEVEL8B", + "LEVEL8C", + "LEVEL10A", + "CUT3", + "LEVEL10B", + "CUT4", + "LEVEL10C" +}; + +#define ITEM_TYPES(E) \ + E( LARA ) \ + E( LARA_PISTOLS ) \ + E( LARA_SHOTGUN ) \ + E( LARA_MAGNUMS ) \ + E( LARA_UZIS ) \ + E( LARA_SPEC ) \ + E( DOPPELGANGER ) \ + E( WOLF ) \ + E( BEAR ) \ + E( BAT ) \ + E( CROCODILE_LAND ) \ + E( CROCODILE_WATER ) \ + E( LION_MALE ) \ + E( LION_FEMALE ) \ + E( PUMA ) \ + E( GORILLA ) \ + E( RAT_LAND ) \ + E( RAT_WATER ) \ + E( REX ) \ + E( RAPTOR ) \ + E( MUTANT_1 ) \ + E( MUTANT_2 ) \ + E( MUTANT_3 ) \ + E( CENTAUR ) \ + E( MUMMY ) \ + E( UNUSED_1 ) \ + E( UNUSED_2 ) \ + E( LARSON ) \ + E( PIERRE ) \ + E( SKATEBOARD ) \ + E( SKATER ) \ + E( COWBOY ) \ + E( MR_T ) \ + E( NATLA ) \ + E( ADAM ) \ + E( TRAP_FLOOR ) \ + E( TRAP_SWING_BLADE ) \ + E( TRAP_SPIKES ) \ + E( TRAP_BOULDER ) \ + E( DART ) \ + E( TRAP_DART_EMITTER ) \ + E( DRAWBRIDGE ) \ + E( TRAP_SLAM ) \ + E( TRAP_SWORD ) \ + E( HAMMER_HANDLE ) \ + E( HAMMER_BLOCK ) \ + E( LIGHTNING ) \ + E( MOVING_OBJECT ) \ + E( BLOCK_1 ) \ + E( BLOCK_2 ) \ + E( BLOCK_3 ) \ + E( BLOCK_4 ) \ + E( MOVING_BLOCK ) \ + E( TRAP_CEILING ) \ + E( TRAP_FLOOR_LOD ) \ + E( SWITCH ) \ + E( SWITCH_WATER ) \ + E( DOOR_1 ) \ + E( DOOR_2 ) \ + E( DOOR_3 ) \ + E( DOOR_4 ) \ + E( DOOR_5 ) \ + E( DOOR_6 ) \ + E( DOOR_7 ) \ + E( DOOR_8 ) \ + E( TRAP_DOOR_1 ) \ + E( TRAP_DOOR_2 ) \ + E( TRAP_DOOR_LOD ) \ + E( BRIDGE_FLAT ) \ + E( BRIDGE_TILT_1 ) \ + E( BRIDGE_TILT_2 ) \ + E( INV_PASSPORT ) \ + E( INV_COMPASS ) \ + E( INV_HOME ) \ + E( GEARS_1 ) \ + E( GEARS_2 ) \ + E( GEARS_3 ) \ + E( CUT_1 ) \ + E( CUT_2 ) \ + E( CUT_3 ) \ + E( CUT_4 ) \ + E( INV_PASSPORT_CLOSED ) \ + E( INV_MAP ) \ + E( CRYSTAL ) \ + E( PISTOLS ) \ + E( SHOTGUN ) \ + E( MAGNUMS ) \ + E( UZIS ) \ + E( AMMO_PISTOLS ) \ + E( AMMO_SHOTGUN ) \ + E( AMMO_MAGNUMS ) \ + E( AMMO_UZIS ) \ + E( EXPLOSIVE ) \ + E( MEDIKIT_SMALL ) \ + E( MEDIKIT_BIG ) \ + E( INV_DETAIL ) \ + E( INV_SOUND ) \ + E( INV_CONTROLS ) \ + E( INV_GAMMA ) \ + E( INV_PISTOLS ) \ + E( INV_SHOTGUN ) \ + E( INV_MAGNUMS ) \ + E( INV_UZIS ) \ + E( INV_AMMO_PISTOLS ) \ + E( INV_AMMO_SHOTGUN ) \ + E( INV_AMMO_MAGNUMS ) \ + E( INV_AMMO_UZIS ) \ + E( INV_EXPLOSIVE ) \ + E( INV_MEDIKIT_SMALL ) \ + E( INV_MEDIKIT_BIG ) \ + E( PUZZLE_1 ) \ + E( PUZZLE_2 ) \ + E( PUZZLE_3 ) \ + E( PUZZLE_4 ) \ + E( INV_PUZZLE_1 ) \ + E( INV_PUZZLE_2 ) \ + E( INV_PUZZLE_3 ) \ + E( INV_PUZZLE_4 ) \ + E( PUZZLEHOLE_1 ) \ + E( PUZZLEHOLE_2 ) \ + E( PUZZLEHOLE_3 ) \ + E( PUZZLEHOLE_4 ) \ + E( PUZZLEHOLE_DONE_1 ) \ + E( PUZZLEHOLE_DONE_2 ) \ + E( PUZZLEHOLE_DONE_3 ) \ + E( PUZZLEHOLE_DONE_4 ) \ + E( LEADBAR ) \ + E( INV_LEADBAR ) \ + E( MIDAS_HAND ) \ + E( KEY_ITEM_1 ) \ + E( KEY_ITEM_2 ) \ + E( KEY_ITEM_3 ) \ + E( KEY_ITEM_4 ) \ + E( INV_KEY_ITEM_1 ) \ + E( INV_KEY_ITEM_2 ) \ + E( INV_KEY_ITEM_3 ) \ + E( INV_KEY_ITEM_4 ) \ + E( KEYHOLE_1 ) \ + E( KEYHOLE_2 ) \ + E( KEYHOLE_3 ) \ + E( KEYHOLE_4 ) \ + E( UNUSED_5 ) \ + E( UNUSED_6 ) \ + E( SCION_PICKUP_QUALOPEC ) \ + E( SCION_PICKUP_DROP ) \ + E( SCION_TARGET ) \ + E( SCION_PICKUP_HOLDER ) \ + E( SCION_HOLDER ) \ + E( UNUSED_7 ) \ + E( UNUSED_8 ) \ + E( INV_SCION ) \ + E( EXPLOSION ) \ + E( UNUSED_9 ) \ + E( SPLASH ) \ + E( UNUSED_10 ) \ + E( BUBBLE ) \ + E( UNUSED_11 ) \ + E( UNUSED_12 ) \ + E( BLOOD ) \ + E( UNUSED_13 ) \ + E( SMOKE ) \ + E( CENTAUR_STATUE ) \ + E( CABIN ) \ + E( MUTANT_EGG_SMALL ) \ + E( RICOCHET ) \ + E( SPARKLES ) \ + E( MUZZLE_FLASH ) \ + E( UNUSED_14 ) \ + E( UNUSED_15 ) \ + E( VIEW_TARGET ) \ + E( WATERFALL ) \ + E( NATLA_BULLET ) \ + E( MUTANT_BULLET ) \ + E( CENTAUR_BULLET ) \ + E( UNUSED_16 ) \ + E( UNUSED_17 ) \ + E( LAVA_PARTICLE ) \ + E( LAVA_EMITTER ) \ + E( FLAME ) \ + E( FLAME_EMITTER ) \ + E( TRAP_LAVA ) \ + E( MUTANT_EGG_BIG ) \ + E( BOAT ) \ + E( EARTHQUAKE ) \ + E( UNUSED_18 ) \ + E( UNUSED_19 ) \ + E( UNUSED_20 ) \ + E( UNUSED_21 ) \ + E( UNUSED_22 ) \ + E( LARA_BRAID ) \ + E( GLYPHS ) + +#define DECL_ENUM(v) ITEM_##v, + +enum ItemType { + ITEM_TYPES(DECL_ENUM) + TR1_ITEM_MAX, + ITEM_MAX = TR1_ITEM_MAX +}; + +#undef DECL_ENUM + +#define MAX_TRACKS 256 +#define MAX_ROOMS 256 +#define MAX_MESHES 512 +#define MAX_MODELS 256 +#define MAX_ANIMS 512 +#define MAX_ROOM_VERTICES 0xFFFF +#define MAX_ROOM_QUADS 2048 +#define MAX_ROOM_TRIANGLES 128 +#define MAX_ROOM_SPRITES 64 +#define MAX_ROOM_PORTALS 16 +#define MAX_ROOM_SECTORS (20*20) +#define MAX_FLOORS (9 * 1024) +#define MAX_BOXES 1024 +#define MAX_OVERLAPS (6 * 1024) +#define MAX_ITEMS 240 +#define MAX_NODES 32 +#define MAX_TEXTURES 1536 * 2 +#define MAX_ANIM_TEX 128 + +#define TEX_ATTR_AKILL 0x0001 +#define TEX_ATTR_ANIM 0x0002 +#define FACE_TEXTURE 0x3FFF + +struct vec3s +{ + int16 x, y, z; + + vec3s() {} + vec3s(int16 x, int16 y, int16 z) : x(x), y(y), z(z) {} +}; + +struct vec3i +{ + int32 x, y, z; +}; + +void launchApp(const char* cmdline) +{ + STARTUPINFOA si; + PROCESS_INFORMATION pi; + + memset(&si, 0, sizeof(si)); + memset(&pi, 0, sizeof(pi)); + si.cb = sizeof(si); + + CreateProcess( + NULL, + (char*)cmdline, + NULL, + NULL, + FALSE, + 0, + NULL, + NULL, + &si, + &pi + ); + + WaitForSingleObject(pi.hProcess, INFINITE); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + +struct _BITMAPFILEHEADER { + uint32 bfSize; + uint16 bfReserved1; + uint16 bfReserved2; + uint32 bfOffBits; +}; + +struct _BITMAPINFOHEADER { + uint32 biSize; + uint32 biWidth; + uint32 biHeight; + uint16 biPlanes; + uint16 biBitCount; + uint32 biCompression; + uint32 biSizeImage; + uint32 biXPelsPerMeter; + uint32 biYPelsPerMeter; + uint32 biClrUsed; + uint32 biClrImportant; +}; + +void saveBitmap(const char* fileName, uint8* data, int32 width, int32 height, int32 bpp = 24) +{ + _BITMAPFILEHEADER fhdr; + _BITMAPINFOHEADER ihdr; + + memset(&fhdr, 0, sizeof(fhdr)); + memset(&ihdr, 0, sizeof(ihdr)); + + ihdr.biSize = sizeof(ihdr); + ihdr.biWidth = width; + ihdr.biHeight = height; + ihdr.biPlanes = 1; + ihdr.biBitCount = bpp; + ihdr.biSizeImage = width * height * bpp / 8; + + fhdr.bfOffBits = 2 + sizeof(fhdr) + ihdr.biSize; + fhdr.bfSize = fhdr.bfOffBits + ihdr.biSizeImage; + + FILE *f = fopen(fileName, "wb"); + if (f) { + uint16 type = 'B' + ('M' << 8); + fwrite(&type, sizeof(type), 1, f); + fwrite(&fhdr, sizeof(fhdr), 1, f); + fwrite(&ihdr, sizeof(ihdr), 1, f); + for (int32 i = 0; i < height; i++) + { + fwrite(data + (height - i - 1) * width * bpp / 8, bpp / 8, width, f); + } + fclose(f); + } +} + +uint8* loadBitmap(const char* fileName, int32* width, int32* height, int32* bpp) +{ + _BITMAPFILEHEADER fhdr; + _BITMAPINFOHEADER ihdr; + + FILE *f = fopen(fileName, "rb"); + if (!f) return NULL; + + uint16 type; + fread(&type, sizeof(type), 1, f); + fread(&fhdr, sizeof(fhdr), 1, f); + fread(&ihdr, sizeof(ihdr), 1, f); + + *width = ihdr.biWidth; + *height = ihdr.biHeight; + *bpp = ihdr.biBitCount; + + uint8* data = new uint8[ihdr.biWidth * ihdr.biHeight * ihdr.biBitCount / 8]; + data += ihdr.biWidth * ihdr.biHeight * ihdr.biBitCount / 8; + + for (uint32 i = 0; i < ihdr.biHeight; i++) + { + data -= ihdr.biWidth * ihdr.biBitCount / 8; + fread(data, ihdr.biWidth * ihdr.biBitCount / 8, 1, f); + } + + fclose(f); + + return data; +} + +void fixTexCoord(uint32 uv0, uint32 &uv1) +{ + int32 u0 = uv0 >> 24; + int32 u1 = uv1 >> 24; + int32 v0 = (uv0 >> 8) & 0xFF; + int32 v1 = (uv1 >> 8) & 0xFF; + + if (abs(u1 - u0) > 127) { + if (u1 > u0) { + u1 = u0 + 127; + } else { + u1 = u0 - 127; + } + } + + if (abs(v1 - v0) > 127) { + if (v1 > v0) { + v1 = v0 + 127; + } else { + v1 = v0 - 127; + } + } + + uv1 = (u1 << 24) | (v1 << 8); +} + +#endif diff --git a/src/platform/gba/packer/main.cpp b/src/platform/gba/packer/main.cpp new file mode 100644 index 00000000..f15ea4ac --- /dev/null +++ b/src/platform/gba/packer/main.cpp @@ -0,0 +1,105 @@ +#include "common.h" +#include "IMA.h" +#include "TR1_PC.h" +#include "TR1_PSX.h" +#include "out_GBA.h" +#include "out_3DO.h" +#include "out_32X.h" + +TR1_PC* pc[LVL_MAX]; +TR1_PSX* psx[LVL_MAX]; + +void dumpLightmap(const char* fileName, TR1_PC* level) +{ + uint32 data[34 * 256]; + + uint32 *ptr = data; + + for (int32 i = 0; i < 256; i++) + { + int32 idx = i * 3; + + uint8 r = level->palette.colors[idx + 0] << 2; + uint8 g = level->palette.colors[idx + 1] << 2; + uint8 b = level->palette.colors[idx + 2] << 2; + + *ptr++ = (b | (g << 8) | (r << 16) | 0xFF000000); + } + + for (int32 i = 0; i < 256; i++) { + *ptr++ = 0; + } + + for (int32 j = 0; j < 32; j++) + { + for (int32 i = 0; i < 256; i++) + { + int32 idx = level->lightmap[j * 256 + i] * 3; + + uint8 r = level->palette.colors[idx + 0] << 2; + uint8 g = level->palette.colors[idx + 1] << 2; + uint8 b = level->palette.colors[idx + 2] << 2; + + *ptr++ = (b | (g << 8) | (r << 16) | 0xFF000000); + } + } + + saveBitmap(fileName, (uint8*)data, 256, 32 + 2, 32); +} + +int main(int argc, char** argv) +{ + if (argc < 3) { + printf("usage: packer.exe [gba|3do] directory\n"); + return 0; + } + + for (int32 i = 0; i < LVL_MAX; i++) + { + char fileName[64]; + + { // load PC level + sprintf(fileName, "TR1_PC/DATA/%s.PHD", levelNames[i]); + + FileStream f(fileName, false); + + if (f.isValid()) { + pc[i] = new TR1_PC(f, LevelID(i)); + pc[i]->generateLODs(); + pc[i]->cutData(); + } else { + printf("can't open \"%s\"", fileName); + } + } + } + + dumpLightmap("lightmap.bmp", pc[LVL_TR1_1]); + + if (strcmp(argv[1], "gba") == 0) + { + out_GBA* out = new out_GBA(); + out->process(argv[2], pc, NULL); + delete out; + } + + if (strcmp(argv[1], "3do") == 0) + { + out_3DO* out = new out_3DO(); + out->process(argv[2], pc, NULL); + delete out; + } + + if (strcmp(argv[1], "32x") == 0) + { + out_32X* out = new out_32X(); + out->process(argv[2], pc, NULL); + delete out; + } + + for (int32 i = 0; i < LVL_MAX; i++) + { + delete pc[i]; + } + + return 0; +} diff --git a/src/platform/gba/packer/out_32X.h b/src/platform/gba/packer/out_32X.h new file mode 100644 index 00000000..565695f9 --- /dev/null +++ b/src/platform/gba/packer/out_32X.h @@ -0,0 +1,2357 @@ +#ifndef H_OUT_32X +#define H_OUT_32X + +#include "common.h" +#include "TR1_PC.h" +#include "TR1_PSX.h" + +struct out_32X +{ + enum FaceType { // 2 high bits of face flags + FACE_TYPE_SHADOW, + FACE_TYPE_F, + FACE_TYPE_FT, + FACE_TYPE_FTA + }; + + enum { + FACE_TYPE_SHIFT = 14 + }; + + enum { + NON_CACHE_ADDR = 0x20000000 + }; + + struct Remap { + int32 meshes[MAX_MESHES]; + int32 models[MAX_MODELS]; + int32 animFrames[MAX_ANIMS]; + int16 textures[MAX_TEXTURES]; + int16 sprites[MAX_TEXTURES]; + }; + + struct Header + { + uint32 magic; + + uint16 tilesCount; + uint16 roomsCount; + uint16 modelsCount; + uint16 meshesCount; + uint16 staticMeshesCount; + uint16 spriteSequencesCount; + uint16 soundSourcesCount; + uint16 boxesCount; + uint16 texturesCount; + uint16 spritesCount; + uint16 itemsCount; + uint16 camerasCount; + uint16 cameraFramesCount; + uint16 soundOffsetsCount; + + uint32 palette; + uint32 lightmap; + uint32 tiles; + uint32 rooms; + uint32 floors; + uint32 meshData; + uint32 meshOffsets; + uint32 anims; + uint32 states; + uint32 ranges; + uint32 commands; + uint32 nodes; + uint32 frameData; + uint32 models; + uint32 staticMeshes; + uint32 objectTextures; + uint32 spriteTextures; + uint32 spriteSequences; + uint32 cameras; + uint32 soundSources; + uint32 boxes; + uint32 overlaps; + uint32 zones[2][3]; + uint32 animTexData; + uint32 items; + uint32 cameraFrames; + uint32 soundMap; + uint32 soundInfos; + uint32 soundData; + uint32 soundOffsets; + + void write(FileStream &f) const + { + f.write(magic); + f.write(tilesCount); + f.write(roomsCount); + f.write(modelsCount); + f.write(meshesCount); + f.write(staticMeshesCount); + f.write(spriteSequencesCount); + f.write(soundSourcesCount); + f.write(boxesCount); + f.write(texturesCount); + f.write(spritesCount); + f.write(itemsCount); + f.write(camerasCount); + f.write(cameraFramesCount); + f.write(soundOffsetsCount); + + f.write(palette); + f.write(lightmap); + f.write(tiles); + f.write(rooms); + f.write(floors); + f.write(meshData); + f.write(meshOffsets); + f.write(anims); + f.write(states); + f.write(ranges); + f.write(commands); + f.write(nodes); + f.write(frameData); + f.write(models); + f.write(staticMeshes); + f.write(objectTextures); + f.write(spriteTextures); + f.write(spriteSequences); + f.write(cameras); + f.write(soundSources); + f.write(boxes); + f.write(overlaps); + + for (int32 i = 0; i < 2; i++) + { + for (int32 j = 0; j < 3; j++) + { + f.write(zones[i][j]); + } + } + + f.write(animTexData); + f.write(items); + f.write(cameraFrames); + f.write(soundMap); + f.write(soundInfos); + f.write(soundData); + f.write(soundOffsets); + } + }; + + struct Info + { + int16 x; + int16 z; + int16 yBottom; + int16 yTop; + + uint16 quadsCount; + uint16 trianglesCount; + + uint16 verticesCount; + uint16 spritesCount; + + uint8 portalsCount; + uint8 lightsCount; + uint8 meshesCount; + uint8 ambient; + + uint8 xSectors; + uint8 zSectors; + uint8 alternateRoom; + uint8 flags; + + uint32 quads; + uint32 triangles; + uint32 vertices; + uint32 sprites; + uint32 portals; + uint32 sectors; + uint32 lights; + uint32 meshes; + + void write(FileStream &f) const + { + f.write(x); + f.write(z); + f.write(yBottom); + f.write(yTop); + f.write(quadsCount); + f.write(trianglesCount); + f.write(verticesCount); + f.write(spritesCount); + f.write(portalsCount); + f.write(lightsCount); + f.write(meshesCount); + f.write(ambient); + f.write(xSectors); + f.write(zSectors); + f.write(alternateRoom); + f.write(flags); + f.write(quads); + f.write(triangles); + f.write(vertices); + f.write(sprites); + f.write(portals); + f.write(sectors); + f.write(lights); + f.write(meshes); + } + }; + + struct RoomVertex + { + uint8 x, y, z, g; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + } + }; + + struct RoomQuad + { + uint32 flags; + int8 indices[4]; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + } + }; + + struct RoomTriangle + { + uint16 flags; + uint16 indices[3]; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + } + }; + + struct MeshQuad + { + uint16 flags; + uint8 indices[4]; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + } + }; + + struct MeshTriangle + { + uint16 flags; + uint8 indices[4]; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + } + }; + + struct AnimState + { + uint8 state; + uint8 rangesCount; + uint16 rangesStart; + + void write(FileStream &f) const + { + f.write(state); + f.write(rangesCount); + f.write(rangesStart); + } + }; + + struct Node + { + vec3s pos; + uint16 flags; + + void write(FileStream &f) + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(flags); + } + }; + + struct Sprite + { + int16 x, y, z; + uint8 g; + uint8 index; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + f.write(index); + } + }; + + struct Portal + { + uint8 roomIndex; + uint8 normalIndex; + uint16 x, y, z; + uint8 a, b; + + Portal(const TR1_PC::Room::Portal &portal) + { + + const vec3s &v0 = portal.vertices[0]; + const vec3s &v1 = portal.vertices[1]; + const vec3s &v2 = portal.vertices[2]; + const vec3s &v3 = portal.vertices[3]; + const vec3s &n = portal.normal; + + normalIndex = 0xFF; + + if (n.x == -1) normalIndex = 0; + if (n.x == 1) normalIndex = 1; + if (n.y == -1) normalIndex = 2; + if (n.y == 1) normalIndex = 3; + if (n.z == -1) normalIndex = 4; + if (n.z == 1) normalIndex = 5; + + ASSERT(normalIndex != 0xFF); + + int32 minX = MIN(MIN(MIN(v0.x, v1.x), v2.x), v3.x); + int32 minY = MIN(MIN(MIN(v0.y, v1.y), v2.y), v3.y); + int32 minZ = MIN(MIN(MIN(v0.z, v1.z), v2.z), v3.z); + int32 maxX = MAX(MAX(MAX(v0.x, v1.x), v2.x), v3.x); + int32 maxY = MAX(MAX(MAX(v0.y, v1.y), v2.y), v3.y); + int32 maxZ = MAX(MAX(MAX(v0.z, v1.z), v2.z), v3.z); + + x = (maxX + minX) / 2; + y = (maxY + minY) / 2; + z = (maxZ + minZ) / 2; + + int32 sx = (maxX - minX) / 256 >> 1; + int32 sy = (maxY - minY) / 256 >> 1; + int32 sz = (maxZ - minZ) / 256 >> 1; + + switch (normalIndex / 2) + { + case 0 : // x + a = sy; + b = sz; + break; + case 1 : // y + a = sx; + b = sz; + break; + case 2 : // z + a = sx; + b = sy; + break; + } + } + + void write(FileStream &f) const + { + f.write(roomIndex); + f.write(normalIndex); + f.write(x); + f.write(y); + f.write(z); + f.write(a); + f.write(b); + } + }; + + struct Light + { + vec3s pos; + uint8 radius; + uint8 intensity; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(radius); + f.write(intensity); + } + }; + + struct RoomMesh + { + vec3s pos; + uint8 intensity; + uint8 flags; + + void write(FileStream &f) const + { + uint32 xy = (pos.x << 16) | uint16(pos.y); + uint32 zf = (pos.z << 16) | (intensity << 8) | flags; + f.write(xy); + f.write(zf); + } + }; + + struct Sphere16 + { + int16 x, y, z, radius; + + void write(FileStream &f) const + { + uint32 xy = (x << 16) | uint16(y); + uint32 zr = (z << 16) | uint16(radius); + f.write(xy); + f.write(zr); + } + }; + + struct MinMax + { + int16 minX, maxX; + int16 minY, maxY; + int16 minZ, maxZ; + + void write(FileStream &f) const + { + f.write(minX); f.write(maxX); + f.write(minY); f.write(maxY); + f.write(minZ); f.write(maxZ); + } + }; + + struct StaticMesh + { + uint16 id; + uint16 meshIndex; + uint32 flags; + //Sphere16 vs; + MinMax vbox; + MinMax cbox; + + void write(FileStream &f) const + { + Sphere16 vs; + vs.x = (vbox.maxX + vbox.minX) >> 1; + vs.y = (vbox.maxY + vbox.minY) >> 1; + vs.z = (vbox.maxZ + vbox.minZ) >> 1; + + int32 dx = (vbox.maxX - vbox.minX) >> 1; + int32 dy = (vbox.maxY - vbox.minY) >> 1; + int32 dz = (vbox.maxZ - vbox.minZ) >> 1; + + vs.radius = int32(sqrtf(float(dx * dx + dy * dy + dz * dz))); + + f.write(id); + f.write(meshIndex); + f.write(flags); + vs.write(f); + vbox.write(f); + cbox.write(f); + } + }; + + struct ObjectTexture + { + uint32 tile; + uint32 uv01; + uint32 uv23; + + ObjectTexture(const TR1_PC::ObjectTexture* tex) + { + tile = (tex->tile & 0x3FFF) << 16; + + uint32 uv0 = ((tex->uv0 << 16) | (tex->uv0 >> 16)) & 0xFF00FF00; + uint32 uv1 = ((tex->uv1 << 16) | (tex->uv1 >> 16)) & 0xFF00FF00; + uint32 uv2 = ((tex->uv2 << 16) | (tex->uv2 >> 16)) & 0xFF00FF00; + uint32 uv3 = ((tex->uv3 << 16) | (tex->uv3 >> 16)) & 0xFF00FF00; + + fixTexCoord(uv0, uv1); + fixTexCoord(uv0, uv3); + fixTexCoord(uv1, uv2); + + uv01 = uv0 | (uv1 >> 8); + uv23 = uv2 | (uv3 >> 8); + + //uv01 = swapW(uv01); + //uv23 = swapW(uv23); + + tile |= NON_CACHE_ADDR; + } + + bool isEqual(const ObjectTexture* tex) + { + return memcmp(this, tex, sizeof(*tex)) == 0; + } + + void write(FileStream &f) const + { + f.write(tile); + f.write(uv01); + f.write(uv23); + } + }; + + struct SpriteTexture + { + uint32 tile; + uint32 uwvh; + int16 l, t, r, b; + + SpriteTexture(const TR1_PC::SpriteTexture* spr) + { + uint32 u = spr->u; + uint32 v = spr->v; + uint32 w = (spr->w + 255) >> 8; + uint32 h = (spr->h + 255) >> 8; + tile = spr->tile << 16; + uwvh = (u << 24) | (w << 16) | (v << 8) | h; + l = spr->l; + t = spr->t; + r = spr->r; + b = spr->b; + } + + bool isEqual(const SpriteTexture* spr) + { + return memcmp(this, spr, sizeof(*spr)) == 0; + } + + void write(FileStream &f) const + { + f.write(tile); + f.write(uwvh); + f.write(l); + f.write(t); + f.write(r); + f.write(b); + } + }; + + struct Box + { + uint8 minZ, maxZ; + uint8 minX, maxX; + int16 floor; + int16 overlap; + + void write(FileStream &f) const + { + f.write(minZ); + f.write(maxZ); + f.write(minX); + f.write(maxX); + f.write(floor); + f.write(overlap); + } + }; + + struct Item + { + uint8 type; + uint8 roomIndex; + vec3s pos; + int16 intensity; + uint16 flags; + + void write(FileStream &f) const + { + f.write(type); + f.write(roomIndex); + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(intensity); + f.write(flags); + } + }; + + struct Mesh + { + int32 offset; + TR1_PC* level; + vec3s center; + int16 radius; + uint16 intensity; + uint8 vCount; + uint8 hasNormals; + int16 rCount; + int16 crCount; + int16 tCount; + int16 ctCount; + const vec3s* vertices; + const TR1_PC::Quad* rFaces; + const TR1_PC::Quad* crFaces; + const TR1_PC::Triangle* tFaces; + const TR1_PC::Triangle* ctFaces; + + Mesh(TR1_PC* level, const uint8* ptr) + { + this->level = level; + + center = *(vec3s*)ptr; ptr += sizeof(center); + radius = *(int16*)ptr; ptr += sizeof(radius); + uint16 flags = *(uint16*)ptr; ptr += sizeof(flags); + + vCount = *(int16*)ptr; ptr += 2; + vertices = (vec3s*)ptr; + ptr += vCount * sizeof(vec3s); + + const uint16* vIntensity = NULL; + const vec3s* vNormal = NULL; + + int16 nCount = *(int16*)ptr; ptr += 2; + //const int16* normals = (int16*)ptr; + if (nCount > 0) { // normals + vNormal = (vec3s*)ptr; + ptr += nCount * 3 * sizeof(int16); + } else { // intensity + vIntensity = (uint16*)ptr; + ptr += vCount * sizeof(uint16); + } + hasNormals = 0; + + rCount = *(int16*)ptr; ptr += 2; + rFaces = (TR1_PC::Quad*)ptr; ptr += rCount * sizeof(TR1_PC::Quad); + + tCount = *(int16*)ptr; ptr += 2; + tFaces = (TR1_PC::Triangle*)ptr; ptr += tCount * sizeof(TR1_PC::Triangle); + + crCount = *(int16*)ptr; ptr += 2; + crFaces = (TR1_PC::Quad*)ptr; ptr += crCount * sizeof(TR1_PC::Quad); + + ctCount = *(int16*)ptr; ptr += 2; + ctFaces = (TR1_PC::Triangle*)ptr; ptr += ctCount * sizeof(TR1_PC::Triangle); + + intensity = 0; + + if (vIntensity) + { + uint32 sum = 0; + for (int32 i = 0; i < vCount; i++) + { + sum += vIntensity[i]; + } + intensity = sum / vCount; + } + } + + void write(FileStream &f, const Remap *remap) const + { + ASSERT(vCount < 256); + + f.write(center.x); + f.write(center.y); + f.write(center.z); + f.write(radius); + f.write(intensity); + f.write(vCount); + f.write(hasNormals); + f.write(int16(rCount + crCount)); + f.write(int16(tCount + ctCount)); + f.write(int16(0)); + f.write(int16(0)); + + for (int32 j = 0; j < vCount; j++) + { + struct MeshVertex32X { + int16 x, y, z; + } v; + + v.x = vertices[j].x << 2; + v.y = vertices[j].y << 2; + v.z = vertices[j].z << 2; + + f.write(v.x); + f.write(v.y); + f.write(v.z); + } + + for (int32 j = 0; j < rCount; j++) + { + TR1_PC::Quad q = rFaces[j]; + uint16 texIndex = q.flags & FACE_TEXTURE; + + MeshQuad comp; + comp.indices[0] = uint8(q.indices[0]); + comp.indices[1] = uint8(q.indices[1]); + comp.indices[2] = uint8(q.indices[2]); + comp.indices[3] = uint8(q.indices[3]); + comp.flags = remap ? remap->textures[texIndex] : texIndex; + + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + for (int32 j = 0; j < crCount; j++) + { + TR1_PC::Quad q = crFaces[j]; + + MeshQuad comp; + comp.indices[0] = uint8(q.indices[0]); + comp.indices[1] = uint8(q.indices[1]); + comp.indices[2] = uint8(q.indices[2]); + comp.indices[3] = uint8(q.indices[3]); + comp.flags = q.flags & FACE_TEXTURE; + comp.flags |= (FACE_TYPE_F << FACE_TYPE_SHIFT); + + comp.write(f); + } + + for (int32 j = 0; j < tCount; j++) + { + TR1_PC::Triangle t = tFaces[j]; + uint16 texIndex = t.flags & FACE_TEXTURE; + + MeshTriangle comp; + comp.indices[0] = uint8(t.indices[0]); + comp.indices[1] = uint8(t.indices[1]); + comp.indices[2] = uint8(t.indices[2]); + comp.indices[3] = 0; + comp.flags = remap ? remap->textures[texIndex] : texIndex; + + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + for (int32 j = 0; j < ctCount; j++) + { + TR1_PC::Triangle t = ctFaces[j]; + + MeshTriangle comp; + comp.indices[0] = uint8(t.indices[0]); + comp.indices[1] = uint8(t.indices[1]); + comp.indices[2] = uint8(t.indices[2]); + comp.indices[3] = 0; + comp.flags = t.flags & FACE_TEXTURE; + comp.flags |= (FACE_TYPE_F << FACE_TYPE_SHIFT); + + comp.write(f); + } + } + }; + + struct Model + { + TR1_PC* level; + int32 objTexIndex; + uint8 type; + uint8 count; + uint16 start; + uint16 nodeIndex; + uint16 animIndex; + + void init(TR1_PC* level, const TR1_PC::Model &model) + { + this->level = level; + } + + void write(FileStream &f) const + { + f.write(type); + f.write(count); + f.write(start); + f.write(nodeIndex); + f.write(animIndex); + } + }; + + struct Animation { + TR1_PC::Animation anim; + + }; + + struct AnimFrames + { + const uint8* data; + uint32 size; + + AnimFrames(const uint8* startPtr, const uint8* endPtr) + { + data = startPtr; + size = uint32(endPtr - startPtr); + } + + void write(FileStream &f) const + { + f.write(data, size); + } + }; + + struct Texture + { + const TR1_PC* level; + TR1_PC::ObjectTexture* tex; + TR1_PC::SpriteTexture* spr; + Texture* link; + int32 uid; + int32 width; + int32 height; + int32 akill; + uint8* indices; + uint32 indexSum; + int32 tile; + int32 x, y; + int32 minX, minY, maxX, maxY; + + Texture(const TR1_PC* level, TR1_PC::ObjectTexture* tex, int32 uid) + { + this->level = level; + this->tex = tex; + this->spr = NULL; + this->link = NULL; + this->uid = uid; + this->tile = -1; + + TR1_PC::Tile *tile = level->tiles + (tex->tile & 0x3FFF); + + minX = MIN(MIN(tex->x0, tex->x1), tex->x2); + minY = MIN(MIN(tex->y0, tex->y1), tex->y2); + maxX = MAX(MAX(tex->x0, tex->x1), tex->x2); + maxY = MAX(MAX(tex->y0, tex->y1), tex->y2); + + if (tex->isQuad) + { + minX = MIN(minX, tex->x3); + minY = MIN(minY, tex->y3); + maxX = MAX(maxX, tex->x3); + maxY = MAX(maxY, tex->y3); + } + + width = maxX - minX + 1; + height = maxY - minY + 1; + akill = 0; + + bool transp = (tex->attribute & TEX_ATTR_AKILL); + + indices = new uint8[width * height]; + const uint8* src = tile->indices + 256 * minY; + uint8* dst = indices; + + for (int32 y = minY; y <= maxY; y++) + { + for (int32 x = minX; x <= maxX; x++) + { + uint8 index = src[x]; + *dst++ = index; + + if ((index == 0) && transp) { + akill++; + } + } + src += 256; + } + } + + Texture(const TR1_PC* level, TR1_PC::SpriteTexture* spr, int32 uid) + { + this->level = level; + this->uid = uid; + this->tex = NULL; + this->spr = spr; + this->link = NULL; + this->tile = -1; + + TR1_PC::Tile *tile = level->tiles + (spr->tile & 0x3FF); + + minX = spr->u; + minY = spr->v; + maxX = spr->u + (spr->w >> 8); + maxY = spr->v + (spr->h >> 8); + + width = maxX - minX + 1; + height = maxY - minY + 1; + akill = 0; + indexSum = 0; + + indices = new uint8[width * height]; + const uint8* src = tile->indices + 256 * minY; + uint8* dst = indices; + + for (int32 y = minY; y <= maxY; y++) + { + for (int32 x = minX; x <= maxX; x++) + { + uint8 index = src[x]; + *dst++ = index; + + indexSum += index; + + if (index == 0) { + akill++; + } + } + src += 256; + } + } + + ~Texture() + { + delete[] indices; + } + + static int cmp(const Texture* a, const Texture* b) + { + int32 animA = a->tex ? a->tex->attribute & TEX_ATTR_ANIM : 0; + int32 animB = b->tex ? b->tex->attribute & TEX_ATTR_ANIM : 0; + int32 i = animB - animA; + + if (i == 0) + { + i = b->akill - a->akill; + } + + if (i == 0) + { + int32 max1 = MAX(a->width, a->height); + int32 max2 = MAX(b->width, b->height); + i = max2 - max1; + } + + if (i == 0) { + i = int32(a->level - b->level); + } + + if (i == 0) { + i = a->uid - b->uid; + } + + return i; + } + }; + + struct Atlas + { + struct Node + { + Node* childs[2]; + Texture* tex; + int32 l, t, r, b; + + Node(short l, short t, short r, short b) : l(l), t(t), r(r), b(b), tex(NULL) { + childs[0] = childs[1] = NULL; + } + + ~Node() { + delete childs[0]; + delete childs[1]; + } + + Node* insert(Texture* tex) + { + if (childs[0] != NULL && childs[1] != NULL) + { + Node* node = childs[0]->insert(tex); + if (node != NULL) + return node; + return childs[1]->insert(tex); + } + + if (this->tex != NULL) + return NULL; + + int16 nw = r - l; + int16 nh = b - t; + int16 tw = tex->width; + int16 th = tex->height; + + if (nw < tw || nh < th) + return NULL; + + if (nw == tw && nh == th) + { + this->tex = tex; + tex->x = l; + tex->y = t; + return this; + } + + int16 dx = nw - tw; + int16 dy = nh - th; + + if (dx > dy) { + childs[0] = new Node(l, t, l + tw, b); + childs[1] = new Node(l + tw, t, r, b); + } else { + childs[0] = new Node(l, t, r, t + th); + childs[1] = new Node(l, t + th, r, b); + } + + return childs[0]->insert(tex); + } + + void fill24(uint8* data) + { + if (childs[0] != NULL && childs[1] != NULL) + { + childs[0]->fill24(data); + childs[1]->fill24(data); + } + + if (!tex) { + return; + } + + // fill code + const TR1_PC::Palette &pal = tex->level->palette; + + uint8* index = tex->indices; + + uint8* dst = data + (t * 256 + l) * 3; + + for (int32 y = 0; y < tex->height; y++) + { + for (int32 x = 0; x < tex->width; x++) + { + if ((*index == 0) && tex->akill) { + dst[x * 3 + 0] = 255; + dst[x * 3 + 1] = 0; + dst[x * 3 + 2] = 255; + } else { + dst[x * 3 + 0] = pal.colors[*index * 3 + 2] << 2; + dst[x * 3 + 1] = pal.colors[*index * 3 + 1] << 2; + dst[x * 3 + 2] = pal.colors[*index * 3 + 0] << 2; + } + *index++; + } + dst += 256 * 3; + } + } + + void fill8(uint8* data) + { + if (childs[0] != NULL && childs[1] != NULL) + { + childs[0]->fill8(data); + childs[1]->fill8(data); + } + + if (!tex) { + return; + } + + // fill code + for (int32 y = 0; y < tex->height; y++) + { + memcpy(data + ((t + y) * 256 + l), tex->indices + y * tex->width, tex->width); + } + } + }; + + Node* root; + + Atlas() + { + root = new Node(0, 0, 256, 256); + } + + ~Atlas() + { + delete root; + } + + void fill24(uint8* data) + { + root->fill24(data); + } + + void fill8(uint8* data) + { + root->fill8(data); + } + + static int cmp(const Atlas* a, const Atlas* b) + { + return 0; + } + }; + + RoomVertex* roomVertices; + int32 roomVerticesCount; + + Remap remaps[LVL_MAX]; + + Array meshes; + Array models; + Array animFrames; + Array objectTextures; + Array spriteTextures; + + Array textures; + Array tiles; + + void addTextures(TR1_PC* level) + { + // check object textures usage + bool* used = new bool[level->objectTexturesCount]; + memset(used, 0, sizeof(bool) * level->objectTexturesCount); + + for (int32 i = 0; i < level->roomsCount; i++) + { + TR1_PC::Room &room = level->rooms[i]; + + for (int32 j = 0; j < room.qCount; j++) + { + used[room.quads[j].flags & FACE_TEXTURE] = true; + } + + for (int32 j = 0; j < room.tCount; j++) + { + used[room.triangles[j].flags & FACE_TEXTURE] = true; + } + } + + for (int32 i = 0; i < level->meshOffsetsCount; i++) + { + const uint8* ptr = (uint8*)level->meshData + level->meshOffsets[i]; + + Mesh mesh(level, ptr); + + for (int32 j = 0; j < mesh.rCount; j++) + { + used[mesh.rFaces[j].flags & FACE_TEXTURE] = true; + } + + for (int32 j = 0; j < mesh.tCount; j++) + { + used[mesh.tFaces[j].flags & FACE_TEXTURE] = true; + } + } + + static int32 texUID = 0; + + // textures + for (int32 i = 0; i < level->objectTexturesCount; i++) + { + if (!used[i]) continue; + Texture* tex = new Texture(level, level->objectTextures + i, texUID++); + textures.add(tex); + } + + // sprites + for (int32 i = 0; i < level->spriteTexturesCount; i++) + { + Texture* tex = new Texture(level, level->spriteTextures + i, texUID++); + textures.add(tex); + } + + static int32 maxSprites = 0; + maxSprites += level->spriteTexturesCount; + printf("%d\n", maxSprites); + + delete[] used; + } + + void linkTextures() + { + textures.sort(); + + for (int32 i = 0; i < textures.count; i++) + { + Texture* src = textures[i]; + ASSERT(src->link == NULL); + + for (int32 j = 0; j < i; j++) + { + Texture* dst = textures[j]; + + if (dst->link) { + dst = dst->link; + ASSERT(dst->link == NULL); + } + + if (src->tex) // is ObjectTexture + { + if (src->width != dst->width || src->height > dst->height) + continue; + + int32 dy = dst->height - src->height; + + for (int32 y = 0; y <= dy; y++) + { + if (memcmp(dst->indices + dst->width * y, src->indices, src->width * src->height) == 0) + { + src->link = dst; + break; + } + } + } + else // is SpriteTexture + { + if (src->width != dst->width || src->height != dst->height || src->indexSum != dst->indexSum) + continue; + + if (memcmp(dst->indices, src->indices, src->width * src->height) == 0) + { + src->link = dst; + break; + } + } + } + } + } + + void packTiles(FileStream &f) + { + int32 texPacked = 0; + + for (int32 i = 0; i < textures.count; i++) + { + Texture* tex = textures[i]; + + if (tex->link) + continue; + + bool placed = false; + + for (int32 j = 0; j < tiles.count; j++) + { + if (tiles[j]->root->insert(tex)) + { + placed = true; + tex->tile = j; + break; + } + } + + if (!placed) + { + Atlas* tile = new Atlas(); + tex->tile = tiles.add(tile); + placed = tile->root->insert(tex); + } + + if (!placed) + { + tex->tile = -1; + printf("Can't pack texture %d x %d", tex->width, tex->height); + break; + } + + if (placed) { + texPacked++; + } + } + + printf("textures packed: %d\n", texPacked); + + uint8* data = new uint8[256 * 256 * 3 * tiles.count]; + + // save bitmap (debug) + for (int32 i = 0; i < 256 * 256 * tiles.count; i++) + { + data[i * 3 + 0] = 255; + data[i * 3 + 1] = 0; + data[i * 3 + 2] = 255; + } + + for (int32 i = 0; i < tiles.count; i++) + { + tiles[i]->fill24(data + i * 256 * 256 * 3); + } + saveBitmap("tiles.bmp", data, 256, 256 * tiles.count); + + memset(data, 0, 256 * 256 * tiles.count); + + for (int32 i = 0; i < tiles.count; i++) + { + tiles[i]->fill8(data + i * 256 * 256); + } + + f.write(data, 256 * 256 * tiles.count); + + delete[] data; + } + + void remapTextures() + { + int32 animated = -1; + int32 maxAnimatedTex = 0; + + for (int32 i = 0; i < textures.count; i++) + { + const Texture* texture = textures[i]; + const Texture* instance = texture->link ? texture->link : texture; + + int32 dx = instance->x - instance->minX; + int32 dy = instance->y - instance->minY; + + ASSERT(instance->tile >= 0); + + Remap &remap = remaps[texture->level->id]; + + if (texture->tex) // is ObjectTexture + { + if (texture->tex->attribute & TEX_ATTR_ANIM) + { + ASSERT(animated == -1 || animated == 1); + animated = 1; + } else { + + // add dummy textures as padding between animated and static textures + int32 padding = MAX_ANIM_TEX - objectTextures.count; + for (int32 j = 0; j < padding; j++) + { + TR1_PC::ObjectTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + objectTextures.add(new ObjectTexture(&tmp)); + } + + animated = 0; + } + + TR1_PC::ObjectTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + tmp.attribute = texture->tex->attribute; // old attribute + tmp.tile = instance->tile; // new tile index + tmp.x0 = texture->tex->x0 + dx; + tmp.y0 = texture->tex->y0 + dy; + tmp.x1 = texture->tex->x1 + dx; + tmp.y1 = texture->tex->y1 + dy; + tmp.x2 = texture->tex->x2 + dx; + tmp.y2 = texture->tex->y2 + dy; + if (texture->tex->isQuad) + { + tmp.x3 = texture->tex->x3 + dx; + tmp.y3 = texture->tex->y3 + dy; + } + + ObjectTexture* comp = new ObjectTexture(&tmp); + + int32 texIndex = int32(texture->tex - texture->level->objectTextures); + + int32 index = objectTextures.find(comp); + if (index <= 0) { + index = objectTextures.add(comp); + } else { + delete comp; + } + remap.textures[texIndex] = index; + + if (texture->tex->attribute & TEX_ATTR_ANIM) { + maxAnimatedTex = i; + } + } + else // is SpriteTexture + { + ASSERT(animated == 0); + + TR1_PC::SpriteTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + tmp.tile = instance->spr->tile; + tmp.u = texture->spr->u + dx; + tmp.v = texture->spr->v + dy; + tmp.w = texture->spr->w; + tmp.h = texture->spr->h; + tmp.l = texture->spr->l; + tmp.t = texture->spr->t; + tmp.r = texture->spr->r; + tmp.b = texture->spr->b; + + SpriteTexture* comp = new SpriteTexture(&tmp); + + int32 sprIndex = int32(texture->spr - texture->level->spriteTextures); + + int32 index = spriteTextures.find(comp); + if (index <= 0) { + index = spriteTextures.add(comp); + } else { + delete comp; + } + remap.sprites[sprIndex] = index; + } + } + + printf("animated textures: %d\n", maxAnimatedTex + 1); + + ASSERT(maxAnimatedTex < MAX_ANIM_TEX); + } + + int32 addRoomVertex(int32 yOffset, const TR1_PC::Room::Vertex &v) + { + RoomVertex comp; + int32 px = v.pos.x >> 8; + int32 py = (v.pos.y - yOffset) >> 8; + int32 pz = v.pos.z >> 8; + + ASSERT(py >= 0); + ASSERT(px < 128); + ASSERT(py < 128); + ASSERT(pz < 128); + + comp.x = px; + comp.y = py; + comp.z = pz; + comp.g = v.lighting >> 8; + + for (int32 i = 0; i < roomVerticesCount; i++) + { + if (memcmp(roomVertices + i, &comp, sizeof(comp)) == 0) + { + return i; + } + } + + ASSERT(roomVerticesCount < 0xFFFF); + + roomVertices[roomVerticesCount] = comp; + return roomVerticesCount++; + } + + int32 addMesh(Mesh* mesh) + { + for (int32 i = 0; i < meshes.count; i++) + { + const Mesh* m = meshes[i]; + if (m->center.x != mesh->center.x || + m->center.y != mesh->center.y || + m->center.z != mesh->center.z || + m->radius != mesh->radius || + m->intensity != mesh->intensity || // TODO move to static mesh to save 5k + m->vCount < mesh->vCount || + m->rCount < mesh->rCount || + m->crCount < mesh->crCount || + m->tCount < mesh->tCount || + m->ctCount < mesh->ctCount) continue; + + if (memcmp(m->vertices, mesh->vertices, mesh->vCount * sizeof(mesh->vertices[0])) != 0) + continue; + + delete mesh; + + return i; + } + + return meshes.add(mesh); + } + + int32 addModel(const Model &model) + { + return 0; + } + + int32 addAnimFrames(AnimFrames* anim) + { + for (int32 i = 0; i < animFrames.count; i++) + { + const AnimFrames* af = animFrames[i]; + + if (af->size < anim->size) + continue; + + if (memcmp(af->data, anim->data, anim->size) != 0) + continue; + + delete anim; + + return i; + } + + return animFrames.add(anim); + } + + uint32 writePalette(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + uint16 pal[256]; + + for (int32 i = 0; i < 256; i++) + { + uint8 r = level->palette.colors[i * 3 + 0]; + uint8 g = level->palette.colors[i * 3 + 1]; + uint8 b = level->palette.colors[i * 3 + 2]; + + pal[i] = (r >> 1) | ((g >> 1) << 5) | ((b >> 1) << 10); + } + + pal[0] = 0; + + f.write(pal, 256); + + return offset; + } + + uint32 writeLightmap(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + { // index 0 is transparent + uint8* ptr = level->lightmap; + for (int32 i = 0; i < 32; i++) + { + *ptr++ = 0; + for (int32 j = 1; j < 256; j++, ptr++) + { + if (*ptr == 0) { + *ptr = 1; // non-zero black index + } + } + } + } + + { // to save extu.b instruction we rearrange lightmap for the range [-128..127] + uint8 remap[256]; + + uint8* ptr = level->lightmap; + for (int32 i = 0; i < 32; i++) + { + for (int32 j = 0; j < 256; j++) + { + remap[int8(j) + 128] = ptr[j]; + } + memcpy(ptr, remap, 256); + ptr += 256; + } + } + + f.write(level->lightmap, 32 * 256); + + return offset; + } + + uint32 writeRooms(FileStream &f, TR1_PC* level, const Remap* remap) + { + uint32 offset = f.align4(); + + f.seek(sizeof(Info) * level->roomsCount); + + Info infos[255]; + + for (int32 i = 0; i < level->roomsCount; i++) + { + const TR1_PC::Room* room = level->rooms + i; + + Info &info = infos[i]; + + ASSERT(room->info.x % 256 == 0); + ASSERT(room->info.z % 256 == 0); + ASSERT(room->info.yBottom >= -32768 && room->info.yBottom <= 32767); + ASSERT(room->info.yTop >= -32768 && room->info.yTop <= 32767); + info.x = room->info.x / 256; + info.z = room->info.z / 256; + + info.yBottom = -32768; + info.yTop = 32767; + + for (int32 j = 0; j < room->vCount; j++) + { + TR1_PC::Room::Vertex &v = room->vertices[j]; + if (v.pos.y < info.yTop) { + info.yTop = v.pos.y; + } + if (v.pos.y > info.yBottom) { + info.yBottom = v.pos.y; + } + } + + info.spritesCount = room->sCount; + info.quadsCount = room->qCount; + info.trianglesCount = room->tCount; + info.portalsCount = uint8(room->pCount); + info.lightsCount = uint8(room->lCount); + info.meshesCount = uint8(room->mCount); + info.ambient = room->ambient >> 5; + info.xSectors = uint8(room->xSectors); + info.zSectors = uint8(room->zSectors); + info.alternateRoom = uint8(room->alternateRoom); + + info.flags = 0; + if (room->flags & 1) info.flags |= 1; + if (room->flags & 256) info.flags |= 2; + + ASSERT((room->flags & ~257) == 0); + ASSERT(info.portalsCount == room->pCount); + ASSERT(info.lightsCount == room->lCount); + ASSERT(info.meshesCount == room->mCount); + ASSERT(info.xSectors == room->xSectors); + ASSERT(info.zSectors == room->zSectors); + + roomVerticesCount = 0; + + info.quads = f.align4(); + + int32 prev = 0; + + for (int32 i = 0; i < room->qCount; i++) + { + TR1_PC::Quad q = room->quads[i]; + uint16 texIndex = q.flags & FACE_TEXTURE; + + int32 i0 = addRoomVertex(info.yTop, room->vertices[q.indices[0]]); + int32 i1 = addRoomVertex(info.yTop, room->vertices[q.indices[1]]); + int32 i2 = addRoomVertex(info.yTop, room->vertices[q.indices[2]]); + int32 i3 = addRoomVertex(info.yTop, room->vertices[q.indices[3]]); + + int32 p0 = i0 - prev; + int32 p1 = i1 - i0; + int32 p2 = i2 - i1; + int32 p3 = i3 - i2; + prev = i3; + + // pre-shift + //p0 <<= 1; + //p1 <<= 1; + //p2 <<= 1; + //p3 <<= 1; + + ASSERT(p0 >= -128 && p0 <= 127); + ASSERT(p1 >= -128 && p1 <= 127); + ASSERT(p2 >= -128 && p2 <= 127); + ASSERT(p3 >= -128 && p3 <= 127); + + RoomQuad comp; + comp.indices[0] = p0; + comp.indices[1] = p1; + comp.indices[2] = p2; + comp.indices[3] = p3; + + comp.flags = remap ? remap->textures[texIndex] : texIndex; + + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + info.triangles = f.align4(); + for (int32 i = 0; i < room->tCount; i++) + { + TR1_PC::Triangle t = room->triangles[i]; + uint16 texIndex = t.flags & FACE_TEXTURE; + + RoomTriangle comp; + int32 i0 = addRoomVertex(info.yTop, room->vertices[t.indices[0]]); + int32 i1 = addRoomVertex(info.yTop, room->vertices[t.indices[1]]); + int32 i2 = addRoomVertex(info.yTop, room->vertices[t.indices[2]]); + comp.flags = remap ? remap->textures[texIndex] : texIndex; + + // pre-shift + i0 <<= 3; + i1 <<= 3; + i2 <<= 3; + + ASSERT(i0 >= 0 && i0 <= 0xFFFF); + ASSERT(i1 >= 0 && i1 <= 0xFFFF); + ASSERT(i2 >= 0 && i2 <= 0xFFFF); + + comp.indices[0] = i0; + comp.indices[1] = i1; + comp.indices[2] = i2; + + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + info.vertices = f.align4(); + info.verticesCount = roomVerticesCount; + for (int32 i = 0; i < roomVerticesCount; i++) + { + roomVertices[i].write(f); + } + + info.sprites = f.align4(); + for (int32 i = 0; i < room->sCount; i++) + { + const TR1_PC::Room::Sprite* sprite = room->sprites + i; + const TR1_PC::Room::Vertex* v = room->vertices + sprite->index; + + Sprite comp; + comp.x = v->pos.x; + comp.y = v->pos.y; + comp.z = v->pos.z; + comp.g = v->lighting >> 5; + comp.index = uint8(sprite->texture); + + ASSERT(sprite->texture <= 255); + + comp.write(f); + } + + info.portals = f.align4(); + #if 0 // -72k + for (int32 i = 0; i < room->pCount; i++) + { + Portal p = room->portals[i]; + p.write(f); + } + #else + f.writeObj(room->portals, room->pCount); + #endif + + info.sectors = f.align4(); + f.writeObj(room->sectors, room->zSectors * room->xSectors); + + info.lights = f.align4(); + for (int32 i = 0; i < room->lCount; i++) + { + const TR1_PC::Room::Light* light = room->lights + i; + + Light comp; + comp.pos.x = light->pos.x - room->info.x; + comp.pos.y = light->pos.y; + comp.pos.z = light->pos.z - room->info.z; + comp.radius = light->radius >> 8; + comp.intensity = light->intensity >> 5; + + comp.write(f); + } + + info.meshes = f.align4(); + for (int32 i = 0; i < room->mCount; i++) + { + const TR1_PC::Room::Mesh* mesh = room->meshes + i; + + RoomMesh comp; + comp.pos.x = mesh->pos.x - room->info.x; + comp.pos.y = mesh->pos.y; + comp.pos.z = mesh->pos.z - room->info.z; + comp.intensity = mesh->intensity >> 5; + comp.flags = ((mesh->angleY / 0x4000 + 2) << 6) | mesh->id; + + ASSERT(mesh->id <= 63); + ASSERT(mesh->angleY % 0x4000 == 0); + ASSERT(mesh->angleY / 0x4000 + 2 >= 0); + + comp.write(f); + } + } + + int32 pos = f.getPos(); + f.setPos(offset); + f.writeObj(infos, level->roomsCount); + f.setPos(pos); + + return offset; + } + + uint32 writeFloors(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->floors, level->floorsCount); + + return offset; + } + + uint32 writeStaticMeshes(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->staticMeshesCount; i++) + { + const TR1_PC::StaticMesh* staticMesh = level->staticMeshes + i; + + StaticMesh comp; + comp.id = staticMesh->id; + comp.meshIndex = staticMesh->meshIndex; + comp.flags = staticMesh->flags; + + comp.vbox.minX = staticMesh->vbox.minX; + comp.vbox.maxX = staticMesh->vbox.maxX; + comp.vbox.minY = staticMesh->vbox.minY; + comp.vbox.maxY = staticMesh->vbox.maxY; + comp.vbox.minZ = staticMesh->vbox.minZ; + comp.vbox.maxZ = staticMesh->vbox.maxZ; + + comp.cbox.minX = staticMesh->cbox.minX; + comp.cbox.maxX = staticMesh->cbox.maxX; + comp.cbox.minY = staticMesh->cbox.minY; + comp.cbox.maxY = staticMesh->cbox.maxY; + comp.cbox.minZ = staticMesh->cbox.minZ; + comp.cbox.maxZ = staticMesh->cbox.maxZ; + + comp.write(f); + } + + return offset; + } + + uint32 writeCameras(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->cameras, level->camerasCount); + + return offset; + } + + uint32 writeSoundSources(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->soundSources, level->soundSourcesCount); + + return offset; + } + + uint32 writeBoxes(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->boxesCount; i++) + { + const TR1_PC::Box* box = level->boxes + i; + + Box comp; + comp.minX = box->minX / 1024; + comp.minZ = box->minZ / 1024; + comp.maxX = (box->maxX + 1) / 1024; + comp.maxZ = (box->maxZ + 1) / 1024; + comp.floor = box->floor; + comp.overlap = box->overlap; + + comp.write(f); + } + + return offset; + } + + uint32 writeOverlaps(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.write(level->overlaps, level->overlapsCount); + + return offset; + } + + void writeZones(FileStream &f, TR1_PC* level, uint32* zoneOffset) + { + for (int32 i = 0; i < 2; i++) + { + *zoneOffset++ = f.align4(); + f.write(level->zones[i].ground1, level->boxesCount); + + *zoneOffset++ = f.align4(); + f.write(level->zones[i].ground2, level->boxesCount); + + *zoneOffset++ = f.align4(); + f.write(level->zones[i].fly, level->boxesCount); + } + } + + uint32 writeAnimTex(FileStream &f, TR1_PC* level, const Remap* remap) + { + uint32 offset = f.align4(); + + const uint16* data = level->animTexData; + + int16 rangesCount = *data++; + + f.write(rangesCount); + + for (int32 i = 0; i < rangesCount; i++) + { + int16 texCount = *data++; + + f.write(texCount); + + for (int32 j = 0; j <= texCount; j++) + { + uint16 texIndex = *data++; + + if (remap) + { + texIndex = remap->textures[texIndex]; + } + + f.write(texIndex); + } + } + + return offset; + } + + uint32 writeItems(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->itemsCount; i++) + { + const TR1_PC::Item* item = level->items + i; + const TR1_PC::Room* room = level->rooms + item->roomIndex; + + Item comp; + comp.type = uint8(item->type); + comp.roomIndex = uint8(item->roomIndex); + comp.pos.x = int16(item->pos.x - room->info.x); + comp.pos.y = int16(item->pos.y); + comp.pos.z = int16(item->pos.z - room->info.z); + comp.intensity = item->intensity < 0 ? 0 : (item->intensity >> 5); + comp.flags = item->flags | ((item->angleY / 0x4000 + 2) << 14); + + ASSERT((item->flags & ~(0x3F1F)) == 0); + + comp.write(f); + } + + return offset; + } + + uint32 writeCameraFrames(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->cameraFrames, level->cameraFramesCount); + + return offset; + } + + void convert32X(FileStream &f, TR1_PC* pc) + { + pc->fixHeadMask(); + + Header header; + f.seek(sizeof(Header)); // will be rewritten at the end + + header.magic = 0x20414247; + header.tilesCount = pc->tilesCount; + header.roomsCount = pc->roomsCount; + header.modelsCount = pc->modelsCount; + header.meshesCount = pc->meshOffsetsCount; + header.staticMeshesCount = pc->staticMeshesCount; + header.spriteSequencesCount = pc->spriteSequencesCount; + header.soundSourcesCount = pc->soundSourcesCount; + header.boxesCount = pc->boxesCount; + header.texturesCount = pc->objectTexturesCount; + header.spritesCount = pc->spriteTexturesCount; + header.itemsCount = pc->itemsCount; + header.camerasCount = pc->camerasCount; + header.cameraFramesCount = pc->cameraFramesCount; + header.soundOffsetsCount = pc->soundOffsetsCount; + + header.palette = writePalette(f, pc); + header.lightmap = writeLightmap(f, pc); + + header.tiles = f.align4(); + f.write((uint8*)pc->tiles, header.tilesCount * 256 * 256); + + header.rooms = writeRooms(f, pc, NULL); + header.floors = writeFloors(f, pc); + + header.meshData = f.align4(); + + int32 mOffsets[2048]; + for (int32 i = 0; i < 2048; i++) { + mOffsets[i] = -1; + } + + for (int32 i = 0; i < pc->meshOffsetsCount; i++) + { + if (mOffsets[i] != -1) + continue; + + mOffsets[i] = f.align4() - header.meshData; + + const uint8* ptr = (uint8*)pc->meshData + pc->meshOffsets[i]; + + Mesh* mesh = new Mesh(pc, ptr); + mesh->write(f, NULL); + delete[] mesh; + + for (int32 j = i + 1; j < pc->meshOffsetsCount; j++) + { + if (pc->meshOffsets[i] == pc->meshOffsets[j]) + { + mOffsets[j] = mOffsets[i]; + } + } + } + + header.meshOffsets = f.align4(); + f.write(mOffsets, pc->meshOffsetsCount); + + header.anims = f.align4(); + f.writeObj(pc->anims, pc->animsCount); + + header.states = f.align4(); + for (int32 i = 0; i < pc->statesCount; i++) + { + const TR1_PC::AnimState* state = pc->states + i; + + AnimState comp; + comp.state = uint8(state->state); + comp.rangesCount = uint8(state->rangesCount); + comp.rangesStart = state->rangesStart; + + comp.write(f); + } + + header.ranges = f.align4(); + f.writeObj(pc->ranges, pc->rangesCount); + + header.commands = f.align4(); + f.write(pc->commands, pc->commandsCount); + + header.nodes = f.align4(); + for (int32 i = 0; i < pc->nodesDataSize / 4; i++) + { + const TR1_PC::Node* node = (TR1_PC::Node*)(pc->nodesData + i * 4); + + ASSERT(node->pos.x > -32768); + ASSERT(node->pos.x < 32767); + ASSERT(node->pos.y > -32768); + ASSERT(node->pos.y < 32767); + ASSERT(node->pos.z > -32768); + ASSERT(node->pos.z < 32767); + ASSERT(node->flags < 0xFFFF); + + Node comp; + comp.flags = uint16(node->flags); + comp.pos.x = int16(node->pos.x); + comp.pos.y = int16(node->pos.y); + comp.pos.z = int16(node->pos.z); + + comp.write(f); + } + + header.frameData = f.align4(); + f.write(pc->frameData, pc->frameDataSize); + + header.models = f.align4(); + for (int32 i = 0; i < pc->modelsCount; i++) + { + const TR1_PC::Model* model = pc->models + i; + + Model comp; + comp.type = uint8(model->type); + comp.count = uint8(model->count); + comp.start = model->start; + comp.nodeIndex = model->nodeIndex / 4; + comp.animIndex = model->animIndex; + + comp.write(f); + } + + header.staticMeshes = writeStaticMeshes(f, pc); + + header.objectTextures = f.align4(); + for (int32 i = 0; i < pc->objectTexturesCount; i++) + { + ObjectTexture comp(pc->objectTextures + i); + comp.write(f); + } + + header.spriteTextures = f.align4(); + for (int32 i = 0; i < pc->spriteTexturesCount; i++) + { + SpriteTexture comp(pc->spriteTextures + i); + comp.write(f); + } + + header.spriteSequences = f.align4(); + f.writeObj(pc->spriteSequences, pc->spriteSequencesCount); + + header.cameras = writeCameras(f, pc); + header.soundSources = writeSoundSources(f, pc); + header.boxes = writeBoxes(f, pc); + header.overlaps = writeOverlaps(f, pc); + writeZones(f, pc, header.zones[0]); + header.animTexData = writeAnimTex(f, pc, NULL); + header.items = writeItems(f, pc); + header.cameraFrames = writeCameraFrames(f, pc); + + //f.writeArray(demoData, demoDataSize); + + for (int32 i = 0; i < pc->soundOffsetsCount; i++) + { + uint8* ptr = pc->soundData + pc->soundOffsets[i]; + int32 size = *(int32*)(ptr + 40); + uint8* src = ptr + 44; + uint8* dst = ptr; + + while ((dst - pc->soundData) % 4 != 0) { + dst++; + } + dst += 4; + + for (int32 j = 0; j < size; j++) + { + dst[j] = src[j]; + } + + while ((size % 4) != 0) + { + dst[size] = dst[size - 1]; + size++; + } + + dst -= 4; + *(int32*)dst = size; + + pc->soundOffsets[i] = uint32(dst - pc->soundData); + } + + #if 0 // no sound + header.soundMap = f.align4(); + f.write(pc->soundMap, 256); + + header.soundInfos = f.align4(); + f.writeObj(pc->soundInfo, pc->soundInfoCount); + + header.soundData = f.align4(); + f.write(pc->soundData, pc->soundDataSize); + + header.soundOffsets = f.align4(); + f.write(pc->soundOffsets, pc->soundOffsetsCount); + #endif + + f.setPos(0); + header.write(f); + } + + void convertTracks(FileStream &f, const char* from) + { + char buf[256]; + sprintf(buf, "%s/*.ima", from); + + WIN32_FIND_DATA fd; + HANDLE h = FindFirstFile(buf, &fd); + + if (h == INVALID_HANDLE_VALUE) + return; + + struct Track { + int32 size; + char* data; + }; + Track tracks[MAX_TRACKS]; + memset(tracks, 0, sizeof(tracks)); + + do + { + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + const char* src = fd.cFileName; + char* dst = buf; + + while (*src) + { + if (*src >= '0' && *src <= '9') + { + *dst++ = *src; + } + src++; + } + *dst++ = 0; + + int32 index = atoi(buf); + + if (index != 0) + { + strcpy(buf, from); + strcat(buf, "/"); + strcat(buf, fd.cFileName); + + FILE* f = fopen(buf, "rb"); + + if (!f) + continue; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + tracks[index].data = new char[size + 4]; + fread(tracks[index].data, 1, size, f); + fclose(f); + + tracks[index].size = ALIGN(*((int32*)tracks[index].data + 2), 4) - 4; + + ASSERT(tracks[index].size % 4 == 0); + } + } + } + while (FindNextFile(h, &fd)); + FindClose(h); + + int32 offset = MAX_TRACKS * (4 + 4); + + for (int32 i = 0; i < MAX_TRACKS; i++) + { + if (tracks[i].size == 0) { + int32 zero = 0; + f.write(zero); + } else { + f.write(offset); + } + f.write(tracks[i].size); + offset += tracks[i].size; + } + + for (int32 i = 0; i < MAX_TRACKS; i++) + { + if (tracks[i].size == 0) + continue; + f.write((uint8*)tracks[i].data + 16, tracks[i].size); + delete[] tracks[i].data; + } + } + + void convertScreen(const char* dir, const char* name, const TR1_PC::Palette &pal) + { + char path[256]; + sprintf(path, "screens/%s.bmp", name); + + int32 width, height, bpp; + uint32* data = (uint32*)loadBitmap(path, &width, &height, &bpp); + + ASSERT(data); + ASSERT(width == 240 && height == 160 && bpp == 32); + + uint32* uniqueColors = new uint32[width * height]; + int32 count = 0; + + for (int32 i = 0; i < width * height; i++) + { + uint32 c = data[i]; + + int32 index = -1; + + for (int32 j = 0; j < count; j++) + { + if (uniqueColors[j] == c) { + index = j; + break; + } + } + + if (index == -1) { + index = count++; + uniqueColors[index] = c; + } + + data[i] = index; + } + + for (int32 i = 0; i < count; i++) + { + uint32 c = uniqueColors[i]; + + int32 cr = (c >> 16) & 0xFF; + int32 cg = (c >> 8) & 0xFF; + int32 cb = c & 0xFF; + + float dist = 256 * 256 * 256; + int32 index = 0; + + for (int32 j = 0; j < 256; j++) + { + int32 r = pal.colors[j * 3 + 0] << 2; + int32 g = pal.colors[j * 3 + 1] << 2; + int32 b = pal.colors[j * 3 + 2] << 2; + + float d = sqrtf(float(SQR(cr - r) + SQR(cg - g) + SQR(cb - b))); + if (d < dist) + { + dist = d; + index = j; + } + } + + uniqueColors[i] = index; + } + + uint8* indices = new uint8[width * height]; + for (int32 i = 0; i < width * height; i++) + { + indices[i] = uniqueColors[data[i]]; + } + + sprintf(path, "%s/%s.SCR", dir, name); + + FILE *f = fopen(path, "wb"); + fwrite(indices, 1, width * height, f); + fclose(f); + + delete[] data; + delete[] uniqueColors; + delete[] indices; + } + + void markAnimatedTextures(TR1_PC* level) + { + const uint16* data = level->animTexData; + + int16 rangesCount = *data++; + + for (int32 i = 0; i < rangesCount; i++) + { + int16 texCount = *data++; + + for (int32 j = 0; j <= texCount; j++) + { + level->objectTextures[*data++].attribute |= TEX_ATTR_ANIM; + } + } + } + + void process(const char* dir, TR1_PC** pc, TR1_PSX** psx) + { + roomVerticesCount = 0; + roomVertices = new RoomVertex[MAX_ROOM_VERTICES]; + + char buf[256]; + + for (int32 i = 0; i < LVL_MAX; i++) + { + sprintf(buf, "%s/%s.PKD", dir, levelNames[i]); + FileStream f(buf, true); + f.bigEndian = true; + + if (!f.isValid()) { + printf("can't save \"%s\"\n", buf); + continue; + } + + convert32X(f, pc[i]); + } + + delete[] roomVertices; + } +}; + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/out_3DO.h b/src/platform/gba/packer/out_3DO.h new file mode 100644 index 00000000..28255412 --- /dev/null +++ b/src/platform/gba/packer/out_3DO.h @@ -0,0 +1,3197 @@ +#ifndef H_OUT_3DO +#define H_OUT_3DO + +#include "common.h" +#include "TR1_PC.h" +#include "TR1_PSX.h" + +// TODO use PSX format as source +struct out_3DO +{ + void process(const char* dir, TR1_PC** pc, TR1_PSX** psx) + { + // + } +}; + + +#if 0 + +#pragma pack(1) +struct LevelPC +{ + struct RoomQuad3DO + { + uint16 indices[4]; + uint32 flags; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + } + }; + + struct MeshQuad3DO + { + uint8 indices[4]; + uint32 flags; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[3]); + f.write(indices[2]); + f.write(indices[1]); + f.write(indices[0]); + } + }; + + struct Quad + { + uint16 indices[4]; + uint16 flags; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + f.write(flags); + } + }; + + struct RoomTriangle3DO + { + uint16 indices[3]; + uint16 _unused; + uint32 flags; + + void write(FileStream &f) const + { + f.write(flags); + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(_unused); + } + }; + + struct MeshTriangle3DO + { + uint8 indices[3]; + uint8 _unused; + uint32 flags; + + void write(FileStream &f) const + { + f.write(flags); + uint8 unused = 0; + f.write(unused); + f.write(indices[2]); + f.write(indices[1]); + f.write(indices[0]); + } + }; + + struct Triangle + { + uint16 indices[3]; + uint16 flags; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(flags); + } + }; + + struct Room + { + struct Info + { + int32 x; + int32 z; + int32 yBottom; + int32 yTop; + int32 dataSize; + }; + + struct Vertex + { + vec3s pos; + int16 lighting; + + bool isEqual(const Vertex *v) + { + return pos.x == v->pos.x && pos.y == v->pos.y && pos.z == v->pos.z && lighting == v->lighting; + } + }; + + struct VertexComp + { + int8 x, y, z; + uint8 g; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + } + }; + + struct Sprite + { + uint16 index; + uint16 texture; + }; + + struct SpriteComp + { + int16 x, y, z; + uint8 g; + uint8 index; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + f.write(index); + } + }; + /* + struct MeshComp { + vec3s center; + int16 radius; + + int16 vCount; + int16 nCount; + + int16 rCount; + int16 tCount; + + vec3s* vertices; + Quad* quads; + Triangle* triangles; + };*/ + + struct Portal + { + int16 roomIndex; + vec3s normal; + vec3s vertices[4]; + + void write(FileStream &f) const + { + f.write(roomIndex); + f.write(normal.x); + f.write(normal.y); + f.write(normal.z); + for (int32 i = 0; i < 4; i++) + { + f.write(vertices[i].x); + f.write(vertices[i].y); + f.write(vertices[i].z); + } + } + }; + + struct PortalComp + { + uint32 roomIndex; + uint32 normalMask; + vec3i vertices[4]; + + void write(FileStream &f) const + { + f.write(roomIndex); + f.write(normalMask); + for (int32 i = 0; i < 4; i++) + { + f.write(vertices[i].x); + f.write(vertices[i].y); + f.write(vertices[i].z); + } + } + }; + + struct Sector + { + uint16 floorIndex; + uint16 boxIndex; + uint8 roomBelow; + int8 floor; + uint8 roomAbove; + int8 ceiling; + + void write(FileStream &f) const + { + f.write(floorIndex); + f.write(boxIndex); + f.write(roomBelow); + f.write(floor); + f.write(roomAbove); + f.write(ceiling); + } + }; + + struct Light + { + vec3i pos; + uint16 intensity; + int32 radius; + }; + + struct LightComp + { + vec3s pos; + uint8 radius; + uint8 intensity; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(radius); + f.write(intensity); + } + }; + + struct Mesh + { + vec3i pos; + int16 angleY; + uint16 intensity; + uint16 id; + }; + + struct MeshComp + { + vec3s pos; + uint8 intensity; + uint8 flags; + + void write(FileStream &f) const + { + uint32 xy = (pos.x << 16) | uint16(pos.y); + uint32 zf = (pos.z << 16) | (intensity << 8) | flags; + f.write(xy); + f.write(zf); + } + }; + + Info info; + + int16 vCount; + Vertex* vertices; + + int16 qCount; + Quad* quads; + + int16 tCount; + Triangle* triangles; + + int16 sCount; + Sprite* sprites; + + int16 pCount; + Portal* portals; + + uint16 zSectors; + uint16 xSectors; + Sector* sectors; + + uint16 ambient; + + uint16 lCount; + Light* lights; + + uint16 mCount; + Mesh* meshes; + + int16 alternateRoom; + uint16 flags; + }; + + struct FloorData + { + uint16 value; + + void write(FileStream &f) const + { + f.write(value); + } + }; + + struct Animation + { + uint32 frameOffset; + + uint8 frameRate; + uint8 frameSize; + uint16 state; + + uint32 speed; + uint32 accel; + + uint16 frameBegin; + uint16 frameEnd; + + uint16 nextAnimIndex; + uint16 nextFrameIndex; + + uint16 statesCount; + uint16 statesStart; + + uint16 commandsCount; + uint16 commandsStart; + + void write(FileStream &f) const + { + f.write(frameOffset); + f.write(frameRate); + f.write(frameSize); + f.write(state); + f.write(speed); + f.write(accel); + f.write(frameBegin); + f.write(frameEnd); + f.write(nextAnimIndex); + f.write(nextFrameIndex); + f.write(statesCount); + f.write(statesStart); + f.write(commandsCount); + f.write(commandsStart); + } + }; + + struct AnimState + { + uint16 state; + uint16 rangesCount; + uint16 rangesStart; + }; + + struct AnimStateComp + { + uint8 state; + uint8 rangesCount; + uint16 rangesStart; + + void write(FileStream &f) const + { + f.write(state); + f.write(rangesCount); + f.write(rangesStart); + } + }; + + struct AnimRange + { + int16 frameBegin; + int16 frameEnd; + int16 nextAnimIndex; + int16 nextFrameIndex; + + void write(FileStream &f) const + { + f.write(frameBegin); + f.write(frameEnd); + f.write(nextAnimIndex); + f.write(nextFrameIndex); + } + }; + + struct Model + { + uint32 type; + uint16 count; + uint16 start; + uint32 nodeIndex; + uint32 frameIndex; + uint16 animIndex; + }; + + struct ModelComp + { + uint8 type; + uint8 count; + uint16 start; + uint16 nodeIndex; + uint16 animIndex; + + void write(FileStream &f) const + { + f.write(type); + f.write(count); + f.write(start); + f.write(nodeIndex); + f.write(animIndex); + } + }; + + struct MinMax + { + int16 minX, maxX; + int16 minY, maxY; + int16 minZ, maxZ; + + void write(FileStream &f) const + { + f.write(minX); f.write(maxX); + f.write(minY); f.write(maxY); + f.write(minZ); f.write(maxZ); + } + }; + + struct Sphere16 + { + int16 x, y, z, radius; + + void write(FileStream &f) const + { + uint32 xy = (x << 16) | uint16(y); + uint32 zr = (z << 16) | uint16(radius); + f.write(xy); + f.write(zr); + } + }; + + struct StaticMesh + { + uint32 id; + uint16 meshIndex; + MinMax vbox; + MinMax cbox; + uint16 flags; + }; + + struct StaticMeshComp + { + uint16 id; + uint16 meshIndex; + uint32 flags; + //Sphere16 vs; + MinMax vbox; + MinMax cbox; + + void write(FileStream &f) const + { + Sphere16 vs; + vs.x = (vbox.maxX + vbox.minX) >> 1; + vs.y = (vbox.maxY + vbox.minY) >> 1; + vs.z = (vbox.maxZ + vbox.minZ) >> 1; + + int32 dx = (vbox.maxX - vbox.minX) >> 1; + int32 dy = (vbox.maxY - vbox.minY) >> 1; + int32 dz = (vbox.maxZ - vbox.minZ) >> 1; + + vs.radius = int32(sqrtf(float(dx * dx + dy * dy + dz * dz))); + + f.write(id); + f.write(meshIndex); + f.write(flags); + vs.write(f); + vbox.write(f); + cbox.write(f); + } + }; + + struct ObjectTexture + { + uint16 attribute; + uint16 tile; + union { + struct { uint8 xh0, x0, yh0, y0; }; + uint32 uv0; + }; + + union { + struct { uint8 xh1, x1, yh1, y1; }; + uint32 uv1; + }; + + union { + struct { uint8 xh2, x2, yh2, y2; }; + uint32 uv2; + }; + + union { + struct { uint8 xh3, x3, yh3, y3; }; + uint32 isQuad; + uint32 uv3; + }; + }; + + struct ObjectTextureComp + { + uint16 attribute; + uint16 tile; + uint32 uv0; + uint32 uv1; + uint32 uv2; + uint32 uv3; + + void write(FileStream &f) const + { + f.write(attribute); + f.write(tile); + f.write(uv0); + f.write(uv1); + f.write(uv2); + f.write(uv3); +/* + union TexCoord { + struct { uint16 v, u; }; + uint32 uv; + } t; + + + t.uv = uv0; + f.write(t.v); + f.write(t.u); + + t.uv = uv1; + f.write(t.v); + f.write(t.u); + + t.uv = uv2; + f.write(t.v); + f.write(t.u); + + t.uv = uv3; + f.write(t.v); + f.write(t.u); +*/ + } + }; + + struct SpriteTexture + { + uint16 tile; + uint8 u, v; + uint16 w, h; + int16 l, t, r, b; + + void write(FileStream &f) const + { + f.write(tile); + f.write(u); + f.write(v); + f.write(w); + f.write(h); + f.write(l); + f.write(t); + f.write(r); + f.write(b); + } + }; + + struct SpriteTextureComp + { + uint16 tile; + uint8 u, v; + uint8 w, h; + int16 l, t, r, b; + + void write(FileStream &f) const + { + f.write(tile); + f.write(u); + f.write(v); + f.write(w); + f.write(h); + f.write(l); + f.write(t); + f.write(r); + f.write(b); + } + }; + + struct SpriteTexture3DO + { + uint32 texture; + int32 l, t, r, b; + + void write(FileStream &f) const + { + f.write(texture); + f.write(l); + f.write(t); + f.write(r); + f.write(b); + } + }; + + struct SpriteSequence + { + uint16 type; + uint16 unused; + int16 count; + int16 start; + + void write(FileStream &f) const + { + f.write(type); + f.write(unused); + f.write(count); + f.write(start); + } + }; + + struct Camera + { + vec3i pos; + int16 roomIndex; + uint16 flags; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(roomIndex); + f.write(flags); + } + }; + + struct SoundSource + { + vec3i pos; + uint16 id; + uint16 flags; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(id); + f.write(flags); + } + }; + + struct Box + { + int32 minZ, maxZ; + int32 minX, maxX; + int16 floor; + int16 overlap; + }; + + struct BoxComp + { + uint8 minZ, maxZ; + uint8 minX, maxX; + int16 floor; + int16 overlap; + + void write(FileStream &f) const + { + f.write(minZ); + f.write(maxZ); + f.write(minX); + f.write(maxX); + f.write(floor); + f.write(overlap); + } + }; + + struct Zone + { + uint16* ground1; + uint16* ground2; + uint16* fly; + }; + + struct Item + { + uint16 type; + int16 roomIndex; + vec3i pos; + int16 angleY; + int16 intensity; + uint16 flags; + }; + + struct ItemComp + { + uint8 type; + uint8 roomIndex; + vec3s pos; + int16 intensity; + uint16 flags; + + void write(FileStream &f) const + { + f.write(type); + f.write(roomIndex); + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(intensity); + f.write(flags); + } + }; + + struct CameraFrame + { + vec3s target; + vec3s pos; + int16 fov; + int16 roll; + + void write(FileStream &f) const + { + f.write(target.x); + f.write(target.y); + f.write(target.z); + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(fov); + f.write(roll); + } + }; + + struct SoundInfo + { + uint16 index; + uint16 volume; + uint16 chance; + + union { + struct { + uint16 mode:2, count:4, unused:6, camera:1, pitch:1, gain:1, :1; + }; + + uint16 value; + } flags; + + void write(FileStream &f) const + { + f.write(index); + f.write(volume); + f.write(chance); + f.write(flags.value); + } + }; + + enum NodeFlag + { + NODE_FLAG_POP = (1 << 0), + NODE_FLAG_PUSH = (1 << 1), + NODE_FLAG_ROTX = (1 << 2), + NODE_FLAG_ROTY = (1 << 3), + NODE_FLAG_ROTZ = (1 << 4), + }; + + struct Node + { + uint32 flags; + vec3i pos; + }; + + struct NodeComp + { + vec3s pos; + uint16 flags; + + void write(FileStream &f) + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(flags); + } + }; + + int32 tilesCount; + Tile* tiles; + + int16 roomsCount; + Room* rooms; + + int32 floorsCount; + FloorData* floors; + + int32 meshDataSize; + uint16* meshData; + + int32 meshOffsetsCount; + uint32* meshOffsets; + + int32 animsCount; + Animation* anims; + + int32 statesCount; + AnimState* states; + + int32 rangesCount; + AnimRange* ranges; + + int32 commandsCount; + int16* commands; + + int32 nodesDataSize; + uint32* nodesData; + + int32 frameDataSize; + uint16* frameData; + + int32 modelsCount; + Model* models; + + int32 staticMeshesCount; + StaticMesh* staticMeshes; + + int32 objectTexturesCount; + ObjectTexture* objectTextures; + + int32 spriteTexturesCount; + SpriteTexture* spriteTextures; + + int32 spriteSequencesCount; + SpriteSequence* spriteSequences; + + int32 camerasCount; + Camera* cameras; + + int32 soundSourcesCount; + SoundSource* soundSources; + + int32 boxesCount; + Box* boxes; + + int32 overlapsCount; + uint16* overlaps; + + Zone zones[2]; + + int32 animTexDataSize; + uint16* animTexData; + + int32 itemsCount; + Item* items; + + uint8 lightmap[32 * 256]; + Palette palette; + + uint16 cameraFramesCount; + CameraFrame* cameraFrames; + + uint16 demoDataSize; + uint8* demoData; + + int16 soundMap[256]; + int32 soundInfoCount; + SoundInfo* soundInfo; + + int32 soundDataSize; + uint8* soundData; + + int32 soundOffsetsCount; + uint32* soundOffsets; + + LevelPC(const char* fileName) + { + tiles = NULL; + + FileStream f(fileName, false); + + if (!f.isValid()) return; + + uint32 magic; + f.read(magic); + + if (magic != 0x00000020) + { + printf("Unsupported level format\n"); + return; + } + + f.readArray(tiles, tilesCount); + f.seek(4); + + f.read(roomsCount); + rooms = new Room[roomsCount]; + + for (int32 i = 0; i < roomsCount; i++) + { + Room* room = rooms + i; + + f.read(room->info); + f.readArray(room->vertices, room->vCount); + f.readArray(room->quads, room->qCount); + f.readArray(room->triangles, room->tCount); + f.readArray(room->sprites, room->sCount); + f.readArray(room->portals, room->pCount); + f.read(room->zSectors); + f.read(room->xSectors); + f.read(room->sectors, room->zSectors * room->xSectors); + f.read(room->ambient); + f.readArray(room->lights, room->lCount); + f.readArray(room->meshes, room->mCount); + f.read(room->alternateRoom); + f.read(room->flags); + } + + f.readArray(floors, floorsCount); + + f.readArray(meshData, meshDataSize); + f.readArray(meshOffsets, meshOffsetsCount); + f.readArray(anims, animsCount); + f.readArray(states, statesCount); + f.readArray(ranges, rangesCount); + f.readArray(commands, commandsCount); + f.readArray(nodesData, nodesDataSize); + f.readArray(frameData, frameDataSize); + f.readArray(models, modelsCount); + f.readArray(staticMeshes, staticMeshesCount); + f.readArray(objectTextures, objectTexturesCount); + f.readArray(spriteTextures, spriteTexturesCount); + f.readArray(spriteSequences, spriteSequencesCount); + + f.readArray(cameras, camerasCount); + f.readArray(soundSources, soundSourcesCount); + f.readArray(boxes, boxesCount); + f.readArray(overlaps, overlapsCount); + + for (int32 i = 0; i < 2; i++) + { + f.read(zones[i].ground1, boxesCount); + f.read(zones[i].ground2, boxesCount); + f.read(zones[i].fly, boxesCount); + } + + f.readArray(animTexData, animTexDataSize); + f.readArray(items, itemsCount); + f.read(lightmap); + f.read(palette); + f.readArray(cameraFrames, cameraFramesCount); + f.readArray(demoData, demoDataSize); + + f.read(soundMap); + f.readArray(soundInfo, soundInfoCount); + f.readArray(soundData, soundDataSize); + f.readArray(soundOffsets, soundOffsetsCount); + + markRoomTextures(); + } + + ~LevelPC() + { + delete[] tiles; + + for (int32 i = 0; i < roomsCount; i++) + { + Room* room = rooms + i; + delete[] room->vertices; + delete[] room->quads; + delete[] room->triangles; + delete[] room->sprites; + delete[] room->portals; + delete[] room->sectors; + delete[] room->lights; + delete[] room->meshes; + } + + delete[] rooms; + delete[] floors; + delete[] meshData; + delete[] meshOffsets; + delete[] anims; + delete[] states; + delete[] ranges; + delete[] commands; + delete[] nodesData; + delete[] frameData; + delete[] models; + delete[] staticMeshes; + delete[] objectTextures; + delete[] spriteTextures; + delete[] spriteSequences; + delete[] cameras; + delete[] soundSources; + delete[] boxes; + delete[] overlaps; + + for (int32 i = 0; i < 2; i++) + { + delete[] zones[i].ground1; + delete[] zones[i].ground2; + delete[] zones[i].fly; + } + + delete[] animTexData; + delete[] items; + delete[] cameraFrames; + delete[] demoData; + delete[] soundInfo; + delete[] soundData; + delete[] soundOffsets; + } + + void markRoomTextures() + { + for (int32 i = 0; i < roomsCount; i++) + { + Room* room = rooms + i; + + for (int32 j = 0; j < room->qCount; j++) + { + Quad* q = room->quads + j; + objectTextures[q->flags & FACE_TEXTURE].attribute |= TEX_ATTR_MIPS; + } + + for (int32 j = 0; j < room->tCount; j++) + { + Triangle* t = room->triangles + j; + objectTextures[t->flags & FACE_TEXTURE].attribute |= TEX_ATTR_MIPS; + } + } + } + + int32 addRoomVertex(int32 yOffset, const Room::Vertex &v, bool ignoreG = false) + { + Room::VertexComp comp; + int32 px = v.pos.x >> 10; + int32 py = (v.pos.y - yOffset) >> 8; + int32 pz = v.pos.z >> 10; + + ASSERT(py >= 0); + ASSERT(px < 32); + ASSERT(py < 64); + ASSERT(pz < 32); + + comp.x = px; + comp.y = py; + comp.z = pz; + comp.g = ignoreG ? 0 : (v.lighting >> 5); + + for (int32 i = 0; i < roomVerticesCount; i++) + { + if (memcmp(roomVertices + i, &comp, sizeof(comp)) == 0) + { + return i; + } + } + + roomVertices[roomVerticesCount] = comp; + + return roomVerticesCount++; + } + +// 3DO ======================================================================== + struct PLUT { + uint16 colors[16]; + } PLUTs[MAX_TEXTURES]; + int32 plutsCount; + + struct Texture3DO { + int32 data; + int32 plut; + + uint8 wShift; + uint8 hShift; + uint16 color; + + uint32 pre0; + uint32 pre1; + uint8* src; + int32 w; + int32 h; + uint16 flip; + int16 mip; + uint8* image; + + void write(FileStream &f) const + { + ASSERT(plut * sizeof(PLUT) < 0xFFFF); + uint32 shift = wShift | (hShift << 8) | ((plut * sizeof(PLUT)) << 16); + f.write(data); + f.write(shift); + } + + bool cmp(const Texture3DO &t) + { + if (wShift != t.wShift || hShift != t.hShift || plut != t.plut) + return false; + + return memcmp(image, t.image, (1 << (20 - wShift)) * (1 << (16 - hShift)) / 2) == 0; + } + + } textures3DO[MAX_TEXTURES]; + + int32 spritesBaseIndex; + + uint32 nextPow2(uint32 x) { + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x++; + return x; + } + + uint32 shiftPow2(int32 x) + { + int32 count = 0; + while (x >>= 1) { + count++; + } + return count; + } + + int32 addPalette(const PLUT &p) + { + for (int32 i = 0; i < plutsCount; i++) + { + if (memcmp(&PLUTs[i], &p, sizeof(PLUT)) == 0) + { + return i; + } + } + + PLUTs[plutsCount] = p; + + return plutsCount++; + } + + template + void calcQuadFlip(T &q) + { + Texture3DO* tex = textures3DO + (q.flags & FACE_TEXTURE); + bool flip = false; + + if (tex->flip & TEX_FLIP_X) { + swap(q.indices[0], q.indices[1]); + swap(q.indices[3], q.indices[2]); + flip = !flip; + } + + if (tex->flip & TEX_FLIP_Y) { + swap(q.indices[0], q.indices[3]); + swap(q.indices[1], q.indices[2]); + flip = !flip; + } + + if (flip) { + q.flags |= FACE_CCW; + } + } + + int32 convertTextures3DO(const char* fileName) + { + #define PRE1_WOFFSET_PREFETCH 2 + #define PRE0_VCNT_PREFETCH 1 + #define PRE0_VCNT_SHIFT 6 + #define PRE0_BPP_4 3 + #define PRE1_TLHPCNT_PREFETCH 1 + #define PRE1_TLHPCNT_SHIFT 0 + #define PRE1_TLLSB_PDC0 0x00001000 + #define PRE1_WOFFSET8_SHIFT 24 + #define PRE0_BGND 0x40000000 + #define PRE0_LINEAR 0x00000010 + #define PRE0_BPP_16 0x00000006 + + ASSERT(objectTexturesCount + spriteTexturesCount < MAX_TEXTURES); + + plutsCount = 0; + + FileStream f(fileName, true); + + if (!f.isValid()) return 0; + + f.bigEndian = true; + + // reserve 4 bytes for the PLUTs offset + f.seek(4); + + // convert palette to 15-bit and fix some color gradients + uint16 pal[256]; + + for (int32 i = 0; i < 256; i++) + { + uint8 b = palette.colors[i * 3 + 0]; + uint8 g = palette.colors[i * 3 + 1]; + uint8 r = palette.colors[i * 3 + 2]; + + pal[i] = (r >> 1) | ((g >> 1) << 5) | ((b >> 1) << 10); + } + + pal[0] = 0; + + // convert palette to 16 x PLUTs + { + for (int32 i = 0; i < 16; i++) + { + memcpy(PLUTs[i].colors, &pal[i * 16], 16 * sizeof(uint16)); + } + plutsCount = 16; + } + + // convert palette to 32-bit + uint32 pal32[256]; + for (int32 i = 0; i < 256; i++) + { + uint16 p = pal[i]; + + uint8 r = (p & 31) << 3; + uint8 g = ((p >> 5) & 31) << 3; + uint8 b = ((p >> 10) & 31) << 3; + + pal32[i] = r | (g << 8) | (b << 16); + + if (pal32[i]) { + pal32[i] |= 0xFF000000; + } + } + pal32[0] = 0; + + uint32* bitmap32 = new uint32[256 * 256]; + uint32* bitmap32_tmp = new uint32[256 * 256]; + uint8* bitmap8 = new uint8[256 * 256]; + uint8* bitmap8_tmp = new uint8[256 * 256]; + + spritesBaseIndex = objectTexturesCount; + + { + LevelPC::ObjectTexture* tmp = new LevelPC::ObjectTexture[objectTexturesCount + spriteTexturesCount]; + memcpy(tmp, objectTextures, sizeof(LevelPC::ObjectTexture) * objectTexturesCount); + + for (int32 i = 0; i < spriteTexturesCount; i++) + { + LevelPC::SpriteTexture* spriteTexture = spriteTextures + i; + LevelPC::ObjectTexture* objectTexture = tmp + objectTexturesCount + i; + + int32 w = spriteTexture->w >> 8; + int32 h = spriteTexture->h >> 8; + + objectTexture->attribute = TEX_ATTR_AKILL; + objectTexture->tile = spriteTexture->tile; + objectTexture->uv0 = 0; + objectTexture->uv1 = 0; + objectTexture->uv2 = 0; + objectTexture->uv3 = 0; + objectTexture->x0 = spriteTexture->u; + objectTexture->y0 = spriteTexture->v; + objectTexture->x1 = spriteTexture->u + w; + objectTexture->y1 = spriteTexture->v; + objectTexture->x2 = spriteTexture->u + w; + objectTexture->y2 = spriteTexture->v + h; + objectTexture->x3 = spriteTexture->u; + objectTexture->y3 = spriteTexture->v + h; + } + + delete[] objectTextures; + objectTextures = tmp; + + objectTexturesCount += spriteTexturesCount; + } + + int32 mipIndex = objectTexturesCount; + + int32 dupSize = 0; + + for (int32 i = 0; i < objectTexturesCount; i++) + { + const LevelPC::ObjectTexture* objectTexture = objectTextures + i; + + int32 x0 = MIN(MIN(objectTexture->x0, objectTexture->x1), objectTexture->x2); + int32 y0 = MIN(MIN(objectTexture->y0, objectTexture->y1), objectTexture->y2); + int32 x1 = MAX(MAX(objectTexture->x0, objectTexture->x1), objectTexture->x2); + int32 y1 = MAX(MAX(objectTexture->y0, objectTexture->y1), objectTexture->y2); + + textures3DO[i].flip = 0; + + if (objectTexture->isQuad) + { + if (objectTexture->x0 > objectTexture->x1) textures3DO[i].flip |= TEX_FLIP_X; + if (objectTexture->y0 > objectTexture->y2) textures3DO[i].flip |= TEX_FLIP_Y; + } + + int32 w = x1 - x0 + 1; + int32 h = y1 - y0 + 1; + + textures3DO[i].src = tiles[objectTexture->tile & 0x3FFF].indices + 256 * y0 + x0; + textures3DO[i].w = w; + textures3DO[i].h = h; + + { // check if the texture is already converted + int32 index = -1; + + if (objectTextures[i].isQuad) + { + for (int32 j = 0; j < i; j++) + { + if (objectTextures[j].isQuad && textures3DO[j].src == textures3DO[i].src) + { + // TODO can we reuse textures with the same src and width but smaller height? + if ((textures3DO[j].w == textures3DO[i].w) && (textures3DO[j].h == textures3DO[i].h)) + { + index = j; + break; + } + } + } + } + + if (index != -1) + { + uint8 flip = textures3DO[i].flip; + textures3DO[i] = textures3DO[index]; + textures3DO[i].flip = flip; // flip flags may differ + continue; // skip texture conversion + } + } + + + { // copy tile to 32-bit image and calculate average tile color + uint8* src = textures3DO[i].src; + uint32* dst = bitmap32; + + uint32 avgR = 0; + uint32 avgG = 0; + uint32 avgB = 0; + + for (int32 y = 0; y < h; y++) + { + for (int32 x = 0; x < w; x++) + { + if (!objectTexture->isQuad) + { + float u = float(x) / float(w - 1); + float v = float(y) / float(h - 1); + + float px0 = objectTexture->x0; + float py0 = objectTexture->y0; + float px1 = objectTexture->x1; + float py1 = objectTexture->y1; + float px2 = objectTexture->x2; + float py2 = objectTexture->y2; + float px3 = objectTexture->x2; + float py3 = objectTexture->y2; + + float px = (1.0f - u) * (1.0f - v) * px0 + u * (1.0f - v) * px1 + (1 - u) * v * px2 + u * v * px3; + float py = (1.0f - u) * (1.0f - v) * py0 + u * (1.0f - v) * py1 + (1 - u) * v * py2 + u * v * py3; + + int32 ix = int32(px + 0.5) - x0; + int32 iy = int32(py + 0.5) - y0; + + ASSERT(!(ix < 0 || ix >= w || iy < 0 || iy >= h)); + + src = textures3DO[i].src + iy * 256 + ix; + } + + uint32 p = pal32[*src++]; + *dst++ = p; + + uint32 A = p >> 24; + if (A) + { + avgR += (p >> 16) & 0xFF; + avgG += (p >> 8) & 0xFF; + avgB += (p) & 0xFF; + } + } + src += 256 - w; + } + + avgR /= w * h; + avgG /= w * h; + avgB /= w * h; + + textures3DO[i].color = (avgB >> 3) | ((avgG >> 3) << 5) | ((avgR >> 3) << 10); + } + + { // resize to POT + int32 wp = nextPow2(w); + int32 hp = nextPow2(h); + + if (wp != w) { + wp /= 2; + } + + if (hp != h) { + hp /= 2; + } + + if (wp > 64) { + wp = 64; + } + + if (hp > 64) { + hp = 64; + } + + ASSERT(wp != 0 && hp != 0); + + if (w != wp || h != hp) + { + stbir_resize_uint8_generic((uint8*)bitmap32, w, h, 0, (uint8*)bitmap32_tmp, wp, hp, 0, 4, 3, 0, + STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); + swap(bitmap32, bitmap32_tmp); + + w = wp; + h = hp; + } + } + + /*{ + char buf[128]; + sprintf(buf, "tex%d.bmp", i); + saveBitmap(buf, (uint8*)bitmap32, w, h, 32); + }*/ + + int32 rowBytes = (((w * 4) + 31) >> 5) << 2; + if (rowBytes < 8) { + rowBytes = 8; + } + int32 rowWOFFSET = (rowBytes >> 2) - PRE1_WOFFSET_PREFETCH; + + textures3DO[i].pre0 = ((h - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT) | PRE0_BPP_4; + textures3DO[i].pre1 = ((w - PRE1_TLHPCNT_PREFETCH) << PRE1_TLHPCNT_SHIFT) | PRE1_TLLSB_PDC0 | (rowWOFFSET << PRE1_WOFFSET8_SHIFT); + textures3DO[i].wShift = 20 - shiftPow2(w); + textures3DO[i].hShift = 16 - shiftPow2(h); + + if (!(objectTexture->attribute & TEX_ATTR_AKILL)) { + textures3DO[i].pre0 |= PRE0_BGND; + } + + { // quantize to 16 colors + liq_attr *attr = liq_attr_create(); + liq_image *image = liq_image_create_rgba(attr, bitmap32, w, h, 0); + liq_set_max_colors(attr, 16); + + liq_result *res; + liq_image_quantize(image, attr, &res); + + liq_write_remapped_image(res, image, bitmap8, 256 * 256); + const liq_palette *pal8 = liq_get_palette(res); + + PLUT plut; + + memset(&plut, 0, sizeof(plut)); + for(int32 j = 0; j < pal8->count; j++) + { + liq_color c = pal8->entries[j]; + if (c.a < 128) { + plut.colors[j] = 0; + } else { + plut.colors[j] = (c.r >> 3) | ((c.g >> 3) << 5) | ((c.b >> 3) << 10); + } + } + + textures3DO[i].plut = addPalette(plut); + + liq_result_destroy(res); + liq_image_destroy(image); + liq_attr_destroy(attr); + } + + if (rowBytes * 2 != w) // adjust row pitch + { + uint8* src = bitmap8; + uint8* dst = bitmap8_tmp; + memset(dst, 0, (rowBytes * 2) * h); + + for (int32 y = 0; y < h; y++) { + memcpy(dst, src, w); + dst += rowBytes * 2; + src += w; + } + + swap(bitmap8, bitmap8_tmp); + } + + { // encode to 4-bit image + textures3DO[i].image = new uint8[rowBytes * h]; + + uint8* src = bitmap8; + uint8* dst = textures3DO[i].image; + for (int32 y = 0; y < h; y++) + { + for (int32 x = 0; x < rowBytes; x++, src += 2) + { + *dst++ = (src[0] << 4) | src[1]; + } + } + + textures3DO[i].data = 0; +/* + for (int32 j = 0; j < i; j++) + { + if (textures3DO[i].cmp(textures3DO[j])) + { + textures3DO[i].data = textures3DO[j].data; + + //ASSERT((objectTextures[i].attribute & TEX_ATTR_MIPS) == (objectTextures[j].attribute & TEX_ATTR_MIPS)); + + dupSize += rowBytes * h; + break; + } + } + */ + // write image + if (!textures3DO[i].data) { + textures3DO[i].data = f.getPos(); + + f.write(textures3DO[i].pre0); + f.write(textures3DO[i].pre1); + f.write(textures3DO[i].image, rowBytes * h); + } + } + + // generate mip level + if (!(objectTexture->attribute & TEX_ATTR_MIPS)) { + textures3DO[i].mip = -1; + continue; + } + + textures3DO[i].mip = mipIndex; + + Texture3DO* mip = &textures3DO[mipIndex++]; + *mip = textures3DO[i]; + + w >>= 1; + h >>= 1; + ASSERT(w > 0); + ASSERT(h > 0); + + { + stbir_resize_uint8_generic((uint8*)bitmap32, w << 1, h << 1, 0, (uint8*)bitmap32_tmp, w, h, 0, 4, 3, 0, + STBIR_EDGE_CLAMP, STBIR_FILTER_BOX, STBIR_COLORSPACE_LINEAR, NULL); + swap(bitmap32, bitmap32_tmp); + } + + rowBytes = (((w * 4) + 31) >> 5) << 2; + if (rowBytes < 8) { + rowBytes = 8; + } + rowWOFFSET = (rowBytes >> 2) - PRE1_WOFFSET_PREFETCH; + + mip->pre0 = ((h - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT) | PRE0_BPP_4; + mip->pre1 = ((w - PRE1_TLHPCNT_PREFETCH) << PRE1_TLHPCNT_SHIFT) | PRE1_TLLSB_PDC0 | (rowWOFFSET << PRE1_WOFFSET8_SHIFT); + mip->wShift = 20 - shiftPow2(w); + mip->hShift = 16 - shiftPow2(h); + + if (!(objectTexture->attribute & TEX_ATTR_AKILL)) { + mip->pre0 |= PRE0_BGND; + } + + { // quantize to 16 colors + liq_attr *attr = liq_attr_create(); + liq_image *image = liq_image_create_rgba(attr, bitmap32, w, h, 0); + liq_set_max_colors(attr, 16); + + liq_result *res; + liq_image_quantize(image, attr, &res); + + liq_write_remapped_image(res, image, bitmap8, 256 * 256); + const liq_palette *pal8 = liq_get_palette(res); + + PLUT plut; + + memset(&plut, 0, sizeof(plut)); + for(int32 j = 0; j < pal8->count; j++) + { + liq_color c = pal8->entries[j]; + if (c.a < 128) { + plut.colors[j] = 0; + } else { + plut.colors[j] = (c.r >> 3) | ((c.g >> 3) << 5) | ((c.b >> 3) << 10); + } + } + + mip->plut = addPalette(plut); + + liq_result_destroy(res); + liq_image_destroy(image); + liq_attr_destroy(attr); + } + + if (rowBytes * 2 != w) // adjust row pitch + { + uint8* src = bitmap8; + uint8* dst = bitmap8_tmp; + memset(dst, 0, (rowBytes * 2) * h); + + for (int32 y = 0; y < h; y++) { + memcpy(dst, src, w); + dst += rowBytes * 2; + src += w; + } + + swap(bitmap8, bitmap8_tmp); + } + + { // encode to 4-bit image + uint8* src = bitmap8; + uint8* dst = bitmap8_tmp; + for (int32 y = 0; y < h; y++) + { + for (int32 x = 0; x < rowBytes; x++, src += 2) + { + *dst++ = (src[0] << 4) | src[1]; + } + } + + // write image + mip->data = f.getPos(); + f.write(mip->pre0); + f.write(mip->pre1); + f.write(bitmap8_tmp, rowBytes * h); + } + } + + objectTexturesCount = mipIndex; + + printf("duplicate size: %d\n", dupSize); + + uint32 paletteOffset = f.align4(); + + // write PLUTs + f.write((uint16*)PLUTs, sizeof(PLUT) / 2 * plutsCount); + + // calculate underwater PLUTs (blue tint = (0.5, 0.8, 0.8)) + { + uint16* src = PLUTs[0].colors; + for (int32 i = 0; i < plutsCount * 16; i++) + { + uint16 p = *src; + + uint32 b = (p & 31) << 3; + uint32 g = ((p >> 5) & 31) << 3; + uint32 r = ((p >> 10) & 31) << 3; + + r = int32(r * 0.5f); + g = int32(g * 0.8f); + b = int32(b * 0.8f); + + *src++ = (b >> 3) | ((g >> 3) << 5) | ((r >> 3) << 10); + } + } + f.write((uint16*)PLUTs, sizeof(PLUT) / 2 * plutsCount); + + int32 texFileSize = f.getPos(); + + // write palette offset at the file start + f.setPos(0); + f.write(paletteOffset); + + delete[] bitmap32; + delete[] bitmap32_tmp; + delete[] bitmap8; + delete[] bitmap8_tmp; + + return texFileSize; + } + + void getSample(const char* base, const char* prefix, int32 id, int32 sub, uint8* buffer, int32 &size) + { + // 57 == 38? + size = 0; + + char path[256]; + sprintf(path, "%s\\%s%03d_%d.wav", base, prefix, id, sub); + + FILE* f = fopen(path, "rb"); + + if (!f) + { + if (prefix[0] == '_') // try to open file without the prefix + { + sprintf(path, "%s\\%s%03d_%d.wav", base, "", id, sub); + f = fopen(path, "rb"); + if (!f) + { + printf("%s not found!\n", path); + return; + } + } else { + printf("%s not found!\n", path); + return; + } + } + + fseek(f, 12, SEEK_SET); // skip RIFF header + + struct { + unsigned int id; + unsigned int size; + } chunk; + + while (1) + { + fread(&chunk, sizeof(chunk), 1, f); + if (chunk.id == 0x61746164) // data + { + int numSamples = chunk.size / (1 * sizeof(short)); + size = numSamples / 2; // 4 bits per sample + + short* data = new short[chunk.size / sizeof(short)]; + + fread(data, 1, chunk.size, f); + + BlockADDVIEncode(buffer, data, numSamples, 1); // mono block + + delete[] data; + + break; + } else { + fseek(f, chunk.size, SEEK_CUR); + } + } + + fclose(f); + } + + bool getSoundID(int32 index, int32 &id, int32 &sub) + { + for (int32 i = 0; i < 256; i++) + { + SoundInfo &s = soundInfo[soundMap[i]]; + if (s.index <= index && s.index + s.flags.count > index) + { + id = i; + sub = index - s.index; + return true; + } + } + + return false; + } + + void convert3DO(const char* name) + { + char path[256]; + sprintf(path, "../../3do/CD/data/%s.V", name); + int32 texFileSize = convertTextures3DO(path); + + sprintf(path, "../../3do/CD/data/%s.D", name); + + FileStream f(path, true); + + if (!f.isValid()) return; + + f.bigEndian = true; + + Header header; + f.seek(sizeof(Header)); // will be rewritten at the end + + header.magic = 0x33444F20; + header.tilesCount = plutsCount; + header.roomsCount = roomsCount; + header.modelsCount = modelsCount; + header.meshesCount = meshOffsetsCount; + header.staticMeshesCount = staticMeshesCount; + header.spriteSequencesCount = spriteSequencesCount; + header.soundSourcesCount = soundSourcesCount; + header.boxesCount = boxesCount; + header.texturesCount = objectTexturesCount; + header.itemsCount = itemsCount; + header.camerasCount = camerasCount; + header.cameraFramesCount = cameraFramesCount; + header.soundOffsetsCount = soundOffsetsCount; + header._reserved = 0; + + header.palette = 0; + header.lightmap = 0; + + fixHeadMask(); + + header.rooms = f.align4(); + { + f.seek(sizeof(Room::InfoComp) * roomsCount); + + Room::InfoComp infoComp[255]; + + for (int32 i = 0; i < roomsCount; i++) + { + const LevelPC::Room* room = rooms + i; + + Room::InfoComp &info = infoComp[i]; + + ASSERT(room->info.x % 256 == 0); + ASSERT(room->info.z % 256 == 0); + ASSERT(room->info.yBottom >= -32768 && room->info.yBottom <= 32767); + ASSERT(room->info.yTop >= -32768 && room->info.yTop <= 32767); + info.x = room->info.x / 256; + info.z = room->info.z / 256; + info.yBottom = -32768; + info.yTop = 32767; + + for (int32 j = 0; j < room->vCount; j++) + { + Room::Vertex &v = room->vertices[j]; + if (v.pos.y < info.yTop) { + info.yTop = v.pos.y; + } + if (v.pos.y > info.yBottom) { + info.yBottom = v.pos.y; + } + } + + info.spritesCount = room->sCount; + info.quadsCount = room->qCount; + info.trianglesCount = room->tCount; + info.portalsCount = uint8(room->pCount); + info.lightsCount = uint8(room->lCount); + info.meshesCount = uint8(room->mCount); + info.ambient = room->ambient >> 5; + info.xSectors = uint8(room->xSectors); + info.zSectors = uint8(room->zSectors); + info.alternateRoom = uint8(room->alternateRoom); + + info.flags = 0; + if (room->flags & 1) info.flags |= 1; + if (room->flags & 256) info.flags |= 2; + + ASSERT((room->flags & ~257) == 0); + ASSERT(info.portalsCount == room->pCount); + ASSERT(info.lightsCount == room->lCount); + ASSERT(info.meshesCount == room->mCount); + ASSERT(info.xSectors == room->xSectors); + ASSERT(info.zSectors == room->zSectors); + + roomVerticesCount = 0; + + info.quads = f.align4(); + for (int32 i = 0; i < room->qCount; i++) + { + Quad q = room->quads[i]; + + // get intensity + const Room::Vertex &v0 = room->vertices[q.indices[0]]; + const Room::Vertex &v1 = room->vertices[q.indices[1]]; + const Room::Vertex &v2 = room->vertices[q.indices[2]]; + const Room::Vertex &v3 = room->vertices[q.indices[3]]; + + uint32 intensity = ((v0.lighting + v1.lighting + v2.lighting + v3.lighting) / 4) >> 5; + ASSERT(intensity <= 255); + + q.indices[0] = addRoomVertex(info.yTop, v0, true); + q.indices[1] = addRoomVertex(info.yTop, v1, true); + q.indices[2] = addRoomVertex(info.yTop, v2, true); + q.indices[3] = addRoomVertex(info.yTop, v3, true); + + ASSERT((int32)q.indices[0] * 12 < 0xFFFF); + ASSERT((int32)q.indices[1] * 12 < 0xFFFF); + ASSERT((int32)q.indices[2] * 12 < 0xFFFF); + ASSERT((int32)q.indices[3] * 12 < 0xFFFF); + + RoomQuad3DO comp; + comp.indices[0] = q.indices[0] * 12; + comp.indices[1] = q.indices[1] * 12; + comp.indices[2] = q.indices[2] * 12; + comp.indices[3] = q.indices[3] * 12; + comp.flags = q.flags; + // add ccw flag and swap indices + calcQuadFlip(comp); + ASSERT((comp.flags & FACE_CCW) == 0); + // add intensity + comp.flags |= (intensity << (FACE_MIP_SHIFT + FACE_MIP_SHIFT)); + if (textures3DO[comp.flags & FACE_TEXTURE].pre0 & PRE0_BGND) { + comp.flags |= FACE_OPAQUE; // set opaque flag + } + // add mip level + Texture3DO* tex = textures3DO + (comp.flags & FACE_TEXTURE); + if (tex->mip != -1) { + comp.flags |= (tex->mip << FACE_MIP_SHIFT); + } + + comp.write(f); + } + + info.triangles = f.align4(); + for (int32 i = 0; i < room->tCount; i++) + { + Triangle t = room->triangles[i]; + + // get intensity + const Room::Vertex &v0 = room->vertices[t.indices[0]]; + const Room::Vertex &v1 = room->vertices[t.indices[1]]; + const Room::Vertex &v2 = room->vertices[t.indices[2]]; + + uint32 intensity = ((v0.lighting + v1.lighting + v2.lighting) / 3) >> 5; + ASSERT(intensity <= 255); + + t.indices[0] = addRoomVertex(info.yTop, v0, true); + t.indices[1] = addRoomVertex(info.yTop, v1, true); + t.indices[2] = addRoomVertex(info.yTop, v2, true); + + ASSERT((int32)t.indices[0] * 12 < 0xFFFF); + ASSERT((int32)t.indices[1] * 12 < 0xFFFF); + ASSERT((int32)t.indices[2] * 12 < 0xFFFF); + + RoomTriangle3DO comp; + comp.indices[0] = t.indices[0] * 12; + comp.indices[1] = t.indices[1] * 12; + comp.indices[2] = t.indices[2] * 12; + comp._unused = 0; + comp.flags = t.flags; + // add intensity + comp.flags |= (intensity << (FACE_MIP_SHIFT + FACE_MIP_SHIFT)); + if (textures3DO[comp.flags & FACE_TEXTURE].pre0 & PRE0_BGND) { + comp.flags |= FACE_OPAQUE; // set opaque flag + } + // add mip level + Texture3DO* tex = textures3DO + (comp.flags & FACE_TEXTURE); + if (tex->mip != -1) { + comp.flags |= (tex->mip << FACE_MIP_SHIFT); + } + comp.write(f); + } + + info.vertices = f.align4(); + info.verticesCount = roomVerticesCount; + for (int32 i = 0; i < roomVerticesCount; i += 4) + { + Room::VertexComp v[4]; + + for (int32 j = 0; j < 4; j++) + { + if (i + j < roomVerticesCount) { + v[j] = roomVertices[i + j]; + } else { + memset(&v[j], 0, sizeof(v[j])); + } + } + + { + uint32 value = v[0].x | (v[0].y << 5) | (v[0].z << 11); + value |= (v[1].x | (v[1].y << 5) | (v[1].z << 11)) << 16; + f.write(value); + } + + { + uint32 value = v[2].x | (v[2].y << 5) | (v[2].z << 11); + value |= (v[3].x | (v[3].y << 5) | (v[3].z << 11)) << 16; + f.write(value); + } + } + + info.sprites = f.align4(); + for (int32 i = 0; i < room->sCount; i++) + { + const Room::Sprite* sprite = room->sprites + i; + const Room::Vertex* v = room->vertices + sprite->index; + + Room::SpriteComp comp; + comp.x = v->pos.x; + comp.y = v->pos.y; + comp.z = v->pos.z; + comp.g = v->lighting >> 5; + comp.index = uint8(sprite->texture); + + ASSERT(sprite->texture <= 255); + + comp.write(f); + } + + info.portals = f.align4(); + f.writeObj(room->portals, room->pCount); + /* + for (int32 i = 0; i < room->pCount; i++) + { + const Room::Portal* portal = room->portals + i; + + Room::PortalComp comp; + + comp.roomIndex = portal->roomIndex; + + static const struct { + int32 x, y, z; + int32 mask; + } normals[9] = { + { -1, 0, 0, 2 << 0 }, + { 1, 0, 0, 1 << 0 }, + { 0, -1, 0, 2 << 2 }, + { 0, 1, 0, 1 << 2 }, + { 0, 0, -1, 2 << 4 }, + { 0, 0, 1, 1 << 4 } + }; + + comp.normalMask = 255; + for (int32 i = 0; i < 9; i++) + { + if (portal->normal.x == normals[i].x && + portal->normal.y == normals[i].y && + portal->normal.z == normals[i].z) + { + comp.normalMask = normals[i].mask; + break; + } + } + + ASSERT(comp.normalMask != 255); + + for (int32 i = 0; i < 4; i++) + { + comp.vertices[i].x = portal->vertices[i].x; + comp.vertices[i].y = portal->vertices[i].y; + comp.vertices[i].z = portal->vertices[i].z; + } + + comp.write(f); + }*/ + + info.sectors = f.align4(); + f.writeObj(room->sectors, room->zSectors * room->xSectors); + + info.lights = f.align4(); + for (int32 i = 0; i < room->lCount; i++) + { + const Room::Light* light = room->lights + i; + + Room::LightComp comp; + comp.pos.x = light->pos.x - room->info.x; + comp.pos.y = light->pos.y; + comp.pos.z = light->pos.z - room->info.z; + comp.radius = light->radius >> 8; + comp.intensity = light->intensity >> 5; + + comp.write(f); + } + + info.meshes = f.align4(); + for (int32 i = 0; i < room->mCount; i++) + { + const Room::Mesh* mesh = room->meshes + i; + + Room::MeshComp comp; + comp.pos.x = mesh->pos.x - room->info.x; + comp.pos.y = mesh->pos.y; + comp.pos.z = mesh->pos.z - room->info.z; + comp.intensity = mesh->intensity >> 5; + comp.flags = ((mesh->angleY / 0x4000 + 2) << 6) | mesh->id; + + ASSERT(mesh->id <= 63); + ASSERT(mesh->angleY % 0x4000 == 0); + ASSERT(mesh->angleY / 0x4000 + 2 >= 0); + + comp.write(f); + } + } + + int32 pos = f.getPos(); + f.setPos(header.rooms); + f.writeObj(infoComp, roomsCount); + f.setPos(pos); + } + + header.floors = f.align4(); + f.writeObj(floors, floorsCount); + + header.meshData = f.align4(); + + int32 mOffsets[2048]; + for (int32 i = 0; i < 2048; i++) { + mOffsets[i] = -1; + } + + for (int32 i = 0; i < meshOffsetsCount; i++) + { + if (mOffsets[i] != -1) + continue; + + mOffsets[i] = f.align4() - header.meshData; + + const uint8* ptr = (uint8*)meshData + meshOffsets[i]; + + vec3s center = *(vec3s*)ptr; ptr += sizeof(center); + int16 radius = *(int16*)ptr; ptr += sizeof(radius); + uint16 flags = *(uint16*)ptr; ptr += sizeof(flags); + + int16 vCount = *(int16*)ptr; ptr += 2; + const vec3s* vertices = (vec3s*)ptr; + ptr += vCount * sizeof(vec3s); + + const uint16* vIntensity = NULL; + const vec3s* vNormal = NULL; + + int16 nCount = *(int16*)ptr; ptr += 2; + //const int16* normals = (int16*)ptr; + if (nCount > 0) { // normals + vNormal = (vec3s*)ptr; + ptr += nCount * 3 * sizeof(int16); + } else { // intensity + vIntensity = (uint16*)ptr; + ptr += vCount * sizeof(uint16); + } + + int16 rCount = *(int16*)ptr; ptr += 2; + Quad* rFaces = (Quad*)ptr; ptr += rCount * sizeof(Quad); + + int16 tCount = *(int16*)ptr; ptr += 2; + Triangle* tFaces = (Triangle*)ptr; ptr += tCount * sizeof(Triangle); + + int16 crCount = *(int16*)ptr; ptr += 2; + Quad* crFaces = (Quad*)ptr; ptr += crCount * sizeof(Quad); + + int16 ctCount = *(int16*)ptr; ptr += 2; + Triangle* ctFaces = (Triangle*)ptr; ptr += ctCount * sizeof(Triangle); + + uint16 intensity = 0; + + if (vIntensity) + { + uint32 sum = 0; + for (int32 i = 0; i < vCount; i++) + { + sum += vIntensity[i]; + } + intensity = sum / vCount; + } + + f.write(center.x); + f.write(center.y); + f.write(center.z); + f.write(radius); + f.write(intensity); + f.write(vCount); + f.write(rCount); + f.write(tCount); + f.write(crCount); + f.write(ctCount); + + for (int32 j = 0; j < vCount; j++) + { + struct MeshVertex3DO { + int16 x, y, z; + } v; + + v.x = vertices[j].x << 2; + v.y = vertices[j].y << 2; + v.z = vertices[j].z << 2; + + f.write(v.x); + f.write(v.y); + f.write(v.z); + } + + if (vCount % 2) { // add one vertex for the data alignment + int16 zero = 0; + f.write(zero); + f.write(zero); + f.write(zero); + } + + for (int32 j = 0; j < rCount; j++) + { + Quad q = rFaces[j]; + + ASSERT(q.indices[0] < 256); + ASSERT(q.indices[1] < 256); + ASSERT(q.indices[2] < 256); + ASSERT(q.indices[3] < 256); + + MeshQuad3DO comp; + comp.indices[0] = q.indices[0]; + comp.indices[1] = q.indices[1]; + comp.indices[2] = q.indices[2]; + comp.indices[3] = q.indices[3]; + comp.flags = q.flags; + if (textures3DO[comp.flags & FACE_TEXTURE].pre0 & PRE0_BGND) { + comp.flags |= FACE_OPAQUE; // set opaque flag + } + calcQuadFlip(comp); + comp.write(f); + } + + for (int32 j = 0; j < tCount; j++) + { + Triangle t = tFaces[j]; + + ASSERT(t.indices[0] < 256); + ASSERT(t.indices[1] < 256); + ASSERT(t.indices[2] < 256); + + MeshTriangle3DO comp; + comp.indices[0] = t.indices[0]; + comp.indices[1] = t.indices[1]; + comp.indices[2] = t.indices[2]; + comp._unused = 0; + comp.flags = t.flags; + if (textures3DO[comp.flags & FACE_TEXTURE].pre0 & PRE0_BGND) { + comp.flags |= FACE_OPAQUE; // set opaque flag + } + comp.write(f); + } + + for (int32 j = 0; j < crCount; j++) + { + Quad q = crFaces[j]; + + ASSERT(q.indices[0] < 256); + ASSERT(q.indices[1] < 256); + ASSERT(q.indices[2] < 256); + ASSERT(q.indices[3] < 256); + + MeshQuad3DO comp; + comp.indices[0] = q.indices[0]; + comp.indices[1] = q.indices[1]; + comp.indices[2] = q.indices[2]; + comp.indices[3] = q.indices[3]; + comp.flags = q.flags; + comp.write(f); + } + + for (int32 j = 0; j < ctCount; j++) + { + Triangle t = ctFaces[j]; + + ASSERT(t.indices[0] < 256); + ASSERT(t.indices[1] < 256); + ASSERT(t.indices[2] < 256); + + MeshTriangle3DO comp; + comp.indices[0] = t.indices[0]; + comp.indices[1] = t.indices[1]; + comp.indices[2] = t.indices[2]; + comp._unused = 0; + comp.flags = t.flags; + comp.write(f); + } + + + for (int32 j = i + 1; j < meshOffsetsCount; j++) + { + if (meshOffsets[i] == meshOffsets[j]) + { + mOffsets[j] = mOffsets[i]; + } + } + } + + header.meshOffsets = f.align4(); + f.write(mOffsets, meshOffsetsCount); + + header.anims = f.align4(); + f.writeObj(anims, animsCount); + + header.states = f.align4(); + for (int32 i = 0; i < statesCount; i++) + { + const LevelPC::AnimState* state = states + i; + + LevelPC::AnimStateComp comp; + comp.state = uint8(state->state); + comp.rangesCount = uint8(state->rangesCount); + comp.rangesStart = state->rangesStart; + + comp.write(f); + } + + header.ranges = f.align4(); + f.writeObj(ranges, rangesCount); + + header.commands = f.align4(); + f.write(commands, commandsCount); + + header.nodes = f.align4(); + for (int32 i = 0; i < nodesDataSize / 4; i++) + { + const Node* node = (Node*)(nodesData + i * 4); + + ASSERT(node->pos.x > -32768); + ASSERT(node->pos.x < 32767); + ASSERT(node->pos.y > -32768); + ASSERT(node->pos.y < 32767); + ASSERT(node->pos.z > -32768); + ASSERT(node->pos.z < 32767); + ASSERT(node->flags < 0xFFFF); + + LevelPC::NodeComp comp; + comp.flags = uint16(node->flags); + comp.pos.x = int16(node->pos.x); + comp.pos.y = int16(node->pos.y); + comp.pos.z = int16(node->pos.z); + + comp.write(f); + } + //f.write(nodesData, nodesDataSize); + + header.frameData = f.align4(); + f.write(frameData, frameDataSize); + + header.models = f.align4(); + for (int32 i = 0; i < modelsCount; i++) + { + const LevelPC::Model* model = models + i; + + LevelPC::ModelComp comp; + comp.type = uint8(model->type); + comp.count = uint8(model->count); + comp.start = model->start; + comp.nodeIndex = model->nodeIndex / 4; + comp.animIndex = model->animIndex; + + comp.write(f); + } + + header.staticMeshes = f.align4(); + for (int32 i = 0; i < staticMeshesCount; i++) + { + const LevelPC::StaticMesh* staticMesh = staticMeshes + i; + + LevelPC::StaticMeshComp comp; + comp.id = staticMesh->id; + comp.meshIndex = staticMesh->meshIndex; + comp.flags = staticMesh->flags; + comp.vbox = staticMesh->vbox; + comp.cbox = staticMesh->cbox; + + comp.write(f); + } + + header.objectTextures = f.align4(); + for (int32 i = 0; i < objectTexturesCount; i++) + { + textures3DO[i].write(f); + } + + header.spriteTextures = f.align4(); + for (int32 i = 0; i < spriteTexturesCount; i++) + { + const LevelPC::SpriteTexture* spriteTexture = spriteTextures + i; + + SpriteTexture3DO comp; + comp.texture = spritesBaseIndex + i; + comp.l = spriteTexture->l; + comp.t = spriteTexture->t; + comp.r = spriteTexture->r; + comp.b = spriteTexture->b; + + comp.write(f); + } + + f.writeObj(spriteTextures, spriteTexturesCount); + + header.spriteSequences = f.align4(); + f.writeObj(spriteSequences, spriteSequencesCount); + + header.cameras = f.align4(); + f.writeObj(cameras, camerasCount); + + header.soundSources = f.align4(); + f.writeObj(soundSources, soundSourcesCount); + + header.boxes = f.align4(); + for (int32 i = 0; i < boxesCount; i++) + { + const LevelPC::Box* box = boxes + i; + + BoxComp comp; + comp.minX = box->minX >> 10; + comp.minZ = box->minZ >> 10; + comp.maxX = (box->maxX + 1) >> 10; + comp.maxZ = (box->maxZ + 1) >> 10; + comp.floor = box->floor; + comp.overlap = box->overlap; + + comp.write(f); + } + + header.overlaps = f.align4(); + f.write(overlaps, overlapsCount); + + for (int32 i = 0; i < 2; i++) + { + header.zones[i][0] = f.align4(); + f.write(zones[i].ground1, boxesCount); + + header.zones[i][1] = f.align4(); + f.write(zones[i].ground2, boxesCount); + + header.zones[i][2] = f.align4(); + f.write(zones[i].fly, boxesCount); + } + + header.animTexData = f.align4(); + { + int32 lastPos = f.getPos(); + + uint16 rangesCount = *animTexData++; + struct TexAnimRange + { + uint16 count; + uint16 indices[256]; + } ranges[64]; + ASSERT(rangesCount <= 64); + + int32 newRangesCount = rangesCount; + + for (int32 i = 0; i < rangesCount; i++) + { + bool mips = true; + + TexAnimRange &range = ranges[i]; + range.count = *animTexData++; + for (int32 j = 0; j <= range.count; j++) + { + range.indices[j] = *animTexData++; + + if (textures3DO[range.indices[j]].mip < 0) { + mips = false; + } + } + + // add the new anim range for mip textures + if (mips) + { + TexAnimRange &mipRange = ranges[newRangesCount++]; + mipRange.count = range.count; + for (int32 j = 0; j <= range.count; j++) + { + mipRange.indices[j] = textures3DO[range.indices[j]].mip; + } + } + } + rangesCount = newRangesCount; + + f.write(rangesCount); + for (int32 i = 0; i < rangesCount; i++) + { + f.write(ranges[i].count); + f.write(ranges[i].indices, ranges[i].count + 1); + } + + lastPos = f.getPos() - lastPos; + } + + header.items = f.align4(); + for (int32 i = 0; i < itemsCount; i++) + { + const LevelPC::Item* item = items + i; + const LevelPC::Room* room = rooms + item->roomIndex; + + ItemComp comp; + comp.type = uint8(item->type); + comp.roomIndex = uint8(item->roomIndex); + comp.pos.x = int16(item->pos.x - room->info.x); + comp.pos.y = int16(item->pos.y); + comp.pos.z = int16(item->pos.z - room->info.z); + comp.intensity = item->intensity < 0 ? 0 : (item->intensity >> 5); + comp.flags = item->flags | ((item->angleY / 0x4000 + 2) << 14); + + ASSERT((item->flags & ~(0x3F1F)) == 0); + + comp.write(f); + } + + header.cameraFrames = f.align4(); + f.writeObj(cameraFrames, cameraFramesCount); + + //f.writeArray(demoData, demoDataSize); + + header.soundMap = f.align4(); + f.write(soundMap, 256); + + header.soundInfos = f.align4(); + f.writeObj(soundInfo, soundInfoCount); + + header.soundData = f.align4(); + + uint8* soundBuf = new uint8[2 * 1024 * 1024]; + + bool isHome = strcmp(name, "GYM") == 0; + + for (int32 i = 0; i < soundOffsetsCount; i++) + { + soundOffsets[i] = f.align4() - header.soundData; + + int32 id, sub, size; + if (getSoundID(i, id, sub)) + { + getSample("C:\\Projects\\OpenLara\\src\\platform\\gba\\packer\\sounds\\conv_3do", isHome ? "_" : "", id, sub, soundBuf, size); + } else { + ASSERT(false); + } + + int32 numSamples = size * 2; + f.write(numSamples); + + if (size) { + f.write(soundBuf, size); + } + } + + delete[] soundBuf; + + header.soundOffsets = f.align4(); + f.write(soundOffsets, soundOffsetsCount); + + f.setPos(0); + header.write(f); + } + +}; + +#define COLOR_THRESHOLD_SQ (8 * 8) +#endif + + +#if 0 +struct WAD +{ + + + struct LevelWAD + { + struct Room + { + struct Vertex + { + int8 x, y, z; + uint8 lighting; + }; + + struct Quad + { + uint16 flags; + uint16 indices[4]; + }; + + struct Triangle + { + uint16 flags; + uint16 indices[3]; + }; + + struct Sprite + { + int16 x, y, z; + uint16 texture; + }; + + struct Portal + { + uint8 roomIndex; + uint8 normalIndex; + uint16 x, y, z; + uint8 a, b; + + Portal() {} + Portal(const LevelPC::Room::Portal &portal) + { + + const vec3s &v0 = portal.vertices[0]; + const vec3s &v1 = portal.vertices[1]; + const vec3s &v2 = portal.vertices[2]; + const vec3s &v3 = portal.vertices[3]; + const vec3s &n = portal.normal; + + normalIndex = 0xFF; + + if (n.x == -1) normalIndex = 0; + if (n.x == 1) normalIndex = 1; + if (n.y == -1) normalIndex = 2; + if (n.y == 1) normalIndex = 3; + if (n.z == -1) normalIndex = 4; + if (n.z == 1) normalIndex = 5; + + ASSERT(normalIndex != 0xFF); + + int32 minX = MIN(MIN(MIN(v0.x, v1.x), v2.x), v3.x); + int32 minY = MIN(MIN(MIN(v0.y, v1.y), v2.y), v3.y); + int32 minZ = MIN(MIN(MIN(v0.z, v1.z), v2.z), v3.z); + int32 maxX = MAX(MAX(MAX(v0.x, v1.x), v2.x), v3.x); + int32 maxY = MAX(MAX(MAX(v0.y, v1.y), v2.y), v3.y); + int32 maxZ = MAX(MAX(MAX(v0.z, v1.z), v2.z), v3.z); + + x = (maxX + minX) / 2; + y = (maxY + minY) / 2; + z = (maxZ + minZ) / 2; + + int32 sx = (maxX - minX) / 256; + int32 sy = (maxY - minY) / 256; + int32 sz = (maxZ - minZ) / 256; + + switch (normalIndex / 2) + { + case 0 : // x + a = sy; + b = sz; + break; + case 1 : // y + a = sx; + b = sz; + break; + case 2 : // z + a = sx; + b = sy; + break; + } + } + }; + + struct Sector + { + uint16 floorIndex; + uint16 boxIndex; + uint8 roomBelow; + int8 floor; + uint8 roomAbove; + int8 ceiling; + }; + + int16 vCount; + int16 qCount; + int16 tCount; + uint8 sCount; + uint8 pCount; + uint8 zSectors; + uint8 xSectors; + + Vertex vertices[MAX_ROOM_VERTICES]; + Quad quads[MAX_ROOM_QUADS]; + Triangle triangles[MAX_ROOM_TRIANGLES]; + Sprite sprites[MAX_ROOM_SPRITES]; + Portal portals[MAX_ROOM_PORTALS]; + Sector sectors[MAX_ROOM_SECTORS]; + + Room() {} + + Room(const LevelPC::Room &room) : vCount(0), qCount(0), tCount(0), sCount(0) + { + for (int32 i = 0; i < room.qCount; i++) + { + addQuad(room.quads[i], room.vertices); + } + + for (int32 i = 0; i < room.tCount; i++) + { + addTriangle(room.triangles[i], room.vertices); + } + + for (int32 i = 0; i < room.sCount; i++) + { + addSprite(room.sprites[i], room.vertices); + } + + pCount = uint8(room.pCount); + for (int32 i = 0; i < pCount; i++) + { + portals[i] = room.portals[i]; + } + + zSectors = uint8(room.zSectors); + xSectors = uint8(room.xSectors); + for (int32 i = 0; i < zSectors * xSectors; i++) + { + const LevelPC::Room::Sector &src = room.sectors[i]; + Sector &dst = sectors[i]; + dst.floorIndex = src.floorIndex; + dst.boxIndex = src.boxIndex; + dst.roomBelow = src.roomBelow; + dst.floor = src.floor; + dst.roomAbove = src.roomAbove; + dst.ceiling = src.ceiling; + } + } + + int32 addVertex(const LevelPC::Room::Vertex &v) + { + Vertex n; + n.x = v.pos.x / 1024; + n.y = v.pos.y / 256; + n.z = v.pos.z / 1024; + n.lighting = v.lighting >> 5; + + for (int32 i = 0; i < vCount; i++) + { + if (vertices[i].x == n.x && + vertices[i].y == n.y && + vertices[i].z == n.z && + vertices[i].lighting == n.lighting) + { + return i; + } + } + + vertices[vCount++] = n; + + return vCount - 1; + } + + void addQuad(const LevelPC::Quad &q, const LevelPC::Room::Vertex* verts) + { + Quad n; + n.flags = q.flags; + n.indices[0] = addVertex(verts[q.indices[0]]); + n.indices[1] = addVertex(verts[q.indices[1]]); + n.indices[2] = addVertex(verts[q.indices[2]]); + n.indices[3] = addVertex(verts[q.indices[3]]); + quads[qCount++] = n; + } + + void addTriangle(const LevelPC::Triangle &t, const LevelPC::Room::Vertex* verts) + { + Triangle n; + n.flags = t.flags; + n.indices[0] = addVertex(verts[t.indices[0]]); + n.indices[1] = addVertex(verts[t.indices[1]]); + n.indices[2] = addVertex(verts[t.indices[2]]); + triangles[tCount++] = n; + } + + void addSprite(const LevelPC::Room::Sprite &s, const LevelPC::Room::Vertex* verts) + { + Sprite n; + n.texture = s.texture; + n.x = verts[s.index].pos.x; + n.y = verts[s.index].pos.y; + n.z = verts[s.index].pos.z; + // lighting? + sprites[sCount++] = n; + } + }; + + struct FloorData + { + uint16 value; + }; + + struct Box + { + int8 minZ, maxZ; + int8 minX, maxX; + int16 floor; + int16 overlap; + + Box() {} + + Box(const LevelPC::Box &b) + { + minX = b.minX / 1024; + minZ = b.minZ / 1024; + maxX = (b.maxX + 1) / 1024; + maxZ = (b.maxZ + 1) / 1024; + + floor = int16(b.floor); + overlap = int16(b.overlap); + + ASSERT(b.minX == minX * 1024); + ASSERT(b.minZ == minZ * 1024); + ASSERT(b.maxX == maxX * 1024 - 1); + ASSERT(b.maxZ == maxZ * 1024 - 1); + } + }; + + struct Overlap + { + uint16 value; + }; + + struct Zone + { + uint16 ground1[MAX_BOXES]; + uint16 ground2[MAX_BOXES]; + uint16 fly[MAX_BOXES]; + }; + + struct Item + { + uint8 type; + uint8 roomIndex; + vec3s pos; + int8 angleY; + uint8 intensity; + uint16 flags; + + Item() {} + + Item(const LevelPC::Item &item) + { + type = uint8(item.type); + roomIndex = uint8(item.roomIndex); + pos.x = int16(item.pos.x); + pos.y = int16(item.pos.y); + pos.z = int16(item.pos.z); + angleY = item.angleY / 0x4000; + intensity = item.intensity >> 5; + flags = item.flags; + } + }; + + int16 roomsCount; + int16 floorsCount; + int16 boxesCount; + int16 overlapsCount; + int16 itemsCount; + + Room rooms[MAX_ROOMS]; + FloorData floors[MAX_FLOORS]; + Box boxes[MAX_BOXES]; + Overlap overlaps[MAX_OVERLAPS]; + Zone zones[2]; + Item items[MAX_ITEMS]; + + LevelWAD() {} + + LevelWAD(const LevelPC &level) + { + roomsCount = int16(level.roomsCount); + for (int32 i = 0; i < level.roomsCount; i++) + { + rooms[i] = level.rooms[i]; + } + + floorsCount = int16(level.floorsCount); + memcpy(floors, level.floors, floorsCount * sizeof(floors[0])); + + boxesCount = int16(level.boxesCount); + for (int32 i = 0; i < level.boxesCount; i++) + { + boxes[i] = level.boxes[i]; + } + + overlapsCount = int16(level.overlapsCount); + memcpy(overlaps, level.overlaps, overlapsCount * sizeof(overlaps[0])); + + for (int32 i = 0; i < 2; i++) + { + memcpy(zones[i].ground1, level.zones[i].ground1, level.boxesCount * sizeof(uint16)); + memcpy(zones[i].ground2, level.zones[i].ground2, level.boxesCount * sizeof(uint16)); + memcpy(zones[i].fly, level.zones[i].fly, level.boxesCount * sizeof(uint16)); + } + + itemsCount = int16(level.itemsCount); + for (int32 i = 0; i < itemsCount; i++) + { + LevelPC::Item item = level.items[i]; + const LevelPC::Room &room = level.rooms[item.roomIndex]; + + item.pos.x -= room.info.x; + item.pos.z -= room.info.z; + + items[i] = item; + } + } + }; + + + + struct Model + { + uint16 count; + uint16 start; + uint16 nodeIndex; + uint16 frameIndex; + uint16 animIndex; + }; + + + Model* models[MAX_ITEMS]; + + bool itemsUsed[MAX_ITEMS]; + + LevelWAD* levels[MAX_LEVELS]; + + WAD() + { + memset(models, 0, sizeof(models)); + memset(itemsUsed, 0, sizeof(itemsUsed)); + } + + + + int32 addNodes(const LevelPC::Node *nodes, int32 count) + { + if (count == 0) + return 0; + + int32 index = 0; + + for (int32 i = 0; i < nodeLists.count; i++) + { + if (nodeLists[i]->count == count) + { + bool equal = true; + + for (int32 j = 0; j < nodeLists[i]->count; j++) + { + const Node &n = nodeLists[i]->nodes[j]; + if (n.flags != nodes[j].flags || + n.pos.x != nodes[j].pos.x || + n.pos.y != nodes[j].pos.y || + n.pos.z != nodes[j].pos.z) + { + equal = false; + break; + } + } + + if (equal) { + return index; + } + } + + index += nodeLists[i]->count; + } + + NodeList* list = new NodeList(); + list->count = count; + for (int32 i = 0; i < count; i++) + { + Node &n = list->nodes[i]; + n.flags = nodes[i].flags; + n.pos.x = nodes[i].pos.x; + n.pos.y = nodes[i].pos.y; + n.pos.z = nodes[i].pos.z; + } + + nodeLists.add(list); + + return index; + } + + void packTiles() + { + textures.sort(); + + for (int32 i = 0; i < textures.count; i++) + { + WAD::Texture* tex = textures[i]; + + bool placed = false; + + for (int32 j = 0; j < tiles.count; j++) + { + if (tiles[j]->root->insert(tex)) { + placed = true; + break; + } + } + + if (!placed) + { + Tile24* tile = new Tile24(); + tiles.add(tile); + if (!tile->root->insert(tex)) + { + printf("Can't pack texture %d x %d", tex->width, tex->height); + break; + } + } + } + + uint8* data = new uint8[256 * 256 * 3 * tiles.count]; + + for (int32 i = 0; i < tiles.count; i++) + { + tiles[i]->fill(data + i * 256 * 256 * 3); + } + saveBitmap("tiles.bmp", data, 256, 256 * tiles.count); + + delete[] data; + } +}; + + +void convertTracks3DO(const char* inDir, const char* outDir) +{ + WIN32_FIND_DATA fd; + HANDLE h = FindFirstFile(inDir, &fd); + + if (h == INVALID_HANDLE_VALUE) + return; + + char buf[256]; + + do + { + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + const char* src = fd.cFileName; + char* dst = buf; + + while (*src) + { + if (*src >= '0' && *src <= '9') + { + *dst++ = *src; + } + src++; + } + *dst++ = 0; + + int32 index = atoi(buf); + + if (index != 0) + { + strcpy(buf, inDir); + buf[strlen(buf) - 1] = 0; + strcat(buf, fd.cFileName); + + char cmdline[256]; + sprintf(cmdline, "C:\\Program Files\\ffmpeg\\ffmpeg.exe -y -i \"%s\" -ac 1 -ar 22050 -acodec pcm_s16be %s\\%d.aiff", buf, outDir, index); + + launchApp(cmdline); + /* TODO SDXC encoder + FILE* f = fopen("tmp.wav", "rb"); + ASSERT(f); + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* samples = new uint8[size]; + fread(samples, 1, size, f); + fclose(f); + + int32 numSamples = size / sizeof(short); + + int32 outputSize = (size + 3) / 4; + uint8* output = new uint8[outputSize]; + memset(output, 0, outputSize); + + BlockADDVIEncode(output, (short*)samples, numSamples, 1); // mono block + + sprintf(buf, "%s\\%d.S", outDir, index); + f = fopen(buf, "wb"); + ASSERT(f); + fwrite(&numSamples, sizeof(numSamples), 1, f); + fwrite(output, 1, outputSize, f); + fclose(f); + + delete[] output; + delete[] samples; + */ + } + } + } + while (FindNextFile(h, &fd)); + FindClose(h); +} + + + +// 3DO face flags +// 1:ccw, 1:opaque, 8:intensity, 11:mipTexIndex, 11:texIndex +#define FACE_MIP_SHIFT 11 +#define FACE_OPAQUE (1 << 30) +#define FACE_CCW (1 << 31) + +#define TEX_FLIP_X 1 +#define TEX_FLIP_Y 2 +#define TEX_ATTR_MIPS 0x8000 + +void process3DO(const char* dir, TR1_PC* pc, TR1_PSX* psx) +{ +} + +// BIG TODO! + //pack_tracks("tracks/conv_demo/*.ima"); return 0; + + + /* + uint32 palDump[32][256]; + memset(palDump, 0, sizeof(palDump)); + + + for (int32 i = 0; i < MAX_LEVELS; i++) + { + char path[64]; + sprintf(path, "levels/%s.PHD", levelNames[i]); + levels[i] = new LevelPC(path); + + for (int32 j = 0; j < 256; j++) + { + int32 r = levels[i]->palette.colors[j * 3 + 0] << 2; + int32 g = levels[i]->palette.colors[j * 3 + 1] << 2; + int32 b = levels[i]->palette.colors[j * 3 + 2] << 2; + palDump[i][j] = b | (g << 8) | (r << 16) | (0xFF << 24); + } + + levels[i]->generateLODs(); + //levels[i]->cutData(levelNames[i]); + + sprintf(path, "../data/%s.PKD", levelNames[i]); + levels[i]->convertGBA(path); + + //levels[i]->convert3DO(levelNames[i]); + }*/ + +// saveBitmap("pal.bmp", (uint8*)palDump, 256, 32, 32); + +// convertTracks3DO("C:\\Projects\\OpenLara\\src\\platform\\gba\\packer\\tracks\\orig\\*", "C:\\Projects\\OpenLara\\src\\platform\\3do\\tracks"); + + +/* + WAD* wad = new WAD(); + + int32 size = 0; + int32 maxItems = 0; + + int32 maxVertices = 0; + + for (int32 i = 0; i < MAX_LEVELS; i++) + { + LevelPC* level = levels[i]; + + wad->addLevel(i, *level); + + for (int32 j = 0; j < level->roomsCount; j++) + { + WAD::LevelWAD::Room &room = wad->levels[i]->rooms[j]; + + size += room.vCount * sizeof(WAD::LevelWAD::Room::Vertex); + size += room.qCount * sizeof(WAD::LevelWAD::Room::Quad); + size += room.tCount * sizeof(WAD::LevelWAD::Room::Triangle); + size += room.sCount * sizeof(WAD::LevelWAD::Room::Sprite); + size += room.pCount * sizeof(WAD::LevelWAD::Room::Portal); + size += room.xSectors * room.zSectors * sizeof(room.sectors[0]); + } + + size += wad->levels[i]->floorsCount * sizeof(WAD::LevelWAD::FloorData); + size += wad->levels[i]->boxesCount * sizeof(WAD::LevelWAD::Box); + size += wad->levels[i]->overlapsCount * sizeof(WAD::LevelWAD::Overlap); + size += wad->levels[i]->boxesCount * sizeof(uint16) * 3 * 2; // zones + size += wad->levels[i]->itemsCount * sizeof(WAD::LevelWAD::Item); + + size += level->frameDataSize * 2; + } + + int32 nodes = 0; + for (int32 i = 0; i < wad->nodeLists.count; i++) + { + nodes += wad->nodeLists[i]->count; + } + + printf("roomsSize: %d bytes %d\n", size, nodes); + + wad->packTiles(); + + printf("tiles: %d (%d bytes)\n", wad->tiles.count, wad->tiles.count * 256 * 256); + +/* + int32 texSize = 0; + for (int32 i = 0; i < wad.textures.count; i++) + { + texSize += wad.textures[i]->width * wad.textures[i]->height; + + char texName[64]; + sprintf(texName, "textures/%d.bmp", i); + wad.textures[i]->save(texName); + } +*/ + +#endif + + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/out_GBA.h b/src/platform/gba/packer/out_GBA.h new file mode 100644 index 00000000..c67fc802 --- /dev/null +++ b/src/platform/gba/packer/out_GBA.h @@ -0,0 +1,2765 @@ +#ifndef H_OUT_GBA +#define H_OUT_GBA + +#include "common.h" +#include "TR1_PC.h" +#include "TR1_PSX.h" + +struct out_GBA +{ + enum FaceType { // 2 high bits of face flags + FACE_TYPE_SHADOW, + FACE_TYPE_F, + FACE_TYPE_FT, + FACE_TYPE_FTA + }; + + enum { + FACE_TYPE_SHIFT = 14, + }; + + struct Remap { + int32 meshes[MAX_MESHES]; + int32 models[MAX_MODELS]; + int32 animFrames[MAX_ANIMS]; + int16 textures[MAX_TEXTURES]; + int16 sprites[MAX_TEXTURES]; + }; + + struct Header + { + uint32 magic; + + uint16 tilesCount; + uint16 roomsCount; + uint16 modelsCount; + uint16 meshesCount; + uint16 staticMeshesCount; + uint16 spriteSequencesCount; + uint16 soundSourcesCount; + uint16 boxesCount; + uint16 texturesCount; + uint16 spritesCount; + uint16 itemsCount; + uint16 camerasCount; + uint16 cameraFramesCount; + uint16 soundOffsetsCount; + + uint32 palette; + uint32 lightmap; + uint32 tiles; + uint32 rooms; + uint32 floors; + uint32 meshData; + uint32 meshOffsets; + uint32 anims; + uint32 states; + uint32 ranges; + uint32 commands; + uint32 nodes; + uint32 frameData; + uint32 models; + uint32 staticMeshes; + uint32 objectTextures; + uint32 spriteTextures; + uint32 spriteSequences; + uint32 cameras; + uint32 soundSources; + uint32 boxes; + uint32 overlaps; + uint32 zones[2][3]; + uint32 animTexData; + uint32 items; + uint32 cameraFrames; + uint32 soundMap; + uint32 soundInfos; + uint32 soundData; + uint32 soundOffsets; + + void write(FileStream &f) const + { + f.write(magic); + f.write(tilesCount); + f.write(roomsCount); + f.write(modelsCount); + f.write(meshesCount); + f.write(staticMeshesCount); + f.write(spriteSequencesCount); + f.write(soundSourcesCount); + f.write(boxesCount); + f.write(texturesCount); + f.write(spritesCount); + f.write(itemsCount); + f.write(camerasCount); + f.write(cameraFramesCount); + f.write(soundOffsetsCount); + + f.write(palette); + f.write(lightmap); + f.write(tiles); + f.write(rooms); + f.write(floors); + f.write(meshData); + f.write(meshOffsets); + f.write(anims); + f.write(states); + f.write(ranges); + f.write(commands); + f.write(nodes); + f.write(frameData); + f.write(models); + f.write(staticMeshes); + f.write(objectTextures); + f.write(spriteTextures); + f.write(spriteSequences); + f.write(cameras); + f.write(soundSources); + f.write(boxes); + f.write(overlaps); + + for (int32 i = 0; i < 2; i++) + { + for (int32 j = 0; j < 3; j++) + { + f.write(zones[i][j]); + } + } + + f.write(animTexData); + f.write(items); + f.write(cameraFrames); + f.write(soundMap); + f.write(soundInfos); + f.write(soundData); + f.write(soundOffsets); + } + }; + + struct Info + { + int16 x; + int16 z; + int16 yBottom; + int16 yTop; + + uint16 quadsCount; + uint16 trianglesCount; + + uint16 verticesCount; + uint16 spritesCount; + + uint8 portalsCount; + uint8 lightsCount; + uint8 meshesCount; + uint8 ambient; + + uint8 xSectors; + uint8 zSectors; + uint8 alternateRoom; + uint8 flags; + + uint32 quads; + uint32 triangles; + uint32 vertices; + uint32 sprites; + uint32 portals; + uint32 sectors; + uint32 lights; + uint32 meshes; + + void write(FileStream &f) const + { + f.write(x); + f.write(z); + f.write(yBottom); + f.write(yTop); + f.write(quadsCount); + f.write(trianglesCount); + f.write(verticesCount); + f.write(spritesCount); + f.write(portalsCount); + f.write(lightsCount); + f.write(meshesCount); + f.write(ambient); + f.write(xSectors); + f.write(zSectors); + f.write(alternateRoom); + f.write(flags); + f.write(quads); + f.write(triangles); + f.write(vertices); + f.write(sprites); + f.write(portals); + f.write(sectors); + f.write(lights); + f.write(meshes); + } + }; + + struct RoomVertex + { + uint8 x, y, z, g; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + } + }; + + struct RoomQuad + { + int8 indices[4]; + uint16 flags; + uint16 unused; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + f.write(flags); + + uint16 padding = 0; + f.write(padding); + } + }; + + struct RoomTriangle + { + uint16 indices[3]; + uint16 flags; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(flags); + } + }; + + struct MeshQuad + { + int8 indices[4]; + uint16 flags; + uint16 unused; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + f.write(flags); + + uint16 padding = 0; + f.write(padding); + } + }; + + struct MeshTriangle + { + int8 indices[4]; + uint16 flags; + uint16 unused; + + void write(FileStream &f) const + { + f.write(indices[0]); + f.write(indices[1]); + f.write(indices[2]); + f.write(indices[3]); + f.write(flags); + + uint16 padding = 0; + f.write(padding); + } + }; + + struct AnimState + { + uint8 state; + uint8 rangesCount; + uint16 rangesStart; + + void write(FileStream &f) const + { + f.write(state); + f.write(rangesCount); + f.write(rangesStart); + } + }; + + struct Node + { + vec3s pos; + uint16 flags; + + void write(FileStream &f) + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(flags); + } + }; + + struct Sprite + { + int16 x, y, z; + uint8 g; + uint8 index; + + void write(FileStream &f) const + { + f.write(x); + f.write(y); + f.write(z); + f.write(g); + f.write(index); + } + }; + + struct Portal + { + uint8 roomIndex; + uint8 normalIndex; + uint16 x, y, z; + uint8 a, b; + + Portal(const TR1_PC::Room::Portal &portal) + { + + const vec3s &v0 = portal.vertices[0]; + const vec3s &v1 = portal.vertices[1]; + const vec3s &v2 = portal.vertices[2]; + const vec3s &v3 = portal.vertices[3]; + const vec3s &n = portal.normal; + + normalIndex = 0xFF; + + if (n.x == -1) normalIndex = 0; + if (n.x == 1) normalIndex = 1; + if (n.y == -1) normalIndex = 2; + if (n.y == 1) normalIndex = 3; + if (n.z == -1) normalIndex = 4; + if (n.z == 1) normalIndex = 5; + + ASSERT(normalIndex != 0xFF); + + int32 minX = MIN(MIN(MIN(v0.x, v1.x), v2.x), v3.x); + int32 minY = MIN(MIN(MIN(v0.y, v1.y), v2.y), v3.y); + int32 minZ = MIN(MIN(MIN(v0.z, v1.z), v2.z), v3.z); + int32 maxX = MAX(MAX(MAX(v0.x, v1.x), v2.x), v3.x); + int32 maxY = MAX(MAX(MAX(v0.y, v1.y), v2.y), v3.y); + int32 maxZ = MAX(MAX(MAX(v0.z, v1.z), v2.z), v3.z); + + x = (maxX + minX) / 2; + y = (maxY + minY) / 2; + z = (maxZ + minZ) / 2; + + int32 sx = (maxX - minX) / 256 >> 1; + int32 sy = (maxY - minY) / 256 >> 1; + int32 sz = (maxZ - minZ) / 256 >> 1; + + switch (normalIndex / 2) + { + case 0 : // x + a = sy; + b = sz; + break; + case 1 : // y + a = sx; + b = sz; + break; + case 2 : // z + a = sx; + b = sy; + break; + } + } + + void write(FileStream &f) const + { + f.write(roomIndex); + f.write(normalIndex); + f.write(x); + f.write(y); + f.write(z); + f.write(a); + f.write(b); + } + }; + + struct Light + { + vec3s pos; + uint8 radius; + uint8 intensity; + + void write(FileStream &f) const + { + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(radius); + f.write(intensity); + } + }; + + struct RoomMesh + { + vec3s pos; + uint8 intensity; + uint8 flags; + + void write(FileStream &f) const + { + uint32 xy = (pos.x << 16) | uint16(pos.y); + uint32 zf = (pos.z << 16) | (intensity << 8) | flags; + f.write(xy); + f.write(zf); + } + }; + + struct Sphere16 + { + int16 x, y, z, radius; + + void write(FileStream &f) const + { + uint32 xy = (x << 16) | uint16(y); + uint32 zr = (z << 16) | uint16(radius); + f.write(xy); + f.write(zr); + } + }; + + struct MinMax + { + int16 minX, maxX; + int16 minY, maxY; + int16 minZ, maxZ; + + void write(FileStream &f) const + { + f.write(minX); f.write(maxX); + f.write(minY); f.write(maxY); + f.write(minZ); f.write(maxZ); + } + }; + + struct StaticMesh + { + uint16 id; + uint16 meshIndex; + uint32 flags; + //Sphere16 vs; + MinMax vbox; + MinMax cbox; + + void write(FileStream &f) const + { + Sphere16 vs; + vs.x = (vbox.maxX + vbox.minX) >> 1; + vs.y = (vbox.maxY + vbox.minY) >> 1; + vs.z = (vbox.maxZ + vbox.minZ) >> 1; + + int32 dx = (vbox.maxX - vbox.minX) >> 1; + int32 dy = (vbox.maxY - vbox.minY) >> 1; + int32 dz = (vbox.maxZ - vbox.minZ) >> 1; + + vs.radius = int32(sqrtf(float(dx * dx + dy * dy + dz * dz))); + + f.write(id); + f.write(meshIndex); + f.write(flags); + vs.write(f); + vbox.write(f); + cbox.write(f); + } + }; + + struct ObjectTexture + { + uint32 tile; + uint32 uv01; + uint32 uv23; + + ObjectTexture(const TR1_PC::ObjectTexture* tex) + { + tile = (tex->tile & 0x3FFF) << 16; + uint32 uv0 = ((tex->uv0 << 16) | (tex->uv0 >> 16)) & 0xFF00FF00; + uint32 uv1 = ((tex->uv1 << 16) | (tex->uv1 >> 16)) & 0xFF00FF00; + uint32 uv2 = ((tex->uv2 << 16) | (tex->uv2 >> 16)) & 0xFF00FF00; + uint32 uv3 = ((tex->uv3 << 16) | (tex->uv3 >> 16)) & 0xFF00FF00; + + fixTexCoord(uv0, uv1); + fixTexCoord(uv0, uv3); + fixTexCoord(uv1, uv2); + + uv01 = uv0 | (uv1 >> 8); + uv23 = uv2 | (uv3 >> 8); + } + + bool isEqual(const ObjectTexture* tex) + { + return memcmp(this, tex, sizeof(*tex)) == 0; + } + + void write(FileStream &f) const + { + f.write(tile); + f.write(uv01); + f.write(uv23); + } + }; + + struct SpriteTexture + { + uint32 tile; + uint32 uwvh; + int16 l, t, r, b; + + SpriteTexture(const TR1_PC::SpriteTexture* spr) + { + uint32 u = spr->u; + uint32 v = spr->v; + uint32 w = (spr->w + 255) >> 8; + uint32 h = (spr->h + 255) >> 8; + tile = spr->tile << 16; + uwvh = (u << 24) | (w << 16) | (v << 8) | h; + l = spr->l; + t = spr->t; + r = spr->r; + b = spr->b; + } + + bool isEqual(const SpriteTexture* spr) + { + return memcmp(this, spr, sizeof(*spr)) == 0; + } + + void write(FileStream &f) const + { + f.write(tile); + f.write(uwvh); + f.write(l); + f.write(t); + f.write(r); + f.write(b); + } + }; + + struct Box + { + uint8 minZ, maxZ; + uint8 minX, maxX; + int16 floor; + int16 overlap; + + void write(FileStream &f) const + { + f.write(minZ); + f.write(maxZ); + f.write(minX); + f.write(maxX); + f.write(floor); + f.write(overlap); + } + }; + + struct Item + { + uint8 type; + uint8 roomIndex; + vec3s pos; + int16 intensity; + uint16 flags; + + void write(FileStream &f) const + { + f.write(type); + f.write(roomIndex); + f.write(pos.x); + f.write(pos.y); + f.write(pos.z); + f.write(intensity); + f.write(flags); + } + }; + + struct Mesh + { + int32 offset; + TR1_PC* level; + vec3s center; + int16 radius; + uint16 intensity; + uint8 vCount; + uint8 hasNormals; + int16 rCount; + int16 crCount; + int16 tCount; + int16 ctCount; + const vec3s* vertices; + const TR1_PC::Quad* rFaces; + const TR1_PC::Quad* crFaces; + const TR1_PC::Triangle* tFaces; + const TR1_PC::Triangle* ctFaces; + + Mesh(TR1_PC* level, const uint8* ptr) + { + this->level = level; + + center = *(vec3s*)ptr; ptr += sizeof(center); + radius = *(int16*)ptr; ptr += sizeof(radius); + uint16 flags = *(uint16*)ptr; ptr += sizeof(flags); + + vCount = (uint8)*(int16*)ptr; ptr += 2; + vertices = (vec3s*)ptr; + ptr += vCount * sizeof(vec3s); + + const uint16* vIntensity = NULL; + const vec3s* vNormal = NULL; + + int16 nCount = *(int16*)ptr; ptr += 2; + //const int16* normals = (int16*)ptr; + if (nCount > 0) { // normals + vNormal = (vec3s*)ptr; + ptr += nCount * 3 * sizeof(int16); + hasNormals = 1; + } else { // intensity + vIntensity = (uint16*)ptr; + ptr += vCount * sizeof(uint16); + hasNormals = 0; + } + + hasNormals = 0; // don't use dynamic per-vertex lighting on GBA + + rCount = *(int16*)ptr; ptr += 2; + rFaces = (TR1_PC::Quad*)ptr; ptr += rCount * sizeof(TR1_PC::Quad); + + tCount = *(int16*)ptr; ptr += 2; + tFaces = (TR1_PC::Triangle*)ptr; ptr += tCount * sizeof(TR1_PC::Triangle); + + crCount = *(int16*)ptr; ptr += 2; + crFaces = (TR1_PC::Quad*)ptr; ptr += crCount * sizeof(TR1_PC::Quad); + + ctCount = *(int16*)ptr; ptr += 2; + ctFaces = (TR1_PC::Triangle*)ptr; ptr += ctCount * sizeof(TR1_PC::Triangle); + + intensity = 0; + + if (vIntensity) + { + uint32 sum = 0; + for (int32 i = 0; i < vCount; i++) + { + sum += vIntensity[i]; + } + intensity = sum / vCount; + } + } + + void write(FileStream &f, const Remap *remap) const + { + ASSERT(vCount < 256); + + #if 0 // TODO proper center/radius calc? + vec3s bmin = vertices[0]; + vec3s bmax = bmin; + + for (int32 j = 0; j < vCount; j++) + { + const vec3s* v = vertices + j; + if (v->x < bmin.x) bmin.x = v->x; + if (v->y < bmin.y) bmin.y = v->y; + if (v->z < bmin.z) bmin.z = v->z; + if (v->x > bmax.x) bmax.x = v->x; + if (v->y > bmax.y) bmax.y = v->y; + if (v->z > bmax.z) bmax.z = v->z; + } + #endif + + f.write(center.x); + f.write(center.y); + f.write(center.z); + f.write(radius); + f.write(intensity); + f.write(vCount); + f.write(hasNormals); + f.write(int16(rCount + crCount)); + f.write(int16(tCount + ctCount)); + f.write(int16(0)); + f.write(int16(0)); + + + Array sortedQuads; + + for (int32 j = 0; j < rCount; j++) + { + sortedQuads.add(rFaces + j); + } + + for (int32 j = 0; j < crCount; j++) + { + sortedQuads.add(crFaces + j); + } + + sortedQuads.sort(); // sort quads by indices for consistent deltas + + int32 prev = 0; + + for (int32 j = 0; j < sortedQuads.count; j++) + { + const TR1_PC::Quad* q = sortedQuads[j]; + + int32 i0 = q->indices[0]; + int32 i1 = q->indices[1]; + int32 i2 = q->indices[2]; + int32 i3 = q->indices[3]; + + int32 p0 = i0 - prev; + int32 p1 = i1 - i0; + int32 p2 = i2 - i1; + int32 p3 = i3 - i2; + prev = i3; + + ASSERT(p0 >= -128 && p0 <= 127); + ASSERT(p1 >= -128 && p1 <= 127); + ASSERT(p2 >= -128 && p2 <= 127); + ASSERT(p3 >= -128 && p3 <= 127); + + MeshQuad comp; + comp.indices[0] = p0; + comp.indices[1] = p1; + comp.indices[2] = p2; + comp.indices[3] = p3; + + bool textured = (q >= rFaces) && (q < (rFaces + rCount)); + + if (textured) + { + uint16 texIndex = q->flags & FACE_TEXTURE; + comp.flags = remap ? remap->textures[texIndex] : texIndex; + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) + { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } + else + { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + } + else + { + comp.flags = q->flags & FACE_TEXTURE; + comp.flags |= (FACE_TYPE_F << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + prev = 0; + for (int32 j = 0; j < tCount; j++) + { + TR1_PC::Triangle t = tFaces[j]; + uint16 texIndex = t.flags & FACE_TEXTURE; + + int32 i0 = t.indices[0]; + int32 i1 = t.indices[1]; + int32 i2 = t.indices[2]; + + int32 p0 = i0 - prev; + int32 p1 = i1 - i0; + int32 p2 = i2 - i1; + prev = i2; + + ASSERT(p0 >= -128 && p0 <= 127); + ASSERT(p1 >= -128 && p1 <= 127); + ASSERT(p2 >= -128 && p2 <= 127); + + MeshTriangle comp; + comp.indices[0] = p0; + comp.indices[1] = p1; + comp.indices[2] = 0; // asr hack + comp.indices[3] = p2; + + comp.flags = remap ? remap->textures[texIndex] : texIndex; + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + for (int32 j = 0; j < ctCount; j++) + { + TR1_PC::Triangle t = ctFaces[j]; + + int32 i0 = t.indices[0]; + int32 i1 = t.indices[1]; + int32 i2 = t.indices[2]; + + int32 p0 = i0 - prev; + int32 p1 = i1 - i0; + int32 p2 = i2 - i1; + prev = i2; + + ASSERT(p0 >= -128 && p0 <= 127); + ASSERT(p1 >= -128 && p1 <= 127); + ASSERT(p2 >= -128 && p2 <= 127); + + MeshTriangle comp; + comp.indices[0] = p0; + comp.indices[1] = p1; + comp.indices[2] = 0; // asr hack + comp.indices[3] = p2; + + comp.flags = t.flags & FACE_TEXTURE; + comp.flags |= (FACE_TYPE_F << FACE_TYPE_SHIFT); + + comp.write(f); + } + + for (int32 j = 0; j < vCount; j++) + { + struct MeshVertexGBA { + int16 x, y, z; + } v; + + v.x = vertices[j].x >> 2; + v.y = vertices[j].y >> 2; + v.z = vertices[j].z >> 2; + + f.write(v.x); + f.write(v.y); + f.write(v.z); + } + } + }; + + struct Model + { + TR1_PC* level; + int32 objTexIndex; + uint8 type; + uint8 count; + uint16 start; + uint16 nodeIndex; + uint16 animIndex; + + void init(TR1_PC* level, const TR1_PC::Model &model) + { + this->level = level; + } + + void write(FileStream &f) const + { + f.write(type); + f.write(count); + f.write(start); + f.write(nodeIndex); + f.write(animIndex); + } + }; + + struct Animation { + TR1_PC::Animation anim; + + }; + + struct AnimFrames + { + const uint8* data; + uint32 size; + + AnimFrames(const uint8* startPtr, const uint8* endPtr) + { + data = startPtr; + size = uint32(endPtr - startPtr); + } + + void write(FileStream &f) const + { + f.write(data, size); + } + }; + + struct Texture + { + const TR1_PC* level; + TR1_PC::ObjectTexture* tex; + TR1_PC::SpriteTexture* spr; + Texture* link; + int32 uid; + int32 width; + int32 height; + int32 akill; + uint8* indices; + uint32 indexSum; + int32 tile; + int32 x, y; + int32 minX, minY, maxX, maxY; + + Texture(const TR1_PC* level, TR1_PC::ObjectTexture* tex, int32 uid) + { + this->level = level; + this->tex = tex; + this->spr = NULL; + this->link = NULL; + this->uid = uid; + this->tile = -1; + + TR1_PC::Tile *tile = level->tiles + (tex->tile & 0x3FFF); + + minX = MIN(MIN(tex->x0, tex->x1), tex->x2); + minY = MIN(MIN(tex->y0, tex->y1), tex->y2); + maxX = MAX(MAX(tex->x0, tex->x1), tex->x2); + maxY = MAX(MAX(tex->y0, tex->y1), tex->y2); + + if (tex->isQuad) + { + minX = MIN(minX, tex->x3); + minY = MIN(minY, tex->y3); + maxX = MAX(maxX, tex->x3); + maxY = MAX(maxY, tex->y3); + } + + width = maxX - minX + 1; + height = maxY - minY + 1; + akill = 0; + + bool transp = (tex->attribute & TEX_ATTR_AKILL); + + indices = new uint8[width * height]; + const uint8* src = tile->indices + 256 * minY; + uint8* dst = indices; + + for (int32 y = minY; y <= maxY; y++) + { + for (int32 x = minX; x <= maxX; x++) + { + uint8 index = src[x]; + *dst++ = index; + + if ((index == 0) && transp) { + akill++; + } + } + src += 256; + } + } + + Texture(const TR1_PC* level, TR1_PC::SpriteTexture* spr, int32 uid) + { + this->level = level; + this->uid = uid; + this->tex = NULL; + this->spr = spr; + this->link = NULL; + this->tile = -1; + + TR1_PC::Tile *tile = level->tiles + (spr->tile & 0x3FF); + + minX = spr->u; + minY = spr->v; + maxX = spr->u + (spr->w >> 8); + maxY = spr->v + (spr->h >> 8); + + width = maxX - minX + 1; + height = maxY - minY + 1; + akill = 0; + indexSum = 0; + + indices = new uint8[width * height]; + const uint8* src = tile->indices + 256 * minY; + uint8* dst = indices; + + for (int32 y = minY; y <= maxY; y++) + { + for (int32 x = minX; x <= maxX; x++) + { + uint8 index = src[x]; + *dst++ = index; + + indexSum += index; + + if (index == 0) { + akill++; + } + } + src += 256; + } + } + + ~Texture() + { + delete[] indices; + } + + static int cmp(const Texture* a, const Texture* b) + { + int32 animA = a->tex ? a->tex->attribute & TEX_ATTR_ANIM : 0; + int32 animB = b->tex ? b->tex->attribute & TEX_ATTR_ANIM : 0; + int32 i = animB - animA; + + if (i == 0) + { + i = b->akill - a->akill; + } + + if (i == 0) + { + int32 max1 = MAX(a->width, a->height); + int32 max2 = MAX(b->width, b->height); + i = max2 - max1; + } + + if (i == 0) { + i = int32(a->level - b->level); + } + + if (i == 0) { + i = a->uid - b->uid; + } + + return i; + } + }; + + struct Atlas + { + struct Node + { + Node* childs[2]; + Texture* tex; + int32 l, t, r, b; + + Node(short l, short t, short r, short b) : l(l), t(t), r(r), b(b), tex(NULL) { + childs[0] = childs[1] = NULL; + } + + ~Node() { + delete childs[0]; + delete childs[1]; + } + + Node* insert(Texture* tex) + { + if (childs[0] != NULL && childs[1] != NULL) + { + Node* node = childs[0]->insert(tex); + if (node != NULL) + return node; + return childs[1]->insert(tex); + } + + if (this->tex != NULL) + return NULL; + + int16 nw = r - l; + int16 nh = b - t; + int16 tw = tex->width; + int16 th = tex->height; + + if (nw < tw || nh < th) + return NULL; + + if (nw == tw && nh == th) + { + this->tex = tex; + tex->x = l; + tex->y = t; + return this; + } + + int16 dx = nw - tw; + int16 dy = nh - th; + + if (dx > dy) { + childs[0] = new Node(l, t, l + tw, b); + childs[1] = new Node(l + tw, t, r, b); + } else { + childs[0] = new Node(l, t, r, t + th); + childs[1] = new Node(l, t + th, r, b); + } + + return childs[0]->insert(tex); + } + + void fill24(uint8* data) + { + if (childs[0] != NULL && childs[1] != NULL) + { + childs[0]->fill24(data); + childs[1]->fill24(data); + } + + if (!tex) { + return; + } + + // fill code + const TR1_PC::Palette &pal = tex->level->palette; + + uint8* index = tex->indices; + + uint8* dst = data + (t * 256 + l) * 3; + + for (int32 y = 0; y < tex->height; y++) + { + for (int32 x = 0; x < tex->width; x++) + { + if ((*index == 0) && tex->akill) { + dst[x * 3 + 0] = 255; + dst[x * 3 + 1] = 0; + dst[x * 3 + 2] = 255; + } else { + dst[x * 3 + 0] = pal.colors[*index * 3 + 2] << 2; + dst[x * 3 + 1] = pal.colors[*index * 3 + 1] << 2; + dst[x * 3 + 2] = pal.colors[*index * 3 + 0] << 2; + } + *index++; + } + dst += 256 * 3; + } + } + + void fill8(uint8* data) + { + if (childs[0] != NULL && childs[1] != NULL) + { + childs[0]->fill8(data); + childs[1]->fill8(data); + } + + if (!tex) { + return; + } + + // fill code + for (int32 y = 0; y < tex->height; y++) + { + memcpy(data + ((t + y) * 256 + l), tex->indices + y * tex->width, tex->width); + } + } + }; + + Node* root; + + Atlas() + { + root = new Node(0, 0, 256, 256); + } + + ~Atlas() + { + delete root; + } + + void fill24(uint8* data) + { + root->fill24(data); + } + + void fill8(uint8* data) + { + root->fill8(data); + } + + static int cmp(const Atlas* a, const Atlas* b) + { + return 0; + } + }; + + RoomVertex* roomVertices; + int32 roomVerticesCount; + + Remap remaps[LVL_MAX]; + + Array meshes; + Array models; + Array animFrames; + Array objectTextures; + Array spriteTextures; + + Array textures; + Array tiles; + + void addTextures(TR1_PC* level) + { + // check object textures usage + bool* used = new bool[level->objectTexturesCount]; + memset(used, 0, sizeof(bool) * level->objectTexturesCount); + + for (int32 i = 0; i < level->roomsCount; i++) + { + TR1_PC::Room &room = level->rooms[i]; + + for (int32 j = 0; j < room.qCount; j++) + { + used[room.quads[j].flags & FACE_TEXTURE] = true; + } + + for (int32 j = 0; j < room.tCount; j++) + { + used[room.triangles[j].flags & FACE_TEXTURE] = true; + } + } + + for (int32 i = 0; i < level->meshOffsetsCount; i++) + { + const uint8* ptr = (uint8*)level->meshData + level->meshOffsets[i]; + + Mesh mesh(level, ptr); + + for (int32 j = 0; j < mesh.rCount; j++) + { + used[mesh.rFaces[j].flags & FACE_TEXTURE] = true; + } + + for (int32 j = 0; j < mesh.tCount; j++) + { + used[mesh.tFaces[j].flags & FACE_TEXTURE] = true; + } + } + + static int32 texUID = 0; + + // textures + for (int32 i = 0; i < level->objectTexturesCount; i++) + { + if (!used[i]) continue; + Texture* tex = new Texture(level, level->objectTextures + i, texUID++); + textures.add(tex); + } + + // sprites + for (int32 i = 0; i < level->spriteTexturesCount; i++) + { + Texture* tex = new Texture(level, level->spriteTextures + i, texUID++); + textures.add(tex); + } + + static int32 maxSprites = 0; + maxSprites += level->spriteTexturesCount; + printf("%d\n", maxSprites); + + delete[] used; + } + + void linkTextures() + { + textures.sort(); + + for (int32 i = 0; i < textures.count; i++) + { + Texture* src = textures[i]; + ASSERT(src->link == NULL); + + for (int32 j = 0; j < i; j++) + { + Texture* dst = textures[j]; + + if (dst->link) { + dst = dst->link; + ASSERT(dst->link == NULL); + } + + if (src->tex) // is ObjectTexture + { + if (src->width != dst->width || src->height > dst->height) + continue; + + int32 dy = dst->height - src->height; + + for (int32 y = 0; y <= dy; y++) + { + if (memcmp(dst->indices + dst->width * y, src->indices, src->width * src->height) == 0) + { + src->link = dst; + break; + } + } + } + else // is SpriteTexture + { + if (src->width != dst->width || src->height != dst->height || src->indexSum != dst->indexSum) + continue; + + if (memcmp(dst->indices, src->indices, src->width * src->height) == 0) + { + src->link = dst; + break; + } + } + } + } + } + + void packTiles(FileStream &f) + { + int32 texPacked = 0; + + for (int32 i = 0; i < textures.count; i++) + { + Texture* tex = textures[i]; + + if (tex->link) + continue; + + bool placed = false; + + for (int32 j = 0; j < tiles.count; j++) + { + if (tiles[j]->root->insert(tex)) + { + placed = true; + tex->tile = j; + break; + } + } + + if (!placed) + { + Atlas* tile = new Atlas(); + tex->tile = tiles.add(tile); + placed = tile->root->insert(tex); + } + + if (!placed) + { + tex->tile = -1; + printf("Can't pack texture %d x %d", tex->width, tex->height); + break; + } + + if (placed) { + texPacked++; + } + } + + printf("textures packed: %d\n", texPacked); + + uint8* data = new uint8[256 * 256 * 3 * tiles.count]; + + // save bitmap (debug) + for (int32 i = 0; i < 256 * 256 * tiles.count; i++) + { + data[i * 3 + 0] = 255; + data[i * 3 + 1] = 0; + data[i * 3 + 2] = 255; + } + + for (int32 i = 0; i < tiles.count; i++) + { + tiles[i]->fill24(data + i * 256 * 256 * 3); + } + saveBitmap("tiles.bmp", data, 256, 256 * tiles.count); + + memset(data, 0, 256 * 256 * tiles.count); + + for (int32 i = 0; i < tiles.count; i++) + { + tiles[i]->fill8(data + i * 256 * 256); + } + + f.write(data, 256 * 256 * tiles.count); + + delete[] data; + } + + void remapTextures() + { + int32 animated = -1; + int32 maxAnimatedTex = 0; + + for (int32 i = 0; i < textures.count; i++) + { + const Texture* texture = textures[i]; + const Texture* instance = texture->link ? texture->link : texture; + + int32 dx = instance->x - instance->minX; + int32 dy = instance->y - instance->minY; + + ASSERT(instance->tile >= 0); + + Remap &remap = remaps[texture->level->id]; + + if (texture->tex) // is ObjectTexture + { + if (texture->tex->attribute & TEX_ATTR_ANIM) + { + ASSERT(animated == -1 || animated == 1); + animated = 1; + } else { + + // add dummy textures as padding between animated and static textures + int32 padding = MAX_ANIM_TEX - objectTextures.count; + for (int32 j = 0; j < padding; j++) + { + TR1_PC::ObjectTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + objectTextures.add(new ObjectTexture(&tmp)); + } + + animated = 0; + } + + TR1_PC::ObjectTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + tmp.attribute = texture->tex->attribute; // old attribute + tmp.tile = instance->tile; // new tile index + tmp.x0 = texture->tex->x0 + dx; + tmp.y0 = texture->tex->y0 + dy; + tmp.x1 = texture->tex->x1 + dx; + tmp.y1 = texture->tex->y1 + dy; + tmp.x2 = texture->tex->x2 + dx; + tmp.y2 = texture->tex->y2 + dy; + if (texture->tex->isQuad) + { + tmp.x3 = texture->tex->x3 + dx; + tmp.y3 = texture->tex->y3 + dy; + } + + ObjectTexture* comp = new ObjectTexture(&tmp); + + int32 texIndex = int32(texture->tex - texture->level->objectTextures); + + int32 index = objectTextures.find(comp); + if (index <= 0) { + index = objectTextures.add(comp); + } else { + delete comp; + } + remap.textures[texIndex] = index; + + if (texture->tex->attribute & TEX_ATTR_ANIM) { + maxAnimatedTex = i; + } + } + else // is SpriteTexture + { + ASSERT(animated == 0); + + TR1_PC::SpriteTexture tmp; + memset(&tmp, 0, sizeof(tmp)); + tmp.tile = instance->spr->tile; + tmp.u = texture->spr->u + dx; + tmp.v = texture->spr->v + dy; + tmp.w = texture->spr->w; + tmp.h = texture->spr->h; + tmp.l = texture->spr->l; + tmp.t = texture->spr->t; + tmp.r = texture->spr->r; + tmp.b = texture->spr->b; + + SpriteTexture* comp = new SpriteTexture(&tmp); + + int32 sprIndex = int32(texture->spr - texture->level->spriteTextures); + + int32 index = spriteTextures.find(comp); + if (index <= 0) { + index = spriteTextures.add(comp); + } else { + delete comp; + } + remap.sprites[sprIndex] = index; + } + } + + printf("animated textures: %d\n", maxAnimatedTex + 1); + + ASSERT(maxAnimatedTex < MAX_ANIM_TEX); + } + + int32 addRoomVertex(int32 yOffset, const TR1_PC::Room::Vertex &v) + { + RoomVertex comp; + int32 px = v.pos.x >> 8; + int32 py = (v.pos.y - yOffset) >> 8; + int32 pz = v.pos.z >> 8; + + ASSERT(py >= 0); + ASSERT(px < (32 << 2)); + ASSERT(py < 64); + ASSERT(pz < (32 << 2)); + + comp.x = px; + comp.y = py; + comp.z = pz; + comp.g = v.lighting >> 5; + + for (int32 i = 0; i < roomVerticesCount; i++) + { + if (memcmp(roomVertices + i, &comp, sizeof(comp)) == 0) + { + return i; + } + } + + ASSERT(roomVerticesCount < 0xFFFF); + + roomVertices[roomVerticesCount] = comp; + return roomVerticesCount++; + } + + int32 addMesh(Mesh* mesh) + { + for (int32 i = 0; i < meshes.count; i++) + { + const Mesh* m = meshes[i]; + if (m->center.x != mesh->center.x || + m->center.y != mesh->center.y || + m->center.z != mesh->center.z || + m->radius != mesh->radius || + m->intensity != mesh->intensity || // TODO move to static mesh to save 5k + m->vCount < mesh->vCount || + m->rCount < mesh->rCount || + m->crCount < mesh->crCount || + m->tCount < mesh->tCount || + m->ctCount < mesh->ctCount) continue; + + if (memcmp(m->vertices, mesh->vertices, mesh->vCount * sizeof(mesh->vertices[0])) != 0) + continue; + + delete mesh; + + return i; + } + + return meshes.add(mesh); + } + + int32 addModel(const Model &model) + { + return 0; + } + + int32 addAnimFrames(AnimFrames* anim) + { + for (int32 i = 0; i < animFrames.count; i++) + { + const AnimFrames* af = animFrames[i]; + + if (af->size < anim->size) + continue; + + if (memcmp(af->data, anim->data, anim->size) != 0) + continue; + + delete anim; + + return i; + } + + return animFrames.add(anim); + } + + uint32 writePalette(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + uint16 pal[256]; + + for (int32 i = 0; i < 256; i++) + { + uint8 r = level->palette.colors[i * 3 + 0]; + uint8 g = level->palette.colors[i * 3 + 1]; + uint8 b = level->palette.colors[i * 3 + 2]; + + pal[i] = (r >> 1) | ((g >> 1) << 5) | ((b >> 1) << 10); + } + + pal[0] = 0; + + f.write(pal, 256); + + return offset; + } + + uint32 writeLightmap(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + #if 1 + for (int32 i = 0; i < 32; i++) { + level->lightmap[i * 256] = 0; + } + f.write(level->lightmap, 256 * 32); + #else + uint8 lmap[256 * 32]; + for (int32 i = 0; i < 32; i++) + { + for (int32 j = 0; j < 256; j++) + { + lmap[j * 32 + i] = level->lightmap[i * 256 + j]; + } + } + f.write(lmap, 256 * 32); + #endif + return offset; + } + + uint32 writeRooms(FileStream &f, TR1_PC* level, const Remap* remap) + { + uint32 offset = f.align4(); + + f.seek(sizeof(Info) * level->roomsCount); + + Info infos[255]; + + for (int32 i = 0; i < level->roomsCount; i++) + { + const TR1_PC::Room* room = level->rooms + i; + + Info &info = infos[i]; + + ASSERT(room->info.x % 256 == 0); + ASSERT(room->info.z % 256 == 0); + ASSERT(room->info.yBottom >= -32768 && room->info.yBottom <= 32767); + ASSERT(room->info.yTop >= -32768 && room->info.yTop <= 32767); + info.x = room->info.x / 256; + info.z = room->info.z / 256; + + info.yBottom = -32768; + info.yTop = 32767; + + for (int32 j = 0; j < room->vCount; j++) + { + TR1_PC::Room::Vertex &v = room->vertices[j]; + if (v.pos.y < info.yTop) { + info.yTop = v.pos.y; + } + if (v.pos.y > info.yBottom) { + info.yBottom = v.pos.y; + } + } + + info.spritesCount = room->sCount; + info.quadsCount = room->qCount; + info.trianglesCount = room->tCount; + info.portalsCount = uint8(room->pCount); + info.lightsCount = uint8(room->lCount); + info.meshesCount = uint8(room->mCount); + info.ambient = room->ambient >> 5; + info.xSectors = uint8(room->xSectors); + info.zSectors = uint8(room->zSectors); + info.alternateRoom = uint8(room->alternateRoom); + + info.flags = 0; + if (room->flags & 1) info.flags |= 1; + if (room->flags & 256) info.flags |= 2; + + ASSERT((room->flags & ~257) == 0); + ASSERT(info.portalsCount == room->pCount); + ASSERT(info.lightsCount == room->lCount); + ASSERT(info.meshesCount == room->mCount); + ASSERT(info.xSectors == room->xSectors); + ASSERT(info.zSectors == room->zSectors); + + roomVerticesCount = 0; + + info.quads = f.align4(); + + int32 prev = 0; + + for (int32 i = 0; i < room->qCount; i++) + { + TR1_PC::Quad q = room->quads[i]; + uint16 texIndex = q.flags & FACE_TEXTURE; + + int32 i0 = addRoomVertex(info.yTop, room->vertices[q.indices[0]]); + int32 i1 = addRoomVertex(info.yTop, room->vertices[q.indices[1]]); + int32 i2 = addRoomVertex(info.yTop, room->vertices[q.indices[2]]); + int32 i3 = addRoomVertex(info.yTop, room->vertices[q.indices[3]]); + + int32 p0 = i0 - prev; + int32 p1 = i1 - i0; + int32 p2 = i2 - i1; + int32 p3 = i3 - i2; + prev = i3; + + ASSERT(p0 >= -128 && p0 <= 127); + ASSERT(p1 >= -128 && p1 <= 127); + ASSERT(p2 >= -128 && p2 <= 127); + ASSERT(p3 >= -128 && p3 <= 127); + + RoomQuad comp; + comp.indices[0] = p0; + comp.indices[1] = p1; + comp.indices[2] = p2; + comp.indices[3] = p3; + + comp.flags = remap ? remap->textures[texIndex] : texIndex; + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + info.triangles = f.align4(); + for (int32 i = 0; i < room->tCount; i++) + { + TR1_PC::Triangle t = room->triangles[i]; + uint16 texIndex = t.flags & FACE_TEXTURE; + + RoomTriangle comp; + comp.indices[0] = addRoomVertex(info.yTop, room->vertices[t.indices[0]]); + comp.indices[1] = addRoomVertex(info.yTop, room->vertices[t.indices[1]]); + comp.indices[2] = addRoomVertex(info.yTop, room->vertices[t.indices[2]]); + comp.flags = remap ? remap->textures[texIndex] : texIndex; + + if (level->objectTextures[texIndex].attribute & TEX_ATTR_AKILL) { + comp.flags |= (FACE_TYPE_FTA << FACE_TYPE_SHIFT); + } else { + comp.flags |= (FACE_TYPE_FT << FACE_TYPE_SHIFT); + } + + comp.write(f); + } + + info.vertices = f.align4(); + info.verticesCount = roomVerticesCount; + for (int32 i = 0; i < roomVerticesCount; i++) + { + roomVertices[i].write(f); + } + + info.sprites = f.align4(); + for (int32 i = 0; i < room->sCount; i++) + { + const TR1_PC::Room::Sprite* sprite = room->sprites + i; + const TR1_PC::Room::Vertex* v = room->vertices + sprite->index; + + Sprite comp; + comp.x = v->pos.x; + comp.y = v->pos.y; + comp.z = v->pos.z; + comp.g = v->lighting >> 5; + comp.index = uint8(sprite->texture); + + ASSERT(sprite->texture <= 255); + + comp.write(f); + } + + info.portals = f.align4(); + #if 0 // -72k + for (int32 i = 0; i < room->pCount; i++) + { + Portal p = room->portals[i]; + p.write(f); + } + #else + f.writeObj(room->portals, room->pCount); + #endif + + info.sectors = f.align4(); + f.writeObj(room->sectors, room->zSectors * room->xSectors); + + info.lights = f.align4(); + for (int32 i = 0; i < room->lCount; i++) + { + const TR1_PC::Room::Light* light = room->lights + i; + + Light comp; + comp.pos.x = light->pos.x - room->info.x; + comp.pos.y = light->pos.y; + comp.pos.z = light->pos.z - room->info.z; + comp.radius = light->radius >> 8; + comp.intensity = light->intensity >> 5; + + comp.write(f); + } + + info.meshes = f.align4(); + for (int32 i = 0; i < room->mCount; i++) + { + const TR1_PC::Room::Mesh* mesh = room->meshes + i; + + RoomMesh comp; + comp.pos.x = mesh->pos.x - room->info.x; + comp.pos.y = mesh->pos.y; + comp.pos.z = mesh->pos.z - room->info.z; + comp.intensity = mesh->intensity >> 5; + comp.flags = ((mesh->angleY / 0x4000 + 2) << 6) | mesh->id; + + ASSERT(mesh->id <= 63); + ASSERT(mesh->angleY % 0x4000 == 0); + ASSERT(mesh->angleY / 0x4000 + 2 >= 0); + + comp.write(f); + } + } + + int32 pos = f.getPos(); + f.setPos(offset); + f.writeObj(infos, level->roomsCount); + f.setPos(pos); + + return offset; + } + + uint32 writeFloors(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->floors, level->floorsCount); + + return offset; + } + + uint32 writeStaticMeshes(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->staticMeshesCount; i++) + { + const TR1_PC::StaticMesh* staticMesh = level->staticMeshes + i; + + StaticMesh comp; + comp.id = staticMesh->id; + comp.meshIndex = staticMesh->meshIndex; + comp.flags = staticMesh->flags; + + comp.vbox.minX = staticMesh->vbox.minX; + comp.vbox.maxX = staticMesh->vbox.maxX; + comp.vbox.minY = staticMesh->vbox.minY; + comp.vbox.maxY = staticMesh->vbox.maxY; + comp.vbox.minZ = staticMesh->vbox.minZ; + comp.vbox.maxZ = staticMesh->vbox.maxZ; + + comp.cbox.minX = staticMesh->cbox.minX; + comp.cbox.maxX = staticMesh->cbox.maxX; + comp.cbox.minY = staticMesh->cbox.minY; + comp.cbox.maxY = staticMesh->cbox.maxY; + comp.cbox.minZ = staticMesh->cbox.minZ; + comp.cbox.maxZ = staticMesh->cbox.maxZ; + + comp.write(f); + } + + return offset; + } + + uint32 writeCameras(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->cameras, level->camerasCount); + + return offset; + } + + uint32 writeSoundSources(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->soundSources, level->soundSourcesCount); + + return offset; + } + + uint32 writeBoxes(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->boxesCount; i++) + { + const TR1_PC::Box* box = level->boxes + i; + + Box comp; + comp.minX = box->minX / 1024; + comp.minZ = box->minZ / 1024; + comp.maxX = (box->maxX + 1) / 1024; + comp.maxZ = (box->maxZ + 1) / 1024; + comp.floor = box->floor; + comp.overlap = box->overlap; + + comp.write(f); + } + + return offset; + } + + uint32 writeOverlaps(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.write(level->overlaps, level->overlapsCount); + + return offset; + } + + void writeZones(FileStream &f, TR1_PC* level, uint32* zoneOffset) + { + for (int32 i = 0; i < 2; i++) + { + *zoneOffset++ = f.align4(); + f.write(level->zones[i].ground1, level->boxesCount); + + *zoneOffset++ = f.align4(); + f.write(level->zones[i].ground2, level->boxesCount); + + *zoneOffset++ = f.align4(); + f.write(level->zones[i].fly, level->boxesCount); + } + } + + uint32 writeAnimTex(FileStream &f, TR1_PC* level, const Remap* remap) + { + uint32 offset = f.align4(); + + const uint16* data = level->animTexData; + + int16 rangesCount = *data++; + + f.write(rangesCount); + + for (int32 i = 0; i < rangesCount; i++) + { + int16 texCount = *data++; + + f.write(texCount); + + for (int32 j = 0; j <= texCount; j++) + { + uint16 texIndex = *data++; + + if (remap) + { + texIndex = remap->textures[texIndex]; + } + + f.write(texIndex); + } + } + + return offset; + } + + uint32 writeItems(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + for (int32 i = 0; i < level->itemsCount; i++) + { + const TR1_PC::Item* item = level->items + i; + const TR1_PC::Room* room = level->rooms + item->roomIndex; + + Item comp; + comp.type = uint8(item->type); + comp.roomIndex = uint8(item->roomIndex); + comp.pos.x = int16(item->pos.x - room->info.x); + comp.pos.y = int16(item->pos.y); + comp.pos.z = int16(item->pos.z - room->info.z); + comp.intensity = item->intensity < 0 ? 0 : (item->intensity >> 5); + comp.flags = item->flags | ((item->angleY / 0x4000 + 2) << 14); + + ASSERT((item->flags & ~(0x3F1F)) == 0); + + comp.write(f); + } + + return offset; + } + + uint32 writeCameraFrames(FileStream &f, TR1_PC* level) + { + uint32 offset = f.align4(); + + f.writeObj(level->cameraFrames, level->cameraFramesCount); + + return offset; + } + + void convertGBA(FileStream &f, TR1_PC* pc) + { + pc->fixHeadMask(); + + Header header; + f.seek(sizeof(Header)); // will be rewritten at the end + + header.magic = 0x20414247; + header.tilesCount = pc->tilesCount; + header.roomsCount = pc->roomsCount; + header.modelsCount = pc->modelsCount; + header.meshesCount = pc->meshOffsetsCount; + header.staticMeshesCount = pc->staticMeshesCount; + header.spriteSequencesCount = pc->spriteSequencesCount; + header.soundSourcesCount = pc->soundSourcesCount; + header.boxesCount = pc->boxesCount; + header.texturesCount = pc->objectTexturesCount; + header.spritesCount = pc->spriteTexturesCount; + header.itemsCount = pc->itemsCount; + header.camerasCount = pc->camerasCount; + header.cameraFramesCount = pc->cameraFramesCount; + header.soundOffsetsCount = pc->soundOffsetsCount; + + header.palette = writePalette(f, pc); + header.lightmap = writeLightmap(f, pc); + + header.tiles = f.align4(); + f.write((uint8*)pc->tiles, header.tilesCount * 256 * 256); + + header.rooms = writeRooms(f, pc, NULL); + header.floors = writeFloors(f, pc); + + header.meshData = f.align4(); + + int32 mOffsets[2048]; + for (int32 i = 0; i < 2048; i++) { + mOffsets[i] = -1; + } + + for (int32 i = 0; i < pc->meshOffsetsCount; i++) + { + if (mOffsets[i] != -1) + continue; + + mOffsets[i] = f.align4() - header.meshData; + + const uint8* ptr = (uint8*)pc->meshData + pc->meshOffsets[i]; + + Mesh* mesh = new Mesh(pc, ptr); + mesh->write(f, NULL); + delete[] mesh; + + for (int32 j = i + 1; j < pc->meshOffsetsCount; j++) + { + if (pc->meshOffsets[i] == pc->meshOffsets[j]) + { + mOffsets[j] = mOffsets[i]; + } + } + } + + header.meshOffsets = f.align4(); + f.write(mOffsets, pc->meshOffsetsCount); + + header.anims = f.align4(); + f.writeObj(pc->anims, pc->animsCount); + + header.states = f.align4(); + for (int32 i = 0; i < pc->statesCount; i++) + { + const TR1_PC::AnimState* state = pc->states + i; + + AnimState comp; + comp.state = uint8(state->state); + comp.rangesCount = uint8(state->rangesCount); + comp.rangesStart = state->rangesStart; + + comp.write(f); + } + + header.ranges = f.align4(); + f.writeObj(pc->ranges, pc->rangesCount); + + header.commands = f.align4(); + f.write(pc->commands, pc->commandsCount); + + header.nodes = f.align4(); + for (int32 i = 0; i < pc->nodesDataSize / 4; i++) + { + const TR1_PC::Node* node = (TR1_PC::Node*)(pc->nodesData + i * 4); + + ASSERT(node->pos.x > -32768); + ASSERT(node->pos.x < 32767); + ASSERT(node->pos.y > -32768); + ASSERT(node->pos.y < 32767); + ASSERT(node->pos.z > -32768); + ASSERT(node->pos.z < 32767); + ASSERT(node->flags < 0xFFFF); + + Node comp; + comp.flags = uint16(node->flags); + comp.pos.x = int16(node->pos.x); + comp.pos.y = int16(node->pos.y); + comp.pos.z = int16(node->pos.z); + + comp.write(f); + } + + header.frameData = f.align4(); + f.write(pc->frameData, pc->frameDataSize); + + header.models = f.align4(); + for (int32 i = 0; i < pc->modelsCount; i++) + { + const TR1_PC::Model* model = pc->models + i; + + Model comp; + comp.type = uint8(model->type); + comp.count = uint8(model->count); + comp.start = model->start; + comp.nodeIndex = model->nodeIndex / 4; + comp.animIndex = model->animIndex; + + comp.write(f); + } + + header.staticMeshes = writeStaticMeshes(f, pc); + + header.objectTextures = f.align4(); + for (int32 i = 0; i < pc->objectTexturesCount; i++) + { + ObjectTexture comp(pc->objectTextures + i); + comp.write(f); + } + + header.spriteTextures = f.align4(); + for (int32 i = 0; i < pc->spriteTexturesCount; i++) + { + SpriteTexture comp(pc->spriteTextures + i); + comp.write(f); + } + + header.spriteSequences = f.align4(); + f.writeObj(pc->spriteSequences, pc->spriteSequencesCount); + + header.cameras = writeCameras(f, pc); + header.soundSources = writeSoundSources(f, pc); + header.boxes = writeBoxes(f, pc); + header.overlaps = writeOverlaps(f, pc); + writeZones(f, pc, header.zones[0]); + header.animTexData = writeAnimTex(f, pc, NULL); + header.items = writeItems(f, pc); + header.cameraFrames = writeCameraFrames(f, pc); + + //f.writeArray(demoData, demoDataSize); + + for (int32 i = 0; i < pc->soundOffsetsCount; i++) + { + uint8* ptr = pc->soundData + pc->soundOffsets[i]; + int32 size = *(int32*)(ptr + 40); + uint8* src = ptr + 44; + uint8* dst = ptr; + + while ((dst - pc->soundData) % 4 != 0) { + dst++; + } + dst += 4; + + for (int32 j = 0; j < size; j++) + { + dst[j] = src[j]; + } + + while ((size % 4) != 0) + { + dst[size] = dst[size - 1]; + size++; + } + + dst -= 4; + *(int32*)dst = size; + + pc->soundOffsets[i] = uint32(dst - pc->soundData); + } + + header.soundMap = f.align4(); + f.write(pc->soundMap, 256); + + header.soundInfos = f.align4(); + f.writeObj(pc->soundInfo, pc->soundInfoCount); + + header.soundData = f.align4(); + f.write(pc->soundData, pc->soundDataSize); + + header.soundOffsets = f.align4(); + f.write(pc->soundOffsets, pc->soundOffsetsCount); + + f.setPos(0); + header.write(f); + } + + void convertTracks(FileStream &f, const char* from) + { + char buf[256]; + sprintf(buf, "%s/*.ad4", from); + + WIN32_FIND_DATA fd; + HANDLE h = FindFirstFile(buf, &fd); + + if (h == INVALID_HANDLE_VALUE) + return; + + struct Track { + int32 size; + uint8* data; + }; + Track tracks[MAX_TRACKS]; + memset(tracks, 0, sizeof(tracks)); + + do + { + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + const char* src = fd.cFileName; + const char* srcEnd = strrchr(src, '.'); + char* dst = buf; + + while (src < srcEnd) + { + if (*src >= '0' && *src <= '9') + { + *dst++ = *src; + } + src++; + } + *dst++ = 0; + + int32 index = atoi(buf); + + if (index != 0) + { + strcpy(buf, from); + strcat(buf, "/"); + strcat(buf, fd.cFileName); + + FILE* f = fopen(buf, "rb"); + + if (!f) + continue; + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + tracks[index].data = new uint8[size]; + fread(tracks[index].data, 1, size, f); + fclose(f); + + tracks[index].size = size; // ad4 tool encodes 32-bit chunks, so no need to align + ASSERT(tracks[index].size % 4 == 0); + } + } + } + while (FindNextFile(h, &fd)); + FindClose(h); + + int32 offset = MAX_TRACKS * (4 + 4); + + for (int32 i = 0; i < MAX_TRACKS; i++) + { + if (tracks[i].size == 0) { + int32 zero = 0; + f.write(zero); + } else { + f.write(offset); + } + f.write(tracks[i].size); + offset += tracks[i].size; + } + + for (int32 i = 0; i < MAX_TRACKS; i++) + { + if (tracks[i].size == 0) + continue; + f.write(tracks[i].data, tracks[i].size); + delete[] tracks[i].data; + } + } + + void convertScreen(const char* dir, const char* name, const TR1_PC::Palette &pal) + { + char path[256]; + sprintf(path, "screens/%s.bmp", name); + + int32 width, height, bpp; + uint32* data = (uint32*)loadBitmap(path, &width, &height, &bpp); + + ASSERT(data); + ASSERT(width == 240 && height == 160 && bpp == 32); + + uint32* uniqueColors = new uint32[width * height]; + int32 count = 0; + + for (int32 i = 0; i < width * height; i++) + { + uint32 c = data[i]; + + int32 index = -1; + + for (int32 j = 0; j < count; j++) + { + if (uniqueColors[j] == c) { + index = j; + break; + } + } + + if (index == -1) { + index = count++; + uniqueColors[index] = c; + } + + data[i] = index; + } + + for (int32 i = 0; i < count; i++) + { + uint32 c = uniqueColors[i]; + + int32 cr = (c >> 16) & 0xFF; + int32 cg = (c >> 8) & 0xFF; + int32 cb = c & 0xFF; + + float dist = 256 * 256 * 256; + int32 index = 0; + + for (int32 j = 0; j < 256; j++) + { + int32 r = pal.colors[j * 3 + 0] << 2; + int32 g = pal.colors[j * 3 + 1] << 2; + int32 b = pal.colors[j * 3 + 2] << 2; + + float d = sqrtf(float(SQR(cr - r) + SQR(cg - g) + SQR(cb - b))); + if (d < dist) + { + dist = d; + index = j; + } + } + + uniqueColors[i] = index; + } + + uint8* indices = new uint8[width * height]; + for (int32 i = 0; i < width * height; i++) + { + indices[i] = uniqueColors[data[i]]; + } + + sprintf(path, "%s/%s.SCR", dir, name); + + FILE *f = fopen(path, "wb"); + fwrite(indices, 1, width * height, f); + fclose(f); + + delete[] data; + delete[] uniqueColors; + delete[] indices; + } + + void markAnimatedTextures(TR1_PC* level) + { + const uint16* data = level->animTexData; + + int16 rangesCount = *data++; + + for (int32 i = 0; i < rangesCount; i++) + { + int16 texCount = *data++; + + for (int32 j = 0; j <= texCount; j++) + { + level->objectTextures[*data++].attribute |= TEX_ATTR_ANIM; + } + } + } + + void convertWAD(FileStream &f, TR1_PC** pc, TR1_PSX** psx) + { + TR1_PC* level; + int32 id; + + #define LEVELS_LOOP() for (id = 0, level = pc[id]; id < LVL_MAX; id++, level = pc[id]) + + Header headers[LVL_MAX]; + f.seek(sizeof(headers)); + + // audio tracks + convertTracks(f, "tracks/conv"); + + // collect unique textures + LEVELS_LOOP() + { + markAnimatedTextures(level); + addTextures(level); + } + + linkTextures(); + + packTiles(f); + + remapTextures(); + + printf("textures: %d\n", objectTextures.count); + printf("sprites: %d\n", spriteTextures.count); + + ASSERT(objectTextures.count < (1 << FACE_TYPE_SHIFT)); + + // collect unique meshes + LEVELS_LOOP() + { + ASSERT(level->meshOffsetsCount < MAX_MESHES); + + for (int32 i = 0; i < level->meshOffsetsCount; i++) + { + const uint8* ptr = (uint8*)level->meshData + level->meshOffsets[i]; + + Mesh* mesh = new Mesh(level, ptr); + remaps[id].meshes[i] = addMesh(mesh); + } + } + + // collect unique animations + LEVELS_LOOP() + { + ASSERT(level->animsCount < MAX_ANIMS); + + for (int32 i = 0; i < level->modelsCount; i++) + { + const TR1_PC::Model &curModel = level->models[i]; + if (curModel.animIndex == 0xFFFF) + continue; + + uint8* startPtr = (uint8*)&level->frameData[level->anims[curModel.animIndex].frameOffset >> 1]; + uint8* endPtr = (uint8*)&level->frameData[level->frameDataSize]; + + for (int32 j = i + 1; j < level->modelsCount; j++) + { + const TR1_PC::Model &nextModel = level->models[j]; + if (nextModel.animIndex == 0xFFFF) + continue; + + endPtr = (uint8*)&level->frameData[level->anims[nextModel.animIndex].frameOffset >> 1]; + break; + } + + AnimFrames* af = new AnimFrames(startPtr, endPtr); + remaps[id].animFrames[i] = addAnimFrames(af); + } + } + + // collect unique models + LEVELS_LOOP() + { + printf("anims: %d\n", level->animsCount); + + for (int32 i = 0; i < level->modelsCount; i++) + { + Model model; + model.init(level, level->models[i]); + remaps[id].models[i] = addModel(model); + } + } + + printf("Meshes: %d\n", meshes.count); + printf("Models: %d\n", models.count); + printf("Animations: %d\n", animFrames.count); + + // write objectTextures + headers[0].objectTextures = f.align4(); + for (int32 i = 0; i < objectTextures.count; i++) + { + objectTextures[i]->write(f); + } + + // write spriteTextures + headers[0].spriteTextures = f.align4(); + for (int32 i = 0; i < spriteTextures.count; i++) + { + spriteTextures[i]->write(f); + } + + // write meshes + headers[0].meshData = f.align4(); + for (int32 i = 0; i < meshes.count; i++) + { + meshes[i]->offset = f.align4(); + meshes[i]->write(f, &remaps[meshes[i]->level->id]); + } + + // write models + headers[0].models = f.align4(); + for (int32 i = 0; i < models.count; i++) + { + models[i]->write(f); + } + + // write anims + headers[0].frameData = f.align4(); + for (int32 i = 0; i < animFrames.count; i++) + { + animFrames[i]->write(f); + } + + // set global array pointers + LEVELS_LOOP() + { + headers[id].objectTextures = headers[0].objectTextures; + headers[id].spriteTextures = headers[0].spriteTextures; + headers[id].meshData = headers[0].meshData; + headers[id].models = headers[0].models; + headers[id].frameData = headers[0].frameData; + } + + // palette + LEVELS_LOOP() + { + headers[id].palette = writePalette(f, level); + } + + // lightmaps + LEVELS_LOOP() + { + headers[id].lightmap = writeLightmap(f, level); + } + + // rooms + LEVELS_LOOP() + { + headers[id].rooms = writeRooms(f, level, &remaps[id]); + } + + // floors data + LEVELS_LOOP() + { + headers[id].floors = writeFloors(f, level); + } + + // mesh offsets + LEVELS_LOOP() + { + headers[id].meshesCount = level->meshOffsetsCount; + headers[id].meshOffsets = f.align4(); + for (int32 i = 0; i < level->meshOffsetsCount; i++) + { + f.write(meshes[remaps[id].meshes[i]]->offset); + } + } + +/* + LEVELS_LOOP() + { + //header.anims = f.align4(); + f.writeObj(level->anims, level->animsCount); + + //header.states = f.align4(); + for (int32 i = 0; i < level->statesCount; i++) + { + const TR1_PC::AnimState* state = level->states + i; + + AnimState comp; + comp.state = uint8(state->state); + comp.rangesCount = uint8(state->rangesCount); + comp.rangesStart = state->rangesStart; + + comp.write(f); + } + + //header.ranges = f.align4(); + f.writeObj(level->ranges, level->rangesCount); + + //header.commands = f.align4(); + f.write(level->commands, level->commandsCount); + + //header.nodes = f.align4(); + for (int32 i = 0; i < level->nodesDataSize / 4; i++) + { + const TR1_PC::Node* node = (TR1_PC::Node*)(level->nodesData + i * 4); + + ASSERT(node->pos.x > -32768); + ASSERT(node->pos.x < 32767); + ASSERT(node->pos.y > -32768); + ASSERT(node->pos.y < 32767); + ASSERT(node->pos.z > -32768); + ASSERT(node->pos.z < 32767); + ASSERT(node->flags < 0xFFFF); + + Node comp; + comp.flags = uint16(node->flags); + comp.pos.x = int16(node->pos.x); + comp.pos.y = int16(node->pos.y); + comp.pos.z = int16(node->pos.z); + + comp.write(f); + } + + //header.frameData = f.align4(); + f.write(level->frameData, level->frameDataSize); + + //header.models = f.align4(); + for (int32 i = 0; i < level->modelsCount; i++) + { + const TR1_PC::Model* model = level->models + i; + + Model comp; + comp.type = uint8(model->type); + comp.count = uint8(model->count); + comp.start = model->start; + comp.nodeIndex = model->nodeIndex / 4; + comp.animIndex = model->animIndex; + + comp.write(f); + } + } +*/ + LEVELS_LOOP() + { + headers[id].staticMeshes = writeStaticMeshes(f, level); + } + +/* + header.spriteSequences = f.align4(); + f.writeObj(pc->spriteSequences, pc->spriteSequencesCount); +*/ + + // fixed cameras + LEVELS_LOOP() + { + headers[id].cameras = writeCameras(f, level); + } + + // static sounds + LEVELS_LOOP() + { + headers[id].soundSources = writeSoundSources(f, level); + } + + // boxes + LEVELS_LOOP() + { + headers[id].boxes = writeBoxes(f, level); + } + + // overlaps + LEVELS_LOOP() + { + headers[id].overlaps = writeOverlaps(f, level); + } + + // zones + LEVELS_LOOP() + { + writeZones(f, level, headers[id].zones[0]); + } + + // animated textures + LEVELS_LOOP() + { + headers[id].animTexData = writeAnimTex(f, level, &remaps[id]); + } + + // items + LEVELS_LOOP() + { + headers[id].items = writeItems(f, level); + } + + // animated camera frames + LEVELS_LOOP() + { + headers[id].cameraFrames = writeCameraFrames(f, level); + } + + /* + for (int32 i = 0; i < pc->soundOffsetsCount; i++) + { + uint8* ptr = pc->soundData + pc->soundOffsets[i]; + int32 size = *(int32*)(ptr + 40); + uint8* src = ptr + 44; + uint8* dst = ptr; + + while ((dst - pc->soundData) % 4 != 0) { + dst++; + } + dst += 4; + + for (int32 j = 0; j < size; j++) + { + dst[j] = src[j]; + } + + while ((size % 4) != 0) + { + dst[size] = dst[size - 1]; + size++; + } + + dst -= 4; + *(int32*)dst = size; + + pc->soundOffsets[i] = dst - pc->soundData; + } + + header.soundMap = f.align4(); + f.write(pc->soundMap, 256); + + header.soundInfos = f.align4(); + f.writeObj(pc->soundInfo, pc->soundInfoCount); + + header.soundData = f.align4(); + f.write(pc->soundData, pc->soundDataSize); + + header.soundOffsets = f.align4(); + f.write(pc->soundOffsets, pc->soundOffsetsCount); + + f.setPos(0); + header.write(f); + */ + f.writeRaw(headers); + } + + //#define GBA_WAD + + void process(const char* dir, TR1_PC** pc, TR1_PSX** psx) + { + roomVerticesCount = 0; + roomVertices = new RoomVertex[MAX_ROOM_VERTICES]; + + char buf[256]; + #ifdef GBA_WAD + sprintf(buf, "%s/TR1.WAD", dir); + FileStream f(buf, true); + + if (!f.isValid()) { + printf("can't save \"%s\"\n", buf); + return; + } + + convertWAD(f, pc, psx); + #else + for (int32 i = 0; i < LVL_MAX; i++) + { + sprintf(buf, "%s/%s.PKD", dir, levelNames[i]); + FileStream f(buf, true); + + if (!f.isValid()) { + printf("can't save \"%s\"\n", buf); + continue; + } + + convertGBA(f, pc[i]); + } + + // title screen + convertScreen(dir, "TITLE", pc[LVL_TR1_TITLE]->palette); + + // audio tracks + { + sprintf(buf, "%s/TRACKS.AD4", dir); + FileStream f(buf, true); + convertTracks(f, "tracks/conv_demo"); + } + #endif + + delete[] roomVertices; + } +}; + +#endif \ No newline at end of file diff --git a/src/platform/gba/packer/packer.sln b/src/platform/gba/packer/packer.sln new file mode 100644 index 00000000..ccebf56b --- /dev/null +++ b/src/platform/gba/packer/packer.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "packer", "packer.vcxproj", "{CED88939-237F-4F70-872C-704A51F7B8E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CED88939-237F-4F70-872C-704A51F7B8E5}.Debug|x64.ActiveCfg = Debug|x64 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Debug|x64.Build.0 = Debug|x64 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Debug|x86.ActiveCfg = Debug|Win32 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Debug|x86.Build.0 = Debug|Win32 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Release|x64.ActiveCfg = Release|x64 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Release|x64.Build.0 = Release|x64 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Release|x86.ActiveCfg = Release|Win32 + {CED88939-237F-4F70-872C-704A51F7B8E5}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A0748762-B1DD-4990-8016-21AD34BA8501} + EndGlobalSection +EndGlobal diff --git a/src/platform/gba/packer/packer.vcxproj b/src/platform/gba/packer/packer.vcxproj new file mode 100644 index 00000000..0bd0d2cb --- /dev/null +++ b/src/platform/gba/packer/packer.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {ced88939-237f-4f70-872c-704a51f7b8e5} + packer + 10.0 + + + + Application + true + v142 + NotSet + + + Application + false + v142 + true + NotSet + + + Application + true + v142 + NotSet + + + Application + false + v142 + true + NotSet + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)\libimagequant;$(ProjectDir)\stb;$(IncludePath) + + + false + $(ProjectDir)\libimagequant;$(ProjectDir)\stb;$(IncludePath) + + + true + $(ProjectDir)\libimagequant;$(ProjectDir)\stb;$(IncludePath) + + + false + $(ProjectDir)\libimagequant;$(ProjectDir)\stb;$(IncludePath) + + + + Level3 + true + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/gba/packer/packer.vcxproj.filters b/src/platform/gba/packer/packer.vcxproj.filters new file mode 100644 index 00000000..b7178432 --- /dev/null +++ b/src/platform/gba/packer/packer.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/gba/packer/tracks/ad4.exe b/src/platform/gba/packer/tracks/ad4.exe new file mode 100644 index 00000000..fb0c3bfa Binary files /dev/null and b/src/platform/gba/packer/tracks/ad4.exe differ diff --git a/src/platform/gba/packer/tracks/convert.bat b/src/platform/gba/packer/tracks/convert.bat new file mode 100644 index 00000000..bf7669a4 --- /dev/null +++ b/src/platform/gba/packer/tracks/convert.bat @@ -0,0 +1,45 @@ +@echo off + +set IN_FOLDER=orig_mono\ +set OUT_FOLDER=conv\ +set DEMO_FOLDER=conv_demo\ + +for /r %IN_FOLDER% %%i in (*.wav) do ( + ffmpeg -v panic -y -i %%i -ar 10512 -f s16le -acodec pcm_s16le temp.raw + ad4 temp.raw %OUT_FOLDER%%%~ni.ad4 -0.5 +) +del /f temp.raw + +xcopy /Y %OUT_FOLDER%track_03.ad4 %DEMO_FOLDER%track_03.ad4* +xcopy /Y %OUT_FOLDER%track_04.ad4 %DEMO_FOLDER%track_04.ad4* +xcopy /Y %OUT_FOLDER%track_08.ad4 %DEMO_FOLDER%track_08.ad4* +xcopy /Y %OUT_FOLDER%track_09.ad4 %DEMO_FOLDER%track_09.ad4* +xcopy /Y %OUT_FOLDER%track_11.ad4 %DEMO_FOLDER%track_11.ad4* +xcopy /Y %OUT_FOLDER%track_12.ad4 %DEMO_FOLDER%track_12.ad4* +xcopy /Y %OUT_FOLDER%track_13.ad4 %DEMO_FOLDER%track_13.ad4* +xcopy /Y %OUT_FOLDER%track_16.ad4 %DEMO_FOLDER%track_16.ad4* +xcopy /Y %OUT_FOLDER%track_26_EN.ad4 %DEMO_FOLDER%track_26_EN.ad4* +xcopy /Y %OUT_FOLDER%track_27_EN.ad4 %DEMO_FOLDER%track_27_EN.ad4* +xcopy /Y %OUT_FOLDER%track_28_EN.ad4 %DEMO_FOLDER%track_28_EN.ad4* +xcopy /Y %OUT_FOLDER%track_29_EN.ad4 %DEMO_FOLDER%track_29_EN.ad4* +xcopy /Y %OUT_FOLDER%track_30_EN.ad4 %DEMO_FOLDER%track_30_EN.ad4* +xcopy /Y %OUT_FOLDER%track_31_EN.ad4 %DEMO_FOLDER%track_31_EN.ad4* +xcopy /Y %OUT_FOLDER%track_32_EN.ad4 %DEMO_FOLDER%track_32_EN.ad4* +xcopy /Y %OUT_FOLDER%track_33_EN.ad4 %DEMO_FOLDER%track_33_EN.ad4* +xcopy /Y %OUT_FOLDER%track_34_EN.ad4 %DEMO_FOLDER%track_34_EN.ad4* +xcopy /Y %OUT_FOLDER%track_35_EN.ad4 %DEMO_FOLDER%track_35_EN.ad4* +xcopy /Y %OUT_FOLDER%track_36_EN.ad4 %DEMO_FOLDER%track_36_EN.ad4* +xcopy /Y %OUT_FOLDER%track_37_EN.ad4 %DEMO_FOLDER%track_37_EN.ad4* +xcopy /Y %OUT_FOLDER%track_38_EN.ad4 %DEMO_FOLDER%track_38_EN.ad4* +xcopy /Y %OUT_FOLDER%track_39_EN.ad4 %DEMO_FOLDER%track_39_EN.ad4* +xcopy /Y %OUT_FOLDER%track_40_EN.ad4 %DEMO_FOLDER%track_40_EN.ad4* +xcopy /Y %OUT_FOLDER%track_41_EN.ad4 %DEMO_FOLDER%track_41_EN.ad4* +xcopy /Y %OUT_FOLDER%track_42_EN.ad4 %DEMO_FOLDER%track_42_EN.ad4* +xcopy /Y %OUT_FOLDER%track_43_EN.ad4 %DEMO_FOLDER%track_43_EN.ad4* +xcopy /Y %OUT_FOLDER%track_45_EN.ad4 %DEMO_FOLDER%track_45_EN.ad4* +xcopy /Y %OUT_FOLDER%track_47_EN.ad4 %DEMO_FOLDER%track_47_EN.ad4* +xcopy /Y %OUT_FOLDER%track_48_EN.ad4 %DEMO_FOLDER%track_48_EN.ad4* +xcopy /Y %OUT_FOLDER%track_49_EN.ad4 %DEMO_FOLDER%track_49_EN.ad4* +xcopy /Y %OUT_FOLDER%track_50_EN.ad4 %DEMO_FOLDER%track_50_EN.ad4* + +pause \ No newline at end of file diff --git a/src/platform/gba/packer/tracks/convertToMono.bat b/src/platform/gba/packer/tracks/convertToMono.bat new file mode 100644 index 00000000..a13e29d7 --- /dev/null +++ b/src/platform/gba/packer/tracks/convertToMono.bat @@ -0,0 +1,8 @@ +set IN_FOLDER=orig\ +set OUT_FOLDER=orig_mono\ + +for /r %IN_FOLDER% %%i in (*.ogg) do ( + ffmpeg -y -i %%i temp.wav + poly2mono temp.wav %OUT_FOLDER%%%~ni.wav -window:sine -blocksize:8192 -nhops:2 +) +del temp.wav diff --git a/src/platform/gba/packer/tracks/poly2mono.exe b/src/platform/gba/packer/tracks/poly2mono.exe new file mode 100644 index 00000000..2d633300 Binary files /dev/null and b/src/platform/gba/packer/tracks/poly2mono.exe differ diff --git a/src/platform/gba/rasterizer.h b/src/platform/gba/rasterizer.h new file mode 100644 index 00000000..d9f1c33c --- /dev/null +++ b/src/platform/gba/rasterizer.h @@ -0,0 +1,1064 @@ +#ifndef H_RASTERIZER_MODE4 +#define H_RASTERIZER_MODE4 + +#include "common.h" + +extern uint8 gLightmap[256 * 32]; +extern const uint8* gTile; + +#ifdef USE_ASM + extern "C" { + void rasterize_dummy(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeS_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeF_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + //void rasterizeG_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeFT_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeGT_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeFTA_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeGTA_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeLineH_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeLineV_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + void rasterizeFillS_asm(uint16* pixel, const VertexLink* L, const VertexLink* R); + } + + #define rasterizeS rasterizeS_asm + #define rasterizeF rasterizeF_asm + //#define rasterizeG rasterizeG_asm + #define rasterizeFT rasterizeFT_asm + #define rasterizeGT rasterizeGT_asm + #define rasterizeFTA rasterizeFTA_asm + #define rasterizeGTA rasterizeGTA_asm + #define rasterizeSprite rasterizeSprite_c + #define rasterizeLineH rasterizeLineH_asm + #define rasterizeLineV rasterizeLineV_asm + #define rasterizeFillS rasterizeFillS_asm +#else + #define rasterizeS rasterizeS_c + #define rasterizeF rasterizeF_c + //#define rasterizeG rasterizeG_c + #define rasterizeFT rasterizeFT_c + #define rasterizeGT rasterizeGT_c + #define rasterizeFTA rasterizeFTA_c + #define rasterizeGTA rasterizeGTA_c + #define rasterizeSprite rasterizeSprite_c + #define rasterizeLineH rasterizeLineH_c + #define rasterizeLineV rasterizeLineV_c + #define rasterizeFillS rasterizeFillS_c + +void rasterizeS_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[0x1A00]; + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile uint16* ptr = pixel + (x1 >> 1); + + if (x1 & 1) + { + uint16 p = ptr[0]; + + uint16 index = ft_lightmap[p >> 8]; + + ptr[0] = (p & 0x00FF) | (index << 8); + ptr++; + width--; + } + + if (width & 1) + { + uint16 p = ptr[width >> 1]; + + uint16 index = ft_lightmap[p & 0xFF]; + + ptr[width >> 1] = (p & 0xFF00) | index; + width--; + } + + while (width) + { + uint16 p = *ptr; + + uint16 index = ft_lightmap[p & 0xFF]; + index |= ft_lightmap[p >> 8] << 8; + + *ptr++ = index; + width -= 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + } + } +} + +void rasterizeF_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + uint32 color = (uint32)R; + color = gLightmap[(L->v.g << 8) | color]; + color |= (color << 8); + + int32 Lh = 0; + int32 Rh = 0; + int32 Ldx = 0; + int32 Rdx = 0; + int32 Rx; + int32 Lx; + + R = L; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + ASSERT(L->v.y >= 0); + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + + if (Lh > 1) + { + uint32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + ASSERT(R->v.y >= 0); + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + + if (Rh > 1) { + uint32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + ptr--; + *(uint16*)ptr = *ptr | (color << 8); + ptr += 2; + width--; + } + + if (width & 1) + { + *(uint16*)(ptr + width - 1) = (ptr[width] << 8) | (color >> 8); + } + + if (width & 2) + { + *(uint16*)ptr = color; + ptr += 2; + } + + width >>= 2; + while (width--) + { + *(uint16*)ptr = color; + ptr += 2; + *(uint16*)ptr = color; + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + } + } +} + +void rasterizeFT_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Ldx = 0, Rdx = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + uint32 tmp = FixedInvU(width); + + uint32 duv = Rt - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + uint32 dtdx = (du & 0xFFFF0000) | (dv >> 16); + + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + ptr--; + *(uint16*)ptr = *ptr | (ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]] << 8); + ptr += 2; + t += dtdx; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + *(uint16*)(ptr + width - 1) = (ptr[width] << 8) | ft_lightmap[gTile[(tmp & 0xFF00) | (tmp >> 24)]]; + } + + width >>= 1; + while (width--) + { + uint16 p; + + p = ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + p |= ft_lightmap[gTile[(t & 0xFF00) | (t >> 24)]] << 8; + t += dtdx; + + *(uint16*)ptr = p; + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeGT_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ +#ifdef ALIGNED_LIGHTMAP + ASSERT((intptr_t(gLightmap) & 0xFFFF) == 0); // lightmap should be 64k aligned +#endif + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Lg, Rg, Ldx = 0, Rdx = 0, Ldg = 0, Rdg = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + // 8-bit fractional part precision for Gouraud component + // has some artifacts but allow to save one reg for inner loop + // with aligned by 64k address of lightmap array + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lg = L->v.g; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + Ldg = tmp * (N->v.g - Lg) >> 8; + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + Lg <<= 8; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rg = R->v.g; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + Rdg = tmp * (N->v.g - Rg) >> 8; + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + Rg <<= 8; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + int32 tmp = FixedInvU(width); + + int32 dgdx = tmp * (Rg - Lg) >> 15; + + uint32 duv = Rt - Lt; + uint32 u = tmp * int16(duv >> 16); + uint32 v = tmp * int16(duv); + uint32 dtdx = (u & 0xFFFF0000) | (v >> 16); + + int32 g = Lg; + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + ptr--; + *(uint16*)ptr = *ptr | (gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]] << 8); + ptr += 2; + t += dtdx; + g += dgdx >> 1; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + *(uint16*)(ptr + width - 1) = (ptr[width] << 8) | gLightmap[(Rg >> 8 << 8) | gTile[(tmp & 0xFF00) | (tmp >> 24)]]; + } + + #ifdef ALIGNED_LIGHTMAP + g += intptr_t(gLightmap); + #endif + + width >>= 1; + + while (width--) + { + #ifdef ALIGNED_LIGHTMAP + const uint8* LMAP = (uint8*)(g >> 8 << 8); + + uint16 p = LMAP[gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + p |= LMAP[gTile[(t & 0xFF00) | (t >> 24)]] << 8; + t += dtdx; + g += dgdx; + #else + uint16 p = gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]]; + t += dtdx; + p |= gLightmap[(g >> 8 << 8) | gTile[(t & 0xFF00) | (t >> 24)]] << 8; + t += dtdx; + g += dgdx; + #endif + + *(uint16*)ptr = p; + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lg += Ldg; + Rg += Rdg; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeFTA_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Ldx = 0, Rdx = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + uint32 tmp = FixedInvU(width); + + uint32 duv = Rt - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + uint32 dtdx = (du & 0xFFFF0000) | (dv >> 16); + + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + uint8 p = gTile[(t & 0xFF00) | (t >> 24)]; + ptr--; + if (p) { + *(uint16*)ptr = *ptr | (ft_lightmap[p] << 8); + } + ptr += 2; + t += dtdx; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + uint8 p = gTile[(tmp & 0xFF00) | (tmp >> 24)]; + if (p) { + *(uint16*)(ptr + width - 1) = (ptr[width] << 8) | ft_lightmap[p]; + } + } + + width >>= 1; + while (width--) + { + uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + uint8 indexB = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + + if (indexA && indexB) { + *(uint16*)ptr = ft_lightmap[indexA] | (ft_lightmap[indexB] << 8); + }/* else if (indexA) { + *(uint16*)ptr = (*(uint16*)ptr & 0xFF00) | ft_lightmap[indexA]; + } else if (indexB) { + *(uint16*)ptr = (*(uint16*)ptr & 0x00FF) | (ft_lightmap[indexB] << 8); + }*/ + + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lt += Ldt; + Rt += Rdt; + } + } +} + +void rasterizeGTA_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ +#ifdef ALIGNED_LIGHTMAP + ASSERT((intptr_t(gLightmap) & 0xFFFF) == 0); // lightmap should be 64k aligned +#endif + + int32 Lh = 0, Rh = 0; + int32 Lx, Rx, Lg, Rg, Ldx = 0, Rdx = 0, Ldg = 0, Rdg = 0; + uint32 Lt, Rt, Ldt, Rdt; + Ldt = 0; + Rdt = 0; + + // 8-bit fractional part precision for Gouraud component + // has some artifacts but allow to save one reg for inner loop + // with aligned by 64k address of lightmap array + + while (1) + { + while (!Lh) + { + const VertexLink* N = L + L->prev; + + if (N->v.y < L->v.y) return; + + Lh = N->v.y - L->v.y; + Lx = L->v.x; + Lg = L->v.g; + Lt = L->t.t; + + if (Lh > 1) + { + int32 tmp = FixedInvU(Lh); + Ldx = tmp * (N->v.x - Lx); + Ldg = tmp * (N->v.g - Lg) >> 8; + + uint32 duv = N->t.t - Lt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Ldt = (du & 0xFFFF0000) | (dv >> 16); + } + + Lx <<= 16; + Lg <<= 8; + L = N; + } + + while (!Rh) + { + const VertexLink* N = R + R->next; + + if (N->v.y < R->v.y) return; + + Rh = N->v.y - R->v.y; + Rx = R->v.x; + Rg = R->v.g; + Rt = R->t.t; + + if (Rh > 1) + { + int32 tmp = FixedInvU(Rh); + Rdx = tmp * (N->v.x - Rx); + Rdg = tmp * (N->v.g - Rg) >> 8; + + uint32 duv = N->t.t - Rt; + uint32 du = tmp * int16(duv >> 16); + uint32 dv = tmp * int16(duv); + Rdt = (du & 0xFFFF0000) | (dv >> 16); + } + + Rx <<= 16; + Rg <<= 8; + R = N; + } + + int32 h = X_MIN(Lh, Rh); + Lh -= h; + Rh -= h; + + while (h--) + { + int32 x1 = Lx >> 16; + int32 x2 = Rx >> 16; + + int32 width = x2 - x1; + + if (width > 0) + { + int32 tmp = FixedInvU(width); + + int32 dgdx = tmp * (Rg - Lg) >> 15; + + uint32 duv = Rt - Lt; + uint32 u = tmp * int16(duv >> 16); + uint32 v = tmp * int16(duv); + uint32 dtdx = (u & 0xFFFF0000) | (v >> 16); + + int32 g = Lg; + uint32 t = Lt; + + volatile uint8* ptr = (uint8*)pixel + x1; + + if (intptr_t(ptr) & 1) + { + ptr--; + + uint8 indexB = gTile[(t & 0xFF00) | (t >> 24)]; + + if (indexB) { + *(uint16*)ptr = *ptr | (gLightmap[(g >> 8 << 8) | indexB] << 8); + } + + ptr += 2; + t += dtdx; + g += dgdx >> 1; + width--; + } + + if (width & 1) + { + uint32 tmp = Rt - dtdx; + + uint8 indexA = gTile[(tmp & 0xFF00) | (tmp >> 24)]; + + if (indexA) { + *(uint16*)(ptr + width - 1) = (ptr[width] << 8) | gLightmap[(Rg >> 8 << 8) | indexA]; + } + } + + #ifdef ALIGNED_LIGHTMAP + g += intptr_t(gLightmap); + #endif + + width >>= 1; + + while (width--) + { + #ifdef ALIGNED_LIGHTMAP + uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + uint8 indexB = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + g += dgdx; + + + if (indexA && indexB) { + const uint8* LMAP = (uint8*)(g >> 8 << 8); + *(uint16*)ptr = LMAP[indexA] | (LMAP[indexB] << 8); + } + #else + uint8 indexA = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + uint8 indexB = gTile[(t & 0xFF00) | (t >> 24)]; + t += dtdx; + g += dgdx; + + if (indexA && indexB) { + *(uint16*)ptr = gLightmap[(g >> 8 << 8) | indexA] | (gLightmap[(g >> 8 << 8) | indexB] << 8); + } + #endif + + ptr += 2; + } + } + + pixel += (FRAME_WIDTH >> 1); + + Lx += Ldx; + Rx += Rdx; + Lg += Ldg; + Rg += Rdg; + Lt += Ldt; + Rt += Rdt; + } + } +} + +X_NOINLINE void rasterizeLineH_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + R++; + int32 x = L->v.x; + int32 index = L->v.g; + int32 width = R->v.x; + + volatile uint8* ptr = (uint8*)pixel + x; + + if (intptr_t(ptr) & 1) + { + ptr--; + *(uint16*)ptr = *ptr | (index << 8); + ptr += 2; + width--; + } + + if (width & 1) + { + *(uint16*)(ptr + width - 1) = index | (ptr[width] << 8); + } + + for (int32 i = 0; i < width / 2; i++) + { + *(uint16*)ptr = index | (index << 8); + ptr += 2; + } +} + +X_NOINLINE void rasterizeLineV_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + R++; + int32 x = L->v.x; + int32 index = L->v.g; + int32 height = R->v.y; + + volatile uint8* ptr = (uint8*)pixel + x; + + for (int32 i = 0; i < height; i++) + { + if (intptr_t(ptr) & 1) { + *(uint16*)(ptr - 1) = *(ptr - 1) | (index << 8); + } else { + *(uint16*)ptr = index | (*ptr << 8); + } + ptr += FRAME_WIDTH; + } +} + +X_NOINLINE void rasterizeFillS_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + R++; + int32 x = L->v.x; + int32 shade = L->v.g; + int32 width = R->v.x; + int32 height = R->v.y; + + const uint8* lm = &gLightmap[shade << 8]; + + for (int32 i = 0; i < height; i++) + { + volatile uint8* ptr = (uint8*)pixel + x; + int32 w = width; + + if (intptr_t(ptr) & 1) + { + ptr--; + *(uint16*)ptr = ptr[0] | (lm[ptr[1]] << 8); + ptr += 2; + w--; + } + + if (w & 1) + { + *(uint16*)(ptr + w - 1) = lm[ptr[w - 1]] | (ptr[w] << 8); + } + + for (int32 i = 0; i < w / 2; i++) + { + uint16 p = *(uint16*)ptr; + *(uint16*)ptr = lm[p & 0xFF] | (lm[p >> 8] << 8); + ptr += 2; + } + + pixel += FRAME_WIDTH / 2; + } +} +#endif + +// TODO ARM version +extern "C" X_NOINLINE void rasterizeSprite_c(uint16* pixel, const VertexLink* L, const VertexLink* R) +{ + R++; + const uint8* ft_lightmap = &gLightmap[L->v.g << 8]; + + int32 w = R->v.x - L->v.x; + if (w <= 0 || w >= DIV_TABLE_SIZE) return; + + int32 h = R->v.y - L->v.y; + if (h <= 0 || h >= DIV_TABLE_SIZE) return; + + int32 u = L->t.uv.u; + int32 v = L->t.uv.v; + + int32 iw = FixedInvU(w); + int32 ih = FixedInvU(h); + + int32 du = R->t.uv.u * iw >> 8; + int32 dv = R->t.uv.v * ih >> 8; + + if (L->v.y < 0) + { + pixel -= L->v.y * (FRAME_WIDTH >> 1); + v -= L->v.y * dv; + h += L->v.y; + } + + if (R->v.y > FRAME_HEIGHT) + { + h -= R->v.y - FRAME_HEIGHT; + } + + uint8* ptr = (uint8*)pixel; + + if (h <= 0) return; + + ptr += L->v.x; + + if (L->v.x < 0) + { + ptr -= L->v.x; + u -= L->v.x * du; + w += L->v.x; + } + + if (R->v.x > FRAME_WIDTH) + { + w -= R->v.x - FRAME_WIDTH; + } + + if (w <= 0) return; + + bool alignL = intptr_t(ptr) & 1; + if (alignL) + { + ptr--; + w--; + } + + bool alignR = w & 1; + + w >>= 1; + + for (int32 y = 0; y < h; y++) + { + const uint8* xtile = gTile + (v & 0xFF00); + + volatile uint8* xptr = ptr; + + int32 xu = u; + + if (alignL) + { + uint8 indexB = xtile[xu >> 8]; + if (indexB) { + *(uint16*)xptr = *xptr | (ft_lightmap[indexB] << 8); + } + + xptr += 2; + xu += du; + } + + for (int32 x = 0; x < w; x++) + { + uint8 indexA = xtile[xu >> 8]; + xu += du; + uint8 indexB = xtile[xu >> 8]; + xu += du; + + if (indexA | indexB) + { + indexA = (indexA) ? ft_lightmap[indexA] : xptr[0]; + indexB = (indexB) ? ft_lightmap[indexB] : xptr[1]; + *(uint16*)xptr = indexA | (indexB << 8); + } + + xptr += 2; + } + + if (alignR) + { + uint8 indexA = xtile[xu >> 8]; + if (indexA) { + *(uint16*)xptr = ft_lightmap[indexA] | (xptr[1] << 8); + } + } + + v += dv; + + ptr += FRAME_WIDTH; + } +} + +#endif diff --git a/src/platform/gba/render.iwram.cpp b/src/platform/gba/render.iwram.cpp new file mode 100644 index 00000000..87854d5e --- /dev/null +++ b/src/platform/gba/render.iwram.cpp @@ -0,0 +1,1199 @@ +#include "common.h" + +struct Vertex +{ + int16 x; + int16 y; + int16 z; + uint8 g; + uint8 clip; +}; + +struct VertexLink +{ + Vertex v; + TexCoord t; + int8 prev; + int8 next; + uint16 padding; +}; + +struct ViewportRel { + int32 minXY; + int32 maxXY; +}; + +ViewportRel viewportRel; + +#if defined(__GBA_WIN__) + uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#elif defined(__GBA__) + uint32 fb = MEM_VRAM; +#elif defined(__TNS__) + uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#elif defined(__DOS__) + uint16 fb[FRAME_WIDTH * FRAME_HEIGHT]; +#endif + +enum FaceType { + FACE_TYPE_SHADOW, + FACE_TYPE_F, + FACE_TYPE_FT, + FACE_TYPE_FTA, + FACE_TYPE_GT, + FACE_TYPE_GTA, + FACE_TYPE_SPRITE, + FACE_TYPE_FILL_S, + FACE_TYPE_LINE_H, + FACE_TYPE_LINE_V, + FACE_TYPE_MAX +}; + +#define FACE_TRIANGLE (1 << 19) +#define FACE_CLIPPED (1 << 18) +#define FACE_TYPE_SHIFT 14 +#define FACE_TYPE_MASK 15 +#define FACE_GOURAUD (2 << FACE_TYPE_SHIFT) +#define FACE_TEXTURE 0x3FFF + +#include "rasterizer.h" + +extern Level level; + +const uint8* gTile; + +EWRAM_DATA uint8 gBackgroundCopy[FRAME_WIDTH * FRAME_HEIGHT]; // EWRAM 37.5k +EWRAM_DATA ALIGN8 Vertex gVertices[MAX_VERTICES]; // EWRAM 16k +EWRAM_DATA Face gFaces[MAX_FACES]; // EWRAM 30k +Face* gOT[OT_SIZE]; // IWRAM 2.5k + +Vertex* gVerticesBase = gVertices; +Face* gFacesBase = gFaces; + +#if defined(USE_VRAM_MESH) || defined(USE_VRAM_ROOM) +uint8* vramPtr; +#endif + +enum ClipFlags { + CLIP_LEFT = 1 << 0, + CLIP_RIGHT = 1 << 1, + CLIP_TOP = 1 << 2, + CLIP_BOTTOM = 1 << 3, + CLIP_PLANE = 1 << 4, + CLIP_FRAME = 1 << 5, + CLIP_DISCARD = (CLIP_LEFT | CLIP_RIGHT | CLIP_TOP | CLIP_BOTTOM | CLIP_PLANE), +}; + +const MeshQuad gShadowQuads[] = { + { {0, 1, 1, 5}, (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT) }, // abs idx {0, 1, 2, 7} + { {0,-5, 1, 3}, (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT) }, // abs idx {7, 2, 3, 6} + { {0,-3, 1, 1}, (FACE_TYPE_SHADOW << FACE_TYPE_SHIFT) } // abs idx {6, 3, 4, 5} +}; + +void setViewport(const RectMinMax &vp) +{ + viewport = vp; + + int32 minX = vp.x0 - (FRAME_WIDTH >> 1); + int32 minY = vp.y0 - (FRAME_HEIGHT >> 1); + int32 maxX = vp.x1 - (FRAME_WIDTH >> 1); + int32 maxY = vp.y1 - (FRAME_HEIGHT >> 1); + + viewportRel.minXY = (minX << 16) | (minY & 0xFFFF); + viewportRel.maxXY = (maxX << 16) | (maxY & 0xFFFF); +} + +void setPaletteIndex(int32 index) +{ + // TODO +} + +X_INLINE Face* faceAdd(int32 depth) +{ + ASSERT(depth >= 0 && depth < OT_SIZE); + + Face* face = gFacesBase++; + face->next = gOT[depth]; + gOT[depth] = face; + + return face; +} + +extern "C" { + X_NOINLINE void drawPoly(uint32 flags, VertexLink* v); +} + +#ifdef USE_ASM + #define transformRoom transformRoom_asm + #define transformRoomUW transformRoomUW_asm + #define transformMesh transformMesh_asm + #define faceAddRoomQuads faceAddRoomQuads_asm + #define faceAddRoomTriangles faceAddRoomTriangles_asm + #define faceAddMeshQuads faceAddMeshQuads_asm + #define faceAddMeshTriangles faceAddMeshTriangles_asm + #define rasterize rasterize_asm + #define clearFB clearFB_asm + + extern "C" { + void transformRoom_asm(const RoomVertex* vertices, int32 count); + void transformRoomUW_asm(const RoomVertex* vertices, int32 count); + void transformMesh_asm(const MeshVertex* vertices, int32 count, int32 intensity); + void faceAddRoomQuads_asm(const RoomQuad* polys, int32 count); + void faceAddRoomTriangles_asm(const RoomTriangle* polys, int32 count); + void faceAddMeshQuads_asm(const MeshQuad* polys, int32 count); + void faceAddMeshTriangles_asm(const MeshTriangle* polys, int32 count); + void rasterize_asm(uint32 flags, VertexLink* top); + void clearFB_asm(void* fb); + } +#else + #define transformRoom transformRoom_c + #define transformRoomUW transformRoomUW_c + #define transformMesh transformMesh_c + #define faceAddRoomQuads faceAddRoomQuads_c + #define faceAddRoomTriangles faceAddRoomTriangles_c + #define faceAddMeshQuads faceAddMeshQuads_c + #define faceAddMeshTriangles faceAddMeshTriangles_c + #define rasterize rasterize_c + #define clearFB(fb) dmaFill(fb, 0, FRAME_WIDTH * FRAME_HEIGHT) + +X_INLINE bool checkBackface(const Vertex* a, const Vertex* b, const Vertex* c) +{ + return (b->x - a->x) * (c->y - a->y) <= (c->x - a->x) * (b->y - a->y); +} + +void transformRoom_c(const RoomVertex* vertices, int32 count) +{ + Vertex* res = gVerticesBase; + + for (int32 i = 0; i < count; i++, res++) + { + uint32 value = *(uint32*)(vertices++); + + int32 vx = (value & (0xFF)) << 8; + int32 vy = (value & (0xFF << 8)); + int32 vz = (value & (0xFF << 16)) >> 8; + int32 vg = (value & (0xFF << 24)) >> (24 + 3); + + const Matrix &m = matrixGet(); + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, vx, vy, vz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, vx, vy, vz); + + uint32 clip = 0; + + if (z <= VIEW_MIN_F) { + clip = CLIP_PLANE; + z = VIEW_MIN_F; + } + + if (z >= VIEW_MAX_F) { + clip = CLIP_PLANE; + z = VIEW_MAX_F; + } + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + int32 fog = z - FOG_MIN; + if (fog > 0) + { + vg += fog >> (FOG_SHIFT + 3); + if (vg > 31) + { + vg = 31; + } + } + + PERSPECTIVE(x, y, z); + + // use this in case of overflow + //x = X_CLAMP(x, -512, 512); + //y = X_CLAMP(y, -512, 512); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + if (x < viewport.x0) clip |= CLIP_LEFT; + if (x > viewport.x1) clip |= CLIP_RIGHT; + if (y < viewport.y0) clip |= CLIP_TOP; + if (y > viewport.y1) clip |= CLIP_BOTTOM; + + res->x = x; + res->y = y; + res->z = z; + res->g = vg >> 8; + res->clip = clip; + } +} + +void transformRoomUW_c(const RoomVertex* vertices, int32 count) +{ + Vertex* res = gVerticesBase; + + for (int32 i = 0; i < count; i++, res++) + { + uint32 value = *(uint32*)(vertices++); + + int32 vx = (value & (0xFF)) << 8; + int32 vy = (value & (0xFF << 8)); + int32 vz = (value & (0xFF << 16)) >> 8; + int32 vg = (value & (0xFF << 24)) >> (24 - 5); + + const Matrix &m = matrixGet(); + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, vx, vy, vz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, vx, vy, vz); + + uint32 clip = 0; + + if (z <= VIEW_MIN_F) { + clip = CLIP_PLANE; + z = VIEW_MIN_F; + } + + if (z >= VIEW_MAX_F) { + clip = CLIP_PLANE; + z = VIEW_MAX_F; + } + + int32 causticsValue = gCaustics[(gRandTable[i & (MAX_RAND_TABLE - 1)] + gCausticsFrame) & (MAX_CAUSTICS - 1)]; + vg = X_CLAMP(vg + causticsValue, 0, 8191); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + if (z > FOG_MIN) + { + vg += (z - FOG_MIN) << FOG_SHIFT; + if (vg > 8191) { + vg = 8191; + } + } + + PERSPECTIVE(x, y, z); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + if (x < viewport.x0) clip |= CLIP_LEFT; + if (x > viewport.x1) clip |= CLIP_RIGHT; + if (y < viewport.y0) clip |= CLIP_TOP; + if (y > viewport.y1) clip |= CLIP_BOTTOM; + + res->x = x; + res->y = y; + res->z = z; + res->g = vg >> 8; + res->clip = clip; + } +} + +void transformMesh_c(const MeshVertex* vertices, int32 count, int32 intensity) +{ + Vertex* res = gVerticesBase; + + int32 vg = X_CLAMP((intensity + gLightAmbient) >> 8, 0, 31); + + for (int32 i = 0; i < count; i++, res++) + { + int32 vx = vertices->x << 2; + int32 vy = vertices->y << 2; + int32 vz = vertices->z << 2; + vertices++; + + const Matrix &m = matrixGet(); + int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz); + int32 y = DP43(m.e10, m.e11, m.e12, m.e13, vx, vy, vz); + int32 z = DP43(m.e20, m.e21, m.e22, m.e23, vx, vy, vz); + + uint32 clip = 0; + + if (z <= VIEW_MIN_F) { + clip = CLIP_PLANE; + z = VIEW_MIN_F; + } + + if (z >= VIEW_MAX_F) { + clip = CLIP_PLANE; + z = VIEW_MAX_F; + } + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + PERSPECTIVE(x, y, z); + + x += (FRAME_WIDTH >> 1); + y += (FRAME_HEIGHT >> 1); + + if ((x < 0 || x > FRAME_WIDTH) || (y < 0 || y > FRAME_HEIGHT)) { + clip |= CLIP_FRAME; + } + + res->x = x; + res->y = y; + res->z = z; + res->g = vg; + res->clip = clip; + } +} + +void faceAddRoomQuads_c(const RoomQuad* polys, int32 count) +{ + const Vertex* v0; + const Vertex* v1; + const Vertex* v2; + const Vertex* v3 = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + v0 = v3 + polys->indices[0]; + v1 = v0 + polys->indices[1]; + v2 = v1 + polys->indices[2]; + v3 = v2 + polys->indices[3]; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + uint32 c3 = v3->clip; + + if (c0 & c1 & c2 & c3 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2 | c3) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + uint32 g0 = v0->g; + uint32 g1 = v1->g; + uint32 g2 = v2->g; + uint32 g3 = v3->g; + + if (g0 != g1 || g0 != g2 || g0 != g3) { + flags += FACE_GOURAUD; + } + + if (checkBackface(v0, v1, v2)) + continue; + + int32 depth = X_MAX(v0->z, X_MAX(v1->z, X_MAX(v2->z, v3->z))) >> OT_SHIFT; + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + f->indices[3] = v3 - gVertices; + } +} + +void faceAddRoomTriangles_c(const RoomTriangle* polys, int32 count) +{ + const Vertex* v = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + uint32 flags = polys->flags; + const Vertex* v0 = v + polys->indices[0]; + const Vertex* v1 = v + polys->indices[1]; + const Vertex* v2 = v + polys->indices[2]; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + + if (c0 & c1 & c2 & CLIP_DISCARD) + continue; + + if ((c0 | c1 | c2) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + uint32 g0 = v0->g; + uint32 g1 = v1->g; + uint32 g2 = v2->g; + + if (g0 != g1 || g0 != g2) { + flags += FACE_GOURAUD; + } + flags |= FACE_TRIANGLE; + + if (checkBackface(v0, v1, v2)) + continue; + + int32 depth = X_MAX(v0->z, X_MAX(v1->z, v2->z)) >> OT_SHIFT; + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + } +} + +void faceAddMeshQuads_c(const MeshQuad* polys, int32 count) +{ + const Vertex* v0; + const Vertex* v1; + const Vertex* v2; + const Vertex* v3 = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + v0 = v3 + polys->indices[0]; + v1 = v0 + polys->indices[1]; + v2 = v1 + polys->indices[2]; + v3 = v2 + polys->indices[3]; + + if (checkBackface(v0, v1, v2)) + continue; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + uint32 c3 = v3->clip; + + if (c0 & c1 & c2 & c3 & CLIP_DISCARD) + continue; + + uint32 flags = polys->flags; + if ((c0 | c1 | c2 | c3) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + + int32 depth = (v0->z + v1->z + v2->z + v3->z) >> (2 + OT_SHIFT); + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + f->indices[3] = v3 - gVertices; + } +} + +void faceAddMeshTriangles_c(const MeshTriangle* polys, int32 count) +{ + const Vertex* v0; + const Vertex* v1; + const Vertex* v2 = gVerticesBase; + + for (int32 i = 0; i < count; i++, polys++) + { + v0 = v2 + polys->indices[0]; + v1 = v0 + polys->indices[1]; + v2 = v1 + polys->indices[3]; + + if (checkBackface(v0, v1, v2)) + continue; + + uint32 c0 = v0->clip; + uint32 c1 = v1->clip; + uint32 c2 = v2->clip; + + if (c0 & c1 & c2 & CLIP_DISCARD) + continue; + + uint32 flags = polys->flags; + if ((c0 | c1 | c2) & CLIP_FRAME) { + flags |= FACE_CLIPPED; + } + flags |= FACE_TRIANGLE; + + int32 depth = (v0->z + v1->z + v2->z + v2->z) >> (2 + OT_SHIFT); + + Face* f = faceAdd(depth); + f->flags = flags; + f->indices[0] = v0 - gVertices; + f->indices[1] = v1 - gVertices; + f->indices[2] = v2 - gVertices; + } +} + +int32 sphereIsVisible_c(int32 sx, int32 sy, int32 sz, int32 r) +{ + Matrix &m = matrixGet(); + + if (abs(sx) < r && abs(sy) < r && abs(sz) < r) + return 1; + + int32 z = DP33(m.e20, m.e21, m.e22, sx, sy, sz); + + if (z < 0) + return 0; + + int32 x = DP33(m.e00, m.e01, m.e02, sx, sy, sz); + int32 y = DP33(m.e10, m.e11, m.e12, sx, sy, sz); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + z = PERSPECTIVE_DZ(z); + if (z >= DIV_TABLE_SIZE) z = DIV_TABLE_SIZE - 1; + int32 d = FixedInvU(z); + x = (x * d) >> 12; + y = (y * d) >> 12; + r = (r * d) >> 12; + + x += (FRAME_WIDTH / 2); + y += (FRAME_HEIGHT / 2); + + int32 rMinX = x - r; + int32 rMinY = y - r; + int32 rMaxX = x + r; + int32 rMaxY = y + r; + + if (rMinX > viewport.x1 || + rMaxX < viewport.x0 || + rMinY > viewport.y1 || + rMaxY < viewport.y0) return 0; // not visible + + return 1; +} + +typedef void (*RasterProc)(uint16* pixel, const VertexLink* L, const VertexLink* R); + +RasterProc gRasterProc[FACE_TYPE_MAX] = { // IWRAM + rasterizeS, + rasterizeF, + rasterizeFT, + rasterizeFTA, + rasterizeGT, + rasterizeGTA, + rasterizeSprite, + rasterizeFillS, + rasterizeLineH, + rasterizeLineV +}; + +X_NOINLINE void rasterize_c(uint32 flags, VertexLink* top) +{ + uint8* pixel = (uint8*)fb + top->v.y * FRAME_WIDTH; + + uint32 type = (flags >> FACE_TYPE_SHIFT) & FACE_TYPE_MASK; + + VertexLink* R = (type == FACE_TYPE_F) ? (VertexLink*)(flags & 0xFF) : top; + + gRasterProc[type]((uint16*)pixel, top, R); +} + +void flush_c() +{ +#ifdef PROFILING + #if !defined(PROFILE_FRAMETIME) && !defined(PROFILE_SOUNDTIME) + gCounters[CNT_VERT] += gVerticesBase - gVertices; + gCounters[CNT_POLY] += gFacesBase - gFaces; + #endif +#endif + + gVerticesBase = gVertices; + + if (gFacesBase == gFaces) + return; + + gFacesBase = gFaces; + + VertexLink v[8]; + VertexLink* q = v; + VertexLink* t = v + 4; + // quad + q[0].prev = 3; + q[0].next = 1; + q[1].prev = -1; + q[1].next = 1; + q[2].prev = -1; + q[2].next = 1; + q[3].prev = -1; + q[3].next = -3; + // triangle + t[0].prev = 2; + t[0].next = 1; + t[1].prev = -1; + t[1].next = 1; + t[2].prev = -1; + t[2].next = -2; + // t[3] dummy + + PROFILE(CNT_FLUSH); + + for (int32 i = OT_SIZE - 1; i >= 0; i--) + { + if (!gOT[i]) continue; + + Face *face = gOT[i]; + gOT[i] = NULL; + + do { + uint32 flags = face->flags; + + uint32 type = (flags >> FACE_TYPE_SHIFT) & FACE_TYPE_MASK; + + if (type <= FACE_TYPE_GTA) + { + VertexLink* ptr = (flags & FACE_TRIANGLE) ? t : q; + + if (type > FACE_TYPE_F) + { + const Texture &tex = level.textures[flags & FACE_TEXTURE]; + gTile = (uint8*)tex.tile; + + ptr[0].t.t = 0xFF00FF00 & (tex.uv01); + ptr[1].t.t = 0xFF00FF00 & (tex.uv01 << 8); + ptr[2].t.t = 0xFF00FF00 & (tex.uv23); + ptr[3].t.t = 0xFF00FF00 & (tex.uv23 << 8); + } + + ptr[0].v = gVertices[face->indices[0]]; + ptr[1].v = gVertices[face->indices[1]]; + ptr[2].v = gVertices[face->indices[2]]; + if (!(flags & FACE_TRIANGLE)) { + ptr[3].v = gVertices[face->indices[3]]; + } + + if (flags & FACE_CLIPPED) { + drawPoly(flags, ptr); + } else { + // get top vertex for tri or quad + VertexLink* top = ptr; + if (top->v.y > ptr[1].v.y) top = ptr + 1; + if (top->v.y > ptr[2].v.y) top = ptr + 2; + if (!(flags & FACE_TRIANGLE)) + { + if (top->v.y > v[3].v.y) top = ptr + 3; + } + rasterize(flags, top); + } + } + else + { + const Vertex *vert = gVertices + face->indices[0]; + v[0].v = vert[0]; + v[1].v = vert[1]; + + if (type == FACE_TYPE_SPRITE) + { + const Sprite &sprite = level.sprites[flags & FACE_TEXTURE]; + gTile = (uint8*)sprite.tile; + v[0].t.t = (sprite.uwvh) & (0xFF00FF00); + v[1].t.t = (sprite.uwvh) & (0xFF00FF00 >> 8); + } + + rasterize(flags, v); + } + + face = face->next; + + } while (face); + } +} +#endif + +extern "C" X_NOINLINE void drawPoly(uint32 flags, VertexLink* v) +{ + #define LERP_SHIFT 6 + #define LERP(a,b,t) (b + ((a - b) * t >> LERP_SHIFT)) + //#define LERP2(a,b,ta,tb) LERP(a,b,t) + #define LERP2(a,b,ta,tb) (b + (((a - b) * ta / tb) >> LERP_SHIFT) ) // less gaps between clipped polys, but slow // @DIV + + #define CLIP_AXIS(X, Y, edge, output) {\ + int32 ta = (edge - b->v.X) << LERP_SHIFT;\ + int32 tb = (a->v.X - b->v.X);\ + ASSERT(tb != 0);\ + int32 t = ta / tb;\ + ASSERT(count < 8);\ + VertexLink* p = output + count++;\ + p->v.X = edge;\ + p->v.Y = LERP2(a->v.Y, b->v.Y, ta, tb);\ + p->v.g = LERP(a->v.g, b->v.g, t);\ + p->t.uv.u = LERP(a->t.uv.u, b->t.uv.u, t);\ + p->t.uv.v = LERP(a->t.uv.v, b->t.uv.v, t);\ + } + + #define CLIP_XY(X, Y, X0, X1, input, output) {\ + const VertexLink *a, *b = input + pCount - 1;\ + for (int32 i = 0; i < pCount; i++) {\ + a = b;\ + b = input + i;\ + if (a->v.X < X0) {\ + if (b->v.X < X0) continue;\ + CLIP_AXIS(X, Y, X0, output);\ + } else if (a->v.X > X1) {\ + if (b->v.X > X1) continue;\ + CLIP_AXIS(X, Y, X1, output);\ + }\ + if (b->v.X < X0) {\ + CLIP_AXIS(X, Y, X0, output);\ + } else if (b->v.X > X1) {\ + CLIP_AXIS(X, Y, X1, output);\ + } else {\ + ASSERT(count < 8);\ + output[count++] = *b;\ + }\ + }\ + if (count < 3) return;\ + } + + VertexLink tmp[8]; + VertexLink out[8]; + + int32 pCount = (flags & FACE_TRIANGLE) ? 3 : 4; + int32 count = 0; + + // clip x + CLIP_XY(x, y, 0, FRAME_WIDTH, v, tmp); + + pCount = count; + count = 0; + + // clip y + CLIP_XY(y, x, 0, FRAME_HEIGHT, tmp, out); + + VertexLink* first = out; + VertexLink* last = out + count - 1; + + bool skip = (first->v.y == last->v.y); + + VertexLink* top = (first->v.y < last->v.y) ? first : last; + first->prev = count - 1; + first->next = 1; + last->prev = -1; + last->next = 1 - count; + + for (int32 i = 1; i < count - 1; i++) + { + VertexLink* p = out + i; + + if (p->v.y != top->v.y) + { + if (p->v.y < top->v.y) + { + top = p; + } + skip = false; + } + + p->prev = -1; + p->next = 1; + } + + if (skip) + return; + + rasterize(flags, top); +} + +void faceAddRoom(const Room* room) +{ + if (room->info->quadsCount > 0) { + faceAddRoomQuads(room->data.quads, room->info->quadsCount); + } + + if (room->info->trianglesCount > 0) { + faceAddRoomTriangles(room->data.triangles, room->info->trianglesCount); + } +} + +void faceAddMesh(const MeshQuad* quads, const MeshTriangle* triangles, int32 qCount, int32 tCount) +{ + if (qCount > 0) { + faceAddMeshQuads(quads, qCount); + } + + if (tCount > 0) { + faceAddMeshTriangles(triangles, tCount); + } +} + +void clear() +{ + clearFB((void*)fb); +} + +void renderRoom(Room* room) +{ + int32 vCount = room->info->verticesCount; + if (vCount <= 0) + return; + + if ((gVerticesBase - gVertices) + vCount > MAX_VERTICES) + { + ASSERT(false); + return; + } + +#ifdef USE_VRAM_ROOM + if (playersExtra[0].camera.view.room == room && !((uint32)room->data.vertices & 0x06000000)) + { + memcpy(vramPtr, room->data.quads, room->info->quadsCount * sizeof(RoomQuad)); + room->data.quads = (RoomQuad*)vramPtr; + vramPtr += room->info->quadsCount * sizeof(RoomQuad); + + if ((uint32)vramPtr & 3) vramPtr += 2; + + memcpy(vramPtr, room->data.triangles, room->info->trianglesCount * sizeof(RoomTriangle)); + room->data.triangles = (RoomTriangle*)vramPtr; + vramPtr += room->info->trianglesCount * sizeof(RoomTriangle); + + if ((uint32)vramPtr & 3) vramPtr += 2; + + memcpy(vramPtr, room->data.vertices, room->info->verticesCount * sizeof(RoomVertex)); + room->data.vertices = (RoomVertex*)vramPtr; + vramPtr += room->info->verticesCount * sizeof(RoomVertex); + } +#endif + + { + PROFILE(CNT_TRANSFORM); + if (ROOM_FLAG_WATER(room->info->flags)) { + transformRoomUW(room->data.vertices, vCount); + } else { + transformRoom(room->data.vertices, vCount); + } + } + + { + PROFILE(CNT_ADD); + faceAddRoom(room); + } + + gVerticesBase += vCount; +} + +void renderMesh(const Mesh* mesh) +{ + int32 vCount = mesh->vCount; + if (vCount <= 0) + return; + + if ((gVerticesBase - gVertices) + vCount > MAX_VERTICES) + { + ASSERT(false); + return; + } + + int32 fCount = mesh->rCount + mesh->tCount; + if ((gFacesBase - gFaces) + fCount > MAX_FACES) + { + ASSERT(false); + return; + } + + const uint8* ptr = (uint8*)mesh + sizeof(Mesh); + + MeshQuad* quads = (MeshQuad*)ptr; + ptr += mesh->rCount * sizeof(MeshQuad); + + MeshTriangle* triangles = (MeshTriangle*)ptr; + ptr += mesh->tCount * sizeof(MeshTriangle); + + const MeshVertex* vertices = (MeshVertex*)ptr; + + { + PROFILE(CNT_TRANSFORM); + transformMesh(vertices, vCount, mesh->intensity); + } + + { + PROFILE(CNT_ADD); + faceAddMesh(quads, triangles, mesh->rCount, mesh->tCount); + } + + gVerticesBase += vCount; +} + +void renderShadow(int32 x, int32 z, int32 sx, int32 sz) +{ + if (gVerticesBase - gVertices + 8 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 3 > MAX_FACES) { + ASSERT(false); + return; + } + + x >>= MESH_SHIFT; + z >>= MESH_SHIFT; + sx >>= MESH_SHIFT; + sz >>= MESH_SHIFT; + + int16 xns1 = x - sx; + int16 xps1 = x + sx; + int16 xns2 = xns1 - sx; + int16 xps2 = xps1 + sx; + + int16 zns1 = z - sz; + int16 zps1 = z + sz; + int16 zns2 = zns1 - sz; + int16 zps2 = zps1 + sz; + + MeshVertex v[8]; + v[0].x = xns1; v[0].y = 0; v[0].z = zps2; + v[1].x = xps1; v[1].y = 0; v[1].z = zps2; + v[2].x = xps2; v[2].y = 0; v[2].z = zps1; + v[3].x = xps2; v[3].y = 0; v[3].z = zns1; + v[4].x = xps1; v[4].y = 0; v[4].z = zns2; + v[5].x = xns1; v[5].y = 0; v[5].z = zns2; + v[6].x = xns2; v[6].y = 0; v[6].z = zns1; + v[7].x = xns2; v[7].y = 0; v[7].z = zps1; + + transformMesh(v, 8, 0); + faceAddMeshQuads(gShadowQuads, 3); + + gVerticesBase += 8; +} + +X_NOINLINE void renderFill(int32 x, int32 y, int32 width, int32 height, int32 shade, int32 z) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + gVerticesBase[0].x = x; + gVerticesBase[0].y = y; + gVerticesBase[0].g = shade; + + gVerticesBase[1].x = width; + gVerticesBase[1].y = height; + + Face* f = faceAdd(z); + f->flags = (FACE_TYPE_FILL_S << FACE_TYPE_SHIFT); + f->indices[0] = gVerticesBase - gVertices; + + gVerticesBase += 2; +} + +X_NOINLINE void renderLine(int32 x, int32 y, int32 width, int32 height, int32 index, int32 z) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + ASSERT(width == 1 || height == 1); + ASSERT(width > 0); + ASSERT(height > 0); + + gVerticesBase[0].x = x; + gVerticesBase[0].y = y; + gVerticesBase[0].g = index; + + gVerticesBase[1].x = width; + gVerticesBase[1].y = height; + + int32 idx = gVerticesBase - gVertices; + + Face* f = faceAdd(z); + f->flags = (height == 1) ? (FACE_TYPE_LINE_H << FACE_TYPE_SHIFT) : (FACE_TYPE_LINE_V << FACE_TYPE_SHIFT); + f->indices[0] = idx; + + gVerticesBase += 2; +} + +void renderSprite(int32 vx, int32 vy, int32 vz, int32 vg, int32 index) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + const Matrix &m = matrixGet(); + + vx -= gCameraViewPos.x; + vy -= gCameraViewPos.y; + vz -= gCameraViewPos.z; + + int32 z = DP33(m.e20, m.e21, m.e22, vx, vy, vz); + + if (z < VIEW_MIN_F || z >= VIEW_MAX_F) + { + return; + } + + int32 x = DP33(m.e00, m.e01, m.e02, vx, vy, vz); + int32 y = DP33(m.e10, m.e11, m.e12, vx, vy, vz); + + x >>= FIXED_SHIFT; + y >>= FIXED_SHIFT; + z >>= FIXED_SHIFT; + + const Sprite* sprite = level.sprites + index; + + int32 l = x + sprite->l; + int32 r = x + sprite->r; + int32 t = y + sprite->t; + int32 b = y + sprite->b; + + // TODO one projection + PERSPECTIVE(l, t, z); + + l += (FRAME_WIDTH >> 1); + if (l >= viewport.x1) return; + + t += (FRAME_HEIGHT >> 1); + if (t >= viewport.y1) return; + + PERSPECTIVE(r, b, z); + + r += (FRAME_WIDTH >> 1); + if (r < viewport.x0) return; + + b += (FRAME_HEIGHT >> 1); + if (b < viewport.y0) return; + + if (l == r) return; + if (t == b) return; + + if (z > FOG_MIN) + { + vg += (z - FOG_MIN) << FOG_SHIFT; + if (vg > 8191) { + vg = 8191; + } + } + vg >>= 8; + + Vertex* v1 = gVerticesBase++; + v1->x = l; + v1->y = t; + //v1->z = z; + v1->g = vg; + + Vertex* v2 = gVerticesBase++; + v2->x = r; + v2->y = b; + //v2->z = z; + //v2->g = vg; + + int32 depth = X_MAX(0, z - 128); // depth hack + + Face* f = faceAdd(depth >> OT_SHIFT); + f->flags = (FACE_TYPE_SPRITE << FACE_TYPE_SHIFT) | index; + f->indices[0] = v1 - gVertices; + + gVerticesBase += 2; +} + +void renderGlyph(int32 vx, int32 vy, int32 index) +{ + if (gVerticesBase - gVertices + 2 > MAX_VERTICES) { + ASSERT(false); + return; + } + + if (gFacesBase - gFaces + 1 > MAX_FACES) { + ASSERT(false); + return; + } + + const Sprite* sprite = level.sprites + index; + + int32 l = vx + sprite->l; + int32 r = vx + sprite->r; + int32 t = vy + sprite->t; + int32 b = vy + sprite->b; + + if (l == r) return; + if (t == b) return; + if (r < 0) return; + if (b < 0) return; + if (l >= FRAME_WIDTH) return; + if (t >= FRAME_HEIGHT) return; + + Vertex* v1 = gVerticesBase++; + v1->x = l; + v1->y = t; + v1->g = 16; + + Vertex* v2 = gVerticesBase++; + v2->x = r; + v2->y = b; + + Face* f = faceAdd(0); + f->flags = (FACE_TYPE_SPRITE << FACE_TYPE_SHIFT) | index; + f->indices[0] = v1 - gVertices; +} + +#define BAR_HEIGHT 5 + +const int32 BAR_COLORS[BAR_MAX][5] = { + { 8, 11, 8, 6, 24 }, + { 32, 41, 32, 19, 21 }, + { 28, 29, 28, 26, 27 }, + { 43, 44, 43, 42, 41 }, +}; + +X_NOINLINE void renderBorder(int32 x, int32 y, int32 width, int32 height, int32 color1, int32 color2, int32 z) +{ + renderLine(x + 1, y, width - 2, 1, color1, z); + renderLine(x + 1, y + height - 1, width - 2, 1, color2, z); + renderLine(x, y, 1, height, color1, z); + renderLine(x + width - 1, y, 1, height, color2, z); +} + +void renderBar(int32 x, int32 y, int32 width, int32 value, BarType type) +{ + // colored bar + int32 ix = x + 1; + int32 iy = y + 1; + int32 w = value* width >> 8; + + if (w > 0) + { + for (int32 i = 0; i < 5; i++) + { + renderLine(ix, iy++, w, 1, BAR_COLORS[type][i], 0); + } + } + + if (w < width) + { + renderFill(x + 1 + w, y + 1, width - w, BAR_HEIGHT, 27, 0); + } + + renderBorder(x, y, width + 2, BAR_HEIGHT + 2, 19, 17, 0); +} + +void renderBackground(const void* background) +{ + dmaCopy(background, (void*)fb, FRAME_WIDTH * FRAME_HEIGHT); +} + +void* copyBackground() +{ + dmaCopy((void*)fb, gBackgroundCopy, FRAME_WIDTH * FRAME_HEIGHT); + + palGrayRemap(gBackgroundCopy, FRAME_WIDTH * FRAME_HEIGHT); + + return gBackgroundCopy; +} diff --git a/src/platform/gba/sound.cpp b/src/platform/gba/sound.cpp new file mode 100644 index 00000000..bde5290d --- /dev/null +++ b/src/platform/gba/sound.cpp @@ -0,0 +1,300 @@ +#include "common.h" + +uint8 ADPCM4_ADAPT[] = { // IWRAM ! + 192,192,136,136,128,128,128,128, // -8..-1 + 112,128,128,128,128,136,136,192, // 0..+7 +}; + +#if defined(__GBA__) && defined(USE_ASM) + extern const uint8_t TRACKS_AD4[]; +#else + extern const void* TRACKS_AD4; +#endif + +int8 soundBuffer[2 * SND_SAMPLES + 32]; // 32 bytes of silence for DMA overrun while interrupt + +#ifdef USE_ASM + #define sndADPCM4_fill sndADPCM4_fill_asm + #define sndPCM_fill sndPCM_fill_asm + #define sndPCM_mix sndPCM_mix_asm + #define sndClear sndClear_asm + + extern "C" { + void sndClear_asm(int8* buffer); + void sndADPCM4_fill_asm(ADPCM4_STATE &state, int8* buffer, const uint8* data, int32 size); + int32 sndPCM_fill_asm(int32 pos, int32 inc, int32 size, int32 volume, const uint8* data, int8* buffer); + int32 sndPCM_mix_asm(int32 pos, int32 inc, int32 size, int32 volume, const uint8* data, int8* buffer); + } +#else + #define sndADPCM4_fill sndADPCM4_c + #define sndPCM_fill sndPCM_c + #define sndPCM_mix sndPCM_c + #define sndClear(b) dmaFill(b, SND_ENCODE(0), SND_SAMPLES * sizeof(b[0])) + +#define DECODE_ADPCM4(n)\ + tap = zM2 + tap - (tap >> 3);\ + *buffer++ = SND_ENCODE(X_CLAMP(tap >> 8, SND_MIN, SND_MAX));\ + res = ((n&0xF) ^ 8) - 8;\ + out = res*quant + (zM1 - zM2);\ + zM2 = zM1;\ + zM1 = out;\ + quant = (quant*(int32)ADPCM4_ADAPT[res+8] + 127) >> 7;\ + +void sndADPCM4_c(ADPCM4_STATE &state, int8* buffer, const uint8* data, int32 size) +{ + int32 zM1 = state.zM1; + int32 zM2 = state.zM2; + int32 tap = state.tap; + int32 quant = state.quant; + int32 res, out; + + for (int32 i=0; i < size; i++) + { + uint32 n = *data++; + DECODE_ADPCM4(n); + n >>= 4; + DECODE_ADPCM4(n); + } + + state.zM1 = zM1; + state.zM2 = zM2; + state.tap = tap; + state.quant = quant; +} + +int32 sndPCM_c(int32 pos, int32 inc, int32 size, int32 volume, const uint8* data, int8* buffer) +{ + int32 last = pos + SND_SAMPLES * inc; + if (last > size) { + last = size; + } + + while (pos < last) + { + int32 amp = SND_DECODE(*(uint8*)buffer) + ((SND_DECODE(data[pos >> SND_FIXED_SHIFT]) * volume) >> SND_VOL_SHIFT); + *buffer++ = SND_ENCODE(X_CLAMP(amp, SND_MIN, SND_MAX)); + pos += inc; + } + + return pos; +} +#endif + +struct Music +{ + const uint8* data; + int32 size; + int32 pos; + ADPCM4_STATE state; + + void fill(int8* buffer) + { + int32 len = X_MIN(size - pos, SND_SAMPLES >> 1); + + sndADPCM4_fill(state, buffer, data + pos, len); + + pos += len; + + if (pos >= size) + { + data = NULL; + memset(buffer + (len << 1), 0, (SND_SAMPLES - (len << 1)) * sizeof(buffer[0])); + } + } +}; + +struct Sample +{ + int32 pos; + int32 inc; + int32 size; + int32 volume; + const uint8* data; + + void mix(int8* buffer) + { + pos = sndPCM_mix(pos, inc, size, volume, data, buffer); + + if (pos >= size) + { + data = NULL; + } + } + + void fill(int8* buffer) + { + pos = sndPCM_fill(pos, inc, size, volume, data, buffer); + + if (pos >= size) + { + data = NULL; + } + } +}; + +EWRAM_DATA Music music; +EWRAM_DATA Sample channels[SND_CHANNELS]; +EWRAM_DATA int32 channelsCount; + +#define CALC_INC (((SND_SAMPLE_FREQ << SND_FIXED_SHIFT) / SND_OUTPUT_FREQ) * pitch >> SND_PITCH_SHIFT) + +void sndInit() +{ + // initialized in main.cpp +} + +void sndInitSamples() +{ + // nothing to do +} + +void sndFreeSamples() +{ + // nothing to do +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + if (!gSettings.audio_sfx) + return NULL; + + const uint8 *data = level.soundData + level.soundOffsets[index]; + int32 size = *(int32*)data; + data += 4; + + if (mode == UNIQUE || mode == REPLAY) + { + for (int32 i = 0; i < channelsCount; i++) + { + Sample* sample = channels + i; + + if (sample->data != data) + continue; + + sample->inc = CALC_INC; + sample->volume = volume; + + if (mode == REPLAY) + { + sample->pos = 0; + } + + return sample; + } + } + + if (channelsCount >= SND_CHANNELS) + return NULL; + + Sample* sample = channels + channelsCount++; + sample->data = data; + sample->size = size << SND_FIXED_SHIFT; + sample->pos = 0; + sample->inc = CALC_INC; + sample->volume = volume; + + return sample; +} + +void sndPlayTrack(int32 track) +{ + if (!gSettings.audio_music) + return; + + if (track == gCurTrack) + return; + + gCurTrack = track; + + if (track == -1) { + sndStopTrack(); + return; + } + + struct TrackInfo { + int32 offset; + int32 size; + }; + + const TrackInfo* info = (const TrackInfo*)TRACKS_AD4 + track; + + if (!info->size) + return; + + // Clear music.data before setup, and write it after to ensure + // music.fill() has a consistent state at any point in time + music.data = NULL; + music.size = info->size; + music.pos = 0; + //music.volume = (1 << SND_VOL_SHIFT); + music.state.zM1 = 0; + music.state.zM2 = 0; + music.state.tap = 0; + music.state.quant = 0x0800; + music.data = (const uint8*)TRACKS_AD4 + info->offset; +} + +void sndStopTrack() +{ + music.data = NULL; + music.size = 0; + music.pos = 0; +} + +bool sndTrackIsPlaying() +{ + return music.data != NULL; +} + +void sndStopSample(int32 index) +{ + const uint8 *data = level.soundData + level.soundOffsets[index] + 4; + + int32 i = channelsCount; + + while (--i >= 0) + { + if (channels[i].data == data) + { + channels[i] = channels[--channelsCount]; + } + } +} + +void sndStop() +{ + channelsCount = 0; + music.data = NULL; +} + +void sndFill(int8* buffer) +{ +#ifdef PROFILE_SOUNDTIME + PROFILE_CLEAR(); + PROFILE(CNT_SOUND); +#endif + bool mix = (music.data != NULL); + + if (mix) { + music.fill(buffer); + } else { + sndClear(buffer); + } + + int32 ch = channelsCount; + while (ch--) + { + Sample* sample = channels + ch; + + if (mix) + sample->mix(buffer); + else + sample->fill(buffer); + + if (!sample->data) { + channels[ch] = channels[--channelsCount]; + } + + mix = true; + } +} diff --git a/src/platform/gcw0/build.sh b/src/platform/gcw0/build.sh new file mode 100755 index 00000000..62d061d5 --- /dev/null +++ b/src/platform/gcw0/build.sh @@ -0,0 +1,3 @@ +set -e +/opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-g++ -o OpenLara -D__GCW0__ -std=c++11 -Os -s -g0 -mips32r2 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -Wno-invalid-source-encoding main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I/opt/vc/include -I../../ -L/opt/vc/lib/ -lGLESv2 -lEGL -lm -lpthread -lasound +/opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note diff --git a/src/platform/gcw0/icon.png b/src/platform/gcw0/icon.png new file mode 100644 index 00000000..1c882e35 Binary files /dev/null and b/src/platform/gcw0/icon.png differ diff --git a/src/platform/gcw0/main.cpp b/src/platform/gcw0/main.cpp new file mode 100644 index 00000000..9ca5ddb7 --- /dev/null +++ b/src/platform/gcw0/main.cpp @@ -0,0 +1,429 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "game.h" + +#define WND_TITLE "OpenLara" + +// timing +unsigned int startTime; + +int osGetTimeMS() { + timeval t; + gettimeofday(&t, NULL); + return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); +} + +// sound +snd_pcm_uframes_t SND_FRAMES = 512; +snd_pcm_t *sndOut; +Sound::Frame *sndData; +pthread_t sndThread; + +void* sndFill(void *arg) { + while (sndOut) { + Sound::fill(sndData, SND_FRAMES); + + int count = SND_FRAMES; + while (count > 0) { + int frames = snd_pcm_writei(sndOut, &sndData[SND_FRAMES - count], count); + if (frames < 0) { + frames = snd_pcm_recover(sndOut, frames, 0); + if (frames == -EAGAIN) { + LOG("snd_pcm_writei try again\n"); + sleep(1); + continue; + } + if (frames < 0) { + LOG("snd_pcm_writei failed: %s\n", snd_strerror(frames)); + sndOut = NULL; + return NULL; + } + } + count -= frames; + } + + snd_pcm_prepare(sndOut); + } + return NULL; +} + +bool sndInit() { + unsigned int freq = 44100; + + int err; + + // In the perfect world ReedPlayer-Clover process + // will release ALSA device before app running, but... + for (int i = 0; i < 20; i++) { // 20 * 0.1 = 2 secs + sndOut = NULL; + if ((err = snd_pcm_open(&sndOut, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + LOG("sound: try to snd_pcm_open #%d...\n", i); + usleep(100000); // wait for 100 ms + continue; + } + break; + } + + // I've bad news for you + if (!sndOut) { + LOG("! sound: snd_pcm_open %s\n", snd_strerror(err)); + return false; + } + + snd_pcm_hw_params_t *params; + + snd_pcm_hw_params_alloca(¶ms); + snd_pcm_hw_params_any(sndOut, params); + snd_pcm_hw_params_set_access(sndOut, params, SND_PCM_ACCESS_RW_INTERLEAVED); + + snd_pcm_hw_params_set_channels(sndOut, params, 2); + snd_pcm_hw_params_set_format(sndOut, params, SND_PCM_FORMAT_S16_LE); + snd_pcm_hw_params_set_rate_near(sndOut, params, &freq, NULL); + + snd_pcm_hw_params_set_periods(sndOut, params, 4, 0); + snd_pcm_hw_params_set_period_size_near(sndOut, params, &SND_FRAMES, NULL); + snd_pcm_hw_params_get_period_size(params, &SND_FRAMES, 0); + + snd_pcm_hw_params(sndOut, params); + snd_pcm_prepare(sndOut); + + sndData = new Sound::Frame[SND_FRAMES]; + memset(sndData, 0, SND_FRAMES * sizeof(Sound::Frame)); + if ((err = snd_pcm_writei(sndOut, sndData, SND_FRAMES)) < 0) { + LOG("! sound: write %s\n", snd_strerror(err)); + sndOut = NULL; + } + + snd_pcm_start(sndOut); + pthread_create(&sndThread, NULL, sndFill, NULL); + + return true; +} + +void sndFree() { + pthread_cancel(sndThread); + snd_pcm_drop(sndOut); + snd_pcm_drain(sndOut); + snd_pcm_close(sndOut); + delete[] sndData; +} + +// Window +struct FrameBuffer { + unsigned short width; + unsigned short height; +} fb; + +EGLDisplay display; +EGLSurface surface; +EGLContext context; + +bool eglInit() { + LOG("EGL init context...\n"); + + fb_var_screeninfo vinfo; + int fd = open("/dev/fb0", O_RDWR); + if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { + LOG("! can't get framebuffer size\n"); + return false; + } + close(fd); + + fb.width = vinfo.xres; + fb.height = vinfo.yres; + + const EGLint eglAttr[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 5, + EGL_GREEN_SIZE, 6, + EGL_RED_SIZE, 5, + EGL_DEPTH_SIZE, 16, + EGL_NONE + }; + + const EGLint ctxAttr[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display == EGL_NO_DISPLAY) { + LOG("eglGetDisplay = EGL_NO_DISPLAY\n"); + return false; + } + + if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + LOG("eglInitialize = EGL_FALSE\n"); + return false; + } + + EGLConfig config; + EGLint configCount; + + if (eglChooseConfig(display, eglAttr, &config, 1, &configCount) == EGL_FALSE || configCount == 0) { + LOG("eglChooseConfig = EGL_FALSE\n"); + return false; + } + + surface = eglCreateWindowSurface(display, config, 0, NULL); + if (surface == EGL_NO_SURFACE) { + LOG("eglCreateWindowSurface = EGL_NO_SURFACE\n"); + return false; + } + + context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctxAttr); + if (context == EGL_NO_CONTEXT) { + LOG("eglCreateContext = EGL_NO_CONTEXT\n"); + return false; + } + + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { + LOG("eglMakeCurrent = EGL_FALSE\n"); + return false; + } + + return true; +} + +void eglFree() { + LOG("EGL release context\n"); + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(display, surface); + eglDestroyContext(display, context); + eglTerminate(display); +} + +// Input +int ev_buttons; +int ev_haptic; +ff_effect joy_ff; + +#define JOY_RUMBLE_TIMER 50 +#define JOY_RUMBLE_GAIN 0xFFFF + +vec2 joyL, joyR; +float joyVGain, joyVGainOld; +int joyVTime; + +bool osJoyReady(int index) { + return index == 0; +} + +void osJoyVibrate(int index, float L, float R) { + if (ev_haptic == -1) return; + joyVGain = (L + R) * 0.5f; +} + +float joyAxisValue(int value) { + return value / 1536.0f - 1.0f; +} + +vec2 joyDir(const vec2 &value) { + float dist = min(1.0f, value.length()); + return value.normal() * dist; +} + +void joyRumble() { + if (joy_ff.id == -1 || joyVGain == joyVGainOld || osGetTimeMS() < joyVTime) + return; + + joy_ff.u.rumble.strong_magnitude = int(JOY_RUMBLE_GAIN * joyVGain); + ioctl(ev_haptic, EVIOCSFF, &joy_ff); + + joyVGainOld = joyVGain; + joyVTime = osGetTimeMS() + JOY_RUMBLE_TIMER; +} + +JoyKey codeToJoyKey(int code) { + switch (code) { + // gamepad + case KEY_LEFT : return jkLeft; + case KEY_RIGHT : return jkRight; + case KEY_UP : return jkUp; + case KEY_DOWN : return jkDown; + case KEY_LEFTCTRL : return jkB; + case KEY_LEFTALT : return jkA; + case KEY_SPACE : return jkY; + case KEY_LEFTSHIFT : return jkX; + case KEY_TAB : return jkLB; + case KEY_BACKSPACE : return jkRB; + case KEY_ESC : return jkSelect; + case KEY_ENTER : return jkStart; + case KEY_KPSLASH : return jkL; + case KEY_KPDOT : return jkR; + case KEY_PAGEUP : return jkLT; + case KEY_PAGEDOWN : return jkRT; + case KEY_POWER : { + Game::quickSave(); + Core::quit(); + } + } + return jkNone; +} + +void inputInit() { + joyL = joyR = vec2(0.0f); + joyVGain = 0.0f; + joyVGainOld = 0.0f; + joyVTime = osGetTimeMS(); + + memset(&joy_ff, 0, sizeof(joy_ff)); + joy_ff.id = -1; + + // TODO find compatible device instead of hardcode + ev_buttons = open("/dev/input/event3", O_NONBLOCK | O_RDONLY); + ev_haptic = open("/dev/input/event1", O_RDWR); + + if (ev_buttons == -1) { + LOG("! input device was not found\n"); + } + + if (ev_haptic == -1) { + LOG("! haptic device was not found\n"); + } else { + joy_ff.type = FF_RUMBLE; + joy_ff.id = -1; + joy_ff.replay.length = 0; + joy_ff.replay.delay = 0; + joy_ff.u.rumble.strong_magnitude = 0; + joy_ff.u.rumble.weak_magnitude = 0; + + if (ioctl(ev_haptic, EVIOCSFF, &joy_ff) != -1) { + input_event gain; + gain.type = EV_FF; + gain.code = FF_GAIN; + gain.value = JOY_RUMBLE_GAIN; + write(ev_haptic, &gain, sizeof(gain)); + + input_event state; + state.type = EV_FF; + state.code = joy_ff.id; + state.value = 1; // play + write(ev_haptic, &state, sizeof(state)); + } else { + LOG("! can't initialize vibration\n"); + close(ev_haptic); + ev_haptic = -1; + } + } +} + +void inputFree() { + if (ev_buttons != -1) close(ev_buttons); + if (ev_haptic != -1) close(ev_haptic); +} + +void inputUpdate() { + joyRumble(); + + if (ev_buttons == -1) return; + + input_event events[64]; + + int rb = read(ev_buttons, events, sizeof(events)); + + input_event *e = events; + while (rb > 0) { + switch (e->type) { + case EV_KEY : { + JoyKey key = codeToJoyKey(e->code); + Input::setJoyDown(0, key, e->value != 0); + break; + } + case EV_ABS : { + switch (e->code) { + // Left stick + case ABS_X : joyL.x = -joyAxisValue(e->value); break; + case ABS_Y : joyL.y = -joyAxisValue(e->value); break; + // Right stick + case ABS_RX : joyR.x = joyAxisValue(e->value); break; + case ABS_RY : joyR.y = joyAxisValue(e->value); break; + } + + Input::setJoyPos(0, jkL, joyDir(joyL)); + Input::setJoyPos(0, jkR, joyDir(joyR)); + } + } + e++; + rb -= sizeof(events[0]); + } +} + +int main(int argc, char **argv) { + if (!eglInit()) { + LOG("! can't initialize EGL context\n"); + return -1; + } + + Core::width = fb.width; + Core::height = fb.height; + + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + + const char *home; + if (!(home = getenv("HOME"))) + home = getpwuid(getuid())->pw_dir; + strcpy(contentDir, home); + strcat(contentDir, "/.openlara/"); + + struct stat st = {0}; + + if (stat(contentDir, &st) == -1) { + LOG("no data directory found, please copy the original game content into %s\n", contentDir); + return -1; + } + + strcpy(saveDir, contentDir); + + strcpy(cacheDir, contentDir); + strcat(cacheDir, "cache/"); + + if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1) { + cacheDir[0] = 0; + LOG("can't create /home/.openlara/cache/\n"); + } + + timeval t; + gettimeofday(&t, NULL); + startTime = t.tv_sec; + + Game::init(); + + Game::quickLoad(true); + + inputInit(); + sndInit(); + + while (!Core::isQuit) { + inputUpdate(); + + if (Game::update()) { + Game::render(); + Core::waitVBlank(); + eglSwapBuffers(display, surface); + } else + usleep(9000); + }; + + inputFree(); + + Game::deinit(); + eglFree(); + + sndFree(); + + return 0; +} diff --git a/src/platform/gcw0/make_opk.sh b/src/platform/gcw0/make_opk.sh new file mode 100755 index 00000000..d06487d0 --- /dev/null +++ b/src/platform/gcw0/make_opk.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +OPK_NAME=OpenLara.opk + +echo ${OPK_NAME} + +# create default.gcw0.desktop +cat > default.gcw0.desktop < #include #include +#include #include #include #include @@ -18,7 +19,7 @@ // timing unsigned int startTime; -int osGetTime() { +int osGetTimeMS() { timeval t; gettimeofday(&t, NULL); return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); @@ -26,7 +27,7 @@ int osGetTime() { // sound #define SND_FRAME_SIZE 4 -#define SND_DATA_SIZE (1024 * SND_FRAME_SIZE) +#define SND_DATA_SIZE (2352 * SND_FRAME_SIZE) pa_simple *sndOut; pthread_t sndThread; @@ -77,17 +78,28 @@ void sndFree() { } // Input -InputKey keyToInputKey(int code) { - int codes[] = { - 113, 114, 111, 116, 65, 23, 36, 9, 50, 37, 64, - 19, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, - 57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, +InputKey keyToInputKey(Display *dpy, XKeyEvent event) { + KeySym code = XLookupKeysym(&event, 0); + + if (code == XK_Shift_R) code = XK_Shift_L; + if (code == XK_Control_R) code = XK_Control_L; + if (code == XK_Alt_R) code = XK_Alt_L; + + KeySym codes[] = { + XK_Left, XK_Right, XK_Up, XK_Down, XK_space, XK_Tab, XK_Return, XK_Escape, XK_Shift_L, XK_Control_L, XK_Alt_L, + XK_0, XK_1, XK_2, XK_3, XK_4, XK_5, XK_6, XK_7, XK_8, XK_9, + XK_a, XK_b, XK_c, XK_d, XK_e, XK_f, XK_g, XK_h, XK_i, XK_j, XK_k, XK_l, XK_m, + XK_n, XK_o, XK_p, XK_q, XK_r, XK_s, XK_t, XK_u, XK_v, XK_w, XK_x, XK_y, XK_z, + XK_KP_0, XK_KP_1, XK_KP_2, XK_KP_3, XK_KP_4, XK_KP_5, XK_KP_6, XK_KP_7, XK_KP_8, XK_KP_9, XK_KP_Add, XK_KP_Subtract, XK_KP_Multiply, XK_KP_Divide, XK_KP_Separator, + XK_F1, XK_F2, XK_F3, XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, XK_F9, XK_F10, XK_F11, XK_F12, + XK_minus, XK_equal, XK_bracketleft, XK_bracketright, XK_slash, XK_backslash, XK_comma, XK_period, XK_grave, XK_semicolon, XK_apostrophe, XK_Page_Up, XK_Page_Down, XK_Home, XK_End, XK_Delete, XK_Insert, XK_BackSpace }; - for (int i = 0; i < sizeof(codes) / sizeof(codes[0]); i++) - if (codes[i] == code) + for (int i = 0; i < COUNT(codes); i++) { + if (XKeysymToKeycode(dpy, codes[i]) == event.keycode) { return (InputKey)(ikLeft + i); + } + } return ikNone; } @@ -143,7 +155,7 @@ void joyInit() { ioctl(joy.fd, JSIOCGAXES, &axes); ioctl(joy.fd, JSIOCGBUTTONS, &buttons); ioctl(joy.fd, JSIOCGAXMAP, joy.axismap); - + if (axes < 4 || buttons < 11) { // is it really a gamepad? close(joy.fd); joy.fd = -1; @@ -157,7 +169,7 @@ void joyInit() { LOG(" name : %s\n", name); LOG(" btns : %d\n", int(buttons)); LOG(" axes : %d\n", int(axes)); - + joy.fe = -1; for (int j = 0; j < 99; j++) { sprintf(name, "/sys/class/input/js%d/device/event%d", i, j); @@ -168,13 +180,13 @@ void joyInit() { joy.fe = open(name, O_RDWR); break; } - + uint32 features[4]; if (joy.fe > -1 && (ioctl(joy.fe, EVIOCGBIT(EV_FF, sizeof(features)), features) == -1 || !TEST_BIT(features, FF_RUMBLE))) { close(joy.fe); joy.fe = -1; } - + if (joy.fe > -1) { int n_effects; if (ioctl(joy.fe, EVIOCGEFFECTS, &n_effects) == -1) { @@ -185,7 +197,7 @@ void joyInit() { joy.fx.type = FF_RUMBLE; joy.fx.replay.delay = 0; joy.vL = joy.oL = joy.vR = joy.oR = 0.0f; - joy.time = osGetTime(); + joy.time = Core::getTime(); } } } @@ -218,13 +230,13 @@ vec2 joyDir(const vec2 &value) { void joyRumble(JoyDevice &joy) { if (joy.fe == -1) return; - + if (joy.oL == 0.0f && joy.vL == 0.0f && joy.oR == 0.0f && joy.vR == 0.0f) return; - - if (osGetTime() <= joy.time) + + if (Core::getTime() <= joy.time) return; - + input_event event; event.type = EV_FF; @@ -233,29 +245,29 @@ void joyRumble(JoyDevice &joy) { joy.fx.u.rumble.strong_magnitude = int(joy.vL * 65535); joy.fx.u.rumble.weak_magnitude = int(joy.vR * 65535); joy.fx.replay.length = int(max(JOY_MIN_UPDATE_FX_TIME, 1000.0f / Core::stats.fps)); - + if (ioctl(joy.fe, EVIOCSFF, &joy.fx) == -1) { LOG("! joy update fx\n"); } // play effect event.value = 1; - event.code = joy.fx.id; + event.code = joy.fx.id; if (write(joy.fe, &event, sizeof(event)) == -1) LOG("! joy play fx\n"); } else if (joy.oL != 0.0f || joy.oR != 0.0f) { // stop effect event.value = 0; - event.code = joy.fx.id; + event.code = joy.fx.id; if (write(joy.fe, &event, sizeof(event)) == -1) LOG("! joy stop fx\n"); } - + joy.oL = joy.vL; joy.oR = joy.vR; - - joy.time = osGetTime() + joy.fx.replay.length; + + joy.time = Core::getTime() + joy.fx.replay.length; } void joyUpdate() { @@ -263,12 +275,12 @@ void joyUpdate() { for (int i = 0; i < INPUT_JOY_COUNT; i++) { JoyDevice &joy = joyDevice[i]; - + if (joy.fd == -1) continue; joyRumble(joy); - + js_event event; while (read(joy.fd, &event, sizeof(event)) != -1) { // buttons @@ -276,7 +288,7 @@ void joyUpdate() { Input::setJoyDown(i, event.number >= COUNT(keys) ? jkNone : keys[event.number], event.value == 1); // axes if (event.type & JS_EVENT_AXIS) { - + switch (joy.axismap[event.number]) { // Left stick case ABS_X : joy.L.x = joyAxisValue(event.value); break; @@ -300,7 +312,7 @@ void joyUpdate() { Input::setJoyDown(i, jkDown, event.value > 0x4000); break; } - + Input::setJoyPos(i, jkL, joyDir(joy.L)); Input::setJoyPos(i, jkR, joyDir(joy.R)); } @@ -308,6 +320,76 @@ void joyUpdate() { } } +// filesystem +#define MAX_FILES 4096 +char* gFiles[MAX_FILES]; +int32 gFilesCount; + +void addDir(char* path) +{ + char* fileName; + struct dirent* e; + DIR* dir = opendir(path); + + int32 pathLen = strlen(path); + path[pathLen] = '/'; + + while ((e = readdir(dir))) + { + if (e->d_type == DT_DIR) + { + if (e->d_name[0] != '.') + { + strcpy(path + 1 + pathLen, e->d_name); + addDir(path); + } + } + else + { + ASSERT(gFilesCount < MAX_FILES); + if (gFilesCount < MAX_FILES) + { + strcpy(path + 1 + pathLen, e->d_name); + fileName = (char*)malloc(strlen(path) + 1 - 2); + gFiles[gFilesCount++] = strcpy(fileName, path + 2); + } + } + } + + path[pathLen] = '\0'; +} + +void fsInit() +{ + char path[1024]; + strcpy(path, "."); + addDir(path); + LOG("scan %d files\n", gFilesCount); +} + +void fsFree() +{ + int32 i; + for (i = 0; i < gFilesCount; i++) + { + free(gFiles[i]); + } +} + +const char* osFixFileName(const char* fileName) +{ + int32 i; + for (i = 0; i < gFilesCount; i++) + { + if (!strcasecmp(fileName, gFiles[i])) + { + return gFiles[i]; + } + } + return NULL; +} + +// system void toggle_fullscreen(Display* dpy, Window win) { const size_t _NET_WM_STATE_TOGGLE=2; @@ -326,7 +408,7 @@ void toggle_fullscreen(Display* dpy, Window win) { XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask, &xev); } -void WndProc(const XEvent &e,Display*dpy,Window wnd) { +void WndProc(const XEvent &e, Display* dpy, Window wnd) { switch (e.type) { case ConfigureNotify : Core::width = e.xconfigure.width; @@ -338,7 +420,7 @@ void WndProc(const XEvent &e,Display*dpy,Window wnd) { toggle_fullscreen(dpy,wnd); break; } - Input::setDown(keyToInputKey(e.xkey.keycode), e.type == KeyPress); + Input::setDown(keyToInputKey(dpy, e.xkey), e.type == KeyPress); break; case ButtonPress : case ButtonRelease : { @@ -353,6 +435,34 @@ void WndProc(const XEvent &e,Display*dpy,Window wnd) { } } +int checkLanguage() { + char *lang = getenv("LANG"); + if (!lang || strlen(lang) < 2) return 0; + + uint16 id; + memcpy(&id, lang, 2); + + if (id == TWOCC("en")) return STR_LANG_EN - STR_LANG_EN; + if (id == TWOCC("fr")) return STR_LANG_FR - STR_LANG_EN; + if (id == TWOCC("de")) return STR_LANG_DE - STR_LANG_EN; + if (id == TWOCC("es")) return STR_LANG_ES - STR_LANG_EN; + if (id == TWOCC("it")) return STR_LANG_IT - STR_LANG_EN; + if (id == TWOCC("pl")) return STR_LANG_PL - STR_LANG_EN; + if (id == TWOCC("pt")) return STR_LANG_PT - STR_LANG_EN; + if (id == TWOCC("uk")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("be")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("ru")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("ja")) return STR_LANG_JA - STR_LANG_EN; + if (id == TWOCC("gr")) return STR_LANG_GR - STR_LANG_EN; + if (id == TWOCC("fi")) return STR_LANG_FI - STR_LANG_EN; + if (id == TWOCC("cs")) return STR_LANG_CZ - STR_LANG_EN; + if (id == TWOCC("zh")) return STR_LANG_CN - STR_LANG_EN; + if (id == TWOCC("hu")) return STR_LANG_HU - STR_LANG_EN; + if (id == TWOCC("sv")) return STR_LANG_SV - STR_LANG_EN; + + return 0; +} + int main(int argc, char **argv) { cacheDir[0] = saveDir[0] = contentDir[0] = 0; @@ -405,6 +515,10 @@ int main(int argc, char **argv) { gettimeofday(&t, NULL); startTime = t.tv_sec; + Core::defLang = checkLanguage(); + + fsInit(); + joyInit(); sndInit(); Game::init(argc > 1 ? argv[1] : NULL); @@ -415,15 +529,15 @@ int main(int argc, char **argv) { XNextEvent(dpy, &event); if (event.type == ClientMessage && *event.xclient.data.l == WM_DELETE_WINDOW) Core::quit(); - WndProc(event,dpy,wnd); + WndProc(event, dpy, wnd); } else { joyUpdate(); - bool updated = Game::update(); + bool updated = Game::update(); if (updated) { - Game::render(); + Game::render(); Core::waitVBlank(); - glXSwapBuffers(dpy, wnd); - } + glXSwapBuffers(dpy, wnd); + } } }; @@ -431,6 +545,8 @@ int main(int argc, char **argv) { sndFree(); Game::deinit(); + fsFree(); + glXMakeCurrent(dpy, 0, 0); XCloseDisplay(dpy); return 0; diff --git a/src/platform/nix/premake5.lua b/src/platform/nix/premake5.lua new file mode 100644 index 00000000..7c3519d3 --- /dev/null +++ b/src/platform/nix/premake5.lua @@ -0,0 +1,23 @@ +workspace "OpenLara" + configurations { "Debug", "Release" } + +project "OpenLara" + kind "ConsoleApp" + language "C++" + includedirs { "../../" } + exceptionhandling "Off" + rtti "Off" + + files { "main.cpp", "../../libs/stb_vorbis/stb_vorbis.c", "../../libs/minimp3/minimp3.cpp", "../../libs/tinf/tinflate.c" } + + filter { "system:Linux", "toolset:gcc or clang" } + links { "X11", "GL", "m", "pthread", "pulse-simple", "pulse" } + defines { "POSIX_THREADS", "POSIX_READER_WRITER_LOCKS" } + + filter "configurations:Debug" + defines { "DEBUG" } + symbols "On" + + filter "configurations:Release" + defines { "NDEBUG" } + optimize "Size" diff --git a/src/platform/nx/Makefile b/src/platform/nx/Makefile index 56c6cb69..55d09eb0 100644 --- a/src/platform/nx/Makefile +++ b/src/platform/nx/Makefile @@ -46,15 +46,15 @@ APP_VERSION := 1.0 #--------------------------------------------------------------------------------- ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -mcpu=cortex-a57+crc+fp+simd -CFLAGS := -g -O -ffast-math -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections \ +CFLAGS := -O3 -ffast-math -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections \ $(ARCH) $(DEFINES) CFLAGS += $(INCLUDE) -D__SWITCH__ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) +ASFLAGS := $(ARCH) +LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs $(ARCH) -Wl,-Map,$(notdir $*.map) LIBS := -lEGL -lGLESv2 -lglapi -ldrm_nouveau -lnx -lm diff --git a/src/platform/nx/main.cpp b/src/platform/nx/main.cpp index 95528116..7070fd68 100644 --- a/src/platform/nx/main.cpp +++ b/src/platform/nx/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -25,11 +25,11 @@ void osMutexUnlock(void *obj) { } // timing -unsigned int startTime; +u64 startTick; -int osGetTime() { +int osGetTimeMS() { u64 tick = armGetSystemTick(); - return (tick * 625 / 12) / 1000000; + return int(((tick - startTick) * 625 / 12) / 1000000); } // sound @@ -46,7 +46,7 @@ void sndFill(void *args) { while (!Core::isQuit) { AudioOutBuffer *chunk; - audoutWaitPlayFinish(&chunk, NULL, U64_MAX); + audoutWaitPlayFinish(&chunk, NULL, UINT64_MAX); Sound::fill(frames, SND_FRAMES_FILL); @@ -76,7 +76,7 @@ bool sndInit() { audoutStartAudioOut(); - threadCreate(&sndThread, sndFill, NULL, 0x4000, 0x2B, 2); + threadCreate(&sndThread, sndFill, NULL, NULL, 0x4000, 0x2B, 2); threadStart(&sndThread); return true; @@ -96,7 +96,7 @@ EGLContext context; NWindow *window; void configureResolution() { - if (appletGetOperationMode() == AppletOperationMode_Docked) { + if (appletGetOperationMode() == AppletOperationMode_Console) { Core::width = 1920; Core::height = 1080; } @@ -184,19 +184,19 @@ void osJoyVibrate(int index, float L, float R) { bool joyIsSplit; int joySplitTime; +PadState pads[2]; void joySplit(bool split) { joyIsSplit = split; - joySplitTime = osGetTime(); + joySplitTime = Core::getTime(); + if (split) { - hidSetNpadJoyHoldType(HidJoyHoldType_Horizontal); - hidSetNpadJoyAssignmentModeSingleByDefault(CONTROLLER_PLAYER_1); - hidSetNpadJoyAssignmentModeSingleByDefault(CONTROLLER_PLAYER_2); + hidSetNpadJoyAssignmentModeSingle(HidNpadIdType_No1, HidNpadJoyDeviceType_Left); + hidSetNpadJoyAssignmentModeSingle(HidNpadIdType_No2, HidNpadJoyDeviceType_Right); } else { - hidSetNpadJoyHoldType(HidJoyHoldType_Default); - hidSetNpadJoyAssignmentModeDual(CONTROLLER_PLAYER_1); - hidSetNpadJoyAssignmentModeDual(CONTROLLER_PLAYER_2); - hidMergeSingleJoyAsDualJoy(CONTROLLER_PLAYER_1, CONTROLLER_PLAYER_2); + hidSetNpadJoyAssignmentModeDual(HidNpadIdType_No1); + hidSetNpadJoyAssignmentModeDual(HidNpadIdType_No2); + hidMergeSingleJoyAsDualJoy(HidNpadIdType_No1, HidNpadIdType_No2); if (Game::level && Game::level->players[1]) { Game::level->addPlayer(1); // add existing player == remove player @@ -205,28 +205,28 @@ void joySplit(bool split) { } void joyInit() { + hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal); + + padConfigureInput(2, HidNpadStyleSet_NpadStandard); + padInitialize(&pads[0], HidNpadIdType_No1, HidNpadIdType_Handheld); + padInitialize(&pads[1], HidNpadIdType_No2, HidNpadIdType_Handheld); + joySplit(false); } void joyUpdate() { const static u64 keys[jkMAX] = { 0, KEY_B, KEY_A, KEY_Y, KEY_X, KEY_L, KEY_R, KEY_PLUS, KEY_MINUS, - 0, 0, KEY_ZL, KEY_ZR, + KEY_LSTICK, KEY_RSTICK, KEY_ZL, KEY_ZR, KEY_DLEFT, KEY_DRIGHT, KEY_DUP, KEY_DDOWN, }; - if (hidGetHandheldMode() && joyIsSplit) { - joySplit(false); - } - - hidScanInput(); - bool waitForSplit = false; for (int i = 0; i < (joyIsSplit ? 2 : 1); i++) { - HidControllerID ctrl = (i == 0 ? CONTROLLER_P1_AUTO : CONTROLLER_PLAYER_2); + padUpdate(&pads[i]); - u64 mask = hidKeysDown(ctrl) | hidKeysHeld(ctrl); + u64 mask = padGetButtonsDown(&pads[i]) | padGetButtons(&pads[i]); for (int j = 1; j < jkMAX; j++) { if (j != jkSelect && j != jkStart) { @@ -237,15 +237,14 @@ void joyUpdate() { Input::setJoyDown(i, jkSelect, (mask & (KEY_MINUS | KEY_PLUS)) != 0); Input::setJoyDown(i, jkStart, (mask & (KEY_LSTICK | KEY_RSTICK)) != 0); - JoystickPosition sL, sR; + HidAnalogStickState sL = padGetStickPos(&pads[i], 0); + HidAnalogStickState sR = padGetStickPos(&pads[i], 1); - hidJoystickRead(&sL, ctrl, JOYSTICK_LEFT); - hidJoystickRead(&sR, ctrl, JOYSTICK_RIGHT); - Input::setJoyPos(i, jkL, vec2(float(sL.dx), float(-sL.dy)) / 32767.0f); - Input::setJoyPos(i, jkR, vec2(float(sR.dx), float(-sR.dy)) / 32767.0f); + Input::setJoyPos(i, jkL, vec2(float(sL.x), float(-sL.y)) / 32767.0f); + Input::setJoyPos(i, jkR, vec2(float(sR.x), float(-sR.y)) / 32767.0f); if ((mask & (KEY_L | KEY_R)) == (KEY_L | KEY_R)) { // hold L and R to split/merge joy-con's - if (joySplitTime + 1000 < osGetTime()) { // 1 sec timer + if (Core::getTime() - joySplitTime > 1000) { // 1 sec timer joySplit(!joyIsSplit); } waitForSplit = true; @@ -253,12 +252,13 @@ void joyUpdate() { } if (!waitForSplit) { - joySplitTime = osGetTime(); + joySplitTime = Core::getTime(); } } void touchUpdate() { - int touchesCount = hidTouchCount(); + HidTouchScreenState state; + hidGetTouchScreenStates(&state, 1); bool touchState[COUNT(Input::touch)]; @@ -266,14 +266,11 @@ void touchUpdate() { touchState[i] = Input::down[ikTouchA + i]; } - for (int i = 0; i < touchesCount; i++) { - touchPosition touch; - hidTouchRead(&touch, i); - - InputKey key = Input::getTouch(i /*touch.id*/); // require libnx with https://github.com/switchbrew/libnx/pull/228 + for (int i = 0; i < state.count; i++) { + InputKey key = Input::getTouch(state.touches[i].finger_id); if (key == ikNone) continue; - Input::setPos(key, vec2(float(touch.px), float(touch.py))); + Input::setPos(key, vec2(float(state.touches[i].x), float(state.touches[i].y))); Input::setDown(key, true); touchState[key - ikTouchA] = false; @@ -286,6 +283,34 @@ void touchUpdate() { } } +void makeCacheDir(char *elfPath) { + char buf[255]; + int len = strlen(elfPath); + int start = 0; + strcpy(buf, elfPath); + + // skip volume id + for (int i = 0; i < len; i++) { + if (buf[i] == ':') { + start = i + 1; + break; + } + } + + // skip executable name + for (int i = len - 1; i >= 0; i--) { + if (buf[i] == '/') { + buf[i] = 0; + break; + } + } + + // make directory by full path + strcpy(cacheDir, buf + start); + strcat(cacheDir, "/cache/"); + fsFsCreateDirectory(fsdevGetDeviceFileSystem("sdmc"), cacheDir); +} + int main(int argc, char* argv[]) { Core::width = 1280; Core::height = 720; @@ -296,14 +321,9 @@ int main(int argc, char* argv[]) { } cacheDir[0] = saveDir[0] = contentDir[0] = 0; + makeCacheDir(argv[0]); - strcat(contentDir, "/switch/OpenLara/"); - strcat(cacheDir, "/switch/OpenLara/cache/"); - strcat(saveDir, "/switch/OpenLara/"); - - fsFsCreateDirectory(fsdevGetDefaultFileSystem(), cacheDir); - - startTime = osGetTime(); + startTick = armGetSystemTick(); sndInit(); joyInit(); @@ -328,4 +348,4 @@ int main(int argc, char* argv[]) { eglFree(); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..130b2e08 --- /dev/null +++ b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,63 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "icon16x16@2x.png", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "icon32x32@2x.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "icon128x128.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "icon256x256.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "icon512x512.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon128x128.png b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon128x128.png new file mode 100644 index 00000000..9303085a Binary files /dev/null and b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon128x128.png differ diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon16x16@2x.png b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon16x16@2x.png new file mode 100644 index 00000000..cfa3e597 Binary files /dev/null and b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon16x16@2x.png differ diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon256x256.png b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon256x256.png new file mode 100644 index 00000000..29212881 Binary files /dev/null and b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon256x256.png differ diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon32x32@2x.png b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon32x32@2x.png new file mode 100644 index 00000000..9e39b60d Binary files /dev/null and b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon32x32@2x.png differ diff --git a/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon512x512.png b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon512x512.png new file mode 100644 index 00000000..884e54b1 Binary files /dev/null and b/src/platform/osx/Assets.xcassets/AppIcon.appiconset/icon512x512.png differ diff --git a/src/platform/osx/OpenLara-Info.plist b/src/platform/osx/OpenLara-Info.plist index 622c6321..788e681b 100644 --- a/src/platform/osx/OpenLara-Info.plist +++ b/src/platform/osx/OpenLara-Info.plist @@ -6,10 +6,10 @@ en CFBundleExecutable ${EXECUTABLE_NAME} - CFBundleIconFile - icon CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) + Bundle display name + OpenLara CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/src/platform/osx/OpenLara.xcodeproj/project.pbxproj b/src/platform/osx/OpenLara.xcodeproj/project.pbxproj index 5ecd5060..5010ce0e 100644 --- a/src/platform/osx/OpenLara.xcodeproj/project.pbxproj +++ b/src/platform/osx/OpenLara.xcodeproj/project.pbxproj @@ -7,17 +7,30 @@ objects = { /* Begin PBXBuildFile section */ + 523F97E41DDF7AA5006FE2FC /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 523F97E31DDF7AA5006FE2FC /* Cocoa.framework */; }; + 9938F1A421E830250056E172 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9938F1A021E81EFE0056E172 /* IOKit.framework */; }; 99713CC9204CAD9900006FAC /* tinflate.c in Sources */ = {isa = PBXBuildFile; fileRef = 99713CC8204CAD9900006FAC /* tinflate.c */; }; - 99BFB6A21DCA7F5300E2E997 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6A11DCA7F5300E2E997 /* main.cpp */; }; + 9975BF0B21E9F5D300F13342 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9975BF0A21E9F5D300F13342 /* Assets.xcassets */; }; + 99BF38CD21E7176900D90A38 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99BF38CC21E7176900D90A38 /* main.mm */; settings = {COMPILER_FLAGS = "-Wno-invalid-source-encoding"; }; }; + 99BF38D221E7202500D90A38 /* audio in Resources */ = {isa = PBXBuildFile; fileRef = 99BF38CE21E7202500D90A38 /* audio */; }; + 99BF38D321E7202500D90A38 /* DELDATA in Resources */ = {isa = PBXBuildFile; fileRef = 99BF38CF21E7202500D90A38 /* DELDATA */; }; + 99BF38D421E7202500D90A38 /* PSXDATA in Resources */ = {isa = PBXBuildFile; fileRef = 99BF38D021E7202500D90A38 /* PSXDATA */; }; + 99BF38D521E7202500D90A38 /* FMV in Resources */ = {isa = PBXBuildFile; fileRef = 99BF38D121E7202500D90A38 /* FMV */; }; 99BFB6A91DCA87BF00E2E997 /* stb_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6A81DCA87BF00E2E997 /* stb_vorbis.c */; }; 99BFB6AB1DCA87C500E2E997 /* minimp3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */; }; - 99C4C0B71796AB730032DE85 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99C4C0951796A9730032DE85 /* AGL.framework */; }; - 99C4C0B91796AB7B0032DE85 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99C4C0B81796AB7B0032DE85 /* Carbon.framework */; }; 99C4C0BA1796AB810032DE85 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99C4C0931796A96F0032DE85 /* OpenGL.framework */; }; 99DF7BC41DCBA30B00C40D0A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99DF7BC31DCBA30B00C40D0A /* AudioToolbox.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 523F97E31DDF7AA5006FE2FC /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 9938F1A021E81EFE0056E172 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; + 993F06C7225BEE3A0030AF80 /* savegame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = savegame.h; path = ../../savegame.h; sourceTree = ""; }; + 993F06C8225BEE3A0030AF80 /* lang */ = {isa = PBXFileReference; lastKnownFileType = folder; name = lang; path = ../../lang; sourceTree = ""; }; + 993F06C9225BEE3A0030AF80 /* lang.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lang.h; path = ../../lang.h; sourceTree = ""; }; + 993F06CA225BEE3A0030AF80 /* objects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = objects.h; path = ../../objects.h; sourceTree = ""; }; + 993F06CB225BEE3A0030AF80 /* video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = video.h; path = ../../video.h; sourceTree = ""; }; + 993F06CC225BEE3A0030AF80 /* gapi */ = {isa = PBXFileReference; lastKnownFileType = folder; name = gapi; path = ../../gapi; sourceTree = ""; }; 995C97EF1E91A857003825B2 /* shaders */ = {isa = PBXFileReference; lastKnownFileType = folder; name = shaders; path = ../../shaders; sourceTree = ""; }; 99713CAE204CA3DA00006FAC /* animation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = animation.h; path = ../../animation.h; sourceTree = ""; }; 99713CAF204CA3DA00006FAC /* cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cache.h; path = ../../cache.h; sourceTree = ""; }; @@ -41,21 +54,21 @@ 99713CC1204CA3DA00006FAC /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sound.h; path = ../../sound.h; sourceTree = ""; }; 99713CC2204CA3DA00006FAC /* sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sprite.h; path = ../../sprite.h; sourceTree = ""; }; 99713CC3204CA3DA00006FAC /* texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = texture.h; path = ../../texture.h; sourceTree = ""; }; - 99713CC4204CA3DA00006FAC /* trigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = trigger.h; path = ../../trigger.h; sourceTree = ""; }; 99713CC5204CA3DA00006FAC /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ui.h; path = ../../ui.h; sourceTree = ""; }; 99713CC6204CA3DA00006FAC /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utils.h; path = ../../utils.h; sourceTree = ""; }; 99713CC8204CAD9900006FAC /* tinflate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = tinflate.c; path = ../../libs/tinf/tinflate.c; sourceTree = ""; }; + 9975BF0A21E9F5D300F13342 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = SOURCE_ROOT; }; + 99BF38CC21E7176900D90A38 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; + 99BF38CE21E7202500D90A38 /* audio */ = {isa = PBXFileReference; lastKnownFileType = folder; name = audio; path = ../../../bin/audio; sourceTree = ""; }; + 99BF38CF21E7202500D90A38 /* DELDATA */ = {isa = PBXFileReference; lastKnownFileType = folder; name = DELDATA; path = ../../../bin/DELDATA; sourceTree = ""; }; + 99BF38D021E7202500D90A38 /* PSXDATA */ = {isa = PBXFileReference; lastKnownFileType = folder; name = PSXDATA; path = ../../../bin/PSXDATA; sourceTree = ""; }; + 99BF38D121E7202500D90A38 /* FMV */ = {isa = PBXFileReference; lastKnownFileType = folder; name = FMV; path = ../../../bin/FMV; sourceTree = ""; }; 99BFB69E1DCA7F1700E2E997 /* libs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = libs; path = ../../libs; sourceTree = ""; }; - 99BFB6A11DCA7F5300E2E997 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 99BFB6A81DCA87BF00E2E997 /* stb_vorbis.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = stb_vorbis.c; path = ../../libs/stb_vorbis/stb_vorbis.c; sourceTree = ""; }; 99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = minimp3.cpp; path = ../../libs/minimp3/minimp3.cpp; sourceTree = ""; }; 99C4C0931796A96F0032DE85 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; - 99C4C0951796A9730032DE85 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = System/Library/Frameworks/AGL.framework; sourceTree = SDKROOT; }; 99C4C09B1796AACF0032DE85 /* OpenLara.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenLara.app; sourceTree = BUILT_PRODUCTS_DIR; }; 99C4C0A41796AACF0032DE85 /* OpenLara-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "OpenLara-Info.plist"; sourceTree = ""; }; - 99C4C0B81796AB7B0032DE85 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; - 99DF7BBF1DCBA2BF00C40D0A /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; - 99DF7BC11DCBA2D100C40D0A /* CoreAudioKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudioKit.framework; path = System/Library/Frameworks/CoreAudioKit.framework; sourceTree = SDKROOT; }; 99DF7BC31DCBA30B00C40D0A /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -64,10 +77,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9938F1A421E830250056E172 /* IOKit.framework in Frameworks */, + 523F97E41DDF7AA5006FE2FC /* Cocoa.framework in Frameworks */, 99DF7BC41DCBA30B00C40D0A /* AudioToolbox.framework in Frameworks */, 99C4C0BA1796AB810032DE85 /* OpenGL.framework in Frameworks */, - 99C4C0B91796AB7B0032DE85 /* Carbon.framework in Frameworks */, - 99C4C0B71796AB730032DE85 /* AGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -77,8 +90,18 @@ 99C4C0771796A8230032DE85 = { isa = PBXGroup; children = ( - 99BFB69E1DCA7F1700E2E997 /* libs */, 995C97EF1E91A857003825B2 /* shaders */, + 993F06CC225BEE3A0030AF80 /* gapi */, + 993F06C8225BEE3A0030AF80 /* lang */, + 993F06C9225BEE3A0030AF80 /* lang.h */, + 993F06CA225BEE3A0030AF80 /* objects.h */, + 993F06C7225BEE3A0030AF80 /* savegame.h */, + 993F06CB225BEE3A0030AF80 /* video.h */, + 99BF38CE21E7202500D90A38 /* audio */, + 99BF38CF21E7202500D90A38 /* DELDATA */, + 99BF38D121E7202500D90A38 /* FMV */, + 99BF38D021E7202500D90A38 /* PSXDATA */, + 99BF38CC21E7176900D90A38 /* main.mm */, 99713CAE204CA3DA00006FAC /* animation.h */, 99713CAF204CA3DA00006FAC /* cache.h */, 99713CB0204CA3DA00006FAC /* camera.h */, @@ -101,13 +124,12 @@ 99713CC1204CA3DA00006FAC /* sound.h */, 99713CC2204CA3DA00006FAC /* sprite.h */, 99713CC3204CA3DA00006FAC /* texture.h */, - 99713CC4204CA3DA00006FAC /* trigger.h */, 99713CC5204CA3DA00006FAC /* ui.h */, 99713CC6204CA3DA00006FAC /* utils.h */, 99BFB6AA1DCA87C500E2E997 /* minimp3.cpp */, 99BFB6A81DCA87BF00E2E997 /* stb_vorbis.c */, 99713CC8204CAD9900006FAC /* tinflate.c */, - 99BFB6A11DCA7F5300E2E997 /* main.cpp */, + 99BFB69E1DCA7F1700E2E997 /* libs */, 99C4C0A31796AACF0032DE85 /* Supporting Files */, 99C4C0821796A8230032DE85 /* Frameworks */, 99C4C0811796A8230032DE85 /* Products */, @@ -125,12 +147,10 @@ 99C4C0821796A8230032DE85 /* Frameworks */ = { isa = PBXGroup; children = ( + 9938F1A021E81EFE0056E172 /* IOKit.framework */, + 523F97E31DDF7AA5006FE2FC /* Cocoa.framework */, 99DF7BC31DCBA30B00C40D0A /* AudioToolbox.framework */, - 99DF7BC11DCBA2D100C40D0A /* CoreAudioKit.framework */, - 99DF7BBF1DCBA2BF00C40D0A /* CoreAudio.framework */, - 99C4C0B81796AB7B0032DE85 /* Carbon.framework */, 99C4C0931796A96F0032DE85 /* OpenGL.framework */, - 99C4C0951796A9730032DE85 /* AGL.framework */, ); name = Frameworks; sourceTree = ""; @@ -138,6 +158,7 @@ 99C4C0A31796AACF0032DE85 /* Supporting Files */ = { isa = PBXGroup; children = ( + 9975BF0A21E9F5D300F13342 /* Assets.xcassets */, 99C4C0A41796AACF0032DE85 /* OpenLara-Info.plist */, ); name = "Supporting Files"; @@ -178,6 +199,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 99C4C0771796A8230032DE85; @@ -195,6 +217,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 99BF38D221E7202500D90A38 /* audio in Resources */, + 99BF38D321E7202500D90A38 /* DELDATA in Resources */, + 99BF38D421E7202500D90A38 /* PSXDATA in Resources */, + 99BF38D521E7202500D90A38 /* FMV in Resources */, + 9975BF0B21E9F5D300F13342 /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -205,9 +232,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 99BF38CD21E7176900D90A38 /* main.mm in Sources */, 99713CC9204CAD9900006FAC /* tinflate.c in Sources */, 99BFB6AB1DCA87C500E2E997 /* minimp3.cpp in Sources */, - 99BFB6A21DCA7F5300E2E997 /* main.cpp in Sources */, 99BFB6A91DCA87BF00E2E997 /* stb_vorbis.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -251,6 +278,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-v"; SDKROOT = macosx; }; name = Debug; @@ -283,6 +311,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.6; + OTHER_LDFLAGS = "-v"; SDKROOT = macosx; }; name = Release; @@ -290,12 +319,15 @@ 99C4C0B51796AAD00032DE85 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = "OpenLara-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_LDFLAGS = "--verbose"; PRODUCT_BUNDLE_IDENTIFIER = "com.xproger.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; @@ -305,13 +337,16 @@ 99C4C0B61796AAD00032DE85 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = "OpenLara-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_LDFLAGS = "--verbose"; PRODUCT_BUNDLE_IDENTIFIER = "com.xproger.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; diff --git a/src/platform/osx/main.mm b/src/platform/osx/main.mm new file mode 100644 index 00000000..c01921e8 --- /dev/null +++ b/src/platform/osx/main.mm @@ -0,0 +1,553 @@ +#include +#include +#include +#include + +#include "game.h" + +int MSAA = 0; +BOOL enableRetina = YES; +int frameLimit = 58 + 4; + +// timing +int osGetTimeMS() { + static mach_timebase_info_data_t timebaseInfo; + if (timebaseInfo.denom == 0) { + mach_timebase_info(&timebaseInfo); + } + + uint64_t absolute = mach_absolute_time(); + uint64_t milliseconds = absolute * timebaseInfo.numer / (timebaseInfo.denom * 1000000ULL); + return int(milliseconds); +} + +// sound +#define SND_SIZE 2352 + +static AudioQueueRef audioQueue; + +void sndFill(void* inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { + void* frames = inBuffer->mAudioData; + UInt32 count = inBuffer->mAudioDataBytesCapacity / 4; + Sound::fill((Sound::Frame*)frames, count); + inBuffer->mAudioDataByteSize = count * 4; + AudioQueueEnqueueBuffer(audioQueue, inBuffer, 0, NULL); +} + +void sndInit() { + AudioStreamBasicDescription deviceFormat; + deviceFormat.mSampleRate = 44100; + deviceFormat.mFormatID = kAudioFormatLinearPCM; + deviceFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; + deviceFormat.mBytesPerPacket = 4; + deviceFormat.mFramesPerPacket = 1; + deviceFormat.mBytesPerFrame = 4; + deviceFormat.mChannelsPerFrame = 2; + deviceFormat.mBitsPerChannel = 16; + deviceFormat.mReserved = 0; + + AudioQueueNewOutput(&deviceFormat, sndFill, NULL, NULL, NULL, 0, &audioQueue); + + for (int i = 0; i < 2; i++) { + AudioQueueBufferRef mBuffer; + AudioQueueAllocateBuffer(audioQueue, SND_SIZE, &mBuffer); + sndFill(NULL, audioQueue, mBuffer); + } + AudioQueueStart(audioQueue, NULL); +} + +// common input functions +InputKey keyToInputKey(int code) { + static const int codes[] = { + 0x7B, 0x7C, 0x7E, 0x7D, 0x31, 0x30, 0x24, 0x35, 0x38, 0x3B, 0x3A, + 0x1D, 0x12, 0x13, 0x14, 0x15, 0x17, 0x16, 0x1A, 0x1C, 0x19, // 0..9 + 0x00, 0x0B, 0x08, 0x02, 0x0E, 0x03, 0x05, 0x04, 0x22, 0x26, 0x28, 0x25, 0x2E, // A..M + 0x2D, 0x1F, 0x23, 0x0C, 0x0F, 0x01, 0x11, 0x20, 0x09, 0x0D, 0x07, 0x10, 0x06, // N..Z + }; + + for (int i = 0; i < sizeof(codes) / sizeof(codes[0]); i++) { + if (codes[i] == code) { + return (InputKey)(ikLeft + i); + } + } + return ikNone; +} + +InputKey mouseToInputKey(int btn) { + switch (btn) { + case 1 : return ikMouseL; + case 2 : return ikMouseR; + case 3 : return ikMouseM; + } + return ikNone; +} + +IOHIDDeviceRef joyDevices[4] = { 0 }; +IOHIDManagerRef hidManager; + +bool osJoyReady(int index) { + if (index < 0 || index >= COUNT(joyDevices)) + return false; + return joyDevices[index] != NULL; +} + +void osJoyVibrate(int index, float L, float R) { + // TODO +} + +float joyAxisValue(IOHIDValueRef value) { + IOHIDElementRef element = IOHIDValueGetElement(value); + CFIndex val = IOHIDValueGetIntegerValue(value); + CFIndex min = IOHIDElementGetLogicalMin(element); + CFIndex max = IOHIDElementGetLogicalMax(element); + + float v = float(val - min) / float(max - min) * 2.0f - 1.0f; + if (v > -0.2f && v < 0.2f) v = 0.0f; // check for deadzone + return v; +} + +static const struct { uint32 vendorId, productId; } JOY_VENDORS[] = { + { 0x045E, 0x02FD }, // Microsoft Xbox One + { 0x045E, 0x0000 }, // Microsoft x360 + { 0x2DC8, 0x0000 }, // 8Bitdo + { 0x054C, 0x0CE6 }, // Sony DualSense + { 0x054C, 0x05C4 }, // Sony DS4 CUH-ZCT1x + { 0x054C, 0x09CC }, // Sony DS4 CUH-ZCT2x + { 0x054C, 0x0000 }, // Sony DS3 + { 0x2717, 0x0000 }, // Xiaomi + { 0x18D1, 0x9400 }, // Google Stadia Controller +}; + +#define JOY_MAX_VENDORS COUNT(JOY_VENDORS) +#define JOY_MAX_BUTTONS 17 + +static const uint32 joyAxisTable[][6] = { + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, kHIDUsage_GD_Z, kHIDUsage_GD_Rz }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Rx, kHIDUsage_GD_Ry, kHIDUsage_GD_Z, kHIDUsage_GD_Rz }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, 0, 0 }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, 0, 0 }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, 0, 0 }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, kHIDUsage_GD_Rx, kHIDUsage_GD_Ry }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, 0, 0 }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, 0, 0 }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, kHIDUsage_GD_Z, kHIDUsage_GD_Rz }, + { kHIDUsage_GD_X, kHIDUsage_GD_Y, kHIDUsage_GD_Z, kHIDUsage_GD_Rz, kHIDUsage_GD_Z, kHIDUsage_GD_Rz } +}; + +static const uint32 joyButtonsTable[][JOY_MAX_BUTTONS] = { + { jkA, jkB, jkNone, jkX, jkY, jkNone, jkLB, jkRB, jkNone, jkNone, jkNone, jkStart, jkNone, jkL, jkR, jkNone, jkNone }, + { jkA, jkB, jkX, jkY, jkLB, jkRB, jkLT, jkRT, jkStart, jkSelect, jkNone, jkUp, jkDown, jkLeft, jkRight, jkNone, jkNone }, + { jkB, jkA, jkNone, jkY, jkX, jkNone, jkLB, jkRB, jkLT, jkRT, jkSelect, jkStart, jkNone, jkL, jkR, jkNone, jkNone }, + { jkX, jkA, jkB, jkY, jkLB, jkRB, jkLT, jkRT, jkSelect, jkStart, jkL, jkR, jkNone, jkNone, jkNone, jkNone, jkNone }, + { jkX, jkA, jkB, jkY, jkLB, jkRB, jkLT, jkRT, jkSelect, jkStart, jkL, jkR, jkNone, jkNone, jkNone, jkNone, jkNone }, + { jkX, jkA, jkB, jkY, jkLB, jkRB, jkLT, jkRT, jkSelect, jkStart, jkL, jkR, jkNone, jkNone, jkNone, jkNone, jkNone }, + { jkSelect, jkL, jkR, jkStart, jkUp, jkRight, jkDown, jkLeft, jkLT, jkRT, jkLB, jkRB, jkY, jkB, jkA, jkX, jkNone }, + { jkA, jkB, jkNone, jkX, jkY, jkNone, jkLB, jkRB, jkLT, jkRT, jkSelect, jkStart, jkNone, jkL, jkR, jkNone, jkNone }, + { jkA, jkB, jkNone, jkX, jkY, jkNone, jkLB, jkRB, jkNone, jkNone, jkSelect, jkStart, jkNone, jkL, jkR, jkNone, jkNone } +}; + +JoyKey joyButtonToKey(const uint32 *btns, uint32 button) { + if (button >= 0 || button < JOY_MAX_BUTTONS) + return JoyKey(btns[button]); + return jkNone; +} + +void joyGetInfo(IOHIDDeviceRef device, uint32 &vendorId, uint32 &productId) { + vendorId = [(NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)) intValue]; + productId = [(NSNumber*)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey)) intValue]; +} + +uint32 joyGetVendorIndex(IOHIDDeviceRef device) { + uint32 vendorId, productId; + joyGetInfo(device, vendorId, productId); + + for (int i = 0; i < JOY_MAX_VENDORS; i++) { + if (JOY_VENDORS[i].vendorId == vendorId && (!JOY_VENDORS[i].productId || JOY_VENDORS[i].productId == productId)) { + return i; + } + } + return 0; // MS Xbox 360 as default +} + +void hidValueCallback(void *context, IOReturn result, void *sender, IOHIDValueRef value) { + if (result != kIOReturnSuccess) + return; + + IOHIDElementRef element = IOHIDValueGetElement(value); + IOHIDDeviceRef device = IOHIDElementGetDevice(element); + + int joyIndex = -1; + for (int i = 0; i < COUNT(joyDevices); i++) { + if (joyDevices[i] == device) { + joyIndex = i; + break; + } + } + + if (joyIndex == -1) return; + + uint32 page = IOHIDElementGetUsagePage(element); + uint32 usage = IOHIDElementGetUsage(element); + uint32 vendor = joyGetVendorIndex(joyDevices[joyIndex]); + + const uint32 *axis = joyAxisTable[vendor]; + const uint32 *btns = joyButtonsTable[vendor]; + + switch (page) { + case kHIDPage_GenericDesktop : { + if (usage == axis[0]) + Input::setJoyPos(joyIndex, jkL, vec2(joyAxisValue(value), Input::joy[joyIndex].L.y)); + else if (usage == axis[1]) + Input::setJoyPos(joyIndex, jkL, vec2(Input::joy[joyIndex].L.x, joyAxisValue(value))); + else if (usage == axis[2]) + Input::setJoyPos(joyIndex, jkR, vec2(joyAxisValue(value), Input::joy[joyIndex].R.y)); + else if (usage == axis[3]) + Input::setJoyPos(joyIndex, jkR, vec2(Input::joy[joyIndex].R.x, joyAxisValue(value))); + else if (usage == axis[4]) + Input::setJoyPos(joyIndex, jkLT, vec2(joyAxisValue(value) * 0.5f + 0.5f, 0.0f)); + else if (usage == axis[5]) + Input::setJoyPos(joyIndex, jkRT, vec2(joyAxisValue(value) * 0.5f + 0.5f, 0.0f)); + else if (usage == kHIDUsage_GD_Hatswitch) { + CFIndex p = IOHIDValueGetIntegerValue(value); + CFIndex min = IOHIDElementGetLogicalMin(element); + if (min == 0) + { + p++; + } + Input::setJoyDown(joyIndex, jkUp, p == 8 || p == 1 || p == 2); + Input::setJoyDown(joyIndex, jkRight, p == 2 || p == 3 || p == 4); + Input::setJoyDown(joyIndex, jkDown, p == 4 || p == 5 || p == 6); + Input::setJoyDown(joyIndex, jkLeft, p == 6 || p == 7 || p == 8); + } + //if (usage != axis[0] && usage != axis[1] && usage != axis[2] && usage != axis[3]) + // LOG("! joy: axis 0x%x (%d)\n", usage, (int)IOHIDValueGetIntegerValue(value)); + break; + } + case kHIDPage_Simulation : { + if (usage == kHIDUsage_Sim_Accelerator) + Input::setJoyPos(joyIndex, jkRT, vec2(joyAxisValue(value) * 0.5f + 0.5f, 0.0f)); + else if (usage == kHIDUsage_Sim_Brake) + Input::setJoyPos(joyIndex, jkLT, vec2(joyAxisValue(value) * 0.5f + 0.5f, 0.0f)); + break; + } + case kHIDPage_Button : { + uint32_t button = IOHIDElementGetUsage(IOHIDValueGetElement(value)) - kHIDUsage_Button_1; + bool down = IOHIDValueGetIntegerValue(value) != 0; + JoyKey key = joyButtonToKey(btns, button); + Input::setJoyDown(joyIndex, key, down); + //LOG("! joy: button %d\n", button); + break; + } + default : ; + } +} + +void joyAdd(void* context, IOReturn, void*, IOHIDDeviceRef device) { + for (int i = 0; i < COUNT(joyDevices); i++) { + if (joyDevices[i] == device) { + return; + } + } + + for (int i = 0; i < COUNT(joyDevices); i++) { + if (joyDevices[i] == NULL) { + uint32 vendorId, productId; + joyGetInfo(device, vendorId, productId); + LOG("! joy: add index:%d vendor:0x%04X product:0x%04X\n", i, vendorId, productId); + joyDevices[i] = device; + break; + } + } +} + +void joyRemove(void* context, IOReturn, void*, IOHIDDeviceRef device) { + for (int i = 0; i < COUNT(joyDevices); i++) { + if (joyDevices[i] == device) { + LOG("! joy: remove index:%d\n", i); + joyDevices[i] = NULL; + break; + } + } +} + +void joyInit() { + hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDManagerOptionNone); + + NSDictionary *matchingGamepad = @{ + @(kIOHIDDeviceUsagePageKey): @(kHIDPage_GenericDesktop), + @(kIOHIDDeviceUsageKey): @(kHIDUsage_GD_GamePad) + }; + NSDictionary *matchingJoystick = @{ + @(kIOHIDDeviceUsagePageKey): @(kHIDPage_GenericDesktop), + @(kIOHIDDeviceUsageKey): @(kHIDUsage_GD_Joystick) + }; + NSArray *matchDicts = @[ matchingGamepad, matchingJoystick ]; + + IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef) matchDicts); + IOHIDManagerRegisterDeviceMatchingCallback(hidManager, joyAdd, NULL); + IOHIDManagerRegisterDeviceRemovalCallback(hidManager, joyRemove, NULL); + IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone); + IOHIDManagerRegisterInputValueCallback(hidManager, hidValueCallback, NULL); + + CFSetRef devices = IOHIDManagerCopyDevices(hidManager); + if (devices) { + CFIndex count = CFSetGetCount(devices); + CFTypeRef devicesArray[count]; // array of IOHIDDeviceRef + CFSetGetValues(devices, devicesArray); + for (int i = 0; i < count; i++) { + joyAdd(NULL, 0, NULL, (IOHIDDeviceRef)devicesArray[i]); + } + CFRelease(devices); + } +} + +void joyFree() { + IOHIDManagerUnscheduleFromRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + IOHIDManagerRegisterDeviceMatchingCallback(hidManager, NULL, 0); + IOHIDManagerRegisterDeviceRemovalCallback(hidManager, NULL, 0); + IOHIDManagerClose(hidManager, kIOHIDOptionsTypeNone); +} + +NSWindow *window; + +@interface OpenLaraGLView : NSOpenGLView + +@end + +@implementation OpenLaraGLView + +- (InputKey)inputKeyForMouseEvent:(NSEvent *)theEvent { + switch (theEvent.buttonNumber) { + case 0 : return ikMouseL; + case 1 : return ikMouseR; + case 2 : return ikMouseM; + default : return ikNone; + } +} + +- (vec2)inputPositionForMouseEvent:(NSEvent *)theEvent { + NSPoint inWindow = theEvent.locationInWindow; + NSPoint inView = [self convertPoint:inWindow fromView:nil]; + return vec2(inView.x, Core::height - inView.y); +} + +- (void)mouseDown:(NSEvent *)theEvent { + InputKey inputKey = [self inputKeyForMouseEvent:theEvent]; + Input::setPos(inputKey, [self inputPositionForMouseEvent:theEvent]); + Input::setDown(inputKey, true); +} + +- (void)rightMouseDown:(NSEvent *)theEvent { + [self mouseDown:theEvent]; +} + +- (void)otherMouseDown:(NSEvent *)theEvent { + [self mouseDown:theEvent]; +} + +- (void)mouseUp:(NSEvent *)theEvent { + InputKey inputKey = [self inputKeyForMouseEvent:theEvent]; + Input::setPos(inputKey, [self inputPositionForMouseEvent:theEvent]); + Input::setDown(inputKey, false); +} + +- (void)rightMouseUp:(NSEvent *)theEvent { + [self mouseUp:theEvent]; +} + +- (void)otherMouseUp:(NSEvent *)theEvent { + [self mouseUp:theEvent]; +} + +- (void)mouseDragged:(NSEvent *)theEvent { + InputKey inputKey = [self inputKeyForMouseEvent:theEvent]; + Input::setPos(inputKey, [self inputPositionForMouseEvent:theEvent]); +} + +- (void)rightMouseDragged:(NSEvent *)theEvent { + [self mouseDragged:theEvent]; +} + +- (void)otherMouseDragged:(NSEvent *)theEvent { + [self mouseDragged:theEvent]; +} + +- (void)keyDown:(NSEvent *)theEvent { + unsigned short keyCode = theEvent.keyCode; + Input::setDown(keyToInputKey(keyCode), true); +} + +- (void)keyUp:(NSEvent *)theEvent { + unsigned short keyCode = theEvent.keyCode; + Input::setDown(keyToInputKey(keyCode), false); + if (keyCode == 36 && Input::down[ikAlt]) { // Alt + Enter + allowFrameUpdate = NO; + [window toggleFullScreen:nil]; + allowFrameUpdate = YES; + } +} + +- (void)flagsChanged:(NSEvent *)theEvent { + NSEventModifierFlags modifiers = theEvent.modifierFlags; + Input::setDown(ikShift, modifiers & NSEventModifierFlagShift); + Input::setDown(ikCtrl, modifiers & NSEventModifierFlagControl); + Input::setDown(ikAlt, modifiers & NSEventModifierFlagOption); +} + +- (BOOL)acceptsFirstResponder { + return YES; +} + +- (void)reshape { + CGSize drawableSize = self.bounds.size; + + if (enableRetina) + { + NSScreen* screen = self.window.screen ?: [NSScreen mainScreen]; + drawableSize.width *= screen.backingScaleFactor; + drawableSize.height *= screen.backingScaleFactor; + } + + Core::width = drawableSize.width; + Core::height = drawableSize.height; +} + +- (void)prepareOpenGL { + GLint swapInt = 1; + [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; +} + +int lastDeltaMs = 1; +BOOL allowFrameUpdate = YES; + +- (void)drawRect:(NSRect)dirtyRect { + + if(!allowFrameUpdate) { + return; + } + + int startDrawMs = Core::getTime(); + + NSOpenGLContext *context = [self openGLContext]; + + if (!Game::update()) + return; + Game::render(); + + [context flushBuffer]; + + int endDrawMs = Core::getTime(); + int deltaMs = endDrawMs - startDrawMs; + float avgDelta = ((lastDeltaMs + deltaMs) / 2.0); + lastDeltaMs = deltaMs; + + float nextDelaySec = (1000.0 / frameLimit) / 1000.0; + nextDelaySec = nextDelaySec - (avgDelta / 1000.0); + + BOOL arg = YES; + NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(setNeedsDisplay:)]]; + [inv setSelector:@selector(setNeedsDisplay:)]; + [inv setTarget:self]; + [inv setArgument:&arg atIndex:2]; + [inv performSelector:@selector(invoke) withObject:self afterDelay:nextDelaySec]; + + if (Core::isQuit) + { + NSApplication *application = [NSApplication sharedApplication]; + [application stop:nil]; + [application abortModal]; // generate UI event + } +} + +@end + +@interface OpenLaraWindowDelegate : NSObject +@end + +@implementation OpenLaraWindowDelegate + +- (void)windowWillClose:(NSNotification *)notification { + [[NSApplication sharedApplication] terminate:self]; +} + +@end + +int main() { + + //get and create support path + NSString *appName, *supportPath = nil; + NSArray *paths = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, + NSUserDomainMask, YES ); + if ( [paths count] > 0) + { + appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"]; + supportPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:appName]; + + if ( ![[NSFileManager defaultManager] fileExistsAtPath:supportPath] ) + if ( ![[NSFileManager defaultManager] createDirectoryAtPath:supportPath attributes:nil] ) + supportPath = nil; + } + + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + + NSApplication *application = [NSApplication sharedApplication]; + + // init window + NSRect rect = NSMakeRect(0, 0, 1280, 720); + window = [[NSWindow alloc] initWithContentRect:rect styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES]; + window.title = @"OpenLara"; + window.acceptsMouseMovedEvents = YES; + window.delegate = [[OpenLaraWindowDelegate alloc] init]; + + + // init OpenGL context + NSOpenGLPixelFormatAttribute attribs[] = { + NSOpenGLPFANoRecovery, + NSOpenGLPFAMultisample, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAColorSize, 32, + NSOpenGLPFADepthSize, 24, + NSOpenGLPFAStencilSize, 8, + NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)(MSAA == 0 ? 0 : 1), + NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)MSAA, + NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy, + 0 + }; + NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; + + OpenLaraGLView *view = [[OpenLaraGLView alloc] initWithFrame:window.contentLayoutRect pixelFormat:format]; + view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + window.contentView = view; + [view.openGLContext makeCurrentContext]; + [view setWantsBestResolutionOpenGLSurface:enableRetina]; + + // get path to game content + NSBundle *bundle = [NSBundle mainBundle]; + NSURL *resourceURL = bundle.resourceURL; + [resourceURL getFileSystemRepresentation:contentDir maxLength:sizeof(contentDir)]; + strcat(contentDir, "/"); + + [supportPath getCString:saveDir maxLength:sizeof(saveDir) encoding:NSUTF8StringEncoding]; + strcat(saveDir, "/"); + [supportPath getCString:cacheDir maxLength:sizeof(cacheDir) encoding:NSUTF8StringEncoding]; + strcat(cacheDir, "/"); + + // show window + [window center]; + [window makeKeyAndOrderFront:nil]; + + joyInit(); + sndInit(); + Game::init(); + + if (!Core::isQuit) { + [application run]; + } + + Game::deinit(); + joyFree(); + // TODO: sndFree + + return 0; +} diff --git a/src/platform/osx/main.cpp b/src/platform/osx/main_carbon_old.cpp similarity index 85% rename from src/platform/osx/main.cpp rename to src/platform/osx/main_carbon_old.cpp index 8ff8564f..eb6bd330 100644 --- a/src/platform/osx/main.cpp +++ b/src/platform/osx/main_carbon_old.cpp @@ -1,10 +1,9 @@ -#include #include "game.h" +bool isQuit = false; WindowRef window; AGLContext context; -// sound #define SND_SIZE 8192 static AudioQueueRef audioQueue; @@ -15,6 +14,7 @@ void soundFill(void* inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffe Sound::fill((Sound::Frame*)frames, count); inBuffer->mAudioDataByteSize = count * 4; AudioQueueEnqueueBuffer(audioQueue, inBuffer, 0, NULL); + // TODO: mutex } void soundInit() { @@ -42,7 +42,7 @@ void soundInit() { // common input functions InputKey keyToInputKey(int code) { static const int codes[] = { - 0x7B, 0x7C, 0x7E, 0x7D, 0x31, 0x30, 0x24, 0x35, 0x38, 0x3B, 0x3A, + 0x7B, 0x7C, 0x7E, 0x7D, 0x31, 0x24, 0x35, 0x38, 0x3B, 0x3A, 0x1D, 0x12, 0x13, 0x14, 0x15, 0x17, 0x16, 0x1A, 0x1C, 0x19, // 0..9 0x00, 0x0B, 0x08, 0x02, 0x0E, 0x03, 0x05, 0x04, 0x22, 0x26, 0x28, 0x25, 0x2E, // A..M 0x2D, 0x1F, 0x23, 0x0C, 0x0F, 0x01, 0x11, 0x20, 0x09, 0x0D, 0x07, 0x10, 0x06, // N..Z @@ -63,14 +63,6 @@ InputKey mouseToInputKey(int btn) { return ikNone; } -bool osJoyReady(int index) { - return false; -} - -void osJoyVibrate(int index, float L, float R) { - // TODO -} - OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userData) { OSType eventClass = GetEventClass(event); UInt32 eventKind = GetEventKind(event); @@ -79,7 +71,7 @@ OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userDat case kEventClassWindow : switch (eventKind) { case kEventWindowClosed : - Core::quit(); + isQuit = true; break; case kEventWindowBoundsChanged : { aglUpdateContext(context); @@ -146,23 +138,15 @@ OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userDat return CallNextEventHandler(handler, event); } -// timing -int osGetTime() { +int getTime() { UInt64 t; Microseconds((UnsignedWide*)&t); return int(t / 1000); } -int main() { - cacheDir[0] = saveDir[0] = contentDir[0] = 0; - - // get path to game content - CFBundleRef bundle = CFBundleGetMainBundle(); - CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); - CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); - CFStringGetFileSystemRepresentation(pathStr, contentDir, 230); - strcat(contentDir, "/Contents/Resources/"); +char *contentPath; +int main() { // init window Rect rect = {0, 0, 720, 1280}; CreateNewWindow(kDocumentWindowClass, kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowFullZoomAttribute | kWindowResizableAttribute | kWindowStandardHandlerAttribute, &rect, &window); @@ -184,6 +168,14 @@ int main() { aglSetDrawable(context, GetWindowPort(window)); aglSetCurrentContext(context); + // get path to game content + CFBundleRef bundle = CFBundleGetMainBundle(); + CFURLRef bundleURL = CFBundleCopyBundleURL(bundle); + CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); + contentPath = new char[1024]; + CFStringGetFileSystemRepresentation(pathStr, contentPath, 1024); + strcat(contentPath, "/Contents/Resources/"); + soundInit(); Game::init(); @@ -203,14 +195,38 @@ int main() { SelectWindow(window); ShowWindow(window); + int lastTime = getTime(), fpsTime = lastTime + 1000, fps = 0; + EventRecord event; - while (!Core::isQuit) - if (!GetNextEvent(0xffff, &event) && Game::update()) { + while (!isQuit) + if (!GetNextEvent(0xffff, &event)) { + int time = getTime(); + if (time <= lastTime) + continue; + + float delta = (time - lastTime) * 0.001f; + while (delta > EPS) { + Core::deltaTime = min(delta, 1.0f / 30.0f); + Game::update(); + delta -= Core::deltaTime; + } + lastTime = time; + + Core::stats.dips = 0; + Core::stats.tris = 0; Game::render(); aglSwapBuffers(context); + + if (fpsTime < getTime()) { + LOG("FPS: %d DIP: %d TRI: %d\n", fps, Core::stats.dips, Core::stats.tris); + fps = 0; + fpsTime = getTime() + 1000; + } else + fps++; } - Game::deinit(); + Game::free(); + delete[] contentPath; // TODO: sndFree aglSetCurrentContext(NULL); diff --git a/src/platform/psc/build.sh b/src/platform/psc/build.sh new file mode 100644 index 00000000..a12da44f --- /dev/null +++ b/src/platform/psc/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# This should really be a makefile with individual platforms but for now... +set -e +# General Info +GIT_COMMIT=$(echo "`git rev-parse --short HEAD``git diff-index --quiet HEAD -- || echo '-dirty'`") + +# Build Rules +[ -z "CXX" ] && CXX="arm-linux-gnueabihf-g++-8" +CFLAGS="-std=c++11 -Os -s -g -marm -march=armv8-a -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections" +LDFLAGS="-Wl,--gc-sections -static-libgcc -static-libstdc++" +DEFINES="-DNDEBUG -D__PSC__" +SRC="main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c" +INCLUDES="-I/usr/arm-linux-gnueabihf/include/ -I../../" +LIBS="-L$LD_LIBRARY_PATH -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev -lwayland-client -lwayland-egl" +TARGET="-o../../../bin/OpenLara" + +clear +echo "-------------------------------------------------------------------------------" +echo "OpenLara Builder v0.1 - OpenLara Build $GIT_COMMIT" +echo "-------------------------------------------------------------------------------" +echo "Build Rules:" +echo "CFLAGS: $CFLAGS" +echo "LDFLAGS: $LDFLAGS" +echo "DEFINES: $DEFINES" +echo "SRC: $SRC" +echo "INCLUDES: $INCLUDES" +echo "LIBS: $LIBS" +echo "TARGET: $TARGET" +echo "-------------------------------------------------------------------------------" +echo + +$CXX $CFLAGS $LDFLAGS $DEFINES $SRC $INCLUDES $LIBS $TARGET \ No newline at end of file diff --git a/src/platform/psc/main.cpp b/src/platform/psc/main.cpp new file mode 100644 index 00000000..7e586a48 --- /dev/null +++ b/src/platform/psc/main.cpp @@ -0,0 +1,592 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "game.h" + +#define WND_TITLE "OpenLara" + +#define WND_WIDTH 1280 +#define WND_HEIGHT 720 + +// timing +unsigned int startTime; + +int osGetTimeMS() { + timeval t; + gettimeofday(&t, NULL); + return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); +} + +// sound +snd_pcm_uframes_t SND_FRAMES = 512; +snd_pcm_t *sndOut; +Sound::Frame *sndData; +pthread_t sndThread; + +void* sndFill(void *arg) { + while (sndOut) { + Sound::fill(sndData, SND_FRAMES); + + int count = SND_FRAMES; + while (count > 0) { + int frames = snd_pcm_writei(sndOut, &sndData[SND_FRAMES - count], count); + if (frames < 0) { + frames = snd_pcm_recover(sndOut, frames, 0); + if (frames == -EAGAIN) { + LOG("snd_pcm_writei try again\n"); + sleep(1); + continue; + } + if (frames < 0) { + LOG("snd_pcm_writei failed: %s\n", snd_strerror(frames)); + sndOut = NULL; + return NULL; + } + } + count -= frames; + } + + snd_pcm_prepare(sndOut); + } + return NULL; +} + +bool sndInit() { + unsigned int freq = 44100; + + int err; + + // In the perfect world ReedPlayer-Clover process + // will release ALSA device before app running, but... + for (int i = 0; i < 20; i++) { // 20 * 0.1 = 2 secs + sndOut = NULL; + if ((err = snd_pcm_open(&sndOut, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + LOG("sound: try to snd_pcm_open #%d...\n", i); + usleep(100000); // wait for 100 ms + continue; + } + break; + } + + // I've bad news for you + if (!sndOut) { + LOG("! sound: snd_pcm_open %s\n", snd_strerror(err)); + return false; + } + + snd_pcm_hw_params_t *params; + + snd_pcm_hw_params_alloca(¶ms); + snd_pcm_hw_params_any(sndOut, params); + snd_pcm_hw_params_set_access(sndOut, params, SND_PCM_ACCESS_RW_INTERLEAVED); + + snd_pcm_hw_params_set_channels(sndOut, params, 2); + snd_pcm_hw_params_set_format(sndOut, params, SND_PCM_FORMAT_S16_LE); + snd_pcm_hw_params_set_rate_near(sndOut, params, &freq, NULL); + + snd_pcm_hw_params_set_periods(sndOut, params, 4, 0); + snd_pcm_hw_params_set_period_size_near(sndOut, params, &SND_FRAMES, NULL); + snd_pcm_hw_params_get_period_size(params, &SND_FRAMES, 0); + + snd_pcm_hw_params(sndOut, params); + snd_pcm_prepare(sndOut); + + sndData = new Sound::Frame[SND_FRAMES]; + memset(sndData, 0, SND_FRAMES * sizeof(Sound::Frame)); + if ((err = snd_pcm_writei(sndOut, sndData, SND_FRAMES)) < 0) { + LOG("! sound: write %s\n", snd_strerror(err)); + sndOut = NULL; + } + + snd_pcm_start(sndOut); + pthread_create(&sndThread, NULL, sndFill, NULL); + + return true; +} + +void sndFree() { + pthread_cancel(sndThread); + snd_pcm_drop(sndOut); + snd_pcm_drain(sndOut); + snd_pcm_close(sndOut); + delete[] sndData; +} + +// Window +wl_display *wlDisplay; +wl_compositor *wlCompositor = NULL; +wl_shell *wlShell = NULL; +wl_surface *wlSurface; +wl_shell_surface *wlShellSurface; +wl_egl_window *wlEGLWindow; + +EGLDisplay display; +EGLSurface surface; +EGLContext context; + +// Wayland Listeners +void wlEventObjectAdd(void* data, wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { + if (!strcmp(interface, "wl_compositor")) { + wlCompositor = (wl_compositor*)wl_registry_bind(registry, name, &wl_compositor_interface, 1); + } else if (!strcmp(interface, "wl_shell")) { + wlShell = (wl_shell*)wl_registry_bind(registry, name, &wl_shell_interface, 1); + } +} + +void wlEventObjectRemove(void* data, wl_registry* registry, uint32_t name) { + // +} + +wl_registry_listener wlRegistryListener = { + &wlEventObjectAdd, + &wlEventObjectRemove +}; + +void wlEventSurfacePing(void* data, wl_shell_surface* shell_surface, uint32_t serial) { + wl_shell_surface_pong(shell_surface, serial); +} + +void wlEventSurfaceConfig(void* data, wl_shell_surface* shell_surface, uint32_t edges, int32_t width, int32_t height) { + wl_egl_window_resize(wlEGLWindow, width, height, 0, 0); + Core::width = width; + Core::height = height; +} + +void wlEnentSurfacePopup(void* data, wl_shell_surface* shell_surface) { + // +} + +wl_shell_surface_listener wlSurfaceListener = { + &wlEventSurfacePing, + &wlEventSurfaceConfig, + &wlEnentSurfacePopup +}; + +void main_loop(void *data, wl_callback *callback, uint32_t time); + +bool configured = false; + +void configure_callback(void *data, wl_callback *callback, uint32_t time) { + wl_callback_destroy(callback); + configured = true; + main_loop(data, NULL, time); +} + +wl_callback_listener configure_callback_listener = { + configure_callback, +}; + +bool eglInit() { + LOG("EGL init context...\n"); + + wlDisplay = wl_display_connect(NULL); + wl_registry* registry = wl_display_get_registry(wlDisplay); + wl_registry_add_listener(registry, &wlRegistryListener, NULL); + wl_display_dispatch(wlDisplay); + + static const EGLint eglAttr[] = { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 24, + EGL_NONE + }; + + static const EGLint ctxAttr[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + display = eglGetDisplay((EGLNativeDisplayType)wlDisplay);; + if (display == EGL_NO_DISPLAY) { + LOG("eglGetDisplay = EGL_NO_DISPLAY\n"); + return false; + } + + if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { + LOG("eglInitialize = EGL_FALSE\n"); + return false; + } + + eglBindAPI(EGL_OPENGL_ES_API); + + EGLConfig config; + EGLint configCount; + + if (eglChooseConfig(display, eglAttr, &config, 1, &configCount) == EGL_FALSE) { + LOG("eglChooseConfig = EGL_FALSE\n"); + return false; + } + + context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctxAttr); + if (context == EGL_NO_CONTEXT) { + LOG("eglCreateContext = EGL_NO_CONTEXT\n"); + return false; + } + + wlSurface = wl_compositor_create_surface(wlCompositor); + wlShellSurface = wl_shell_get_shell_surface(wlShell, wlSurface); + wl_shell_surface_add_listener(wlShellSurface, &wlSurfaceListener, NULL); + wl_shell_surface_set_toplevel(wlShellSurface); + + wlEGLWindow = wl_egl_window_create(wlSurface, WND_WIDTH, WND_HEIGHT); + + surface = eglCreateWindowSurface(display, config, wlEGLWindow, NULL); + if (surface == EGL_NO_SURFACE) { + LOG("eglCreateWindowSurface = EGL_NO_SURFACE\n"); + return false; + } + + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { + LOG("eglMakeCurrent = EGL_FALSE\n"); + return false; + } + + wl_shell_surface_set_fullscreen(wlShellSurface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); + + wl_callback *callback = wl_display_sync(wlDisplay); + wl_callback_add_listener(callback, &configure_callback_listener, NULL); + + return true; +} + +void eglFree() { + LOG("EGL release context\n"); + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(display, surface); + wl_egl_window_destroy(wlEGLWindow); + wl_shell_surface_destroy(wlShellSurface); + wl_surface_destroy(wlSurface); + eglDestroyContext(display, context); + eglTerminate(display); + wl_display_disconnect(wlDisplay); +} + +// Input +#define MAX_INPUT_DEVICES 16 +struct InputDevice { + int fd; + int joyIndex; +} inputDevices[MAX_INPUT_DEVICES]; + +udev *udevObj; +udev_monitor *udevMon; +int udevMon_fd; + +vec2 joyL, joyR; + +bool osJoyReady(int index) { + return index == 0; // TODO +} + +void osJoyVibrate(int index, float L, float R) { + // TODO +} + +int inputDevIndex(const char *node) { + const char *str = strstr(node, "/event"); + if (str) + return atoi(str + 6); + return -1; +} + +void inputDevAdd(const char *node, udev_device *device) { + int index = inputDevIndex(node); + if (index != -1) { + InputDevice &item = inputDevices[index]; + item.fd = open(node, O_RDONLY | O_NONBLOCK); + ioctl(item.fd, EVIOCGRAB, 1); + + item.joyIndex = -1; + if (udev_device_get_property_value(device, "ID_INPUT_JOYSTICK")) { + + // TODO get index from /dev/input/js[N] + + for (int i = 0; i < 4; i++) { // up to 4 gamepads + bool found = true; + for (int j = 0; j < MAX_INPUT_DEVICES; j++) { + if (inputDevices[j].joyIndex == i) { + found = false; + break; + } + } + + if (found) { + item.joyIndex = i; + break; + } + } + } + + //LOG("input: add %s (%d)\n", node, item.joyIndex); + } +} + +void inputDevRemove(const char *node) { + int index = inputDevIndex(node); + if (index != -1 && inputDevices[index].fd != -1) { + close(inputDevices[index].fd); + //LOG("input: remove %s\n", node); + } +} + +bool inputInit() { + joyL = joyR = vec2(0); + + for (int i = 0; i < MAX_INPUT_DEVICES; i++) { + inputDevices[i].fd = -1; + inputDevices[i].joyIndex = -1; + } + + udevObj = udev_new(); + if (!udevObj) + return false; + + udevMon = udev_monitor_new_from_netlink(udevObj, "udev"); + udev_monitor_filter_add_match_subsystem_devtype(udevMon, "input", NULL); + udev_monitor_enable_receiving(udevMon); + udevMon_fd = udev_monitor_get_fd(udevMon); + + udev_enumerate *e = udev_enumerate_new(udevObj); + udev_enumerate_add_match_subsystem(e, "input"); + udev_enumerate_scan_devices(e); + udev_list_entry *devices = udev_enumerate_get_list_entry(e); + + udev_list_entry *entry; + udev_list_entry_foreach(entry, devices) { + const char *path, *node; + udev_device *device; + + path = udev_list_entry_get_name(entry); + device = udev_device_new_from_syspath(udevObj, path); + node = udev_device_get_devnode(device); + + if (node) + inputDevAdd(node, device); + } + udev_enumerate_unref(e); + + return true; +} + +void inputFree() { + for (int i = 0; i < MAX_INPUT_DEVICES; i++) + if (inputDevices[i].fd != -1) + close(inputDevices[i].fd); + udev_monitor_unref(udevMon); + udev_unref(udevObj); +} + +#define JOY_DEAD_ZONE_STICK 8192 + +float joyAxisValue(int value) { + if (value > -JOY_DEAD_ZONE_STICK && value < JOY_DEAD_ZONE_STICK) + return 0.0f; + return value / 32767.0f; +} + +float joyTrigger(int value) { + return min(1.0f, value / 255.0f); +} + +vec2 joyDir(const vec2 &value) { + float dist = min(1.0f, value.length()); + return value.normal() * dist; +} + +JoyKey codeToJoyKey(int code) { + switch (code) { + // gamepad + case BTN_B : return jkB; + case BTN_C : return jkA; + case BTN_A : return jkY; + case BTN_X : return jkX; + case BTN_TL : return jkLB; + case BTN_TR : return jkRB; + case BTN_TL2 : return jkSelect; + case BTN_TR2 : return jkStart; + case BTN_Y : return jkLT; + case BTN_Z : return jkRT; + } + return jkNone; +} + +void inputUpdate() { +// get input events + input_event events[16]; + + for (int i = 0; i < MAX_INPUT_DEVICES; i++) { + if (inputDevices[i].fd == -1) continue; + int rb = read(inputDevices[i].fd, events, sizeof(events)); + + int joyIndex = inputDevices[i].joyIndex; + if (joyIndex == -1) continue; + + input_event *e = events; + while (rb > 0) { + switch (e->type) { + case EV_KEY : { + JoyKey key = codeToJoyKey(e->code); + Input::setJoyDown(joyIndex, key, e->value != 0); + break; + } + case EV_ABS : { + switch (e->code) { + case ABS_X : { + if (e->value == 1) { + Input::setJoyDown(joyIndex, jkLeft, false); + Input::setJoyDown(joyIndex, jkRight, false); + } else { + Input::setJoyDown(joyIndex, e->value ? jkRight : jkLeft, true); + } + break; + } + case ABS_Y : { + if (e->value == 1) { + Input::setJoyDown(joyIndex, jkUp, false); + Input::setJoyDown(joyIndex, jkDown, false); + } else { + Input::setJoyDown(joyIndex, e->value ? jkDown : jkUp, true); + } + break; + } + } + } + } + //LOG("input: type = %d, code = %d, value = %d\n", int(e->type), int(e->code), int(e->value)); + e++; + rb -= sizeof(events[0]); + } + } + +// monitoring plug and unplug input devices + fd_set fds; + FD_ZERO(&fds); + FD_SET(udevMon_fd, &fds); + + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + + if (select(udevMon_fd + 1, &fds, NULL, NULL, &tv) > 0 && FD_ISSET(udevMon_fd, &fds)) { + udev_device *device = udev_monitor_receive_device(udevMon); + if (device) { + const char *node = udev_device_get_devnode(device); + if (node) { + const char *action = udev_device_get_action(device); + if (!strcmp(action, "add")) + inputDevAdd(node, device); + if (!strcmp(action, "remove")) + inputDevRemove(node); + } + udev_device_unref(device); + } else + LOG("! input: receive_device\n"); + } +} + +wl_callback_listener frame_listener = { + main_loop +}; + +void main_loop(void *data, wl_callback *callback, uint32_t time) { + if (!configured) + return; + + if (callback) { + wl_callback_destroy(callback); + } + + inputUpdate(); + + Game::update(); + Game::render(); + Core::waitVBlank(); + + wl_region *region = wl_compositor_create_region(wlCompositor); + wl_region_add(region, 0, 0, Core::width, Core::height); + wl_surface_set_opaque_region(wlSurface, region); + wl_region_destroy(region); + + { + wl_callback *callback = wl_surface_frame(wlSurface); + wl_callback_add_listener(callback, &frame_listener, NULL); + } + + eglSwapBuffers(display, surface); +} + +int main(int argc, char **argv) { + if (!eglInit()) { + LOG("! can't initialize EGL context\n"); + return -1; + } + + //Core::width = fb.width; + //Core::height = fb.height; + + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + + strcpy(contentDir, argv[0]); + int i = strlen(contentDir); + while (--i >= 0) { + if (contentDir[i] == '/') { + contentDir[i + 1] = 0; + break; + } + i--; + } + + strcpy(cacheDir, contentDir); + strcat(cacheDir, "cache/"); + + struct stat st = {0}; + if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1) + cacheDir[0] = 0; + + const char *home; + if (!(home = getenv("HOME"))) + home = getpwuid(getuid())->pw_dir; + strcpy(saveDir, home); + strcat(saveDir, "/.openlara/"); + + if (stat(saveDir, &st) == -1 && mkdir(saveDir, 0777) == -1) + saveDir[0] = 0; + + timeval t; + gettimeofday(&t, NULL); + startTime = t.tv_sec; + + Game::init(); + inputInit(); + sndInit(); + + while (!Core::isQuit && wl_display_dispatch(wlDisplay) != -1); + + inputFree(); + + Game::deinit(); + eglFree(); + + sndFree(); + + return 0; +} diff --git a/src/platform/psp/main.cpp b/src/platform/psp/main.cpp index 1b30fe56..05325064 100644 --- a/src/platform/psp/main.cpp +++ b/src/platform/psp/main.cpp @@ -87,7 +87,7 @@ void osRWUnlockWrite(void *obj) { int osStartTime = 0; int osTimerFreq; -int osGetTime() { +int osGetTimeMS() { u64 time; sceRtcGetCurrentTick(&time); return int(time * 1000 / osTimerFreq - osStartTime); @@ -160,7 +160,7 @@ int main() { joyInit(); osTimerFreq = sceRtcGetTickResolution(); - osStartTime = osGetTime(); + osStartTime = Core::getTime(); Game::init(); diff --git a/src/platform/psv/CMakeLists.txt b/src/platform/psv/CMakeLists.txt index 733d8429..863aac8f 100644 --- a/src/platform/psv/CMakeLists.txt +++ b/src/platform/psv/CMakeLists.txt @@ -17,8 +17,8 @@ set(VITA_APP_NAME "OpenLara") set(VITA_TITLEID "OPENLARA1") set(VITA_VERSION "01.00") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -std=c++11") set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1") include_directories( @@ -44,6 +44,7 @@ target_link_libraries(OpenLara SceCtrl_stub SceAudio_stub SceTouch_stub + SceAppUtil_stub ) diff --git a/src/platform/psv/deploy.sh b/src/platform/psv/deploy.sh new file mode 100644 index 00000000..8ac45f49 --- /dev/null +++ b/src/platform/psv/deploy.sh @@ -0,0 +1,3 @@ +make +curl --ftp-method nocwd -T OpenLara.self ftp://192.168.1.59:1337/ux0:/app/OPENLARA1/eboot.bin +echo launch OPENLARA1 | ./nc.exe 192.168.1.59 1338 diff --git a/src/platform/psv/main.cpp b/src/platform/psv/main.cpp index 506a0ae7..60150add 100644 --- a/src/platform/psv/main.cpp +++ b/src/platform/psv/main.cpp @@ -1,37 +1,40 @@ #include #include #include +#include #include "debugScreen.h" - -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "game.h" // multi-threading -void* osMutexInit() { - SceUID *mutex = new SceUID(); - *mutex = sceKernelCreateMutex(NULL, 0, 0, NULL); +void* osMutexInit() +{ + SceUID mutex = sceKernelCreateMutex(NULL, SCE_KERNEL_MUTEX_ATTR_RECURSIVE, 0, NULL); + if (mutex < 0) + { + return NULL; + } + SceUID* obj = new SceUID(); + *obj = mutex; + return obj; } -void osMutexFree(void *obj) { +void osMutexFree(void *obj) +{ sceKernelDeleteMutex(*(SceUID*)obj); delete (SceUID*)obj; } -void osMutexLock(void *obj) { +void osMutexLock(void *obj) +{ sceKernelLockMutex(*(SceUID*)obj, 1, NULL); } -void osMutexUnlock(void *obj) { +void osMutexUnlock(void *obj) +{ sceKernelUnlockMutex(*(SceUID*)obj, 1); } @@ -39,28 +42,33 @@ void osMutexUnlock(void *obj) { int osStartTime = 0; int osTimerFreq; -int osGetTime() { +int osGetTimeMS() +{ SceRtcTick current; sceRtcGetCurrentTick(¤t); return int(current.tick * 1000 / osTimerFreq - osStartTime); } // input -bool osJoyReady(int index) { +bool osJoyReady(int index) +{ return index == 0; } -void osJoyVibrate(int index, float L, float R) { +void osJoyVibrate(int index, float L, float R) +{ // } -void inputInit() { +void inputInit() +{ sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG); sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT); } -void inputUpdate() { +void inputUpdate() +{ // gamepad SceCtrlData pad; sceCtrlReadBufferPositive(0, &pad, 1); @@ -80,8 +88,8 @@ void inputUpdate() { vec2 stickL = vec2(float(pad.lx), float(pad.ly)) / 128.0f - 1.0f; vec2 stickR = vec2(float(pad.rx), float(pad.ry)) / 128.0f - 1.0f; - if (fabsf(stickL.x) < 0.2f && fabsf(stickL.y) < 0.2f) stickL = vec2(0.0f); - if (fabsf(stickR.x) < 0.2f && fabsf(stickR.y) < 0.2f) stickR = vec2(0.0f); + if (fabsf(stickL.x) < 0.3f && fabsf(stickL.y) < 0.3f) stickL = vec2(0.0f); + if (fabsf(stickR.x) < 0.3f && fabsf(stickR.y) < 0.3f) stickR = vec2(0.0f); Input::setJoyPos(0, jkL, stickL); Input::setJoyPos(0, jkR, stickR); @@ -91,9 +99,12 @@ void inputUpdate() { bool touchState[COUNT(Input::touch)]; for (int i = 0; i < COUNT(Input::touch); i++) + { touchState[i] = Input::down[ikTouchA + i]; + } - for (int i = 0; i < touch.reportNum; i++) { + for (int i = 0; i < touch.reportNum; i++) + { SceTouchReport &t = touch.report[i]; InputKey key = Input::getTouch(t.id); @@ -106,8 +117,12 @@ void inputUpdate() { } for (int i = 0; i < COUNT(Input::touch); i++) + { if (touchState[i]) + { Input::setDown(InputKey(ikTouchA + i), false); + } + } } bool sndTerm; @@ -119,8 +134,10 @@ Sound::Frame *sndBuffer; #define SND_FRAMES 2048 -int sndPrepThread(SceSize args, void *argp) { - while (!sndTerm) { +int sndPrepThread(SceSize args, void *argp) +{ + while (!sndTerm) + { sceKernelWaitSema(sndSema, 1, NULL); sndPartIndex ^= 1; Sound::Frame *part = sndBuffer + SND_FRAMES * sndPartIndex; @@ -129,8 +146,10 @@ int sndPrepThread(SceSize args, void *argp) { return 0; } -int sndOutThread(SceSize args, void *argp) { - while (!sndTerm) { +int sndOutThread(SceSize args, void *argp) +{ + while (!sndTerm) + { Sound::Frame *part = sndBuffer + SND_FRAMES * sndPartIndex; sceKernelSignalSema(sndSema, 1); sceAudioOutOutput(sndPort, part); @@ -138,7 +157,8 @@ int sndOutThread(SceSize args, void *argp) { return 0; } -void sndInit() { +void sndInit() +{ sndTerm = false; sndPartIndex = 0; @@ -158,7 +178,8 @@ void sndInit() { sceKernelStartThread(sndOutTID, 0, NULL); } -void sndFree() { +void sndFree() +{ sndTerm = true; sceKernelSignalSema(sndSema, 1); @@ -173,8 +194,37 @@ void sndFree() { free(sndBuffer); } +int checkLanguage() +{ + int id; + sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &id); + + int str = STR_LANG_EN; + switch (id) + { + case SCE_SYSTEM_PARAM_LANG_ENGLISH_US : + case SCE_SYSTEM_PARAM_LANG_ENGLISH_GB : str = STR_LANG_EN; break; + case SCE_SYSTEM_PARAM_LANG_FRENCH : str = STR_LANG_FR; break; + case SCE_SYSTEM_PARAM_LANG_GERMAN : str = STR_LANG_DE; break; + case SCE_SYSTEM_PARAM_LANG_SPANISH : str = STR_LANG_ES; break; + case SCE_SYSTEM_PARAM_LANG_ITALIAN : str = STR_LANG_IT; break; + case SCE_SYSTEM_PARAM_LANG_POLISH : str = STR_LANG_PL; break; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT : + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR : str = STR_LANG_PT; break; + case SCE_SYSTEM_PARAM_LANG_RUSSIAN : str = STR_LANG_RU; break; + case SCE_SYSTEM_PARAM_LANG_JAPANESE : str = STR_LANG_JA; break; + case SCE_SYSTEM_PARAM_LANG_FINNISH : str = STR_LANG_FI; break; + case SCE_SYSTEM_PARAM_LANG_CHINESE_T : + case SCE_SYSTEM_PARAM_LANG_CHINESE_S : str = STR_LANG_CN; break; + case SCE_SYSTEM_PARAM_LANG_SWEDISH : str = STR_LANG_SV; break; + } + return str - STR_LANG_EN; +} -int main() { +extern "C" int32_t sceKernelChangeThreadVfpException(int32_t clear, int32_t set); + +int main() +{ psvDebugScreenInit(); scePowerSetArmClockFrequency(444); @@ -182,16 +232,28 @@ int main() { scePowerSetGpuClockFrequency(222); scePowerSetGpuXbarClockFrequency(166); + { + SceAppUtilInitParam initParam = {}; + SceAppUtilBootParam bootParam = {}; + sceAppUtilInit(&initParam, &bootParam); + } + + sceKernelChangeThreadVfpException(0x0800009FU, 0x0); + cacheDir[0] = saveDir[0] = contentDir[0] = 0; strcpy(cacheDir, "ux0:data/OpenLara/"); strcpy(saveDir, "ux0:data/OpenLara/"); strcpy(contentDir, "ux0:data/OpenLara/"); + Stream::init(); + + Core::defLang = checkLanguage(); + sndInit(); inputInit(); osTimerFreq = sceRtcGetTickResolution(); - osStartTime = osGetTime(); + osStartTime = osGetTimeMS(); Game::init(); @@ -199,12 +261,16 @@ int main() { inputUpdate(); if (Input::joy[0].down[jkStart]) + { Core::quit(); + } Game::update(); Game::render(); GAPI::present(); + + sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DEFAULT); } sndFree(); diff --git a/src/platform/psv/sce_sys/icon0.png b/src/platform/psv/sce_sys/icon0.png index bb54cf58..94c68fa3 100644 Binary files a/src/platform/psv/sce_sys/icon0.png and b/src/platform/psv/sce_sys/icon0.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/bg.png b/src/platform/psv/sce_sys/livearea/contents/bg.png index 23a9f3b5..259af4a3 100644 Binary files a/src/platform/psv/sce_sys/livearea/contents/bg.png and b/src/platform/psv/sce_sys/livearea/contents/bg.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/startup.png b/src/platform/psv/sce_sys/livearea/contents/startup.png index 9f2bf25e..ce0ec882 100644 Binary files a/src/platform/psv/sce_sys/livearea/contents/startup.png and b/src/platform/psv/sce_sys/livearea/contents/startup.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/template.xml b/src/platform/psv/sce_sys/livearea/contents/template.xml index a4d43f01..b934a299 100644 --- a/src/platform/psv/sce_sys/livearea/contents/template.xml +++ b/src/platform/psv/sce_sys/livearea/contents/template.xml @@ -1,6 +1,6 @@ - + bg.png diff --git a/src/platform/rpi/build.sh b/src/platform/rpi/build.sh index f518ddcb..44a8d659 100755 --- a/src/platform/rpi/build.sh +++ b/src/platform/rpi/build.sh @@ -1,3 +1,3 @@ set -e -clang++ -std=c++11 -Os -s -g -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__RPI__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I/opt/vc/include -I../../ -o../../../bin/OpenLara -L/opt/vc/lib/ -lbrcmGLESv2 -lbrcmEGL -lX11 -lm -lrt -lpthread -lasound -lbcm_host -ludev +clang++ -std=c++11 -Os -s -g -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -Wno-invalid-source-encoding -DNDEBUG -D__RPI__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I/opt/vc/include -I../../ -o../../../bin/OpenLara -L/opt/vc/lib/ -lbrcmGLESv2 -lbrcmEGL -lm -lrt -lpthread -lasound -lbcm_host -ludev strip ../../../bin/OpenLara --strip-all --remove-section=.comment --remove-section=.note diff --git a/src/platform/rpi/main.cpp b/src/platform/rpi/main.cpp index da2ee1e1..1d936a86 100644 --- a/src/platform/rpi/main.cpp +++ b/src/platform/rpi/main.cpp @@ -19,7 +19,7 @@ // timing unsigned int startTime; -int osGetTime() { +int osGetTimeMS() { timeval t; gettimeofday(&t, NULL); return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); @@ -197,6 +197,7 @@ int inputDevices[MAX_INPUT_DEVICES]; udev *udevObj; udev_monitor *udevMon; int udevMon_fd; +int joy_centre; vec2 joyL, joyR; @@ -347,6 +348,10 @@ bool inputInit() { } udev_enumerate_unref(e); + const char *temp = getenv("JOY_CENTRE"); + if (temp && (joy_centre = atoi(temp))) + LOG("input: joy centred at %d\n", joy_centre); + return true; } @@ -359,11 +364,13 @@ void inputFree() { } #define JOY_DEAD_ZONE_STICK 8192 +#define JOY_CENTRE 32768 float joyAxisValue(int value) { + value -= joy_centre ? joy_centre : JOY_CENTRE; if (value > -JOY_DEAD_ZONE_STICK && value < JOY_DEAD_ZONE_STICK) return 0.0f; - return value / 32767.0f; + return value / 32768.0f; } float joyTrigger(int value) { @@ -469,6 +476,34 @@ void inputUpdate() { EGLDisplay display; +int checkLanguage() { + char *lang = getenv("LANG"); + if (!lang || strlen(lang) < 2) return 0; + + uint16 id; + memcpy(&id, lang, 2); + + if (id == TWOCC("en")) return STR_LANG_EN - STR_LANG_EN; + if (id == TWOCC("fr")) return STR_LANG_FR - STR_LANG_EN; + if (id == TWOCC("de")) return STR_LANG_DE - STR_LANG_EN; + if (id == TWOCC("es")) return STR_LANG_ES - STR_LANG_EN; + if (id == TWOCC("it")) return STR_LANG_IT - STR_LANG_EN; + if (id == TWOCC("pl")) return STR_LANG_PL - STR_LANG_EN; + if (id == TWOCC("pt")) return STR_LANG_PT - STR_LANG_EN; + if (id == TWOCC("uk")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("be")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("ru")) return STR_LANG_RU - STR_LANG_EN; + if (id == TWOCC("ja")) return STR_LANG_JA - STR_LANG_EN; + if (id == TWOCC("gr")) return STR_LANG_GR - STR_LANG_EN; + if (id == TWOCC("fi")) return STR_LANG_FI - STR_LANG_EN; + if (id == TWOCC("cs")) return STR_LANG_CZ - STR_LANG_EN; + if (id == TWOCC("zh")) return STR_LANG_CN - STR_LANG_EN; + if (id == TWOCC("hu")) return STR_LANG_HU - STR_LANG_EN; + if (id == TWOCC("sv")) return STR_LANG_SV - STR_LANG_EN; + + return 0; +} + int main(int argc, char **argv) { bcm_host_init(); @@ -502,6 +537,8 @@ int main(int argc, char **argv) { timeval t; gettimeofday(&t, NULL); startTime = t.tv_sec; + + Core::defLang = checkLanguage(); sndInit(); diff --git a/src/platform/sdl2/Makefile b/src/platform/sdl2/Makefile new file mode 100644 index 00000000..064300fc --- /dev/null +++ b/src/platform/sdl2/Makefile @@ -0,0 +1,27 @@ +SRCS=main.cpp \ + ../../libs/stb_vorbis/stb_vorbis.c \ + ../../libs/minimp3/minimp3.cpp \ + ../../libs/tinf/tinflate.c +CC=g++ + +SDL_CFLAGS := $(shell sdl2-config --cflags) +SDL_LDFLAGS := $(shell sdl2-config --libs) + +CFLAGS+=-DSDL2_GLES -D_GAPI_GLES2 -std=c++11 -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -D__SDL2__ $(SDL_CFLAGS) -Wall +LDFLAGS+=-lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev $(SDL_LDFLAGS) + +INCLUDES+=-I../../ + +openlara : + $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(SRCS) -o $@ + +install : openlara + install -d $(DESTDIR)$(PREFIX)/bin/ + install openlara $(DESTDIR)$(PREFIX)/bin/OpenLara + +uninstall : + rm -f $(DESTDIR)$(PREFIX)/bin/OpenLara + +clean: + rm -f OpenLara + diff --git a/src/platform/sdl2/build.sh b/src/platform/sdl2/build.sh new file mode 100755 index 00000000..fd4046aa --- /dev/null +++ b/src/platform/sdl2/build.sh @@ -0,0 +1,10 @@ +set -e + +# Use this compilation line to build SDL2/GLES version, GLES2 version. +g++ -DSDL2_GLES -D_GAPI_GLES2 -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev + +# Use this compilation line to build SDL2/GLES version, GLES3, which is an extension to GLES2 so we use -lGLESv2, too. +#g++ -DSDL2_GLES -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGLESv2 -lEGL -lm -lrt -lpthread -lasound -ludev + +# Use this compilation line to build SDL2/OpenGL version. +#g++ -std=c++11 `sdl2-config --cflags` -O3 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DNDEBUG -D__SDL2__ -D_SDL2_OPENGL main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o OpenLara `sdl2-config --libs` -lGL -lm -lrt -lpthread -lasound -ludev diff --git a/src/platform/sdl2/main.cpp b/src/platform/sdl2/main.cpp new file mode 100644 index 00000000..06cf9254 --- /dev/null +++ b/src/platform/sdl2/main.cpp @@ -0,0 +1,603 @@ +#include +#include +#include +#include +#include + +#include + +#include "game.h" + +#define WND_TITLE "OpenLara" + +// timing +unsigned int startTime; + +int osGetTimeMS() { + timeval t; + gettimeofday(&t, NULL); + return int((t.tv_sec - startTime) * 1000 + t.tv_usec / 1000); +} + +// sound +#define SND_FRAME_SIZE 4 +#define SND_FRAMES 1024 + +// A Frame is a struct containing: int16 L, int16 R. +Sound::Frame *sndData; +SDL_AudioDeviceID sdl_audiodev; + +void sndFill(void *udata, Uint8 *stream, int len) { + // Let's milk the audio subsystem for SND_FRAMES frames! + Sound::fill(sndData, SND_FRAMES); + // We have the number of samples, but each sample is 4 bytes long (16bit stereo sound), + // and memcpy copies a number of bytes. + memcpy (stream, sndData, SND_FRAMES * SND_FRAME_SIZE); +} + +bool sndInit() { + int FREQ = 44100; + + SDL_AudioSpec desired, obtained; + + desired.freq = FREQ; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = SND_FRAMES; + desired.callback = sndFill; + desired.userdata = NULL; + + sdl_audiodev = SDL_OpenAudioDevice(NULL, 0, &desired, &obtained, /*SDL_AUDIO_ALLOW_FORMAT_CHANGE*/0); + if (sdl_audiodev == 0) + { + LOG ("SDL2: error opening audio device: %s\n", SDL_GetError()); + return false; + } + + if (desired.samples != obtained.samples) { + LOG ("SDL2: number of samples not supported by device. Watch out for buggy audio drivers!\n"); + return false; + } + + // Initialize audio buffer and fill it with zeros + sndData = new Sound::Frame[SND_FRAMES]; + memset(sndData, 0, SND_FRAMES * SND_FRAME_SIZE); + + SDL_PauseAudioDevice(sdl_audiodev,0); + + return true; +} + +void sndFree() { + SDL_PauseAudioDevice(sdl_audiodev,1); + SDL_CloseAudioDevice(sdl_audiodev); + + // Delete the audio buffer + delete[] sndData; +} + +// Input + +#define MAX_JOYS 4 +#define JOY_DEAD_ZONE_STICK 8192 +#define WIN_W 640 +#define WIN_H 480 + +struct sdl_input *sdl_inputs; +int sdl_numjoysticks, sdl_numcontrollers; +SDL_Joystick *sdl_joysticks[MAX_JOYS]; +SDL_GameController *sdl_controllers[MAX_JOYS]; +SDL_Haptic *sdl_haptics[MAX_JOYS]; +SDL_Window *sdl_window; +SDL_DisplayMode sdl_displaymode; + +bool fullscreen; + +vec2 joyL, joyR; + +bool osJoyReady(int index) { + return index == 0; // TODO +} + +void osJoyVibrate(int index, float L, float R) { + if (index >= sdl_numcontrollers) + return; + if (SDL_IsGameController(index)) { + SDL_GameControllerRumble(sdl_controllers[index], L*0xFFFF, R*0xFFFF, 500); + } else { + SDL_HapticRumblePlay(sdl_haptics[index], L+R, 500); + } +} + +bool isKeyPressed (SDL_Scancode scancode) { + const Uint8 *state = SDL_GetKeyboardState(NULL); + if (state[scancode]) { + return true; + } + return false; +} + +#ifndef _GAPI_GLES +void toggleFullscreen () { + + Uint32 flags = 0; + + fullscreen = !fullscreen; + + flags = fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0; + + SDL_SetWindowFullscreen (sdl_window, flags); + + // Tell the engine we have changed display size! + Core::width = fullscreen ? sdl_displaymode.w : WIN_W; + Core::height = fullscreen ? sdl_displaymode.h : WIN_H; +} +#endif + +InputKey codeToInputKey(int code) { + switch (code) { + // keyboard + case SDL_SCANCODE_LEFT : return ikLeft; + case SDL_SCANCODE_RIGHT : return ikRight; + case SDL_SCANCODE_UP : return ikUp; + case SDL_SCANCODE_DOWN : return ikDown; + case SDL_SCANCODE_SPACE : return ikSpace; + case SDL_SCANCODE_TAB : return ikTab; + case SDL_SCANCODE_RETURN : return ikEnter; + case SDL_SCANCODE_ESCAPE : return ikEscape; + case SDL_SCANCODE_LSHIFT : + case SDL_SCANCODE_RSHIFT : return ikShift; + case SDL_SCANCODE_LCTRL : + case SDL_SCANCODE_RCTRL : return ikCtrl; + case SDL_SCANCODE_LALT : + case SDL_SCANCODE_RALT : return ikAlt; + case SDL_SCANCODE_0 : return ik0; + case SDL_SCANCODE_1 : return ik1; + case SDL_SCANCODE_2 : return ik2; + case SDL_SCANCODE_3 : return ik3; + case SDL_SCANCODE_4 : return ik4; + case SDL_SCANCODE_5 : return ik5; + case SDL_SCANCODE_6 : return ik6; + case SDL_SCANCODE_7 : return ik7; + case SDL_SCANCODE_8 : return ik8; + case SDL_SCANCODE_9 : return ik9; + case SDL_SCANCODE_A : return ikA; + case SDL_SCANCODE_B : return ikB; + case SDL_SCANCODE_C : return ikC; + case SDL_SCANCODE_D : return ikD; + case SDL_SCANCODE_E : return ikE; + case SDL_SCANCODE_F : return ikF; + case SDL_SCANCODE_G : return ikG; + case SDL_SCANCODE_H : return ikH; + case SDL_SCANCODE_I : return ikI; + case SDL_SCANCODE_J : return ikJ; + case SDL_SCANCODE_K : return ikK; + case SDL_SCANCODE_L : return ikL; + case SDL_SCANCODE_M : return ikM; + case SDL_SCANCODE_N : return ikN; + case SDL_SCANCODE_O : return ikO; + case SDL_SCANCODE_P : return ikP; + case SDL_SCANCODE_Q : return ikQ; + case SDL_SCANCODE_R : return ikR; + case SDL_SCANCODE_S : return ikS; + case SDL_SCANCODE_T : return ikT; + case SDL_SCANCODE_U : return ikU; + case SDL_SCANCODE_V : return ikV; + case SDL_SCANCODE_W : return ikW; + case SDL_SCANCODE_X : return ikX; + case SDL_SCANCODE_Y : return ikY; + case SDL_SCANCODE_Z : return ikZ; + case SDL_SCANCODE_AC_HOME : return ikEscape; + } + return ikNone; +} + +JoyKey controllerCodeToJoyKey(int code) { +// joystick using the modern SDL GameController interface + switch (code) { + case SDL_CONTROLLER_BUTTON_A : return jkA; + case SDL_CONTROLLER_BUTTON_B : return jkB; + case SDL_CONTROLLER_BUTTON_X : return jkX; + case SDL_CONTROLLER_BUTTON_Y : return jkY; + case SDL_CONTROLLER_BUTTON_LEFTSHOULDER : return jkLB; + case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER : return jkRB; + case SDL_CONTROLLER_BUTTON_BACK : return jkSelect; + case SDL_CONTROLLER_BUTTON_START : return jkStart; + case SDL_CONTROLLER_BUTTON_LEFTSTICK : return jkL; + case SDL_CONTROLLER_BUTTON_RIGHTSTICK : return jkR; + case SDL_CONTROLLER_BUTTON_DPAD_UP : return jkUp; + case SDL_CONTROLLER_BUTTON_DPAD_DOWN : return jkDown; + case SDL_CONTROLLER_BUTTON_DPAD_LEFT : return jkLeft; + case SDL_CONTROLLER_BUTTON_DPAD_RIGHT : return jkRight; + } + return jkNone; +} + +JoyKey joyCodeToJoyKey(int buttonNumber) { +// joystick using the classic SDL Joystick interface + switch (buttonNumber) { + case 0 : return jkY; + case 1 : return jkB; + case 2 : return jkA; + case 3 : return jkX; + case 4 : return jkL; + case 5 : return jkR; + case 6 : return jkLB; + case 7 : return jkRB; + case 8 : return jkSelect; + case 9 : return jkStart; + } + return jkNone; +} + +int joyGetIndex(SDL_JoystickID id) { + int i; + for (i=0 ; i < sdl_numjoysticks; i++) { + if (SDL_JoystickInstanceID(sdl_joysticks[i]) == id) { + return i; + } + } + return -1; +} + +// To know if it's a gamecontroller when we only have the instanceID +bool joyIsController (Sint32 instanceID) { + int i; + bool ret = false; + + // We can't use SDL_IsGameController after we have physically disconnected a joystick, so we use this workaround. + for (i = 0; i < sdl_numcontrollers; i++) { + if (SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(sdl_controllers[i])) == instanceID) { + ret = true; + break; + } + } + return ret; +} + +void joyAdd(int index) { + if(SDL_IsGameController(index)) { + SDL_GameController *controller = SDL_GameControllerOpen(index); + sdl_controllers[index] = controller; + sdl_joysticks[index] = SDL_GameControllerGetJoystick(controller); + sdl_numcontrollers++; + } + else { + sdl_joysticks[index] = SDL_JoystickOpen(index); + sdl_haptics[index] = SDL_HapticOpenFromJoystick(sdl_joysticks[index]); + SDL_HapticRumbleInit(sdl_haptics[index]); + } + // Update number of joysticks + sdl_numjoysticks = SDL_NumJoysticks(); + sdl_numjoysticks = (sdl_numjoysticks < MAX_JOYS )? sdl_numjoysticks : MAX_JOYS; +} + +void joyRemove(Sint32 instanceID) { + int i; + + // Closing game controller + if (joyIsController(instanceID)) { + for (i = 0; i < sdl_numcontrollers; i++) { + if (SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(sdl_controllers[i])) == instanceID) { + SDL_GameControllerClose(sdl_controllers[i]); + sdl_controllers[i] = NULL; + sdl_numcontrollers--; + sdl_numjoysticks--; + } + } + } + // Closing joystick + else { + i = joyGetIndex(instanceID); + if (i >= 0) { + SDL_JoystickClose(sdl_joysticks[i]); + SDL_HapticClose(sdl_haptics[i]); + sdl_haptics[i] = NULL; + sdl_numjoysticks--; + } + } +} + +bool inputInit() { + int index; + joyL = joyR = vec2(0); + sdl_numjoysticks = SDL_NumJoysticks(); + sdl_numjoysticks = (sdl_numjoysticks < MAX_JOYS )? sdl_numjoysticks : MAX_JOYS; + + for (index = 0; index < MAX_JOYS; index++) + sdl_joysticks[index] = NULL; + + for (index = 0; index < sdl_numjoysticks; index++) + joyAdd(index); + return true; +} + +void inputFree() { + int i; + Sint32 instanceID; + + for (i = 0; i < sdl_numjoysticks; i++) { + instanceID = SDL_JoystickInstanceID(sdl_joysticks[i]); + joyRemove(instanceID); + } +} + +float joyAxisValue(int value) { + if (value > -JOY_DEAD_ZONE_STICK && value < JOY_DEAD_ZONE_STICK) + return 0.0f; + return value / 32767.0f; +} + +float joyTrigger(int value) { + return min(1.0f, value / 255.0f); +} + +vec2 joyDir(const vec2 &value) { + float dist = min(1.0f, value.length()); + return value.normal() * dist; +} + +void inputUpdate() { +// get input events + + int joyIndex; + SDL_Event event; + + while (SDL_PollEvent(&event) == 1) { // while there are still events to be processed + switch (event.type) { + case SDL_KEYDOWN: { + int scancode = event.key.keysym.scancode; + InputKey key = codeToInputKey(scancode); + if (key != ikNone) { + Input::setDown(key, 1); + } + +#ifndef _GAPI_GLES + if (scancode == SDL_SCANCODE_RETURN) { + if (isKeyPressed(SDL_SCANCODE_LALT) && isKeyPressed(SDL_SCANCODE_RETURN)) { + toggleFullscreen(); + } + } +#endif + break; + } + + case SDL_KEYUP: { + int scancode = event.key.keysym.scancode; + InputKey key = codeToInputKey(scancode); + if (key != ikNone) + Input::setDown(key, 0); + break; + } + + // Joystick reading using the modern SDL GameController interface + case SDL_CONTROLLERBUTTONDOWN: { + joyIndex = joyGetIndex(event.cbutton.which); + JoyKey key = controllerCodeToJoyKey(event.cbutton.button); + Input::setJoyDown(joyIndex, key, 1); + break; + } + case SDL_CONTROLLERBUTTONUP: { + joyIndex = joyGetIndex(event.cbutton.which); + JoyKey key = controllerCodeToJoyKey(event.cbutton.button); + Input::setJoyDown(joyIndex, key, 0); + break; + } + + case SDL_CONTROLLERAXISMOTION: { + joyIndex = joyGetIndex(event.caxis.which); + switch (event.caxis.axis) { + case SDL_CONTROLLER_AXIS_LEFTX: + joyL.x = joyAxisValue(event.caxis.value); + break; + case SDL_CONTROLLER_AXIS_LEFTY: + joyL.y = joyAxisValue(event.caxis.value); + break; + case SDL_CONTROLLER_AXIS_RIGHTX: + joyR.x = joyAxisValue(event.caxis.value); + break; + case SDL_CONTROLLER_AXIS_RIGHTY: + joyR.y = joyAxisValue(event.caxis.value); + break; + } + Input::setJoyPos(joyIndex, jkL, joyDir(joyL)); + Input::setJoyPos(joyIndex, jkR, joyDir(joyR)); + break; + } + + // GameController connection or disconnection + case SDL_CONTROLLERDEVICEADDED: { + // Upon connection, 'which' is the internal SDL2 joystick index, + // but on disconnection, 'which' is the instanceID. + // We store the joysticks in their corresponding position on the joysticks array, + // IE: joystick with index 3 will be in sdl_joysticks[3]. + joyAdd(event.cdevice.which); + break; + } + case SDL_CONTROLLERDEVICEREMOVED: { + joyRemove(event.cdevice.which); + break; + + // Joystick reading using the old SDL Joystick interface + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + case SDL_JOYAXISMOTION: + case SDL_JOYDEVICEADDED: + case SDL_JOYDEVICEREMOVED: + // Only handle the event if the joystick is incompatible with the SDL_GameController interface. + // (Otherwise it will interfere with the normal action of the SDL_GameController API, because + // the event is both a GameController event AND a Joystick event.) + if (SDL_IsGameController(joyIndex)) { + break; + } + + switch (event.type) { + case SDL_JOYBUTTONDOWN: { + joyIndex = joyGetIndex(event.jbutton.which); + JoyKey key = joyCodeToJoyKey(event.jbutton.button); + Input::setJoyDown(joyIndex, key, 1); + break; + } + case SDL_JOYBUTTONUP: { + joyIndex = joyGetIndex(event.jbutton.which); + JoyKey key = joyCodeToJoyKey(event.jbutton.button); + Input::setJoyDown(joyIndex, key, 0); + break; + } + case SDL_JOYAXISMOTION: { + joyIndex = joyGetIndex(event.jaxis.which); + switch (event.jaxis.axis) + { + // In the classic joystick interface we know what axis changed by it's number, + // they have no names like on the fancy GameController interface. + case 0: joyL.x = joyAxisValue(event.jaxis.value); break; + case 1: joyL.y = joyAxisValue(event.jaxis.value); break; + case 2: joyR.x = joyAxisValue(event.jaxis.value); break; + case 3: joyR.y = joyAxisValue(event.jaxis.value); break; + } + Input::setJoyPos(joyIndex, jkL, joyDir(joyL)); + Input::setJoyPos(joyIndex, jkR, joyDir(joyR)); + break; + } + + // Joystick connection or disconnection + case SDL_JOYDEVICEADDED: { + // Upon connection, 'which' is the internal SDL2 joystick index, + // but on disconnection, 'which' is the instanceID. + // We store the joysticks in their corresponding position on the joysticks array, + // IE: joystick with index 3 will be in sdl_joysticks[3]. + joyAdd(event.jdevice.which); + break; + } + case SDL_JOYDEVICEREMOVED: { + joyRemove(event.jdevice.which); + break; + } + break; + } + } + } + } +} + +void print_help(int argc, char **argv) { + + printf("%s [OPTION]\nA open source re-implementation of the classic Tomb Raider engine.\n", + argc ? argv[0] : "OpenLara"); + puts("-d [DIRECTORY] directory where data files are"); + puts("-l [FILE] load a specific level file"); + puts("-h print this help"); +} + +int main(int argc, char **argv) { + + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + char *lvlName = nullptr; + + int option; + while ((option = getopt(argc, argv, "hl:d:")) != -1) { + switch(option) { + case 'h': + print_help(argc, argv); + return 0; + case 'l': + lvlName = optarg; + break; + case 'd': + strncpy(contentDir, optarg, 254); + break; + case ':': + printf("option %c needs a value\n", optopt); + print_help(argc, argv); + return -1; + case '?': + printf("unknown option: %c\n", optopt); + print_help(argc, argv); + return -1; + default: + break; + } + } + + size_t contentDirLen = strlen(contentDir); + + if (contentDirLen > 0 && + contentDir[contentDirLen-1] != '/' && contentDir[contentDirLen-1] != '\\' && + contentDirLen < 254) { + contentDir[contentDirLen] = '/'; + contentDir[contentDirLen+1] = '\0'; + } + + int w, h; + SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt"); + SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_EVENTS|SDL_INIT_GAMECONTROLLER|SDL_INIT_HAPTIC); + + SDL_GetCurrentDisplayMode(0, &sdl_displaymode); + +#ifdef _GAPI_GLES + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); +#endif + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + /* In GLES, start in fullscreen mode using the vide mode currently in use. */ + sdl_window = SDL_CreateWindow(WND_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, +#ifdef _GAPI_GLES + sdl_displaymode.w, sdl_displaymode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP +#else + WIN_W, WIN_H, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN +#endif + ); + + // We try to use the current video mode, but we inform the core of whatever mode SDL2 gave us in the end. + SDL_GetWindowSize(sdl_window, &w, &h); + + Core::width = w; + Core::height = h; + + SDL_GLContext context = SDL_GL_CreateContext(sdl_window); + + SDL_ShowCursor(SDL_DISABLE); + + const char *home; + if (!(home = getenv("HOME"))) + home = getpwuid(getuid())->pw_dir; + strcat(cacheDir, home); + strcat(cacheDir, "/.openlara/"); + + struct stat st = {0}; + if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1) + cacheDir[0] = 0; + strcpy(saveDir, cacheDir); + + timeval t; + gettimeofday(&t, NULL); + startTime = t.tv_sec; + + sndInit(); + + inputInit(); + + Game::init(lvlName); + + while (!Core::isQuit) { + inputUpdate(); + + if (Game::update()) { + Game::render(); + Core::waitVBlank(); + SDL_GL_SwapWindow(sdl_window); + } + }; + + sndFree(); + Game::deinit(); + + SDL_DestroyWindow(sdl_window); + SDL_Quit(); + + return 0; +} diff --git a/src/platform/tns/Makefile b/src/platform/tns/Makefile new file mode 100644 index 00000000..f652a0a2 --- /dev/null +++ b/src/platform/tns/Makefile @@ -0,0 +1,50 @@ +DEBUG = FALSE + +GCC = nspire-gcc +AS = nspire-as +GXX = nspire-g++ +LD = nspire-ld +GENZEHN = genzehn + +GCCFLAGS = -marm -march=armv5te -mtune=arm926ej-s -std=c++11 -flto -ffast-math -fomit-frame-pointer -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -D__TNS__ -I../../fixed/ +LDFLAGS = -Wl,--gc-sections -Wl,--as-needed -flto -Wno-alloc-size-larger-than +ZEHNFLAGS = --name "OpenLara" + +ifeq ($(DEBUG),FALSE) + GCCFLAGS += -Ofast +else + GCCFLAGS += -O0 -g +endif + +OBJS = $(patsubst %.c, %.o, $(shell find . -name \*.c)) +OBJS += $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp)) +OBJS += $(patsubst %.s, %.o, $(shell find . -name \*.s)) +EXE = OpenLara +DISTDIR = . +vpath %.tns $(DISTDIR) +vpath %.elf $(DISTDIR) + +all: $(EXE).prg.tns + +%.o: %.c + $(GCC) $(GCCFLAGS) -c $< + +%.o: %.cpp + $(GXX) $(GCCFLAGS) -c $< + +%.o: %.s + $(AS) -c $< + +$(EXE).elf: $(OBJS) + cp ../gba/render.iwram.cpp render.cpp + mkdir -p $(DISTDIR) + $(LD) $^ -o $(DISTDIR)/$@ $(LDFLAGS) + +$(EXE).tns: $(EXE).elf + $(GENZEHN) --input $(DISTDIR)/$^ --output $(DISTDIR)/$@ $(ZEHNFLAGS) + +$(EXE).prg.tns: $(EXE).tns + make-prg $(DISTDIR)/$^ $(DISTDIR)/$@ + +clean: + rm -f *.o $(DISTDIR)/$(EXE).tns $(DISTDIR)/$(EXE).elf $(DISTDIR)/$(EXE).prg.tns diff --git a/src/platform/tns/main.cpp b/src/platform/tns/main.cpp new file mode 100644 index 00000000..f6cb05e2 --- /dev/null +++ b/src/platform/tns/main.cpp @@ -0,0 +1,190 @@ +const void* TRACKS_IMA; +const void* TITLE_SCR; +unsigned char* levelData; + +#include "game.h" + +int32 fps; +int32 frameIndex = 0; +int32 fpsCounter = 0; +uint32 curSoundBuffer = 0; + +unsigned int osTime; +volatile unsigned int *timerBUS; +volatile unsigned int *timerCLK; +volatile unsigned int *timerCTR; +volatile unsigned int *timerDIV; + +void timerInit() +{ + timerBUS = (unsigned int*)0x900B0018; + timerCLK = (unsigned int*)0x900C0004; + timerCTR = (unsigned int*)0x900C0008; + timerDIV = (unsigned int*)0x900C0080; + + *timerBUS &= ~(1 << 11); + *timerDIV = 0x0A; + *timerCTR = 0x82; + + osTime = *timerCLK; +} + +int32 GetTickCount() +{ + return (osTime - *timerCLK) / 33; +} + +int32 osGetSystemTimeMS() +{ + return *timerCLK / 33; +} + +bool osSaveSettings() +{ + return false; +} + +bool osLoadSettings() +{ + return false; +} + +bool osCheckSave() +{ + return false; +} + +bool osSaveGame() +{ + return false; +} + +bool osLoadGame() +{ + return false; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) {} + +void osSetPalette(const uint16* palette) +{ + memcpy((uint16*)0xC0000200, palette, 256 * 2); +} + +touchpad_info_t* touchInfo; +touchpad_report_t touchReport; +uint8 inputData[0x20]; + +bool keyDown(const t_key &key) +{ + return (*(short*)(inputData + key.tpad_row)) & key.tpad_col; +} + +void inputInit() +{ + touchInfo = is_touchpad ? touchpad_getinfo() : NULL; +} + +void inputUpdate() +{ + keys = 0; + + if (touchInfo) + { + touchpad_scan(&touchReport); + } + + memcpy(inputData, (void*)0x900E0000, 0x20); + + if (touchInfo && touchReport.contact) + { + float tx = float(touchReport.x) / float(touchInfo->width) * 2.0f - 1.0f; + float ty = float(touchReport.y) / float(touchInfo->height) * 2.0f - 1.0f; + + if (tx < -0.5f) keys |= IK_LEFT; + if (tx > 0.5f) keys |= IK_RIGHT; + if (ty > 0.5f) keys |= IK_UP; + if (ty < -0.5f) keys |= IK_DOWN; + } + + if (keyDown(KEY_NSPIRE_2)) keys |= IK_A; + if (keyDown(KEY_NSPIRE_3)) keys |= IK_B; + if (keyDown(KEY_NSPIRE_7)) keys |= IK_L; + if (keyDown(KEY_NSPIRE_9)) keys |= IK_R; + if (keyDown(KEY_NSPIRE_ENTER)) keys |= IK_START; + if (keyDown(KEY_NSPIRE_SPACE)) keys |= IK_SELECT; +} + +void* osLoadLevel(const char* name) +{ +// level1 + char buf[32]; + + delete[] levelData; + + sprintf(buf, "/documents/OpenLara/%s.PKD.tns", name); + + FILE *f = fopen(buf, "rb"); + + if (!f) + return NULL; + + { + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + levelData = data; + } + + return (void*)levelData; +} + +int main(void) +{ + if (!has_colors) + return 0; + + lcd_init(SCR_320x240_8); + + timerInit(); + inputInit(); + + gameInit(gLevelInfo[gLevelID].name); + + int startTime = GetTickCount(); + int lastTime = -16; + int fpsTime = startTime; + + while (1) + { + inputUpdate(); + + if (keyDown(KEY_NSPIRE_ESC)) + { + break; + } + + int time = GetTickCount() - startTime; + gameUpdate((time - lastTime) / 16); + lastTime = time; + + gameRender(); + + lcd_blit(fb, SCR_320x240_8); + //msleep(16); + + fpsCounter++; + if (lastTime - fpsTime >= 1000) + { + fps = fpsCounter; + fpsCounter = 0; + fpsTime = lastTime - ((lastTime - fpsTime) - 1000); + } + } + + return 0; +} diff --git a/src/platform/tns/sound.cpp b/src/platform/tns/sound.cpp new file mode 100644 index 00000000..2512df5c --- /dev/null +++ b/src/platform/tns/sound.cpp @@ -0,0 +1,51 @@ +#include "common.h" + +void sndInit() +{ + // TODO +} + +void sndInitSamples() +{ + // TODO +} + +void sndFreeSamples() +{ + // TODO +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + return NULL; // TODO +} + +void sndPlayTrack(int32 track) +{ + // TODO +} + +void sndStopTrack() +{ + // TODO +} + +bool sndTrackIsPlaying() +{ + return false; // TODO +} + +void sndStopSample(int32 index) +{ + // TODO +} + +void sndStop() +{ + // TODO +} + +void sndFill(uint8* buffer, int32 count) +{ + // TODO +} diff --git a/src/platform/web/build.bat b/src/platform/web/build.bat index 35683bc0..28ecd676 100644 --- a/src/platform/web/build.bat +++ b/src/platform/web/build.bat @@ -2,7 +2,7 @@ cls set SRC=main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/tinf/tinflate.c set PROJ=OpenLara -set FLAGS=-O3 -ffast-math -Wno-deprecated-register --llvm-opts 2 -fmax-type-align=2 -std=c++11 -s ALLOW_MEMORY_GROWTH=1 -Wall -I../../ +set FLAGS=-O3 -ffast-math -Wno-deprecated-register --llvm-opts 2 -fmax-type-align=2 -std=c++11 -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -Wall -Wno-invalid-source-encoding -I../../ echo. call em++ %SRC% %FLAGS% -o %PROJ%.js --preload-file ./level/1/TITLE.PSX --preload-file ./audio/1/dummy --preload-file ./audio/2/dummy --preload-file ./audio/3/dummy --preload-file ./level/2/dummy --preload-file ./level/3/dummy gzip.exe -9 -f %PROJ%.data %PROJ%.js %PROJ%.js.mem \ No newline at end of file diff --git a/src/platform/web/build_wasm.bat b/src/platform/web/build_wasm.bat index e965de81..1b53d480 100644 --- a/src/platform/web/build_wasm.bat +++ b/src/platform/web/build_wasm.bat @@ -2,7 +2,7 @@ cls set SRC=main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/tinf/tinflate.c set PROJ=OpenLara_wasm -set FLAGS=-s WASM=1 -O3 -ffast-math -Wno-deprecated-register --llvm-opts 2 -fmax-type-align=2 -std=c++11 -Wall -I../../ +set FLAGS=-s WASM=1 -O3 -ffast-math -Wno-deprecated-register --llvm-opts 2 -fmax-type-align=2 -std=c++11 -s USE_WEBGL2=1 -Wall -Wno-invalid-source-encoding -I../../ echo. call em++ %SRC% %FLAGS% -o %PROJ%.js --preload-file ./level/1/TITLE.PSX --preload-file ./audio/1/dummy --preload-file ./audio/2/dummy --preload-file ./audio/3/dummy --preload-file ./level/2/dummy --preload-file ./level/3/dummy gzip.exe -9 -f %PROJ%.data %PROJ%.js %PROJ%.wasm %PROJ%.js.mem load-wasm-worker.js \ No newline at end of file diff --git a/src/platform/web/index.html b/src/platform/web/index.php similarity index 75% rename from src/platform/web/index.html rename to src/platform/web/index.php index 8ba9c6b8..da376063 100644 --- a/src/platform/web/index.html +++ b/src/platform/web/index.php @@ -1,18 +1,19 @@ - + OpenLara + - + + +
Starting...
- - - - (.PHD, .PSX, .TR2)  +
+ + (.PHD, .PSX, .TR2, .TR4)  -

+

OpenLara on github & facebook
-
last update: 04.12.2018
+
last update:
-

- +
+
- \ No newline at end of file + diff --git a/src/platform/web/main.cpp b/src/platform/web/main.cpp index 65face98..57194a0d 100644 --- a/src/platform/web/main.cpp +++ b/src/platform/web/main.cpp @@ -1,17 +1,15 @@ #include #include #include -#include #include "game.h" int lastJoy = -1; -EGLDisplay display; -EGLSurface surface; -EGLContext context; +EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context; +int WEBGL_VERSION; // timing -int osGetTime() { +int osGetTimeMS() { return (int)emscripten_get_now(); } @@ -105,15 +103,8 @@ JoyKey joyToInputKey(int code) { return jkNone; } -#define JOY_DEAD_ZONE_STICK 0.3f #define JOY_DEAD_ZONE_TRIGGER 0.01f -vec2 joyAxis(float x, float y) { - if (fabsf(x) > JOY_DEAD_ZONE_STICK || fabsf(y) > JOY_DEAD_ZONE_STICK) - return vec2(x, y); - return vec2(0.0f); -} - vec2 joyTrigger(float x) { return vec2(x > JOY_DEAD_ZONE_TRIGGER ? x : 0.0f, 0.0f); } @@ -148,8 +139,8 @@ void joyUpdate() { Input::setJoyPos(j, key, joyTrigger(state.analogButton[i])); } - Input::setJoyPos(j, jkL, joyAxis(state.axis[0], state.axis[1])); - Input::setJoyPos(j, jkR, joyAxis(state.axis[2], state.axis[3])); + Input::setJoyPos(j, jkL, vec2(state.axis[0], state.axis[1])); + Input::setJoyPos(j, jkR, vec2(state.axis[2], state.axis[3])); } } @@ -164,47 +155,56 @@ void main_loop() { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glColorMask(true, true, true, true); - - eglSwapBuffers(display, surface); } } bool initGL() { - EGLint vMajor, vMinor, cfgCount; - EGLConfig cfg; - - EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; - EGLint attribList[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_DEPTH_SIZE, 8, - EGL_STENCIL_SIZE, EGL_DONT_CARE, - EGL_SAMPLE_BUFFERS, EGL_DONT_CARE, - EGL_NONE - }; + EmscriptenWebGLContextAttributes attrs; + emscripten_webgl_init_context_attributes(&attrs); + attrs.alpha = true; + attrs.depth = true; + attrs.enableExtensionsByDefault = true; + attrs.antialias = false; + attrs.premultipliedAlpha = false; + attrs.majorVersion = 2; + + context = emscripten_webgl_create_context(0, &attrs); + if (!context) { + attrs.majorVersion = 1; + context = emscripten_webgl_create_context(0, &attrs); + } + + if (!context) { + LOG("! can't initialize WebGL !\n"); + return false; + } + WEBGL_VERSION = attrs.majorVersion; + + emscripten_webgl_make_context_current(context); + + char *ext = (char*)glGetString(GL_EXTENSIONS); + if (ext != NULL) { + char buf[255]; + int len = strlen(ext); + int start = 0; + for (int i = 0; i < len; i++) + if (ext[i] == ' ' || (i == len - 1)) { + memcpy(buf, &ext[start], i - start); + buf[i - start] = 0; + emscripten_webgl_enable_extension(context, buf); + //LOG("enable: %s\n", buf); + start = i + 1; + } + } - display = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); - eglInitialize(display, &vMajor, &vMinor); - eglGetConfigs(display, NULL, 0, &cfgCount); - eglChooseConfig(display, attribList, &cfg, 1, &cfgCount); - surface = eglCreateWindowSurface(display, cfg, NULL, NULL); - context = eglCreateContext(display, cfg, EGL_NO_CONTEXT, contextAttribs); - eglMakeCurrent(display, surface, surface, context); return true; } void freeGL() { - eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext(display, context); - eglDestroySurface(display, surface); - eglTerminate(display); + emscripten_webgl_destroy_context(context); } EM_BOOL resize() { - //int f; - //emscripten_get_canvas_size(&Core::width, &Core::height, &f); double w, h; emscripten_get_element_css_size(NULL, &w, &h); Core::width = int(w); @@ -229,6 +229,10 @@ bool isFullScreen() { } extern "C" { + void EMSCRIPTEN_KEEPALIVE set_def_lang(int id) { + Core::defLang = id; + } + void EMSCRIPTEN_KEEPALIVE snd_fill(Sound::Frame *frames, int count) { Sound::fill(frames, count); } @@ -261,11 +265,16 @@ InputKey keyToInputKey(int code) { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6B, 0x6D, 0x6A, 0x6F, 0x6E, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, + 0xBB, 0xBD, 0xDB, 0xDD, 0xBF, 0xDC, 0xBC, 0xBE, 0xC0, 0xBA, 0xDE, 0x21, 0x22, 0x24, 0x23, 0x2E, 0x2D, 0x08 }; - for (int i = 0; i < sizeof(codes) / sizeof(codes[0]); i++) - if (codes[i] == code) + for (int i = 0; i < COUNT(codes); i++) { + if (codes[i] == code) { return (InputKey)(ikLeft + i); + } + } return ikNone; } @@ -313,10 +322,11 @@ EM_BOOL mouseCallback(int eventType, const EmscriptenMouseEvent *e, void *userDa } int main() { + if (!initGL()) { + return 0; + } cacheDir[0] = saveDir[0] = contentDir[0] = 0; - initGL(); - emscripten_set_keydown_callback(0, 0, 1, keyCallback); emscripten_set_keyup_callback(0, 0, 1, keyCallback); emscripten_set_resize_callback(0, 0, 0, resizeCallback); @@ -330,6 +340,7 @@ int main() { emscripten_set_mouseup_callback(0, 0, 1, mouseCallback); emscripten_set_mousemove_callback(0, 0, 1, mouseCallback); + emscripten_run_script("getLanguage()"); Game::init(); emscripten_run_script("snd_init()"); resize(); diff --git a/src/platform/win/OpenLara.rc b/src/platform/win/OpenLara.rc new file mode 100644 index 00000000..9f444cf0 Binary files /dev/null and b/src/platform/win/OpenLara.rc differ diff --git a/src/platform/win/OpenLara.sln b/src/platform/win/OpenLara.sln index c49f4440..2079fe9a 100644 --- a/src/platform/win/OpenLara.sln +++ b/src/platform/win/OpenLara.sln @@ -1,25 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{6935E070-59B8-418A-9241-70BACB4217B5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Profile|Win32 = Profile|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6935E070-59B8-418A-9241-70BACB4217B5}.Debug|Win32.ActiveCfg = Debug|Win32 {6935E070-59B8-418A-9241-70BACB4217B5}.Debug|Win32.Build.0 = Debug|Win32 - {6935E070-59B8-418A-9241-70BACB4217B5}.Profile|Win32.ActiveCfg = Profile|Win32 - {6935E070-59B8-418A-9241-70BACB4217B5}.Profile|Win32.Build.0 = Profile|Win32 {6935E070-59B8-418A-9241-70BACB4217B5}.Release|Win32.ActiveCfg = Release|Win32 {6935E070-59B8-418A-9241-70BACB4217B5}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {969CCE82-3511-4643-9273-4B4554C4E782} + EndGlobalSection EndGlobal diff --git a/src/platform/win/OpenLara.vcxproj b/src/platform/win/OpenLara.vcxproj index 0be254e6..bb09c760 100644 --- a/src/platform/win/OpenLara.vcxproj +++ b/src/platform/win/OpenLara.vcxproj @@ -5,14 +5,6 @@ Debug Win32 - - Editor - Win32 - - - Profile - Win32 - Release Win32 @@ -22,32 +14,19 @@ {6935E070-59B8-418A-9241-70BACB4217B5} Win32Proj OpenLara - 8.1 + 10.0 Application true - v140_xp - NotSet - - - Application - true - v120_xp + v142 NotSet Application false - v140_xp - true - NotSet - - - Application - false - v140_xp + v142 true NotSet @@ -57,40 +36,26 @@ - - - - - - true ..\..\..\bin\ - ..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath); - ..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86); - - - true - ..\..\..\bin\ - ..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath); + ..\..\libs\;..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86); + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(FxCopDir);$(MSBuild_ExecutablePath);$(VC_LibraryPath_x86);$(SystemRoot) + $(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH); false ..\..\..\bin\ false - ..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath); - ..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86); - - - false - ..\..\..\bin\ - false - ..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath); - ..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86); + ..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86); + ..\..\libs\;..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(FxCopDir);$(MSBuild_ExecutablePath);$(VC_LibraryPath_x86);$(SystemRoot) + $(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH); @@ -102,28 +67,12 @@ Strict + MultiThreadedDebug Console true - wsock32.lib;openvr_api.lib;d3d9.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - LEVEL_EDITOR;STB_VORBIS_NO_STDIO;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - Strict - - - - - Console - true - opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + wsock32.lib;d3d9.lib;d3d11.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -145,46 +94,17 @@ true - Console + Windows true true true - wcrt.lib;wsock32.lib;openvr_api.lib;d3d9.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + wcrt.lib;wsock32.lib;d3d9.lib;d3d11.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) true false false true - - - Level3 - - - Full - true - true - PROFILE;MINIMAL;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - false - false - MultiThreaded - Strict - false - Size - /d2noftol3 %(AdditionalOptions) - true - - - Console - false - true - true - wcrt.lib;wsock32.lib;openvr_api.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - true - false - false - - @@ -199,17 +119,44 @@ + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -218,7 +165,6 @@ - @@ -226,17 +172,26 @@ - + + + - + + + + + + + + diff --git a/src/platform/win/OpenLara.vcxproj.filters b/src/platform/win/OpenLara.vcxproj.filters index 2b142424..ead0abb0 100644 --- a/src/platform/win/OpenLara.vcxproj.filters +++ b/src/platform/win/OpenLara.vcxproj.filters @@ -35,19 +35,10 @@ - - - - - - libs\minimp3 - - libs\minimp3 - libs\tinf @@ -57,6 +48,95 @@ + + + lang + + + lang + + + lang + + + lang + + + lang + + + lang + + + lang + + + lang + + + lang + + + + gapi + + + gapi + + + gapi + + + gapi + + + gapi + + + gapi + + + gapi + + + gapi + + + lang + + + lang + + + lang + + + lang + + + lang + + + lang + + + + + + lang + + + lang + + + gapi + + + lang + + + lang + @@ -68,7 +148,16 @@ shaders - + + shaders + + + shaders + + + shaders + + shaders @@ -88,5 +177,17 @@ {80edb27c-40cf-4f7a-a854-88eeba24a5fb} + + {2aaeadd4-47e5-4826-a82a-3adc5ff45978} + + + {1cbd1ed7-2d29-45a4-b242-5b3ad71cc62e} + + + + + + +
\ No newline at end of file diff --git a/src/platform/win/OpenLara.vcxproj.user b/src/platform/win/OpenLara.vcxproj.user index 29c03dbc..3552e3b8 100644 --- a/src/platform/win/OpenLara.vcxproj.user +++ b/src/platform/win/OpenLara.vcxproj.user @@ -1,16 +1,17 @@  - ..\..\..\bin + ..\..\..\bin\TR1_PSX WindowsLocalDebugger - GYM.PHD + + - C:\Projects\OpenLara\bin\ + ..\..\..\bin\TR1_PSX WindowsLocalDebugger - C:\Projects\OpenLara\bin\TR3_PC + ..\..\..\bin\TR1_PSX WindowsLocalDebugger diff --git a/src/platform/win/compile_mingw.bat b/src/platform/win/compile_mingw.bat new file mode 100644 index 00000000..b83f15b2 --- /dev/null +++ b/src/platform/win/compile_mingw.bat @@ -0,0 +1 @@ +C:\MinGW\bin\mingw32-g++ -static-libstdc++ -static-libgcc -O3 -s -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections -DWIN32 -DNDEBUG -DNO_TOUCH_SUPPORT -I../../libs/ main.cpp ../../libs/stb_vorbis/stb_vorbis.c ../../libs/minimp3/minimp3.cpp ../../libs/tinf/tinflate.c -I../../ -o../../../bin/OpenLara_mingw.exe -lopengl32 -lwinmm -lwsock32 -lgdi32 -lm \ No newline at end of file diff --git a/src/platform/win/icon.ico b/src/platform/win/icon.ico new file mode 100644 index 00000000..7a5aed33 Binary files /dev/null and b/src/platform/win/icon.ico differ diff --git a/src/platform/win/main.cpp b/src/platform/win/main.cpp index 54a54768..27dfe01f 100644 --- a/src/platform/win/main.cpp +++ b/src/platform/win/main.cpp @@ -14,28 +14,17 @@ #endif #endif -//#define VR_SUPPORT -// TODO: fix depth precision -// TODO: fix water surface rendering -// TODO: fix clipping -// TODO: add MSAA support for render targets -// TODO: add IK for arms -// TODO: controls - // hint to the driver to use discrete GPU extern "C" { // NVIDIA - __declspec(dllexport) int NvOptimusEnablement = 1; + __declspec(dllexport) int NvOptimusEnablement = 1; // AMD - __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } -#ifdef VR_SUPPORT - #include "libs/openvr/openvr.h" -#endif - #include "game.h" +#define GetProcAddr(lib, x) (x = lib ? (decltype(x))GetProcAddress(lib, #x + 1) : NULL) // multi-threading void* osMutexInit() { @@ -57,45 +46,16 @@ void osMutexUnlock(void *obj) { LeaveCriticalSection((CRITICAL_SECTION*)obj); } -/* -void* osRWLockInit() { - SRWLOCK *lock = new SRWLOCK(); - InitializeSRWLock(lock); - return lock; -} - -void osRWLockFree(void *obj) { - delete (SRWLOCK*)obj; -} - -void osRWLockRead(void *obj) { - AcquireSRWLockShared((SRWLOCK*)obj); -} - -void osRWUnlockRead(void *obj) { - ReleaseSRWLockShared((SRWLOCK*)obj); -} - -void osRWLockWrite(void *obj) { - AcquireSRWLockExclusive((SRWLOCK*)obj); -} - -void osRWUnlockWrite(void *obj) { - ReleaseSRWLockExclusive((SRWLOCK*)obj); -} -*/ - // timing int osStartTime = 0; -int osGetTime() { +int osGetTimeMS() { #ifdef DEBUG LARGE_INTEGER Freq, Count; QueryPerformanceFrequency(&Freq); QueryPerformanceCounter(&Count); return int(Count.QuadPart * 1000L / Freq.QuadPart); #else - timeBeginPeriod(0); return int(timeGetTime()) - osStartTime; #endif } @@ -107,11 +67,16 @@ InputKey keyToInputKey(int code) { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_ADD, VK_SUBTRACT, VK_MULTIPLY, VK_DIVIDE, VK_DECIMAL, + VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, + VK_OEM_MINUS, VK_OEM_PLUS, VK_OEM_4, VK_OEM_6, VK_OEM_2, VK_OEM_5, VK_OEM_COMMA, VK_OEM_PERIOD, VK_OEM_3, VK_OEM_1, VK_OEM_7, VK_PRIOR, VK_NEXT, VK_HOME, VK_END, VK_DELETE, VK_INSERT, VK_BACK, }; - for (int i = 0; i < sizeof(codes) / sizeof(codes[0]); i++) - if (codes[i] == code) + for (int i = 0; i < COUNT(codes); i++) { + if (codes[i] == code) { return (InputKey)(ikLeft + i); + } + } return ikNone; } @@ -145,12 +110,10 @@ typedef struct _XINPUT_VIBRATION { #define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 #define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 -DWORD (WINAPI *XInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState) = NULL; -DWORD (WINAPI *XInputSetState) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) = NULL; -void (WINAPI *XInputEnable) (BOOL enable) = NULL; -#define XInputGetProc(x) (x = (decltype(x))GetProcAddress(h, #x)) +DWORD (WINAPI *_XInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState); +DWORD (WINAPI *_XInputSetState) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration); +void (WINAPI *_XInputEnable) (BOOL enable); -#define JOY_DEAD_ZONE_STICK 0.3f #define JOY_DEAD_ZONE_TRIGGER 0.01f #define JOY_MIN_UPDATE_FX_TIME 50 @@ -172,14 +135,14 @@ void osJoyVibrate(int index, float L, float R) { void joyRumble(int index) { JoyDevice &joy = joyDevice[index]; - if (XInputSetState && joy.ready && (joy.vL != joy.oL || joy.vR != joy.oR) && osGetTime() >= joy.time) { + if (_XInputSetState && joy.ready && (joy.vL != joy.oL || joy.vR != joy.oR) && Core::getTime() >= joy.time) { XINPUT_VIBRATION vibration; vibration.wLeftMotorSpeed = int(joy.vL * 65535.0f); vibration.wRightMotorSpeed = int(joy.vR * 65535.0f); - XInputSetState(index, &vibration); + _XInputSetState(index, &vibration); joy.oL = joy.vL; joy.oR = joy.vR; - joy.time = osGetTime() + JOY_MIN_UPDATE_FX_TIME; + joy.time = Core::getTime() + JOY_MIN_UPDATE_FX_TIME; } } @@ -187,18 +150,18 @@ void joyInit() { memset(joyDevice, 0, sizeof(joyDevice)); HMODULE h = LoadLibrary("xinput1_3.dll"); - if (h == NULL) + if (h == NULL) { h = LoadLibrary("xinput9_1_0.dll"); + } - XInputGetProc(XInputGetState); - XInputGetProc(XInputSetState); - XInputGetProc(XInputEnable); + GetProcAddr(h, _XInputGetState); + GetProcAddr(h, _XInputSetState); + GetProcAddr(h, _XInputEnable); for (int j = 0; j < INPUT_JOY_COUNT; j++) { - if (XInputGetState) { // XInput + if (_XInputGetState) { // XInput XINPUT_STATE state; - int res = XInputGetState(j, &state); - joyDevice[j].ready = (XInputGetState(j, &state) == ERROR_SUCCESS); + joyDevice[j].ready = (_XInputGetState(j, &state) == ERROR_SUCCESS); } else { // mmSystem (legacy) JOYINFOEX info; info.dwSize = sizeof(info); @@ -223,32 +186,27 @@ float joyAxis(int x, int xMin, int xMax) { vec2 joyDir(float ax, float ay) { vec2 dir = vec2(ax, ay); float dist = min(1.0f, dir.length()); - if (dist < JOY_DEAD_ZONE_STICK) dist = 0.0f; return dir.normal() * dist; } -int joyDeadZone(int value, int zone) { - return (value < -zone || value > zone) ? value : 0; -} - void joyUpdate() { for (int j = 0; j < INPUT_JOY_COUNT; j++) { if (!joyDevice[j].ready) continue; joyRumble(j); - if (XInputGetState) { // XInput + if (_XInputGetState) { // XInput XINPUT_STATE state; - if (XInputGetState(j, &state) == ERROR_SUCCESS) { + if (_XInputGetState(j, &state) == ERROR_SUCCESS) { //osJoyVibrate(j, state.Gamepad.bLeftTrigger / 255.0f, state.Gamepad.bRightTrigger / 255.0f); // vibration test - Input::setJoyPos(j, jkL, joyDir(joyAxis(joyDeadZone( state.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE), -32768, 32767), - joyAxis(joyDeadZone(-state.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE), -32768, 32767))); - Input::setJoyPos(j, jkR, joyDir(joyAxis(joyDeadZone( state.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE), -32768, 32767), - joyAxis(joyDeadZone(-state.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE), -32768, 32767))); - Input::setJoyPos(j, jkLT, vec2(joyDeadZone(state.Gamepad.bLeftTrigger, XINPUT_GAMEPAD_TRIGGER_THRESHOLD) / 255.0f, 0.0f)); - Input::setJoyPos(j, jkRT, vec2(joyDeadZone(state.Gamepad.bRightTrigger, XINPUT_GAMEPAD_TRIGGER_THRESHOLD) / 255.0f, 0.0f)); + Input::setJoyPos(j, jkL, joyDir(joyAxis( state.Gamepad.sThumbLX, -32768, 32767), + joyAxis(-state.Gamepad.sThumbLY, -32768, 32767))); + Input::setJoyPos(j, jkR, joyDir(joyAxis( state.Gamepad.sThumbRX, -32768, 32767), + joyAxis(-state.Gamepad.sThumbRY, -32768, 32767))); + Input::setJoyPos(j, jkLT, vec2(state.Gamepad.bLeftTrigger / 255.0f, 0.0f)); + Input::setJoyPos(j, jkRT, vec2(state.Gamepad.bRightTrigger/ 255.0f, 0.0f)); static const JoyKey keys[] = { jkUp, jkDown, jkLeft, jkRight, jkStart, jkSelect, jkL, jkR, jkLB, jkRB, jkNone, jkNone, jkA, jkB, jkX, jkY }; for (int i = 0; i < 16; i++) @@ -269,11 +227,11 @@ void joyUpdate() { if (caps.wNumAxes > 0) { Input::setJoyPos(j, jkL, joyDir(joyAxis(info.dwXpos, caps.wXmin, caps.wXmax), - joyAxis(info.dwYpos, caps.wYmin, caps.wYmax))); + joyAxis(info.dwYpos, caps.wYmin, caps.wYmax))); if ((caps.wCaps & JOYCAPS_HASR) && (caps.wCaps & JOYCAPS_HASU)) Input::setJoyPos(j, jkR, joyDir(joyAxis(info.dwUpos, caps.wUmin, caps.wUmax), - joyAxis(info.dwRpos, caps.wRmin, caps.wRmax))); + joyAxis(info.dwRpos, caps.wRmin, caps.wRmax))); if (caps.wCaps & JOYCAPS_HASZ) { float z = joyAxis(info.dwZpos, caps.wZmin, caps.wZmax); @@ -294,6 +252,7 @@ void joyUpdate() { for (int i = 0; i < 10; i++) Input::setJoyDown(j, JoyKey(jkA + i), (info.dwButtons & (1 << i)) > 0); + } else { joyFree(); joyInit(); @@ -303,22 +262,26 @@ void joyUpdate() { } } +#ifndef NO_TOUCH_SUPPORT // touch -BOOL (WINAPI *RegisterTouchWindowX)(HWND, ULONG); -BOOL (WINAPI *GetTouchInputInfoX)(HTOUCHINPUT, UINT, PTOUCHINPUT, int); -BOOL (WINAPI *CloseTouchInputHandleX)(HTOUCHINPUT); +BOOL (WINAPI *_RegisterTouchWindow)(HWND, ULONG); +BOOL (WINAPI *_GetTouchInputInfo)(HTOUCHINPUT, UINT, PTOUCHINPUT, int); +BOOL (WINAPI *_CloseTouchInputHandle)(HTOUCHINPUT); -#define MAX_TOUCH_COUNT 6 +#ifndef MAX_TOUCH_COUNT + #define MAX_TOUCH_COUNT 6 +#endif void touchInit(HWND hWnd) { int value = GetSystemMetrics(SM_DIGITIZER); if (value) { HMODULE hUser32 = LoadLibrary("user32.dll"); - RegisterTouchWindowX = (decltype(RegisterTouchWindowX)) GetProcAddress(hUser32, "RegisterTouchWindow"); - GetTouchInputInfoX = (decltype(GetTouchInputInfoX)) GetProcAddress(hUser32, "GetTouchInputInfo"); - CloseTouchInputHandleX = (decltype(CloseTouchInputHandleX)) GetProcAddress(hUser32, "CloseTouchInputHandle"); - if (RegisterTouchWindowX && GetTouchInputInfoX && CloseTouchInputHandleX) - RegisterTouchWindowX(hWnd, 0); + GetProcAddr(hUser32, _RegisterTouchWindow); + GetProcAddr(hUser32, _GetTouchInputInfo); + GetProcAddr(hUser32, _CloseTouchInputHandle); + + if (_RegisterTouchWindow && _GetTouchInputInfo && _CloseTouchInputHandle) + _RegisterTouchWindow(hWnd, 0); } } @@ -326,7 +289,7 @@ void touchUpdate(HWND hWnd, HTOUCHINPUT hTouch, int count) { TOUCHINPUT touch[MAX_TOUCH_COUNT]; count = min(count, MAX_TOUCH_COUNT); - if (!GetTouchInputInfoX(hTouch, count, touch, sizeof(TOUCHINPUT))) + if (!_GetTouchInputInfo(hTouch, count, touch, sizeof(TOUCHINPUT))) return; for (int i = 0; i < count; i++) { @@ -340,19 +303,22 @@ void touchUpdate(HWND hWnd, HTOUCHINPUT hTouch, int count) { Input::setDown(key, (touch[i].dwFlags & TOUCHEVENTF_DOWN) != 0); } - CloseTouchInputHandleX(hTouch); + _CloseTouchInputHandle(hTouch); } +#else +void touchInit(HWND hWnd) {}; +#endif // sound -#define SND_SIZE 4704*2 +#define SND_SIZE (2352*3*2) bool sndReady; char *sndData; HWAVEOUT waveOut; WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 2, 44100, 44100 * 4, 4, 16, sizeof(waveFmt) }; WAVEHDR waveBuf[2]; -HANDLE sndThread; -HANDLE sndSema; +HANDLE sndThread; +HANDLE sndSema; void sndFree() { if (!sndReady) return; @@ -411,15 +377,42 @@ void sndInit(HWND hwnd) { } } +// DPI api +BOOL (WINAPI *_SetProcessDpiAwarenessContext)(HANDLE); // Win 10 +BOOL (WINAPI *_SetProcessDpiAwareness)(int); // Win 8.1 +BOOL (WINAPI *_SetProcessDPIAware)(); // Win Vista +BOOL (WINAPI *_EnableNonClientDpiScaling)(HWND); // Win 10 + HWND hWnd; -#ifdef _GAPI_GL - HDC hDC; - HGLRC hRC; +#ifdef _GAPI_SW + HDC hDC; void ContextCreate() { hDC = GetDC(hWnd); + } + + void ContextDelete() { + ReleaseDC(hWnd, hDC); + delete[] GAPI::swColor; + } + + void ContextResize() { + delete[] GAPI::swColor; + GAPI::swColor = new GAPI::ColorSW[Core::width * Core::height]; + + GAPI::resize(); + } + + void ContextSwap() { + const BITMAPINFO bmi = { sizeof(BITMAPINFOHEADER), Core::width, -Core::height, 1, sizeof(GAPI::ColorSW) * 8, BI_RGB, 0, 0, 0, 0, 0 }; + SetDIBitsToDevice(hDC, 0, 0, Core::width, Core::height, 0, 0, 0, Core::height, GAPI::swColor, &bmi, DIB_RGB_COLORS); + } +#elif _GAPI_GL + HDC hDC; + HGLRC hRC; + void ContextCreate() { PIXELFORMATDESCRIPTOR pfd; memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); @@ -431,11 +424,67 @@ HWND hWnd; pfd.cBlueBits = 8; pfd.cAlphaBits = 8; pfd.cDepthBits = 24; - pfd.cStencilBits = 8; - int format = ChoosePixelFormat(hDC, &pfd); - SetPixelFormat(hDC, format, &pfd); - hRC = wglCreateContext(hDC); + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = NULL; + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; + + { + HWND fWnd = CreateWindow("static", NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, 0); + HDC fDC = GetDC(fWnd); + + int format = ChoosePixelFormat(fDC, &pfd); + SetPixelFormat(fDC, format, &pfd); + HGLRC fRC = wglCreateContext(fDC); + wglMakeCurrent(fDC, fRC); + + wglChoosePixelFormatARB = GetProcOGL(wglChoosePixelFormatARB); + wglCreateContextAttribsARB = GetProcOGL(wglCreateContextAttribsARB); + + wglMakeCurrent(0, 0); + ReleaseDC(fWnd, fDC); + wglDeleteContext(fRC); + DestroyWindow(fWnd); + } + + hDC = GetDC(hWnd); + + if (wglChoosePixelFormatARB && wglCreateContextAttribsARB) { + const int pixelAttribs[] = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_DOUBLE_BUFFER_ARB, GL_TRUE, + WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, 32, + WGL_ALPHA_BITS_ARB, 8, + WGL_DEPTH_BITS_ARB, 24, + 0 + }; + + int format; + UINT numFormats; + bool status = wglChoosePixelFormatARB(hDC, pixelAttribs, NULL, 1, &format, &numFormats); + ASSERT(status && numFormats > 0); + + DescribePixelFormat(hDC, format, sizeof(pfd), &pfd); + SetPixelFormat(hDC, format, &pfd); + + int contextAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 2, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; + + hRC = wglCreateContextAttribsARB(hDC, 0, contextAttribs); + + GAPI::GL_VER_3 = true; + } else { + int format = ChoosePixelFormat(hDC, &pfd); + SetPixelFormat(hDC, format, &pfd); + hRC = wglCreateContext(hDC); + } + wglMakeCurrent(hDC, hRC); } @@ -448,9 +497,10 @@ HWND hWnd; void ContextResize() {} void ContextSwap() { + timeBeginPeriod(1); // fix for Intel HD Graphics 4000 OGL driver bug in SwapBuffers timing SwapBuffers(hDC); } -#else +#elif _GAPI_D3D9 LPDIRECT3D9 D3D; LPDIRECT3DDEVICE9 device; D3DPRESENT_PARAMETERS d3dpp; @@ -493,6 +543,59 @@ HWND hWnd; if (device->Present(NULL, NULL, NULL, NULL) == D3DERR_DEVICELOST) GAPI::resetDevice(); } +#elif _GAPI_D3D11 + ID3D11Device *osDevice; + ID3D11DeviceContext *osContext; + IDXGISwapChain *osSwapChain; + + void ContextCreate() { + DXGI_SWAP_CHAIN_DESC desc = { 0 }; + desc.BufferCount = 2; + desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.BufferDesc.RefreshRate.Numerator = 60; + desc.BufferDesc.RefreshRate.Denominator = 1; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.OutputWindow = hWnd; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Windowed = TRUE; + desc.OutputWindow = hWnd; + + D3D_FEATURE_LEVEL featureLevels[] = { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + }; + + HRESULT ret; + + ret = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, &desc, &osSwapChain, &osDevice, NULL, &osContext); + ASSERT(ret == S_OK); + + GAPI::defRTV = NULL; + GAPI::defDSV = NULL; + } + + void ContextDelete() { + GAPI::deinit(); + SAFE_RELEASE(osSwapChain); + SAFE_RELEASE(osContext); + SAFE_RELEASE(osDevice); + } + + void ContextResize() { + if (osSwapChain == NULL || Core::width <= 0 || Core::height <= 0) + return; + + GAPI::resetDevice(); + + HRESULT ret = osSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); + ASSERT(ret == S_OK); + } + + void ContextSwap() { + HRESULT ret = osSwapChain->Present(Core::settings.detail.vsync ? 1 : 0, 0); + } #endif #ifdef _NAPI_SOCKET @@ -516,12 +619,38 @@ void parseCommand(char *cmd) { } #endif +int checkLanguage() { + LANGID id = GetUserDefaultUILanguage() & 0xFF; + int str = STR_LANG_EN; + switch (id) { + case LANG_ENGLISH : str = STR_LANG_EN; break; + case LANG_FRENCH : str = STR_LANG_FR; break; + case LANG_GERMAN : str = STR_LANG_DE; break; + case LANG_SPANISH : str = STR_LANG_ES; break; + case LANG_ITALIAN : str = STR_LANG_IT; break; + case LANG_POLISH : str = STR_LANG_PL; break; + case LANG_PORTUGUESE : str = STR_LANG_PT; break; + case LANG_RUSSIAN : + case LANG_UKRAINIAN : + case LANG_BELARUSIAN : str = STR_LANG_RU; break; + case LANG_JAPANESE : str = STR_LANG_JA; break; + case LANG_GREEK : str = STR_LANG_GR; break; + case LANG_FINNISH : str = STR_LANG_FI; break; + case LANG_CZECH : str = STR_LANG_CZ; break; + case LANG_CHINESE : str = STR_LANG_CN; break; + case LANG_HUNGARIAN : str = STR_LANG_HU; break; + case LANG_SWEDISH : str = STR_LANG_SV; break; + } + return str - STR_LANG_EN; +} + static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { // window case WM_ACTIVATE : - if (XInputEnable) - XInputEnable(wParam != WA_INACTIVE); + if (_XInputEnable) { + _XInputEnable(wParam != WA_INACTIVE); + } Input::reset(); break; case WM_SIZE: @@ -534,7 +663,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara break; // keyboard case WM_CHAR : - case WM_SYSCHAR : + case WM_SYSCHAR : #ifdef _NAPI_SOCKET if (wParam == VK_RETURN) { parseCommand(command); @@ -554,13 +683,13 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_KEYUP : case WM_SYSKEYDOWN : case WM_SYSKEYUP : - if (msg == WM_SYSKEYDOWN && wParam == VK_RETURN) { // switch to fullscreen or window + if (msg == WM_SYSKEYDOWN && wParam == VK_RETURN) { // Alt + Enter - switch to fullscreen or window static WINDOWPLACEMENT pLast; DWORD style = GetWindowLong(hWnd, GWL_STYLE); if (style & WS_OVERLAPPEDWINDOW) { MONITORINFO mInfo = { sizeof(mInfo) }; if (GetWindowPlacement(hWnd, &pLast) && GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY), &mInfo)) { - RECT &r = mInfo.rcMonitor; + RECT &r = mInfo.rcMonitor; SetWindowLong(hWnd, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW); MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE); } @@ -570,6 +699,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara } break; } + if (msg == WM_SYSKEYDOWN && wParam == VK_F4) { // Alt + F4 - close application + Core::quit(); + break; + } Input::setDown(keyToInputKey(wParam), msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN); break; // mouse @@ -602,27 +735,77 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara joyFree(); joyInit(); return 1; + #ifndef NO_TOUCH_SUPPORT // touch case WM_TOUCH : touchUpdate(hWnd, (HTOUCHINPUT)lParam, wParam); break; + #endif // sound case MM_WOM_DONE : sndFill((HWAVEOUT)wParam, (WAVEHDR*)lParam); break; + case WM_NCCREATE: + // allow windows to properly scale non-client area based on per-monitor dpi + if (_EnableNonClientDpiScaling != NULL) { + _EnableNonClientDpiScaling(hWnd); + } + // we have to pass this message to default wnd proc default : return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; } +//VR Support #ifdef VR_SUPPORT -vr::IVRSystem *hmd; +// TODO: fix depth precision +// TODO: fix water surface rendering +// TODO: fix clipping +// TODO: add MSAA support for render targets +// TODO: add IK for arms +// TODO: controls (WIP) + +#include "libs/openvr/openvr.h" + +vr::IVRSystem *hmd; // vrContext +vr::IVRRenderModels* rm; // not currently in use vr::TrackedDevicePose_t tPose[vr::k_unMaxTrackedDeviceCount]; +//eye textures(eventually) + +//action handles +vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle; + +vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcInventory = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcStart = vr::k_ulInvalidActionHandle; + +vr::VRActionSetHandle_t m_actionsetDemo = vr::k_ulInvalidActionSetHandle; + +vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle; +vr::VRInputValueHandle_t m_rightHand = vr::k_ulInvalidInputValueHandle; + +//only in select TR games +vr::VRActionHandle_t VRcDuck = vr::k_ulInvalidActionHandle; +vr::VRActionHandle_t VRcDash = vr::k_ulInvalidActionHandle; +// + +vr::VRActionSetHandle_t m_actionsetTR = vr::k_ulInvalidActionSetHandle; void vrInit() { + vr::VR_InitLibrary("openvr_api.dll"); + vr::EVRInitError eError = vr::VRInitError_None; hmd = vr::VR_Init(&eError, vr::VRApplication_Scene); + //rm = vr::VRRenderModels(); // initialize render models interface if (eError != vr::VRInitError_None) { hmd = NULL; @@ -638,81 +821,139 @@ void vrInit() { } void vrInitTargets() { + if (!hmd) return; uint32_t width, height; - hmd->GetRecommendedRenderTargetSize( &width, &height); - eyeTex[0] = new Texture(width, height, Texture::RGBA); - eyeTex[1] = new Texture(width, height, Texture::RGBA); + hmd->GetRecommendedRenderTargetSize(&width, &height); + Core::eyeTex[0] = new Texture(width, height, 1, TexFormat::FMT_RGBA, OPT_TARGET); + Core::eyeTex[1] = new Texture(width, height, 1, TexFormat::FMT_RGBA, OPT_TARGET); } void vrFree() { if (!hmd) return; vr::VR_Shutdown(); + hmd = NULL; + Input::hmd.ready = false; + delete Core::eyeTex[0]; + delete Core::eyeTex[1]; + Core::eyeTex[0] = Core::eyeTex[1] = NULL; } mat4 convToMat4(const vr::HmdMatrix44_t &m) { return mat4(m.m[0][0], m.m[1][0], m.m[2][0], m.m[3][0], - m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1], - m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2], + m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1], + m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2], m.m[0][3], m.m[1][3], m.m[2][3], m.m[3][3]); } mat4 convToMat4(const vr::HmdMatrix34_t &m) { - return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f, + return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f, m.m[0][1], m.m[1][1], m.m[2][1], 0.0f, m.m[0][2], m.m[1][2], m.m[2][2], 0.0f, m.m[0][3], m.m[1][3], m.m[2][3], 1.0f); } +//utility function for reading digital state +bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr) +{ + vr::InputDigitalActionData_t actionData; + vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle); + if (pDevicePath) { + *pDevicePath = vr::k_ulInvalidInputValueHandle; + if (actionData.bActive) { + vr::InputOriginInfo_t originInfo; + if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) { + *pDevicePath = originInfo.devicePath; + } + } + } + return actionData.bActive && actionData.bState; +} -void vrUpdateInput() { +void vrUpdate() { if (!hmd) return; + vr::VREvent_t event; while (hmd->PollNextEvent(&event, sizeof(event))) { - //ProcessVREvent( event ); switch (event.eventType) { case vr::VREvent_TrackedDeviceActivated: - //SetupRenderModelForTrackedDevice( event.trackedDeviceIndex ); - LOG( "Device %u attached. Setting up render model\n", event.trackedDeviceIndex); break; case vr::VREvent_TrackedDeviceDeactivated: - LOG("Device %u detached.\n", event.trackedDeviceIndex); + Input::reset(); break; case vr::VREvent_TrackedDeviceUpdated: - LOG("Device %u updated.\n", event.trackedDeviceIndex); break; } } - for (vr::TrackedDeviceIndex_t unDevice = 0; unDevice < vr::k_unMaxTrackedDeviceCount; unDevice++) { - vr::VRControllerState_t state; - if (hmd->GetControllerState(unDevice, &state, sizeof(state))) { - //m_rbShowTrackedDevice[ unDevice ] = state.ulButtonPressed == 0; + vr::VRCompositor()->WaitGetPoses(tPose, vr::k_unMaxTrackedDeviceCount, NULL, 0); + + for (int id = 0; id < vr::k_unMaxTrackedDeviceCount; id++) { + vr::TrackedDevicePose_t &pose = tPose[id]; + + if (!pose.bPoseIsValid) { + continue; } - } -} -void vrUpdateView() { - if (!hmd) return; - vr::VRCompositor()->WaitGetPoses(tPose, vr::k_unMaxTrackedDeviceCount, NULL, 0); + switch (hmd->GetTrackedDeviceClass(id)) { + case vr::TrackedDeviceClass_HMD : { + mat4 pL = convToMat4(hmd->GetProjectionMatrix(vr::Eye_Left, 8.0f, 45.0f * 1024.0f)); + mat4 pR = convToMat4(hmd->GetProjectionMatrix(vr::Eye_Right, 8.0f, 45.0f * 1024.0f)); - if (!tPose[vr::k_unTrackedDeviceIndex_Hmd].bPoseIsValid) - return; + mat4 head = convToMat4(pose.mDeviceToAbsoluteTracking); + if (Input::hmd.zero.x == INF) { + Input::hmd.zero = head.getPos(); + } + head.setPos(head.getPos() - Input::hmd.zero); - mat4 pL = convToMat4(hmd->GetProjectionMatrix(vr::Eye_Left, 8.0f, 45.0f * 1024.0f)); - mat4 pR = convToMat4(hmd->GetProjectionMatrix(vr::Eye_Right, 8.0f, 45.0f * 1024.0f)); + mat4 vL = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Left)); + mat4 vR = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Right)); - mat4 head = convToMat4(tPose[vr::k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking); - if (Input::hmd.zero.x == INF) - Input::hmd.zero = head.getPos(); - head.setPos(head.getPos() - Input::hmd.zero); - - mat4 vL = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Left)); - mat4 vR = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Right)); + vL.setPos(vL.getPos() * ONE_METER); + vR.setPos(vR.getPos() * ONE_METER); + Input::hmd.setView(pL, pR, vL, vR); + + Input::hmd.head = head; + break; + } + case vr::TrackedDeviceClass_Controller : { + vr::VRControllerState_t state; + hmd->GetControllerState(id, &state, sizeof(state)); + + #define IS_DOWN(btn) ((state.ulButtonPressed & vr::ButtonMaskFromId(btn)) != 0) + + if (!state.ulButtonPressed) { + // continue; + } + + Input::setJoyDown(0, jkLeft, IS_DOWN(vr::k_EButton_DPad_Left)); + Input::setJoyDown(0, jkUp, IS_DOWN(vr::k_EButton_DPad_Up)); + Input::setJoyDown(0, jkRight, IS_DOWN(vr::k_EButton_DPad_Right)); + Input::setJoyDown(0, jkDown, IS_DOWN(vr::k_EButton_DPad_Down)); + + if (IS_DOWN(vr::k_EButton_Axis0)) { + Input::setJoyPos(0, jkL, vec2(state.rAxis[0].x, -state.rAxis[0].y)); + } - vL.setPos(vL.getPos() * ONE_METER); - vR.setPos(vR.getPos() * ONE_METER); + Input::setJoyDown(0, jkA, IS_DOWN(vr::k_EButton_Axis1) ? (state.rAxis[1].x > 0.5) : false); + Input::setJoyDown(0, jkY, IS_DOWN(vr::k_EButton_Grip)); + Input::setJoyDown(0, jkX, IS_DOWN(vr::k_EButton_ApplicationMenu)); + + // TODO + switch (hmd->GetControllerRoleForTrackedDeviceIndex(id)) { + case vr::TrackedControllerRole_LeftHand : + // TODO + break; + case vr::TrackedControllerRole_RightHand : + // TODO + break; + default : ; + } + break; - Input::hmd.setView(pL, pR, vL, vR); + #undef IS_DOWN + } + } + } } void vrCompose() { @@ -722,6 +963,25 @@ void vrCompose() { vr::Texture_t RTex = {(void*)(uintptr_t)Core::eyeTex[1]->ID, vr::TextureType_OpenGL, vr::ColorSpace_Gamma}; vr::VRCompositor()->Submit(vr::Eye_Right, &RTex); } + +void osToggleVR(bool enable) { + if (enable) { + vrInit(); + vrInitTargets(); + Input::hmd.ready = hmd != NULL; + if (!hmd) { + Core::settings.detail.stereo = Core::Settings::STEREO_OFF; + } + } else { + vrFree(); + } +} + +#else + +void vrUpdate() {} +void vrCompose() {} + #endif // #ifdef VR_SUPPORT #ifdef _DEBUG @@ -731,10 +991,12 @@ int main(int argc, char** argv) { _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); _CrtMemCheckpoint(&_msBegin); //#elif PROFILE -#else +#elif PROFILE int main(int argc, char** argv) { -//#else -//int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { +#else +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + int argc = (lpCmdLine && strlen(lpCmdLine)) ? 2 : 1; + const char *argv[] = { "", lpCmdLine }; #endif cacheDir[0] = saveDir[0] = contentDir[0] = 0; @@ -744,32 +1006,87 @@ int main(int argc, char** argv) { CreateDirectory(cacheDir, NULL); RECT r = { 0, 0, 1280, 720 }; - AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false); - hWnd = CreateWindow("static", "OpenLara", WS_OVERLAPPEDWINDOW, 0, 0, r.right - r.left, r.bottom - r.top, 0, 0, 0, 0); + int sw = GetSystemMetrics(SM_CXSCREEN); + int sh = GetSystemMetrics(SM_CYSCREEN); + if (sw <= r.right + 128 || sh <= r.bottom + 128) { + r.right /= 2; + r.bottom /= 2; + } - ContextCreate(); + AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false); -#ifdef VR_SUPPORT - vrInit(); +#ifndef _DEBUG + { + int ox = (sw - (r.right - r.left)) / 2; + int oy = (sh - (r.bottom - r.top)) / 2; + r.left += ox; + r.top += oy; + r.right += ox; + r.bottom += oy; + } +#else + r.right -= r.left; + r.bottom -= r.top; + r.left = r.top = 0; #endif + // set our process to be DPI aware before creating main window + + bool high_dpi = false; + for (int i = 0; i < argc; i++) { + if (strcmp(argv[i], "--high-dpi") == 0) { + high_dpi = true; + } + } + + HMODULE hUser32 = NULL, hShcore = NULL; + + if (high_dpi) { + hUser32 = LoadLibrary("User32.dll"); + hShcore = LoadLibrary("Shcore.dll"); + } + + GetProcAddr(hUser32, _SetProcessDpiAwarenessContext); + GetProcAddr(hShcore, _SetProcessDpiAwareness); + GetProcAddr(hUser32, _SetProcessDPIAware); + GetProcAddr(hUser32, _EnableNonClientDpiScaling); + + if (_SetProcessDpiAwarenessContext) { + _SetProcessDpiAwarenessContext((HANDLE)-3); // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE v1 + } else if (_SetProcessDpiAwareness) { + _SetProcessDpiAwareness(2); // DPI_AWARENESS_PER_MONITOR_AWARE + } else if (_SetProcessDPIAware) { + _SetProcessDPIAware(); + } + + WNDCLASSEX wcex; + memset(&wcex, 0, sizeof(wcex)); + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.hInstance = GetModuleHandle(NULL); + wcex.hIcon = LoadIcon(wcex.hInstance, "MAINICON"); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.lpszClassName = "OpenLaraWnd"; + wcex.hIconSm = wcex.hIcon; + wcex.lpfnWndProc = &WndProc; + RegisterClassEx(&wcex); + + hWnd = CreateWindow(wcex.lpszClassName, "OpenLara", WS_OVERLAPPEDWINDOW, r.left, r.top, r.right - r.left, r.bottom - r.top, 0, 0, 0, 0); + + ContextCreate(); + Sound::channelsCount = 0; - osStartTime = osGetTime(); + osStartTime = Core::getTime(); touchInit(hWnd); joyInit(); sndInit(hWnd); - Game::init(argc > 1 ? argv[1] : NULL); - -#ifdef VR_SUPPORT - Input::hmd.ready = hmd != NULL; - vrInitTargets(); -#endif + Core::defLang = checkLanguage(); - SetWindowLong(hWnd, GWL_WNDPROC, (LONG)&WndProc); + Game::init((argc > 1 && strstr(argv[1], "--") != argv[1]) ? argv[1] : NULL); if (Core::isQuit) { MessageBoxA(hWnd, "Please check the readme file first!", "Game resources not found", MB_ICONHAND); @@ -787,17 +1104,10 @@ int main(int argc, char** argv) { Core::quit(); } else { joyUpdate(); - #ifdef VR_SUPPORT - vrUpdateInput(); - #endif + vrUpdate(); if (Game::update()) { - #ifdef VR_SUPPORT - vrUpdateView(); - #endif Game::render(); - #ifdef VR_SUPPORT vrCompose(); - #endif Core::waitVBlank(); ContextSwap(); } @@ -827,4 +1137,4 @@ int main(int argc, char** argv) { #endif return 0; -} \ No newline at end of file +} diff --git a/src/platform/win_fixed/OpenLara.rc b/src/platform/win_fixed/OpenLara.rc new file mode 100644 index 00000000..9f444cf0 Binary files /dev/null and b/src/platform/win_fixed/OpenLara.rc differ diff --git a/src/platform/win_fixed/OpenLara.sln b/src/platform/win_fixed/OpenLara.sln new file mode 100644 index 00000000..2079fe9a --- /dev/null +++ b/src/platform/win_fixed/OpenLara.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{6935E070-59B8-418A-9241-70BACB4217B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6935E070-59B8-418A-9241-70BACB4217B5}.Debug|Win32.ActiveCfg = Debug|Win32 + {6935E070-59B8-418A-9241-70BACB4217B5}.Debug|Win32.Build.0 = Debug|Win32 + {6935E070-59B8-418A-9241-70BACB4217B5}.Release|Win32.ActiveCfg = Release|Win32 + {6935E070-59B8-418A-9241-70BACB4217B5}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {969CCE82-3511-4643-9273-4B4554C4E782} + EndGlobalSection +EndGlobal diff --git a/src/platform/win_fixed/OpenLara.vcxproj b/src/platform/win_fixed/OpenLara.vcxproj new file mode 100644 index 00000000..588fba46 --- /dev/null +++ b/src/platform/win_fixed/OpenLara.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {6935E070-59B8-418A-9241-70BACB4217B5} + Win32Proj + OpenLara + 10.0 + + + + Application + true + NotSet + v142 + + + Application + false + true + NotSet + v142 + + + + + + + + + + + + + true + ..\..\..\bin\ + ..\..\fixed;$(VC_IncludePath);$(WindowsSDK_IncludePath) + $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(FxCopDir);$(MSBuild_ExecutablePath);$(VC_LibraryPath_x86);$(SystemRoot) + $(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH); + + + false + ..\..\..\bin\ + false + ..\..\fixed;$(VC_IncludePath);$(WindowsSDK_IncludePath); + + + + + + Level3 + Disabled + __WIN32__;NOMINMAX;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + Strict + + + MultiThreadedDebug + 26495 + + + true + glu32.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + + + Full + true + true + __WIN32__;MINIMAL;NOMINMAX;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + false + false + MultiThreaded + Strict + false + Size + /d2noftol3 %(AdditionalOptions) + true + 26495 + + + true + true + true + false + false + true + glu32.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/win_fixed/OpenLara.vcxproj.filters b/src/platform/win_fixed/OpenLara.vcxproj.filters new file mode 100644 index 00000000..861476b0 --- /dev/null +++ b/src/platform/win_fixed/OpenLara.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + + + + render + + + + + + + + + + + + + + + + + + + + + + + lang + + + fmt + + + fmt + + + + + {1d3e6f64-05d8-42b8-b2c6-c5bba7798936} + + + {f297223e-368f-46b9-9f41-3e8075cbc5c2} + + + {fe1fca63-da0d-4e31-b8c4-1d61eb02d01b} + + + \ No newline at end of file diff --git a/src/platform/win_fixed/icon.ico b/src/platform/win_fixed/icon.ico new file mode 100644 index 00000000..7a5aed33 Binary files /dev/null and b/src/platform/win_fixed/icon.ico differ diff --git a/src/platform/win_fixed/main.cpp b/src/platform/win_fixed/main.cpp new file mode 100644 index 00000000..91bd42f1 --- /dev/null +++ b/src/platform/win_fixed/main.cpp @@ -0,0 +1,489 @@ +#include "game.h" + +int FRAME_WIDTH = 1280; +int FRAME_HEIGHT = 720; + +int32 fps; +int32 frameIndex = 0; +int32 fpsCounter = 0; +uint32 curSoundBuffer = 0; + +const void* TRACKS_IMA; +const void* TITLE_SCR; +const void* levelData; + +HWND hWnd; +HDC hDC; + +LARGE_INTEGER g_timer; +LARGE_INTEGER g_current; + +LARGE_INTEGER gTimerFreq; +LARGE_INTEGER gTimerStart; + +void osSetPalette(const uint16* palette) +{ + // +} + +int32 osGetSystemTimeMS() +{ + LARGE_INTEGER count; + QueryPerformanceCounter(&count); + return int32((count.QuadPart - gTimerStart.QuadPart) * 1000L / gTimerFreq.QuadPart); +} + +bool osSaveSettings() +{ + FILE* f = fopen("settings.dat", "wb"); + if (!f) return false; + fwrite(&gSettings, sizeof(gSettings), 1, f); + fclose(f); + return true; +} + +bool osLoadSettings() +{ + FILE* f = fopen("settings.dat", "rb"); + if (!f) return false; + uint8 version; + fread(&version, 1, 1, f); + if (version != gSettings.version) { + fclose(f); + return false; + } + fread((uint8*)&gSettings + 1, sizeof(gSettings) - 1, 1, f); + fclose(f); + return true; +} + +bool osCheckSave() +{ + FILE* f = fopen("savegame.dat", "rb"); + if (!f) return false; + fclose(f); + return true; +} + +bool osSaveGame() +{ + FILE* f = fopen("savegame.dat", "wb"); + if (!f) return false; + fwrite(&gSaveGame, sizeof(gSaveGame), 1, f); + fwrite(&gSaveData, gSaveGame.dataSize, 1, f); + fclose(f); + return true; +} + +bool osLoadGame() +{ + FILE* f = fopen("savegame.dat", "rb"); + if (!f) return false; + + uint32 version; + fread(&version, sizeof(version), 1, f); + + if (SAVEGAME_VER != version) + { + fclose(f); + return false; + } + + fread(&gSaveGame.dataSize, sizeof(gSaveGame) - sizeof(version), 1, f); + fread(&gSaveData, gSaveGame.dataSize, 1, f); + fclose(f); + return true; +} + + +#define INPUT_JOY_COUNT 4 + +#define USE_GAMEPAD_XINPUT + +// gamepad +#ifdef USE_GAMEPAD_XINPUT +typedef struct _XINPUT_GAMEPAD { + WORD wButtons; + BYTE bLeftTrigger; + BYTE bRightTrigger; + SHORT sThumbLX; + SHORT sThumbLY; + SHORT sThumbRX; + SHORT sThumbRY; +} XINPUT_GAMEPAD, * PXINPUT_GAMEPAD; + +typedef struct _XINPUT_STATE { + DWORD dwPacketNumber; + XINPUT_GAMEPAD Gamepad; +} XINPUT_STATE, * PXINPUT_STATE; + +typedef struct _XINPUT_VIBRATION { + WORD wLeftMotorSpeed; + WORD wRightMotorSpeed; +} XINPUT_VIBRATION, * PXINPUT_VIBRATION; + +#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 +#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 +#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 + +DWORD(WINAPI* _XInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState); +DWORD(WINAPI* _XInputSetState) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration); +void (WINAPI* _XInputEnable) (BOOL enable); + +#define JOY_DEAD_ZONE_TRIGGER 0.01f +#define JOY_MIN_UPDATE_FX_TIME 50 + +struct JoyDevice { + int32 vL, vR; // current value for left/right motor vibration + int32 oL, oR; // last applied value + int32 time; // time when we can send vibration update + int32 mask; // buttons mask + bool ready; +} joyDevice[INPUT_JOY_COUNT]; + +bool osJoyReady(int index) { + return joyDevice[index].ready; +} + +void osJoyVibrate(int32 index, int32 L, int32 R) +{ + joyDevice[index].vL = L; + joyDevice[index].vR = R; +} + +void joyRumble(int index) +{ + if (!_XInputSetState) + return; + + JoyDevice& joy = joyDevice[index]; + + if (!joy.ready) + return; + + if ((joy.vL == joy.oL) && (joy.vR == joy.oR)) + return; + + if (osGetSystemTimeMS() < joy.time) + return; + + XINPUT_VIBRATION vibration; + vibration.wLeftMotorSpeed = WORD(joy.vL << 8); + vibration.wRightMotorSpeed = WORD(joy.vR << 8); + _XInputSetState(index, &vibration); + joy.oL = joy.vL; + joy.oR = joy.vR; + joy.time = osGetSystemTimeMS() + JOY_MIN_UPDATE_FX_TIME; +} + +void inputInit() { + memset(joyDevice, 0, sizeof(joyDevice)); + + HMODULE h = LoadLibrary("xinput1_3.dll"); + if (h == NULL) { + h = LoadLibrary("xinput9_1_0.dll"); + } + + if (!h) + return; + + #define GetProcAddr(lib, x) (x = (decltype(x))GetProcAddress(lib, #x + 1)) + + GetProcAddr(h, _XInputGetState); + GetProcAddr(h, _XInputSetState); + GetProcAddr(h, _XInputEnable); + + for (int i = 0; i < INPUT_JOY_COUNT; i++) + { + XINPUT_STATE state; + int res = _XInputGetState(i, &state); + joyDevice[i].ready = (_XInputGetState(i, &state) == ERROR_SUCCESS); + + if (joyDevice[i].ready) + LOG("Gamepad %d is ready\n", i + 1); + } +} + +void inputFree() +{ + memset(joyDevice, 0, sizeof(joyDevice)); +} + +void inputUpdate() +{ + if (!_XInputGetState) + return; + + for (int i = 0; i < INPUT_JOY_COUNT; i++) + { + if (!joyDevice[i].ready) + continue; + + joyRumble(i); + + XINPUT_STATE state; + if (_XInputGetState(i, &state) != ERROR_SUCCESS) + { + inputFree(); + inputInit(); + break; + } + + static const InputKey buttons[] = { IK_UP, IK_DOWN, IK_LEFT, IK_RIGHT, IK_START, IK_SELECT, IK_NONE, IK_NONE, IK_L, IK_R, IK_NONE, IK_NONE, IK_A, IK_B, IK_X, IK_Y }; + + int32 curMask = state.Gamepad.wButtons; + int32 oldMask = joyDevice[i].mask; + + for (int i = 0; i < 16; i++) + { + bool wasDown = (oldMask & (1 << i)) != 0; + bool isDown = (curMask & (1 << i)) != 0; + + if (isDown == wasDown) + continue; + + if (isDown && !wasDown) { + keys |= buttons[i]; + } else { + keys &= ~buttons[i]; + } + } + + joyDevice[i].mask = curMask; + + + //osJoyVibrate(j, state.Gamepad.bLeftTrigger / 255.0f, state.Gamepad.bRightTrigger / 255.0f); // vibration test + + /* + Input::setJoyPos(j, jkL, joyDir(joyAxis(state.Gamepad.sThumbLX, -32768, 32767), + joyAxis(-state.Gamepad.sThumbLY, -32768, 32767))); + Input::setJoyPos(j, jkR, joyDir(joyAxis(state.Gamepad.sThumbRX, -32768, 32767), + joyAxis(-state.Gamepad.sThumbRY, -32768, 32767))); + Input::setJoyPos(j, jkLT, vec2(state.Gamepad.bLeftTrigger / 255.0f, 0.0f)); + Input::setJoyPos(j, jkRT, vec2(state.Gamepad.bRightTrigger / 255.0f, 0.0f)); + */ + + + + + } +} +#elif defined(USE_GAMEPAD_WINMM) + +#else + +void osJoyVibrate(int32 index, int32 L, int32 R) {} + +#endif + + +uint8 soundBuffer[2 * SND_SAMPLES + 32]; // 32 bytes of silence for DMA overrun while interrupt + +HWAVEOUT waveOut; +WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 1, SND_OUTPUT_FREQ, SND_OUTPUT_FREQ, 1, 8, sizeof(waveFmt) }; +WAVEHDR waveBuf[2]; + +void soundInit() +{ +#if 0 + sndInit(); + + if (waveOutOpen(&waveOut, WAVE_MAPPER, &waveFmt, (INT_PTR)hWnd, 0, CALLBACK_WINDOW) != MMSYSERR_NOERROR) + return; + + memset(&waveBuf, 0, sizeof(waveBuf)); + for (int i = 0; i < 2; i++) + { + WAVEHDR *waveHdr = waveBuf + i; + waveHdr->dwBufferLength = SND_SAMPLES; + waveHdr->lpData = (LPSTR)(soundBuffer + i * SND_SAMPLES); + waveOutPrepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + waveOutWrite(waveOut, waveHdr, sizeof(WAVEHDR)); + } +#endif +} + +void soundFill() +{ +#if 0 + WAVEHDR *waveHdr = waveBuf + curSoundBuffer; + waveOutUnprepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + sndFill((uint8*)waveHdr->lpData, SND_SAMPLES); + waveOutPrepareHeader(waveOut, waveHdr, sizeof(WAVEHDR)); + waveOutWrite(waveOut, waveHdr, sizeof(WAVEHDR)); + curSoundBuffer ^= 1; +#endif +} + +LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_ACTIVATE: + { + keys = 0; + break; + } + + case WM_DESTROY : + { + PostQuitMessage(0); + break; + } + + case WM_KEYDOWN : + case WM_KEYUP : + case WM_SYSKEYUP : + case WM_SYSKEYDOWN : + { + InputKey key = IK_NONE; + switch (wParam) { + case VK_UP : key = IK_UP; break; + case VK_RIGHT : key = IK_RIGHT; break; + case VK_DOWN : key = IK_DOWN; break; + case VK_LEFT : key = IK_LEFT; break; + case 'A' : key = IK_B; break; + case 'S' : key = IK_A; break; + case 'Q' : key = IK_L; break; + case 'W' : key = IK_R; break; + case VK_RETURN : key = IK_START; break; + case VK_SPACE : key = IK_SELECT; break; + } + + if (wParam == '1') players[0]->extraL->goalWeapon = WEAPON_PISTOLS; + if (wParam == '2') players[0]->extraL->goalWeapon = WEAPON_MAGNUMS; + if (wParam == '3') players[0]->extraL->goalWeapon = WEAPON_UZIS; + if (wParam == '4') players[0]->extraL->goalWeapon = WEAPON_SHOTGUN; + + if (msg != WM_KEYUP && msg != WM_SYSKEYUP) { + keys |= key; + } else { + keys &= ~key; + } + break; + } + + case MM_WOM_DONE : + { + soundFill(); + break; + } + + case WM_SIZE : + { + FRAME_WIDTH = LOWORD(lParam); + FRAME_HEIGHT = HIWORD(lParam); + break; + } + + default : + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} + +const void* osLoadScreen(LevelID id) +{ + return (const void*)1; // TODO +} + +const void* osLoadLevel(LevelID id) +{ + // level1 + char buf[32]; + + delete[] levelData; + + sprintf(buf, "data/%s.PHD", (char*)gLevelInfo[id].data); + + FILE *f = fopen(buf, "rb"); + + if (!f) { + LOG("level file not found!"); + return NULL; + } + + fseek(f, 0, SEEK_END); + int32 size = ftell(f); + fseek(f, 0, SEEK_SET); + uint8* data = new uint8[size]; + fread(data, 1, size, f); + fclose(f); + + levelData = data; + + return (void*)levelData; +} + +// hint to the driver to use discrete GPU +extern "C" { + __declspec(dllexport) int NvOptimusEnablement = 1; // NVIDIA + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; // AMD +} + +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + QueryPerformanceFrequency(&gTimerFreq); + QueryPerformanceCounter(&gTimerStart); + +// int argc = (lpCmdLine && strlen(lpCmdLine)) ? 2 : 1; +// const char* argv[] = { "", lpCmdLine }; + + RECT r = { 0, 0, FRAME_WIDTH, FRAME_HEIGHT }; + + int sw = GetSystemMetrics(SM_CXSCREEN); + int sh = GetSystemMetrics(SM_CYSCREEN); + if (sw <= r.right + 128 || sh <= r.bottom + 128) { + r.right /= 2; + r.bottom /= 2; + } + + AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false); + int wx = (sw - (r.right - r.left)) / 2; + int wy = (sh - (r.bottom - r.top)) / 2; + + hWnd = CreateWindow("static", "OpenLara", WS_OVERLAPPEDWINDOW, wx + r.left, wy + r.top, r.right - r.left, r.bottom - r.top, 0, 0, 0, 0); + hDC = GetDC(hWnd); + + SetWindowLong(hWnd, GWL_WNDPROC, (LONG)&wndProc); + ShowWindow(hWnd, SW_SHOWDEFAULT); + + soundInit(); + inputInit(); + + gameInit(); + + MSG msg; + + int32 startTime = GetTickCount() - 33; + int32 lastFrame = 0; + + do { + if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + #ifdef _DEBUG + Sleep(4); + #endif + inputUpdate(); + + int32 frame = (GetTickCount() - startTime) / 33; + if (GetAsyncKeyState('R')) frame /= 10; + + int32 count = frame - lastFrame; + if (GetAsyncKeyState('T')) count *= 10; + gameUpdate(count); + lastFrame = frame; + + gameRender(); + + renderSwap(); + } + } while (msg.message != WM_QUIT); + + inputFree(); + gameFree(); + + return 0; +} diff --git a/src/platform/win_fixed/sound.cpp b/src/platform/win_fixed/sound.cpp new file mode 100644 index 00000000..2512df5c --- /dev/null +++ b/src/platform/win_fixed/sound.cpp @@ -0,0 +1,51 @@ +#include "common.h" + +void sndInit() +{ + // TODO +} + +void sndInitSamples() +{ + // TODO +} + +void sndFreeSamples() +{ + // TODO +} + +void* sndPlaySample(int32 index, int32 volume, int32 pitch, int32 mode) +{ + return NULL; // TODO +} + +void sndPlayTrack(int32 track) +{ + // TODO +} + +void sndStopTrack() +{ + // TODO +} + +bool sndTrackIsPlaying() +{ + return false; // TODO +} + +void sndStopSample(int32 index) +{ + // TODO +} + +void sndStop() +{ + // TODO +} + +void sndFill(uint8* buffer, int32 count) +{ + // TODO +} diff --git a/src/platform/wp8/OpenLara.sln b/src/platform/wp8/OpenLara.sln new file mode 100644 index 00000000..7b0762f2 --- /dev/null +++ b/src/platform/wp8/OpenLara.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{D2F22E35-7E0D-457C-8401-1CB2FA4277C9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|ARM.ActiveCfg = Debug|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|ARM.Build.0 = Debug|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|ARM.Deploy.0 = Debug|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|Win32.ActiveCfg = Debug|Win32 + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|Win32.Build.0 = Debug|Win32 + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Debug|Win32.Deploy.0 = Debug|Win32 + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|ARM.ActiveCfg = Release|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|ARM.Build.0 = Release|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|ARM.Deploy.0 = Release|ARM + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|Win32.ActiveCfg = Release|Win32 + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|Win32.Build.0 = Release|Win32 + {D2F22E35-7E0D-457C-8401-1CB2FA4277C9}.Release|Win32.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/platform/wp8/OpenLara.vcxproj b/src/platform/wp8/OpenLara.vcxproj new file mode 100644 index 00000000..42016ff6 --- /dev/null +++ b/src/platform/wp8/OpenLara.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {d2f22e35-7e0d-457c-8401-1cb2fa4277c9} + OpenLara + en-US + 11.0 + true + OpenLara.xap + true + OpenLara + + + + Application + true + v110_wp80 + + + Application + true + v110_wp80 + + + Application + false + true + v110_wp80 + + + Application + false + true + v110_wp80 + + + + + + + + ../..;../../libs;$(IncludePath) + + + ../..;../../libs;$(IncludePath) + + + ../..;../../libs;$(IncludePath) + + + ../..;../../libs;$(IncludePath) + + + + _CRT_SECURE_NO_WARNINGS;NOMINMAX;PSAPI_VERSION=2;%(PreprocessorDefinitions) + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + true + NotUsing + + + Xaudio2.lib;d3d11.lib;%(AdditionalDependencies) + false + ole32.lib;%(IgnoreSpecificDefaultLibraries) + + + + + _CRT_SECURE_NO_WARNINGS;NOMINMAX;PSAPI_VERSION=2;%(PreprocessorDefinitions) + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + true + NotUsing + + + Xaudio2.lib;d3d11.lib;%(AdditionalDependencies) + false + ole32.lib;%(IgnoreSpecificDefaultLibraries) + + + + + _CRT_SECURE_NO_WARNINGS;NOMINMAX;PSAPI_VERSION=2;%(PreprocessorDefinitions) + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + true + NotUsing + + + Xaudio2.lib;d3d11.lib;%(AdditionalDependencies) + false + ole32.lib;%(IgnoreSpecificDefaultLibraries) + + + + + _CRT_SECURE_NO_WARNINGS;NOMINMAX;PSAPI_VERSION=2;%(PreprocessorDefinitions) + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + true + NotUsing + + + Xaudio2.lib;d3d11.lib;%(AdditionalDependencies) + false + ole32.lib;%(IgnoreSpecificDefaultLibraries) + + + + + true + false + + + + + + + + + + + Designer + + + + + + false + false + false + false + + + false + false + false + false + + + + + + + + + + Document + + + Document + + + Document + + + Document + + + + + + + \ No newline at end of file diff --git a/src/platform/wp8/OpenLara.vcxproj.filters b/src/platform/wp8/OpenLara.vcxproj.filters new file mode 100644 index 00000000..8fbf3d77 --- /dev/null +++ b/src/platform/wp8/OpenLara.vcxproj.filters @@ -0,0 +1,75 @@ + + + + + 17b52f90-9b33-4188-8a0e-808582bbabbc + ico;bmp;dlg;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;resw;resjson + + + {095bc541-7391-4afd-8d1a-bf8ffb6c9db6} + + + {64d3ea92-1a79-4d88-9672-ab9b528494d3} + + + {93e9d653-9fd0-4db2-bb1b-ab70c41de674} + + + {cfed5f2e-b257-47d1-b336-a0d7b4e8ff9b} + + + {05e6d078-92d8-4497-b3f9-217b429676ad} + + + + + Assets + + + Assets + + + Assets + + + Content + + + + + + libs\minimp3 + + + libs\stb_vorbis + + + libs\tinf + + + + + + + + libs\minimp3 + + + libs\tinf + + + + + Content + + + Content + + + Content + + + Content + + + \ No newline at end of file diff --git a/src/platform/wp8/WMAppManifest.xml b/src/platform/wp8/WMAppManifest.xml new file mode 100644 index 00000000..58bf77a4 --- /dev/null +++ b/src/platform/wp8/WMAppManifest.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + Assets\ApplicationIcon.png + + + + + + + + + + + Assets\Tiles\FlipCycleTileSmall.png + 0 + Assets\Tiles\FlipCycleTileMedium.png + OpenLara + + + + + + + + + false + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/wp8/main.cpp b/src/platform/wp8/main.cpp new file mode 100644 index 00000000..dc7c2ecd --- /dev/null +++ b/src/platform/wp8/main.cpp @@ -0,0 +1,518 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "game.h" + +using namespace Windows; +using namespace DirectX; +using namespace Microsoft::WRL; +using namespace Windows::Foundation; +using namespace Windows::Graphics::Display; +using namespace Windows::ApplicationModel::Core; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::UI::Core; +using namespace Windows::System; +using namespace Windows::Foundation; +using namespace Windows::Graphics::Display; +using namespace Windows::Storage; +using namespace Concurrency; + +// multi-threading +void* osMutexInit() +{ + CRITICAL_SECTION *CS = new CRITICAL_SECTION(); + InitializeCriticalSectionEx(CS, 0, 0); + return CS; +} + +void osMutexFree(void *obj) +{ + DeleteCriticalSection((CRITICAL_SECTION*)obj); + delete (CRITICAL_SECTION*)obj; +} + +void osMutexLock(void *obj) +{ + EnterCriticalSection((CRITICAL_SECTION*)obj); +} + +void osMutexUnlock(void *obj) +{ + LeaveCriticalSection((CRITICAL_SECTION*)obj); +} + + +// timing +int osStartTime = 0; + +int osGetTimeMS() +{ + LARGE_INTEGER Freq, Count; + QueryPerformanceFrequency(&Freq); + QueryPerformanceCounter(&Count); + return int(Count.QuadPart * 1000L / Freq.QuadPart); +} + + +// input +bool osJoyReady(int index) +{ + return false; +} + +void osJoyVibrate(int index, float L, float R) +{ + // +} + + +// sound +#define SND_SIZE 4704*sizeof(int16) +#define SND_MAX_BUFFERS 2 + +struct AudioContext : public IXAudio2VoiceCallback +{ + Microsoft::WRL::ComPtr pXAudio2; + HANDLE event; + + virtual void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32) override {} + virtual void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() override {} + virtual void STDMETHODCALLTYPE OnStreamEnd() override {} + virtual void STDMETHODCALLTYPE OnLoopEnd(void*) override {} + virtual void STDMETHODCALLTYPE OnVoiceError(void*, HRESULT) override {} + virtual void STDMETHODCALLTYPE OnBufferStart(void*) override {} + + virtual void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) + { + SetEvent(event); + } + + AudioContext() + { + event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); + } + + virtual ~AudioContext() + { + CloseHandle(event); + } + + void start() + { + auto workItem = ref new Windows::System::Threading::WorkItemHandler([this](IAsyncAction^ workItem) + { + AudioContext::fill(this); + }); + + Windows::System::Threading::ThreadPool::RunAsync(workItem); + } + + void stop() { + SetEvent(event); + } + + void suspend() { + pXAudio2->StopEngine(); + } + + void resume() { + pXAudio2->StartEngine(); + } + + static DWORD WINAPI fill(LPVOID lpParam) + { + AudioContext* context = (AudioContext*)lpParam; + + IXAudio2MasteringVoice* masteringVoice; + IXAudio2SourceVoice* sourceVoice; + uint32 bufferIndex = 0; + + if (FAILED(XAudio2Create(context->pXAudio2.GetAddressOf(), 0))) { + return 0; + } + + if (FAILED(context->pXAudio2->CreateMasteringVoice(&masteringVoice))) { + return 0; + } + + uint8* data = new uint8[SND_SIZE * SND_MAX_BUFFERS]; + + WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 2, 44100, 44100 * 4, 4, 16, sizeof(waveFmt) }; + + if (FAILED(context->pXAudio2->CreateSourceVoice(&sourceVoice, &waveFmt, 0, XAUDIO2_DEFAULT_FREQ_RATIO, context))) { + return 0; + } + + if (FAILED(sourceVoice->Start(0))) { + return 0; + } + + while (!Core::isQuit) + { + XAUDIO2_VOICE_STATE state; + sourceVoice->GetState(&state, XAUDIO2_VOICE_NOSAMPLESPLAYED); + + if (state.BuffersQueued < SND_MAX_BUFFERS) { + XAUDIO2_BUFFER buffer = {}; + buffer.AudioBytes = SND_SIZE; + buffer.pAudioData = data + SND_SIZE * bufferIndex; + + Sound::fill((Sound::Frame*)buffer.pAudioData, buffer.AudioBytes / 4); + + bufferIndex = (bufferIndex + 1) % SND_MAX_BUFFERS; + + sourceVoice->SubmitSourceBuffer(&buffer); + } + else { + WaitForSingleObjectEx(context->event, INFINITE, FALSE); + } + } + + delete[] data; + + return 0; + } +}; + + +// system +Microsoft::WRL::ComPtr osDevice; +Microsoft::WRL::ComPtr osContext; +Microsoft::WRL::ComPtr osSwapChain; + +float ConvertDipsToPixels(float dips) +{ + static const float dipsPerInch = 96.0f; + return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); +} + +ref class View sealed : public IFrameworkView +{ +private: + Platform::Agile m_window; + AudioContext audioContext; + bool m_windowVisible; + +public: + View() : m_windowVisible(true) {} + + void InitD3D11(Windows::UI::Core::CoreWindow^ window) + { + m_window = window; + + CreateDeviceResources(); + CreateWindowSizeDependentResources(); + } + + void HandleDeviceLost() + { + ReleaseResourcesForSuspending(); + CreateDeviceResources(); + CreateWindowSizeDependentResources(); + } + + void CreateDeviceResources() + { + UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + //creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + + D3D_FEATURE_LEVEL featureLevels[] = + { + D3D_FEATURE_LEVEL_9_3 + }; + + ComPtr device; + ComPtr context; + + D3D11CreateDevice( + nullptr, + D3D_DRIVER_TYPE_HARDWARE, + nullptr, + creationFlags, + featureLevels, + ARRAYSIZE(featureLevels), + D3D11_SDK_VERSION, + &device, + nullptr, + &context); + + device.As(&osDevice); + context.As(&osContext); + } + + void CreateWindowSizeDependentResources() + { + Core::width = int32(ConvertDipsToPixels(m_window->Bounds.Width)); + Core::height = int32(ConvertDipsToPixels(m_window->Bounds.Height)); + + DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 }; + swapChainDesc.Width = Core::width; + swapChainDesc.Height = Core::height; + swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + swapChainDesc.Stereo = false; + swapChainDesc.SampleDesc.Count = 1; + swapChainDesc.SampleDesc.Quality = 0; + swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapChainDesc.BufferCount = 1; + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + swapChainDesc.Flags = 0; + + ComPtr dxgiDevice; + osDevice.As(&dxgiDevice); + + ComPtr dxgiAdapter; + dxgiDevice->GetAdapter(&dxgiAdapter); + + ComPtr dxgiFactory; + dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory); + + Windows::UI::Core::CoreWindow^ window = m_window.Get(); + dxgiFactory->CreateSwapChainForCoreWindow( + osDevice.Get(), + reinterpret_cast(window), + &swapChainDesc, + nullptr, + &osSwapChain); + + dxgiDevice->SetMaximumFrameLatency(1); + } + + void ReleaseResourcesForSuspending() + { + GAPI::resetDevice(); + osSwapChain = nullptr; + } + + void Present() + { + HRESULT hr = osSwapChain->Present(1, 0); + + if (hr == DXGI_ERROR_DEVICE_REMOVED) + { + HandleDeviceLost(); + } + } + + virtual void Initialize(CoreApplicationView^ applicationView) + { + applicationView->Activated += + ref new TypedEventHandler(this, &View::OnActivated); + + CoreApplication::Suspending += + ref new EventHandler(this, &View::OnSuspending); + + CoreApplication::Resuming += + ref new EventHandler(this, &View::OnResuming); + } + + virtual void SetWindow(CoreWindow^ window) + { + DisplayProperties::AutoRotationPreferences = + Windows::Graphics::Display::DisplayOrientations::Landscape; + + window->VisibilityChanged += + ref new TypedEventHandler(this, &View::OnVisibilityChanged); + + window->Closed += + ref new TypedEventHandler(this, &View::OnWindowClosed); + + window->PointerPressed += + ref new TypedEventHandler(this, &View::OnPointerPressed); + + window->PointerMoved += + ref new TypedEventHandler(this, &View::OnPointerMoved); + + window->PointerReleased += + ref new TypedEventHandler(this, &View::OnPointerReleased); + + InitD3D11(CoreWindow::GetForCurrentThread()); + } + + int checkLanguage() + { + ULONG numLanguages = 0; + DWORD cchLanguagesBuffer = 0; + BOOL hr = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLanguages, NULL, &cchLanguagesBuffer); + if (!hr) return 0; + + WCHAR* id = new WCHAR[cchLanguagesBuffer]; + hr = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLanguages, id, &cchLanguagesBuffer); + if (!hr) return 0; + + #define CHECK(str) (wcsstr(id, L##str L"-") != 0) + + int str = STR_LANG_EN; + + if (CHECK("fr")) { + str = STR_LANG_FR; + } else if (CHECK("de")) { + str = STR_LANG_DE; + } else if (CHECK("es")) { + str = STR_LANG_ES; + } else if (CHECK("it")) { + str = STR_LANG_IT; + } else if (CHECK("pl")) { + str = STR_LANG_PL; + } else if (CHECK("pt")) { + str = STR_LANG_PT; + } else if (CHECK("ru") || CHECK("be") || CHECK("uk")) { + str = STR_LANG_RU; + } else if (CHECK("ja")) { + str = STR_LANG_JA; + } else if (CHECK("gr")) { + str = STR_LANG_GR; + } else if (CHECK("fi")) { + str = STR_LANG_FI; + } else if (CHECK("cs")) { + str = STR_LANG_CZ; + } else if (CHECK("zh")) { + str = STR_LANG_CN; + } else if (CHECK("hu")) { + str = STR_LANG_HU; + } else if (CHECK("sv")) { + str = STR_LANG_SV; + } + + return str - STR_LANG_EN; + } + + virtual void Load(Platform::String^ entryPoint) {} + + virtual void Run() + { + cacheDir[0] = saveDir[0] = contentDir[0] = 0; + + StorageFolder^ localFolder = Windows::Storage::ApplicationData::Current->LocalFolder; + wcstombs(cacheDir, localFolder->Path->Data(), sizeof(cacheDir)); + strcat(cacheDir, "\\"); + strcpy(saveDir, cacheDir); + + auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation; + const wchar_t* path = folder->Path->Data(); + wcstombs(contentDir, path, sizeof(contentDir) - 1); + strcat(contentDir, "\\Content\\"); + + osStartTime = osGetTimeMS(); + + audioContext.start(); + + Core::defLang = checkLanguage(); + + Game::init((const char*)NULL); + + while (!Core::isQuit) + { + if (m_windowVisible) + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); + + if (Game::update()) + { + Game::render(); + Present(); + } + } + else + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + } + } + + audioContext.stop(); + Game::deinit(); + } + + virtual void Uninitialize() {} + +protected: + + void OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) + { + CoreWindow::GetForCurrentThread()->Activate(); + } + + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args) + { + audioContext.suspend(); + + ReleaseResourcesForSuspending(); + + Windows::ApplicationModel::SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); + create_task([this, deferral]() + { + Game::quickSave(); + deferral->Complete(); + }); + } + + void OnResuming(Platform::Object^ sender, Platform::Object^ args) + { + CreateWindowSizeDependentResources(); + + Game::quickLoad(true); + + audioContext.resume(); + } + + void OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) + { + Core::quit(); + } + + void OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) + { + m_windowVisible = args->Visible; + } + + void OnPointer(Windows::UI::Input::PointerPoint^ p, bool down) + { + InputKey key = Input::getTouch(p->PointerId); + if (key == ikNone) return; + + int32 y = Core::width - int32(ConvertDipsToPixels(p->Position.X)); + int32 x = int32(ConvertDipsToPixels(p->Position.Y)); + + Input::setPos(key, vec2(float(x), float(y))); + Input::setDown(key, down); + } + + void OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) + { + OnPointer(args->CurrentPoint, true); + } + + void OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) + { + OnPointer(args->CurrentPoint, true); + } + + void OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) + { + OnPointer(args->CurrentPoint, false); + } +}; + +ref class ViewSource sealed : ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual ApplicationModel::Core::IFrameworkView^ CreateView() + { + return ref new View(); + } +}; + +[Platform::MTAThread] +int main(Platform::Array^) +{ + auto viewSource = ref new ViewSource(); + ApplicationModel::Core::CoreApplication::Run(viewSource); + return 0; +} \ No newline at end of file diff --git a/src/platform/xb1/Assets/LargeTile.scale-200.png b/src/platform/xb1/Assets/LargeTile.scale-200.png new file mode 100644 index 00000000..6b8e2cb5 Binary files /dev/null and b/src/platform/xb1/Assets/LargeTile.scale-200.png differ diff --git a/src/platform/xb1/Assets/SmallTile.scale-200.png b/src/platform/xb1/Assets/SmallTile.scale-200.png new file mode 100644 index 00000000..d5e72e28 Binary files /dev/null and b/src/platform/xb1/Assets/SmallTile.scale-200.png differ diff --git a/src/platform/xb1/Assets/SplashScreen.scale-200.png b/src/platform/xb1/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000..3ef80865 Binary files /dev/null and b/src/platform/xb1/Assets/SplashScreen.scale-200.png differ diff --git a/src/platform/xb1/Assets/Square150x150Logo.scale-200.png b/src/platform/xb1/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000..78f8b235 Binary files /dev/null and b/src/platform/xb1/Assets/Square150x150Logo.scale-200.png differ diff --git a/src/platform/xb1/Assets/Square44x44Logo.altform-unplated_targetsize-48.png b/src/platform/xb1/Assets/Square44x44Logo.altform-unplated_targetsize-48.png new file mode 100644 index 00000000..42fb2bdb Binary files /dev/null and b/src/platform/xb1/Assets/Square44x44Logo.altform-unplated_targetsize-48.png differ diff --git a/src/platform/xb1/Assets/Square44x44Logo.scale-200.png b/src/platform/xb1/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..8893058e Binary files /dev/null and b/src/platform/xb1/Assets/Square44x44Logo.scale-200.png differ diff --git a/src/platform/xb1/Assets/Square44x44Logo.targetsize-48.png b/src/platform/xb1/Assets/Square44x44Logo.targetsize-48.png new file mode 100644 index 00000000..42fb2bdb Binary files /dev/null and b/src/platform/xb1/Assets/Square44x44Logo.targetsize-48.png differ diff --git a/src/platform/xb1/Assets/StoreLogo.scale-200.png b/src/platform/xb1/Assets/StoreLogo.scale-200.png new file mode 100644 index 00000000..98ba5a86 Binary files /dev/null and b/src/platform/xb1/Assets/StoreLogo.scale-200.png differ diff --git a/src/platform/xb1/Assets/Wide310x150Logo.scale-200.png b/src/platform/xb1/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..12e41d09 Binary files /dev/null and b/src/platform/xb1/Assets/Wide310x150Logo.scale-200.png differ diff --git a/src/platform/xb1/OpenLara.sln b/src/platform/xb1/OpenLara.sln new file mode 100644 index 00000000..86965dcf --- /dev/null +++ b/src/platform/xb1/OpenLara.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{0DF8D188-E91B-49C5-A2C5-75C430648B5E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.ActiveCfg = Debug|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.Build.0 = Debug|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.Deploy.0 = Debug|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.Build.0 = Debug|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.ActiveCfg = Debug|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.Build.0 = Debug|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.Deploy.0 = Debug|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.ActiveCfg = Debug|Win32 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.Build.0 = Debug|Win32 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.Deploy.0 = Debug|Win32 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.ActiveCfg = Release|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.Build.0 = Release|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.Deploy.0 = Release|ARM + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.ActiveCfg = Release|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.Build.0 = Release|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.Deploy.0 = Release|ARM64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.ActiveCfg = Release|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.Build.0 = Release|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.Deploy.0 = Release|x64 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.ActiveCfg = Release|Win32 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.Build.0 = Release|Win32 + {0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {037CFBE7-50F7-492C-B712-18C42FD39BE3} + EndGlobalSection +EndGlobal diff --git a/src/platform/xb1/OpenLara.vcxproj b/src/platform/xb1/OpenLara.vcxproj new file mode 100644 index 00000000..f12b042a --- /dev/null +++ b/src/platform/xb1/OpenLara.vcxproj @@ -0,0 +1,332 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + {0df8d188-e91b-49c5-a2c5-75c430648b5e} + DirectXApp + OpenLara + en-US + 14.0 + true + Windows Store + 10.0.17763.0 + 10.0.16299.0 + 10.0 + + + + Application + true + v141 + + + Application + true + v141 + + + Application + true + v141 + true + + + Application + true + v141 + + + Application + false + true + v141 + true + + + Application + false + true + v141 + true + + + Application + false + true + v141 + true + + + Application + false + true + v141 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OpenLara_TemporaryKey.pfx + False + False + Always + x64 + 0F7D3218F53B8902E26C7E787E16EB3520A9898C + 1 + OnApplicationRun + False + + + ..\..\libs\;..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + + + ..\..\libs\;..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath); + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm; $(VCInstallDir)\lib\arm + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\arm64; $(VCInstallDir)\lib\arm64 + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store; $(VCInstallDir)\lib + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + NDEBUG;%(PreprocessorDefinitions) + + + + + d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + + + pch.h + $(IntDir)pch.pch + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + _DEBUG;%(PreprocessorDefinitions) + + + + + vccorlib.lib; msvcrt.lib; d2d1.lib; d3d11.lib; dxgi.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) + %(AdditionalLibraryDirectories); $(VCInstallDir)\lib\store\amd64; $(VCInstallDir)\lib\amd64 + vccorlib;msvcrt + + + $(ProjectDir);$(IntermediateOutputPath);%(AdditionalIncludeDirectories) + /bigobj %(AdditionalOptions) + 4453;28204 + __XB1__;__UWP__;NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + NotUsing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/xb1/OpenLara.vcxproj.filters b/src/platform/xb1/OpenLara.vcxproj.filters new file mode 100644 index 00000000..619c14bc --- /dev/null +++ b/src/platform/xb1/OpenLara.vcxproj.filters @@ -0,0 +1,103 @@ + + + + + db6ab835-f1cb-4efb-94eb-2bdfd0c3a3d2 + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + {ba6867bc-3dac-49f7-b628-c02d534f8825} + + + {d606bd3a-145c-432f-ae5a-66dcb178b466} + + + {d5e2e716-2bc5-43a1-bebc-4c5631d0b1bc} + + + + + + libs\tinf + + + libs\stb_vorbis + + + + + libs\tinf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + \ No newline at end of file diff --git a/src/platform/xb1/OpenLara.vcxproj.user b/src/platform/xb1/OpenLara.vcxproj.user new file mode 100644 index 00000000..85512529 --- /dev/null +++ b/src/platform/xb1/OpenLara.vcxproj.user @@ -0,0 +1,23 @@ + + + + UWPRemoteDebugger + 192.168.1.49 + + + AppHostLocalDebugger + 192.168.1.49 + + + UWPRemoteDebugger + 192.168.1.49 + + + True + False + x64 + False + 192.168.1.49 + True + + \ No newline at end of file diff --git a/src/platform/xb1/OpenLara_TemporaryKey.pfx b/src/platform/xb1/OpenLara_TemporaryKey.pfx new file mode 100644 index 00000000..fc69764f Binary files /dev/null and b/src/platform/xb1/OpenLara_TemporaryKey.pfx differ diff --git a/src/platform/xb1/Package.StoreAssociation.xml b/src/platform/xb1/Package.StoreAssociation.xml new file mode 100644 index 00000000..b6f680e1 --- /dev/null +++ b/src/platform/xb1/Package.StoreAssociation.xml @@ -0,0 +1,371 @@ + + + CN=EAAE5CD2-DCE4-4EC0-B98D-40B753FDC939 + XProger + MSA + http://www.w3.org/2001/04/xmlenc#sha256 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 39822XProger.OpenLara + + OpenLara + + + + + \ No newline at end of file diff --git a/src/platform/xb1/Package.appxmanifest b/src/platform/xb1/Package.appxmanifest new file mode 100644 index 00000000..312c87c5 --- /dev/null +++ b/src/platform/xb1/Package.appxmanifest @@ -0,0 +1,33 @@ + + + + + + OpenLara + XProger + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/platform/xb1/main.cpp b/src/platform/xb1/main.cpp new file mode 100644 index 00000000..bbe0764a --- /dev/null +++ b/src/platform/xb1/main.cpp @@ -0,0 +1,507 @@ +#include +#include +#include +#include + +#include "game.h" + +using namespace Concurrency; +using namespace Windows; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::UI::Core; +using namespace Windows::Foundation; +using namespace Windows::Graphics; +using namespace Windows::Gaming::Input; +using namespace Windows::Storage; +using namespace Windows::Globalization; +using namespace Windows::System::UserProfile; +using namespace Microsoft::WRL; + + +ID3D11Device *device; +ID3D11DeviceContext *deviceContext; +IDXGISwapChain1 *swapChain; + + +// multi-threading +void* osMutexInit() +{ + CRITICAL_SECTION *CS = new CRITICAL_SECTION(); + InitializeCriticalSection(CS); + return CS; +} + +void osMutexFree(void *obj) +{ + DeleteCriticalSection((CRITICAL_SECTION*)obj); + delete (CRITICAL_SECTION*)obj; +} + +void osMutexLock(void *obj) +{ + EnterCriticalSection((CRITICAL_SECTION*)obj); +} + +void osMutexUnlock(void *obj) +{ + LeaveCriticalSection((CRITICAL_SECTION*)obj); +} + + +// timing +LARGE_INTEGER timerFreq; +LARGE_INTEGER timerStart; + +int osGetTimeMS() +{ + LARGE_INTEGER time; + QueryPerformanceCounter(&time); + return int32((time.QuadPart - timerStart.QuadPart) * 1000L / timerFreq.QuadPart); +} + + +// input +struct JoyDevice { + Gamepad^ gamepad; + int time; + float vL, vR; + float oL, oR; +} joyDevice[INPUT_JOY_COUNT]; + +Core::Mutex joyLock; + +#define JOY_MIN_UPDATE_FX_TIME 50 +#define JOY_TRIGGER_THRESHOLD 0.1f + +void osJoyVibrate(int index, float L, float R) +{ + joyDevice[index].vL = L; + joyDevice[index].vR = R; +} + +float joyTrigger(double value) +{ + return clamp(((float)value - JOY_TRIGGER_THRESHOLD) / (1.0f - JOY_TRIGGER_THRESHOLD), 0.0f, 1.0f); +} + +void joyUpdate() +{ + OS_LOCK(joyLock); + + #define JOY_BUTTON(index, btn, mask) Input::setJoyDown(index, btn, (state.Buttons & mask) == mask); + + for (int i = 0; i < INPUT_JOY_COUNT; i++) + { + JoyDevice &joy = joyDevice[i]; + + if (!joy.gamepad) continue; + + GamepadReading& state = joy.gamepad->GetCurrentReading(); + + JOY_BUTTON(i, jkA, GamepadButtons::A); + JOY_BUTTON(i, jkB, GamepadButtons::B); + JOY_BUTTON(i, jkX, GamepadButtons::X); + JOY_BUTTON(i, jkY, GamepadButtons::Y); + JOY_BUTTON(i, jkLeft, GamepadButtons::DPadLeft); + JOY_BUTTON(i, jkRight, GamepadButtons::DPadRight); + JOY_BUTTON(i, jkUp, GamepadButtons::DPadUp); + JOY_BUTTON(i, jkDown, GamepadButtons::DPadDown); + JOY_BUTTON(i, jkSelect, GamepadButtons::View); + JOY_BUTTON(i, jkStart, GamepadButtons::Menu); + JOY_BUTTON(i, jkL, GamepadButtons::LeftThumbstick); + JOY_BUTTON(i, jkR, GamepadButtons::RightThumbstick); + JOY_BUTTON(i, jkLB, GamepadButtons::LeftShoulder); + JOY_BUTTON(i, jkRB, GamepadButtons::RightShoulder); + + Input::setJoyPos(i, jkL, vec2(float(state.LeftThumbstickX), -float(state.LeftThumbstickY))); + Input::setJoyPos(i, jkR, vec2(float(state.RightThumbstickX), -float(state.RightThumbstickY))); + Input::setJoyPos(i, jkLT, vec2(joyTrigger(state.LeftTrigger), 0.0f)); + Input::setJoyPos(i, jkRT, vec2(joyTrigger(state.RightTrigger), 0.0f)); + + if ((joy.vL != joy.oL || joy.vR != joy.oR) && osGetTimeMS() >= joy.time) { + GamepadVibration vibration; + vibration.LeftMotor = joy.vL; + vibration.RightMotor = joy.vR; + joy.gamepad->Vibration = vibration; + joy.oL = joy.vL; + joy.oR = joy.vR; + joy.time = osGetTimeMS() + JOY_MIN_UPDATE_FX_TIME; + } + } + + #undef JOY_BUTTON +} + +void joyAdd(Platform::Object^, Gamepad^ args) +{ + OS_LOCK(joyLock); + for (int i = 0; i < INPUT_JOY_COUNT; i++) + { + JoyDevice &joy = joyDevice[i]; + if (joy.gamepad) continue; + joy.gamepad = args; + return; + } +} + +void joyRemove(Platform::Object^, Gamepad^ args) +{ + OS_LOCK(joyLock); + for (int i = 0; i < INPUT_JOY_COUNT; i++) + { + JoyDevice &joy = joyDevice[i]; + if (!joy.gamepad) continue; + if (joy.gamepad == args) { + joy = {}; + return; + } + } +} + +void joyInit() +{ + Gamepad::GamepadAdded += ref new EventHandler(&joyAdd); + Gamepad::GamepadRemoved += ref new EventHandler(&joyRemove); +} + + +// sound +#define SND_SIZE 4704*sizeof(int16) +#define SND_MAX_BUFFERS 2 + +struct AudioContext : public IXAudio2VoiceCallback +{ + Microsoft::WRL::ComPtr pXAudio2; + HANDLE event; + + virtual void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32) override {} + virtual void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() override {} + virtual void STDMETHODCALLTYPE OnStreamEnd() override {} + virtual void STDMETHODCALLTYPE OnLoopEnd(void*) override {} + virtual void STDMETHODCALLTYPE OnVoiceError(void*, HRESULT) override {} + virtual void STDMETHODCALLTYPE OnBufferStart(void*) override {} + + virtual void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) + { + SetEvent(event); + } + + AudioContext() + { + event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); + } + + virtual ~AudioContext() + { + CloseHandle(event); + } + + void start() + { + CreateThread(NULL, 0, fill, this, 0, NULL); + } + + void stop() { + SetEvent(event); + } + + void suspend() { + pXAudio2->StopEngine(); + } + + void resume() { + pXAudio2->StartEngine(); + } + + static DWORD WINAPI fill(LPVOID lpParam) + { + AudioContext* context = (AudioContext*)lpParam; + + IXAudio2MasteringVoice* masteringVoice; + IXAudio2SourceVoice* sourceVoice; + uint32 bufferIndex = 0; + + if (FAILED(XAudio2Create(context->pXAudio2.GetAddressOf(), 0))) { + return 0; + } + + if (FAILED(context->pXAudio2->CreateMasteringVoice(&masteringVoice))) { + return 0; + } + + uint8* data = new uint8[SND_SIZE * SND_MAX_BUFFERS]; + + WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 2, 44100, 44100 * 4, 4, 16, sizeof(waveFmt) }; + + if (FAILED(context->pXAudio2->CreateSourceVoice(&sourceVoice, &waveFmt, 0, XAUDIO2_DEFAULT_FREQ_RATIO, context))) { + return 0; + } + + if (FAILED(sourceVoice->Start(0))) { + return 0; + } + + while (!Core::isQuit) + { + XAUDIO2_VOICE_STATE state; + sourceVoice->GetState(&state, XAUDIO2_VOICE_NOSAMPLESPLAYED); + + if (state.BuffersQueued < SND_MAX_BUFFERS) { + XAUDIO2_BUFFER buffer = {}; + buffer.AudioBytes = SND_SIZE; + buffer.pAudioData = data + SND_SIZE * bufferIndex; + + Sound::fill((Sound::Frame*)buffer.pAudioData, buffer.AudioBytes / 4); + + bufferIndex = (bufferIndex + 1) % SND_MAX_BUFFERS; + + sourceVoice->SubmitSourceBuffer(&buffer); + } else { + WaitForSingleObject(context->event, INFINITE); + } + } + + delete[] data; + + return 0; + } +}; + + +struct RenderContext +{ + void init(CoreWindow^ window) + { + D3D_FEATURE_LEVEL featureLevels[] = { + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1 + }; + + HRESULT ret; + ret = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, &device, NULL, &deviceContext); + ASSERT(ret == S_OK); + + ComPtr dxgiDevice; + ComPtr(device).As(&dxgiDevice); + + ComPtr dxgiAdapter; + dxgiDevice->GetAdapter(&dxgiAdapter); + + ComPtr dxgiFactory; + dxgiAdapter->GetParent(IID_PPV_ARGS(&dxgiFactory)); + + DXGI_SWAP_CHAIN_DESC1 desc = {}; + desc.Width = Core::width; + desc.Height = Core::height; + desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + desc.BufferCount = 2; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; + desc.Scaling = DXGI_SCALING_NONE; + desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; + + ret = dxgiFactory->CreateSwapChainForCoreWindow(device, reinterpret_cast(window), &desc, NULL, &swapChain); + ASSERT(ret == S_OK); + + dxgiDevice->SetMaximumFrameLatency(1); + } + + void present() + { + swapChain->Present(Core::settings.detail.vsync ? 1 : 0, 0); + } +}; + + +ref class View sealed : public ApplicationModel::Core::IFrameworkView +{ +private: + AudioContext audioContext; + RenderContext renderContext; + + bool m_windowVisible; + +public: + View() : m_windowVisible(true) {}; + + virtual void Initialize(ApplicationModel::Core::CoreApplicationView^ applicationView) + { + applicationView->Activated += ref new TypedEventHandler(this, &View::OnActivated); + ApplicationModel::Core::CoreApplication::Suspending += ref new EventHandler(this, &View::OnSuspending); + ApplicationModel::Core::CoreApplication::Resuming += ref new EventHandler(this, &View::OnResuming); + } + + virtual void SetWindow(CoreWindow^ window) + { + window->VisibilityChanged += ref new TypedEventHandler(this, &View::OnVisibilityChanged); + window->Closed += ref new TypedEventHandler(this, &View::OnWindowClosed); + SystemNavigationManager::GetForCurrentView()->BackRequested += ref new EventHandler(this, &View::OnBackRequested); + + Core::width = 1920; + Core::height = 1080; + + renderContext.init(window); + } + + int checkLanguage() + { + Platform::String^ language = GlobalizationPreferences::Languages->GetAt(0); + const wchar_t* id = language->Begin(); + + #define CHECK(str) (wcsstr(id, L##str"-") != 0) + + int str = STR_LANG_EN; + + if (CHECK("fr")) { + str = STR_LANG_FR; + } else if (CHECK("de")) { + str = STR_LANG_DE; + } else if (CHECK("es")) { + str = STR_LANG_ES; + } else if (CHECK("it")) { + str = STR_LANG_IT; + } else if (CHECK("pl")) { + str = STR_LANG_PL; + } else if (CHECK("pt")) { + str = STR_LANG_PT; + } else if (CHECK("ru") || CHECK("be") || CHECK("uk")) { + str = STR_LANG_RU; + } else if (CHECK("ja")) { + str = STR_LANG_JA; + } else if (CHECK("gr")) { + str = STR_LANG_GR; + } else if (CHECK("fi")) { + str = STR_LANG_FI; + } else if (CHECK("cs")) { + str = STR_LANG_CZ; + } else if (CHECK("zh")) { + str = STR_LANG_CN; + } else if (CHECK("hu")) { + str = STR_LANG_HU; + } else if (CHECK("sv")) { + str = STR_LANG_SV; + } + + return str - STR_LANG_EN; + } + + virtual void Load(Platform::String^ entryPoint) + { + // + } + + virtual void Run() + { + contentDir[0] = saveDir[0] = cacheDir[0] = 0; + + StorageFolder^ localFolder = ApplicationData::Current->LocalFolder; + wcstombs(contentDir, localFolder->Path->Data(), sizeof(contentDir)); + strcat(contentDir, "\\"); + strcpy(saveDir, contentDir); + strcpy(cacheDir, contentDir); + + Stream::addPack("content.zip"); + + GAPI::defRTV = NULL; + GAPI::defDSV = NULL; + + QueryPerformanceFrequency(&timerFreq); + QueryPerformanceCounter(&timerStart); + + Sound::channelsCount = 0; + + joyInit(); + audioContext.start(); + + Core::defLang = checkLanguage(); + + Game::init((const char*)NULL); + + while (!Core::isQuit) + { + if (m_windowVisible) + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); + + joyUpdate(); + + if (Game::update()) { + Game::render(); + renderContext.present(); + } + } else { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + } + } + + audioContext.stop(); + Game::deinit(); + } + + virtual void Uninitialize() + { + // TODO save state? + } + +protected: + void OnActivated(ApplicationModel::Core::CoreApplicationView^ applicationView, ApplicationModel::Activation::IActivatedEventArgs^ args) + { + CoreWindow::GetForCurrentThread()->Activate(); + } + + void OnSuspending(Platform::Object^ sender, ApplicationModel::SuspendingEventArgs^ args) + { + audioContext.suspend(); + + ApplicationModel::SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); + + create_task([this, deferral]() + { + // TODO save state? + deferral->Complete(); + }); + } + + void OnResuming(Platform::Object^ sender, Platform::Object^ args) + { + audioContext.resume(); + // TODO load state? + } + + void OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) + { + m_windowVisible = args->Visible; + } + + void OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) + { + ::Core::quit(); + } + + void OnBackRequested(Platform::Object^, BackRequestedEventArgs^ args) + { + args->Handled = true; + } +}; + + +ref class ViewSource sealed : ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual ApplicationModel::Core::IFrameworkView^ CreateView() + { + return ref new View(); + } +}; + + +[Platform::MTAThread] +int main(Platform::Array^) { + auto viewSource = ref new ViewSource(); + ApplicationModel::Core::CoreApplication::Run(viewSource); + return 0; +} \ No newline at end of file diff --git a/src/platform/xbox/OpenLara.sln b/src/platform/xbox/OpenLara.sln new file mode 100644 index 00000000..e7641531 --- /dev/null +++ b/src/platform/xbox/OpenLara.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcproj", "{9DC80A4E-C379-4FB3-994E-62C358071007}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Profile = Profile + Profile_FastCap = Profile_FastCap + Release = Release + Release_LTCG = Release_LTCG + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {9DC80A4E-C379-4FB3-994E-62C358071007}.Debug.ActiveCfg = Debug|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Debug.Build.0 = Debug|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Profile.ActiveCfg = Profile|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Profile.Build.0 = Profile|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Release.ActiveCfg = Release|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Release.Build.0 = Release|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox + {9DC80A4E-C379-4FB3-994E-62C358071007}.Release_LTCG.Build.0 = Release_LTCG|Xbox + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/src/platform/xbox/OpenLara.vcproj b/src/platform/xbox/OpenLara.vcproj new file mode 100644 index 00000000..b84f7953 --- /dev/null +++ b/src/platform/xbox/OpenLara.vcproj @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/platform/xbox/main.cpp b/src/platform/xbox/main.cpp new file mode 100644 index 00000000..c5a92695 --- /dev/null +++ b/src/platform/xbox/main.cpp @@ -0,0 +1,344 @@ +#include "game.h" + +LPDIRECT3D8 D3D; +LPDIRECT3DDEVICE8 device; +D3DPRESENT_PARAMETERS d3dpp; + +// multi-threading +void* osMutexInit() { + CRITICAL_SECTION *CS = new CRITICAL_SECTION(); + InitializeCriticalSection(CS); + return CS; +} + +void osMutexFree(void *obj) { + DeleteCriticalSection((CRITICAL_SECTION*)obj); + delete (CRITICAL_SECTION*)obj; +} + +void osMutexLock(void *obj) { + EnterCriticalSection((CRITICAL_SECTION*)obj); +} + +void osMutexUnlock(void *obj) { + LeaveCriticalSection((CRITICAL_SECTION*)obj); +} + +// timing +LARGE_INTEGER timerFreq; +LARGE_INTEGER timerStart; + +int osGetTimeMS() { + LARGE_INTEGER time; + QueryPerformanceCounter(&time); + return int32((time.QuadPart - timerStart.QuadPart) * 1000L / timerFreq.QuadPart); +} + + +// input +struct JoyDevice { + HANDLE handle; + int time; + float vL, vR; + float oL, oR; + XINPUT_FEEDBACK feedback; +} joyDevice[INPUT_JOY_COUNT]; + +#define JOY_MIN_UPDATE_FX_TIME 50 +#define JOY_TRIGGER_THRESHOLD 30 + +void osJoyVibrate(int index, float L, float R) { + joyDevice[index].vL = L; + joyDevice[index].vR = R; +} + +void joyInit() { + XInitDevices(0, NULL); +} + +float joyTrigger(int32 value) { + return clamp(float(value - JOY_TRIGGER_THRESHOLD) / (255 - JOY_TRIGGER_THRESHOLD), 0.0f, 1.0f); +} + +void joyUpdate() { + static XINPUT_POLLING_PARAMETERS params = { TRUE, TRUE, 0, 8, 8, 0, }; + + DWORD dwInsertions, dwRemovals; + XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, &dwInsertions, &dwRemovals); + + for (DWORD i = 0; i < XGetPortCount(); i++) { + JoyDevice &joy = joyDevice[i]; + + if (dwInsertions & (1 << i)) { + memset(&joy, 0, sizeof(joy)); + joy.handle = XInputOpen(XDEVICE_TYPE_GAMEPAD, i, XDEVICE_NO_SLOT, ¶ms); + LOG("joy insert: %d\n", i); + } + + if (dwRemovals & (1 << i)) { + XInputClose(joy.handle); + joy.handle = NULL; + LOG("joy remove: %d\n", i); + } + + if (joy.handle) { + XINPUT_STATE state; + XInputGetState(joy.handle, &state); + + Input::setJoyPos(i, jkL, vec2(state.Gamepad.sThumbLX + 0.5f, -(state.Gamepad.sThumbLY + 0.5f)) / 32767.5f); + Input::setJoyPos(i, jkR, vec2(state.Gamepad.sThumbRX + 0.5f, -(state.Gamepad.sThumbRY + 0.5f)) / 32767.5f); + Input::setJoyPos(i, jkLT, vec2(state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_WHITE], 0.0f)); + Input::setJoyPos(i, jkRT, vec2(state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_BLACK], 0.0f)); + + Input::setJoyDown(i, jkA, state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_A] > 0); + Input::setJoyDown(i, jkB, state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_B] > 0); + Input::setJoyDown(i, jkX, state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_X] > 0); + Input::setJoyDown(i, jkY, state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_Y] > 0); + Input::setJoyDown(i, jkLB, joyTrigger(state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER]) > 0); + Input::setJoyDown(i, jkRB, joyTrigger(state.Gamepad.bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]) > 0); + Input::setJoyDown(i, jkUp, (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) > 0); + Input::setJoyDown(i, jkDown, (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) > 0); + Input::setJoyDown(i, jkLeft, (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) > 0); + Input::setJoyDown(i, jkRight, (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) > 0); + Input::setJoyDown(i, jkStart, (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) > 0); + Input::setJoyDown(i, jkSelect, (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) > 0); + Input::setJoyDown(i, jkL, (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) > 0); + Input::setJoyDown(i, jkR, (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) > 0); + + if ((joy.vL != joy.oL || joy.vR != joy.oR) && Core::getTime() >= joy.time) { + if (joy.feedback.Header.dwStatus != ERROR_IO_PENDING) { + joy.feedback.Rumble.wLeftMotorSpeed = WORD(joy.vL * 65535.0f); + joy.feedback.Rumble.wRightMotorSpeed = WORD(joy.vR * 65535.0f); + joy.oL = joy.vL; + joy.oR = joy.vR; + joy.time = Core::getTime() + JOY_MIN_UPDATE_FX_TIME; + XInputSetState(joy.handle, &joy.feedback); + } + } + + } + } +} + + +// sound +#define SND_PACKETS 2 +#define SND_SAMPLES 2352 +#define SND_SIZE (SND_SAMPLES * sizeof(int16) * 2) + +LPDIRECTSOUND DSound; +LPDIRECTSOUNDSTREAM sndStream; +uint8* sndBuffer; + +void CALLBACK sndFill(VOID* pStreamContext, VOID* pPacketContext, DWORD dwStatus) { + if (Core::isQuit) return; + + if (dwStatus != XMEDIAPACKET_STATUS_SUCCESS) + return; + + int32 index = (int32)pPacketContext; + + XMEDIAPACKET packet = {0}; + packet.dwMaxSize = SND_SIZE; + packet.pvBuffer = sndBuffer + index * SND_SIZE; + packet.pContext = pPacketContext; + + Sound::fill((Sound::Frame*)packet.pvBuffer, SND_SIZE / 4); + + sndStream->Process(&packet, NULL); +} + +void sndInit() { + if (FAILED(DirectSoundCreate(NULL, &DSound, NULL))) + return; + + WAVEFORMATEX waveFmt = { WAVE_FORMAT_PCM, 2, 44100, 44100 * 4, 4, 16, sizeof(waveFmt) }; + + DSSTREAMDESC dssd = {0}; + dssd.dwMaxAttachedPackets = SND_PACKETS; + dssd.lpwfxFormat = &waveFmt; + dssd.lpfnCallback = sndFill; + + sndBuffer = (uint8*)XPhysicalAlloc(SND_SIZE * SND_PACKETS, MAXULONG_PTR, 0, PAGE_READWRITE | PAGE_NOCACHE); + if (!sndBuffer) + return; + memset(sndBuffer, 0, SND_SIZE * SND_PACKETS); + + if (FAILED(DirectSoundCreateStream(&dssd, &sndStream))) + return; + + XMEDIAPACKET packet = {0}; + packet.dwMaxSize = SND_SIZE; + for (int i = 0; i < SND_PACKETS; i++) { + packet.pvBuffer = sndBuffer + i * SND_SIZE; + packet.pContext = (VOID*)i; + sndStream->Process(&packet, NULL); + } +} + +void sndFree() { + if (sndStream) { + sndStream->Pause(DSSTREAMPAUSE_PAUSE); + sndStream->Discontinuity(); + sndStream->Flush(); + sndStream->Release(); + } + if (sndBuffer) { + XPhysicalFree(sndBuffer); + } +} + +void sndUpdate() { + DirectSoundDoWork(); +} + + +// context +struct { + int width; + int height; + bool prog; + bool wide; + + bool support(DWORD videoFlags) { + if (wide && !(videoFlags & XC_VIDEO_FLAGS_WIDESCREEN)) + return false; + if ((height == 480) && wide && !(videoFlags & XC_VIDEO_FLAGS_WIDESCREEN)) + return false; + if ((height == 480) && prog && !(videoFlags & XC_VIDEO_FLAGS_HDTV_480p)) + return false; + if ((height == 720) && !(videoFlags & XC_VIDEO_FLAGS_HDTV_720p)) + return false; + if ((height == 1080) && !(videoFlags & XC_VIDEO_FLAGS_HDTV_1080i)) + return false; + return true; + } +} displayModes[] = { + { 1920, 1080, false, true }, // 1920x1080 interlaced 16x9 + { 1280, 720, true, true }, // 1280x720 progressive 16x9 + { 720, 480, true, true }, // 720x480 progressive 16x9 + { 720, 480, false, true }, // 720x480 interlaced 16x9 + { 640, 480, true, true }, // 640x480 progressive 16x9 + { 640, 480, false, true }, // 640x480 interlaced 16x9 + { 720, 480, true, false }, // 720x480 progressive 4x3 + { 720, 480, false, false }, // 720x480 interlaced 4x3 + { 640, 480, true, false }, // 640x480 progressive 4x3 + { 640, 480, false, false }, // 640x480 interlaced 4x3 +}; + +HRESULT ContextCreate() { + D3D = Direct3DCreate8(D3D_SDK_VERSION); + + if (!D3D) return E_FAIL; + + memset(&d3dpp, 0, sizeof(d3dpp)); + d3dpp.BackBufferWidth = 640; + d3dpp.BackBufferHeight = 480; + + DWORD videoFlags = XGetVideoFlags(); + + for (int i = 0; i < COUNT(displayModes); i++) { + if (displayModes[i].support(videoFlags)) { + d3dpp.BackBufferWidth = displayModes[i].width; + d3dpp.BackBufferHeight = displayModes[i].height; + if (displayModes[i].wide) { + d3dpp.Flags |= D3DPRESENTFLAG_WIDESCREEN; + } + if (displayModes[i].prog) { + d3dpp.Flags |= D3DPRESENTFLAG_PROGRESSIVE; + } + break; + } + } + + float f = float(d3dpp.BackBufferWidth) / float(d3dpp.BackBufferHeight); + if (d3dpp.Flags & D3DPRESENTFLAG_WIDESCREEN) { + Core::aspectFix = (16.0f / 9.0f) / f; + } else { + Core::aspectFix = (4.0f / 3.0f) / f; + } + + d3dpp.BackBufferFormat = D3DFMT_LIN_X8R8G8B8; + d3dpp.BackBufferCount = 1; + d3dpp.EnableAutoDepthStencil = TRUE; + d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE; + + if (d3dpp.BackBufferHeight == 480) { + d3dpp.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES_MULTISAMPLE_GAUSSIAN; + } else if (d3dpp.BackBufferHeight == 720) { + d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; //D3DMULTISAMPLE_2_SAMPLES_MULTISAMPLE_QUINCUNX; // unstable 60 fps + } else if (d3dpp.BackBufferHeight == 1080) { + d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; + } + + if (FAILED(D3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &device))) + return E_FAIL; + + Core::width = d3dpp.BackBufferWidth; + Core::height = d3dpp.BackBufferHeight; + + return S_OK; +} + +void ContextSwap() { + device->Present(NULL, NULL, NULL, NULL); +} + + +int checkLanguage() { + int str = STR_LANG_EN; + switch (XGetLanguage()) { + case XC_LANGUAGE_ENGLISH : str = STR_LANG_EN; break; + case XC_LANGUAGE_FRENCH : str = STR_LANG_FR; break; + case XC_LANGUAGE_GERMAN : str = STR_LANG_DE; break; + case XC_LANGUAGE_SPANISH : str = STR_LANG_ES; break; + case XC_LANGUAGE_ITALIAN : str = STR_LANG_IT; break; + case XC_LANGUAGE_PORTUGUESE : str = STR_LANG_PT; break; + case XC_LANGUAGE_JAPANESE : str = STR_LANG_JA; break; + case XC_LANGUAGE_TCHINESE : str = STR_LANG_CN; break; + } + return str - STR_LANG_EN; +} + +void main() +{ + strcpy(contentDir, "D:\\"); + + saveDir[0] = cacheDir[0] = 0; + if (XCreateSaveGame("U:\\", L"OpenLara", OPEN_ALWAYS, 0, saveDir, 256) == ERROR_SUCCESS) { + strcpy(cacheDir, saveDir); + } + + if (FAILED(ContextCreate())) + return; + + QueryPerformanceFrequency(&timerFreq); + QueryPerformanceCounter(&timerStart); + + Sound::channelsCount = 0; + + joyInit(); + sndInit(); + + Core::defLang = checkLanguage(); + + Game::init((char*)NULL);//"PSXDATA\\LEVEL1.PSX"); + + while (!Core::isQuit) { + joyUpdate(); + sndUpdate(); + + if (Game::update()) { + Game::render(); + ContextSwap(); + } + }; + + sndFree(); + Game::deinit(); + + LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU }; + XLaunchNewImage(NULL, (LAUNCH_DATA*)&LaunchData); +} diff --git a/src/platform/xbox/saveimage.xbx b/src/platform/xbox/saveimage.xbx new file mode 100644 index 00000000..7e195e6f Binary files /dev/null and b/src/platform/xbox/saveimage.xbx differ diff --git a/src/platform/xbox/titleimage.xbx b/src/platform/xbox/titleimage.xbx new file mode 100644 index 00000000..9115b8d2 Binary files /dev/null and b/src/platform/xbox/titleimage.xbx differ diff --git a/src/shader.h b/src/shader.h index 26a70469..754e516f 100644 --- a/src/shader.h +++ b/src/shader.h @@ -7,9 +7,10 @@ struct Shader : GAPI::Shader { enum Type { DEFAULT = 0, - /* shader */ SPRITE = 0, FLASH, ROOM, ENTITY, MIRROR, - /* filter */ FILTER_UPSCALE = 0, FILTER_DOWNSAMPLE, FILTER_GRAYSCALE, FILTER_BLUR, FILTER_EQUIRECTANGULAR, - /* water */ WATER_DROP = 0, WATER_SIMULATE, WATER_CAUSTICS, WATER_RAYS, WATER_MASK, WATER_COMPOSE, + SPRITE = 0, FLASH, ROOM, ENTITY, MIRROR, + FILTER_UPSCALE = 0, FILTER_DOWNSAMPLE, FILTER_DOWNSAMPLE_DEPTH, FILTER_GRAYSCALE, FILTER_BLUR, FILTER_ANAGLYPH, FILTER_EQUIRECTANGULAR, + WATER_DROP = 0, WATER_SIMULATE, WATER_CAUSTICS, WATER_RAYS, WATER_MASK, WATER_COMPOSE, + SKY_TEXTURE = 0, SKY_CLOUDS, SKY_AZURE, MAX = 6 }; @@ -27,7 +28,6 @@ struct Shader : GAPI::Shader { setParam(uLightProj, Core::mLightProj); setParam(uViewPos, Core::viewPos); setParam(uParam, Core::params); - setParam(uFogParams, Core::fogParams); } }; diff --git a/src/shaders/ambient.glsl b/src/shaders/ambient.glsl new file mode 100644 index 00000000..bf050af1 --- /dev/null +++ b/src/shaders/ambient.glsl @@ -0,0 +1,69 @@ +R"====( +uniform mat4 uViewProj; +uniform vec4 uViewPos; +uniform vec4 uFogParams; + +varying vec2 vTexCoord; +varying vec4 vDiffuse; + +#ifdef VERTEX + + uniform vec4 uBasis[2]; + uniform vec4 uMaterial; + + attribute vec4 aCoord; + attribute vec4 aTexCoord; + + attribute vec3 aColor; + attribute vec3 aLight; + + vec3 mulQuat(vec4 q, vec3 v) { + return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + v * q.w); + } + + vec3 mulBasis(vec4 rot, vec3 pos, vec3 v) { + return mulQuat(rot, v) + pos; + } + + void main() { + vTexCoord = aTexCoord.xy; + + vec4 rBasisRot = uBasis[0]; + vec4 rBasisPos = uBasis[1]; + + vec3 coord = + #ifdef TYPE_SPRITE + mulBasis(rBasisRot, rBasisPos.xyz + aCoord.xyz, vec3(aTexCoord.z, aTexCoord.w, 0.0) * 32767.0); + #else + mulBasis(rBasisRot, rBasisPos.xyz, aCoord.xyz); + #endif + + vDiffuse.xyz = aColor.xyz * aLight.xyz * uMaterial.xyz; + float fog = length(uViewPos.xyz - coord.xyz) * uFogParams.w; + vDiffuse.w = clamp(1.0 / exp(fog), 0.0, 1.0); + + gl_Position = uViewProj * vec4(coord, 1.0); + } + +#else + + uniform sampler2D sDiffuse; + + void main() { + vec4 color = texture2D(sDiffuse, vTexCoord); + + #ifdef ALPHA_TEST + if (color.w <= 0.5) + discard; + #endif + + color.xyz *= vDiffuse.xyz; + color.xyz = mix(uFogParams.xyz, color.xyz, vDiffuse.w); + + color.xyz *= color.w; + + fragColor = color; + } + +#endif +)====" diff --git a/src/shaders/ambient.hlsl b/src/shaders/ambient.hlsl deleted file mode 100644 index 340f3860..00000000 --- a/src/shaders/ambient.hlsl +++ /dev/null @@ -1,54 +0,0 @@ -#include "common.hlsl" - -struct VS_OUTPUT { - float4 pos : POSITION; - float4 texCoord : TEXCOORD0; - float4 diffuse : TEXCOORD1; -}; - -#ifdef VERTEX -VS_OUTPUT main(VS_INPUT In) { - VS_OUTPUT Out; - - float4 rBasisRot = uBasis[0]; - float4 rBasisPos = uBasis[0 + 1]; - - Out.texCoord = In.aTexCoord * (1.0 / 32767.0); - - float3 coord; - - if (TYPE_SPRITE) { - coord = mulBasis(rBasisRot, rBasisPos.xyz + In.aCoord.xyz, float3(In.aTexCoord.z, In.aTexCoord.w, 0.0)); - } else { - coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); - } - - Out.diffuse = float4(RGB(In.aColor) * (uMaterial.x * 1.8), 1.0); - Out.diffuse.xyz *= RGB(In.aLight); - - Out.diffuse *= uMaterial.w; - - if (TYPE_SPRITE) { - Out.diffuse *= RGBA(In.aLight).a; - } - - Out.pos = mul(uViewProj, float4(coord, rBasisPos.w)); - - return Out; -} - -#else // PIXEL - -float4 main(VS_OUTPUT In) : COLOR0 { - float4 color = tex2D(sDiffuse, In.texCoord.xy).bgra; - - if (ALPHA_TEST) { - if (color.w <= 0.5) - discard; - } - - color *= In.diffuse; - - return color; -} -#endif \ No newline at end of file diff --git a/src/shaders/ambient_room.asm b/src/shaders/ambient_room.asm new file mode 100644 index 00000000..98eb8af0 --- /dev/null +++ b/src/shaders/ambient_room.asm @@ -0,0 +1,72 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define att r5 + #define light r6 + #define pos r7 + +; pos = mulQuatPos(uBasis[0], aCoord) + mulQuatPos(pos, aCoord, 0) + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, c[uLightPos + 1], -pos + add lv2.xyz, c[uLightPos + 2], -pos + add lv3.xyz, c[uLightPos + 3], -pos + mul lv1.xyz, c[uLightColor + 1].w, lv1 + mul lv2.xyz, c[uLightColor + 2].w, lv2 + mul lv3.xyz, c[uLightColor + 3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; light = max(0, dot(aNormal, lv[1..3])) + mov light.x, ZERO + dp3 light.y, lv1, aNormal + dp3 light.z, lv2, aNormal + dp3 light.w, lv3, aNormal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = (aLight + light[1..3] * uLightColor[1..3]) * aColor * 2 + mov att, aColor + mov tmp, aLight + mad tmp.xyz, light.y, c[uLightColor + 1], tmp + mad tmp.xyz, light.z, c[uLightColor + 2], tmp + mad tmp.xyz, light.w, c[uLightColor + 3], tmp + mul att, att, tmp + applyUnderwater(tmp, pos) + add vColor, tmp, tmp + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + mul r0, t0, vColor +#endif \ No newline at end of file diff --git a/src/shaders/ambient_room.hlsl b/src/shaders/ambient_room.hlsl new file mode 100644 index 00000000..e5a0ccf9 --- /dev/null +++ b/src/shaders/ambient_room.hlsl @@ -0,0 +1,47 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float4 texCoord : TEXCOORD0; + float4 diffuse : COLOR0; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float4 rBasisRot = uBasis[0]; + float4 rBasisPos = uBasis[1]; + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + + float3 coord; + + coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); + + Out.diffuse = float4(In.aColor.rgb * (uMaterial.x * 1.8), 1.0); + Out.diffuse.xyz *= In.aLight.rgb; + + Out.diffuse *= uMaterial.w; + + Out.pos = mul(uViewProj, float4(coord, 1.0)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy); + + #ifdef ALPHA_TEST + clip(color.w - ALPHA_REF); + #endif + + color *= In.diffuse; + + return color; +} + +#endif diff --git a/src/shaders/ambient_sprite.asm b/src/shaders/ambient_sprite.asm new file mode 100644 index 00000000..3662618c --- /dev/null +++ b/src/shaders/ambient_sprite.asm @@ -0,0 +1,10 @@ +#include "common.asm" + +#ifdef VERTEX + m4x4 oPos, aCoord, c[uViewProj] + mov oD0, aLight + mov oT0, aTexCoord +#else + tex t0 + mov r0, t0 +#endif \ No newline at end of file diff --git a/src/shaders/ambient_sprite.hlsl b/src/shaders/ambient_sprite.hlsl new file mode 100644 index 00000000..d1865e52 --- /dev/null +++ b/src/shaders/ambient_sprite.hlsl @@ -0,0 +1,49 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float4 texCoord : TEXCOORD0; + float4 diffuse : COLOR0; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float4 rBasisRot = uBasis[0]; + float4 rBasisPos = uBasis[1]; + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + + float3 coord; + + coord = mulBasis(rBasisRot, rBasisPos.xyz + In.aCoord.xyz, float3(In.aTexCoord.z, In.aTexCoord.w, 0.0)); + + Out.diffuse = float4(In.aColor.rgb * (uMaterial.x * 1.8), 1.0); + Out.diffuse.xyz *= In.aLight.rgb; + + Out.diffuse *= uMaterial.w; + + Out.diffuse *= In.aLight.a; + + Out.pos = mul(uViewProj, float4(coord, 1.0)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy); + + #ifdef ALPHA_TEST + clip(color.w - ALPHA_REF); + #endif + + color *= In.diffuse; + + return color; +} + +#endif diff --git a/src/shaders/common.asm b/src/shaders/common.asm new file mode 100644 index 00000000..00b25644 --- /dev/null +++ b/src/shaders/common.asm @@ -0,0 +1,120 @@ +#ifdef VERTEX + xvs.1.1 + + #define vPosition oPos + #define vColor oD0 + #define vTexCoord oT0 + #define vFog oFog +#else + ps.1.0 + + #define vColor v0 +#endif + +; attributes +#define aCoord v0 +#define aNormal v1 +#define aTexCoord v2 +#define aColor v3 +#define aLight v4 + +; constants +#define uParam 0 +#define uTexParam 1 +#define uViewProj 2 +#define uBasis 6 +#define uLightProj 70 +#define uMaterial 74 +#define uAmbient 75 +#define uFogParams 81 +#define uViewPos 82 +#define uLightPos 83 +#define uLightColor 87 +#define uRoomSize 91 +#define uCosCoeff 92 +#define uAngles 93 + +#define ZERO c94.xxxx +#define HALF c94.yyyy +#define ONE c94.zzzz +#define TWO c94.wwww +#define UW_COLOR c95.xyz +#define MAX_SHORT c95.wwww +#define WAVE_SIZE c[uAngles].wwww ; 1 / 1024 +#define WAVE_LUM c[uAngles].zzzz ; 0.75 + +#define tmp r8 + +#define mulMat(dst, src, matrix) \ + mul tmp, c[matrix + 0], src.x \ + mad tmp, src.y, c[matrix + 1], tmp \ + mad tmp, src.z, c[matrix + 2], tmp \ + mad dst, src.w, c[matrix + 3], tmp + +#define mulQuat(dst, src, joint) \ + mul dst.xyz, c[uBasis + joint], src.zxyw \ + mad dst.xyz, src, c[uBasis + joint].zxyw, -dst \ + mad dst.xyz, src.yzxw, c[uBasis + joint].w, dst \ + mul tmp.xyz, c[uBasis + joint].zxyw, dst \ + mad dst.xyz, dst.yzxw, c[uBasis + joint].yzxw, -tmp \ + mad dst.xyz, dst, TWO, src \ + mov dst.w, ONE + +#define mulQuatPos(dst, src, joint) \ + mul dst.xyz, c[uBasis + joint], src.zxyw \ + mad dst.xyz, src, c[uBasis + joint].zxyw, -dst \ + mad dst.xyz, src.yzxw, c[uBasis + joint].w, dst \ + mul tmp.xyz, c[uBasis + joint].zxyw, dst \ + mad dst.xyz, dst.yzxw, c[uBasis + joint].yzxw, -tmp \ + mad dst.xyz, dst, TWO, src \ + add dst.xyz, c[uBasis + joint + 1], dst \ + mov dst.w, c[uBasis + joint + 1].w + +#define reflect(dst, a, b) \ + dp3 tmp.x, a, b \ + add tmp.x, tmp.x, tmp.x \ + mad dst, -tmp.xxxx, b, a + +#define normalize(v) \ + dp3 tmp.x, v, v \ + rsq tmp.x, tmp.x \ + mul v, v, tmp.xxxx + +#define applyFog(dst, src) \ + add tmp.xyz, c[uViewPos].xyz, -src.xyz \ + mul tmp.xyz, tmp.xyz, c[uFogParams].www \ + dp3 tmp.x, tmp.xyz, tmp.xyz \ + rsq tmp.x, tmp.x \ + rcp dst.x, tmp.x + +#define encodeColor(v) \ + mul vColor, v, HALF + +#define applyColor(dst, src) \ + mul dst, src, vColor \ + add dst, dst, dst \ + add dst, dst, dst + +#define cos(dst, ang) \ + mad dst.x, ang, c[uAngles].y, c[uAngles].x \ + expp dst.yw, dst.xxxx \ + add dst.x, dst.y, -c[uAngles].x \ + mul dst, dst.wwxx, dst.wxxx \ + mul dst.w, dst.w, dst.y \ + mul dst, dst, dst \ + dp4 dst.x, dst, c[uCosCoeff] + +#ifdef UNDERWATER + #define applyUnderwater(dst, pos) \ + dp3 tmp.x, pos, WAVE_SIZE \ + add tmp.x, tmp.x, c[uParam].x \ + cos(tmp, tmp.x) \ + max tmp.x, tmp.x, -tmp.x \ + mul tmp.x, tmp.x, WAVE_LUM \ + add tmp.x, tmp.x, HALF \ + mul dst.xyz, dst.xyz, tmp.xxx \ + mul dst.xyz, dst.xyz, UW_COLOR + +#else + #define applyUnderwater(dst, pos) +#endif diff --git a/src/shaders/common.hlsl b/src/shaders/common.hlsl index 73523043..77e79878 100644 --- a/src/shaders/common.hlsl +++ b/src/shaders/common.hlsl @@ -1,46 +1,121 @@ -#ifdef __psp2__ - #define _GAPI_GXM +#ifdef _GAPI_GXM #pragma pack_matrix( column_major ) #endif +#define ALPHA_REF 0.5 #define MAX_LIGHTS 4 #define MAX_CONTACTS 15 #define WATER_FOG_DIST (1.0 / (6.0 * 1024.0)) #define WATER_COLOR_DIST (1.0 / (2.0 * 1024.0)) #define UNDERWATER_COLOR float3(0.6, 0.9, 0.9) -#define SHADOW_NORMAL_BIAS 16.0 +#define UNDERWATER_COLOR_H half3(0.6, 0.9, 0.9) +#define SHADOW_NORMAL_BIAS 1.0 #define SHADOW_CONST_BIAS 0.05 -#define SHADOW_SIZE 1024 -#define PI 3.141592653589793 - -static const float3 SHADOW_TEXEL = float3(1.0 / SHADOW_SIZE, 1.0 / SHADOW_SIZE, 0.0); #ifdef _GAPI_GXM - #define FLAGS_REG c94 - #define FLAGS_TYPE float4 - #define RGBA(c) (c).rgba - #define RGB(c) (c).rgb + #define SHADOW_SIZE 1024.0 #else - #define FLAGS_REG b0 - #define FLAGS_TYPE bool4 - #define RGBA(c) (c).bgra - #define RGB(c) (c).bgr + #define SHADOW_SIZE 2048.0 +#endif + +#define SHADOW_TEXEL (1.0 / SHADOW_SIZE) + +#define PI 3.141592653589793 + +#define INV_SHORT_HALF (1.0 / 32767.0) + +#if (defined(_GAPI_D3D11) || defined(_GAPI_GXM)) && !defined(_GAPI_D3D11_9_3) + #define SHADOW_DEPTH #endif struct VS_INPUT { +#ifdef _GAPI_GXM float4 aCoord : POSITION; float4 aNormal : NORMAL; float4 aTexCoord : TEXCOORD0; +#else + int4 aCoord : POSITION; + int4 aNormal : NORMAL; + int4 aTexCoord : TEXCOORD0; +#endif float4 aColor : COLOR0; float4 aLight : COLOR1; }; -sampler2D sDiffuse : register(s0); -sampler2D sNormal : register(s1); -sampler2D sReflect : register(s2); -sampler2D sShadow : register(s3); -samplerCUBE sEnvironment : register(s4); -sampler2D sMask : register(s5); +#ifdef _GAPI_D3D11 + SamplerState smpDefault : register(s0); + SamplerState smpPoint : register(s1); + SamplerState smpPointWrap : register(s2); + SamplerState smpLinear : register(s3); + SamplerState smpLinearWrap : register(s4); + SamplerComparisonState smpCmp : register(s5); + + #ifdef DIFFUSE_AS_CUBE + TextureCube sDiffuse : register(t0); + #else + Texture2D sDiffuse : register(t0); + #endif + + #ifdef NORMAL_AS_3D + Texture3D sNormal : register(t1); + #else + Texture2D sNormal : register(t1); + #endif + + Texture2D sReflect : register(t2); + Texture2D sShadow : register(t3); + Texture2D sMask : register(t4); + + #define SAMPLE_2D(T,uv) T.Sample(smpDefault, uv) + #define SAMPLE_2D_POINT(T,uv) T.Sample(smpPoint, uv) + #define SAMPLE_2D_POINT_WRAP(T,uv) T.Sample(smpPointWrap, uv) + #define SAMPLE_2D_LINEAR(T,uv) T.Sample(smpLinear, uv) + #define SAMPLE_2D_LINEAR_WRAP(T,uv) T.Sample(smpLinearWrap, uv) + + #ifdef _GAPI_D3D11_9_3 + #define SAMPLE_2D_LOD0(T,uv) SAMPLE_2D_POINT(T, uv) + #define SAMPLE_SHADOW(T,uv) ((unpack(SAMPLE_2D_POINT(T, uv.xy/uv.w)) >= uv.z/uv.w) ? 1 : 0) + #else + #define SAMPLE_2D_LOD0(T,uv) T.SampleLevel(smpLinear, uv, 0) + #define SAMPLE_SHADOW(T,uv) T.SampleCmpLevelZero(smpCmp, uv.xy/uv.w, uv.z/uv.w) + #endif + + #define SAMPLE_3D(T,uv) T.SampleLevel(smpLinearWrap, uv, 0) + #define SAMPLE_CUBE(T,uv) T.Sample(smpLinear, uv) + + #define POSITION SV_POSITION +#else + #ifdef DIFFUSE_AS_CUBE + samplerCUBE sDiffuse : register(s0); + #else + sampler2D sDiffuse : register(s0); + #endif + + sampler2D sNormal : register(s1); + sampler2D sReflect : register(s2); + sampler2D sShadow : register(s3); + sampler2D sMask : register(s4); + + #define SAMPLE_2D(T,uv) tex2D(T, uv) + #define SAMPLE_2D_POINT(T,uv) tex2D(T, uv) + #define SAMPLE_2D_POINT_WRAP(T,uv) tex2D(T, uv) + #define SAMPLE_2D_LINEAR(T,uv) tex2D(T, uv) + #define SAMPLE_2D_LINEAR_WRAP(T,uv) tex2D(T, uv) + #define SAMPLE_2D_LOD0(T,uv) tex2Dlod(T, float4(uv.xy, 0, 0)) + + #if defined(_GAPI_GXM) + #define SAMPLE_SHADOW(T,uv) f1tex2Dproj(T, uv) + #else + #define SAMPLE_SHADOW(T,uv) ((unpack(tex2D(T, uv.xy/uv.w)) >= uv.z/uv.w) ? 1 : 0) + #endif + + #define SAMPLE_3D(T,uv) tex3D(T, uv) + #define SAMPLE_CUBE(T,uv) texCUBE(T, uv) + + #if defined(PIXEL) && !defined(_GAPI_GXM) + #define POSITION VPOS + #endif +#endif float4 uParam : register( c0 ); float4 uTexParam : register( c1 ); @@ -55,37 +130,25 @@ float4 uLightPos[MAX_LIGHTS] : register( c83 ); float4 uLightColor[MAX_LIGHTS] : register( c87 ); float4 uRoomSize : register( c91 ); float4 uPosScale[2] : register( c92 ); -FLAGS_TYPE uFlags[4] : register( FLAGS_REG ); float4 uContacts[MAX_CONTACTS] : register( c98 ); - -#define TYPE_SPRITE uFlags[0].x -#define TYPE_FLASH uFlags[0].y -#define TYPE_ROOM uFlags[0].z -#define TYPE_ENTITY uFlags[0].w -#define TYPE_MIRROR uFlags[1].x - -#define FILTER_DEFAULT uFlags[0].x -#define FILTER_DOWNSAMPLE uFlags[0].y -#define FILTER_GRAYSCALE uFlags[0].z -#define FILTER_BLUR uFlags[0].w -#define FILTER_EQUIRECTANGULAR uFlags[1].x - -#define WATER_DROP uFlags[0].x -#define WATER_SIMULATE uFlags[0].y -#define WATER_CAUSTICS uFlags[0].z -#define WATER_RAYS uFlags[0].w -#define WATER_MASK uFlags[1].x -#define WATER_COMPOSE uFlags[1].y - // options for compose, shadow, ambient passes -#define UNDERWATER uFlags[1].y -#define ALPHA_TEST uFlags[1].z -#define CLIP_PLANE uFlags[1].w -#define OPT_AMBIENT uFlags[2].x -#define OPT_SHADOW uFlags[2].y -#define OPT_CONTACT uFlags[2].z -#define OPT_CAUSTICS uFlags[2].w +#ifdef _GAPI_GXM + //#define OPT_AMBIENT + #define OPT_SHADOW + //#define OPT_CONTACT + //#define OPT_CAUSTICS +#elif _GAPI_D3D11_9_3 + //#define OPT_AMBIENT + //#define OPT_SHADOW + //#define OPT_CONTACT + //#define OPT_CAUSTICS +#else + #define OPT_AMBIENT + #define OPT_SHADOW + #define OPT_CONTACT + #define OPT_CAUSTICS +#endif float4 pack(float value) { float4 v = frac(value * float4(1.0, 255.0, 65025.0, 16581375.0)); @@ -110,4 +173,100 @@ float3 calcAmbient(float3 n) { return sqr.x * lerp(uAmbient[1].xyz, uAmbient[0].xyz, pos.x) + sqr.y * lerp(uAmbient[3].xyz, uAmbient[2].xyz, pos.y) + sqr.z * lerp(uAmbient[5].xyz, uAmbient[4].xyz, pos.z); -} \ No newline at end of file +} + +float calcSpecular(float3 normal, float3 viewVec, float3 lightVec, float intensity) { + float3 vv = normalize(viewVec); + float3 rv = reflect(-vv, normal); + float3 lv = normalize(lightVec); + return pow(max(0.0, dot(rv, lv)), 8.0) * intensity; +} + +float calcCaustics(float3 coord, float3 n) { + float2 cc = saturate((coord.xz - uRoomSize.xy) / uRoomSize.zw); + float2 border = 256.0 / uRoomSize.zw; + float2 fade = smoothstep((float2)0.0, border, cc) * (1.0 - smoothstep(1.0 - border, 1.0, cc)); + return SAMPLE_2D_LINEAR(sReflect, float2(cc.x, 1.0 - cc.y)).x * max(0.0, -n.y) * fade.x * fade.y; +} + +float calcCausticsV(float3 coord) { + return 0.5 + abs(sin(dot(coord.xyz, 1.0 / 1024.0) + uParam.x)) * 0.75; +} + +#ifndef NORMAL_AS_3D +float3 calcHeightMapNormal(float2 tcR, float2 tcB, float base) { + float dx = SAMPLE_2D_LOD0(sNormal, tcR).x - base; + float dz = SAMPLE_2D_LOD0(sNormal, tcB).x - base; + return normalize( float3(dx, 64.0 / (1024.0 * 8.0), dz) ); +} +#endif + +float calcFresnel(float NdotV, float f0) { + return f0 + (1.0 - f0) * pow(1.0 - NdotV, 5.0); +} + +void applyFogUW(inout float3 color, float3 coord, float waterFogDist, float waterColorDist) { + float h = coord.y - uParam.y; + float3 dir = uViewPos.xyz - coord.xyz; + float dist = lerp(length(dir), abs(h / normalize(dir).y), step(uViewPos.y, uParam.y)); +/* + if (uViewPos.y < uParam.y) { + dist = abs(h / normalize(dir).y); + } else { + dist = length(dir); + } +*/ + float fog = saturate(1.0 / exp(dist * waterFogDist)); + dist += h; + color.xyz *= lerp((float3)1.0, UNDERWATER_COLOR, clamp(dist * waterColorDist, 0.0, 2.0)); + color.xyz = lerp(UNDERWATER_COLOR * 0.2, color.xyz, fog); +} + +void applyFog(inout float3 color, float fogFactor) { + color.xyz = lerp(uFogParams.xyz, color.xyz, fogFactor); +} + +float getShadowValue(float3 lightVec, float4 lightProj) { +/* + float sMin = min(lightProj.x, lightProj.y); + float sMax = max(lightProj.x, lightProj.y); + float vis = lightProj.w; + if (TYPE_ROOM) { + vis = min(vis, dot(normal, lightVec)); + } + sMin = min(vis, sMin); +*/ + float factor = step(0.0, lightProj.w); //float((sMin > 0.0f) && (sMax < lightProj.w)); // + lightProj.xyz *= factor; + lightProj.z -= SHADOW_CONST_BIAS * SHADOW_TEXEL * lightProj.w; + + + float rShadow = SAMPLE_SHADOW(sShadow, lightProj); + + float fade = saturate(dot(lightVec, lightVec)); + return rShadow + (1.0 - rShadow) * fade; +} + +float getShadow(float3 lightVec, float4 lightProj) { + return getShadowValue(lightVec, lightProj); +} + +float4 calcLightProj(float3 coord) { + return mul(uLightProj, float4(coord, 1.0)); +} + +float getContactAO(float3 p, float3 n) { + float res = 1.0; +#ifdef _GAPI_GXM + #pragma loop (unroll: always) +#else + [unroll] +#endif + for (int i = 0; i < MAX_CONTACTS; i++) { + float3 v = uContacts[i].xyz - p; + float a = uContacts[i].w; + float o = a * saturate(dot(n, v)) / dot(v, v); + res *= saturate(1.0 - o); + } + return res; +} diff --git a/src/shaders/compile_d3d11.bat b/src/shaders/compile_d3d11.bat new file mode 100644 index 00000000..6e38efd6 --- /dev/null +++ b/src/shaders/compile_d3d11.bat @@ -0,0 +1,60 @@ +@echo off +rd /S /Q d3d11 +mkdir d3d11 + +call :compile_au compose_sprite +call :compile_au compose_room +call :compile_au compose_entity +call :compile compose_mirror +call :compile compose_flash + +call :compile_a shadow_entity +call :compile_a ambient_room +call :compile_a ambient_sprite + +call :compile water_drop +call :compile water_simulate +call :compile water_caustics +call :compile water_rays +call :compile water_mask +call :compile water_compose + +call :compile filter _upscale "/DUPSCALE" +call :compile filter _downsample "/DDOWNSAMPLE" +call :compile filter _grayscale "/DGRAYSCALE" +call :compile filter _blur "/DBLUR" +call :compile filter _anaglyph "/DANAGLYPH" + +call :compile sky +call :compile sky _clouds "/DSKY_CLOUDS" +call :compile sky _azure "/DSKY_AZURE" + +call :compile gui + + +EXIT /B %ERRORLEVEL% + +:compile + SETLOCAL + echo compile d3d11/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> d3d11/shaders.h + echo #include "%~1%~2_f.h" >> d3d11/shaders.h + fxc /nologo /T vs_4_0 /O3 /Gec /D_GAPI_D3D11=1 /Vn %~1%~2_v /Fh d3d11/%~1%~2_v.h %~1.hlsl /DVERTEX %~3 + fxc /nologo /T ps_4_0 /O3 /Gec /D_GAPI_D3D11=1 /Vn %~1%~2_f /Fh d3d11/%~1%~2_f.h %~1.hlsl /DPIXEL %~3 + ENDLOCAL +EXIT /B 0 + +:compile_a + SETLOCAL + call :compile %~1 + call :compile %~1 _a "/DALPHA_TEST" + ENDLOCAL +EXIT /B 0 + +:compile_au + SETLOCAL + call :compile_a %~1 + call :compile %~1 _u "/DUNDERWATER" + call :compile %~1 _au "/DALPHA_TEST /DUNDERWATER" + ENDLOCAL +EXIT /B 0 diff --git a/src/shaders/compile_d3d11_wp8.bat b/src/shaders/compile_d3d11_wp8.bat new file mode 100644 index 00000000..91de20aa --- /dev/null +++ b/src/shaders/compile_d3d11_wp8.bat @@ -0,0 +1,70 @@ +@echo off +rd /S /Q d3d11 +mkdir d3d11 + +call :compile_au compose_sprite +call :compile_au compose_room +call :compile_au compose_entity +call :compile compose_mirror +call :compile compose_flash + +call :compile_a shadow_entity +call :compile_a ambient_room +call :compile_a ambient_sprite + +call :compile water_drop +call :compile water_simulate +call :compile_dummy water_caustics +call :compile_dummy water_rays +call :compile water_mask +call :compile water_compose + +call :compile filter _upscale "/DUPSCALE" +call :compile filter _downsample "/DDOWNSAMPLE" +call :compile filter _grayscale "/DGRAYSCALE" +call :compile filter _blur "/DBLUR" +call :compile_dummy filter _anaglyph "/DANAGLYPH" + +call :compile_dummy sky +call :compile_dummy sky _clouds "/DSKY_CLOUDS" +call :compile_dummy sky _azure "/DSKY_AZURE" + +call :compile gui + + +EXIT /B %ERRORLEVEL% + +:compile + SETLOCAL + echo compile d3d11/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> d3d11/shaders.h + echo #include "%~1%~2_f.h" >> d3d11/shaders.h + fxc /nologo /T vs_4_0_level_9_3 /O3 /Gec /D_GAPI_D3D11=1 /D_GAPI_D3D11_9_3=1 /Vn %~1%~2_v /Fh d3d11/%~1%~2_v.h %~1.hlsl /DVERTEX %~3 + fxc /nologo /T ps_4_0_level_9_3 /O3 /Gec /D_GAPI_D3D11=1 /D_GAPI_D3D11_9_3=1 /Vn %~1%~2_f /Fh d3d11/%~1%~2_f.h %~1.hlsl /DPIXEL %~3 + ENDLOCAL +EXIT /B 0 + +:compile_dummy + SETLOCAL + echo compile_dummy d3d11/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> d3d11/shaders.h + echo #include "%~1%~2_f.h" >> d3d11/shaders.h + fxc /nologo /T vs_4_0_level_9_3 /O3 /Gec /D_GAPI_D3D11=1 /D_GAPI_D3D11_9_3=1 /Vn %~1%~2_v /Fh d3d11/%~1%~2_v.h dummy.hlsl /DVERTEX %~3 + fxc /nologo /T ps_4_0_level_9_3 /O3 /Gec /D_GAPI_D3D11=1 /D_GAPI_D3D11_9_3=1 /Vn %~1%~2_f /Fh d3d11/%~1%~2_f.h dummy.hlsl /DPIXEL %~3 + ENDLOCAL +EXIT /B 0 + +:compile_a + SETLOCAL + call :compile %~1 + call :compile %~1 _a "/DALPHA_TEST" + ENDLOCAL +EXIT /B 0 + +:compile_au + SETLOCAL + call :compile_a %~1 + call :compile %~1 _u "/DUNDERWATER" + call :compile %~1 _au "/DALPHA_TEST /DUNDERWATER" + ENDLOCAL +EXIT /B 0 diff --git a/src/shaders/compile_d3d8.bat b/src/shaders/compile_d3d8.bat new file mode 100644 index 00000000..31e61b08 --- /dev/null +++ b/src/shaders/compile_d3d8.bat @@ -0,0 +1,44 @@ +@echo off +rd /S /Q d3d8 +mkdir d3d8 + +call :compile_u compose_sprite +call :compile_u compose_room +call :compile_u compose_entity +call :compile compose_mirror +call :compile compose_flash + +call :compile shadow_entity +call :compile ambient_room +call :compile ambient_sprite + +call :compile filter _upscale "/D UPSCALE" +call :compile filter _downsample "/D DOWNSAMPLE" +call :compile filter _grayscale "/D GRAYSCALE" +call :compile filter _blur "/D BLUR" +call :compile filter _anaglyph "/D ANAGLYPH" + +call :compile gui + +del tmp + +EXIT /B %ERRORLEVEL% + +:compile + SETLOCAL + echo compile d3d8/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> d3d8/shaders.h + echo #include "%~1%~2_f.h" >> d3d8/shaders.h + xsasm /D VERTEX /O2 %~3 %~1.asm tmp + bin2c -n %~1%~2_v -o d3d8/%~1%~2_v.h tmp + xsasm /D PIXEL /O2 %~3 %~1.asm tmp + bin2c -n %~1%~2_f -o d3d8/%~1%~2_f.h tmp + ENDLOCAL +EXIT /B 0 + +:compile_u + SETLOCAL + call :compile %~1 + call :compile %~1 _u "/D UNDERWATER" + ENDLOCAL +EXIT /B 0 diff --git a/src/shaders/compile_d3d9.bat b/src/shaders/compile_d3d9.bat index 7bcd548f..e1eced96 100644 --- a/src/shaders/compile_d3d9.bat +++ b/src/shaders/compile_d3d9.bat @@ -1,15 +1,56 @@ @echo off rd /S /Q d3d9 mkdir d3d9 -fxc /nologo /T vs_3_0 /O3 /Gec /Vn COMPOSE_VS /Fh d3d9/compose_vs.h compose.hlsl /DPASS_COMPOSE /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn COMPOSE_PS /Fh d3d9/compose_ps.h compose.hlsl /DPASS_COMPOSE /DPIXEL -fxc /nologo /T vs_3_0 /O3 /Gec /Vn SHADOW_VS /Fh d3d9/shadow_vs.h shadow.hlsl /DPASS_SHADOW /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn SHADOW_PS /Fh d3d9/shadow_ps.h shadow.hlsl /DPASS_SHADOW /DPIXEL -fxc /nologo /T vs_3_0 /O3 /Gec /Vn AMBIENT_VS /Fh d3d9/ambient_vs.h ambient.hlsl /DPASS_AMBIENT /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn AMBIENT_PS /Fh d3d9/ambient_ps.h ambient.hlsl /DPASS_AMBIENT /DPIXEL -fxc /nologo /T vs_3_0 /O3 /Gec /Vn WATER_VS /Fh d3d9/water_vs.h water.hlsl /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn WATER_PS /Fh d3d9/water_ps.h water.hlsl /DPIXEL -fxc /nologo /T vs_3_0 /O3 /Gec /Vn FILTER_VS /Fh d3d9/filter_vs.h filter.hlsl /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn FILTER_PS /Fh d3d9/filter_ps.h filter.hlsl /DPIXEL -fxc /nologo /T vs_3_0 /O3 /Gec /Vn GUI_VS /Fh d3d9/gui_vs.h gui.hlsl /DVERTEX -fxc /nologo /T ps_3_0 /O3 /Gec /Vn GUI_PS /Fh d3d9/gui_ps.h gui.hlsl /DPIXEL + +call :compile_au compose_sprite +call :compile_au compose_room +call :compile_au compose_entity +call :compile compose_mirror +call :compile compose_flash + +call :compile_a shadow_entity +call :compile_a ambient_room +call :compile_a ambient_sprite + +call :compile water_drop +call :compile water_simulate +call :compile water_caustics +call :compile water_rays +call :compile water_mask +call :compile water_compose + +call :compile filter _upscale "/DUPSCALE" +call :compile filter _downsample "/DDOWNSAMPLE" +call :compile filter _grayscale "/DGRAYSCALE" +call :compile filter _blur "/DBLUR" +call :compile filter _anaglyph "/DANAGLYPH" + +call :compile gui + + +EXIT /B %ERRORLEVEL% + +:compile + SETLOCAL + echo compile d3d9/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> d3d9/shaders.h + echo #include "%~1%~2_f.h" >> d3d9/shaders.h + fxc /nologo /T vs_3_0 /O3 /Gec /D_GAPI_D3D9=1 /Vn %~1%~2_v /Fh d3d9/%~1%~2_v.h %~1.hlsl /DVERTEX %~3 + fxc /nologo /T ps_3_0 /O3 /Gec /D_GAPI_D3D9=1 /Vn %~1%~2_f /Fh d3d9/%~1%~2_f.h %~1.hlsl /DPIXEL %~3 + ENDLOCAL +EXIT /B 0 + +:compile_a + SETLOCAL + call :compile %~1 + call :compile %~1 _a "/DALPHA_TEST" + ENDLOCAL +EXIT /B 0 + +:compile_au + SETLOCAL + call :compile_a %~1 + call :compile %~1 _u "/DUNDERWATER" + call :compile %~1 _au "/DALPHA_TEST /DUNDERWATER" + ENDLOCAL +EXIT /B 0 diff --git a/src/shaders/compile_gxm.bat b/src/shaders/compile_gxm.bat index 13b12825..ca5264a8 100644 --- a/src/shaders/compile_gxm.bat +++ b/src/shaders/compile_gxm.bat @@ -1,36 +1,66 @@ @echo off rd /S /Q gxm mkdir gxm -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/compose_vp.gxp compose.hlsl -DPASS_COMPOSE -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/compose_fp.gxp compose.hlsl -DPASS_COMPOSE -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/shadow_vp.gxp shadow.hlsl -DPASS_SHADOW -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/shadow_fp.gxp shadow.hlsl -DPASS_SHADOW -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/ambient_vp.gxp ambient.hlsl -DPASS_AMBIENT -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/ambient_fp.gxp ambient.hlsl -DPASS_AMBIENT -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/water_vp.gxp water.hlsl -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/water_fp.gxp water.hlsl -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/filter_vp.gxp filter.hlsl -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/filter_fp.gxp filter.hlsl -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/gui_vp.gxp gui.hlsl -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/gui_fp.gxp gui.hlsl -DPIXEL -psp2cgc -profile sce_vp_psp2 -W4 -Wperf -pedantic -o gxm/clear_vp.gxp clear.hlsl -DVERTEX -psp2cgc -profile sce_fp_psp2 -W4 -Wperf -pedantic -o gxm/clear_fp.gxp clear.hlsl -DPIXEL + +call :compile_au compose_sprite +call :compile_au compose_room +call :compile_au compose_entity +call :compile compose_mirror +call :compile compose_flash + +call :compile_a shadow_entity +call :compile_a ambient_room +call :compile_a ambient_sprite + +call :compile water_drop +call :compile water_simulate +call :compile water_caustics +call :compile water_rays +call :compile water_mask +call :compile water_compose + +call :compile filter _upscale "-DUPSCALE" +call :compile filter _downsample "-DDOWNSAMPLE" +call :compile filter _grayscale "-DGRAYSCALE" +call :compile filter _blur "-DBLUR" + +call :compile gui + +call :compile clear cd gxm -..\bin2c.exe compose_vp.gxp compose_vp.h COMPOSE_VP -..\bin2c.exe compose_fp.gxp compose_fp.h COMPOSE_FP -..\bin2c.exe shadow_vp.gxp shadow_vp.h SHADOW_VP -..\bin2c.exe shadow_fp.gxp shadow_fp.h SHADOW_FP -..\bin2c.exe ambient_vp.gxp ambient_vp.h AMBIENT_VP -..\bin2c.exe ambient_fp.gxp ambient_fp.h AMBIENT_FP -..\bin2c.exe water_vp.gxp water_vp.h WATER_VP -..\bin2c.exe water_fp.gxp water_fp.h WATER_FP -..\bin2c.exe filter_vp.gxp filter_vp.h FILTER_VP -..\bin2c.exe filter_fp.gxp filter_fp.h FILTER_FP -..\bin2c.exe gui_vp.gxp gui_vp.h GUI_VP -..\bin2c.exe gui_fp.gxp gui_fp.h GUI_FP -..\bin2c.exe clear_vp.gxp clear_vp.h CLEAR_VP -..\bin2c.exe clear_fp.gxp clear_fp.h CLEAR_FP - - -cd .. \ No newline at end of file +set CONV_CMD=..\bin2c.exe + +for /r . %%i in (*.gxp) do ( +:: ..\psp2gxpstrip -o %%i %%i + ..\bin2c.exe %%i %%~ni.h %%~ni +) + +cd .. + +EXIT /B %ERRORLEVEL% + +:compile + SETLOCAL + echo compile gxm/%~1%~2 %~3 + echo #include "%~1%~2_v.h" >> gxm/shaders.h + echo #include "%~1%~2_f.h" >> gxm/shaders.h + psp2cgc -profile sce_vp_psp2 -W4 -Wperf -D_GAPI_GXM=1 -pedantic %~1.hlsl -cache -o gxm/%~1%~2_v.gxp %~3 -DVERTEX + psp2cgc -profile sce_fp_psp2 -W4 -Wperf -D_GAPI_GXM=1 -pedantic %~1.hlsl -cache -o gxm/%~1%~2_f.gxp %~3 -DPIXEL + ENDLOCAL +EXIT /B 0 + +:compile_a + SETLOCAL + call :compile %~1 + call :compile %~1 _a "-DALPHA_TEST" + ENDLOCAL +EXIT /B 0 + +:compile_au + SETLOCAL + call :compile_a %~1 + call :compile %~1 _u "-DUNDERWATER" + call :compile %~1 _au "-DALPHA_TEST -DUNDERWATER" + ENDLOCAL +EXIT /B 0 diff --git a/src/shaders/compose.glsl b/src/shaders/compose.glsl new file mode 100644 index 00000000..76fd0cd1 --- /dev/null +++ b/src/shaders/compose.glsl @@ -0,0 +1,460 @@ +R"====( +#define MAX_LIGHTS 4 +#define MAX_CONTACTS 15 +#define WATER_FOG_DIST (1.0 / (6.0 * 1024.0)) +#define WATER_COLOR_DIST (1.0 / (2.0 * 1024.0)) +#define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9) + +#define SHADOW_NORMAL_BIAS 16.0 +#define SHADOW_CONST_BIAS 0.05 + +#ifdef OPT_CAUSTICS + uniform vec4 uRoomSize; // xy - minXZ, zw - maxXZ +#endif + +#ifdef OPT_SHADOW + #define SHADOW_TEXEL vec3(1.0 / SHADOW_SIZE, 1.0 / SHADOW_SIZE, 0.0) + uniform mat4 uLightProj; + + #ifdef OPT_VLIGHTPROJ + varying vec4 vLightProj; + #endif +#endif + +uniform mat4 uViewProj; +uniform vec4 uViewPos; + +uniform vec4 uParam; // x - time, y - water height, z - clip plane sign, w - clip plane height +uniform vec4 uLightPos[MAX_LIGHTS]; +uniform vec4 uLightColor[MAX_LIGHTS]; // xyz - color, w - radius * intensity +uniform vec4 uMaterial; // x - diffuse, y - ambient, z - specular, w - alpha +uniform vec4 uFogParams; + +varying vec4 vViewVec; // xyz - dir * dist, w - coord.y * clipPlaneSign +varying vec4 vDiffuse; + +#ifndef TYPE_FLASH + varying vec3 vCoord; + varying vec4 vNormal; // xyz - normal dir, w - fog factor + + #ifdef OPT_SHADOW + varying vec3 vAmbient; + varying vec3 vLightMap; + #endif + + varying vec4 vLight; // lights intensity (MAX_LIGHTS == 4) +#endif + +varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction + +#ifdef OPT_VLIGHTVEC + varying vec3 vLightVec; +#endif + +#ifdef OPT_SHADOW + vec4 calcLightProj(vec3 coord, vec3 lightVec, vec3 normal) { + float factor = clamp(1.0 - dot(normalize(lightVec), normal), 0.0, 1.0); + factor *= SHADOW_NORMAL_BIAS; + return uLightProj * vec4(coord + normal * factor, 1.0); + } +#endif + +#ifdef VERTEX + + #if defined(TYPE_ENTITY) || defined(TYPE_MIRROR) + uniform vec4 uBasis[32 * 2]; + #else + uniform vec4 uBasis[2]; + #endif + + #ifdef OPT_AMBIENT + uniform vec4 uAmbient[6]; + + vec3 calcAmbient(vec3 n) { + vec3 sqr = n * n; + vec3 pos = step(0.0, n); + return sqr.x * mix(uAmbient[1].xyz, uAmbient[0].xyz, pos.x) + + sqr.y * mix(uAmbient[3].xyz, uAmbient[2].xyz, pos.y) + + sqr.z * mix(uAmbient[5].xyz, uAmbient[4].xyz, pos.z); + } + #endif + + attribute vec4 aCoord; + attribute vec4 aTexCoord; + attribute vec4 aNormal; + + attribute vec4 aColor; + attribute vec4 aLight; + + vec3 mulQuat(vec4 q, vec3 v) { + return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + v * q.w); + } + + vec3 mulBasis(vec4 rot, vec3 pos, vec3 v) { + return mulQuat(rot, v) + pos; + } + + vec4 _transform() { + #if (defined(TYPE_ENTITY) || defined(TYPE_MIRROR)) && defined(MESH_SKINNING) + int index = int(aCoord.w); + vec4 rBasisRot = uBasis[index]; + vec4 rBasisPos = uBasis[index + 1]; + #else + vec4 rBasisRot = uBasis[0]; + vec4 rBasisPos = uBasis[1]; + #endif + + vec3 coord = + #ifdef TYPE_SPRITE + mulBasis(rBasisRot, rBasisPos.xyz + aCoord.xyz, vec3(aTexCoord.z, aTexCoord.w, 0.0) * 32767.0); + #else + mulBasis(rBasisRot, rBasisPos.xyz, aCoord.xyz); + #endif + + vViewVec = vec4((uViewPos.xyz - coord) * uFogParams.w, 0.0); + + #ifndef TYPE_FLASH + #ifdef TYPE_SPRITE + vNormal.xyz = normalize(vViewVec.xyz); + #else + vNormal.xyz = normalize(mulQuat(rBasisRot, aNormal.xyz)); + #endif + + float fog; + #if defined(UNDERWATER) && !defined(OPT_UNDERWATER_FOG) + float d = length(uViewPos.xyz - coord); + if (uViewPos.y < uParam.y) { + d *= (coord.y - uParam.y) / (coord.y - uViewPos.y); + } + fog = d * WATER_FOG_DIST; + fog *= step(uParam.y, coord.y); + #else + fog = length(vViewVec.xyz); + #endif + vNormal.w = clamp(1.0 / exp(fog), 0.0, 1.0); + + vCoord = coord; + #endif + return vec4(coord, rBasisPos.w); + } + + void _diffuse() { + vDiffuse = vec4(aColor.xyz * uMaterial.x, 1.0); + vDiffuse.xyz *= 2.0; + + #ifdef TYPE_MIRROR + vDiffuse.xyz = uMaterial.xyz; + #endif + + #ifdef TYPE_FLASH + vDiffuse.xyz += uMaterial.w; + #endif + + #ifdef TYPE_ENTITY + vDiffuse *= uMaterial.w; + #endif + + #ifdef TYPE_SPRITE + vDiffuse *= aLight.w; + #endif + } + + void _lighting(vec3 coord) { + #ifndef TYPE_FLASH + vec3 lv0 = (uLightPos[0].xyz - coord) * uLightColor[0].w; + vec3 lv1 = (uLightPos[1].xyz - coord) * uLightColor[1].w; + vec3 lv2 = (uLightPos[2].xyz - coord) * uLightColor[2].w; + vec3 lv3 = (uLightPos[3].xyz - coord) * uLightColor[3].w; + + #ifdef OPT_VLIGHTVEC + vLightVec = lv0; + #endif + + vec4 lum, att; + #ifdef TYPE_ENTITY + lum.x = dot(vNormal.xyz, normalize(lv0)); + att.x = dot(lv0, lv0); + #else + lum.x = 1.0; + att.x = 0.0; + + #ifdef TYPE_SPRITE + lum.x *= uMaterial.y; + #endif + + #endif + + lum.y = dot(vNormal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); + lum.z = dot(vNormal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); + lum.w = dot(vNormal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); + vec4 light = max(vec4(0.0), lum) * max(vec4(0.0), vec4(1.0) - att); + + #if (defined(TYPE_ENTITY) || defined(TYPE_ROOM)) && defined(UNDERWATER) && defined(VERT_CAUSTICS) + light.x *= 0.5 + abs(sin(dot(coord.xyz, vec3(1.0 / 1024.0)) + uParam.x)) * 0.75; + #endif + + vec3 ambient; + #ifdef TYPE_ENTITY + #ifdef OPT_AMBIENT + ambient = calcAmbient(vNormal.xyz); + #else + ambient = vec3(uMaterial.y); + #endif + #else + ambient = min(uMaterial.yyy, aLight.xyz); + #endif + + #ifdef OPT_SHADOW + vAmbient = ambient; + vLight = light; + vLightMap = aLight.xyz * light.x; + + #ifdef OPT_VLIGHTPROJ + vLightProj = calcLightProj(coord, lv0, vNormal.xyz); + #endif + + #else + vLight.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; + vLight.w = 0.0; + + #ifdef TYPE_ENTITY + vLight.xyz += ambient + uLightColor[0].xyz * light.x; + #else + vLight.xyz += aLight.xyz * light.x; + #endif + + #endif + #endif + } + + void _uv(vec3 coord) { + vTexCoord = aTexCoord; + #ifndef TYPE_SPRITE + #ifdef OPT_TRAPEZOID + vTexCoord.xy *= vTexCoord.zw; + #endif + #endif + } + + void main() { + vec4 coord = _transform(); + + _diffuse(); + _lighting(coord.xyz); + + _uv(coord.xyz); + + gl_Position = uViewProj * coord; + } + +#else + + #ifdef TYPE_MIRROR + uniform samplerCube sDiffuse; + #else + uniform sampler2D sDiffuse; + #endif + + float unpack(vec4 value) { + return dot(value, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0)); + } + + #ifdef OPT_SHADOW + #ifdef SHADOW_SAMPLER + uniform sampler2DShadow sShadow; + #define SHADOW(p) (FETCH_SHADOW2D(sShadow, p)) + #else + uniform sampler2D sShadow; + + float SHADOW(vec2 p) { + #ifdef SHADOW_DEPTH + return texture2D(sShadow, p).x; + #else + return unpack(texture2D(sShadow, p)); + #endif + } + #endif + + float getShadow(vec3 lightVec, vec3 normal, vec4 lightProj) { + vec3 p = lightProj.xyz / lightProj.w; + p.z -= SHADOW_CONST_BIAS * SHADOW_TEXEL.x; + + float vis = lightProj.w; + #ifdef TYPE_ROOM + vis = min(vis, dot(normal, lightVec)); + #endif + if (min(vis, min(p.x, p.y)) < 0.0 || max(p.x, p.y) > 1.0) return 1.0; + + #ifdef SHADOW_SAMPLER + float rShadow = SHADOW(p); + #else + #ifndef OPT_SHADOW_ONETAP + vec4 samples = vec4(SHADOW( p.xy), + SHADOW(SHADOW_TEXEL.xz + p.xy), + SHADOW(SHADOW_TEXEL.zy + p.xy), + SHADOW(SHADOW_TEXEL.xy + p.xy)); + + samples = step(vec4(p.z), samples); + + vec2 f = fract(p.xy / SHADOW_TEXEL.xy); + samples.xy = mix(samples.xz, samples.yw, f.x); + float rShadow = mix(samples.x, samples.y, f.y); + #else + float rShadow = step(p.z, SHADOW(p.xy)); + #endif + #endif + + float fade = clamp(dot(lightVec, lightVec), 0.0, 1.0); + return rShadow + (1.0 - rShadow) * fade; + } + + float getShadow(vec3 lightVec, vec3 normal) { + #ifndef OPT_VLIGHTPROJ + vec4 vLightProj = calcLightProj(vCoord, lightVec, normal); + #endif + return getShadow(lightVec, normal, vLightProj); + } + #endif + + #ifdef OPT_CAUSTICS + uniform sampler2D sReflect; + + float calcCaustics(vec3 n) { + vec2 cc = clamp((vCoord.xz - uRoomSize.xy) / uRoomSize.zw, vec2(0.0), vec2(1.0)); + vec2 border = vec2(256.0) / uRoomSize.zw; + vec2 fade = smoothstep(vec2(0.0), border, cc) * (1.0 - smoothstep(vec2(1.0) - border, vec2(1.0), cc)); + return texture2D(sReflect, cc).x * max(0.0, -n.y) * fade.x * fade.y; + } + #endif + + #ifdef OPT_CONTACT + uniform vec4 uContacts[MAX_CONTACTS]; + + float getContactAO(vec3 p, vec3 n) { + float res = 1.0; + for (int i = 0; i < MAX_CONTACTS; i++) { + vec3 v = uContacts[i].xyz - p; + float a = uContacts[i].w; + float o = a * clamp(dot(n, v), 0.0, 1.0) / dot(v, v); + res *= clamp(1.0 - o, 0.0, 1.0); + } + return res; + } + #endif + + float calcSpecular(vec3 normal, vec3 viewVec, vec3 lightVec, vec4 color, float intensity) { + vec3 vv = normalize(viewVec); + vec3 rv = reflect(-vv, normal); + vec3 lv = normalize(lightVec); + return pow(max(0.0, dot(rv, lv)), 8.0) * intensity; + } + + void main() { + vec2 uv = vTexCoord.xy; + vec4 color; + #ifdef TYPE_MIRROR + vec3 rv = reflect(-normalize(vViewVec.xyz), normalize(vNormal.xyz)); + color = textureCube(sDiffuse, normalize(rv)); + #else + #ifndef TYPE_SPRITE + #ifdef OPT_TRAPEZOID + uv /= vTexCoord.zw; + #endif + #endif + color = texture2D(sDiffuse, uv); + #endif + + #ifdef ALPHA_TEST +//color = vec4(1, 0, 0, 1); + if (color.w <= 0.5) + discard; + #endif + + color *= vDiffuse; + + #if !defined(TYPE_FLASH) && !defined(TYPE_MIRROR) + + #ifndef OPT_VLIGHTVEC + vec3 vLightVec = (uLightPos[0].xyz - vCoord) * uLightColor[0].w; + #endif + + vec3 normal = normalize(vNormal.xyz); + + #ifdef TYPE_ENTITY + float rSpecular = uMaterial.z; + #endif + + #ifdef OPT_SHADOW + vec3 light = uLightColor[1].xyz * vLight.y + uLightColor[2].xyz * vLight.z + uLightColor[3].xyz * vLight.w; + + #if defined(TYPE_ENTITY) || defined(TYPE_ROOM) + float rShadow = getShadow(vLightVec, normal); + #endif + + #ifdef TYPE_ENTITY + rSpecular *= rShadow; + light += vAmbient + uLightColor[0].xyz * (vLight.x * rShadow); + #endif + + #ifdef TYPE_ROOM + light += mix(vAmbient, vLightMap, rShadow); + #endif + + #ifdef TYPE_SPRITE + light += vLightMap; + #endif + + #else + vec3 light = vLight.xyz; + #endif + + #ifdef UNDERWATER + float uwSign = 1.0; + #ifdef TYPE_ENTITY + uwSign = step(uParam.y, vCoord.y); + #endif + + #ifdef OPT_CAUSTICS + light += calcCaustics(normal) * uwSign; + #endif + #endif + + #ifdef OPT_CONTACT + light *= getContactAO(vCoord, normal) * 0.5 + 0.5; + #endif + + color.xyz *= light; + + #if defined(TYPE_ENTITY) && defined(OPT_UNDERWATER_FOG) + float specular = calcSpecular(normal, vViewVec.xyz, vLightVec, uLightColor[0], rSpecular); + #ifdef UNDERWATER + specular *= (1.0 - uwSign); + #endif + color.xyz += specular; + #endif + + #ifdef UNDERWATER + #ifdef OPT_UNDERWATER_FOG + float dist; + if (uViewPos.y < uParam.y) + dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y); + else + dist = length(uViewPos.xyz - vCoord.xyz); + float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0); + dist += vCoord.y - uParam.y; + color.xyz *= mix(vec3(1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0)); + color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog); + #else + color.xyz = mix(color.xyz, color.xyz * UNDERWATER_COLOR, uwSign); + color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, vNormal.w); + #endif + #else + color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w); + #endif + #endif + + fragColor = color; + } + +#endif +)====" diff --git a/src/shaders/compose.hlsl b/src/shaders/compose.hlsl deleted file mode 100644 index 8f47e4ed..00000000 --- a/src/shaders/compose.hlsl +++ /dev/null @@ -1,332 +0,0 @@ -#include "common.hlsl" - -struct VS_OUTPUT { - float4 pos : POSITION; - float3 coord : TEXCOORD0; - float4 texCoord : TEXCOORD1; - float4 viewVec : TEXCOORD2; - float4 normal : TEXCOORD3; - float4 diffuse : TEXCOORD4; - float3 ambient : TEXCOORD5; - float3 lightMap : TEXCOORD6; - float4 light : TEXCOORD7; - float4 lightProj : TEXCOORD8; -#ifdef _GAPI_GXM - float clipDist : CLP0; -#endif -}; - -#ifdef VERTEX -VS_OUTPUT main(VS_INPUT In) { - VS_OUTPUT Out; - Out.ambient = 0.0; - Out.lightMap = 0.0; - Out.light = 0.0; - - int index = int(In.aCoord.w * 2.0); - float4 rBasisRot = uBasis[index]; - float4 rBasisPos = uBasis[index + 1]; - - Out.texCoord = In.aTexCoord * (1.0 / 32767.0); - - if (TYPE_SPRITE) { - Out.coord = mulBasis(rBasisRot, rBasisPos.xyz + In.aCoord.xyz, float3(In.aTexCoord.z, In.aTexCoord.w, 0.0)); - } else { - Out.coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); - Out.texCoord.xy *= Out.texCoord.zw; - } - - Out.viewVec = float4((uViewPos.xyz - Out.coord) * uFogParams.w, Out.coord.y * uParam.z); - - if (TYPE_SPRITE) { - Out.normal.xyz = normalize(Out.viewVec.xyz); - } else { - Out.normal.xyz = mulQuat(rBasisRot, normalize(In.aNormal.xyz)); - } - - float fog; - - if (!TYPE_FLASH) { - float3 lv0 = (uLightPos[0].xyz - Out.coord) * uLightColor[0].w; - float3 lv1 = (uLightPos[1].xyz - Out.coord) * uLightColor[1].w; - float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w; - float3 lv3 = (uLightPos[3].xyz - Out.coord) * uLightColor[3].w; - - float4 lum, att; - if (TYPE_ENTITY) { - lum.x = dot(Out.normal.xyz, normalize(lv0)); - att.x = dot(lv0, lv0); - if (OPT_AMBIENT) { - Out.ambient = calcAmbient(Out.normal.xyz); - } else { - Out.ambient = min(uMaterial.yyy, RGB(In.aLight)); - } - } else { - if (TYPE_SPRITE) { - lum.x = uMaterial.y; - } else { - lum.x = 1.0; - } - att.x = 0.0; - - Out.ambient = min(uMaterial.yyy, RGB(In.aLight)); - } - - float4 light; - lum.y = dot(Out.normal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); - lum.z = dot(Out.normal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); - lum.w = dot(Out.normal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); - light = max((float4)0.0, lum) * max((float4)0.0, (float4)1.0 - att); - - if (UNDERWATER) { - light.x *= abs(sin(dot(Out.coord.xyz, 1.0 / 512.0) + uParam.x)) * 1.5 + 0.5; - - float d; - if (uViewPos.y < uParam.y) { - d = abs((Out.coord.y - uParam.y) / normalize(uViewPos.xyz - Out.coord.xyz).y); - } else { - d = length(uViewPos.xyz - Out.coord.xyz); - } - fog = d * WATER_FOG_DIST; - fog *= step(uParam.y, Out.coord.y); - Out.normal.w = fog; - } else { - fog = length(Out.viewVec.xyz); - Out.normal.w = saturate(1.0 / exp(fog)); - } - Out.normal.w = saturate(1.0 / exp(fog)); - - if (OPT_SHADOW) { - Out.light = light; - Out.lightMap = RGB(In.aLight) * light.x; - } else { - Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; - Out.light.w = 0.0; - - if (TYPE_ENTITY) { - Out.light.xyz += Out.ambient + uLightColor[0].xyz * light.x; - } else { - Out.light.xyz += RGB(In.aLight) * light.x; - } - } - } else - Out.normal.w = 1.0; - - if (TYPE_MIRROR) { - Out.diffuse = uMaterial; - } else { - Out.diffuse = float4(RGB(In.aColor) * (uMaterial.x * 1.8), 1.0); - - if (TYPE_FLASH) { - Out.diffuse.xyz += uMaterial.w; - } else { - Out.diffuse *= uMaterial.w; - } - - if (TYPE_SPRITE) { - Out.diffuse *= RGBA(In.aLight).a; - } - } - - Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w)); - Out.lightProj = mul(uLightProj, float4(Out.coord, 1.0)); -/* - if (TYPE_ROOM) { - float3 lightVec = uLightPos[0].xyz - Out.coord; - if (dot(Out.normal.xyz, lightVec) < 0.0) { - Out.lightProj.w = -1.0; - } - } -*/ -#ifdef _GAPI_GXM - Out.clipDist = uParam.w - Out.viewVec.w; -#endif - - return Out; -} - -#else // PIXEL - -float SHADOW(float2 p) { - #ifdef SHADOW_DEPTH - return tex2Dlod(sShadow, float4(p, 0, 0)).x; - #else - return unpack(tex2Dlod(sShadow, float4(p, 0, 0))); - #endif -} - -float getShadow(float3 lightVec, float3 normal, float4 lightProj) { -/* - float sMin = min(lightProj.x, lightProj.y); - float sMax = max(lightProj.x, lightProj.y); - float vis = lightProj.w; - if (TYPE_ROOM) { - vis = min(vis, dot(normal, lightVec)); - } - sMin = min(vis, sMin); -*/ - float factor = step(0.0, lightProj.w); //float((sMin > 0.0f) && (sMax < lightProj.w)); // - lightProj.xyz *= factor; - -#ifdef _GAPI_GXM - lightProj.z += SHADOW_CONST_BIAS * SHADOW_TEXEL.x * lightProj.w; - float rShadow = f1tex2Dproj(sShadow, lightProj); -#else - float3 p = lightProj.xyz / lightProj.w; - - p.z -= SHADOW_CONST_BIAS * SHADOW_TEXEL.x; - - p.z = saturate(p.z); - - float4 samples = float4( - SHADOW(p.xy ), - SHADOW(p.xy + SHADOW_TEXEL.xz), - SHADOW(p.xy + SHADOW_TEXEL.zy), - SHADOW(p.xy + SHADOW_TEXEL.xy) - ); - samples = step(p.zzzz, samples); - - float2 f = frac(p.xy / SHADOW_TEXEL.xy); - samples.xy = lerp(samples.xz, samples.yw, f.xx); - float rShadow = lerp(samples.x, samples.y, f.y); -#endif - - //rShadow = lerp(1.0, rShadow, factor); - - float fade = saturate(dot(lightVec, lightVec)); - return rShadow + (1.0 - rShadow) * fade; -} - -float getShadow(float3 coord, float3 lightVec, float3 normal, float4 lightProj) { - float factor = clamp(1.0 - dot(normalize(lightVec), normal), 0.0, 1.0); - factor *= SHADOW_NORMAL_BIAS; - return getShadow(lightVec, normal, lightProj /*mul(uLightProj, float4(coord + normal * factor, 1.0)) */ ); -} - -float getContactAO(float3 p, float3 n) { - float res = 1.0; - for (int i = 0; i < MAX_CONTACTS; i++) { - float3 v = uContacts[i].xyz - p; - float a = uContacts[i].w; - float o = a * saturate(dot(n, v)) / dot(v, v); - res *= saturate(1.0 - o); - } - return res; -} - -float calcCaustics(float3 coord, float3 n) { - float2 cc = saturate((coord.xz - uRoomSize.xy) / uRoomSize.zw); - return tex2Dlod(sReflect, float4(cc.x, 1.0 - cc.y, 0, 0)).x * max(0.0, -n.y); -} - -float calcSpecular(float3 normal, float3 viewVec, float3 lightVec, float intensity) { - float3 vv = normalize(viewVec); - float3 rv = reflect(-vv, normal); - float3 lv = normalize(lightVec); - return pow(max(0.0, dot(rv, lv)), 8.0) * intensity; -} - -float4 main(VS_OUTPUT In) : COLOR0 { - float2 uv = In.texCoord.xy; - - if (!TYPE_SPRITE) { - uv /= In.texCoord.zw; - } - - float4 color; - - if (TYPE_MIRROR) { - float3 rv = reflect(-normalize(In.viewVec.xyz), normalize(In.normal.xyz)); - color = texCUBE(sEnvironment, normalize(rv)).bgra; - } else { - color = tex2D(sDiffuse, uv).bgra; - - if (ALPHA_TEST) { - if (color.w <= 0.5) - discard; - } - } - -#ifndef _GAPI_GXM - if (CLIP_PLANE) { - if (In.viewVec.w > uParam.w) { - discard; - } - } -#endif - - color *= In.diffuse; - - if (TYPE_FLASH) { - return color; - } - - if (TYPE_MIRROR) { - return color; - } - - float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w; - float3 normal = normalize(In.normal.xyz); - - float rSpecular = 0.0; - - float3 light; - if (OPT_SHADOW) { - light = uLightColor[1].xyz * In.light.y + uLightColor[2].xyz * In.light.z + uLightColor[3].xyz * In.light.w; - - if (TYPE_ENTITY) { - float rShadow = getShadow(In.coord, lightVec, normal, In.lightProj); - rSpecular = (uMaterial.z + 0.03) * rShadow; - light += In.ambient + uLightColor[0].xyz * (In.light.x * rShadow); - } else if (TYPE_ROOM) { - float rShadow = getShadow(In.coord, lightVec, normal, In.lightProj); - light += lerp(In.ambient, In.lightMap, rShadow); - } else if (TYPE_SPRITE) { - light += In.lightMap; - } - } else { - light = In.light.xyz; - } - - float uwSign = 1.0; - if (UNDERWATER) { - if (TYPE_ENTITY) { - uwSign = step(uParam.y, In.coord.y); - } - - if (OPT_CAUSTICS) { - light += calcCaustics(In.coord, normal); - } - } - - if (OPT_CONTACT) { - light *= getContactAO(In.coord, normal) * 0.5 + 0.5; - } - - color.xyz *= light; - - if (TYPE_ENTITY) { - float specular = calcSpecular(normal, In.viewVec.xyz, lightVec, rSpecular); - if (UNDERWATER) { - specular *= (1.0 - uwSign); - } - color.xyz += specular; - } - - if (UNDERWATER) { - float dist; - if (uViewPos.y < uParam.y) - dist = abs((In.coord.y - uParam.y) / normalize(uViewPos.xyz - In.coord.xyz).y); - else - dist = length(uViewPos.xyz - In.coord.xyz); - float fog = saturate(1.0 / exp(dist * WATER_FOG_DIST * uwSign)); - dist += In.coord.y - uParam.y; - color.xyz *= lerp(float3(1.0, 1.0, 1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0)); - color.xyz = lerp(UNDERWATER_COLOR * 0.2, color.xyz, fog); - } else { - color.xyz = lerp(uFogParams.xyz, color.xyz, In.normal.w); - } - - return color; -} -#endif \ No newline at end of file diff --git a/src/shaders/compose_entity.asm b/src/shaders/compose_entity.asm new file mode 100644 index 00000000..f9a98e9a --- /dev/null +++ b/src/shaders/compose_entity.asm @@ -0,0 +1,88 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv0 r0 + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define att r5 + #define light r6 + #define pos r7 + + #define MAT_AMBIENT c[uMaterial].y + #define MAT_ALPHA c[uMaterial].w + +; joint = int(aCoord.w) + mov a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mulQuatPos(pos, aCoord, a0.x) + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; lighting + ; lv[0..3] = (uLightPos[0..3].xyz - pos) * uLightColor[0..3].w; + add lv0.xyz, c[uLightPos + 0], -pos + add lv1.xyz, c[uLightPos + 1], -pos + add lv2.xyz, c[uLightPos + 2], -pos + add lv3.xyz, c[uLightPos + 3], -pos + mul lv0.xyz, c[uLightColor + 0].w, lv0 + mul lv1.xyz, c[uLightColor + 1].w, lv1 + mul lv2.xyz, c[uLightColor + 2].w, lv2 + mul lv3.xyz, c[uLightColor + 3].w, lv3 + + ; att[0..3] = dot(lv[0..3], lv[0..3]) + dp3 att.x, lv0, lv0 + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.x, att.x + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; normal = mulQuat(uBasis[joint], aNormal) + mulQuat(normal, aNormal, a0.x) + + ; light = max(0, dot(normal, lv[0..3])) + dp3 light.x, lv0, normal + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = aColor * material.alpha * (material.ambient + light[0..3] * uLightColor[0..3]) * 2 + mov att, aColor + mul att, MAT_ALPHA, att + mov tmp.xyz, MAT_AMBIENT + mov tmp.w, ONE + mad tmp.xyz, light.x, c[uLightColor + 0], tmp + mad tmp.xyz, light.y, c[uLightColor + 1], tmp + mad tmp.xyz, light.z, c[uLightColor + 2], tmp + mad tmp.xyz, light.w, c[uLightColor + 3], tmp + mul att, att, tmp + applyUnderwater(att, pos) + encodeColor(att) + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + applyColor(r0, t0) +#endif diff --git a/src/shaders/compose_entity.hlsl b/src/shaders/compose_entity.hlsl new file mode 100644 index 00000000..0cc3fff6 --- /dev/null +++ b/src/shaders/compose_entity.hlsl @@ -0,0 +1,145 @@ +#include "common.hlsl" + +// ALPHA_TEST, UNDERWATER, OPT_SHADOW, OPT_CAUSTICS, OPT_AMBIENT + +struct VS_OUTPUT { + float4 pos : POSITION; + float3 coord : TEXCOORD0; + float4 texCoord : TEXCOORD1; + float4 viewVec : TEXCOORD2; + float4 normal : TEXCOORD3; + float4 diffuse : TEXCOORD4; + float4 light : TEXCOORD5; + +#ifdef OPT_SHADOW + float4 lightProj : TEXCOORD6; +#endif + +#ifdef OPT_AMBIENT + float3 ambient : TEXCOORD7; +#endif +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + int index = int(In.aCoord.w); + float4 rBasisRot = uBasis[index]; + float4 rBasisPos = uBasis[index + 1]; + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + + Out.coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); + Out.texCoord.xy *= Out.texCoord.zw; + + Out.viewVec = float4((uViewPos.xyz - Out.coord) * uFogParams.w, uParam.w - Out.coord.y * uParam.z); + + Out.normal.xyz = mulQuat(rBasisRot, normalize(In.aNormal.xyz)); + + float3 lv0 = (uLightPos[0].xyz - Out.coord) * uLightColor[0].w; + float3 lv1 = (uLightPos[1].xyz - Out.coord) * uLightColor[1].w; + float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w; + float3 lv3 = (uLightPos[3].xyz - Out.coord) * uLightColor[3].w; + + float3 ambient; + #ifdef OPT_AMBIENT + ambient = calcAmbient(Out.normal.xyz); + #else + ambient = uMaterial.yyy; + #endif + + float4 lum, att, light; + lum.x = dot(Out.normal.xyz, normalize(lv0)); att.x = dot(lv0, lv0); + lum.y = dot(Out.normal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); + lum.z = dot(Out.normal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); + lum.w = dot(Out.normal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); + light = max((float4)0.0, lum) * max((float4)0.0, (float4)1.0 - att); + + #ifdef UNDERWATER + light.x *= calcCausticsV(Out.coord); + Out.normal.w = 0.0; + #else + Out.normal.w = saturate(1.0 / exp(length(Out.viewVec.xyz))); + #endif + + #ifdef OPT_SHADOW + Out.light = light; + Out.lightProj = calcLightProj(Out.coord); + #ifdef OPT_AMBIENT + Out.ambient = ambient; + #endif + #else + Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; + Out.light.w = 0.0; + + Out.light.xyz += ambient + uLightColor[0].xyz * light.x; + #endif + + Out.diffuse = float4(In.aColor.xyz * (uMaterial.x * 1.8), 1.0); + + Out.diffuse *= uMaterial.w; + + Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy / In.texCoord.zw); + + #ifdef ALPHA_TEST + clip(color.w - ALPHA_REF); + #endif + + color *= In.diffuse; + + float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w; + float3 normal = normalize(In.normal.xyz); + + float rSpecular = 0.0; + + float3 light; + #ifdef OPT_SHADOW + light = uLightColor[1].xyz * In.light.y + uLightColor[2].xyz * In.light.z + uLightColor[3].xyz * In.light.w; + float rShadow = getShadow(lightVec, In.lightProj); + rSpecular = (uMaterial.z + 0.03) * rShadow; + + float3 ambient; + #ifdef OPT_AMBIENT + ambient = In.ambient; + #else + ambient = uMaterial.yyy; + #endif + + light += ambient + uLightColor[0].xyz * (In.light.x * rShadow); + #else + light = In.light.xyz; + #endif + + #ifdef OPT_CAUSTICS + light += calcCaustics(In.coord, normal); + #endif + + color.xyz *= light; + + float specular = calcSpecular(normal, In.viewVec.xyz, lightVec, rSpecular); + + #ifdef UNDERWATER + float uwSign = step(uParam.y, In.coord.y); + specular *= (1.0 - uwSign); + color.xyz += specular; + + applyFogUW(color.xyz, In.coord, WATER_FOG_DIST * uwSign, WATER_COLOR_DIST * uwSign); + #else + color.xyz += specular; + applyFog(color.xyz, In.normal.w); + #endif + + return color; +} + +#endif diff --git a/src/shaders/compose_flash.asm b/src/shaders/compose_flash.asm new file mode 100644 index 00000000..b3181507 --- /dev/null +++ b/src/shaders/compose_flash.asm @@ -0,0 +1,39 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv0 r0 + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define att r5 + #define light r6 + #define pos r7 + #define MAT_DIFFUSE c[uMaterial].x + #define MAT_EMISSIVE c[uMaterial].w + +; pos = mulQuatPos(uBasis[0], aCoord) + mulQuatPos(pos, aCoord, 0) + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; vColor = (material.diffuse * aColor.xyz * 2.0 + material.emissive, 1.0) + mul tmp, MAT_DIFFUSE, aColor + add tmp, tmp, tmp + add tmp, tmp, MAT_EMISSIVE + mov tmp.w, MAT_EMISSIVE + mul tmp, tmp, HALF + encodeColor(tmp) + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + applyColor(r0, t0) +#endif \ No newline at end of file diff --git a/src/shaders/compose_flash.hlsl b/src/shaders/compose_flash.hlsl new file mode 100644 index 00000000..72c20042 --- /dev/null +++ b/src/shaders/compose_flash.hlsl @@ -0,0 +1,37 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float4 texCoord : TEXCOORD0; + float3 diffuse : TEXCOORD1; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + int index = int(In.aCoord.w); + float4 rBasisRot = uBasis[index]; + float4 rBasisPos = uBasis[index + 1]; + + float3 coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); + + Out.pos = mul(uViewProj, float4(coord, 1.0)); + Out.diffuse = In.aColor.rgb * (uMaterial.x * 1.8) + uMaterial.w; + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + Out.texCoord.xy *= Out.texCoord.zw; + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy / In.texCoord.zw); + + color.xyz *= In.diffuse.xyz; + return color; +} + +#endif diff --git a/src/shaders/compose_mirror.asm b/src/shaders/compose_mirror.asm new file mode 100644 index 00000000..942a3294 --- /dev/null +++ b/src/shaders/compose_mirror.asm @@ -0,0 +1,43 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv0 r0 + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define tmp2 r5 + #define viewVec r6 + #define pos r7 + +; joint = int(aCoord.w) + mov a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mulQuatPos(pos, aCoord, a0.x) + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; viewVec = normalize(pos - uViewPos) + sub viewVec, pos, c[uViewPos] + normalize(viewVec) + +; normal = mulQuat(uBasis, aNormal) + mulQuat(normal, aNormal, a0.x) + +; vTexCoord = reflect(viewVec, normal) + reflect(vTexCoord, viewVec, normal) + +; vColor = uMaterial + mov tmp, c[uMaterial] + mul tmp, tmp, HALF + encodeColor(tmp) +#else + tex t0 + applyColor(r0, t0) +#endif \ No newline at end of file diff --git a/src/shaders/compose_mirror.hlsl b/src/shaders/compose_mirror.hlsl new file mode 100644 index 00000000..aeeb7ea9 --- /dev/null +++ b/src/shaders/compose_mirror.hlsl @@ -0,0 +1,45 @@ +#define DIFFUSE_AS_CUBE +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float4 viewVec : TEXCOORD0; + float4 normal : TEXCOORD1; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + int index = int(In.aCoord.w); + float4 rBasisRot = uBasis[index]; + float4 rBasisPos = uBasis[index + 1]; + + float3 coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); + + Out.viewVec = float4((uViewPos.xyz - coord) * uFogParams.w, uParam.w - coord.y * uParam.z); + + Out.normal.xyz = mulQuat(rBasisRot, normalize(In.aNormal.xyz)); + Out.normal.w = saturate(1.0 / exp(length(Out.viewVec.xyz))); + + Out.pos = mul(uViewProj, float4(coord, rBasisPos.w)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float3 rv = reflect(-In.viewVec.xyz, In.normal.xyz); + float4 color = SAMPLE_CUBE(sDiffuse, normalize(rv)); + + color *= uMaterial; + color.xyz = saturate(color.xyz); + + applyFog(color.xyz, In.normal.w); + + return color; +} + +#endif diff --git a/src/shaders/compose_room.asm b/src/shaders/compose_room.asm new file mode 100644 index 00000000..557f4897 --- /dev/null +++ b/src/shaders/compose_room.asm @@ -0,0 +1,72 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define att r5 + #define light r6 + #define pos r7 + +; pos = mulQuatPos(uBasis[0], aCoord) + mulQuatPos(pos, aCoord, 0) + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, c[uLightPos + 1], -pos + add lv2.xyz, c[uLightPos + 2], -pos + add lv3.xyz, c[uLightPos + 3], -pos + mul lv1.xyz, c[uLightColor + 1].w, lv1 + mul lv2.xyz, c[uLightColor + 2].w, lv2 + mul lv3.xyz, c[uLightColor + 3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; light = max(0, dot(aNormal, lv[1..3])) + mov light.x, ZERO + dp3 light.y, lv1, aNormal + dp3 light.z, lv2, aNormal + dp3 light.w, lv3, aNormal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = (aLight + light[1..3] * uLightColor[1..3]) * aColor * 2 + mov att, aColor + mov tmp, aLight + mad tmp.xyz, light.y, c[uLightColor + 1], tmp + mad tmp.xyz, light.z, c[uLightColor + 2], tmp + mad tmp.xyz, light.w, c[uLightColor + 3], tmp + mul att, att, tmp + applyUnderwater(att, pos) + encodeColor(att) + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + applyColor(r0, t0) +#endif \ No newline at end of file diff --git a/src/shaders/compose_room.hlsl b/src/shaders/compose_room.hlsl new file mode 100644 index 00000000..fd869b08 --- /dev/null +++ b/src/shaders/compose_room.hlsl @@ -0,0 +1,138 @@ +#include "common.hlsl" + +// ALPHA_TEST, UNDERWATER, OPT_SHADOW, OPT_CAUSTICS, OPT_CONTACT + +#ifdef _GAPI_D3D11_9_3 + #define MONOCHROME_AMBIENT +#endif + +struct VS_OUTPUT { + float4 pos : POSITION; + float3 coord : TEXCOORD0; + float4 texCoord : TEXCOORD1; + float4 normal : TEXCOORD2; + float4 diffuse : TEXCOORD3; + float4 light : TEXCOORD4; + +#ifdef OPT_SHADOW + float4 lightProj : TEXCOORD5; + float4 lightMap : TEXCOORD6; + + #ifndef MONOCHROME_AMBIENT + float3 ambient : TEXCOORD7; + #endif + +#endif +}; + +#ifdef VERTEX +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float4 rBasisRot = uBasis[0]; + float4 rBasisPos = uBasis[1]; + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + + Out.coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); + Out.texCoord.xy *= Out.texCoord.zw; + + Out.normal.xyz = normalize(In.aNormal.xyz); + + float3 lv1 = (uLightPos[1].xyz - Out.coord) * uLightColor[1].w; + float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w; + float3 lv3 = (uLightPos[3].xyz - Out.coord) * uLightColor[3].w; + + float4 lum, att; + lum.x = 1.0; + att.x = 0.0; + + float4 light; + lum.y = dot(Out.normal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); + lum.z = dot(Out.normal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); + lum.w = dot(Out.normal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); + light = max((float4)0.0, lum) * max((float4)0.0, (float4)1.0 - att); + + #ifdef UNDERWATER + light.x *= calcCausticsV(Out.coord); + Out.normal.w = 0.0; + #else + float3 viewVec = (uViewPos.xyz - Out.coord) * uFogParams.w; + Out.normal.w = saturate(1.0 / exp(length(viewVec.xyz))); + #endif + + #ifdef OPT_SHADOW + Out.light = light; + Out.lightMap.rgb = In.aLight.rgb * light.x; + Out.lightProj = calcLightProj(Out.coord); + + #ifdef MONOCHROME_AMBIENT + Out.lightMap.a = min(uMaterial.y, In.aLight.r); + #else + Out.lightMap.a = 0.0; + Out.ambient = min(uMaterial.yyy, In.aLight.rgb); + #endif + #else + Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; + Out.light.w = 0.0; + Out.light.xyz += In.aLight.rgb * light.x; + #endif + + Out.diffuse = float4(In.aColor.rgb * (uMaterial.x * 1.8), 1.0); + + Out.diffuse *= uMaterial.w; + + Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy / In.texCoord.zw); + + #ifdef ALPHA_TEST + clip(color.w - ALPHA_REF); + #endif + + color *= In.diffuse; + + float3 light; + #ifdef OPT_SHADOW + float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w; + light = uLightColor[1].xyz * In.light.y + uLightColor[2].xyz * In.light.z + uLightColor[3].xyz * In.light.w; + float rShadow = getShadow(lightVec, In.lightProj); + #ifdef MONOCHROME_AMBIENT + light += lerp(In.lightMap.aaa, In.lightMap.rgb, rShadow); + #else + light += lerp(In.ambient, In.lightMap.rgb, rShadow); + #endif + #else + light = In.light.xyz; + #endif + + #if defined(OPT_CAUSTICS) || defined(OPT_CONTACT) + float3 normal = normalize(In.normal.xyz); + #endif + + #ifdef OPT_CAUSTICS + light += calcCaustics(In.coord, normal); + #endif + + #ifdef OPT_CONTACT + light *= getContactAO(In.coord, normal) * 0.5 + 0.5; + #endif + + color.xyz *= light; + + #ifdef UNDERWATER + applyFogUW(color.xyz, In.coord, WATER_FOG_DIST, WATER_COLOR_DIST); + #else + applyFog(color.xyz, In.normal.w); + #endif + + return color; +} + +#endif diff --git a/src/shaders/compose_sprite.asm b/src/shaders/compose_sprite.asm new file mode 100644 index 00000000..8d7e789e --- /dev/null +++ b/src/shaders/compose_sprite.asm @@ -0,0 +1,94 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define lv0 r0 + #define lv1 r1 + #define lv2 r2 + #define lv3 r3 + #define normal r4 + #define att r5 + #define light r6 + #define pos r7 + #define size r4 + #define vv r6 + + #define MAT_AMBIENT c[uMaterial].y + #define MAT_ALPHA c[uMaterial].w + +; pos = (aTexCoord.zw * 32767, 0, 0) + mov pos, ZERO + mul pos.xy, aTexCoord.zw, MAX_SHORT + +; size = mulQuatPos(uBasis[0], pos) + mulQuatPos(size, pos, 0) + +; pos = size + aCoord + add pos, size, aCoord + mov pos.w, ONE + +; vFog = length((uViewPos - pos) * uFogParams.w) + applyFog(vFog, pos) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, c[uLightPos + 1], -pos + add lv2.xyz, c[uLightPos + 2], -pos + add lv3.xyz, c[uLightPos + 3], -pos + mul lv1.xyz, c[uLightColor + 1].w, lv1 + mul lv2.xyz, c[uLightColor + 2].w, lv2 + mul lv3.xyz, c[uLightColor + 3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; viewVec = uViewPos - pos + add vv, c[uViewPos], -pos + + ; normal = normalize(viewVec) + dp3 tmp.x, vv, vv + rsq tmp.x, tmp.x + mul normal, vv, tmp.x + + ; light = max(0, dot(normal, lv[1..3])) + mov light.x, MAT_AMBIENT + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = vec4(aLight.rgb * aLight.a, aLight.a) * 2 + mov att, aLight + mad att.xyz, light.x, c[uLightColor + 0], att + mad att.xyz, light.y, c[uLightColor + 1], att + mad att.xyz, light.z, c[uLightColor + 2], att + mad att.xyz, light.w, c[uLightColor + 3], att + mul att.xyz, att, att.w + applyUnderwater(att, pos) + encodeColor(att) + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + applyColor(r0, t0) +#endif \ No newline at end of file diff --git a/src/shaders/compose_sprite.hlsl b/src/shaders/compose_sprite.hlsl new file mode 100644 index 00000000..3e704de6 --- /dev/null +++ b/src/shaders/compose_sprite.hlsl @@ -0,0 +1,89 @@ +#include "common.hlsl" + +// ALPHA_TEST, UNDERWATER, OPT_CAUSTICS + +struct VS_OUTPUT { + float4 pos : POSITION; + float3 coord : TEXCOORD0; + float4 texCoord : TEXCOORD1; + float4 normal : TEXCOORD2; + float4 diffuse : TEXCOORD3; + float4 light : TEXCOORD4; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float4 rBasisRot = uBasis[0]; + float4 rBasisPos = uBasis[1]; + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + + Out.coord = mulBasis(rBasisRot, rBasisPos.xyz + In.aCoord.xyz, float3(In.aTexCoord.z, In.aTexCoord.w, 0.0)); + + float3 viewVec = (uViewPos.xyz - Out.coord) * uFogParams.w; + + Out.normal.xyz = normalize(viewVec); + + float3 lv1 = (uLightPos[1].xyz - Out.coord) * uLightColor[1].w; + float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w; + float3 lv3 = (uLightPos[3].xyz - Out.coord) * uLightColor[3].w; + + float4 lum, att; + lum.x = uMaterial.y; + att.x = 0.0; + + float4 light; + lum.y = dot(Out.normal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); + lum.z = dot(Out.normal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); + lum.w = dot(Out.normal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); + light = max((float4)0.0, lum) * max((float4)0.0, (float4)1.0 - att); + + #ifdef UNDERWATER + Out.normal.w = 0.0; + #else + Out.normal.w = saturate(1.0 / exp(length(viewVec.xyz))); + #endif + + Out.light.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; + Out.light.w = 0.0; + + Out.light.xyz += In.aLight.rgb * light.x; + + Out.diffuse = float4(In.aColor.rgb * (uMaterial.x * 1.8), 1.0); + + Out.diffuse *= uMaterial.w; + Out.diffuse *= In.aLight.a; + + Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy); + + #ifdef ALPHA_TEST + clip(color.w - ALPHA_REF); + #endif + + color *= In.diffuse; + + float3 light = In.light.xyz; + + color.xyz *= light; + + #ifdef UNDERWATER + applyFogUW(color.xyz, In.coord, WATER_FOG_DIST, WATER_COLOR_DIST); + #else + applyFog(color.xyz, In.normal.w); + #endif + + return color; +} + +#endif diff --git a/src/shaders/dummy.hlsl b/src/shaders/dummy.hlsl new file mode 100644 index 00000000..27577dca --- /dev/null +++ b/src/shaders/dummy.hlsl @@ -0,0 +1,19 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; +}; + +#ifdef VERTEX +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + Out.pos = 0.0; + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + return float4(1.0, 0.0, 1.0, 0.0); +} +#endif \ No newline at end of file diff --git a/src/shaders/filter.asm b/src/shaders/filter.asm new file mode 100644 index 00000000..93494379 --- /dev/null +++ b/src/shaders/filter.asm @@ -0,0 +1,65 @@ +#include "common.asm" + +#ifdef VERTEX + mulMat(vPosition, aCoord, uViewProj) + + + #ifdef GRAYSCALE + mov vColor.xyz, c[uParam].xyz + mov vColor.w, ONE + #else + mov vColor, aLight + #endif + +; vTecCoord = (aTexCoord.xyz, 1) + #ifdef UPSCALE + mov vTexCoord, aTexCoord ; TODO + 0.5 * (1 / uParam.xy) + #endif + + #ifdef DOWNSAMPLE + mov vTexCoord, aTexCoord + #endif + + #ifdef GRAYSCALE + mov tmp, c[uParam].wwww + mad vTexCoord, tmp, HALF, aTexCoord + #endif + + #ifdef BLUR + mov tmp, c[uParam].wwww + mad vTexCoord, tmp, HALF, aTexCoord + #endif + + #ifdef ANAGLYPH + mov vTexCoord, aTexCoord + #endif + + mov vTexCoord.w, ONE +#else + def c0, 0.299f, 0.587f, 0.114f, 0.0f + + tex t0 + + #ifdef UPSCALE + mul r0, t0, vColor + #endif + + #ifdef DOWNSAMPLE + mul r0, t0, vColor + #endif + + #ifdef GRAYSCALE + dp3 r1.rgb, t0, c0 + mov r0, vColor + mul r0.rgb, r0.rgb, r1.rgb + #endif + + #ifdef BLUR ; TODO four tap blur + mul r0, t0, vColor + #endif + + #ifdef ANAGLYPH + mul r0, t0, vColor + #endif + +#endif \ No newline at end of file diff --git a/src/shaders/filter.glsl b/src/shaders/filter.glsl index b6488467..b8f8bd23 100644 --- a/src/shaders/filter.glsl +++ b/src/shaders/filter.glsl @@ -1,12 +1,8 @@ R"====( -#ifdef GL_ES - precision highp int; - precision highp float; -#endif - varying vec2 vTexCoord; varying vec4 vColor; uniform vec4 uParam; +uniform mat4 uViewProj; #ifdef VERTEX attribute vec4 aCoord; @@ -14,73 +10,106 @@ uniform vec4 uParam; attribute vec4 aLight; void main() { - vTexCoord = aTexCoord.xy; - vColor = aLight; - gl_Position = vec4(aCoord.xy * (1.0 / 32767.0), 0.0, 1.0); + vTexCoord = aTexCoord.xy; + vColor = aLight; + gl_Position = uViewProj * vec4(aCoord.xy, 0.0, 1.0); } #else uniform sampler2D sDiffuse; uniform sampler2D sNormal; - vec4 downsample() { // uParam (textureSize, unused, unused, unused) - vec4 color = vec4(0.0); - for (float y = -1.5; y < 2.0; y++) - for (float x = -1.5; x < 2.0; x++) { - vec4 p; - p.xyz = texture2D(sDiffuse, vTexCoord + vec2(x, y) * uParam.x).xyz; - p.w = dot(p.xyz, vec3(0.299, 0.587, 0.114)); - p.xyz *= p.w; - color += p; - } - - return vec4(color.xyz / color.w, 1.0); - } + #ifdef FILTER_DOWNSAMPLE + vec4 downsample() { // uParam (texelSize, unused, unused, unused) + vec4 color = vec4(0.0); + for (float y = -1.5; y < 2.0; y++) + for (float x = -1.5; x < 2.0; x++) { + vec4 p; + p.xyz = texture2D(sDiffuse, vTexCoord + vec2(x, y) * uParam.x).xyz; + p.w = dot(p.xyz, vec3(0.299, 0.587, 0.114)); + p.xyz *= p.w; + color += p; + } + + return vec4(color.xyz / color.w, 1.0); + } + #endif - vec4 grayscale() { // uParam (factor, unused, unused, unused) - vec4 color = texture2D(sDiffuse, vTexCoord); - vec3 gray = vec3(dot(color, vec4(0.299, 0.587, 0.114, 0.0))); - return vec4(mix(color.xyz, gray, uParam.w) * uParam.xyz, color.w); - } + #ifdef FILTER_DOWNSAMPLE_DEPTH + vec4 downsampleDepth() { + vec2 t = vTexCoord.xy; + vec3 o = vec3(uParam.x, uParam.y, 0.0); + float d0 = texture2D(sDiffuse, t + o.zz).x; + float d1 = texture2D(sDiffuse, t + o.xz).x; + float d2 = texture2D(sDiffuse, t + o.zy).x; + float d3 = texture2D(sDiffuse, t + o.xy).x; + gl_FragDepth = max(max(d0, d1), max(d2, d3)); + return vec4(0.0); + } + #endif - vec4 blur() { // uParam (dirX, dirY, 1 / textureSize, unused) - const vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); - const vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); - - vec2 dir = uParam.xy; - vec4 color = texture2D(sDiffuse, vTexCoord) * weight[0]; - color += texture2D(sDiffuse, vTexCoord + dir * offset[1]) * weight[1]; - color += texture2D(sDiffuse, vTexCoord - dir * offset[1]) * weight[1]; - color += texture2D(sDiffuse, vTexCoord + dir * offset[2]) * weight[2]; - color += texture2D(sDiffuse, vTexCoord - dir * offset[2]) * weight[2]; - return color; - } + #ifdef FILTER_GRAYSCALE + vec4 grayscale() { // uParam (tint.rgb, texelSize) + vec4 color = texture2D(sDiffuse, vTexCoord); + vec3 gray = vec3(dot(color, vec4(0.299, 0.587, 0.114, 0.0))); + return vec4(gray * uParam.xyz, color.w); + } + #endif + + #ifdef FILTER_BLUR + vec4 blur() { // uParam (dirX, dirY, unused, texelSize) + const vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); + const vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); + + vec2 dir = uParam.xy; + vec4 color = texture2D(sDiffuse, vTexCoord) * weight[0]; + color += texture2D(sDiffuse, vTexCoord + dir * offset[1]) * weight[1]; + color += texture2D(sDiffuse, vTexCoord - dir * offset[1]) * weight[1]; + color += texture2D(sDiffuse, vTexCoord + dir * offset[2]) * weight[2]; + color += texture2D(sDiffuse, vTexCoord - dir * offset[2]) * weight[2]; + return color; + } + #endif #ifdef FILTER_EQUIRECTANGULAR - uniform samplerCube sEnvironment; + uniform samplerCube sDiffuse; #define PI 3.14159265358979323846 vec4 equirectangular() { vec2 a = (vTexCoord - 0.5) * vec2(PI * 2.0, PI); vec3 v = vec3(sin(a.x) * cos(a.y), -sin(a.y), cos(a.x) * cos(a.y)); - return textureCube(sEnvironment, normalize(v)); + return textureCube(sDiffuse, normalize(v)); } #endif - vec4 upscale() { // https://www.shadertoy.com/view/XsfGDn - vec2 uv = vTexCoord * uParam.xy + 0.5; - vec2 iuv = floor(uv); - vec2 fuv = fract(uv); - uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv); - uv = (uv - 0.5) / uParam.xy; - return texture2D(sDiffuse, uv) * vColor; - } + #ifdef FILTER_UPSCALE + vec4 upscale() { // https://www.shadertoy.com/view/XsfGDn + vec2 uv = vTexCoord * uParam.xy + 0.5; + vec2 iuv = floor(uv); + vec2 fuv = fract(uv); + uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv); + uv = (uv - 0.5) / uParam.xy; + return texture2D(sDiffuse, uv) * vColor; + } + #endif + + #ifdef FILTER_ANAGLYPH + vec4 anaglyph() { + vec3 eyeL = texture2D(sDiffuse, vTexCoord).rgb; + vec3 eyeR = texture2D(sNormal, vTexCoord).rgb; + return vec4(eyeL.r, eyeR.g, eyeR.b, 1.0); + } + #endif - vec4 filter() { + vec4 process() { #ifdef FILTER_DOWNSAMPLE return downsample(); #endif + #ifdef FILTER_DOWNSAMPLE_DEPTH + return downsampleDepth(); + #endif + #ifdef FILTER_GRAYSCALE return grayscale(); #endif @@ -93,11 +122,19 @@ uniform vec4 uParam; return equirectangular(); #endif - return upscale(); + #ifdef FILTER_UPSCALE + return upscale(); + #endif + + #ifdef FILTER_ANAGLYPH + return anaglyph(); + #endif + + return vec4(1.0); } void main() { - gl_FragColor = filter(); + fragColor = process(); } #endif )====" \ No newline at end of file diff --git a/src/shaders/filter.hlsl b/src/shaders/filter.hlsl index e02b5907..fb7c3fb5 100644 --- a/src/shaders/filter.hlsl +++ b/src/shaders/filter.hlsl @@ -3,37 +3,42 @@ struct VS_OUTPUT { float4 pos : POSITION; float2 texCoord : TEXCOORD0; +#ifdef UPSCALE float4 diffuse : COLOR0; +#endif }; #ifdef VERTEX VS_OUTPUT main(VS_INPUT In) { VS_OUTPUT Out; - Out.pos = float4(In.aCoord.xy * (1.0 / 32767.0), 0.0, 1.0); - Out.texCoord = In.aTexCoord.xy * (1.0 / 32767.0); - Out.diffuse = RGBA(In.aLight); + Out.pos = mul(uViewProj, float4(In.aCoord.xy, 0.0, 1.0)); + Out.texCoord = In.aTexCoord.xy * INV_SHORT_HALF; + #ifdef UPSCALE + Out.diffuse = In.aLight; + #endif + + #ifdef _GAPI_D3D9 + #if defined(DOWNSAMPLE) + Out.texCoord += float2(2.0, -2.0) * uParam.x; // ??? + #elif defined(BLUR) || defined(GRAYSCALE) + Out.texCoord += float2(0.5, 0.5) * uParam.w; + #elif defined(UPSCALE) + Out.texCoord += float2(0.5, 0.5) / uParam.xy; + #endif + #endif - #ifndef _GAPI_GXM - // D3D9 specific - if (FILTER_DOWNSAMPLE) { - Out.texCoord += float2(2.0, -2.0) * uParam.x; - } else if (FILTER_BLUR) { - Out.texCoord += float2(1.0, -1.0) * uParam.z; - } - #endif - return Out; } #else // PIXEL -float4 downsample(float2 uv) { // uParam (1 / textureSize, unused, unused, unused) +float4 downsample(float2 uv) { // uParam (texelSize, unused, unused, unused) float4 color = 0.0; for (float y = -1.5; y < 2.0; y++) { for (float x = -1.5; x < 2.0; x++) { float4 p; - p.xyz = tex2Dlod(sDiffuse, float4(uv + float2(x, y) * uParam.x, 0, 0)).xyz; + p.xyz = SAMPLE_2D_LINEAR(sDiffuse, uv + float2(x, y) * uParam.x).xyz; p.w = dot(p.xyz, float3(0.299, 0.587, 0.114)); p.xyz *= p.w; color += p; @@ -43,45 +48,53 @@ float4 downsample(float2 uv) { // uParam (1 / textureSize, unused, unused, unuse return float4(color.xyz / color.w, 1.0); } -float4 grayscale(float2 uv) { // uParam (factor, unused, unused, unused) - float4 color = tex2D(sDiffuse, uv); +float4 grayscale(float2 uv) { // uParam (tint.rgb, texelSize) + float4 color = SAMPLE_2D_POINT(sDiffuse, uv); float3 gray = dot(color, float4(0.299, 0.587, 0.114, 0.0)); - return float4(lerp(color.xyz, gray, uParam.w) * uParam.xyz, color.w).bgra; + return float4(gray * uParam.xyz, color.w); } -float4 blur(float2 uv) { // uParam (dirX, dirY, 1 / textureSize, unused) +float4 blur(float2 uv) { // uParam (dirX, dirY, unused, texelSize) const float3 offset = float3( 0.0, 1.3846153846, 3.2307692308); const float3 weight = float3(0.2270270270, 0.3162162162, 0.0702702703); float2 dir = uParam.xy; - float4 color = tex2D(sDiffuse, uv) * weight[0]; - color += tex2D(sDiffuse, uv + dir * offset[1]) * weight[1]; - color += tex2D(sDiffuse, uv - dir * offset[1]) * weight[1]; - color += tex2D(sDiffuse, uv + dir * offset[2]) * weight[2]; - color += tex2D(sDiffuse, uv - dir * offset[2]) * weight[2]; + float4 color = SAMPLE_2D_LINEAR(sDiffuse, uv) * weight[0]; + color += SAMPLE_2D_LINEAR(sDiffuse, uv + dir * offset[1]) * weight[1]; + color += SAMPLE_2D_LINEAR(sDiffuse, uv - dir * offset[1]) * weight[1]; + color += SAMPLE_2D_LINEAR(sDiffuse, uv + dir * offset[2]) * weight[2]; + color += SAMPLE_2D_LINEAR(sDiffuse, uv - dir * offset[2]) * weight[2]; return color; } -float4 upscale(float2 uv) { - uv *= uParam.xy + 0.5; - float2 iuv = floor(uv); - float2 fuv = frac(uv); - uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv); - uv = (uv - 0.5) / uParam.xy; - return tex2D(sDiffuse, uv).bgra; +float4 upscale(float2 uv) { // uParam (textureWidth, textureHeight, unused, unused) + uv = uv * uParam.xy + 0.5; + float2 iuv = floor(uv); + float2 fuv = frac(uv); + uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv); + uv = (uv - 0.5) / uParam.xy; + return SAMPLE_2D_LINEAR(sDiffuse, uv); } -float4 main(VS_OUTPUT In) : COLOR0 { +float4 anaglyph(float2 uv) { + float3 eyeL = SAMPLE_2D_POINT(sDiffuse, float2(uv.x, 1.0 - uv.y)).rgb; + float3 eyeR = SAMPLE_2D_POINT(sNormal, float2(uv.x, 1.0 - uv.y)).rgb; + return float4(eyeL.r, eyeR.g, eyeR.b, 1.0); +} - if (FILTER_DOWNSAMPLE) +float4 main(VS_OUTPUT In) : COLOR0 { + #ifdef DOWNSAMPLE return downsample(In.texCoord.xy); - - if (FILTER_GRAYSCALE) + #elif GRAYSCALE return grayscale(In.texCoord.xy); - - if (FILTER_BLUR) + #elif BLUR return blur(In.texCoord.xy); - - return upscale(In.texCoord.xy) * In.diffuse; + #elif UPSCALE + return upscale(In.texCoord.xy) * In.diffuse; + #elif ANAGLYPH + return anaglyph(In.texCoord.xy); + #else + #error unsupported filter type + #endif } #endif \ No newline at end of file diff --git a/src/shaders/gui.asm b/src/shaders/gui.asm new file mode 100644 index 00000000..27ab378f --- /dev/null +++ b/src/shaders/gui.asm @@ -0,0 +1,14 @@ +#include "common.asm" + +#ifdef VERTEX + mulMat(vPosition, aCoord, uViewProj) + + mul vColor, aLight, c[uMaterial] + +; vTecCoord = (aTexCoord.xyz, 1) + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + tex t0 + mul r0, t0, vColor +#endif \ No newline at end of file diff --git a/src/shaders/gui.glsl b/src/shaders/gui.glsl index 99a59998..54ef3987 100644 --- a/src/shaders/gui.glsl +++ b/src/shaders/gui.glsl @@ -1,9 +1,4 @@ R"====( -#ifdef GL_ES - precision lowp int; - precision highp float; -#endif - varying vec2 vTexCoord; varying vec4 vColor; @@ -16,15 +11,15 @@ varying vec4 vColor; attribute vec4 aLight; void main() { - vTexCoord = aTexCoord.xy; - vColor = aLight * uMaterial; - gl_Position = uViewProj * vec4(aCoord.xyz, 1.0); + vTexCoord = aTexCoord.xy; + vColor = aLight * uMaterial; + gl_Position = uViewProj * aCoord; } #else - uniform sampler2D sDiffuse; + uniform sampler2D sDiffuse; void main() { - gl_FragColor = texture2D(sDiffuse, vTexCoord) * vColor; + fragColor = texture2D(sDiffuse, vTexCoord) * vColor; } #endif -)====" \ No newline at end of file +)====" diff --git a/src/shaders/gui.hlsl b/src/shaders/gui.hlsl index 95097584..8d331970 100644 --- a/src/shaders/gui.hlsl +++ b/src/shaders/gui.hlsl @@ -10,14 +10,14 @@ struct VS_OUTPUT { VS_OUTPUT main(VS_INPUT In) { VS_OUTPUT Out; Out.pos = mul(uViewProj, float4(In.aCoord.xy, 0.0, 1.0)); - Out.texCoord = In.aTexCoord.xy * (1.0 / 32767.0); - Out.diffuse = RGBA(In.aLight) * uMaterial; + Out.texCoord = In.aTexCoord.xy * INV_SHORT_HALF; + Out.diffuse = In.aLight * uMaterial; return Out; } #else // PIXEL float4 main(VS_OUTPUT In) : COLOR0 { - return In.diffuse * tex2D(sDiffuse, In.texCoord.xy).bgra; + return In.diffuse * SAMPLE_2D_LINEAR(sDiffuse, In.texCoord); } #endif \ No newline at end of file diff --git a/src/shaders/pica/ambient_room.v.pica b/src/shaders/pica/ambient_room.v.pica new file mode 100644 index 00000000..ed53a728 --- /dev/null +++ b/src/shaders/pica/ambient_room.v.pica @@ -0,0 +1,68 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; pos = mulQuatPos(uBasis, aCoord) + mul pos.xyz, uBasis[0], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[0].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[0].w, pos + mul tmp.xyz, uBasis[0].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[0].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[1], pos + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; vColor = aColor/255 * aLight/255 + mul tmp, INV_BYTE, aColor + mul att, INV_BYTE, aLight + mul vColor, tmp, att + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/ambient_sprite.v.pica b/src/shaders/pica/ambient_sprite.v.pica new file mode 100644 index 00000000..6340cb61 --- /dev/null +++ b/src/shaders/pica/ambient_sprite.v.pica @@ -0,0 +1,78 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewPos +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] +.fvec uMaterial +.alias MAT_AMBIENT uMaterial.y +.alias MAT_ALPHA uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 +.alias size r4 +.alias vv r6 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; pos = aCoord + mulQuatPos(uBasis, aTexCoord.zw) + mov pos.z, ZERO + mov pos.xy, aTexCoord.zw + mul size.xyz, uBasis[0], pos.zxy + mad size.xyz, pos.xyz, uBasis[0].zxy, -size + mad size.xyz, pos.yzx, uBasis[0].w, size + mul tmp.xyz, uBasis[0].zxy, size.xyz + mad size.xyz, size.yzx, uBasis[0].yzx, -tmp + mad pos.xyz, size, TWO, pos + add size.xyz, uBasis[1], aCoord + add pos.xyz, pos, size + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; vColor = premultAlpha(aLight / 255) + mul tmp, INV_BYTE, aLight + mul tmp.xyz, tmp, tmp.w + mov vColor, tmp + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_entity.v.pica b/src/shaders/pica/compose_entity.v.pica new file mode 100644 index 00000000..40e5aa35 --- /dev/null +++ b/src/shaders/pica/compose_entity.v.pica @@ -0,0 +1,130 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uLightPos[4] +.fvec uLightColor[4] +.fvec uMaterial +.fvec uBasis[32*2] + +.alias MAT_AMBIENT uMaterial.y +.alias MAT_ALPHA uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; joint = int(aCoord.w) + mova a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mul pos.xyz, uBasis[a0.x], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[a0.x].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[a0.x + 1], pos + mov pos.w, uBasis[a0.x + 1].w + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[0..3] = (uLightPos[0..3].xyz - pos) * uLightColor[0..3].w; + add lv0.xyz, uLightPos[0], -pos + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv0.xyz, uLightColor[0].w, lv0 + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[0..3] = dot(lv[0..3], lv[0..3]) + dp3 att.x, lv0, lv0 + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.x, att.x + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; normal = mulQuat(uBasis[joint], aNormal/127 - 1) + mul normal.xyz, INV_127, aNormal + add normal.xyz, -ONE, normal + mul pos.xyz, uBasis[a0.x], normal.zxyw + mad pos.xyz, normal, uBasis[a0.x].zxyw, -pos + mad pos.xyz, normal.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad normal.xyz, pos, TWO, normal + + ; light = max(0, dot(normal, lv[0..3])) + dp3 light.x, lv0, normal + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = aColor/255 * material.alpha * (material.ambient + light[0..3] * uLightColor[0..3]) + mul pos, INV_BYTE, aColor + mul pos, MAT_ALPHA, pos + mov tmp.xyz, MAT_AMBIENT + mov tmp.w, ONE + mad tmp.xyz, light.x, uLightColor[0], tmp + mad tmp.xyz, light.y, uLightColor[1], tmp + mad tmp.xyz, light.z, uLightColor[2], tmp + mad tmp.xyz, light.w, uLightColor[3], tmp + mul tmp, pos, tmp + mul vColor, HALF, tmp + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_entity_u.v.pica b/src/shaders/pica/compose_entity_u.v.pica new file mode 100644 index 00000000..33b22e40 --- /dev/null +++ b/src/shaders/pica/compose_entity_u.v.pica @@ -0,0 +1,190 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uLightPos[4] +.fvec uLightColor[4] +.fvec uMaterial +.fvec uBasis[32*2] + +.alias MAT_AMBIENT uMaterial.y +.alias MAT_ALPHA uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 +.alias diffuse r5 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + + +; underwater block -------------------------------------------------- +.constf const2(6.28318530718, 0.15915494309, 0.63661977236, 0.0) +.constf const3(1.0, 3.0, 0.0009765625, 0.75) +.constf const4(0.6, 0.9, 0.9, 1.0) + +.alias TWO_PI const2.x +.alias INV_TWO_PI const2.y +.alias INV_HALF_PI const2.z +.alias ONE_THREE const3.xy +.alias WAVE_SIZE const3.z +.alias WAVE_LUM const3.w +.alias UW_COLOR const4 + +.fvec uParam +.alias TIME uParam.x + +; tmp.x = abs(tmp.x) +.proc abs + max tmp.x, tmp.x, -tmp.x +.end + +; tmp.x = mod(tmp.x, TWO_PI) +.proc mod2pi + mul tmp.y, INV_TWO_PI, tmp.x + flr tmp.y, tmp.y + mul tmp.y, TWO_PI, tmp.y + add tmp.x, tmp.x, -tmp.y +.end + +; tmp.x = sin(tmp.x) +.proc sin + mul tmp.x, INV_HALF_PI, tmp.x + add tmp.xy, -ONE_THREE, tmp.xx + mad tmp.xy, tmp.xy, -tmp.xy, ONE_THREE.xx + max tmp.xy, ZERO, tmp.xy + add tmp.x, tmp.x, tmp.y +.end + +.proc applyUnderwater + ; k = dot(pos, 1/1024) + time + dp3 tmp.x, WAVE_SIZE, pos + add tmp.x, TIME, tmp.x + + call mod2pi + call sin + call abs + + mul tmp.x, WAVE_LUM, tmp.x + add tmp.x, HALF, tmp.x + mul tmp.xyz, UW_COLOR, tmp.xxx + mul diffuse.xyz, diffuse.xyz, tmp.xyz + mul vColor, HALF, diffuse +.end +; ------------------------------------------------------------------- + + +.proc main +; joint = int(aCoord.w) + mova a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mul pos.xyz, uBasis[a0.x], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[a0.x].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[a0.x + 1], pos + mov pos.w, uBasis[a0.x + 1].w + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[0..3] = (uLightPos[0..3].xyz - pos) * uLightColor[0..3].w; + add lv0.xyz, uLightPos[0], -pos + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv0.xyz, uLightColor[0].w, lv0 + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[0..3] = dot(lv[0..3], lv[0..3]) + dp3 att.x, lv0, lv0 + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.x, att.x + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; normal = mulQuat(uBasis[joint], aNormal/127 - 1) + mul normal.xyz, INV_127, aNormal + add normal.xyz, -ONE, normal + mul pos.xyz, uBasis[a0.x], normal.zxyw + mad pos.xyz, normal, uBasis[a0.x].zxyw, -pos + mad pos.xyz, normal.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad normal.xyz, pos, TWO, normal + + ; light = max(0, dot(normal, lv[0..3])) + dp3 light.x, lv0, normal + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = aColor/255 * material.alpha * (material.ambient + light[0..3] * uLightColor[0..3]) + mul diffuse, INV_BYTE, aColor + mul diffuse, MAT_ALPHA, diffuse + mov tmp.xyz, MAT_AMBIENT + mov tmp.w, ONE + mad tmp.xyz, light.x, uLightColor[0], tmp + mad tmp.xyz, light.y, uLightColor[1], tmp + mad tmp.xyz, light.z, uLightColor[2], tmp + mad tmp.xyz, light.w, uLightColor[3], tmp + mul diffuse, diffuse, tmp + +; vColor = applyUnderwater(diffuse, pos) + call applyUnderwater + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_flash.v.pica b/src/shaders/pica/compose_flash.v.pica new file mode 100644 index 00000000..b5ef7888 --- /dev/null +++ b/src/shaders/pica/compose_flash.v.pica @@ -0,0 +1,72 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.25) +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias QUART const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uMaterial +.alias MAT_DIFFUSE uMaterial.x +.alias MAT_EMISSIVE uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; pos = mulQuatPos(uBasis, aCoord) + mul pos.xyz, uBasis[0], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[0].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[0].w, pos + mul tmp.xyz, uBasis[0].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[0].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[1], pos + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; vColor = aColor/255 * material.diffuse + material.emissive * 0.5 + mul tmp, INV_BYTE, aColor + mul tmp, MAT_DIFFUSE, tmp + add tmp, tmp, tmp + add tmp, MAT_EMISSIVE, tmp + mov tmp.w, MAT_EMISSIVE + mul vColor, QUART, tmp + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_mirror.v.pica b/src/shaders/pica/compose_mirror.v.pica new file mode 100644 index 00000000..a9e9dc04 --- /dev/null +++ b/src/shaders/pica/compose_mirror.v.pica @@ -0,0 +1,96 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.25, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias QUART const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[32*2] +.fvec uMaterial +.fvec uViewPos + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias refl r5 +.alias view r6 +.alias pos r7 +.alias tmp r8 + +; out +.out vPosition position +;.out vTexCoord texcoord0 +.out vTexCoord texcoord0.st +.out - texcoord0w vTexCoord.p +.out vColor color + +.proc main +; joint = int(aCoord.w) + mova a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mul pos.xyz, uBasis[a0.x], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[a0.x].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[a0.x + 1], pos + mov pos.w, uBasis[a0.x + 1].w + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; view = normalize(uViewPos - pos) + add view, uViewPos, pos + dp3 tmp.x, view, view + rsq tmp.x, tmp.x + mul view, view, tmp.xxxx + +; normal = mulQuat(uBasis[joint], aNormal/127 - 1) + mul normal, INV_127, aNormal + add normal, -ONE, normal + mul pos.xyz, uBasis[a0.x], normal.zxyw + mad pos.xyz, normal, uBasis[a0.x].zxyw, -pos + mad pos.xyz, normal.yzxw, uBasis[a0.x].w, pos + mul tmp.xyz, uBasis[a0.x].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[a0.x].yzxw, -tmp + mad normal, pos, TWO, normal + +; refl = reflect(-view, normal) + dp3 tmp.x, -view, normal + add tmp.x, tmp.x, tmp.x + mad refl, -tmp.xxxx, normal, -view + +; vTexCoord = lerp(normal, refl, uMaterial.w) + add tmp, -normal, refl + mad vTexCoord, tmp, uMaterial.wwww, normal + +; vColor = uMaterial + mov tmp.xyz, uMaterial + mov tmp.w, ONE + mul vColor, QUART, tmp + + end +.end diff --git a/src/shaders/pica/compose_room.v.pica b/src/shaders/pica/compose_room.v.pica new file mode 100644 index 00000000..25f4547c --- /dev/null +++ b/src/shaders/pica/compose_room.v.pica @@ -0,0 +1,110 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; pos = mulQuatPos(uBasis, aCoord) + mul pos.xyz, uBasis[0], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[0].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[0].w, pos + mul tmp.xyz, uBasis[0].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[0].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[1], pos + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; normal = aNormal/127 - 1 + mul normal.xyz, INV_127, aNormal + add normal.xyz, -ONE, normal + + ; light = max(0, dot(normal, lv[1..3])) + mov light.x, ZERO + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = (aLight/255 + light[1..3] * uLightColor[1..3]) * aColor/255 + mul pos, INV_BYTE, aColor + mul tmp, INV_BYTE, aLight + mad tmp.xyz, light.y, uLightColor[1], tmp + mad tmp.xyz, light.z, uLightColor[2], tmp + mad tmp.xyz, light.w, uLightColor[3], tmp + mul tmp, pos, tmp + mul vColor, HALF, tmp + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_room_u.v.pica b/src/shaders/pica/compose_room_u.v.pica new file mode 100644 index 00000000..467789d5 --- /dev/null +++ b/src/shaders/pica/compose_room_u.v.pica @@ -0,0 +1,169 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.0009765625, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias INV_127 const1.w + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 +.alias diffuse r5 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + + +; underwater block -------------------------------------------------- +.constf const2(6.28318530718, 0.15915494309, 0.63661977236, 0.0) +.constf const3(1.0, 3.0, 0.0009765625, 0.75) +.constf const4(0.6, 0.9, 0.9, 1.0) + +.alias TWO_PI const2.x +.alias INV_TWO_PI const2.y +.alias INV_HALF_PI const2.z +.alias ONE_THREE const3.xy +.alias WAVE_SIZE const3.z +.alias WAVE_LUM const3.w +.alias UW_COLOR const4 + +.fvec uParam +.alias TIME uParam.x + +; tmp.x = abs(tmp.x) +.proc abs + max tmp.x, tmp.x, -tmp.x +.end + +; tmp.x = mod(tmp.x, TWO_PI) +.proc mod2pi + mul tmp.y, INV_TWO_PI, tmp.x + flr tmp.y, tmp.y + mul tmp.y, TWO_PI, tmp.y + add tmp.x, tmp.x, -tmp.y +.end + +; tmp.x = sin(tmp.x) +.proc sin + mul tmp.x, INV_HALF_PI, tmp.x + add tmp.xy, -ONE_THREE, tmp.xx + mad tmp.xy, tmp.xy, -tmp.xy, ONE_THREE.xx + max tmp.xy, ZERO, tmp.xy + add tmp.x, tmp.x, tmp.y +.end + +.proc applyUnderwater + ; k = dot(pos, 1/1024) + time + dp3 tmp.x, WAVE_SIZE, pos + add tmp.x, TIME, tmp.x + + call mod2pi + call sin + call abs + + mul tmp.x, WAVE_LUM, tmp.x + add tmp.x, HALF, tmp.x + mul tmp.xyz, UW_COLOR, tmp.xxx + mul diffuse.xyz, diffuse.xyz, tmp.xyz + mul vColor, HALF, diffuse +.end +; ------------------------------------------------------------------- + + +.proc main +; pos = mulQuatPos(uBasis, aCoord) + mul pos.xyz, uBasis[0], aCoord.zxyw + mad pos.xyz, aCoord, uBasis[0].zxyw, -pos + mad pos.xyz, aCoord.yzxw, uBasis[0].w, pos + mul tmp.xyz, uBasis[0].zxyw, pos + mad pos.xyz, pos.yzxw, uBasis[0].yzxw, -tmp + mad pos.xyz, pos, TWO, aCoord + add pos.xyz, uBasis[1], pos + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; normal = aNormal/127 - 1 + mul normal.xyz, INV_127, aNormal + add normal.xyz, -ONE, normal + + ; light = max(0, dot(normal, lv[1..3])) + mov light.x, ZERO + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; color = (aLight/255 + light[1..3] * uLightColor[1..3]) * aColor/255 + mul tmp, INV_BYTE, aLight + mad tmp.xyz, light.y, uLightColor[1], tmp + mad tmp.xyz, light.z, uLightColor[2], tmp + mad tmp.xyz, light.w, uLightColor[3], tmp + mul diffuse, INV_BYTE, aColor + mul diffuse, diffuse, tmp + +; vColor = applyUnderwater(diffuse, pos) + call applyUnderwater + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_sprite.v.pica b/src/shaders/pica/compose_sprite.v.pica new file mode 100644 index 00000000..1d46fb32 --- /dev/null +++ b/src/shaders/pica/compose_sprite.v.pica @@ -0,0 +1,124 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewPos +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] +.fvec uMaterial +.alias MAT_AMBIENT uMaterial.y +.alias MAT_ALPHA uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 +.alias size r4 +.alias vv r6 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; pos = aCoord + mulQuatPos(uBasis, aTexCoord.zw) + mov pos.z, ZERO + mov pos.xy, aTexCoord.zw + mul size.xyz, uBasis[0], pos.zxy + mad size.xyz, pos.xyz, uBasis[0].zxy, -size + mad size.xyz, pos.yzx, uBasis[0].w, size + mul tmp.xyz, uBasis[0].zxy, size.xyz + mad size.xyz, size.yzx, uBasis[0].yzx, -tmp + mad pos.xyz, size, TWO, pos + add size.xyz, uBasis[1], aCoord + add pos.xyz, pos, size + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; viewVec = uViewPos - pos + add vv.xyz, uViewPos, -pos + + ; normal = normalize(viewVec) + dp3 tmp.x, vv, vv + rsq tmp.x, tmp.x + mul normal, vv, tmp.x + + ; light = max(0, dot(normal, lv[1..3])) + mov light.x, MAT_AMBIENT + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = vec4(aLight.rgb * aLight.a, aLight.a) + mul tmp, INV_BYTE, aLight + mad tmp.xyz, light.x, uLightColor[0], tmp + mad tmp.xyz, light.y, uLightColor[1], tmp + mad tmp.xyz, light.z, uLightColor[2], tmp + mad tmp.xyz, light.w, uLightColor[3], tmp + mul tmp.xyz, tmp, tmp.w + mul vColor, HALF, tmp + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/compose_sprite_u.v.pica b/src/shaders/pica/compose_sprite_u.v.pica new file mode 100644 index 00000000..13d1d88b --- /dev/null +++ b/src/shaders/pica/compose_sprite_u.v.pica @@ -0,0 +1,184 @@ +; constants +.constf const0(0.0, 0.5, 1.0, 2.0) +.constf const1(0.00392156886, 3.05185094e-005, 0.00001, 0.00787401574) + +.alias ZERO const0.x +.alias HALF const0.y +.alias ONE const0.z +.alias TWO const0.w +.alias INV_BYTE const1.x +.alias INV_SHORT const1.y +.alias EPS const1.z +.alias INV_127 const1.w + +; uniforms +.fvec uViewPos +.fvec uViewProj[4] +.fvec uBasis[2] +.fvec uLightPos[4] +.fvec uLightColor[4] +.fvec uMaterial +.alias MAT_AMBIENT uMaterial.y +.alias MAT_ALPHA uMaterial.w + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; variables +.alias lv0 r0 +.alias lv1 r1 +.alias lv2 r2 +.alias lv3 r3 +.alias normal r4 +.alias att r5 +.alias light r6 +.alias pos r7 +.alias tmp r8 +.alias size r4 +.alias vv r6 +.alias diffuse r5 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + + +; underwater block -------------------------------------------------- +.constf const2(6.28318530718, 0.15915494309, 0.63661977236, 0.0) +.constf const3(1.0, 3.0, 0.0009765625, 0.75) +.constf const4(0.6, 0.9, 0.9, 1.0) + +.alias TWO_PI const2.x +.alias INV_TWO_PI const2.y +.alias INV_HALF_PI const2.z +.alias ONE_THREE const3.xy +.alias WAVE_SIZE const3.z +.alias WAVE_LUM const3.w +.alias UW_COLOR const4 + +.fvec uParam +.alias TIME uParam.x + +; tmp.x = abs(tmp.x) +.proc abs + max tmp.x, tmp.x, -tmp.x +.end + +; tmp.x = mod(tmp.x, TWO_PI) +.proc mod2pi + mul tmp.y, INV_TWO_PI, tmp.x + flr tmp.y, tmp.y + mul tmp.y, TWO_PI, tmp.y + add tmp.x, tmp.x, -tmp.y +.end + +; tmp.x = sin(tmp.x) +.proc sin + mul tmp.x, INV_HALF_PI, tmp.x + add tmp.xy, -ONE_THREE, tmp.xx + mad tmp.xy, tmp.xy, -tmp.xy, ONE_THREE.xx + max tmp.xy, ZERO, tmp.xy + add tmp.x, tmp.x, tmp.y +.end + +.proc applyUnderwater + ; k = dot(pos, 1/1024) + time + dp3 tmp.x, WAVE_SIZE, pos + add tmp.x, TIME, tmp.x + + call mod2pi + call sin + call abs + + mul tmp.x, WAVE_LUM, tmp.x + add tmp.x, HALF, tmp.x + mul tmp.xyz, UW_COLOR, tmp.xxx + mul diffuse.xyz, diffuse.xyz, tmp.xyz + mul vColor, HALF, diffuse +.end +; ------------------------------------------------------------------- + + +.proc main +; pos = aCoord + mulQuatPos(uBasis, aTexCoord.zw) + mov pos.z, ZERO + mov pos.xy, aTexCoord.zw + mul size.xyz, uBasis[0], pos.zxy + mad size.xyz, pos.xyz, uBasis[0].zxy, -size + mad size.xyz, pos.yzx, uBasis[0].w, size + mul tmp.xyz, uBasis[0].zxy, size.xyz + mad size.xyz, size.yzx, uBasis[0].yzx, -tmp + mad pos.xyz, size, TWO, pos + add size.xyz, uBasis[1], aCoord + add pos.xyz, pos, size + mov pos.w, ONE + +; vPosition = uViewProj * pos + mul tmp, uViewProj[0], pos.x + mad tmp, pos.y, uViewProj[1], tmp + mad tmp, pos.z, uViewProj[2], tmp + mad vPosition, pos.w, uViewProj[3], tmp + +; lighting + ; lv[1..3] = (uLightPos[1..3].xyz - pos) * uLightColor[1..3].w; + add lv1.xyz, uLightPos[1], -pos + add lv2.xyz, uLightPos[2], -pos + add lv3.xyz, uLightPos[3], -pos + mul lv1.xyz, uLightColor[1].w, lv1 + mul lv2.xyz, uLightColor[2].w, lv2 + mul lv3.xyz, uLightColor[3].w, lv3 + + ; att[1..3] = dot(lv[1..3], lv[1..3]) + mov att.x, ONE + dp3 att.y, lv1, lv1 + dp3 att.z, lv2, lv2 + dp3 att.w, lv3, lv3 + + ; att = max(0, 1 - att) / sqrt(att) + rsq tmp.y, att.y + rsq tmp.z, att.z + rsq tmp.w, att.w + + add att, ONE, -att + max att, ZERO, att + mul att, tmp, att + + ; viewVec = uViewPos - pos + add vv.xyz, uViewPos, -pos + + ; normal = normalize(viewVec) + dp3 tmp.x, vv, vv + rsq tmp.x, tmp.x + mul normal, vv, tmp.x + + ; light = max(0, dot(normal, lv[1..3])) + mov light.x, MAT_AMBIENT + dp3 light.y, lv1, normal + dp3 light.z, lv2, normal + dp3 light.w, lv3, normal + + ; light = max(0, light) * att + max light, ZERO, light + mul light, light, att + +; vColor = vec4(aLight.rgb * aLight.a, aLight.a) + mul diffuse, INV_BYTE, aLight + mad diffuse.xyz, light.x, uLightColor[0], diffuse + mad diffuse.xyz, light.y, uLightColor[1], diffuse + mad diffuse.xyz, light.z, uLightColor[2], diffuse + mad diffuse.xyz, light.w, uLightColor[3], diffuse + mul diffuse.xyz, diffuse, diffuse.w + +; vColor = applyUnderwater(diffuse, pos) + call applyUnderwater + +; vTecCoord = aTexCoord/32767 + mul vTexCoord, INV_SHORT, aTexCoord + + end +.end diff --git a/src/shaders/pica/dummy.v.pica b/src/shaders/pica/dummy.v.pica new file mode 100644 index 00000000..7e2f80be --- /dev/null +++ b/src/shaders/pica/dummy.v.pica @@ -0,0 +1,14 @@ +; constants +.constf const0(0.0, 0.0, 0.0, 1.0) + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main + mov vPosition, const0 + mov vTexCoord, const0 + mov vColor, const0 + end +.end diff --git a/src/shaders/pica/filter_upscale.v.pica b/src/shaders/pica/filter_upscale.v.pica new file mode 100644 index 00000000..d4b72307 --- /dev/null +++ b/src/shaders/pica/filter_upscale.v.pica @@ -0,0 +1,29 @@ +; constants +.constf const0(3.05185094e-005, 0.00392156886, 0.0, 0.0) + +; uniforms +.fvec uViewProj[4] + +; in +.alias aCoord v0 +.alias aTexCoord v2 +.alias aLight v4 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; uViewProj * coord + mov r0, uViewProj[3] + mad r0, aCoord.xxxx, uViewProj[0], r0 + mad r0, aCoord.yyyy, uViewProj[1], r0 + mad vPosition, aCoord.zzzz, uViewProj[2], r0 + + mul vTexCoord, const0.xxxx, aTexCoord + + mul vColor, const0.yyyy, aLight + + end +.end diff --git a/src/shaders/pica/gui.v.pica b/src/shaders/pica/gui.v.pica new file mode 100644 index 00000000..08c1471c --- /dev/null +++ b/src/shaders/pica/gui.v.pica @@ -0,0 +1,31 @@ +; constants +.constf const0(3.05185094e-005, 0.00392156886, 1.0, 0.0) + +; uniforms +.fvec uViewProj[4] +.fvec uMaterial + +; in +.alias aCoord v0 +.alias aTexCoord v2 +.alias aLight v4 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; uViewProj * coord + mov r0, uViewProj[3] + mad r0, aCoord.xxxx, uViewProj[0], r0 + mad r0, aCoord.yyyy, uViewProj[1], r0 + mad vPosition, aCoord.zzzz, uViewProj[2], r0 + + mul vTexCoord, const0.xxxx, aTexCoord + + mul r1, const0.yyyy, aLight + mul vColor, uMaterial, r1 + + end +.end diff --git a/src/shaders/pica/shadow_entity.v.pica b/src/shaders/pica/shadow_entity.v.pica new file mode 100644 index 00000000..a4a157ca --- /dev/null +++ b/src/shaders/pica/shadow_entity.v.pica @@ -0,0 +1,48 @@ +; constants +.constf const0(2.0, 1.0, 0.5, 0.25) +.constf const1(3.05185094e-005, 0.00392156886, 0.00784313725, 0.0) + +; uniforms +.fvec uViewProj[4] +.fvec uBasis[32*2] + +; in +.alias aCoord v0 +.alias aNormal v1 +.alias aTexCoord v2 +.alias aColor v3 +.alias aLight v4 + +; out +.out vPosition position +.out vTexCoord texcoord0 +.out vColor color + +.proc main +; mulQuat + mul r0.x, const0.xxxx, aCoord.wwww + + mova a0.x, r0.x + mul r0.xyz, uBasis[a0.x], aCoord.zxyw + mad r0.xyz, aCoord, uBasis[a0.x].zxyw, -r0 + mad r0.xyz, aCoord.yzxw, uBasis[a0.x].w, r0 + mul r1.xyz, uBasis[a0.x].zxyw, r0 + mad r0.xyz, r0.yzxw, uBasis[a0.x].yzxw, -r1 + mad r0.xyz, r0, const0.x, aCoord + add r0.xyz, uBasis[a0.x + 1], r0 + mov r0.w, uBasis[a0.x + 1].w + +; uViewProj * coord + mul r1, uViewProj[0], r0.xxxx + mad r1, r0.yyyy, uViewProj[1], r1 + mad r1, r0.zzzz, uViewProj[2], r1 + mad vPosition, r0.wwww, uViewProj[3], r1 + + mul vTexCoord, const1.xxxx, aTexCoord.xyzw + + mul r3, const1.yyyy, aColor + mul r4, const1.yyyy, aLight + mul vColor, r3, r4 + + end +.end diff --git a/src/shaders/shader.glsl b/src/shaders/shader.glsl deleted file mode 100644 index 36a4c92a..00000000 --- a/src/shaders/shader.glsl +++ /dev/null @@ -1,519 +0,0 @@ -R"====( -#ifdef GL_ES - precision lowp int; - precision highp float; -#endif - -#define MAX_LIGHTS 4 -#define MAX_CONTACTS 15 -#define WATER_FOG_DIST (1.0 / (6.0 * 1024.0)) -#define WATER_COLOR_DIST (1.0 / (2.0 * 1024.0)) -#define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9) - -#define SHADOW_NORMAL_BIAS 16.0 -#define SHADOW_CONST_BIAS 0.05 - -#if (defined(PASS_AMBIENT) || defined(PASS_COMPOSE)) && !defined(TYPE_FLASH) - varying vec3 vCoord; -#endif - -varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction - -#ifdef OPT_VLIGHTVEC - varying vec3 vLightVec; -#endif - -#ifdef OPT_CAUSTICS - uniform vec4 uRoomSize; // xy - minXZ, zw - maxXZ -#endif - -#ifdef OPT_SHADOW - #define SHADOW_TEXEL vec3(1.0 / 1024.0, 1.0 / 1024.0, 0.0) - uniform mat4 uLightProj; - - #ifdef OPT_VLIGHTPROJ - varying vec4 vLightProj; - #endif -#endif - -uniform mat4 uViewProj; -uniform vec4 uViewPos; - -uniform vec4 uParam; // x - time, y - water height, z - clip plane sign, w - clip plane height -uniform vec4 uLightPos[MAX_LIGHTS]; -uniform vec4 uLightColor[MAX_LIGHTS]; // xyz - color, w - radius * intensity -uniform vec4 uMaterial; // x - diffuse, y - ambient, z - specular, w - alpha -uniform vec4 uFogParams; - -#ifndef PASS_SHADOW - varying vec4 vViewVec; // xyz - dir * dist, w - coord.y * clipPlaneSign - varying vec4 vDiffuse; - varying vec4 vNormal; // xyz - normal dir, w - fog factor - - #ifndef TYPE_FLASH - #ifdef PASS_COMPOSE - #ifdef OPT_SHADOW - varying vec3 vAmbient; - varying vec3 vLightMap; - #endif - #endif - - varying vec4 vLight; // lights intensity (MAX_LIGHTS == 4) - #endif -#endif - -#ifdef OPT_SHADOW - vec4 calcLightProj(vec3 coord, vec3 lightVec, vec3 normal) { - float factor = clamp(1.0 - dot(normalize(lightVec), normal), 0.0, 1.0); - factor *= SHADOW_NORMAL_BIAS; - return uLightProj * vec4(coord + normal * factor, 1.0); - } -#endif - -#ifdef VERTEX - - #if defined(TYPE_ENTITY) || defined(TYPE_MIRROR) - uniform vec4 uBasis[32 * 2]; - #else - uniform vec4 uBasis[2]; - #endif - - #ifdef OPT_AMBIENT - uniform vec4 uAmbient[6]; - - vec3 calcAmbient(vec3 n) { - vec3 sqr = n * n; - vec3 pos = step(0.0, n); - return sqr.x * mix(uAmbient[1].xyz, uAmbient[0].xyz, pos.x) + - sqr.y * mix(uAmbient[3].xyz, uAmbient[2].xyz, pos.y) + - sqr.z * mix(uAmbient[5].xyz, uAmbient[4].xyz, pos.z); - } - #endif - - attribute vec4 aCoord; - attribute vec4 aTexCoord; - attribute vec4 aNormal; - - #ifndef PASS_SHADOW - attribute vec4 aColor; - attribute vec4 aLight; - #endif - - vec3 mulQuat(vec4 q, vec3 v) { - return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + v * q.w); - } - - vec3 mulBasis(vec4 rot, vec3 pos, vec3 v) { - return mulQuat(rot, v) + pos; - } - - vec4 _transform() { - #if defined(TYPE_ENTITY) || defined(TYPE_MIRROR) - int index = int(aCoord.w * 2.0); - vec4 rBasisRot = uBasis[index]; - vec4 rBasisPos = uBasis[index + 1]; - #else - vec4 rBasisRot = uBasis[0]; - vec4 rBasisPos = uBasis[1]; - #endif - - vec4 coord; - coord.w = rBasisPos.w; // visible flag - #if defined(TYPE_SPRITE) - coord.xyz = mulBasis(rBasisRot, rBasisPos.xyz + aCoord.xyz, vec3(aTexCoord.z, aTexCoord.w, 0.0) * 32767.0); - #else - coord.xyz = mulBasis(rBasisRot, rBasisPos.xyz, aCoord.xyz); - #endif - - #ifndef PASS_SHADOW - vViewVec = vec4((uViewPos.xyz - coord.xyz) * uFogParams.w, coord.y * uParam.z); - #endif - - #ifdef PASS_AMBIENT - vNormal = aNormal; - #endif - - #if defined(PASS_COMPOSE) && !defined(TYPE_FLASH) - #ifdef TYPE_SPRITE - vNormal.xyz = normalize(vViewVec.xyz); - #else - vNormal.xyz = normalize(mulQuat(rBasisRot, aNormal.xyz)); - #endif - - float fog; - #if defined(UNDERWATER) && defined(OPT_UNDERWATER_FOG) - float d; - if (uViewPos.y < uParam.y) // TODO: fix for mediump - d = abs((coord.y - uParam.y) / normalize(uViewPos.xyz - coord.xyz).y); - else - d = length(uViewPos.xyz - coord.xyz); - fog = d * WATER_FOG_DIST; - fog *= step(uParam.y, coord.y); - vNormal.w = fog; - #else - fog = length(vViewVec.xyz); - vNormal.w = clamp(1.0 / exp(fog), 0.0, 1.0); - #endif - - vCoord = coord.xyz; - #endif - return coord; - } - - void _diffuse() { - #ifndef PASS_SHADOW - vDiffuse = vec4(aColor.xyz * (uMaterial.x * 1.8), 1.0); - - #ifdef TYPE_MIRROR - vDiffuse.xyz = uMaterial.xyz; - #endif - - #ifdef TYPE_FLASH - vDiffuse.xyz += uMaterial.w; - #else - vDiffuse *= uMaterial.w; - #endif - - #ifdef TYPE_SPRITE - vDiffuse *= aLight.w; - #endif - #endif - } - - void _lighting(vec3 coord) { - #ifndef TYPE_FLASH - #ifdef PASS_COMPOSE - vec3 lv0 = (uLightPos[0].xyz - coord) * uLightColor[0].w; - vec3 lv1 = (uLightPos[1].xyz - coord) * uLightColor[1].w; - vec3 lv2 = (uLightPos[2].xyz - coord) * uLightColor[2].w; - vec3 lv3 = (uLightPos[3].xyz - coord) * uLightColor[3].w; - - #ifdef OPT_VLIGHTVEC - vLightVec = lv0; - #endif - - vec4 lum, att; - #ifdef TYPE_ENTITY - lum.x = dot(vNormal.xyz, normalize(lv0)); - att.x = dot(lv0, lv0); - #else - lum.x = 1.0; - att.x = 0.0; - - #ifdef TYPE_SPRITE - lum.x *= uMaterial.y; - #endif - - #endif - - lum.y = dot(vNormal.xyz, normalize(lv1)); att.y = dot(lv1, lv1); - lum.z = dot(vNormal.xyz, normalize(lv2)); att.z = dot(lv2, lv2); - lum.w = dot(vNormal.xyz, normalize(lv3)); att.w = dot(lv3, lv3); - vec4 light = max(vec4(0.0), lum) * max(vec4(0.0), vec4(1.0) - att); - - #ifdef UNDERWATER - light.x *= 0.5 + abs(sin(dot(coord.xyz, vec3(1.0 / 1024.0)) + uParam.x)) * 0.75; - #endif - - vec3 ambient; - #ifdef TYPE_ENTITY - #ifdef OPT_AMBIENT - ambient = calcAmbient(vNormal.xyz); - #else - ambient = vec3(uMaterial.y); - #endif - #else - ambient = min(uMaterial.yyy, aLight.xyz); - #endif - - #ifdef OPT_SHADOW - vAmbient = ambient; - vLight = light; - vLightMap = aLight.xyz * light.x; - - #ifdef OPT_VLIGHTPROJ - vLightProj = calcLightProj(coord, lv0, vNormal.xyz); - #endif - - #else - vLight.xyz = uLightColor[1].xyz * light.y + uLightColor[2].xyz * light.z + uLightColor[3].xyz * light.w; - vLight.w = 0.0; - - #ifdef TYPE_ENTITY - vLight.xyz += ambient + uLightColor[0].xyz * light.x; - #else - vLight.xyz += aLight.xyz * light.x; - #endif - #endif - - #endif - - #ifdef PASS_AMBIENT - vLight = vec4(aLight.xyz, 1.0); - #endif - #endif - } - - void _uv(vec3 coord) { - vTexCoord = aTexCoord; - #if defined(PASS_COMPOSE) && !defined(TYPE_SPRITE) - #ifdef OPT_TRAPEZOID - vTexCoord.xy *= vTexCoord.zw; - #endif - #endif - } - - void main() { - vec4 coord = _transform(); - - #ifndef PASS_SHADOW - _diffuse(); - _lighting(coord.xyz); - #endif - - _uv(coord.xyz); - - gl_Position = uViewProj * coord; - } -#else - uniform sampler2D sDiffuse; - - #if defined(PASS_COMPOSE) && defined(TYPE_MIRROR) - uniform samplerCube sEnvironment; - #endif - - vec4 pack(float value) { - vec4 v = fract(value * vec4(1.0, 255.0, 65025.0, 16581375.0)); - return v - v.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0); - } - - float unpack(vec4 value) { - return dot(value, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0)); - } - - #ifdef OPT_SHADOW - #ifdef SHADOW_SAMPLER - uniform sampler2DShadow sShadow; - #ifdef GL_ES - #define SHADOW(V) (shadow2DEXT(sShadow, V)) - #else - #define SHADOW(V) (shadow2D(sShadow, V).x) - #endif - #else - uniform sampler2D sShadow; - - float SHADOW(vec2 p) { - #ifdef SHADOW_DEPTH - return texture2D(sShadow, p).x; - #else - return unpack(texture2D(sShadow, p)); - #endif - } - #endif - - float getShadow(vec3 lightVec, vec3 normal, vec4 lightProj) { - vec3 p = lightProj.xyz / lightProj.w; - p.z -= SHADOW_CONST_BIAS * SHADOW_TEXEL.x; - - float vis = lightProj.w; - #ifdef TYPE_ROOM - vis = min(vis, dot(normal, lightVec)); - #endif - if (min(vis, min(p.x, p.y)) < 0.0 || max(p.x, p.y) > 1.0) return 1.0; - - #ifdef SHADOW_SAMPLER - float rShadow = SHADOW(p); - #else - #ifndef OPT_SHADOW_ONETAP - vec4 samples = vec4(SHADOW( p.xy), - SHADOW(SHADOW_TEXEL.xz + p.xy), - SHADOW(SHADOW_TEXEL.zy + p.xy), - SHADOW(SHADOW_TEXEL.xy + p.xy)); - - samples = step(vec4(p.z), samples); - - vec2 f = fract(p.xy / SHADOW_TEXEL.xy); - samples.xy = mix(samples.xz, samples.yw, f.x); - float rShadow = mix(samples.x, samples.y, f.y); - #else - float rShadow = step(p.z, SHADOW(p.xy)); - #endif - #endif - - float fade = clamp(dot(lightVec, lightVec), 0.0, 1.0); - return rShadow + (1.0 - rShadow) * fade; - } - - float getShadow(vec3 lightVec, vec3 normal) { - #ifndef OPT_VLIGHTPROJ - vec4 vLightProj = calcLightProj(vCoord, lightVec, normal); - #endif - return getShadow(lightVec, normal, vLightProj); - } - #endif - - #ifdef OPT_CAUSTICS - uniform sampler2D sReflect; - - float calcCaustics(vec3 n) { - vec2 cc = clamp((vCoord.xz - uRoomSize.xy) / uRoomSize.zw, vec2(0.0), vec2(1.0)); - return texture2D(sReflect, cc).x * max(0.0, -n.y); - } - #endif - - #ifdef OPT_CONTACT - uniform vec4 uContacts[MAX_CONTACTS]; - - float getContactAO(vec3 p, vec3 n) { - float res = 1.0; - for (int i = 0; i < MAX_CONTACTS; i++) { - vec3 v = uContacts[i].xyz - p; - float a = uContacts[i].w; - float o = a * clamp(dot(n, v), 0.0, 1.0) / dot(v, v); - res *= clamp(1.0 - o, 0.0, 1.0); - } - return res; - } - #endif - - float calcSpecular(vec3 normal, vec3 viewVec, vec3 lightVec, vec4 color, float intensity) { - vec3 vv = normalize(viewVec); - vec3 rv = reflect(-vv, normal); - vec3 lv = normalize(lightVec); - return pow(max(0.0, dot(rv, lv)), 8.0) * intensity; - } - - void main() { - #ifdef CLIP_PLANE - if (vViewVec.w > uParam.w) - discard; - #endif - - vec2 uv = vTexCoord.xy; - vec4 color; - #ifdef TYPE_MIRROR - #ifdef PASS_COMPOSE - vec3 rv = reflect(-normalize(vViewVec.xyz), normalize(vNormal.xyz)); - color = textureCube(sEnvironment, normalize(rv)); - #else - color = vec4(1.0); - #endif - #else - #if defined(PASS_COMPOSE) && !defined(TYPE_SPRITE) - #ifdef OPT_TRAPEZOID - uv /= vTexCoord.zw; - #endif - #endif - color = texture2D(sDiffuse, uv); - #endif - - #ifdef ALPHA_TEST -//color = vec4(1, 0, 0, 1); - if (color.w <= 0.5) - discard; - #endif - - #ifdef PASS_SHADOW - - #ifdef SHADOW_COLOR - gl_FragColor = pack(gl_FragCoord.z); - #else - gl_FragColor = vec4(1.0); - #endif - - #else - color *= vDiffuse; - - #if !defined(TYPE_FLASH) && !defined(TYPE_MIRROR) - - #ifdef PASS_AMBIENT - color.xyz *= vLight.xyz; - #endif - - #ifdef PASS_COMPOSE - - #ifndef OPT_VLIGHTVEC - vec3 vLightVec = (uLightPos[0].xyz - vCoord) * uLightColor[0].w; - #endif - - vec3 normal = normalize(vNormal.xyz); - - #ifdef TYPE_ENTITY - float rSpecular = uMaterial.z; - #endif - - #ifdef OPT_SHADOW - vec3 light = uLightColor[1].xyz * vLight.y + uLightColor[2].xyz * vLight.z + uLightColor[3].xyz * vLight.w; - - #if defined(TYPE_ENTITY) || defined(TYPE_ROOM) - float rShadow = getShadow(vLightVec, normal); - #endif - - #ifdef TYPE_ENTITY - rSpecular *= rShadow; - light += vAmbient + uLightColor[0].xyz * (vLight.x * rShadow); - #endif - - #ifdef TYPE_ROOM - light += mix(vAmbient, vLightMap, rShadow); - #endif - - #ifdef TYPE_SPRITE - light += vLightMap; - #endif - - #else - vec3 light = vLight.xyz; - #endif - - #ifdef UNDERWATER - float uwSign = 1.0; - #ifdef TYPE_ENTITY - uwSign = step(uParam.y, vCoord.y); - #endif - - #ifdef OPT_CAUSTICS - light += calcCaustics(normal) * uwSign; - #endif - #endif - - #ifdef OPT_CONTACT - light *= getContactAO(vCoord, normal) * 0.5 + 0.5; - #endif - - color.xyz *= light; - - #if defined(TYPE_ENTITY) && defined(OPT_UNDERWATER_FOG) - float specular = calcSpecular(normal, vViewVec.xyz, vLightVec, uLightColor[0], rSpecular); - #ifdef UNDERWATER - specular *= (1.0 - uwSign); - #endif - color.xyz += specular; - #endif - - #ifdef UNDERWATER - #ifdef OPT_UNDERWATER_FOG - float dist; - if (uViewPos.y < uParam.y) - dist = abs((vCoord.y - uParam.y) / normalize(uViewPos.xyz - vCoord.xyz).y); - else - dist = length(uViewPos.xyz - vCoord.xyz); - float fog = clamp(1.0 / exp(dist * WATER_FOG_DIST * uwSign), 0.0, 1.0); - dist += vCoord.y - uParam.y; - color.xyz *= mix(vec3(1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST * uwSign, 0.0, 2.0)); - color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog); - #else - color.xyz = mix(color.xyz, color.xyz * UNDERWATER_COLOR, uwSign); - color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w); - #endif - #else - color.xyz = mix(uFogParams.xyz, color.xyz, vNormal.w); - #endif - #endif - #endif - - gl_FragColor = color; - #endif - } -#endif -)====" diff --git a/src/shaders/shadow.glsl b/src/shaders/shadow.glsl new file mode 100644 index 00000000..09c30ff5 --- /dev/null +++ b/src/shaders/shadow.glsl @@ -0,0 +1,65 @@ +R"====( +#ifdef ALPHA_TEST + varying vec2 vTexCoord; +#endif + +#ifdef VERTEX + + uniform mat4 uViewProj; + uniform vec4 uBasis[32 * 2]; + + attribute vec4 aCoord; + #ifdef ALPHA_TEST + attribute vec4 aTexCoord; + #endif + + vec3 mulQuat(vec4 q, vec3 v) { + return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + v * q.w); + } + + vec3 mulBasis(vec4 rot, vec3 pos, vec3 v) { + return mulQuat(rot, v) + pos; + } + + void main() { + #ifdef MESH_SKINNING + int index = int(aCoord.w); + vec4 rBasisRot = uBasis[index]; + vec4 rBasisPos = uBasis[index + 1]; + #else + vec4 rBasisRot = uBasis[0]; + vec4 rBasisPos = uBasis[1]; + #endif + #ifdef ALPHA_TEST + vTexCoord = aTexCoord.xy; + #endif + vec3 coord = mulBasis(rBasisRot, rBasisPos.xyz, aCoord.xyz); + gl_Position = uViewProj * vec4(coord, rBasisPos.w); + } + +#else + + #ifdef ALPHA_TEST + uniform sampler2D sDiffuse; + #endif + + vec4 pack(float value) { + vec4 v = fract(value * vec4(1.0, 255.0, 65025.0, 16581375.0)); + return v - v.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0); + } + + void main() { + #ifdef ALPHA_TEST + if (texture2D(sDiffuse, vTexCoord).w <= 0.5) + discard; + #endif + + #ifdef SHADOW_COLOR + fragColor = pack(gl_FragCoord.z); + #else + fragColor = vec4(1.0); + #endif + } + +#endif +)====" diff --git a/src/shaders/shadow.hlsl b/src/shaders/shadow.hlsl deleted file mode 100644 index 093638a2..00000000 --- a/src/shaders/shadow.hlsl +++ /dev/null @@ -1,41 +0,0 @@ -#include "common.hlsl" - -struct VS_OUTPUT { - float4 pos : POSITION; - float4 texCoord : TEXCOORD0; - float4 hpos : TEXCOORD1; -}; - -#ifdef VERTEX -VS_OUTPUT main(VS_INPUT In) { - VS_OUTPUT Out; - - int index = int(In.aCoord.w * 2.0); - float4 rBasisRot = uBasis[index]; - float4 rBasisPos = uBasis[index + 1]; - - float3 coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz); - Out.texCoord = In.aTexCoord * (1.0 / 32767.0); - Out.pos = mul(uViewProj, float4(coord, rBasisPos.w)); - Out.hpos = Out.pos; - return Out; -} - -#else // PIXEL - -float4 main(VS_OUTPUT In) : COLOR0 { - if (ALPHA_TEST) { - if (tex2D(sDiffuse, In.texCoord.xy).a <= 0.5) - discard; - } -#ifdef _GAPI_GXM - return 0.0; -#else - #ifdef SHADOW_DEPTH - return 0.0; - #else // SHADOW_COLOR - return pack(In.hpos.z / In.hpos.w); - #endif -#endif -} -#endif \ No newline at end of file diff --git a/src/shaders/shadow_entity.asm b/src/shaders/shadow_entity.asm new file mode 100644 index 00000000..d22c84ad --- /dev/null +++ b/src/shaders/shadow_entity.asm @@ -0,0 +1,22 @@ +#include "common.asm" + +#ifdef VERTEX +; variables + #define pos r7 + +; joint = int(aCoord.w) + mov a0.x, aCoord.w + +; pos = mulQuatPos(uBasis[joint], aCoord) + mulQuatPos(pos, aCoord, a0.x) + +; vPosition = uViewProj * pos + mulMat(vPosition, pos, uViewProj) + +; vTecCoord = (aTexCoord.xyz, 1) TODO check AKILL + mov vTexCoord, aTexCoord + mov vTexCoord.w, ONE +#else + def c0, 0.0f, 0.0f, 0.0f, 1.0f + mov r0, c0 +#endif \ No newline at end of file diff --git a/src/shaders/shadow_entity.hlsl b/src/shaders/shadow_entity.hlsl new file mode 100644 index 00000000..db3ff26a --- /dev/null +++ b/src/shaders/shadow_entity.hlsl @@ -0,0 +1,51 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float4 texCoord : TEXCOORD0; +#ifndef SHADOW_DEPTH + float4 hpos : TEXCOORD1; +#endif +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + int index = int(In.aCoord.w); + float4 rBasisRot = uBasis[index]; + float4 rBasisPos = uBasis[index + 1]; + + float3 cpos = In.aCoord.xyz - normalize(In.aNormal.xyz) * SHADOW_NORMAL_BIAS; + float3 coord = mulBasis(rBasisRot, rBasisPos.xyz, cpos); + + Out.texCoord = In.aTexCoord * INV_SHORT_HALF; + Out.pos = mul(uViewProj, float4(coord, rBasisPos.w)); +#ifndef SHADOW_DEPTH + Out.hpos = Out.pos; +#endif + return Out; +} + +#else // PIXEL + +#if defined(ALPHA_TEST) || !defined(SHADOW_DEPTH) + #define PS_PARAMS VS_OUTPUT In +#else + #define PS_PARAMS +#endif + +float4 main(PS_PARAMS) : COLOR0 { +#ifdef ALPHA_TEST + clip(SAMPLE_2D_LINEAR(sDiffuse, In.texCoord.xy).a - ALPHA_REF); +#endif + +#ifdef SHADOW_DEPTH + return 0.0; +#else + return pack(In.hpos.z / In.hpos.w); +#endif +} + +#endif diff --git a/src/shaders/sky.glsl b/src/shaders/sky.glsl new file mode 100644 index 00000000..d525a0eb --- /dev/null +++ b/src/shaders/sky.glsl @@ -0,0 +1,122 @@ +R"====( +varying vec4 vColor; +varying vec2 vTexCoord; +varying vec3 vCoord; + +uniform vec4 uViewPos; + +#ifdef VERTEX + uniform mat4 uViewProj; + + attribute vec4 aCoord; + attribute vec4 aColor; + attribute vec4 aTexCoord; + + void main() { + vColor = aColor; + vTexCoord = aTexCoord.xy; + vCoord = vec3(aCoord.x, -aCoord.y, aCoord.z); + gl_Position = uViewProj * vec4(aCoord.xyz * 5.0, 1.0); + gl_Position.z = gl_Position.w; + } +#else + uniform sampler2D sDiffuse; + + #ifdef SKY_CLOUDS_AZURE + #define SKY_CLOUDS + #define SKY_AZURE + #endif + + #ifdef SKY_CLOUDS + uniform sampler3D sNormal; + uniform sampler2D sMask; + + uniform mat4 uLightProj; + uniform vec4 uPosScale[2]; + uniform vec4 uParam; + + #define STEPS 8.0 + #define MIN_HEIGHT 2.0 + #define MAX_HEIGHT 4.0 + #define skyWind uParam.xyz + #define skyDown uLightProj[0].xyz + #define skyUp uLightProj[1].xyz + #define sunDir uLightProj[2].xyz + #define sunSize uLightProj[2].w + #define sunColor uLightProj[3].xyz + #define sunGlare uLightProj[3].w + #define cloudsDown uPosScale[0].xyz + #define cloudsUp uPosScale[1].xyz + + // based on https://www.shadertoy.com/view/XsVGz3 / https://www.shadertoy.com/view/XslGRr + float noise3D(vec3 p) { + p = p * 0.15 + skyWind; + return texture3D(sNormal, p).x; + } + + float density(vec3 pos) { + float den = noise3D(pos) * 3.0 - 2.0 + (pos.y - MIN_HEIGHT); + float edge = 1.0 - smoothstep(MIN_HEIGHT, MAX_HEIGHT, pos.y); + den = clamp(den * edge * edge, 0.0, 1.0); + return den; + } + + vec3 raymarching(vec3 dir, float t0, float t1, vec3 backCol) { + float dither = texture2D(sMask, gl_FragCoord.xy * (1.0 / 8.0)).x; + + vec3 step = dir * ((t1 - t0) / STEPS); + vec3 pos = dir * t0 + step * dither; + vec4 sum = vec4(0.0); + + for (float i = 0.0; i < STEPS; i++) { + float den = density(pos); + + if (den > 0.01) { + float dif = max(0.0, den - density(pos + 0.3 * sunDir)) * 4.0; + + vec4 col = vec4(mix(cloudsUp, cloudsDown, den), den); + vec3 lin = sunColor * dif + 1.0; + + col.rgb *= lin; + + col.a *= 0.5; + col.rgb *= col.a; + sum = sum + col * (1.0 - sum.a); + } + + pos += step; + } + + sum = clamp(sum, 0.0, 1.0); + + float h = dir.y; + sum.rgb = mix(sum.rgb, backCol, exp(-20.0 * h * h) ); + + return mix(backCol, sum.xyz, sum.a); + } + #endif + + void main() { + vec3 dir = normalize(vCoord); + + #ifdef SKY_AZURE + vec3 col = mix(skyDown, skyUp, dir.y); + #else + vec3 col = texture2D(sDiffuse, vTexCoord).xyz * vColor.xyz; + #endif + + #ifdef SKY_CLOUDS + float sun = clamp(sunSize + dot(sunDir, dir), 0.0, 1.0); + col += sunColor * pow(sun, sunGlare); + + vec2 dist = vec2(MIN_HEIGHT, MAX_HEIGHT) / dir.y; + + if (dist.x > 0.0) { + col = raymarching(dir, dist.x, dist.y, col); + } + #endif + + fragColor = vec4(col, 1.0); + } +#endif +)====" diff --git a/src/shaders/sky.hlsl b/src/shaders/sky.hlsl new file mode 100644 index 00000000..801ecec1 --- /dev/null +++ b/src/shaders/sky.hlsl @@ -0,0 +1,116 @@ +#define NORMAL_AS_3D + +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + half4 color : TEXCOORD0; + half2 texCoord : TEXCOORD1; + float3 coord : TEXCOORD2; +}; + +#ifdef VERTEX + VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + Out.color = (half4)In.aColor; + Out.texCoord = (half2)In.aTexCoord.xy; + Out.coord = float3(In.aCoord.x, -In.aCoord.y, In.aCoord.z); + + Out.pos = mul(uViewProj, float4(In.aCoord.xyz * 5.0, 1.0)); + Out.pos.z = Out.pos.w; + + return Out; + } + +#else // PIXEL + + #ifdef SKY_AZURE + #define SKY_CLOUDS + #endif + + #ifdef SKY_CLOUDS + #define STEPS 8.0 + #define MIN_HEIGHT 2.0 + #define MAX_HEIGHT 4.0 + #define skyWind uParam.xyz + #define skyDown float3(uLightProj[0].x, uLightProj[1].x, uLightProj[2].x) + #define skyUp float3(uLightProj[0].y, uLightProj[1].y, uLightProj[2].y) + #define sunDir float3(uLightProj[0].z, uLightProj[1].z, uLightProj[2].z) + #define sunSize uLightProj[3].z + #define sunColor float3(uLightProj[0].w, uLightProj[1].w, uLightProj[2].w) + #define sunGlare uLightProj[3].w + #define cloudsDown uPosScale[0].xyz + #define cloudsUp uPosScale[1].xyz + + // based on https://www.shadertoy.com/view/XsVGz3 / https://www.shadertoy.com/view/XslGRr + float noise3D(float3 p) { + p = p * 0.15 + skyWind; + return SAMPLE_3D(sNormal, p).x; + } + + float density(float3 pos) { + float den = noise3D(pos) * 3.0 - 2.0 + (pos.y - MIN_HEIGHT); + float edge = 1.0 - smoothstep(MIN_HEIGHT, MAX_HEIGHT, pos.y); + den = clamp(den * edge * edge, 0.0, 1.0); + return den; + } + + float3 raymarching(float2 screenPos, float3 dir, float t0, float t1, float3 backCol) { + float dither = SAMPLE_2D_POINT_WRAP(sMask, screenPos * (1.0 / 8.0)).x; + + float3 step = dir * ((t1 - t0) / STEPS); + float3 pos = dir * t0 + step * dither; + float4 sum = 0.0; + + for (float i = 0.0; i < STEPS; i++) { + float den = density(pos); + + if (den > 0.01) { + float dif = max(0.0, den - density(pos + 0.3 * sunDir)) * 4.0; + + float4 col = float4(lerp(cloudsUp, cloudsDown, den), den); + float3 lin = sunColor * dif + 1.0; + + col.rgb *= lin; + + col.a *= 0.5; + col.rgb *= col.a; + sum = sum + col * (1.0 - sum.a); + } + + pos += step; + } + + sum = clamp(sum, 0.0, 1.0); + + float h = dir.y; + sum.rgb = lerp(sum.rgb, backCol, exp(-20.0 * h * h) ); + + return lerp(backCol, sum.xyz, sum.a); + } + #endif + + half4 main(VS_OUTPUT In) : COLOR0 { + float3 dir = normalize(In.coord); + + #ifdef SKY_AZURE + float3 col = lerp(skyDown, skyUp, dir.y); + #else + float3 col = SAMPLE_2D_LINEAR(sDiffuse, In.texCoord).xyz * In.color.xyz; + #endif + + #ifdef SKY_CLOUDS + float sun = clamp(sunSize + dot(sunDir, dir), 0.0, 1.0); + col += sunColor * pow(sun, sunGlare); + + float2 dist = float2(MIN_HEIGHT, MAX_HEIGHT) / dir.y; + + if (dist.x > 0.0) { + col = raymarching(In.pos.xy, dir, dist.x, dist.y, col); + } + #endif + + return half4(col, 1.0h); + } +#endif diff --git a/src/shaders/water.glsl b/src/shaders/water.glsl index f8f44818..fd16319e 100644 --- a/src/shaders/water.glsl +++ b/src/shaders/water.glsl @@ -1,11 +1,6 @@ R"====( -#ifdef GL_ES - precision lowp int; - precision highp float; -#endif - #define MAX_LIGHTS 4 -#define WATER_FOG_DIST (1.0 / (1024.0 * 6.0)) +#define WATER_FOG_DIST (1.0 / (6.0 * 1024.0)) #define WATER_COLOR_DIST (1.0 / (2.0 * 1024.0)) #define UNDERWATER_COLOR vec3(0.6, 0.9, 0.9) @@ -20,6 +15,10 @@ varying vec3 vLightVec; varying vec3 vNewPos; #endif +#if defined(WATER_COMPOSE) || defined(WATER_SIMULATE) + varying vec2 vMaskCoord; +#endif + uniform vec4 uViewPos; uniform mat4 uViewProj; uniform vec4 uLightPos[MAX_LIGHTS]; @@ -27,9 +26,16 @@ uniform vec4 uPosScale[2]; uniform vec4 uTexParam; uniform vec4 uParam; +uniform vec4 uRoomSize; uniform sampler2D sNormal; +vec3 calcNormal(vec2 tc, float base) { + float dx = texture2D(sNormal, vec2(tc.x + uTexParam.x, tc.y)).x - base; + float dz = texture2D(sNormal, vec2(tc.x, tc.y + uTexParam.y)).x - base; + return normalize( vec3(dx, 64.0 / (1024.0 * 8.0), dz) ); +} + #ifdef VERTEX attribute vec4 aCoord; @@ -38,6 +44,10 @@ uniform sampler2D sNormal; vTexCoord = (coord.xy * 0.5 + 0.5) * uTexParam.zw; + #if defined(WATER_COMPOSE) || defined(WATER_SIMULATE) + vMaskCoord = (coord.xy * 0.5 + 0.5) * uRoomSize.zw; + #endif + #if defined(WATER_MASK) || defined(WATER_COMPOSE) float height = 0.0; @@ -54,12 +64,13 @@ uniform sampler2D sNormal; #ifdef WATER_CAUSTICS vec3 rCoord = vec3(coord.x, coord.y, 0.0) * uPosScale[1].xzy; - vec4 info = texture2D(sNormal, (rCoord.xy * 0.5 + 0.5) * uTexParam.zw); - vec3 normal = vec3(info.z, info.w, sqrt(1.0 - dot(info.zw, info.zw))); + vec2 tc = (rCoord.xy * 0.5 + 0.5) * uTexParam.zw; + vec4 info = texture2D(sNormal, tc); + vec3 normal = calcNormal(tc, info.x).xzy; vec3 light = vec3(0.0, 0.0, 1.0); vec3 refOld = refract(-light, vec3(0.0, 0.0, 1.0), 0.75); - vec3 refNew = refract(-light, normal, 0.75); + vec3 refNew = refract(-light, normalize(normal + vec3(0.0, 0.0, 0.25)), 0.75); vOldPos = rCoord + refOld * (-1.0 / refOld.z) + refOld * ((-refOld.z - 1.0) / refOld.z); vNewPos = rCoord + refNew * ((info.r - 1.0) / refNew.z) + refOld * ((-refNew.z - 1.0) / refOld.z); @@ -78,6 +89,11 @@ uniform sampler2D sNormal; #endif vViewVec = uViewPos.xyz - vCoord.xyz; vLightVec = uLightPos[0].xyz - vCoord.xyz; + + #ifdef WATER_COMPOSE + vViewVec.y = abs(vViewVec.y); + vLightVec.y = abs(vLightVec.y); + #endif } #else uniform sampler2D sDiffuse; @@ -88,78 +104,53 @@ uniform sampler2D sNormal; #define PI 3.141592653589793 - float calcFresnel(float VoH, float f0) { - float f = pow(1.0 - VoH, 5.0); - return f + f0 * (1.0 - f); + float calcFresnel(float NdotV, float f0) { + return f0 + (1.0 - f0) * pow(1.0 - NdotV, 5.0); } +#ifdef WATER_DROP vec4 drop() { - vec4 v = texture2D(sDiffuse, vTexCoord); + vec2 v = texture2D(sNormal, vTexCoord).xy; float drop = max(0.0, 1.0 - length(uParam.xy - vTexCoord / uTexParam.xy) / uParam.z); drop = 0.5 - cos(drop * PI) * 0.5; v.x += drop * uParam.w; - return v; - } - - vec3 hash33(vec3 p3) { - p3 = fract(p3 * vec3(.1031,.11369,.13787)); - p3 += dot(p3, p3.yxz+19.19); - return -1.0 + 2.0 * fract(vec3((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y, (p3.y+p3.z)*p3.x)); - } - - float simplex_noise(vec3 p) { // https://www.shadertoy.com/view/4sc3z2 - const float K1 = 0.333333333; - const float K2 = 0.166666667; - - vec3 i = floor(p + (p.x + p.y + p.z) * K1); - vec3 d0 = p - (i - (i.x + i.y + i.z) * K2); - - vec3 e = step(vec3(0.0), d0 - d0.yzx); - vec3 i1 = e * (1.0 - e.zxy); - vec3 i2 = 1.0 - e.zxy * (1.0 - e); - - vec3 d1 = d0 - (i1 - 1.0 * K2); - vec3 d2 = d0 - (i2 - 2.0 * K2); - vec3 d3 = d0 - (1.0 - 3.0 * K2); - - vec4 h = max(0.6 - vec4(dot(d0, d0), dot(d1, d1), dot(d2, d2), dot(d3, d3)), 0.0); - vec4 n = h * h * h * h * vec4(dot(d0, hash33(i)), dot(d1, hash33(i + i1)), dot(d2, hash33(i + i2)), dot(d3, hash33(i + 1.0))); - - return dot(vec4(31.316), n); + return vec4(v, 0.0, 0.0); } +#endif - float h(vec2 tc) { - return simplex_noise(vec3(tc * 16.0, uParam.w)) * 0.0005; +#ifdef WATER_SIMULATE + float noise3D(vec3 x) { // https://www.shadertoy.com/view/XslGRr + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + vec2 uv = (p.xy + vec2(37.0, 17.0) * p.z) + f.xy; + vec2 rg = texture2D(sDiffuse, (uv + 0.5) / 32.0).yx; + return mix(rg.x, rg.y, f.z) * 2.0 - 1.0; } vec4 simulate() { vec2 tc = vTexCoord; - if (texture2D(sMask, tc).x < 0.5) - return vec4(0.0); - - vec4 v = texture2D(sDiffuse, tc); // height, speed, normal.xz + vec2 v = texture2D(sNormal, tc).xy; // height, speed vec3 d = vec3(uTexParam.xy, 0.0); - vec4 f = vec4(texture2D(sDiffuse, tc + d.xz).x, texture2D(sDiffuse, tc + d.zy).x, - texture2D(sDiffuse, tc - d.xz).x, texture2D(sDiffuse, tc - d.zy).x); + vec4 f = vec4(texture2D(sNormal, tc + d.xz).x, texture2D(sNormal, tc + d.zy).x, + texture2D(sNormal, tc - d.xz).x, texture2D(sNormal, tc - d.zy).x); float average = dot(f, vec4(0.25)); - // normal - v.zw = normalize( vec3(f.x - f.z, 64.0 / (1024.0 * 4.0), f.y - f.w) ).xz; - // integrate const float vel = 1.4; const float vis = 0.995; - v.y += (average - v.x) * vel; v.y *= vis; - v.x += v.y + h(tc); + v.x += v.y + noise3D(vec3(tc * 32.0, uParam.w)) * 0.00025; + v *= texture2D(sMask, vMaskCoord).x; - return v; + return vec4(v.xy, 0.0, 0.0); } +#endif #ifdef WATER_CAUSTICS vec4 caustics() { @@ -172,14 +163,13 @@ uniform sampler2D sNormal; #endif #ifdef WATER_RAYS - -float boxIntersect(vec3 rayPos, vec3 rayDir, vec3 center, vec3 hsize) { - center -= rayPos; - vec3 bMin = (center - hsize) / rayDir; - vec3 bMax = (center + hsize) / rayDir; - vec3 m = min(bMin, bMax); - return max(0.0, max(m.x, max(m.y, m.z))); -} + float boxIntersect(vec3 rayPos, vec3 rayDir, vec3 center, vec3 hsize) { + center -= rayPos; + vec3 bMin = (center - hsize) / rayDir; + vec3 bMax = (center + hsize) / rayDir; + vec3 m = min(bMin, bMax); + return max(0.0, max(m.x, max(m.y, m.z))); + } vec4 rays() { #define RAY_STEPS 16.0 @@ -222,12 +212,14 @@ float boxIntersect(vec3 rayPos, vec3 rayDir, vec3 center, vec3 hsize) { color.xyz = mix(UNDERWATER_COLOR * 0.2, color.xyz, fog); } +#ifdef WATER_COMPOSE vec4 compose() { vec3 viewVec = normalize(vViewVec); - vec4 value = texture2D(sNormal, vTexCoord); - vec3 normal = vec3(value.z, sqrt(1.0 - dot(value.zw, value.zw)) * sign(viewVec.y), value.w); - vec2 dudv = (uViewProj * vec4(normal.x, 0.0, normal.z, 0.0)).xy; + vec2 value = texture2D(sNormal, vTexCoord).xy; + vec3 normal = calcNormal(vTexCoord, value.x); + + vec2 dudv = (uViewProj * vec4(normal.x, 0.0, normal.z, 0.0)).xy; vec3 rv = reflect(-viewVec, normal); vec3 lv = normalize(vLightVec); @@ -237,20 +229,22 @@ float boxIntersect(vec3 rayPos, vec3 rayDir, vec3 center, vec3 hsize) { vec2 tc = vProjCoord.xy / vProjCoord.w * 0.5 + 0.5; vec4 refrA = texture2D(sDiffuse, uParam.xy * clamp(tc + dudv * uParam.z, 0.0, 0.999) ); - vec4 refrB = texture2D(sDiffuse, uParam.xy * tc ); + vec4 refrB = texture2D(sDiffuse, uParam.xy * tc); vec4 refr = vec4(mix(refrA.xyz, refrB.xyz, refrA.w), 1.0); vec4 refl = texture2D(sReflect, vec2(tc.x, 1.0 - tc.y) + dudv * uParam.w); - float fresnel = calcFresnel(max(0.0, dot(normal, viewVec)), 0.12); + float fresnel = calcFresnel(abs(dot(normal, viewVec)), 0.12); - vec4 color = mix(refr, refl, fresnel) + spec * 1.5; - color.w *= texture2D(sMask, vTexCoord).x; + vec4 color = mix(refr, refl, fresnel); + color.xyz += spec * 1.5; + color.w = texture2D(sMask, vMaskCoord).x; applyFog(color.xyz, vViewVec.y / viewVec.y); return color; } +#endif - vec4 pass() { + vec4 process() { #ifdef WATER_DROP return drop(); #endif @@ -279,7 +273,7 @@ float boxIntersect(vec3 rayPos, vec3 rayDir, vec3 center, vec3 hsize) { } void main() { - gl_FragColor = pass(); + fragColor = process(); } #endif )====" diff --git a/src/shaders/water.hlsl b/src/shaders/water.hlsl deleted file mode 100644 index c506a31a..00000000 --- a/src/shaders/water.hlsl +++ /dev/null @@ -1,267 +0,0 @@ -#include "common.hlsl" - -struct VS_OUTPUT { - float4 pos : POSITION; - float3 coord : TEXCOORD0; - float2 texCoord : TEXCOORD1; - float3 viewVec : TEXCOORD2; - float3 lightVec : TEXCOORD3; - float3 oldPos : TEXCOORD4; - float3 newPos : TEXCOORD5; - float4 hpos : TEXCOORD6; -}; - -float2 invUV(float2 uv) { - return float2(uv.x, 1.0 - uv.y); -} - -float3 getInvUV(float2 uv, float4 param) { - return float3((float2(uv.x, -uv.y) * 0.5 + 0.5) * param.zw + 0.5 * param.xy, 0.0); -} - -#ifdef VERTEX -VS_OUTPUT main(VS_INPUT In) { - VS_OUTPUT Out; - - Out.pos = 0.0; - Out.coord = 0.0; - Out.viewVec = 0.0; - Out.lightVec = 0.0; - Out.oldPos = 0.0; - Out.newPos = 0.0; - Out.hpos = 0.0; - - float3 coord = In.aCoord.xyz * (1.0 / 32767.0); - - if (WATER_COMPOSE) { - Out.coord = float3(coord.x, 0.0, coord.y) * uPosScale[1].xyz + uPosScale[0].xyz; - Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); - Out.viewVec = uViewPos.xyz - Out.coord.xyz; - Out.lightVec = uLightPos[0].xyz - Out.coord.xyz; - Out.oldPos = getInvUV(coord.xy, uTexParam); - } else if (WATER_DROP) { - Out.pos = float4(coord.xyz, 1.0); - Out.oldPos = getInvUV(coord.xy, uTexParam); - } else if (WATER_SIMULATE) { - Out.pos = float4(coord.xyz, 1.0); - Out.oldPos = getInvUV(coord.xy, uTexParam); - } else if (WATER_CAUSTICS) { - float3 rCoord = float3(coord.x, coord.y, 0.0) * uPosScale[1].xzy; - float2 uv = getInvUV(rCoord.xy, uTexParam).xy; - float4 info = tex2Dlod(sNormal, float4(uv, 0, 0)); - float3 normal = float3(info.z, info.w, sqrt(1.0 - dot(info.zw, info.zw))); - - float3 light = float3(0.0, 0.0, 1.0); - float3 refOld = refract(-light, float3(0.0, 0.0, 1.0), 0.75); - float3 refNew = refract(-light, normal, 0.75); - - Out.oldPos = rCoord + refOld * (-1.0 / refOld.z) + refOld * ((-refOld.z - 1.0) / refOld.z); - Out.newPos = rCoord + refNew * ((info.r - 1.0) / refNew.z) + refOld * ((-refNew.z - 1.0) / refOld.z); - - Out.pos = float4(Out.newPos.xy + refOld.xy / refOld.z, 0.0, 1.0); - } else if (WATER_MASK) { - Out.coord = float3(coord.x, 0.0, coord.y) * uPosScale[1].xyz + uPosScale[0].xyz; - Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); - } else if (WATER_RAYS) { - Out.coord = In.aCoord.xyz + uParam.xyz; - Out.viewVec = uViewPos.xyz - Out.coord.xyz; - Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); - } - - Out.texCoord = (coord.xy * 0.5 + 0.5) * uTexParam.zw + 0.5 * uTexParam.xy; // + half texel offset - Out.hpos = Out.pos; - - return Out; -} - -#else // PIXEL - -float calcFresnel(float VoH, float f0) { - float f = pow(1.0 - VoH, 5.0); - return f + f0 * (1.0f - f); -} - -float4 drop(VS_OUTPUT In) { - float2 iuv = In.oldPos.xy; - - float4 v = tex2D(sDiffuse, iuv); - - float value = max(0.0, 1.0 - length(uParam.xy - In.texCoord / uTexParam.xy) / uParam.z); - value = 0.5 - cos(value * PI) * 0.5; - - v.x += value * uParam.w; - - return v; -} - -float3 hash33(float3 p3) { - p3 = frac(p3 * float3(.1031,.11369,.13787)); - p3 += dot(p3, p3.yxz+19.19); - return -1.0 + 2.0 * frac(float3((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y, (p3.y+p3.z)*p3.x)); -} - -float simplex_noise(float3 p) { // https://www.shadertoy.com/view/4sc3z2 - const float K1 = 0.333333333; - const float K2 = 0.166666667; - - float3 i = floor(p + (p.x + p.y + p.z) * K1); - float3 d0 = p - (i - (i.x + i.y + i.z) * K2); - - float3 e = step((float3)0.0, d0 - d0.yzx); - float3 i1 = e * (1.0 - e.zxy); - float3 i2 = 1.0 - e.zxy * (1.0 - e); - - float3 d1 = d0 - (i1 - 1.0 * K2); - float3 d2 = d0 - (i2 - 2.0 * K2); - float3 d3 = d0 - (1.0 - 3.0 * K2); - - float4 h = max(0.6 - float4(dot(d0, d0), dot(d1, d1), dot(d2, d2), dot(d3, d3)), 0.0); - float4 n = h * h * h * h * float4(dot(d0, hash33(i)), dot(d1, hash33(i + i1)), dot(d2, hash33(i + i2)), dot(d3, hash33(i + 1.0))); - - return dot((float4)31.316, n); -} - -float h(float2 tc) { - return simplex_noise(float3(tc * 16.0, uParam.w)) * 0.0005; -} - -float4 simulate(VS_OUTPUT In) { - float2 iuv = In.oldPos.xy; - float2 uv = In.texCoord; - - if (tex2D(sMask, uv).x < 0.5) - return 0.0; - - float4 v = tex2D(sDiffuse, iuv); // height, speed, normal.xz - - float3 d = float3(float2(uTexParam.x, -uTexParam.y), 0.0); - float4 f = float4( - tex2D(sDiffuse, iuv + d.xz).x, tex2D(sDiffuse, iuv + d.zy).x, - tex2D(sDiffuse, iuv - d.xz).x, tex2D(sDiffuse, iuv - d.zy).x - ); - - float average = dot(f, (float4)0.25); - -// normal - v.zw = normalize( float3(f.x - f.z, 64.0 / (1024.0 * 4.0), f.y - f.w) ).xz; - -// integrate - const float vel = 1.4; - const float vis = 0.995; - - v.y += (average - v.x) * vel; - v.y *= vis; - v.x += v.y + h(uv); - - return v; -} - -float4 caustics(VS_OUTPUT In) { - float rOldArea = length(ddx(In.oldPos)) * length(ddy(In.oldPos)); - float rNewArea = length(ddx(In.newPos)) * length(ddy(In.newPos)); - rNewArea = max(rNewArea, 0.00002); // WebGL NVIDIA workaround >_< - float value = saturate(rOldArea / rNewArea * 0.2); - return float4(value, 0.0, 0.0, 0.0); -} - -float boxIntersect(float3 rayPos, float3 rayDir, float3 center, float3 hsize) { - center -= rayPos; - float3 bMin = (center - hsize) / rayDir; - float3 bMax = (center + hsize) / rayDir; - float3 m = min(bMin, bMax); - return max(0.0, max(m.x, max(m.y, m.z))); -} - -float4 rays(VS_OUTPUT In, float2 pixelCoord) { - #define RAY_STEPS 16.0 - - float3 viewVec = normalize(In.viewVec); - - float t = boxIntersect(uViewPos.xyz, -viewVec, uPosScale[0].xyz, uPosScale[1].xyz); - - float3 p0 = uViewPos.xyz - viewVec * t; - float3 p1 = In.coord.xyz; - - float dither = tex2Dlod(sMask, float4(pixelCoord * (1.0 / 8.0), 0, 0)).x; - - float3 delta = (p1 - p0) / RAY_STEPS; - float3 pos = p0 + delta * dither; - - float sum = 0.0; - for (float i = 0.0; i < RAY_STEPS; i++) { - float3 wpos = (pos - uPosScale[0].xyz) / uPosScale[1].xyz; - float2 tc = wpos.xz * 0.5 + 0.5; - float light = tex2Dlod(sReflect, float4(tc, 0, 0)).x; - sum += light * (1.0 - (clamp(wpos.y, -1.0, 1.0) * 0.5 + 0.5)); - pos += delta; - } - sum /= RAY_STEPS; - sum *= uParam.w; - - return float4(UNDERWATER_COLOR * sum, 1.0); -} - -float4 mask() { - return 0.0; -} - -float4 compose(VS_OUTPUT In) { - float3 viewVec = normalize(In.viewVec); - float2 iuv = In.oldPos.xy; - - float4 value = tex2D(sNormal, iuv); - float3 normal = float3(value.z, sqrt(1.0 - dot(value.zw, value.zw)) * sign(viewVec.y), value.w); - float2 dudv = mul(uViewProj, float4(normal.x, 0.0, normal.z, 0.0)).xy; - - float3 rv = reflect(-viewVec, normal); - float3 lv = normalize(In.lightVec); - - float spec = pow(max(0.0, dot(rv, lv)), 64.0) * 0.5; - - float2 tc = In.hpos.xy / In.hpos.w * 0.5 + 0.5; - - float4 refrA = tex2D(sDiffuse, uParam.xy * invUV(clamp(tc + dudv * uParam.z, 0.0, 0.999)) ); - float4 refrB = tex2D(sDiffuse, uParam.xy * invUV(tc) ); - float4 refr = float4(lerp(refrA.xyz, refrB.xyz, refrA.w), 1.0); - float4 refl = tex2D(sReflect, tc.xy + dudv * uParam.w); - - float fresnel = calcFresnel(max(0.0, dot(normal, viewVec)), 0.12); - - float4 color = lerp(refr, refl, fresnel) + spec * 1.5; - color.w *= tex2D(sMask, In.texCoord).x; - - float dist = In.viewVec.y / viewVec.y; - dist *= step(In.coord.y, uViewPos.y); - color.xyz *= lerp(float3(1.0, 1.0, 1.0), UNDERWATER_COLOR, clamp(dist * WATER_COLOR_DIST, 0.0, 2.0)); - float fog = saturate(1.0 / exp(dist * WATER_FOG_DIST)); - color.xyz = lerp(UNDERWATER_COLOR * 0.2, color.xyz, fog); - return color; -} - -#ifdef _GAPI_GXM -float4 main(VS_OUTPUT In) : COLOR0 { - float2 pixelCoord = float2(__pixel_x(), __pixel_y()); -#else -float4 main(VS_OUTPUT In, float4 pixelCoord: VPOS) : COLOR0 { -#endif - if (WATER_DROP) - return drop(In); - - if (WATER_SIMULATE) - return simulate(In); - - if (WATER_CAUSTICS) - return caustics(In); - - if (WATER_RAYS) - return rays(In, pixelCoord.xy); - - if (WATER_MASK) - return mask(); - - if (WATER_COMPOSE) - return compose(In); - - return float4(1.0, 0.0, 1.0, 1.0); -} -#endif \ No newline at end of file diff --git a/src/shaders/water_caustics.hlsl b/src/shaders/water_caustics.hlsl new file mode 100644 index 00000000..523ca88c --- /dev/null +++ b/src/shaders/water_caustics.hlsl @@ -0,0 +1,57 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float3 oldPos : TEXCOORD1; + float3 newPos : TEXCOORD2; +}; + +float2 getInvUV(float2 uv, float4 param) { + float2 p = (float2(uv.x, -uv.y) * 0.5 + 0.5) * param.zw; + +#ifdef _GAPI_D3D9 + p.xy += 0.5 * param.xy; +#endif + + return p; +} + +float2 getUV(float2 uv, float4 param) { + return (uv.xy * 0.5 + 0.5) * param.zw; +} + +#ifdef VERTEX +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float3 coord = In.aCoord.xyz * INV_SHORT_HALF; + + float3 rCoord = float3(coord.x, coord.y, 0.0) * uPosScale[1].xzy; + + float2 uv = getInvUV(rCoord.xy, uTexParam).xy; + float2 info = SAMPLE_2D_LOD0(sNormal, uv).xy; + float3 normal = calcHeightMapNormal(float2(uv.x + uTexParam.x, uv.y), float2(uv.x, uv.y - uTexParam.y), info.x).xzy; + + float3 light = float3(0.0, 0.0, 1.0); + float3 refOld = refract(-light, float3(0.0, 0.0, 1.0), 0.75); + float3 refNew = refract(-light, normalize(normal + float3(0.0, 0.0, 0.25)), 0.75); + + Out.oldPos = rCoord + refOld * (-1.0 / refOld.z) + refOld * ((-refOld.z - 1.0) / refOld.z); + Out.newPos = rCoord + refNew * ((info.r - 1.0) / refNew.z) + refOld * ((-refNew.z - 1.0) / refOld.z); + + Out.pos = float4(Out.newPos.xy + refOld.xy / refOld.z, 0.0, 1.0); + + return Out; +} + +#else // PIXEL + +float4 main(VS_OUTPUT In) : COLOR0 { + float rOldArea = length(ddx(In.oldPos)) * length(ddy(In.oldPos)); + float rNewArea = length(ddx(In.newPos)) * length(ddy(In.newPos)); + rNewArea = max(rNewArea, 0.00002); // WebGL NVIDIA workaround >_< + float value = saturate(rOldArea / rNewArea * 0.2); + return float4(value, 0.0, 0.0, 0.0); +} + +#endif diff --git a/src/shaders/water_compose.hlsl b/src/shaders/water_compose.hlsl new file mode 100644 index 00000000..fdf788cb --- /dev/null +++ b/src/shaders/water_compose.hlsl @@ -0,0 +1,87 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + half2 texCoord : TEXCOORD1; + half2 maskCoord : TEXCOORD2; + half2 texCoordR : TEXCOORD6; + half2 texCoordB : TEXCOORD7; + float4 viewVec : TEXCOORD3; + float3 lightVec : TEXCOORD4; + float3 hpos : TEXCOORD5; +}; + +#ifdef VERTEX +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float3 coord = In.aCoord.xyz * INV_SHORT_HALF; + + float4 uv = float4(coord.x, coord.y, coord.x, -coord.y) * 0.5 + 0.5; + Out.maskCoord = uv.xy * uRoomSize.zw; + Out.texCoord = uv.zw * uTexParam.zw; + +#ifdef _GAPI_D3D9 + Out.texCoord += 0.5 * uTexParam.xy; +#endif + + coord = float3(coord.x, 0.0, coord.y) * uPosScale[1].xyz + uPosScale[0].xyz; + + Out.pos = mul(uViewProj, float4(coord, 1.0)); + Out.hpos = Out.pos.xyw; + Out.viewVec.xyz = uViewPos.xyz - coord; + Out.lightVec = uLightPos[0].xyz - coord; + Out.viewVec.y = abs(Out.viewVec.y); + Out.lightVec.y = abs(Out.lightVec.y); + + Out.viewVec.w = step(uPosScale[0].y, uViewPos.y); + + Out.texCoordR = Out.texCoord + float2(uTexParam.x, 0.0); + Out.texCoordB = Out.texCoord + float2(0.0, uTexParam.y); + + return Out; +} + +#else // PIXEL + +half4 main(VS_OUTPUT In) : COLOR0 { + float3 viewVec = normalize(In.viewVec.xyz); + + float value = SAMPLE_2D_LINEAR(sNormal, In.texCoord).x; + float3 normal = calcHeightMapNormal(In.texCoordR, In.texCoordB, value); + + float2 dudv = mul(uViewProj, float4(normal.x, 0.0, normal.z, 0.0)).xy; + float3 rv = reflect(-viewVec, normal); + float3 lv = normalize(In.lightVec); + + half spec = pow(max(0.0, dot(rv, lv)), 64.0) * 0.5; + + float2 tc = In.hpos.xy / In.hpos.z * 0.5 + 0.5; + + half4 refrA = SAMPLE_2D_LINEAR(sDiffuse, clamp(tc + dudv * uParam.z, 0.0, 0.999)); + half4 refrB = SAMPLE_2D_POINT(sDiffuse, tc); + half3 refr = lerp(refrA.xyz, refrB.xyz, refrA.w); + +#ifdef _GAPI_D3D11_9_3 // TODO scale reflection matrix + tc.x = 1.0 - tc.x; + tc.y = 1.0 - tc.y; +#endif + + half3 refl = SAMPLE_2D_LINEAR(sReflect, float2(tc.x, tc.y) + dudv * uParam.w).xyz; + + half fresnel = calcFresnel(abs(dot(normal, viewVec)), 0.12); + + half mask = SAMPLE_2D_POINT(sMask, In.maskCoord).r; + half4 color = half4(lerp(refr, refl, fresnel), mask); + color.xyz += spec * 1.5; + + float dist = (In.viewVec.y / viewVec.y) * In.viewVec.w; + color.xyz *= lerp((half3)1.0, UNDERWATER_COLOR_H, (half)clamp(dist * WATER_COLOR_DIST, 0.0, 2.0)); + + half fog = saturate(1.0h / exp(dist * WATER_FOG_DIST)); + color.xyz = lerp(UNDERWATER_COLOR_H * 0.2, color.xyz, fog); + + return color; +} + +#endif diff --git a/src/shaders/water_drop.hlsl b/src/shaders/water_drop.hlsl new file mode 100644 index 00000000..2cf5a82e --- /dev/null +++ b/src/shaders/water_drop.hlsl @@ -0,0 +1,51 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float2 texCoord : TEXCOORD0; + float2 dropCoord : TEXCOORD1; +}; + +float2 getInvUV(float2 uv, float4 param) { + float2 p = (float2(uv.x, -uv.y) * 0.5 + 0.5) * param.zw; +#ifdef _GAPI_D3D9 + p.xy += 0.5 * param.xy; +#endif + return p; +} + +float2 getUV(float2 uv, float4 param) { + float2 p = (uv.xy * 0.5 + 0.5) * param.zw; + return p; +} + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float3 coord = In.aCoord.xyz * INV_SHORT_HALF; + + Out.pos = float4(coord.xyz, 1.0); + Out.texCoord = getInvUV(coord.xy, uTexParam); + Out.dropCoord = getUV(coord.xy, uTexParam); + + return Out; +} + +#else // PIXEL + +half4 main(VS_OUTPUT In) : COLOR0 { + half2 v = SAMPLE_2D_LINEAR(sNormal, In.texCoord.xy).xy; + + float value = max(0.0, 1.0 - length(uParam.xy - In.dropCoord / uTexParam.xy) / uParam.z); + value = 0.5 - cos(value * PI) * 0.5; + value *= uParam.w; + + v.x += (half)value; + //v.x = 1.0; + + return half4(v, 0, 0); +} + +#endif diff --git a/src/shaders/water_mask.hlsl b/src/shaders/water_mask.hlsl new file mode 100644 index 00000000..fe2662ff --- /dev/null +++ b/src/shaders/water_mask.hlsl @@ -0,0 +1,17 @@ +#include "common.hlsl" + +#ifdef VERTEX + +float4 main(VS_INPUT In) : POSITION { + float3 coord = In.aCoord.xyz * INV_SHORT_HALF; + coord = float3(coord.x, 0.0, coord.y) * uPosScale[1].xyz + uPosScale[0].xyz; + return mul(uViewProj, float4(coord, 1.0)); +} + +#else // PIXEL + +float4 main() : COLOR0 { + return 0.0; +} + +#endif diff --git a/src/shaders/water_rays.hlsl b/src/shaders/water_rays.hlsl new file mode 100644 index 00000000..3020c1b2 --- /dev/null +++ b/src/shaders/water_rays.hlsl @@ -0,0 +1,66 @@ +#include "common.hlsl" + +#define RAY_STEPS 16.0 + +struct VS_OUTPUT { + float4 pos : POSITION; + float3 coord : TEXCOORD0; + float3 viewVec : TEXCOORD1; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + Out.coord = In.aCoord.xyz + uParam.xyz; + Out.viewVec = uViewPos.xyz - Out.coord.xyz; + Out.pos = mul(uViewProj, float4(Out.coord, 1.0)); + + return Out; +} + +#else // PIXEL + +float boxIntersect(float3 rayPos, float3 rayDir, float3 center, float3 hsize) { + center -= rayPos; + float3 bMin = (center - hsize) / rayDir; + float3 bMax = (center + hsize) / rayDir; + float3 m = min(bMin, bMax); + return max(0.0, max(m.x, max(m.y, m.z))); +} + +#if defined(_GAPI_GXM) +float4 main(VS_OUTPUT In) : COLOR0 { + float2 pixelCoord = float2(__pixel_x(), __pixel_y()); +#else +float4 main(VS_OUTPUT In) : COLOR0 { + float2 pixelCoord = In.pos.xy; +#endif + float3 viewVec = normalize(In.viewVec); + + float t = boxIntersect(uViewPos.xyz, -viewVec, uPosScale[0].xyz, uPosScale[1].xyz); + + float3 p0 = uViewPos.xyz - viewVec * t; + float3 p1 = In.coord.xyz; + + float dither = SAMPLE_2D_POINT_WRAP(sMask, pixelCoord * (1.0 / 8.0)).x; + + float3 delta = (p1 - p0) / RAY_STEPS; + float3 pos = p0 + delta * dither; + + float sum = 0.0; + for (float i = 0.0; i < RAY_STEPS; i++) { + float3 wpos = (pos - uPosScale[0].xyz) / uPosScale[1].xyz; + float2 tc = wpos.xz * 0.5 + 0.5; + float light = SAMPLE_2D_LINEAR(sReflect, tc).x; + sum += light * (1.0 - (clamp(wpos.y, -1.0, 1.0) * 0.5 + 0.5)); + pos += delta; + } + sum /= RAY_STEPS; + sum *= uParam.w; + + return float4(UNDERWATER_COLOR * sum, 1.0); +} + +#endif diff --git a/src/shaders/water_simulate.hlsl b/src/shaders/water_simulate.hlsl new file mode 100644 index 00000000..d9637898 --- /dev/null +++ b/src/shaders/water_simulate.hlsl @@ -0,0 +1,64 @@ +#include "common.hlsl" + +struct VS_OUTPUT { + float4 pos : POSITION; + float2 texCoord : TEXCOORD0; + half2 maskCoord : TEXCOORD1; + float2 texCoordL : TEXCOORD2; + float2 texCoordR : TEXCOORD3; + float2 texCoordT : TEXCOORD4; + float2 texCoordB : TEXCOORD5; + half2 noiseCoord : TEXCOORD6; +}; + +#ifdef VERTEX + +VS_OUTPUT main(VS_INPUT In) { + VS_OUTPUT Out; + + float3 coord = In.aCoord.xyz * INV_SHORT_HALF; + float4 uv = float4(coord.x, coord.y, coord.x, -coord.y) * 0.5 + 0.5; + + Out.pos = float4(coord.xyz, 1.0); + Out.maskCoord = uv.xy * uRoomSize.zw; + Out.texCoord = uv.zw * uTexParam.zw; + #ifdef _GAPI_D3D9 + Out.texCoord += 0.5 * uTexParam.xy; + #endif + + float3 d = float3(uTexParam.x, uTexParam.y, 0.0); + Out.texCoordL = Out.texCoord - d.xz; + Out.texCoordR = Out.texCoord + d.xz; + Out.texCoordT = Out.texCoord - d.zy; + Out.texCoordB = Out.texCoord + d.zy; + Out.noiseCoord = Out.maskCoord + uParam.zw; + + return Out; +} + +#else // PIXEL + +#define WATER_VEL 1.4 +#define WATER_VIS 0.995 + +half4 main(VS_OUTPUT In) : COLOR0 { + half4 v = SAMPLE_2D_POINT(sNormal, In.texCoord.xy); // height, speed + + half average = ( + SAMPLE_2D_POINT(sNormal, In.texCoordL).x + + SAMPLE_2D_POINT(sNormal, In.texCoordR).x + + SAMPLE_2D_POINT(sNormal, In.texCoordT).x + + SAMPLE_2D_POINT(sNormal, In.texCoordB).x) * 0.25; + +// integrate + v.y += (average - v.x) * WATER_VEL; + v.y *= WATER_VIS; + v.x += v.y; + v.x += (SAMPLE_2D_LINEAR_WRAP(sDiffuse, In.noiseCoord).x * 2.0 - 1.0) * 0.00025; + + v *= SAMPLE_2D_POINT(sMask, In.maskCoord).r; + + return v; +} + +#endif diff --git a/src/sound.h b/src/sound.h index 16ea3eec..c1a95f97 100644 --- a/src/sound.h +++ b/src/sound.h @@ -1,15 +1,20 @@ #ifndef H_SOUND #define H_SOUND -#define DECODE_ADPCM -#define DECODE_IMA -#define DECODE_VAG -#define DECODE_XA +#ifdef _OS_TNS + #define NO_SOUND +#endif -#define DECODE_OGG +#ifndef NO_SOUND + #define DECODE_ADPCM + #define DECODE_IMA + #define DECODE_VAG + #define DECODE_XA + #define DECODE_OGG -#if !defined(_OS_PSP) && !defined(_OS_WEB) && !defined(_OS_PSV) - #define DECODE_MP3 + #if !defined(_OS_PSP) && !defined(_OS_WEB) && !defined(_OS_PSV) && !defined(_OS_3DS) && !defined(_OS_XBOX) && !defined(_OS_XB1) + #define DECODE_MP3 + #endif #endif #include "utils.h" @@ -19,13 +24,20 @@ #endif #ifdef DECODE_OGG - #define STB_VORBIS_HEADER_ONLY - #include "libs/stb_vorbis/stb_vorbis.c" + #ifdef USE_LIBVORBIS + #include + #else + #define STB_VORBIS_HEADER_ONLY + #include "libs/stb_vorbis/stb_vorbis.c" + #endif #endif #define SND_CHANNELS_MAX 128 #define SND_FADEOFF_DIST (1024.0f * 8.0f) +#define SND_LOWPASS_FREQ 0.2f #define SND_MAX_VOLUME 20 +#define SND_PAN_FACTOR 0.7f +#define SND_FACING_FACTOR 0.3f namespace Sound { @@ -50,31 +62,62 @@ namespace Sound { int32 L, R; }; + struct Stats { + int mixer; + int reverb; + int render[2]; + int ogg; + } stats; + namespace Filter { - #define MAX_FDN 16 - #define MAX_DELAY 1024 + #define MAX_FDN 16 + #define MAX_DELAY 954 + + #define DSP_SCALE_BIT 8 + #define DSP_SCALE (1 << DSP_SCALE_BIT) static const int16 FDN[MAX_FDN] = { 281, 331, 373, 419, 461, 503, 547, 593, 641, 683, 727, 769, 811, 853, 907, 953 }; struct Delay { int index; - float out[MAX_DELAY]; + int16 out[MAX_DELAY]; - float process(float x, int delay) { + void process(int16 &x, int16 delay) { index = (index + 1) % delay; - float y = out[index]; + int16 y = out[index]; out[index] = x; - return y; + x = y; } }; struct Absorption { - float out; + int16 out; - float process(float x, float gain, float damping) { - out = out * damping + x * gain * (1.0f - damping); - if (out < EPS) out = 0.0f; - return out; + void process(int16 &x, int32 gain, int32 damping) { + x = out = (out * damping + ((x * gain * (DSP_SCALE - damping)) >> DSP_SCALE_BIT)) >> DSP_SCALE_BIT; + } + }; + + struct LowPass { + float buffer[2][4]; + + LowPass() { + memset(buffer, 0, sizeof(buffer)); + } + + inline void process(int32 &x, float *out, float freq) { + out[0] += freq * (float(x) - out[0]); + out[1] += freq * (out[0] - out[1]); + out[2] += freq * (out[1] - out[2]); + out[3] += freq * (out[2] - out[3]); + x = int32(out[3]); + } + + void process(FrameHI *frames, int count, float freq) { + for (int i = 0; i < count; i++) { + process(frames[i].L, buffer[0], freq); + process(frames[i].R, buffer[1], freq); + } } }; @@ -82,25 +125,28 @@ namespace Sound { Delay df[MAX_FDN]; Absorption af[MAX_FDN]; - float output[MAX_FDN]; - float panCoeff[MAX_FDN][2]; - float absCoeff[MAX_FDN][2]; // absorption gain & damping + int32 output[MAX_FDN]; + int16 buffer[MAX_FDN]; + int16 panCoeff[MAX_FDN][2]; + int32 absCoeff[MAX_FDN][2]; // absorption gain & damping Reverberation() { - float k = 1.0f / MAX_FDN; - for (int i = 0; i < MAX_FDN; i++) { - output[i] = 0.0f; - panCoeff[i][0] = (i % 2) ? -k : k; + panCoeff[i][0] = (i % 2) ? -1 : 1; } for (int i = 0; i < MAX_FDN; i += 2) { if ((i / 2) % 2) - panCoeff[i][1] = panCoeff[i + 1][1] = -k; + panCoeff[i][1] = panCoeff[i + 1][1] = -1; else - panCoeff[i][1] = panCoeff[i + 1][1] = k; + panCoeff[i][1] = panCoeff[i + 1][1] = 1; } + clear(); + } + + void clear() { + memset(output, 0, sizeof(output)); memset(df, 0, sizeof(df)); memset(af, 0, sizeof(af)); @@ -115,40 +161,43 @@ namespace Sound { float k = -10.0f / (44100.0f * rt60); for (int i = 0; i < MAX_FDN; i++) { - absCoeff[i][0] = powf(10.0f, FDN[i] * k); - absCoeff[i][1] = 1.0f - (2.0f / (1.0f + powf(absCoeff[i][0], 1.0f - 1.0f / 0.15f))); + float v = powf(10.0f, FDN[i] * k); + absCoeff[i][0] = int32(v * DSP_SCALE); + absCoeff[i][1] = int32((1.0f - (2.0f / (1.0f + powf(v, 1.0f - 1.0f / 0.15f)))) * DSP_SCALE); } }; void process(FrameHI *frames, int count) { - float buffer[MAX_FDN]; + PROFILE_CPU_TIMING(stats.reverb); for (int i = 0; i < count; i++) { FrameHI &frame = frames[i]; - float L = frame.L * (1.0f / 32767.0f); - float R = frame.R * (1.0f / 32767.0f); - float in = (L + R) * 0.5f; - float out = 0.0f; + int32 in = (frame.L + frame.R) / 2; + int32 out = 0; + int32 L = 0; + int32 R = 0; // apply delay & absorption filters for (int j = 0; j < MAX_FDN; j++) { - float k = in + output[j]; - k = df[j].process(k, FDN[j]); - k = af[j].process(k, absCoeff[j][0], absCoeff[j][1]); - out += k * (2.0f / MAX_FDN); + int16 k = clamp(in + output[j], -0x7FFF, 0x7FFF); + df[j].process(k, FDN[j]); + af[j].process(k, absCoeff[j][0], absCoeff[j][1]); buffer[j] = k; + out += k; } + out = out * 2 / MAX_FDN; // apply pan + int16 buf = buffer[MAX_FDN - 1]; for (int j = 0; j < MAX_FDN; j++) { - output[j] = out - buffer[(j + MAX_FDN - 1) % MAX_FDN]; - if (output[j] < EPS) output[j] = 0.0f; - L += buffer[j] * panCoeff[j][0]; - R += buffer[j] * panCoeff[j][1]; + output[j] = max(0, out - buf); + buf = buffer[j]; + L += buf ^ panCoeff[j][0]; + R += buf ^ panCoeff[j][1]; } - frame.L = int(L * 32767.0f); - frame.R = int(R * 32767.0f); + frame.L += L / MAX_FDN; + frame.R += R / MAX_FDN; } } }; @@ -257,20 +306,21 @@ namespace Sound { }; #ifdef DECODE_ADPCM - struct ADPCM : Decoder { // https://wiki.multimedia.cx/?title=Microsoft_ADPCM + struct ADPCM : Decoder // https://wiki.multimedia.cx/?title=Microsoft_ADPCM + { int size, block; - ADPCM(Stream *stream, int channels, int freq, int size, int block) : Decoder(stream, channels, freq), size(size), block(block) {} - - struct Channel { + struct Channel + { int16 c1, c2; int16 delta; int16 sample1; int16 sample2; - int predicate(uint8 nibble) { + int predicate(uint8 nibble) + { static const int table[] = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; - + int8 ns = nibble; if (ns & 8) ns -= 16; @@ -283,15 +333,23 @@ namespace Sound { } } channel[2]; - virtual int decode(Frame *frames, int count) { + ADPCM(Stream *stream, int channels, int freq, int size, int block) : Decoder(stream, channels, freq), size(size), block(block) + { + memset(channel, 0, sizeof(channel)); + } + + virtual int decode(Frame *frames, int count) + { static const int coeff1[] = { 256, 512, 0, 192, 240, 460, 392 }; static const int coeff2[] = { 0, -256, 0, 64, 0, -208, -232 }; int seek = stream->pos - offset; if (seek >= size) return 0; - if (seek % block == 0) { - for (int i = 0; i < channels; i++) { + if (seek % block == 0) + { + for (int i = 0; i < channels; i++) + { uint8 index; stream->read(index); channel[i].c1 = coeff1[index]; @@ -301,26 +359,54 @@ namespace Sound { for (int i = 0; i < channels; i++) stream->read(channel[i].sample1); for (int i = 0; i < channels; i++) stream->read(channel[i].sample2); - if (channels == 1) { - frames[0].L = frames[0].R = channel[0].sample2; - frames[1].L = frames[1].R = channel[0].sample1; + if (channels == 1) + { + if (freq == 22050) + { + ASSERT(count >= 4); + frames[0].L = frames[0].R = + frames[1].L = frames[1].R = channel[0].sample2; + frames[2].L = frames[2].R = + frames[3].L = frames[3].R = channel[0].sample1; + return 4; + } else { + ASSERT(count >= 2); + frames[0].L = frames[0].R = channel[0].sample2; + frames[1].L = frames[1].R = channel[0].sample1; + return 2; + } } else { + ASSERT(freq == 44100); + ASSERT(count >= 2); frames[0].L = channel[0].sample2; frames[0].R = channel[1].sample2; frames[1].L = channel[0].sample1; frames[1].R = channel[1].sample1; + return 2; } - return 2; } else { uint8 value; stream->read(value); uint8 n1 = value >> 4, n2 = value & 0xF; - if (channels == 1) { - frames[0].L = frames[0].R = channel[0].predicate(n1); - frames[1].L = frames[1].R = channel[0].predicate(n2); - return 2; + if (channels == 1) + { + if (freq == 22050) + { + ASSERT(count >= 4); + frames[0].L = frames[0].R = + frames[1].L = frames[1].R = channel[0].predicate(n1); + frames[2].L = frames[2].R = + frames[3].L = frames[3].R = channel[0].predicate(n2); + return 4; + } else { + ASSERT(count >= 2); + frames[0].L = frames[0].R = channel[0].predicate(n1); + frames[1].L = frames[1].R = channel[0].predicate(n2); + return 2; + } } else { + ASSERT(freq == 44100); frames[0].L = channel[0].predicate(n1); frames[0].R = channel[1].predicate(n2); return 1; @@ -386,8 +472,8 @@ namespace Sound { uint8 n; stream->read(n); - int a = getSample(n >> 4, state[0]); - int b = getSample(n & 0x0F, state[1 % channels]); + int a = getSample(n >> 4, state[0]); + int b = getSample(n, state[1 % channels]); Frame frame; if (channels == 2) { @@ -411,7 +497,9 @@ namespace Sound { Frame buffer[28 * 4]; int bufferSize; - VAG(Stream *stream) : Decoder(stream, 1, 11025), s1(0), s2(0), bufferSize(0) {} + VAG(Stream *stream) : Decoder(stream, 1, 11025), s1(0), s2(0), bufferSize(0) { + memset(buffer, 0, sizeof(buffer)); + } void predicate(short value) { int s = (s1 * SPU_POS[pred] + s2 * SPU_NEG[pred]) >> 6; @@ -422,10 +510,10 @@ namespace Sound { void resample(Frame *frames, short value) { predicate(value); - frames[0].L = frames[0].R = s2 + (s1 - s2) / 4; // 0.25 - frames[1].L = frames[1].R = s2 + (s1 - s2) / 2; // 0.50 - frames[2].L = frames[2].R = s2 + (s1 - s2) * 3 / 4; // 0.75 - frames[3].L = frames[3].R = s1; // 1.00 + frames[0].L = frames[0].R = s2 + (s1 - s2) / 4; // 0.25 + frames[1].L = frames[1].R = s2 + (s1 - s2) / 2; // 0.50 + frames[2].L = frames[2].R = s1 - (s1 - s2) / 4; // 0.75 + frames[3].L = frames[3].R = s1; // 1.00 } int processBlock() { @@ -459,7 +547,9 @@ namespace Sound { res += length; if (bufferSize -= length) { // if data remained in buffer, move it to the beginning - memcpy(buffer, &buffer[sizeof(buffer) / sizeof(Frame) - bufferSize], bufferSize * sizeof(Frame)); + for (int i = 0; i < bufferSize; i++) { + buffer[i] = buffer[sizeof(buffer) / sizeof(Frame) - bufferSize + i]; + } break; } } @@ -476,29 +566,34 @@ namespace Sound { #ifdef DECODE_XA // http://problemkaputt.de/psx-spx.htm#cdromxaaudioadpcmcompression - struct XA : Decoder { - uint8 pred, shift, flags; - int s1, s2; - - Frame buffer[18 * 112]; - int pos; + struct XA : Decoder + { + typedef bool (Callback)(void* userData); - struct Group { + struct Group + { uint8 params[16]; uint8 data[112]; - } groups[18]; + }; - Frame prevFrames[2]; + Frame buffer[18 * 112]; + Frame prevFrames[2]; + Frame lerpFrames[32]; - Frame lerpFrames[32]; - uint32 lerpPos; + int32 pos; + int32 lerpPos; + int32 frameIndex; + void* userData; + Callback* nextSectorCallback; - XA(Stream *stream) : Decoder(stream, 1, 11025), s1(0), s2(0), pos(COUNT(buffer)), lerpPos(0) { + XA(void* userData, Callback* nextSectorCallback) : Decoder(NULL, 1, 11025), pos(COUNT(buffer)), lerpPos(0), frameIndex(7), userData(userData), nextSectorCallback(nextSectorCallback) + { memset(prevFrames, 0, sizeof(prevFrames)); memset(lerpFrames, 0, sizeof(lerpFrames)); } - void decode28(Group &group, int block, int channel) { + void decode28(Group &group, int block, int channel) + { int16 *dst = channel ? &buffer[pos].R : &buffer[pos].L; int16 &old = channel ? prevFrames[0].R : prevFrames[0].L; int16 &older = channel ? prevFrames[1].R : prevFrames[1].L; @@ -509,10 +604,10 @@ namespace Sound { int f0 = SPU_POS[filter]; int f1 = SPU_NEG[filter]; - for (int i = 0; i < 28; i++) { + for (int i = 0; i < 28; i++) + { int t = (group.data[block + i * 4] >> (channel * 4)) & 0x0F; - if (t & 8) - t -= 16; + if (t & 8) t -= 16; int s = (t << shift) + ((old * f0 + older * f1 + 32) / 64); s = clamp(s, -32768, 32767); older = old; @@ -522,30 +617,33 @@ namespace Sound { } } - void processBlock() { - if (stream->pos >= stream->size) - return; - - stream->raw(groups, sizeof(groups)); + void processSector(void* data) + { + Group* groups = (Group*)data; pos = 0; - for (int i = 0; i < COUNT(groups); i++) - for (int j = 0; j < 4; j++) { + for (int i = 0; i < 18; i++) + { + for (int j = 0; j < 4; j++) + { decode28(groups[i], j, 0); decode28(groups[i], j, 1); pos += 28; } + } pos = 0; } - void ZigZagOut(Frame &frame, uint8 p, const int16 *LUT) { + void ZigZagOut(Frame &frame, int32 p, const int16 *LUT) + { FrameHI sum; sum.L = sum.R = 0; - for (uint8 i = 1; i < 30; i++) { - Frame &f = lerpFrames[uint8(p - i) & 0x1F]; + for (int32 i = 1; i < 30; i++) + { + Frame &f = lerpFrames[(p - i) & 31]; sum.L += f.L * LUT[i]; sum.R += f.R * LUT[i]; } @@ -555,40 +653,43 @@ namespace Sound { } virtual int decode(Frame *frames, int count) { - if (pos >= COUNT(buffer)) - processBlock(); + #if defined(_OS_PSV) || defined(_OS_PSP) // TODO crash + memset(frames, 0, count * sizeof(Frame)); + return count; + #endif + int i = 0; - ASSERT((int(COUNT(buffer)) - pos) % 6 == 0) - ASSERT(count % 7 == 0) + while (i < count) { + if (frameIndex == 7) { + frameIndex = 0; - count = min(count, (int(COUNT(buffer)) - pos) / 6 * 7); + if (pos >= COUNT(buffer)) { + if (!nextSectorCallback || !nextSectorCallback(userData)) { + break; + } + } - int i = 0; - while (i < count) { - ASSERT(pos < COUNT(buffer)); - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - lerpFrames[lerpPos++ & 0x1F] = buffer[pos++]; - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[0]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[1]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[2]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[3]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[4]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[5]); - ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[6]); - } + ASSERT(pos <= (COUNT(buffer) - 6)); - ASSERT(i == count); + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + lerpFrames[lerpPos++ & 31] = buffer[pos++]; + } else { + ZigZagOut(frames[i++], lerpPos, SPU_ZIG_ZAG[frameIndex++]); + } + } - return count; + return i; } - virtual void replay() { - stream->setPos(0); - s1 = s2 = 0; + virtual void replay() + { + pos = COUNT(buffer); + lerpPos = 0; + frameIndex = 7; } }; #endif @@ -635,13 +736,60 @@ namespace Sound { #endif #ifdef DECODE_OGG + +#ifdef USE_LIBVORBIS + struct OGG : Decoder { + OggVorbis_File vf; + FILE *memFile; + uint8 *data; + + OGG(Stream *stream, int channels) : Decoder(stream, channels, 0) { + char buf[255]; + strcpy(buf, contentDir); + strcat(buf, stream->name); + + data = new uint8[stream->size]; + stream->raw(data, stream->size); + + memFile = fmemopen(data, stream->size, "rb"); + int err = ov_open(memFile, &vf, NULL, 0); + ASSERT(err >= 0); + vorbis_info *info = ov_info(&vf, -1); + this->channels = info->channels; + this->freq = info->rate; + } + + virtual ~OGG() { + ov_clear(&vf); + fclose(memFile); + delete[] data; + } + + virtual int decode(Frame *frames, int count) { + PROFILE_CPU_TIMING(stats.ogg); + int i = 0; + int bytes = count * sizeof(Frame); + while (i < bytes) { + int bitstream; + int res = ov_read(&vf, (char*)frames + i, bytes - i, &bitstream); + if (!res) break; + i += res; + } + return i / sizeof(Frame); + } + + virtual void replay() { + fseek(memFile, 0, SEEK_SET); + ov_open(memFile, &vf, NULL, 0); + } + }; +#else // stb_vorbis struct OGG : Decoder { stb_vorbis *ogg; stb_vorbis_alloc alloc; + uint8 *data; - uint8 *data; - - OGG(Stream *stream, int channels) : Decoder(stream, channels, 0), ogg(NULL) { + OGG(Stream *stream, int channels) : Decoder(stream, channels, 0) { char buf[255]; strcpy(buf, contentDir); strcat(buf, stream->name); @@ -665,6 +813,7 @@ namespace Sound { } virtual int decode(Frame *frames, int count) { + PROFILE_CPU_TIMING(stats.ogg); int i = 0; while (i < count) { int res = stb_vorbis_get_samples_short_interleaved(ogg, channels, (short*)frames + i, (count - i) * 2); @@ -679,15 +828,22 @@ namespace Sound { } }; #endif + +#endif // DECODE_OGG + Core::Mutex lock; - struct Listener { + struct Listener + { mat4 matrix; - } listener[2]; + bool underwater; + }; - int listenersCount; + Listener listener[2]; + int listenersCount; - Listener& getListener(const vec3 &pos) { + Listener& getListener(const vec3 &pos) + { if (listenersCount == 1 || (listener[0].matrix.getPos() - pos).length2() < (listener[1].matrix.getPos() - pos).length2()) return listener[0]; return listener[1]; @@ -705,7 +861,8 @@ namespace Sound { bool flipped; - struct Sample { + struct Sample + { const vec3 *uniquePtr; Decoder *decoder; vec3 pos; @@ -719,18 +876,22 @@ namespace Sound { bool isPaused; bool stopAfterFade; - Sample(Decoder *decoder, float volume, float pitch, int flags, int id) : uniquePtr(NULL), decoder(decoder), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) { + Sample(Decoder *decoder, float volume, float pitch, int flags, int id) : uniquePtr(NULL), decoder(decoder), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) + { isPlaying = decoder != NULL; isPaused = false; + stopAfterFade = true; } - Sample(Stream *stream, const vec3 *pos, float volume, float pitch, int flags, int id) : uniquePtr(pos), decoder(NULL), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) { + Sample(Stream *stream, const vec3 *pos, float volume, float pitch, int flags, int id) : uniquePtr(pos), decoder(NULL), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) + { this->pos = pos ? *pos : vec3(0.0f); - + + #ifndef NO_SOUND uint32 fourcc; stream->read(fourcc); - if (fourcc == FOURCC("RIFF")) { // wav - + if (fourcc == FOURCC("RIFF")) // wav + { struct { uint16 format; uint16 channels; @@ -738,7 +899,7 @@ namespace Sound { uint32 bytesPerSec; uint16 block; uint16 sampleBits; - } waveFmt; + } waveFmt = {}; stream->seek(8); while (stream->pos < stream->size) { @@ -750,95 +911,112 @@ namespace Sound { stream->seek(size - sizeof(waveFmt)); } else if (type == FOURCC("data")) { if (waveFmt.format == 1) decoder = new PCM(stream, waveFmt.channels, waveFmt.samplesPerSec, size, waveFmt.sampleBits); - #ifdef DECODE_ADPCM + #ifdef DECODE_ADPCM if (waveFmt.format == 2) decoder = new ADPCM(stream, waveFmt.channels, waveFmt.samplesPerSec, size, waveFmt.block); - #endif + #endif break; - } else + } else { stream->seek(size); + } } - } - else if (fourcc == FOURCC("OggS")) { // ogg + } else if (fourcc == FOURCC("OggS")) { // ogg stream->seek(-4); #ifdef DECODE_OGG decoder = new OGG(stream, 2); #endif - } - else if (fourcc == FOURCC("ID3\3")) { // mp3 + } else if (fourcc == FOURCC("ID3\3")) { // mp3 #ifdef DECODE_MP3 decoder = new MP3(stream, 2); #endif - } - else if (fourcc == FOURCC("SEGA")) { // Sega Saturn PCM mono signed 8-bit 11025 Hz + } else if (fourcc == FOURCC("SEGA")) { // Sega Saturn PCM mono signed 8-bit 11025 Hz decoder = new PCM(stream, 1, 11025, stream->size, -8); - } - else { // vag + } else { // vag stream->setPos(0); #ifdef DECODE_VAG decoder = new VAG(stream); #endif } + #endif if (!decoder) + { delete stream; + } isPlaying = decoder != NULL; isPaused = false; } - ~Sample() { + ~Sample() + { delete decoder; } - void setVolume(float value, float time) { + void setVolume(float value, float time) + { if (value < 0.0f) { stopAfterFade = true; value = 0.0f; - } else + } else { stopAfterFade = false; + } volumeTarget = value; volumeDelta = volumeTarget - volume; + if (time > 0.0f) + { volumeDelta /= 44100.0f * time; + } } - vec2 getPan() { - if (!(flags & PAN)) - return vec2(1.0f); + vec2 getPan() + { + if (!(flags & PAN)) return vec2(1.0f); + mat4 m = Sound::getListener(pos).matrix; vec3 v = pos - m.offset().xyz(); + vec3 n = v.normal(); - float dist = max(0.0f, 1.0f - (v.length() / SND_FADEOFF_DIST)); - float pan = m.right().xyz().dot(v.normal()); + float dist = max(0.0f, 1.0f - (v.length() / SND_FADEOFF_DIST)); + float pan = m.right().xyz().dot(n); + float facing = (0.5f - m.dir().xyz().dot(n) * 0.5f) * SND_FACING_FACTOR + (1.0f - SND_FACING_FACTOR); - float l = min(1.0f, 1.0f - pan); - float r = min(1.0f, 1.0f + pan); + vec2 value(min(1.0f, 1.0f - pan), + min(1.0f, 1.0f + pan)); - return vec2(l, r) * dist; + return (value * SND_PAN_FACTOR + (1.0f - SND_PAN_FACTOR)) * facing * dist; } - bool render(Frame *frames, int count) { + bool render(Frame *frames, int count) + { if (!isPlaying) return false; - if (isPaused) { + if (isPaused) + { memset(frames, 0, sizeof(Frame) * count); return true; } // decode int i = 0; - while (i < count) { - int res = decoder->decode(&frames[i], count - i); - if (res == 0) { - if (!(flags & LOOP)) { + while (i < count) + { + int ret = decoder->decode(&frames[i], count - i); + + if (ret == 0) + { + if (!(flags & LOOP)) + { isPlaying = false; break; - } else - decoder->replay(); + } + decoder->replay(); } - i += res; + + i += ret; } + // apply volume #define VOL_CONV(x) (1.0f - sqrtf(1.0f - x * x)); @@ -846,19 +1024,27 @@ namespace Sound { float v = volume * m; vec2 pan = getPan(); vec2 vol = pan * VOL_CONV(v); - for (int j = 0; j < i; j++) { - if (volumeDelta != 0.0f) { // increase / decrease channel volume + for (int j = 0; j < i; j++) + { + if (volumeDelta != 0.0f) // increase / decrease channel volume + { volume += volumeDelta; + if ((volumeDelta < 0.0f && volume < volumeTarget) || - (volumeDelta > 0.0f && volume > volumeTarget)) { + (volumeDelta > 0.0f && volume > volumeTarget)) + { volume = volumeTarget; volumeDelta = 0.0f; if (stopAfterFade) + { isPlaying = false; + } } + v = volume * m; vol = pan * VOL_CONV(v); } + frames[j].L = int(frames[j].L * vol.x); frames[j].R = int(frames[j].R * vol.y); } @@ -867,19 +1053,23 @@ namespace Sound { return true; } - void stop() { + void stop() + { isPlaying = false; } - void replay() { + void replay() + { decoder->replay(); } - void pause() { + void pause() + { isPaused = true; } - void resume() { + void resume() + { isPaused = false; } } *channels[SND_CHANNELS_MAX]; @@ -890,9 +1080,13 @@ namespace Sound { FrameHI *result; Frame *buffer; + + // TODO: per listener Filter::Reverberation reverb; + Filter::LowPass lowPass; - void init() { + void init() + { flipped = false; channelsCount = 0; callback = NULL; @@ -903,9 +1097,12 @@ namespace Sound { #endif } - void deinit() { + void deinit() + { for (int i = 0; i < channelsCount; i++) + { delete channels[i]; + } #ifdef DECODE_MP3 mp3_decode_free(); #endif @@ -913,95 +1110,150 @@ namespace Sound { delete[] result; } - void renderChannels(FrameHI *result, int count, bool music) { - int bufSize = count + count / 2; - if (!buffer) buffer = new Frame[bufSize]; // + 50% for pitch + void renderChannels(FrameHI *result, int count, bool music) + { + PROFILE_CPU_TIMING(stats.render[music]); - for (int i = 0; i < channelsCount; i++) { - if (music != ((channels[i]->flags & MUSIC) != 0)) + int bufSize = count + count / 2 + 4; + if (!buffer) { + buffer = new Frame[bufSize]; // + 50% for pitch + } + + for (int i = 0; i < channelsCount; i++) + { + if (music != ((channels[i]->flags & MUSIC) != 0)) { continue; - + } + if (channels[i]->flags & (FLIPPED | UNFLIPPED)) { - if (!(channels[i]->flags & (flipped ? FLIPPED : UNFLIPPED))) + if (!(channels[i]->flags & (flipped ? FLIPPED : UNFLIPPED))) { continue; + } vec3 d = channels[i]->pos - getListener(channels[i]->pos).matrix.getPos(); - if (fabsf(d.x) > SND_FADEOFF_DIST || fabsf(d.y) > SND_FADEOFF_DIST || fabsf(d.z) > SND_FADEOFF_DIST) + if (fabsf(d.x) > SND_FADEOFF_DIST || fabsf(d.y) > SND_FADEOFF_DIST || fabsf(d.z) > SND_FADEOFF_DIST) { continue; + } } - if ((channels[i]->flags & LOOP) && channels[i]->volume < EPS && channels[i]->volumeTarget < EPS) + if ((channels[i]->flags & LOOP) && channels[i]->volume < EPS && channels[i]->volumeTarget < EPS) { continue; + } memset(buffer, 0, sizeof(Frame) * bufSize); - channels[i]->render(buffer, int(count * channels[i]->pitch)); + channels[i]->render(buffer, (int(count * channels[i]->pitch) + 3) / 4 * 4); if (channels[i]->pitch == 1.0f) { // no pitch - for (int j = 0; j < count; j++) { + + for (int j = 0; j < count; j++) + { result[j].L += buffer[j].L; result[j].R += buffer[j].R; } + } else { // has pitch (interpolate values for smooth wave) float t = 0.0f; - for (int j = 0; j < count; j++, t += channels[i]->pitch) { + + for (int j = 0; j < count; j++, t += channels[i]->pitch) + { int idxA = int(t); int idxB = (j == (count - 1)) ? idxA : (idxA + 1); - float k = t - idxA; - result[j].L += int(lerp(buffer[idxA].L, buffer[idxB].L, k)); - result[j].R += int(lerp(buffer[idxA].R, buffer[idxB].R, k)); + int st = int((t - idxA) * DSP_SCALE); + Frame &a = buffer[idxA]; + Frame &b = buffer[idxB]; + + result[j].L += a.L + ((b.L - a.L) * st >> DSP_SCALE_BIT); + result[j].R += a.R + ((b.R - a.R) * st >> DSP_SCALE_BIT); } + } } } - void convFrames(FrameHI *from, Frame *to, int count) { - for (int i = 0; i < count; i++) { + void convFrames(FrameHI *from, Frame *to, int count) + { + for (int i = 0; i < count; i++) + { to[i].L = clamp(from[i].L, -32767, 32767); to[i].R = clamp(from[i].R, -32767, 32767); } } - void fill(Frame *frames, int count) { + void fill(Frame *frames, int count) + { OS_LOCK(lock); + PROFILE_CPU_TIMING(stats.mixer); if (!channelsCount) { - if (result) { + if (result && (Core::settings.audio.music != 0 || Core::settings.audio.sound != 0)) { memset(result, 0, sizeof(FrameHI) * count); + if (Core::settings.audio.reverb) + { reverb.process(result, count); + } + convFrames(result, frames, count); - } else + } else { memset(frames, 0, sizeof(frames[0]) * count); + } return; } - if (!result) result = new FrameHI[count]; + if (!result) + { + result = new FrameHI[count]; + } + memset(result, 0, sizeof(FrameHI) * count); - renderChannels(result, count, false); + if (Core::settings.audio.sound != 0) + { + renderChannels(result, count, false); - if (Core::settings.audio.reverb) - reverb.process(result, count); + if (Core::settings.audio.reverb) + { + if (listener[0].underwater) + { + lowPass.process(result, count, SND_LOWPASS_FREQ); + } + reverb.process(result, count); + } + } - renderChannels(result, count, true); + if (Core::settings.audio.music != 0) + { + renderChannels(result, count, true); + } convFrames(result, frames, count); - for (int i = 0; i < channelsCount; i++) - if (!channels[i]->isPlaying) { - if (callback) callback(channels[i]); + for (int i = 0; i < channelsCount; i++) + { + if (!channels[i]->isPlaying) + { + if (callback) + { + callback(channels[i]); + } + delete channels[i]; channels[i] = channels[--channelsCount]; i--; } + } } - Stream *openCDAudioWAD(const char *name, int index = -1) { + Stream *openCDAudioWAD(const char *name, int index = -1) + { if (!Stream::existsContent(name)) + { return NULL; + } Stream *stream = new Stream(name); - if (stream->size) { + if (stream->size) + { struct Item { char name[260]; int size; @@ -1017,21 +1269,31 @@ namespace Sound { return NULL; } - Stream *openCDAudioMP3(const char *dat, const char *name, int index = -1) { + Stream *openCDAudioMP3(const char *dat, const char *name, int index = -1) + { if (!Stream::existsContent(dat) || !Stream::existsContent(name)) + { return NULL; + } Stream *stream = new Stream(name); return stream; } - Sample* getChannel(int id, const vec3 *pos) { + Sample* getChannel(int id, const vec3 *pos) + { for (int i = 0; i < channelsCount; i++) + { if (channels[i]->id == id && channels[i]->uniquePtr == pos) + { return channels[i]; + } + } return NULL; } - Sample* play(Stream *stream, const vec3 *pos = NULL, float volume = 1.0f, float pitch = 0.0f, int flags = 0, int id = - 1) { + Sample* play(Stream *stream, const vec3 *pos = NULL, float volume = 1.0f, float pitch = 0.0f, int flags = 0, int id = - 1) + { + #ifndef NO_SOUND OS_LOCK(lock); ASSERT(pitch >= 0.0f); @@ -1047,16 +1309,23 @@ namespace Sound { } } - if (flags & (UNIQUE | REPLAY)) { + if (flags & (UNIQUE | REPLAY)) + { Sample *ch = getChannel(id, pos); - if (ch) { + if (ch) + { if (pos) + { ch->pos = *pos; + } + ch->pitch = pitch; if (flags & REPLAY) + { ch->replay(); + } delete stream; return ch; @@ -1064,35 +1333,50 @@ namespace Sound { } if (channelsCount < SND_CHANNELS_MAX) + { return channels[channelsCount++] = new Sample(stream, pos, volume, pitch, flags, id); + } LOG("! no free channels\n"); } + #endif delete stream; return NULL; } - Sample* play(Decoder *decoder) { + Sample* play(Decoder *decoder) + { OS_LOCK(lock); if (channelsCount < SND_CHANNELS_MAX) + { return channels[channelsCount++] = new Sample(decoder, 1.0f, 1.0f, MUSIC, -1); + } return NULL; } - void stop(int id = -1) { + void stop(int id = -1) + { OS_LOCK(lock); for (int i = 0; i < channelsCount; i++) + { if (id == -1 || channels[i]->id == id) + { channels[i]->stop(); + } + } } - void stopAll() { + void stopAll() + { OS_LOCK(lock); + reverb.clear(); for (int i = 0; i < channelsCount; i++) + { delete channels[i]; + } channelsCount = 0; } } diff --git a/src/texture.h b/src/texture.h index fec11340..e102ceb4 100644 --- a/src/texture.h +++ b/src/texture.h @@ -8,14 +8,20 @@ struct Texture : GAPI::Texture { #ifdef SPLIT_BY_TILE - #ifdef _OS_PSP - TR::Tile4 *tiles; - TR::CLUT *cluts; + #if defined(_GAPI_SW) + Tile8 *tiles; - Texture(TR::Tile4 *tiles, int tilesCount, TR::CLUT *cluts, int clutsCount) : GAPI::Texture(256, 256, OPT_PROXY) { + Texture(Tile8 *tiles, int tilesCount) : GAPI::Texture(256, 256, 1, OPT_PROXY) { + this->tiles = tiles; + } + #elif defined(_GAPI_GU) + Tile4 *tiles; + CLUT *cluts; + // TODO: PSP depth ?? + Texture(Tile4 *tiles, int tilesCount, CLUT *cluts, int clutsCount) : GAPI::Texture(256, 256, 1, OPT_PROXY) { #ifdef EDRAM_TEX - this->tiles = (TR::Tile4*)GAPI::allocEDRAM(tilesCount * sizeof(tiles[0])); - this->cluts = (TR::CLUT*)GAPI::allocEDRAM(clutsCount * sizeof(cluts[0])); + this->tiles = (Tile4*)GAPI::allocEDRAM(tilesCount * sizeof(tiles[0])); + this->cluts = (CLUT*)GAPI::allocEDRAM(clutsCount * sizeof(cluts[0])); memcpy(this->cluts, cluts, clutsCount * sizeof(cluts[0])); #ifdef TEX_SWIZZLE for (int i = 0; i < tilesCount; i++) @@ -37,17 +43,19 @@ struct Texture : GAPI::Texture { uint32 *data; }; - Texture(Tile *tiles, int tilesCount) : GAPI::Texture(256, 256, OPT_PROXY) { + Texture(Tile *tiles, int tilesCount) : GAPI::Texture(256, 256, 1, OPT_PROXY) { memset(this->tiles, 0, sizeof(this->tiles)); ASSERT(tilesCount < COUNT(this->tiles)); for (int i = 0; i < tilesCount; i++) - this->tiles[i] = new Texture(tiles[i].width, tiles[i].height, FMT_RGBA, OPT_MIPMAPS, tiles[i].data); + this->tiles[i] = new Texture(tiles[i].width, tiles[i].height, 1, FMT_RGBA, OPT_NEAREST, tiles[i].data); } #endif void bindTile(uint16 tile, uint16 clut) { - #ifdef _OS_PSP + #if defined(_GAPI_SW) + bindTileIndices(tiles + tile); + #elif defined(_GAPI_GU) bindTileCLUT(tiles + tile, cluts + clut); #else tiles[tile]->bind(0); @@ -66,11 +74,9 @@ struct Texture : GAPI::Texture { } #endif - Texture(int width, int height, TexFormat format, uint32 opt = 0, void *data = NULL) : GAPI::Texture(width, height, opt) { -// LOG("create texture %d x %d (%d)\n", width, height, format); - + Texture(int width, int height, int depth, TexFormat format, uint32 opt = 0, void *data = NULL) : GAPI::Texture(width, height, depth, opt) { #ifdef SPLIT_BY_TILE - #ifndef _OS_PSP + #if !defined(_GAPI_SW) && !defined(_GAPI_GU) memset(this->tiles, 0, sizeof(tiles)); #endif #endif @@ -82,9 +88,11 @@ struct Texture : GAPI::Texture { bool filter = (opt & OPT_NEAREST) == 0; bool mipmaps = (opt & OPT_MIPMAPS) != 0; + bool isVolume = (opt & OPT_VOLUME) != 0; - if (format == FMT_SHADOW && !Core::support.shadowSampler) + if (format == FMT_SHADOW && !Core::support.shadowSampler) { format = FMT_DEPTH; + } if (format == FMT_DEPTH) { if (!Core::support.depthTexture) @@ -92,14 +100,14 @@ struct Texture : GAPI::Texture { filter = false; } - if (format == FMT_RGBA_HALF) { + if (format == FMT_RG_HALF) { if (Core::support.texHalf) filter = filter && Core::support.texHalfLinear; else - format = FMT_RGBA_FLOAT; + format = FMT_RG_FLOAT; } - if (format == FMT_RGBA_FLOAT) { + if (format == FMT_RG_FLOAT) { if (Core::support.texFloat) filter = filter && Core::support.texFloatLinear; else @@ -112,19 +120,32 @@ struct Texture : GAPI::Texture { else this->opt |= OPT_NEAREST; + if (isVolume && !Core::support.tex3D) { + this->opt &= ~OPT_VOLUME; + } + + if (this->opt & OPT_PROXY) { + return; + } + init(data); - if (mipmaps) + if (mipmaps && width > Core::support.texMinSize && height > Core::support.texMinSize) generateMipMap(); } virtual ~Texture() { - #ifndef _OS_PSP + #if !defined(_GAPI_SW) && !defined(_GAPI_GU) #ifdef SPLIT_BY_TILE for (int i = 0; i < COUNT(tiles); i++) delete tiles[i]; #endif #endif + + if (this->opt & OPT_PROXY) { + return; + } + deinit(); } @@ -268,33 +289,59 @@ struct Texture : GAPI::Texture { } static uint8* LoadBMP(Stream &stream, uint32 &width, uint32 &height) { - int32 offset; + int32 offset, size; + uint16 bpp; stream.seek(10); stream.read(offset); stream.seek(4); stream.read(width); stream.read(height); + stream.seek(2); + stream.read(bpp); + stream.seek(8); stream.seek(offset - stream.pos); - Color24 *data24 = new Color24[width * height]; - Color32 *data32 = new Color32[width * height]; - stream.raw(data24, width * height * sizeof(Color24)); - - Color32 *dst = data32; - for (uint32 y = 0; y < height; y++) { - Color24 *src = data24 + (height - y - 1) * width; - for (uint32 x = 0; x < width; x++) { - dst->r = src->b; - dst->g = src->g; - dst->b = src->r; - dst->a = 255; - src++; - dst++; + size = width * height * bpp >> 3; + uint8 *data = new uint8[size]; + stream.raw(data, size); + + uint8 *data32 = new uint8[width * height * 8]; + Color32 *dst = (Color32*)data32; + + switch (bpp) { + case 1 : { // monochrome (alpha) + for (uint32 y = 0; y < height; y++) { + uint8 *src = data + (height - y - 1) * (width / 8); + for (uint32 x = 0; x < width / 8; x++) { + for (int i = 7; i >= 0; i--) { + dst->r = dst->g = dst->b = 255; + dst->a = (*src & (1 << i)) != 0 ? 255 : 0; + dst++; + } + src++; + } + } + break; } + case 24 : { // true color + for (uint32 y = 0; y < height; y++) { + Color24 *src = (Color24*)data + (height - y - 1) * width; + for (uint32 x = 0; x < width; x++) { + dst->r = src->b; + dst->g = src->g; + dst->b = src->r; + dst->a = 255; + src++; + dst++; + } + } + break; + } + default : ASSERT(false); } - delete[] data24; + delete[] data; - return (uint8*)data32; + return data32; } #ifdef USE_INFLATE @@ -600,8 +647,12 @@ struct Texture : GAPI::Texture { } static uint8* LoadBIN(Stream &stream, uint32 &width, uint32 &height) { - height = 224; - width = stream.size / height / 2; + if (strstr(stream.name, "224.") || stream.size == 157696) { + height = 224; + } else { + height = 256; + } + width = stream.size / height / 2; uint8 *data = new uint8[stream.size]; stream.raw(data, stream.size); @@ -669,7 +720,7 @@ struct Texture : GAPI::Texture { ((uint32*)data)[y * dw] = ((uint32*)data)[y * dw + dw - 1] = 0xFF000000; } - Texture *tex = new Texture(dw, dh, FMT_RGBA, 0, data); + Texture *tex = new Texture(dw, dh, 1, FMT_RGBA, 0, data); tex->origWidth = width; tex->origHeight = height; @@ -679,16 +730,16 @@ struct Texture : GAPI::Texture { } }; -#define ATLAS_BORDER 8 struct Atlas { + struct Tile { uint16 id; TR::TextureInfo *tex; short4 uv; } *tiles; - typedef void (Callback)(int id, int tileX, int tileY, int atalsWidth, int atlasHeight, Tile &tile, void *userData, void *data); + typedef void (Callback)(Atlas *atlas, int id, int tileX, int tileY, int atalsWidth, int atlasHeight, Tile &tile, void *userData, void *data); struct Node { Node *child[2]; @@ -704,21 +755,21 @@ struct Atlas { delete child[1]; } - Node* insert(const short4 &tile, int tileIndex) { + Node* insert(Atlas *atlas, const short4 &tile, int tileIndex) { ASSERT(tile.x != 0x7FFF); if (child[0] != NULL && child[1] != NULL) { - Node *node = child[0]->insert(tile, tileIndex); + Node *node = child[0]->insert(atlas, tile, tileIndex); if (node != NULL) return node; - return child[1]->insert(tile, tileIndex); + return child[1]->insert(atlas, tile, tileIndex); } else { if (this->tileIndex != -1) return NULL; int16 w = rect.z - rect.x; int16 h = rect.w - rect.y; - int16 tx = (tile.z - tile.x) + ATLAS_BORDER * 2; - int16 ty = (tile.w - tile.y) + ATLAS_BORDER * 2; + int16 tx = (tile.z - tile.x) + atlas->border.x + atlas->border.z; + int16 ty = (tile.w - tile.y) + atlas->border.y + atlas->border.w; if (w < tx || h < ty) return NULL; @@ -739,7 +790,7 @@ struct Atlas { child[1] = new Node(rect.x, rect.y + ty, rect.z, rect.w); } - return child[0]->insert(tile, tileIndex); + return child[0]->insert(atlas, tile, tileIndex); } } } *root; @@ -747,10 +798,11 @@ struct Atlas { int tilesCount; int size; int width, height; + short4 border; void *userData; Callback *callback; - Atlas(int maxTiles, void *userData, Callback *callback) : root(NULL), tilesCount(0), size(0), userData(userData), callback(callback) { + Atlas(int maxTiles, short4 border, void *userData, Callback *callback) : root(NULL), tilesCount(0), size(0), border(border), userData(userData), callback(callback) { tiles = new Tile[maxTiles]; } @@ -774,24 +826,24 @@ struct Atlas { tilesCount++; if (uv.x != 0x7FFF) - size += (uv.z - uv.x + ATLAS_BORDER * 2) * (uv.w - uv.y + ATLAS_BORDER * 2); + size += (uv.z - uv.x + border.x + border.z) * (uv.w - uv.y + border.y + border.w); } bool insertAll(int *indices) { for (int i = 0; i < tilesCount; i++) { int idx = indices[i]; - if (tiles[idx].uv.x != 0x7FFF && !root->insert(tiles[idx].uv, idx)) + if (tiles[idx].uv.x != 0x7FFF && !root->insert(this, tiles[idx].uv, idx)) return false; } return true; } - Texture* pack() { + Texture* pack(uint32 opt) { // TODO TR2 fix CUT2 AV // width = 4096;//nextPow2(int(sqrtf(float(size)))); // height = 2048;//(width * width / 2 > size) ? (width / 2) : width; - width = nextPow2(int(sqrtf(float(size)))); - height = (width * width / 2 > size) ? (width / 2) : width; + width = max(1, nextPow2(int(sqrtf(float(size))))); + height = max(1, (width * width / 2 > size) ? (width / 2) : width); // sort int *indices = new int[tilesCount]; for (int i = 0; i < tilesCount; i++) @@ -805,7 +857,7 @@ struct Atlas { short4 &a = tiles[indices[i - 1]].uv; short4 &b = tiles[indices[i]].uv; //if ((a.z - a.x + ATLAS_BORDER * 2) * (a.w - a.y + ATLAS_BORDER * 2) < (b.z - b.x + ATLAS_BORDER * 2) * (b.w - b.y + ATLAS_BORDER * 2)) { - if ((a.z - a.x + ATLAS_BORDER * 2) < (b.z - b.x + ATLAS_BORDER * 2)) { + if ((a.z - a.x) < (b.z - b.x)) { swap(indices[i - 1], indices[i]); swapped = true; } @@ -828,12 +880,12 @@ struct Atlas { delete[] indices; - uint32 *data = new uint32[width * height]; + AtlasColor *data = new AtlasColor[width * height]; memset(data, 0, width * height * sizeof(data[0])); fill(root, data); fillInstances(); - Texture *atlas = new Texture(width, height, FMT_RGBA, OPT_MIPMAPS, data); + Texture *atlas = new Texture(width, height, 1, ATLAS_FORMAT, opt, data); //Texture::SaveBMP("atlas", (char*)data, width, height); @@ -848,13 +900,13 @@ struct Atlas { fill(node->child[0], data); fill(node->child[1], data); } else - callback(tiles[node->tileIndex].id, node->rect.x, node->rect.y, width, height, tiles[node->tileIndex], userData, data); + callback(this, tiles[node->tileIndex].id, node->rect.x, node->rect.y, width, height, tiles[node->tileIndex], userData, data); } void fillInstances() { for (int i = 0; i < tilesCount; i++) if (tiles[i].uv.x == 0x7FFF) - callback(tiles[i].id, tiles[i].uv.y, 0, width, height, tiles[i], userData, NULL); + callback(this, tiles[i].id, tiles[i].uv.y, 0, width, height, tiles[i], userData, NULL); } }; diff --git a/src/tools/glyphs/glyphs.sln b/src/tools/glyphs/glyphs.sln new file mode 100644 index 00000000..20bb585d --- /dev/null +++ b/src/tools/glyphs/glyphs.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2042 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glyphs", "glyphs.vcxproj", "{3031FCE5-2BF7-4003-9732-9C095E5D07B3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Debug|x64.ActiveCfg = Debug|x64 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Debug|x64.Build.0 = Debug|x64 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Debug|x86.ActiveCfg = Debug|Win32 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Debug|x86.Build.0 = Debug|Win32 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Release|x64.ActiveCfg = Release|x64 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Release|x64.Build.0 = Release|x64 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Release|x86.ActiveCfg = Release|Win32 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9D72AAC3-A13E-4773-962A-1D73EE9AAA89} + EndGlobalSection +EndGlobal diff --git a/src/tools/glyphs/glyphs.vcxproj b/src/tools/glyphs/glyphs.vcxproj new file mode 100644 index 00000000..8352be18 --- /dev/null +++ b/src/tools/glyphs/glyphs.vcxproj @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {3031FCE5-2BF7-4003-9732-9C095E5D07B3} + Win32Proj + glyphs + 10.0.17134.0 + + + + Application + true + v141 + NotSet + + + Application + false + v141 + true + NotSet + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\ + + + true + + + false + ..\..\..\bin\ + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/src/tools/glyphs/main.cpp b/src/tools/glyphs/main.cpp new file mode 100644 index 00000000..66ba1d1b Binary files /dev/null and b/src/tools/glyphs/main.cpp differ diff --git a/src/ui.h b/src/ui.h index b5842dd1..03cf736b 100644 --- a/src/ui.h +++ b/src/ui.h @@ -6,279 +6,14 @@ #include "controller.h" #define PICKUP_SHOW_TIME 5.0f -//#define UI_SHOW_FPS - -enum StringID { - STR_NOT_IMPLEMENTED -// common - , STR_LOADING - , STR_HELP_PRESS - , STR_HELP_TEXT - , STR_LEVEL_STATS - , STR_HINT_SAVING - , STR_HINT_SAVING_DONE - , STR_HINT_SAVING_ERROR - , STR_YES - , STR_NO - , STR_OFF - , STR_ON - , STR_SPLIT - , STR_VR - , STR_QUALITY_LOW - , STR_QUALITY_MEDIUM - , STR_QUALITY_HIGH - , STR_APPLY - , STR_GAMEPAD_1 - , STR_GAMEPAD_2 - , STR_GAMEPAD_3 - , STR_GAMEPAD_4 - , STR_NOT_READY - , STR_PLAYER_1 - , STR_PLAYER_2 - , STR_PRESS_ANY_KEY - , STR_HELP_SELECT - , STR_HELP_BACK -// inventory pages - , STR_OPTION - , STR_INVENTORY - , STR_ITEMS -// save game page - , STR_SAVEGAME - , STR_CURRENT_POSITION -// inventory option - , STR_GAME - , STR_MAP - , STR_COMPASS - , STR_STOPWATCH - , STR_HOME - , STR_DETAIL - , STR_SOUND - , STR_CONTROLS - , STR_GAMMA -// passport menu - , STR_AUTOSAVE - , STR_LOAD_GAME - , STR_START_GAME - , STR_RESTART_LEVEL - , STR_EXIT_TO_TITLE - , STR_EXIT_GAME - , STR_SELECT_LEVEL -// detail options - , STR_SELECT_DETAIL - , STR_OPT_DETAIL_FILTER - , STR_OPT_DETAIL_LIGHTING - , STR_OPT_DETAIL_SHADOWS - , STR_OPT_DETAIL_WATER - , STR_OPT_DETAIL_VSYNC - , STR_OPT_DETAIL_STEREO - , STR_OPT_SIMPLE_ITEMS -// sound options - , STR_SET_VOLUMES - , STR_REVERBERATION -// controls options - , STR_SET_CONTROLS - , STR_OPT_CONTROLS_KEYBOARD - , STR_OPT_CONTROLS_GAMEPAD - , STR_OPT_CONTROLS_VIBRATION - , STR_OPT_CONTROLS_RETARGET - , STR_OPT_CONTROLS_MULTIAIM - // controls - , STR_CTRL_FIRST - , STR_CTRL_LAST = STR_CTRL_FIRST + cMAX - 1 - // keys - , STR_KEY_FIRST - , STR_KEY_LAST = STR_KEY_FIRST + ikZ - // gamepad - , STR_JOY_FIRST - , STR_JOY_LAST = STR_JOY_FIRST + jkMAX - 1 -// inventory items - , STR_UNKNOWN - , STR_EXPLOSIVE - , STR_PISTOLS - , STR_SHOTGUN - , STR_MAGNUMS - , STR_UZIS - , STR_AMMO_PISTOLS - , STR_AMMO_SHOTGUN - , STR_AMMO_MAGNUMS - , STR_AMMO_UZIS - , STR_MEDI_SMALL - , STR_MEDI_BIG - , STR_LEAD_BAR - , STR_SCION -// keys - , STR_KEY - , STR_KEY_SILVER - , STR_KEY_RUSTY - , STR_KEY_GOLD - , STR_KEY_SAPPHIRE - , STR_KEY_NEPTUNE - , STR_KEY_ATLAS - , STR_KEY_DAMOCLES - , STR_KEY_THOR - , STR_KEY_ORNATE -// puzzles - , STR_PUZZLE - , STR_PUZZLE_GOLD_IDOL - , STR_PUZZLE_GOLD_BAR - , STR_PUZZLE_COG - , STR_PUZZLE_FUSE - , STR_PUZZLE_ANKH - , STR_PUZZLE_HORUS - , STR_PUZZLE_ANUBIS - , STR_PUZZLE_SCARAB - , STR_PUZZLE_PYRAMID - - , STR_MAX -}; +#define SUBTITLES_SPEED 0.1f +#define TEXT_LINE_HEIGHT 18 -const char *helpText = - "Start - add second player or restore Lara@" - "H - Show or hide this help@" - "ALT + ENTER - Fullscreen@" - "5 - Save Game@" - "9 - Load Game@" - "C - Look@" - "R - Slow motion@" - "T - Fast motion@" - "Roll - Up + Down@" - "Step Left - Walk + Left@" - "Step Right - Walk + Right@" - "Out of water - Up + Action@" - "Handstand - Up + Walk@" - "Swan dive - Up + Walk + Jump@" - "First Person View - Look + Action@" - "DOZY on - Look + Duck + Action + Jump@" - "DOZY off - Walk"; - -const char *levelStats = - "%s@@@" - "KILLS %d@@" - "PICKUPS %d@@" - "SECRETS %d of %d@@" - "TIME TAKEN %s"; - -const char *STR[STR_MAX] = { - "Not implemented yet!" -// help - , "Loading..." - , "Press H for help" - , helpText - , levelStats - , "Saving game..." - , "Saving done!" - , "SAVING ERROR!" - , "YES" - , "NO" - , "Off" - , "On" - , "Split Screen" - , "VR" - , "Low" - , "Medium" - , "High" - , "Apply" - , "Gamepad 1" - , "Gamepad 2" - , "Gamepad 3" - , "Gamepad 4" - , "Not Ready" - , "Player 1" - , "Player 2" - , "Press Any Key" - , "%s - Select" - , "%s - Go Back" -// inventory pages - , "OPTION" - , "INVENTORY" - , "ITEMS" -// save game page - , "Save Game?" - , "Current Position" -// inventory option - , "Game" - , "Map" - , "Compass" - , "Statistics" - , "Lara's Home" - , "Detail Levels" - , "Sound" - , "Controls" - , "Gamma" -// passport menu - , "Autosave" - , "Load Game" - , "Start Game" - , "Restart Level" - , "Exit to Title" - , "Exit Game" - , "Load Game" -// detail options - , "Select Detail" - , "Filtering" - , "Lighting" - , "Shadows" - , "Water" - , "VSync" - , "Stereo" - , "Simple Items" -// sound options - , "Set Volumes" - , "Reverberation" -// controls options - , "Set Controls" - , "Keyboard" - , "Gamepad" - , "Vibration" - , "Retargeting" - , "Multi-aiming" - // controls - , "Left", "Right", "Up", "Down", "Jump", "Walk", "Action", "Draw Weapon", "Look", "Duck", "Dash", "Roll", "Inventory", "Start" - // keys - , "NONE", "LEFT", "RIGHT", "UP", "DOWN", "SPACE", "TAB", "ENTER", "ESCAPE", "SHIFT", "CTRL", "ALT" - , "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" - , "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" - , "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" - // gamepad - , "NONE", "A", "B", "X", "Y", "L BUMPER", "R BUMPER", "SELECT", "START", "L STICK", "R STICK", "L TRIGGER", "R TRIGGER", "D-LEFT", "D-RIGHT", "D-UP", "D-DOWN" -// inventory items - , "Unknown" - , "Explosive" - , "Pistols" - , "Shotgun" - , "Magnums" - , "Uzis" - , "Pistol Clips" - , "Shotgun Shells" - , "Magnum Clips" - , "Uzi Clips" - , "Small Medi Pack" - , "Large Medi Pack" - , "Lead Bar" - , "Scion" -// keys - , "Key" - , "Silver Key" - , "Rusty Key" - , "Gold Key" - , "Sapphire Key" - , "Neptune Key" - , "Atlas Key" - , "Damocles Key" - , "Thor Key" - , "Ornate Key" -// puzzles - , "Puzzle" - , "Gold Idol" - , "Gold Bar" - , "Machine Cog" - , "Fuse" - , "Ankh" - , "Eye of Horus" - , "Seal of Anubis" - , "Scarab" - , "Pyramid Key" -}; +#if defined(_OS_TNS) + #define UI_SHOW_FPS +#endif + +#include "lang.h" #ifdef _NAPI_SOCKET extern char command[256]; @@ -289,36 +24,69 @@ namespace UI { float width, height; float helpTipTime; float hintTime; + float subsTime; + int subsPartTime; + int subsPartLength; + int subsPos; + int subsLength; + StringID hintStr; + StringID subsStr; bool showHelp; struct PickupItem { float time; vec2 pos; + int playerIndex; int modelIndex; Animation *animation; }; Array pickups; - const static uint8 char_width[110] = { + int advGlyphsStart; + + #define RU_MAP "ÁÃÄÆÇÈËÏÓÔÖ×ØÙÚÛÜÝÞßáâãäæçêëìíïòôö÷øùúûüýþÿ" "i~\"^" + #define RU_GLYPH_COUNT (COUNT(RU_MAP) - 1) + #define RU_GLYPH_START 102 + #define RU_GLYPH_UPPERCASE 20 + #define CHAR_SPR_TILDA 154 + #define CHAR_SPR_I 153 + #define CHAR_SPR_QUOTE 155 + #define CHAR_SPR_AUH 156 + + const static uint8 char_width[110 + RU_GLYPH_COUNT] = { 14, 11, 11, 11, 11, 11, 11, 13, 8, 11, 12, 11, 13, 13, 12, 11, 12, 12, 11, 12, 13, 13, 13, 12, 12, 11, // A-Z 9, 9, 9, 9, 9, 9, 9, 9, 5, 9, 9, 5, 12, 10, 9, 9, 9, 8, 9, 8, 9, 9, 11, 9, 9, 9, // a-z 12, 8, 10, 10, 10, 10, 10, 9, 10, 10, // 0-9 - 5, 5, 5, 11, 9, 10, 8, 6, 6, 7, 7, 3, 11, 8, 13, 16, 9, 4, 12, 12, - 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 16, 14, 14, 14, 16, 16, 16, 16, 16, 12, 14, 8, 8, 8, 8, 8, 8, 8 }; + 5, 5, 5, 11, 9, 7, 8, 6, 0, 7, 7, 3, 8, 8, 13, 7, 9, 4, 12, 12, + 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 16, 14, 14, 14, 16, 16, 16, 16, 16, 12, 14, 8, 8, 8, 8, 8, 8, 8, + // cyrillic + 11, 11, 11, 13, 10, 13, 11, 11, 12, 12, 11, 9, 13, 13, 10, 13, // ÁÃÄÆÇÈËÏÓÔÖ×ØÙÚÛ + 9, 11, 12, 11, 10, 9, 8, 10, 11, 9, 10, 10, 11, 9, 10, 12, // ÜÝÞßáâãäæçêëìíïò + 10, 10, 9, 11, 12, 9, 11, 8, 9, 13, 9, // ôö÷øùúûüýþÿ + // additional + 5, 10, 10, 10 // i~"^ + }; - static const uint8 char_map[102] = { + static const uint8 char_map[102 + 33*2] = { 0, 64, 66, 78, 77, 74, 78, 79, 69, 70, 92, 72, 63, 71, 62, 68, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 73, 73, 66, 74, 75, 65, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 80, 76, 81, 97, 98, 77, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 100, 101, 102, 67, 0, 0, 0, 0, 0, 0, 0 }; + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 100, 101, 102, 67, 0, 0, 0, 0, 0, 0, 0, + // cyrillic + 0, 110, 0, 111, 112, 0, 113, 114, 115, 0, 0, 116, 0, 0, 0, 117, 0, 0, 0, 118, 119, 0, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 0, 130, 131, 132, 133, 0, 134, 135, 0, 0, 136, 137, 138, 139, 0, 140, 0, 0, 141, 0, 142, 0, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + }; - enum Align { aLeft, aRight, aCenter }; + enum Align { aLeft, aRight, aCenter, aCenterV }; inline int charRemap(char c) { - ASSERT(c <= 126); + if (isCyrillic(c)) { + return char_map[RU_GLYPH_START + (c - 'À')]; + } + if (c < 11) return c + 81; if (c < 16) @@ -327,31 +95,164 @@ namespace UI { return char_map[c - 32]; } + inline bool skipChar(char c) { + return c == '~' || c == '\"' || c == '^' || c == '$' || c == '(' || c == ')' || c == '|' || c == '}' || c == '*' || c == '{' || c == '+'; + } + + inline bool upperCase(int index) { + return index < 26 || (index >= 110 && (index < 110 + RU_GLYPH_UPPERCASE)); + } + + void patchGlyphs(TR::Level &level) { + UI::advGlyphsStart = level.spriteTexturesCount; + + // init new sprites array with additional sprites + TR::TextureInfo *newSprites = new TR::TextureInfo[level.spriteTexturesCount + RU_GLYPH_COUNT + JA_GLYPH_COUNT + GR_GLYPH_COUNT + CN_GLYPH_COUNT]; + + // copy original sprites + memcpy(newSprites, level.spriteTextures, sizeof(TR::TextureInfo) * level.spriteTexturesCount); + // append russian glyphs + TR::TextureInfo *glyphSprite = newSprites + level.spriteTexturesCount; + for (int i = 0; i < RU_GLYPH_COUNT; i++) { + int idx = 110 + i; // mapped index + int w = char_width[idx]; + int h = upperCase(idx) ? 13 : 9; + int o = 0; + char c = RU_MAP[i]; + + if (c == 'á' || c == 'ä' || c == '~' || c == '\"') h = 14; + if (c == '^') h = 16; + if (c == 'Ö' || c == 'Ù' || c == 'ö' || c == 'ù') { o = 1; h++; } + if (c == 'ô') { o = 2; h += 2; } + + *glyphSprite++ = TR::TextureInfo(TR::TEX_TYPE_SPRITE, 0, -h + o, w, o, (i % 16) * 16, (i / 16) * 16 + (16 - h), w, h); + } + // append japanese glyphs + for (int i = 0; i < JA_GLYPH_COUNT; i++) { + *glyphSprite++ = TR::TextureInfo(TR::TEX_TYPE_SPRITE, 0, -16, 16, 0, (i % 16) * 16, ((i % 256) / 16) * 16, 16, 16); + } + // append greek glyphs + for (int i = 0; i < GR_GLYPH_COUNT; i++) { + *glyphSprite++ = TR::TextureInfo(TR::TEX_TYPE_SPRITE, 0, -16 + GR_GLYPH_BASE - 1, GR_GLYPH_WIDTH[i], 0 + GR_GLYPH_BASE - 1, (i % 16) * 16, ((i % 256) / 16) * 16, GR_GLYPH_WIDTH[i], 16); + } + // append chinese glyphs + for (int i = 0; i < CN_GLYPH_COUNT; i++) { + *glyphSprite++ = TR::TextureInfo(TR::TEX_TYPE_SPRITE, 0, -16, 16, 0, (i % 16) * 16, ((i % 256) / 16) * 16, 16, 16); + } + + level.spriteTexturesCount += RU_GLYPH_COUNT + JA_GLYPH_COUNT + GR_GLYPH_COUNT + CN_GLYPH_COUNT; + + delete[] level.spriteTextures; + TR::gSpriteTextures = level.spriteTextures = newSprites; + TR::gSpriteTexturesCount = level.spriteTexturesCount; + } + + bool isWideCharStart(char c) { + int lang = Core::settings.audio.language + STR_LANG_EN; + if (lang == STR_LANG_JA || lang == STR_LANG_GR || lang == STR_LANG_CN) + return c == '\x11'; + return false; + } + + uint16 getWideCharGlyph(const char *text) { + uint16 index = uint8(*text) << 8; + index |= uint8(*(text + 1)); + if (index == 0xFFFF) + return index; + index -= 257; + if (index > 255) index--; + return index; + } + + uint16 getWideCharGlyphWidth(uint16 glyph) { + int lang = Core::settings.audio.language + STR_LANG_EN; + if (lang == STR_LANG_JA) { + ASSERT(glyph < JA_GLYPH_COUNT); + return 16; + } + if (lang == STR_LANG_GR) { + ASSERT(glyph < GR_GLYPH_COUNT); + return GR_GLYPH_WIDTH[glyph]; + } + if (lang == STR_LANG_CN) { + ASSERT(glyph < CN_GLYPH_COUNT); + return 16; + } + return 1; + } + + int getWideCharGlyphIndex(uint16 glyph) { + int lang = Core::settings.audio.language + STR_LANG_EN; + glyph += UI::advGlyphsStart + RU_GLYPH_COUNT; + if (lang == STR_LANG_JA) return glyph; glyph += JA_GLYPH_COUNT; + if (lang == STR_LANG_GR) return glyph; glyph += GR_GLYPH_COUNT; + if (lang == STR_LANG_CN) return glyph; glyph += CN_GLYPH_COUNT; + ASSERT(false); + return glyph; + } + short2 getLineSize(const char *text) { - int x = 0; + int x = 0; while (char c = *text++) { - if (c == ' ' || c == '_') { + + if (isWideCharStart(c)) { + uint16 glyph; + while ((glyph = getWideCharGlyph(text)) != 0xFFFF) { + x += getWideCharGlyphWidth(glyph); + text += 2; + } + text += 2; + continue; + } + + if (c == '[') break; + c = remapCyrillic(c); + if (c == '\xBF') c = '?'; + if (c == '\xA1') c = '!'; + + if (skipChar(c) && *text && *text != '@') { + // + } else if (c == ' ' || c == '_') { x += 6; } else if (c == '@') { break; - } else + } else { x += char_width[charRemap(c)] + 1; + } } - return short2(x, 16); + return short2(x, TEXT_LINE_HEIGHT); } short2 getTextSize(const char *text) { int x = 0, w = 0, h = 16; while (char c = *text++) { - if (c == ' ' || c == '_') { + + if (isWideCharStart(c)) { + uint16 glyph; + while ((glyph = getWideCharGlyph(text)) != 0xFFFF) { + x += getWideCharGlyphWidth(glyph); + text += 2; + } + text += 2; + continue; + } + + if (c == '[') break; + c = remapCyrillic(c); + if (c == '\xBF') c = '?'; + if (c == '\xA1') c = '!'; + + if (skipChar(c) && *text && *text != '@') { + // + } else if (c == ' ' || c == '_') { x += 6; } else if (c == '@') { w = max(w, x); - h += 16; + h += TEXT_LINE_HEIGHT; x = 0; - } else + } else x += char_width[charRemap(c)] + 1; } w = max(w, x); @@ -359,36 +260,31 @@ namespace UI { return short2(w, h); } - enum BarType { - BAR_FLASH, - BAR_HEALTH, - BAR_OXYGEN, - BAR_OPTION, - BAR_WHITE, - BAR_MAX, - }; - #ifdef SPLIT_BY_TILE uint16 curTile, curClut; #endif - void updateAspect(float aspect) { + void begin(float aspect) { + ensureLanguage(Core::settings.audio.language); + + #ifdef _OS_WP8 + aspect = 1.0f / aspect; + #endif + height = 480.0f; width = height * aspect; + + Core::mModel.identity(); + Core::mView.identity(); Core::mProj = GAPI::ortho(0.0f, width, height, 0.0f, -128.0f, 127.0f); Core::setViewProj(Core::mView, Core::mProj); - Core::active.shader->setParam(uViewProj, Core::mViewProj); - } - void begin() { Core::setDepthTest(false); + Core::setDepthWrite(false); Core::setBlendMode(bmPremult); Core::setCullMode(cmNone); game->setupBinding(); - Core::mView.identity(); - Core::mModel.identity(); - game->setShader(Core::passGUI, Shader::DEFAULT); Core::setMaterial(1, 1, 1, 1); @@ -404,6 +300,7 @@ namespace UI { Core::setCullMode(cmFront); Core::setBlendMode(bmNone); Core::setDepthTest(true); + Core::setDepthWrite(true); } enum ShadeType { @@ -416,7 +313,7 @@ namespace UI { if (align != aLeft) { int lineWidth = getLineSize(text).x; - if (align == aCenter) + if (align == aCenter || align == aCenterV) return (width - lineWidth) / 2; if (align == aRight) @@ -426,10 +323,10 @@ namespace UI { } void textOut(const vec2 &pos, const char *text, Align align = aLeft, float width = 0, uint8 alpha = 255, ShadeType shade = SHADE_ORANGE, bool isShadow = false) { - if (!text) return; - TR::Level *level = game->getLevel(); + if (!text || level->extra.glyphs == -1) return; + if (shade && !isShadow && ((level->version & TR::VER_TR3))) textOut(pos + vec2(1, 1), text, align, width, alpha, shade, true); @@ -438,12 +335,81 @@ namespace UI { int x = int(pos.x) + getLeftOffset(text, align, int(width)); int y = int(pos.y); + if (align == aCenterV) { + y -= getTextSize(text).y / 2; + } + + Color32 tColor, bColor, sColor; + tColor = bColor = sColor = Color32(0, 0, 0, 255); + + switch (level->version & TR::VER_VERSION) { + case TR::VER_TR1 : sColor = Color32(48, 12, 0, alpha); break; + case TR::VER_TR2 : sColor = Color32(0, 49, 0, alpha); break; + case TR::VER_TR3 : sColor = shade == SHADE_ORANGE ? Color32(48, 12, 0, alpha) : Color32(12, 12, 12, alpha); break; + } + + char lastChar = 0; while (char c = *text++) { + // skip japanese chars + if (isWideCharStart(c)) { + uint16 glyph; + while ((glyph = getWideCharGlyph(text)) != 0xFFFF) { + if (!isShadow) { + int index = getWideCharGlyphIndex(glyph); + mesh->addDynSprite(index, short3(x + 1, 1 + y + 1, 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x - 1, 1 + y - 1, 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x - 1, 1 + y + 1, 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x + 1, 1 + y - 1, 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x - 1, 1 + y , 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x + 1, 1 + y , 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x , 1 + y - 1, 0), false, false, sColor, sColor, true); + mesh->addDynSprite(index, short3(x , 1 + y + 1, 0), false, false, sColor, sColor, true); + + switch (level->version & TR::VER_VERSION) { + case TR::VER_TR1 : + tColor = Color32(252, 236, 136, alpha); + bColor = Color32(160, 104, 56, alpha); + break; + case TR::VER_TR2 : + tColor = Color32(99, 189, 95, alpha); + bColor = Color32( 79, 152, 76, alpha); + break; + case TR::VER_TR3 : + if (shade == SHADE_NONE) { + tColor = Color32(255, 255, 255, alpha); + bColor = Color32(255, 255, 255, alpha); + } else if (shade == SHADE_ORANGE) { + tColor = Color32(255, 190, 90, alpha); + bColor = Color32(140, 50, 10, alpha); + } else if (shade == SHADE_GRAY) { + tColor = Color32(255, 255, 255, alpha); + bColor = Color32(128, 128, 128, alpha); + } + break; + } + + mesh->addDynSprite(index, short3(x, 1 + y, 0), false, false, tColor, bColor, true); + } + x += getWideCharGlyphWidth(glyph); + text += 2; + } + text += 2; + continue; + } + + if (c == '[') break; // subs part end (timing tags) + + bool invertX = false, invertY = false; + int dx = 0, dy = 0; + + c = remapCyrillic(c); + if (c == '\xBF') { c = '?'; invertX = invertY = true; } + if (c == '\xA1') { c = '!'; invertX = invertY = true; } if (c == '@') { x = int(pos.x) + getLeftOffset(text, align, int(width)); - y += 16; + y += TEXT_LINE_HEIGHT; continue; } @@ -452,21 +418,29 @@ namespace UI { continue; } - int frame = charRemap(c); + char charFrame = c; + if (charFrame == '\xBF') charFrame = '?'; + if (charFrame == '\xA1') charFrame = '!'; + if (charFrame == '|') charFrame = ','; + if (charFrame == '*') charFrame = '.'; + if (charFrame == '{') charFrame = '('; - if (frame >= level->spriteSequences[seq].sCount) - continue; + int frame = charRemap(charFrame); + if (c == '+' && *text && *text != '@') frame = CHAR_SPR_TILDA; + if (c == 'i' && skipChar(lastChar)) frame = CHAR_SPR_I; + if (c == '\"') frame = CHAR_SPR_QUOTE; + if (c == '^') frame = CHAR_SPR_AUH; + lastChar = c; - Color32 tColor, bColor; if (isShadow) { - tColor = bColor = Color32(0, 0, 0, alpha); + tColor = bColor = sColor; } else { tColor = bColor = Color32(255, 255, 255, alpha); if (shade && ((level->version & TR::VER_TR3))) { if (shade == SHADE_ORANGE) { tColor = Color32(255, 190, 90, alpha); - bColor = Color32(140, 50, 10, alpha); + bColor = Color32(140, 50, 10, alpha); } if (shade == SHADE_GRAY) { tColor = Color32(255, 255, 255, alpha); @@ -475,9 +449,71 @@ namespace UI { } } - mesh->addDynSprite(level->spriteSequences[seq].sStart + frame, short3(x, y, 0), tColor, bColor, true); + bool isSkipChar = skipChar(c) && *text && *text != '@'; + + if (isSkipChar) { + int idx = charRemap(remapCyrillic(*text)); + bool isUppderCase = upperCase(idx); + + if (c == '{') { + invertY = true; + dx = isUppderCase ? 2 : 0; + dy = isUppderCase ? -17 : -13; + } else if (c == '*') { + dx = (char_width[idx] - char_width[frame]) / 2; + dy = isUppderCase ? -13 : -9; + } else if (c == '}') { + frame = idx; + text++; + isSkipChar = false; + } else if (c == '|') { + dy = 2; + invertX = true; + if (isUppderCase) { + dx = (char_width[idx] - char_width[frame]); + } else { + dx = (char_width[idx] - char_width[frame]) / 2; + } + } else { + dx = (char_width[idx] - char_width[frame]) / 2 - 1; + if (isUppderCase) { // if next char is uppercase + dy -= 4; + } + } + + if (c == '(' && idx == 34) { // i with cap, just align it %) + dx -= 1; + } + } + + if (invertX) dx += char_width[frame]; + if (invertY) dy -= 10; + int ax = 1; + + if (c == '}') { + ax += 2; + x += 2; + int ox = frame < 26 ? 1 : 0; + int line = charRemap(')'); + mesh->addDynSprite(level->spriteSequences[seq].sStart + line, short3(x + ox + 1, y + 4, 0), false, false, tColor, bColor, true); + mesh->addDynSprite(level->spriteSequences[seq].sStart + line, short3(x + ox - 3, y + 7, 0), false, false, tColor, bColor, true); + } - x += char_width[frame] + 1; + int spriteIndex = frame; + if (frame < level->spriteSequences[seq].sCount) { + spriteIndex += level->spriteSequences[seq].sStart; + } else { + spriteIndex += advGlyphsStart - 110; + } + + if (spriteIndex >= level->spriteTexturesCount) + continue; + + mesh->addDynSprite(spriteIndex, short3(x + dx, y + dy, 0), invertX, invertY, tColor, bColor, true); + + if (!isSkipChar) { + x += char_width[frame] + ax; + } } } @@ -487,6 +523,10 @@ namespace UI { void specOut(const vec2 &pos, char specChar) { TR::Level *level = game->getLevel(); + + if (level->extra.glyphs == -1) + return; + MeshBuilder *mesh = game->getMesh(); int seq = level->extra.glyphs; @@ -494,16 +534,18 @@ namespace UI { if (specChar >= level->spriteSequences[seq].sCount) return; - mesh->addDynSprite(level->spriteSequences[seq].sStart + specChar, short3(int16(pos.x), int16(pos.y), 0), COLOR_WHITE, COLOR_WHITE, true); + mesh->addDynSprite(level->spriteSequences[seq].sStart + specChar, short3(int16(pos.x), int16(pos.y), 0), false, false, COLOR_WHITE, COLOR_WHITE, true); } #undef MAX_CHARS void init(IGame *game) { + ensureLanguage(Core::settings.audio.language); UI::game = game; showHelp = false; helpTipTime = 5.0f; - hintTime = 0.0f; + hintTime = subsTime = 0.0f; + pickups.clear(); } void deinit() { @@ -513,9 +555,82 @@ namespace UI { pickups.clear(); } + void showHint(StringID str, float time) { + hintStr = str; + hintTime = time; + } + + void subsGetNextPart() { + const char *subs = STR[subsStr]; + + subsPos += subsPartLength; + + if (subsPos >= subsLength) { + subsTime = 0.0f; + subsStr = STR_EMPTY; + return; + } + + for (int i = subsPos; i < subsLength; i++) { + + if (isWideCharStart(subs[i])) { + while (getWideCharGlyph(subs + i + 1) != 0xFFFF) { + i += 2; + } + i += 2; + continue; + } + + if (subs[i] == '[') { + for (int j = i + 1; j < subsLength; j++) { + if (subs[j] == ']') { + char buf[32]; + memcpy(buf, subs + i + 1, j - i - 1); + buf[j - i - 1] = 0; + + int time = atoi(buf); + + subsTime += (time - subsPartTime) / 1000.0f; + subsPartTime = time; + subsPartLength = j - subsPos + 1; + return; + } + } + } + } + + subsPartLength = subsLength - subsPos; + subsTime = subsPartLength * SUBTITLES_SPEED; + } + + void showSubs(StringID str) { + subsStr = str; + subsTime = 0.0f; + + if (str == STR_EMPTY || !Core::settings.audio.subtitles) { + subsTime = 0.0f; + return; + } + + subsLength = int(strlen(STR[str])); + subsPos = 0; + subsPartTime = 0; + subsPartLength = 0; + + subsGetNextPart(); + } + void update() { - if (hintTime > 0.0f) + if (hintTime > 0.0f) { hintTime = max(0.0f, hintTime - Core::deltaTime); + } + + if (subsTime > 0.0f) { + subsTime -= Core::deltaTime; + if (subsTime <= 0.0f) { + subsGetNextPart(); + } + } if (Input::down[ikH]) { Input::down[ikH] = false; @@ -525,6 +640,11 @@ namespace UI { if (helpTipTime > 0.0f) helpTipTime -= Core::deltaTime; + float w = UI::width; + if (game->getLara(1)) { + w *= 0.5f; + } + int i = 0; while (i < pickups.length) { PickupItem &item = pickups[i]; @@ -533,7 +653,7 @@ namespace UI { delete item.animation; pickups.remove(i); } else { - vec2 target = vec2(UI::width - 48.0f - Core::eye * 16.0f - (i % 4) * 96.0f, UI::height - 48.0f - (i / 4) * 96.0f); + vec2 target = vec2(w - 48.0f - (i % 4) * 96.0f, UI::height - 48.0f - (i / 4) * 96.0f); item.pos = item.pos.lerp(target, Core::deltaTime * 5.0f); i++; } @@ -546,27 +666,28 @@ namespace UI { m.translate(vec3(pos.x, pos.y, 0.0)); m.scale(vec3(scale.x, scale.y, 1.0)); Core::active.shader->setParam(uViewProj, m); - Core::setMaterial(1.0f, 1.0f, 1.0f, active ? 0.7f : 0.5f); + float a = active ? 0.7f : 0.5f; + Core::setMaterial(a, a, a, a); game->getMesh()->renderCircle(); } void renderTouch() { - game->setupBinding(); - if (Input::touchTimerVis <= 0.0f) return; + Core::whiteTex->bind(sDiffuse); + Core::setDepthTest(false); - Core::setBlendMode(bmAlpha); + Core::setBlendMode(bmPremult); Core::setCullMode(cmNone); - Core::mViewProj = GAPI::ortho(0.0f, float(Core::width), float(Core::height), 0.0f, 0.0f, 1.0f); + Core::mViewProj = GAPI::ortho(0.0f, float(Input::getTouchWidth()), float(Input::getTouchHeight()), 0.0f, 0.0f, 1.0f); game->setShader(Core::passGUI, Shader::DEFAULT); - float offset = Core::height * 0.25f; + float offset = Input::getTouchHeight() * 0.25f; if (Input::btnEnable[Input::bMove]) { - vec2 pos = vec2(offset * 0.7f, Core::height - offset * 0.7f) + vec2(-cosf(-PI * 3.0f / 4.0f), sinf(-PI * 3.0f / 4.0f)) * offset; + vec2 pos = vec2(offset * 0.7f, Input::getTouchHeight() - offset * 0.7f) + vec2(-cosf(-PI * 3.0f / 4.0f), sinf(-PI * 3.0f / 4.0f)) * offset; if (Input::down[Input::touchKey[Input::zMove]]) { Input::Touch &t = Input::touch[Input::touchKey[Input::zMove] - ikTouchA]; renderControl(t.pos, Input::btnRadius, true); @@ -584,38 +705,35 @@ namespace UI { Core::setDepthTest(true); } - void renderBar(BarType type, const vec2 &pos, const vec2 &size, float value, uint32 fgColor = 0xFFFFFFFF, uint32 bgColor = 0x80000000, uint32 brColor1 = 0xFF4C504C, uint32 brColor2 = 0xFF748474, uint32 fgColor2 = 0) { + void renderBar(CommonTexType type, const vec2 &pos, const vec2 &size, float value, uint32 fgColor = 0xFFFFFFFF, uint32 bgColor = 0x80000000, uint32 brColor1 = 0xFF4C504C, uint32 brColor2 = 0xFF748474, uint32 fgColor2 = 0) { MeshBuilder *mesh = game->getMesh(); if (brColor1 != 0 || brColor2 != 0) mesh->addDynFrame(pos - 2.0f, size + 4.0f, brColor1, brColor2); if (bgColor != 0) - mesh->addDynBar(whiteTile, pos - 1.0f, size + 2.0f, bgColor); + mesh->addDynBar(whiteSprite, pos - 1.0f, size + 2.0f, bgColor); if ((fgColor != 0 || fgColor2 != 0) && value > 0.0f) - mesh->addDynBar(barTile[type], pos, vec2(size.x * value, size.y), fgColor, fgColor2); - } - - void showHint(StringID str, float time) { - hintStr = str; - hintTime = time; + mesh->addDynBar(CommonTex[type], pos, vec2(size.x * value, size.y), fgColor, fgColor2); } void renderHelp() { #ifdef _NAPI_SOCKET textOut(vec2(16, height - 32), command, aLeft, width - 32, 255, UI::SHADE_GRAY); #endif - // TODO: Core::eye offset if (hintTime > 0.0f) { textOut(vec2(16, 32), hintStr, aLeft, width - 32, 255, UI::SHADE_GRAY); } + #if defined(_OS_WEB) || defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_MAC) || defined(_OS_RPI) if (showHelp) { textOut(vec2(32, 32), STR_HELP_TEXT, aLeft, width - 32, 255, UI::SHADE_GRAY); } else { if (helpTipTime > 0.0f) { - textOut(vec2(0, height - 32), STR_HELP_PRESS, aCenter, width, 255, UI::SHADE_ORANGE); + textOut(vec2(0, height - 16), STR_HELP_PRESS, aCenter, width, 255, UI::SHADE_ORANGE); } } + #endif + #ifdef UI_SHOW_FPS char buf[256]; sprintf(buf, "%d", Core::stats.fps); @@ -623,27 +741,39 @@ namespace UI { #endif } - void addPickup(TR::Entity::Type type, const vec2 &pos) { + void renderSubs() { + if (!Core::settings.audio.subtitles) return; + + if (subsTime > 0.0f) { + const char *subs = STR[subsStr] + subsPos; + textOut(vec2(16, height - 48) + vec2(1, 1), subs, aCenterV, width - 32, 255, UI::SHADE_GRAY, true); + textOut(vec2(16, height - 48), subs, aCenterV, width - 32, 255, UI::SHADE_GRAY); + } + } + + void addPickup(TR::Entity::Type type, int playerIndex, const vec2 &pos) { TR::Level *level = game->getLevel(); PickupItem item; - item.time = PICKUP_SHOW_TIME; - item.pos = pos; - item.modelIndex = level->getModelIndex(TR::Level::convToInv(type)); + item.time = PICKUP_SHOW_TIME; + item.pos = pos; + item.playerIndex = playerIndex; + item.modelIndex = level->getModelIndex(TR::Level::convToInv(type)); if (item.modelIndex <= 0) return; - item.animation = new Animation(level, &level->models[item.modelIndex - 1]); + item.animation = new Animation(level, &level->models[item.modelIndex - 1]); pickups.push(item); } void setupInventoryShading(vec3 offset) { Core::mView.identity(); - Core::mProj = GAPI::perspective(1.0f, 1.0f, 1.0f, 2.0f); + Core::mProj = GAPI::perspective(1.0f, 1.0f, 1.0f, 2.0f, 0.0f); Core::mLightProj = Core::mProj * Core::mView; game->setShader(Core::passCompose, Shader::ENTITY, false, false); Core::setMaterial(1.0f, 0.0f, 0.0f, 1.0f); + Core::setFog(FOG_NONE); vec4 o = vec4(offset, 0.0f); @@ -674,19 +804,23 @@ namespace UI { mat4 mView = Core::mView; Core::mView.scale(vec3(0.5f)); + //Core::mView.translate(vec3(-Core::eye * CAM_EYE_SEPARATION, 0.0f, 0.0f)); Core::setViewProj(Core::mView, Core::mProj); vec3 lightOffset = vec3(UI::width - 64.0f, UI::height - 64.0f, 2048.0f); setupInventoryShading(lightOffset); - Basis joints[MAX_SPHERES]; + Basis joints[MAX_JOINTS]; Core::setDepthTest(true); + Core::setDepthWrite(true); - MeshBuilder *mesh = game->getMesh(); for (int i = 0; i < pickups.length; i++) { const PickupItem &item = pickups[i]; + if (item.playerIndex != game->getCamera()->cameraIndex) + continue; + float offset = 0.0f; if (item.time < 1.0f) { offset = 1.0f - item.time; @@ -702,7 +836,6 @@ namespace UI { matrix.rotateY(item.time * PI * 0.5f); item.animation->getJoints(matrix, -1, true, joints); - Core::setBasis(joints, item.animation->model->mCount); float alpha = 1.0f - min(PICKUP_SHOW_TIME - item.time, 1.0f); alpha *= alpha; @@ -711,10 +844,11 @@ namespace UI { Core::setMaterial(1.0f, 0.0f, 0.0f, alpha); - mesh->renderModelFull(item.modelIndex - 1); + game->renderModelFull(item.modelIndex - 1, false, joints); } Core::setDepthTest(false); + Core::setDepthWrite(false); Core::setViewProj(mView, Core::mProj); game->setShader(Core::passGUI, Shader::DEFAULT); @@ -725,4 +859,4 @@ namespace UI { } }; -#endif \ No newline at end of file +#endif diff --git a/src/utils.h b/src/utils.h index bd7da34d..b85bbf5a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -8,29 +8,50 @@ //#define TEST_SLOW_FIO #ifdef _DEBUG - #if defined(_OS_LINUX) || defined(_OS_RPI) || defined(_OS_CLOVER) + #if defined(_OS_WP8) + #define debugBreak() /* TODO */ + #elif defined(_OS_LINUX) || defined(_OS_RPI) || defined(_OS_CLOVER) #define debugBreak() raise(SIGTRAP); + #elif defined(_OS_3DS) + #define debugBreak() svcBreak(USERBREAK_ASSERT); #else #define debugBreak() _asm { int 3 } #endif - #define ASSERT(expr) if (expr) {} else { LOG("ASSERT:\n %s:%d\n %s => %s\n", __FILE__, __LINE__, __FUNCTION__, #expr); debugBreak(); } + #define ASSERT(expr) if (!(expr)) { LOG("ASSERT:\n %s:%d\n %s => %s\n", __FILE__, __LINE__, __FUNCTION__, #expr); debugBreak(); } #define ASSERTV(expr) ASSERT(expr) #ifndef _OS_ANDROID - #define LOG(...) printf(__VA_ARGS__) + #define LOG printf + #endif + + #if defined(_OS_XBOX) || defined(_OS_XB1) || defined(_OS_WP8) + #define MAX_LOG_LENGTH 1024 + + #undef LOG + void LOG(const char *format, ...) { + char str[MAX_LOG_LENGTH]; + va_list arglist; + va_start(arglist, format); + _vsnprintf(str, MAX_LOG_LENGTH, format, arglist); + va_end(arglist); + OutputDebugStringA(str); + } #endif #else - //#define ASSERT(expr) if (expr) {} else { LOG("ASSERT:\n %s:%d\n %s => %s\n", __FILE__, __LINE__, __FUNCTION__, #expr); } + #define ASSERT(expr) #define ASSERTV(expr) (expr) ? 1 : 0 - #ifdef _OS_LINUX - #define LOG(...) printf(__VA_ARGS__); fflush(stdout) + #ifdef PROFILE + #ifdef _OS_LINUX + #define LOG(...) printf(__VA_ARGS__); fflush(stdout) + #else + #define LOG(...) printf(__VA_ARGS__) + #endif #else - #define LOG(...) printf(__VA_ARGS__) - // #define LOG(...) 0 + #define LOG printf #endif #endif @@ -45,6 +66,7 @@ #define LOG(...) __android_log_print(ANDROID_LOG_INFO,"OpenLara",__VA_ARGS__) #endif + #ifdef _OS_PSP extern "C" { // pspmath.h @@ -69,8 +91,9 @@ #define DECL_STR(v) #v, #define EPS FLT_EPSILON -#define INF INFINITY +#define INF FLT_MAX #define PI 3.14159265358979323846f +#define PIH (PI * 0.5f) #define PI2 (PI * 2.0f) #define DEG2RAD (PI / 180.0f) #define RAD2DEG (180.0f / PI) @@ -80,7 +103,7 @@ #define COS60 0.50000000000f #define SQR(x) ((x)*(x)) -#define randf() ((float)rand()/RAND_MAX) +#define randf() (float(rand())/float(RAND_MAX)) typedef signed char int8; typedef signed short int16; @@ -91,8 +114,10 @@ typedef unsigned short uint16; typedef unsigned int uint32; typedef unsigned long long uint64; -#define FOURCC(str) uint32(((uint8*)(str))[0] | (((uint8*)(str))[1] << 8) | (((uint8*)(str))[2] << 16) | (((uint8*)(str))[3] << 24) ) +#define FOURCC(str) uint32( ((uint8*)(str))[0] | (((uint8*)(str))[1] << 8) | (((uint8*)(str))[2] << 16) | (((uint8*)(str))[3] << 24) ) +#define TWOCC(str) uint32( ((uint8*)(str))[0] | (((uint8*)(str))[1] << 8) ) +#define ALIGNADDR(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) #define COUNT(arr) int(sizeof(arr) / sizeof(arr[0])) #define OFFSETOF(T, E) ((size_t)&(((T*)0)->E)) #define TEST_BIT(arr, bit) ((arr[bit / 32] >> (bit % 32)) & 1) @@ -123,8 +148,8 @@ inline const T& clamp(const T &x, const T &a, const T &b) { } template -inline const int sign(const T &x) { - return x > 0 ? 1 : (x < 0 ? -1 : 0); +inline const T sign(const T &x) { + return (T)(x > 0 ? 1 : (x < 0 ? -1 : 0)); } template @@ -157,8 +182,8 @@ float normalizeAngle(float angle) { return angle; } -int angleQuadrant(float angle) { - return int(normalizeAngle(angle + PI * 0.25f) / (PI * 0.5f)); +int angleQuadrant(float angle, float offset) { + return int(normalizeAngle(angle + PI * offset) / (PI * 0.5f)); } float decrease(float delta, float &value, float &speed) { @@ -171,20 +196,24 @@ float decrease(float delta, float &value, float &speed) { return 0.0f; } -float hermite(float x) { - return x * x * (3.0f - 2.0f * x); +inline float hermite(float x) { + return x * x * (3 - 2 * x); +} + +inline float quintic(float x) { + return x * x * x * (x * (x * 6 - 15) + 10); } -float lerp(float a, float b, float t) { +inline float lerp(float a, float b, float t) { if (t <= 0.0f) return a; if (t >= 1.0f) return b; - return a + (b - a) * t; + return a + (b - a) * t; } float lerpAngle(float a, float b, float t) { if (t <= 0.0f) return a; if (t >= 1.0f) return b; - return a + shortAngle(a, b) * t; + return a + shortAngle(a, b) * t; } int nextPow2(uint32 x) { @@ -234,6 +263,108 @@ void sort(T *items, int count) { qsort(items, 0, count - 1); } + +namespace Noise { // based on https://github.com/Auburns/FastNoise + int seed; + + uint8 m_perm[512]; + uint8 m_perm12[512]; + + const float GRAD_X[] = { 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0 }; + const float GRAD_Y[] = { 1, 1, -1, -1, 0, 0, 0, 0, 1, -1, 1, -1 }; + const float GRAD_Z[] = { 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, -1 }; + + uint8 index(int x, int y, int z) { + return m_perm12[(x & 0xff) + m_perm[(y & 0xff) + m_perm[(z & 0xff)]]]; + } + + float noise(int x, int y, int z, float xd, float yd, float zd) { + uint8 lutPos = index(x, y, z); + return xd * GRAD_X[lutPos] + yd * GRAD_Y[lutPos] + zd * GRAD_Z[lutPos]; + } + + void setSeed(int seed) { + Noise::seed = seed; + srand(seed); + + for (int i = 0; i < 256; i++) + m_perm[i] = i; + + for (int j = 0; j < 256; j++) { + int k = (rand() % (256 - j)) + j; + int p = m_perm[j]; + m_perm[j] = m_perm[j + 256] = m_perm[k]; + m_perm[k] = p; + m_perm12[j] = m_perm12[j + 256] = m_perm[j] % 12; + } + } + + float value(float x, float y, float z, int size) { + x *= size; + y *= size; + z *= size; + + int x0 = (int)x; + int y0 = (int)y; + int z0 = (int)z; + int x1 = (x0 + 1) % size; + int y1 = (y0 + 1) % size; + int z1 = (z0 + 1) % size; + + float dx0 = x - x0; + float dy0 = y - y0; + float dz0 = z - z0; + float dx1 = dx0 - 1; + float dy1 = dy0 - 1; + float dz1 = dz0 - 1; + + float fx = quintic(dx0); + float fy = quintic(dy0); + float fz = quintic(dz0); + + return lerp(lerp(lerp(noise(x0, y0, z0, dx0, dy0, dz0), noise(x1, y0, z0, dx1, dy0, dz0), fx), + lerp(noise(x0, y1, z0, dx0, dy1, dz0), noise(x1, y1, z0, dx1, dy1, dz0), fx), fy), + lerp(lerp(noise(x0, y0, z1, dx0, dy0, dz1), noise(x1, y0, z1, dx1, dy0, dz1), fx), + lerp(noise(x0, y1, z1, dx0, dy1, dz1), noise(x1, y1, z1, dx1, dy1, dz1), fx), fy), fz); + } + + uint8* generate(uint32 seed, int size, int octaves, int frequency, float amplitude) { + setSeed(seed); + + float *out = new float[size * size * size]; + memset(out, 0, size * size * size * sizeof(float)); + + float isize = 1.0f / size; + + for (int j = 0; j < octaves; j++) { + float *ptr = out; + + for (int z = 0; z < size; z++) { + float iz = z * isize; + for (int y = 0; y < size; y++) { + float iy = y * isize; + for (int x = 0; x < size; x++) { + float ix = x * isize; + *ptr++ += value(ix, iy, iz, frequency) * amplitude; + } + } + } + + frequency *= 2; + amplitude *= 0.5f; + } + + uint8 *dst = new uint8[size * size * size]; + for (int i = 0; i < size * size * size; i++) { + dst[i] = clamp(int((out[i] * 0.5f + 0.5f) * 255.0f), 0, 255); + } + + delete[] out; + + return dst; + } +} + struct vec2 { float x, y; vec2() {} @@ -282,7 +413,7 @@ struct vec2 { vec2 lerp(const vec2 &v, const float t) const { if (t <= 0.0f) return *this; if (t >= 1.0f) return v; - return *this + (v - *this) * t; + return *this + (v - *this) * t; } }; @@ -342,7 +473,7 @@ struct vec3 { vec3 lerp(const vec3 &v, const float t) const { if (t <= 0.0f) return *this; if (t >= 1.0f) return v; - return *this + (v - *this) * t; + return *this + (v - *this) * t; } vec3 rotateY(float angle) const { @@ -362,6 +493,7 @@ struct vec3 { struct vec4 { float x, y, z, w; + vec2& xy() const { return *((vec2*)&x); } vec3& xyz() const { return *((vec3*)&x); } vec4() {} @@ -371,6 +503,8 @@ struct vec4 { vec4(const vec3 &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) {} vec4(const vec2 &xy, const vec2 &zw) : x(xy.x), y(xy.y), z(zw.x), w(zw.y) {} + inline float& operator [] (int index) const { ASSERT(index >= 0 && index <= 3); return ((float*)this)[index]; } + inline bool operator == (const vec4 &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } inline bool operator != (const vec4 &v) const { return !(*this == v); } @@ -379,10 +513,12 @@ struct vec4 { vec4 operator * (const vec4 &v) const { return vec4(x*v.x, y*v.y, z*v.z, w*v.w); } vec4& operator *= (const vec4 &v) { x*=v.x; y*=v.y; z*=v.z; w*=v.w; return *this; } + float dot(const vec4 &v) const { return x * v.x + y * v.y + z * v.z + w * v.w; } + vec4 lerp(const vec4 &v, const float t) const { if (t <= 0.0f) return *this; if (t >= 1.0f) return v; - return *this + (v - *this) * t; + return *this + (v - *this) * t; } }; @@ -403,20 +539,23 @@ struct quat { w = c; } + inline bool operator == (const quat &q) const { return x == q.x && y == q.y && z == q.z && w == q.w; } + inline bool operator != (const quat &v) const { return !(*this == v); } + quat operator - () const { return quat(-x, -y, -z, -w); } - quat operator + (const quat &q) const { - return quat(x + q.x, y + q.y, z + q.z, w + q.w); + quat operator + (const quat &q) const { + return quat(x + q.x, y + q.y, z + q.z, w + q.w); } - quat operator - (const quat &q) const { - return quat(x - q.x, y - q.y, z - q.z, w - q.w); + quat operator - (const quat &q) const { + return quat(x - q.x, y - q.y, z - q.z, w - q.w); } - quat operator * (const float s) const { - return quat(x * s, y * s, z * s, w * s); + quat operator * (const float s) const { + return quat(x * s, y * s, z * s, w * s); } quat operator * (const quat &q) const { @@ -427,19 +566,18 @@ struct quat { } vec3 operator * (const vec3 &v) const { - //return v + xyz.cross(xyz.cross(v) + v * w) * 2.0f; - return (*this * quat(v.x, v.y, v.z, 0) * inverse()).xyz(); + return v + xyz().cross(xyz().cross(v) + v * w) * 2.0f; } float dot(const quat &q) const { return x * q.x + y * q.y + z * q.z + w * q.w; } - float length2() const { - return dot(*this); + float length2() const { + return dot(*this); } - float length() const { + float length() const { return sqrtf(length2()); } @@ -463,7 +601,7 @@ struct quat { if (t <= 0.0f) return *this; if (t >= 1.0f) return q; - return dot(q) < 0 ? (*this - (q + *this) * t) : + return dot(q) < 0 ? (*this - (q + *this) * t) : (*this + (q - *this) * t); } @@ -499,6 +637,7 @@ struct mat4 { enum ProjRange { PROJ_NEG_POS, + PROJ_NEG_ZERO, PROJ_ZERO_POS, }; @@ -517,7 +656,7 @@ struct mat4 { mat4(float e00, float e10, float e20, float e30, float e01, float e11, float e21, float e31, float e02, float e12, float e22, float e32, - float e03, float e13, float e23, float e33) : + float e03, float e13, float e23, float e33) : e00(e00), e10(e10), e20(e20), e30(e30), e01(e01), e11(e11), e21(e21), e31(e31), e02(e02), e12(e12), e22(e22), e32(e32), @@ -530,40 +669,64 @@ struct mat4 { e33 = 1.0f; } - mat4(ProjRange range, float l, float r, float b, float t, float znear, float zfar) { + void ortho(ProjRange range, float l, float r, float b, float t, float znear, float zfar, bool rotate90 = false) { identity(); - e00 = 2.0f / (r - l); - e11 = 2.0f / (t - b); - e22 = 2.0f / (znear - zfar); + + if (rotate90) { + e00 = e11 = 0.0f; + e10 = 2.0f / (l - r); + e01 = 2.0f / (t - b); + } else { + e00 = 2.0f / (r - l); + e11 = 2.0f / (t - b); + } + e03 = (l + r) / (l - r); e13 = (t + b) / (b - t); + switch (range) { case PROJ_NEG_POS : - e23 = (zfar + znear) / (znear - zfar); + e22 = 2.0f / (znear - zfar); + e23 = (znear + zfar) / (znear - zfar); + break; + case PROJ_NEG_ZERO : + e22 = 1.0f / (znear - zfar); + e23 = (znear + zfar) / (znear - zfar) * 0.5f - 0.5f; + e03 = -e03; break; case PROJ_ZERO_POS : + e22 = 2.0f / (znear - zfar); e23 = znear / (znear - zfar); break; } } - mat4(ProjRange range, float fov, float aspect, float znear, float zfar) { - float k = 1.0f / tanf(fov * 0.5f * DEG2RAD); + void frustum(ProjRange range, float l, float r, float b, float t, float znear, float zfar, bool rotate90 = false) { identity(); - if (aspect >= 1.0f) { - e00 = k / aspect; - e11 = k; + + if (rotate90) { + e00 = e11 = 0.0f; + e01 = 2.0f * znear / (r - l); + e10 = 2.0f * znear / (b - t); } else { - e00 = k; - e11 = k * aspect; + e00 = 2.0f * znear / (r - l); + e11 = 2.0f * znear / (t - b); } - e33 = 0.0f; + + e02 = (r + l) / (r - l); + e12 = (t + b) / (t - b); e32 = -1.0f; + e33 = 0.0f; + switch (range) { case PROJ_NEG_POS : e22 = (znear + zfar) / (znear - zfar); e23 = 2.0f * zfar * znear / (znear - zfar); break; + case PROJ_NEG_ZERO : + e22 = znear / (znear - zfar); + e23 = zfar * znear / (znear - zfar); + break; case PROJ_ZERO_POS : e22 = zfar / (znear - zfar); e23 = znear * e22; @@ -571,6 +734,40 @@ struct mat4 { } } + void perspective(ProjRange range, float fov, float aspect, float znear, float zfar, float eye = 0.0f, bool rotate90 = false) { + float y = tanf(fov * 0.5f * DEG2RAD) * znear; + float x = y; + float eyeX, eyeY; + + if (rotate90) { + eyeX = 0.0f; + eyeY = -eye; + aspect = 1.0f / aspect; + swap(x, y); + } else { + eyeX = eye; + eyeY = 0.0f; + } + + if (aspect >= 1.0f) { + x = y * aspect; + } else { + y /= aspect; + } + + frustum(range, -x - eyeX, x - eyeX, -y - eyeY, y - eyeY, znear, zfar, rotate90); + } + + void viewport(float x, float y, float width, float height, float n, float f) { + identity(); + e00 = width * 0.5f; + e11 = height * 0.5f; + e22 = (f - n) * 0.5f; + e23 = (f + n) * 0.5f; + e03 = x + e00; + e13 = y + e11; + } + mat4(const vec3 &from, const vec3 &at, const vec3 &up) { vec3 r, u, d; d = (from - at).normal(); @@ -584,9 +781,9 @@ struct mat4 { } mat4(const vec4 &reflectPlane) { - float a = reflectPlane.x, - b = reflectPlane.y, - c = reflectPlane.z, + float a = reflectPlane.x, + b = reflectPlane.y, + c = reflectPlane.z, d = reflectPlane.w; right() = vec4(1 - 2*a*a, - 2*b*a, - 2*c*a, 0); @@ -628,7 +825,7 @@ struct mat4 { e10 * v.x + e11 * v.y + e12 * v.z + e13, e20 * v.x + e21 * v.y + e22 * v.z + e23); } - + vec4 operator * (const vec4 &v) const { return vec4( e00 * v.x + e01 * v.y + e02 * v.z + e03 * v.w, @@ -866,6 +1063,32 @@ struct mat4 { void setPos(const vec3 &pos) { offset().xyz() = pos; } + + void rot90() + { + swap(e00, e10); + swap(e01, e11); + swap(e02, e12); + swap(e03, e13); + + e10 = -e10; + e11 = -e11; + e12 = -e12; + e13 = -e13; + } + + void unrot90() + { + e10 = -e10; + e11 = -e11; + e12 = -e12; + e13 = -e13; + + swap(e00, e10); + swap(e01, e11); + swap(e02, e12); + swap(e03, e13); + } }; struct Basis { @@ -883,15 +1106,15 @@ struct Basis { w = 1.0f; } - Basis operator * (const Basis &basis) const { + Basis operator * (const Basis &basis) const { return Basis(rot * basis.rot, pos + rot * basis.pos); } - vec3 operator * (const vec3 &v) const { + vec3 operator * (const vec3 &v) const { return rot * v + pos; } - Basis inverse() const { + Basis inverse() const { quat q = rot.conjugate(); return Basis(q, -(q * pos)); } @@ -931,6 +1154,8 @@ struct short2 { short2() {} short2(int16 x, int16 y) : x(x), y(y) {} + + inline bool operator == (const short2 &v) const { return x == v.x && y == v.y; } }; struct short3 { @@ -943,6 +1168,7 @@ struct short3 { short3 operator + (const short3 &v) const { return short3(x + v.x, y + v.y, z + v.z); } short3 operator - (const short3 &v) const { return short3(x - v.x, y - v.y, z - v.z); } + inline bool operator == (const short3 &v) const { return x == v.x && y == v.y && z == v.z; } }; struct short4 { @@ -951,7 +1177,11 @@ struct short4 { short4() {} short4(int16 x, int16 y, int16 z, int16 w) : x(x), y(y), z(z), w(w) {} + operator vec2() const { return vec2((float)x, (float)y); }; operator vec3() const { return vec3((float)x, (float)y, (float)z); }; + operator vec4() const { return vec4((float)x, (float)y, (float)z, (float)w); }; + + operator short2() const { return *((short2*)this); } operator short3() const { return *((short3*)this); } inline bool operator == (const short4 &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } @@ -1023,7 +1253,7 @@ struct Box { Box() {} Box(const vec3 &min, const vec3 &max) : min(min), max(max) {} - vec3 operator [] (int index) const { + vec3 operator [] (int index) const { ASSERT(index >= 0 && index <= 7); switch (index) { case 0 : return min; @@ -1056,7 +1286,7 @@ struct Box { max.x = ::max(max.x, box.max.x); max.y = ::max(max.y, box.max.y); max.z = ::max(max.z, box.max.z); - return *this; + return *this; } Box& operator += (const vec3 &v) { @@ -1066,7 +1296,7 @@ struct Box { max.x = ::max(max.x, v.x); max.y = ::max(max.y, v.y); max.z = ::max(max.z, v.z); - return *this; + return *this; } Box& operator -= (const Box &box) { @@ -1076,13 +1306,13 @@ struct Box { max.x = ::min(max.x, box.max.x); max.y = ::min(max.y, box.max.y); max.z = ::min(max.z, box.max.z); - return *this; + return *this; } Box operator * (const mat4 &m) const { Box res(vec3(+INF), vec3(-INF)); for (int i = 0; i < 8; i++) { - vec4 v = m * vec4((*this)[i], 1.0f); + vec4 v = m * vec4((*this)[i], 1.0f); res += v.xyz() /= v.w; } return res; @@ -1178,7 +1408,7 @@ struct Box { bool intersect(const vec3 &rayPos, const vec3 &rayDir, float &t) const { float tMax = INF, tMin = -tMax; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) if (rayDir[i] != 0) { float lo = (min[i] - rayPos[i]) / rayDir[i]; float hi = (max[i] - rayPos[i]) / rayDir[i]; @@ -1202,6 +1432,7 @@ union Color32 { // RGBA8888 struct { uint8 r, g, b, a; }; Color32() {} + Color32(uint32 value) : value(value) {} Color32(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) {} void SetRGB15(uint16 v) { @@ -1260,17 +1491,187 @@ struct Color24 { // RGB888 }; union Color16 { // RGBA5551 - struct { uint16 r:5, g:5, b:5, a:1; }; + struct { uint16 b:5, g:5, r:5, a:1; }; uint16 value; Color16() {} Color16(uint16 value) : value(value) {} - Color32 getBGR() const { return Color32((b << 3) | (b >> 2), (g << 3) | (g >> 2), (r << 3) | (r >> 2), 255); } operator Color24() const { return Color24((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2)); } operator Color32() const { return Color32((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), -a); } }; +union ColorCLUT { // RGBA5551 + struct { uint16 r:5, g:5, b:5, a:1; }; + uint16 value; + + ColorCLUT() {} + ColorCLUT(uint16 value) : value(value) {} + + operator Color24() const { return Color24((r << 3) | (r >> 2), (g << 3), (b << 3)); } + operator Color32() const { return Color32((r << 3) | (r >> 2), (g << 3), (b << 3), -a); } +}; + +struct ColorIndex4 { + uint8 a:4, b:4; +}; + +struct Tile4 { + ColorIndex4 index[256 * 256 / 2]; +}; + +struct Tile8 { + uint8 index[256 * 256]; +}; + +struct Tile16 { + Color16 color[256 * 256]; +}; + +#ifdef USE_ATLAS_RGBA16 +union AtlasColor { + struct { uint16 a:1, b:5, g:5, r:5; }; + uint16 value; + + AtlasColor() {} + AtlasColor(uint16 value) : value(value) {} + AtlasColor(const Color16 &value) : a(value.a), b(value.b), g(value.g), r(value.r) {} + AtlasColor(const Color24 &value) : a(1), b(value.b >> 3), g(value.g >> 3), r(value.r >> 3) {} + AtlasColor(const Color32 &value) : a(value.a ? 1 : 0), b(value.b >> 3), g(value.g >> 3), r(value.r >> 3) {} + AtlasColor(const ColorCLUT &value) : a(value.a), b(value.b), g(value.g), r(value.r) {} +}; + +#define ATLAS_FORMAT FMT_RGBA16 +#else +typedef Color32 AtlasColor; +#define ATLAS_FORMAT FMT_RGBA +#endif + +struct AtlasTile { + AtlasColor color[256 * 256]; +}; + +struct Tile32 { + Color32 color[256 * 256]; +}; + +struct CLUT { + ColorCLUT color[16]; +}; + +namespace StrUtils { + + void toLower(char *str) { + if (!str) return; + + while (char &c = *str++) { + if (c >= 'A' && c <= 'Z') + c -= 'Z' - 'z'; + } + } + + char* copy(const char *str) { + if (str == NULL) { + return NULL; + } + char *res = new char[strlen(str) + 1]; + strcpy(res, str); + return res; + } + + int32 length(uint16 *str) { + if (!str || !str[0]) return 0; + int32 len = 0; + while (*str++) { + len++; + } + return len; + } +} + + +template +struct Array { + int capacity; + int length; + T *items; + + Array(int capacity = 32) : capacity(capacity), length(0), items(NULL) {} + + ~Array() { + clear(); + } + + void reserve(int capacity) { + this->capacity = capacity; + if (items) + items = (T*)realloc(items, capacity * sizeof(T)); + else + items = (T*)malloc(capacity * sizeof(T)); + } + + int push(const T &item) { + if (!items) + items = (T*)malloc(capacity * sizeof(T)); + + if (length == capacity) + reserve(capacity + capacity / 2); + + items[length] = item; + return length++; + } + + int pop() { + ASSERT(length > 0); + return --length; + } + + void removeFast(int index) { + (*this)[index] = (*this)[length - 1]; + length--; + } + + void remove(int index) { + length--; + ASSERT(length >= 0); + for (int i = index; i < length; i++) + items[i] = items[i + 1]; + } + + void resize(int length) { + if (capacity < length) + reserve(length); + this->length = length; + } + + void reset() { + length = 0; + } + + void clear() { + reset(); + free(items); + items = NULL; + } + + int find(const T &item) { + for (int i = 0; i < length; i++) { + if (items[i] == item) + return i; + } + return -1; + } + + void sort() { + ::sort(items, length); + } + + T& operator[] (int index) { + ASSERT(index >= 0 && index < length); + return items[index]; + }; +}; + struct Stream; @@ -1280,6 +1681,10 @@ extern void osCacheRead (Stream *stream); extern void osReadSlot (Stream *stream); extern void osWriteSlot (Stream *stream); +#ifdef _OS_LINUX +extern const char* osFixFileName(const char* fileName); +#endif + #ifdef _OS_WEB extern void osDownload (Stream *stream); #endif @@ -1290,6 +1695,8 @@ char contentDir[255]; #define STREAM_BUFFER_SIZE (16 * 1024) +#define MAX_PACKS 32 + struct Stream { typedef void (Callback)(Stream *stream, void *userData); Callback *callback; @@ -1302,40 +1709,178 @@ struct Stream { char *buffer; int bufferIndex; + bool buffering; + uint32 baseOffset; + + struct Pack + { + Stream* stream; + uint8* table; + uint32 count; + + struct FileInfo + { + uint32 size; + uint32 offset; + }; - Stream(const char *name, const void *data, int size, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), f(NULL), data((char*)data), name(NULL), size(size), pos(0), buffer(NULL) { - if (name) { - this->name = new char[strlen(name) + 1]; - strcpy(this->name, name); + bool findFile(const char* name, FileInfo &info) + { + if (!table || !name || !name[0]) { + return false; + } + + uint16 len = (uint16)strlen(name); + uint8* ptr = table; + + for (uint32 i = 0; i < count; i++) + { + uint32 magic; + memcpy(&magic, ptr, sizeof(magic)); + if (magic != 0x02014B50) { + ASSERT(false); + return false; + } + + uint16 nameLen, extraLen, infoLen; + memcpy(&nameLen, ptr + 28, sizeof(nameLen)); + memcpy(&extraLen, ptr + 30, sizeof(extraLen)); + + if ((nameLen == len) && (memcmp(ptr + 46, name, len) == 0)) + { + uint16 compression; + memcpy(&compression, ptr + 10, sizeof(compression)); + + if (compression != 0) + { + ASSERT(false); + return false; + } + + memcpy(&info.size, ptr + 24, sizeof(info.size)); + memcpy(&info.offset, ptr + 42, sizeof(info.offset)); + + stream->setPos(info.offset); + magic = stream->readLE32(); + + if (magic != 0x04034B50) { + ASSERT(false); + return false; + } + stream->seek(22); + nameLen = stream->readLE16(); + extraLen = stream->readLE16(); + + info.offset += 4 + 22 + 2 + 2 + nameLen + extraLen; + + return true; + } + + memcpy(&infoLen, ptr + 32, sizeof(infoLen)); + + ptr += 46 + nameLen + extraLen + infoLen; + } + + return false; + } + + Pack(const char *name) : stream(NULL), table(NULL), count(0) + { + stream = new Stream(name); + stream->buffering = false; + stream->setPos(stream->size - 22); + uint32 magic = stream->readLE32(); + + if (magic != 0x06054B50) + { + ASSERT(false); + return; + } + + stream->seek(6); + count = stream->readLE16(); + uint32 tableSize = stream->readLE32(); + uint32 tableOffset = stream->readLE32(); + + stream->setPos(tableOffset); + + table = new uint8[tableSize]; + stream->raw(table, tableSize); + } + + ~Pack() { + delete stream; + delete[] table; + } + }; + + static Pack* packs[MAX_PACKS]; + + static Array fileList; + + static bool addPack(const char *name) + { + if (!existsContent(name)) { + return false; } + + for (int i = 0; i < MAX_PACKS; i++) + { + if (!packs[i]) + { + packs[i] = new Pack(name); + return true; + } + } + return false; } - Stream(const char *name, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), f(NULL), data(NULL), name(NULL), size(-1), pos(0), buffer(NULL) { - if (!name && callback) { - callback(NULL, userData); - delete this; - return; + static void init() { + readFileList(); + } + + static void deinit() + { + for (int i = 0; i < MAX_PACKS; i++) + { + if (!packs[i]) break; + delete packs[i]; } - if (!name) { - ASSERT(false); + for (int i = 0; i < fileList.length; i++) { + delete[] fileList[i]; } + fileList.clear(); + } +private: +#ifdef _OS_3DS + static void streamThread(void *arg) { + Stream* stream = (Stream*)arg; + stream->openFile(); + } +#endif + + void openFile() { + char path[255]; + + path[0] = 0; if (contentDir[0] && (!cacheDir[0] || !strstr(name, cacheDir))) { - char path[255]; - path[0] = 0; - strcat(path, contentDir); - strcat(path, name); - f = fopen(path, "rb"); - } else - f = fopen(name, "rb"); + strcpy(path, contentDir); + } + + #ifdef _OS_LINUX + strcat(path, osFixFileName(name)); + #else + strcat(path, name); + #endif + + fixBackslash(path); + + f = fopen(path, "rb"); if (!f) { #ifdef _OS_WEB - if (name) { - this->name = new char[strlen(name) + 1]; - strcpy(this->name, name); - } osDownload(this); #else LOG("error loading file \"%s\"\n", name); @@ -1350,18 +1895,78 @@ struct Stream { fseek(f, 0, SEEK_END); size = (int32)ftell(f); fseek(f, 0, SEEK_SET); - fpos = 0; + fpos = 0; bufferIndex = -1; - if (name) { - this->name = new char[strlen(name) + 1]; - strcpy(this->name, name); - } + if (callback) callback(this, userData); + } + } +public: + + Stream(const char *name, const void *data, int size, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), f(NULL), data((char*)data), name(NULL), size(size), pos(0), buffer(NULL) { + this->name = StrUtils::copy(name); + } + + Stream(const char *name, Callback *callback = NULL, void *userData = NULL) : callback(callback), userData(userData), f(NULL), data(NULL), name(NULL), size(-1), pos(0), buffer(NULL), buffering(true), baseOffset(0) { + if (!name && callback) { + callback(NULL, userData); + delete this; + return; + } - if (callback) - callback(this, userData); + if (!name) { + ASSERT(false); } + + Stream::Pack::FileInfo info; + + char path[256]; + + for (int i = 0; i < MAX_PACKS; i++) + { + if (!packs[i]) break; + + if (packs[i]->findFile(name, info)) + { + path[0] = 0; + if (contentDir[0] && (!cacheDir[0] || !strstr(name, cacheDir))) { + strcpy(path, contentDir); + } + strcat(path, packs[i]->stream->name); + fixBackslash(path); + + f = fopen(path, "rb"); + if (!f) { + LOG("error loading file from pack \"%s -> %s\"\n", packs[i]->stream->name, name); + ASSERT(false); + return; + } + baseOffset = info.offset; + fseek(f, info.offset, SEEK_SET); + size = info.size; + + fpos = 0; + bufferIndex = -1; + + this->name = StrUtils::copy(name); + if (callback) callback(this, userData); + return; + } + } + + this->name = StrUtils::copy(name); + + #ifdef _OS_3DS /* TODO + if (callback) { + s32 priority = 0; + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); + threadCreate(streamThread, this, 64 * 1024, priority - 1, -2, false); + return; + }*/ + #endif + + openFile(); } ~Stream() { @@ -1370,25 +1975,191 @@ struct Stream { if (f) fclose(f); } +#if _OS_3DS + static void readDirectory(const FS_Archive &archive, const char* path) { + char buf[255]; + strcpy(buf, contentDir + 5); // 5 to skip "sdmc:" + strcat(buf, path); + + FS_Path fsPath = fsMakePath(FS_PathType::PATH_ASCII, buf); + + Handle dir; + if (FSUSER_OpenDirectory(&dir, archive, fsPath) != 0) { + return; + } + + int32 pathLen = strlen(path); + strcpy(buf, path); + + while (1) { + FS_DirectoryEntry entry; + + u32 entriesRead = 0; + FSDIR_Read(dir, &entriesRead, 1, &entry); + + if (entriesRead == 0) { + break; + } + + int32 len = utf16_to_utf8((uint8*)buf + pathLen, entry.name, StrUtils::length(entry.name)); + buf[pathLen + len] = 0; + + if (entry.attributes & FS_ATTRIBUTE_DIRECTORY) { + strcat(buf, "/"); + readDirectory(archive, buf); + } else { + fileList.push(StrUtils::copy(buf)); + } + } + + FSDIR_Close(dir); + } + + static void readFileList() { + FS_Archive sdmc; + FS_Path fsRoot = fsMakePath(FS_PathType::PATH_ASCII, ""); + + if (FSUSER_OpenArchive(&sdmc, FS_ArchiveID::ARCHIVE_SDMC, fsRoot) != 0) { + return; + } + + readDirectory(sdmc, ""); + + FSUSER_CloseArchive(sdmc); + } +#elif _OS_PSV + static void readDirectory(char* path) { + SceUID dd = sceIoDopen(path); + + size_t len = strlen(path); + + SceIoDirent entry; + while (sceIoDread(dd, &entry) > 0) + { + strcat(path, entry.d_name); + + if (SCE_S_ISDIR(entry.d_stat.st_mode)) + { + strcat(path, "/"); + readDirectory(path); + } else { + fileList.push(StrUtils::copy(path + strlen(contentDir))); + } + + path[len] = 0; + } + + sceIoClose(dd); + } + + static void readFileList() { + char path[255]; + strcpy(path, contentDir); + readDirectory(path); + } +#elif _OS_PSP //vita isnt called "psp2" by coincidence +//dunno if this is used (?) + static void readDirectory(char* path) { + SceUID dd = sceIoDopen(path); + + size_t len = strlen(path); + + SceIoDirent entry; + while (sceIoDread(dd, &entry) > 0) + { + strcat(path, entry.d_name); + + if (FIO_S_ISDIR(entry.d_stat.st_mode)) + { + strcat(path, "/"); + readDirectory(path); + } else { + fileList.push(StrUtils::copy(path + strlen(contentDir))); + } + + path[len] = 0; + } + + sceIoClose(dd); + } + + static void readFileList() { + char path[255]; + strcpy(path, contentDir); + readDirectory(path); + } +#else + static void readFileList() {}; +#endif + static void cacheRead(const char *name, Callback *callback = NULL, void *userData = NULL) { - osCacheRead(new Stream(name, NULL, 0, callback, userData)); + Stream *stream = new Stream(name, NULL, 0, callback, userData); + #ifdef _OS_ANDROID // use saveDir for settings on android devices + if (name && strcmp(name, "settings") == 0) { + osReadSlot(stream); + return; + } + #endif + osCacheRead(stream); } static void cacheWrite(const char *name, const char *data, int size, Callback *callback = NULL, void *userData = NULL) { - osCacheWrite(new Stream(name, data, size, callback, userData)); + Stream *stream = new Stream(name, data, size, callback, userData); + #ifdef _OS_ANDROID // use saveDir for settings on android devices + if (name && strcmp(name, "settings") == 0) { + osWriteSlot(stream); + return; + } + #endif + osCacheWrite(stream); + } + + static void fixBackslash(char *str) { + #ifdef _OS_XBOX + int len = strlen(str); + for (int i = 0; i < len; i++) { + if (str[i] == '/') { + str[i] = '\\'; + } + } + #endif } static bool exists(const char *name) { + #ifdef _OS_LINUX + name = osFixFileName(name); + return (name != NULL); + #else FILE *f = fopen(name, "rb"); if (!f) return false; fclose(f); return true; + #endif } static bool existsContent(const char *name) { + for (uint32 i = 0; i < MAX_PACKS; i++) + { + if (!packs[i]) break; + + Pack::FileInfo info; + if (packs[i]->findFile(name, info)) + return true; + } + + if (fileList.length) { + for (int i = 0; i < fileList.length; i++) { + if (strcmp(fileList[i], name) == 0) { + return true; + } + } + return false; + } + char fileName[1024]; strcpy(fileName, contentDir); strcat(fileName, name); + fixBackslash(fileName); return exists(fileName); } @@ -1404,6 +2175,18 @@ struct Stream { if (!count) return; if (f) { + + if (!buffering) { + if (fpos != pos) { + fseek(f, baseOffset + pos, SEEK_SET); + fpos = pos; + } + fread(data, 1, count, f); + pos += count; + fpos += count; + return; + } + uint8 *ptr = (uint8*)data; while (count > 0) { @@ -1412,12 +2195,13 @@ struct Stream { if (bufferIndex != bIndex) { bufferIndex = bIndex; - int readed, part; + int readed; + int part; if (fpos == pos) { part = min(count / STREAM_BUFFER_SIZE * STREAM_BUFFER_SIZE, size - fpos); if (part > STREAM_BUFFER_SIZE) { - readed = fread(ptr, 1, part, f); + readed = (int)fread(ptr, 1, part, f); #ifdef TEST_SLOW_FIO LOG("%s read %d + %d\n", name, fpos, readed); @@ -1441,7 +2225,7 @@ struct Stream { if (fpos != bufferIndex * STREAM_BUFFER_SIZE) { fpos = bufferIndex * STREAM_BUFFER_SIZE; - fseek(f, fpos, SEEK_SET); + fseek(f, baseOffset + fpos, SEEK_SET); #ifdef TEST_SLOW_FIO LOG("%s seek %d\n", name, fpos); @@ -1454,7 +2238,7 @@ struct Stream { } part = min(STREAM_BUFFER_SIZE, size - fpos); - readed = fread(buffer, 1, part, f); + readed = (int)fread(buffer, 1, part, f); #ifdef TEST_SLOW_FIO LOG("%s read %d + %d\n", name, fpos, readed); @@ -1528,6 +2312,8 @@ struct Stream { } }; +Stream::Pack* Stream::packs[MAX_PACKS]; +Array Stream::fileList; #ifdef OS_FILEIO_CACHE void osDataWrite(Stream *stream, const char *dir) { @@ -1594,9 +2380,7 @@ void osReadSlot(Stream *stream) { void* osMutexInit() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); -#if !defined(_OS_WEB) && !defined(_OS_IOS) - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); -#endif + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_t *mutex = new pthread_mutex_t(); pthread_mutex_init(mutex, &attr); @@ -1667,17 +2451,17 @@ struct BitStream { BitStream(uint8 *data, int size) : data(data), end(data + size), index(0), value(0) {} inline uint32 readBit() { - uint32 bit; + uint32 bit; - if (!index--) { - value = *data++; - index = 7; - } + if (!index--) { + value = *data++; + index = 7; + } - bit = value & 1; - value >>= 1; + bit = value & 1; + value >>= 1; - return bit; + return bit; } uint32 read(int count) { @@ -1780,20 +2564,6 @@ struct BitStream { }; -namespace String { - - void toLower(char *str) { - if (!str) return; - - while (char &c = *str++) { - if (c >= 'A' && c <= 'Z') - c -= 'Z' - 'z'; - } - } - -} - - template struct FixedStr { char data[N]; @@ -1804,7 +2574,7 @@ struct FixedStr { } FixedStr& operator = (const char *str) { - int len = min(sizeof(data), strlen(str)); + size_t len = min(sizeof(data), strlen(str)); memset(data, 0, sizeof(data)); memcpy(data, str, len); return *this; @@ -1813,78 +2583,4 @@ struct FixedStr { typedef FixedStr<16> str16; - -template -struct Array { - int capacity; - int length; - T *items; - - Array(int capacity = 32) : capacity(capacity), length(0), items(NULL) {} - - ~Array() { - clear(); - } - - void reserve(int capacity) { - this->capacity = capacity; - if (items) - items = (T*)realloc(items, capacity * sizeof(T)); - else - items = (T*)malloc(capacity * sizeof(T)); - } - - int push(const T &item) { - if (!items) - items = (T*)malloc(capacity * sizeof(T)); - - if (length == capacity) - reserve(capacity + capacity / 2); - - items[length] = item; - return length++; - } - - int pop() { - ASSERT(length > 0); - return --length; - } - - void removeFast(int index) { - (*this)[index] = (*this)[length - 1]; - length--; - } - - void remove(int index) { - length--; - ASSERT(length >= 0); - for (int i = index; i < length; i++) - items[i] = items[i + 1]; - } - - void resize(int length) { - if (capacity < length) - reserve(length); - this->length = length; - } - - void clear() { - length = 0; - free(items); - items = NULL; - } - - void sort() { - ::sort(items, length); - } - - T& operator[] (int index) { - ASSERT(index >= 0 && index < length); - return items[index]; - }; - - operator T*() const { return items; }; -}; - - #endif diff --git a/src/video.h b/src/video.h index b047e3dd..6f0de10a 100644 --- a/src/video.h +++ b/src/video.h @@ -5,6 +5,10 @@ #include "texture.h" #include "sound.h" +#ifdef _OS_TNS + #define NO_VIDEO +#endif + struct AC_ENTRY { uint8 code; uint8 skip; @@ -130,7 +134,7 @@ static const AC_ENTRY STR_AC[] = { { 0X3E , 27 , 1 , 17 }, // 00111110 }; -static const uint8 STR_ZIG_ZAG[] = { +static const uint8 STR_ZSCAN[] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, @@ -141,26 +145,15 @@ static const uint8 STR_ZIG_ZAG[] = { 53, 60, 61, 54, 47, 55, 62, 63, }; -static const uint8 STR_QUANTIZATION[] = { - 2, 16, 19, 22, 26, 27, 29, 34, - 16, 16, 22, 24, 27, 29, 34, 37, - 19, 22, 26, 27, 29, 34, 34, 38, - 22, 22, 26, 27, 29, 34, 37, 40, - 22, 26, 27, 29, 32, 35, 40, 48, - 26, 27, 29, 32, 35, 40, 48, 58, - 26, 27, 29, 34, 38, 46, 56, 69, - 27, 29, 35, 38, 46, 56, 69, 83 -}; - -static const float STR_IDCT[] = { - 0.354f, 0.354f, 0.354f, 0.354f, 0.354f, 0.354f, 0.354f, 0.354f, - 0.490f, 0.416f, 0.278f, 0.098f, -0.098f, -0.278f, -0.416f, -0.490f, - 0.462f, 0.191f, -0.191f, -0.462f, -0.462f, -0.191f, 0.191f, 0.462f, - 0.416f, -0.098f, -0.490f, -0.278f, 0.278f, 0.490f, 0.098f, -0.416f, - 0.354f, -0.354f, -0.354f, 0.354f, 0.354f, -0.354f, -0.354f, 0.354f, - 0.278f, -0.490f, 0.098f, 0.416f, -0.416f, -0.098f, 0.490f, -0.278f, - 0.191f, -0.462f, 0.462f, -0.191f, -0.191f, 0.462f, -0.462f, 0.191f, - 0.098f, -0.278f, 0.416f, -0.490f, 0.490f, -0.416f, 0.278f, -0.098f, +static const int32 STR_QTABLE[] = { + 0x00020000, 0x00163150, 0x00163150, 0x0018D321, 0x001EC830, 0x0018D321, 0x0019DE84, 0x0027DEA0, + 0x0027DEA0, 0x0019DE84, 0x00160000, 0x0023E1B0, 0x002C6282, 0x002724C0, 0x001A0000, 0x001536B1, + 0x00257337, 0x00297B55, 0x0027F206, 0x00241022, 0x00146D8E, 0x000E1238, 0x001D6CAF, 0x002346F9, + 0x00255528, 0x0025E3EF, 0x001F9AA9, 0x000FB1DC, 0x00096162, 0x001985B6, 0x0022E73A, 0x002219AE, + 0x002219AE, 0x001DC539, 0x00144489, 0x000772FB, 0x000B1918, 0x00148191, 0x001D9060, 0x00200000, + 0x001F6966, 0x00180AAA, 0x000E28D8, 0x000DB2B0, 0x00178BD2, 0x001B7FC9, 0x001B7FC9, 0x0015A314, + 0x000C9DD8, 0x000C53EE, 0x001490C8, 0x0018B140, 0x0015A5E0, 0x000CFA08, 0x000D3E30, 0x00146910, + 0x00138F5A, 0x000CB0EE, 0x000C2390, 0x001066E8, 0x000C928C, 0x000A4DA2, 0x000A4DA2, 0x00065187, }; struct Video { @@ -267,6 +260,9 @@ struct Video { nextChunk(0, 0); + #ifdef NO_SOUND + audioDecoder = NULL; + #else if (sfmt == 1) audioDecoder = new Sound::PCM(NULL, channels, rate, 0x7FFFFF, bps); // TR2 else if (sfmt == 101) { @@ -275,6 +271,7 @@ struct Video { else audioDecoder = new Sound::IMA(NULL, channels, rate); // TR3 } + #endif } virtual ~Escape() { @@ -681,6 +678,9 @@ struct Video { } virtual int decode(Sound::Frame *frames, int count) { + #ifdef NO_VIDEO + return 0; + #else if (!audioDecoder) return 0; if (bps != 4 && abs(curAudioChunk - curVideoChunk) > 1) { // sync with video chunk, doesn't work for IMA @@ -721,6 +721,7 @@ struct Video { } return count; + #endif } }; @@ -757,12 +758,13 @@ struct Video { uint16 chunksCount; uint32 frameIndex; uint32 chunkSize; - uint16 width, height; + uint16 width; + uint16 height; uint16 blocks; - uint16 unk1; + uint16 unk3800; uint16 qscale; uint16 version; - uint32 unk2; + uint32 unk00000000; }; struct VideoChunk { @@ -791,7 +793,7 @@ struct Video { int curVideoChunk; int curAudioChunk; - Sound::Decoder *audioDecoder; + Sound::XA *audioDecoder; struct { uint8 code; @@ -800,9 +802,13 @@ struct Video { bool hasSyncHeader; - STR(Stream *stream) : Decoder(stream), videoChunksCount(0), audioChunksCount(0), curVideoChunk(-1), curAudioChunk(-1), audioDecoder(NULL) { + STR(Stream *stream) : Decoder(stream), videoChunksCount(0), audioChunksCount(0), curVideoChunk(-1), curAudioChunk(-1), audioDecoder(NULL) + { + memset(videoChunks, 0, sizeof(videoChunks)); + memset(audioChunks, 0, sizeof(audioChunks)); - if (stream->pos >= stream->size) { + if (stream->pos >= stream->size) + { LOG("Can't load STR format \"%s\"\n", stream->name); ASSERT(false); return; @@ -822,15 +828,11 @@ struct Video { hasSyncHeader = syncMagic[0] == 0xFFFFFF00 && syncMagic[1] == 0xFFFFFFFF && syncMagic[2] == 0x00FFFFFF; - if (!hasSyncHeader) { + if (!hasSyncHeader) + { LOG("! No sync header found, please use jpsxdec tool to extract FMVs\n"); } - for (int i = 0; i < MAX_CHUNKS; i++) { - videoChunks[i].size = 0; - audioChunks[i].size = 0; - } - nextChunk(); VideoChunk &chunk = videoChunks[0]; @@ -841,45 +843,66 @@ struct Video { channels = 2; freq = 37800; - audioDecoder = new Sound::XA(NULL); + #ifdef NO_SOUND + audioDecoder = NULL; + #else + audioDecoder = new Sound::XA(this, audioNextBlockCallback); + #endif } - virtual ~STR() { + virtual ~STR() + { OS_LOCK(Sound::lock); audioDecoder->stream = NULL; delete audioDecoder; } - void buildLUT(uint8 *LUT, int start, int end, int shift) { - for (int i = start; i < end; i++) { + void buildLUT(uint8 *LUT, int start, int end, int shift) + { + for (int i = start; i < end; i++) + { const AC_ENTRY &e = STR_AC[i]; uint8 trash = (1 << (8 + shift - e.length + 1)); // fill the value and all possible endings while (trash--) + { LUT[e.code | trash] = i; + } } } - bool nextChunk() { + bool nextChunk() + { OS_LOCK(Sound::lock); + if (videoChunks[videoChunksCount % MAX_CHUNKS].size > 0) + { + return false; + } + if (stream->pos >= stream->size) + { return false; + } bool readingVideo = false; - while (stream->pos < stream->size) { - + while (stream->pos < stream->size) + { if (hasSyncHeader) + { stream->seek(24); + } Sector sector; stream->raw(§or, sizeof(Sector)); - if (sector.magic == MAGIC_STR) { + if (sector.magic == MAGIC_STR) + { VideoChunk *chunk = videoChunks + (videoChunksCount % MAX_CHUNKS); - if (sector.chunkIndex == 0) { + if (sector.chunkIndex == 0) + { readingVideo = true; chunk->size = 0; chunk->width = sector.width; @@ -892,9 +915,12 @@ struct Video { chunk->size += VIDEO_SECTOR_SIZE; if (hasSyncHeader) + { stream->seek(280); + } - if (sector.chunkIndex == sector.chunksCount - 1) { + if (sector.chunkIndex == sector.chunksCount - 1) + { videoChunksCount++; return true; } @@ -908,19 +934,26 @@ struct Video { stream->seek(24); if (!hasSyncHeader) + { stream->seek(2048 - (AUDIO_SECTOR_SIZE + 24)); + } if (!readingVideo) + { return true; + } }; } return false; } // http://jpsxdec.blogspot.com/2011/06/decoding-mpeg-like-bitstreams.html - bool readCode(BitStream &bs, int16 &skip, int16 &ac) { - if (bs.readU(1)) { - if (bs.readU(1)) { + bool readCode(BitStream &bs, int16 &skip, int16 &ac) + { + if (bs.readU(1)) + { + if (bs.readU(1)) + { skip = 0; ac = bs.readU(1) ? -1 : 1; return true; @@ -930,9 +963,12 @@ struct Video { int nz = 1; while (!bs.readU(1)) + { nz++; + } - if (nz == 5) { // escape code == 0b1000001 + if (nz == 5) // escape code == 0b1000001 + { uint16 esc = bs.readU(16); skip = esc >> 10; ac = esc & 0x3FF; @@ -970,40 +1006,209 @@ struct Video { ac = (code & (1 << (8 + shift - e.length))) ? -e.ac : e.ac; return true; } - - void IDCT(int16 *b) { - float t[64]; - - for (int x = 0; x < 8; x++) - for (int y = 0; y < 8; y++) - t[x + y * 8] = b[x + 0 * 8] * STR_IDCT[0 * 8 + y] - + b[x + 1 * 8] * STR_IDCT[1 * 8 + y] - + b[x + 2 * 8] * STR_IDCT[2 * 8 + y] - + b[x + 3 * 8] * STR_IDCT[3 * 8 + y] - + b[x + 4 * 8] * STR_IDCT[4 * 8 + y] - + b[x + 5 * 8] * STR_IDCT[5 * 8 + y] - + b[x + 6 * 8] * STR_IDCT[6 * 8 + y] - + b[x + 7 * 8] * STR_IDCT[7 * 8 + y]; - - for (int x = 0; x < 8; x++) - for (int y = 0; y < 8; y++) { - int i = y * 8; - b[x + i] = int16( - t[0 + i] * STR_IDCT[x + 0 * 8] - + t[1 + i] * STR_IDCT[x + 1 * 8] - + t[2 + i] * STR_IDCT[x + 2 * 8] - + t[3 + i] * STR_IDCT[x + 3 * 8] - + t[4 + i] * STR_IDCT[x + 4 * 8] - + t[5 + i] * STR_IDCT[x + 5 * 8] - + t[6 + i] * STR_IDCT[x + 6 * 8] - + t[7 + i] * STR_IDCT[x + 7 * 8]); + + // https://psx-spx.consoledev.net/macroblockdecodermdec/ + // https://github.com/grumpycoders/pcsx-redux/ + #define AAN_CONST_BITS 12 + #define AAN_PRESCALE_BITS 16 + + #define AAN_EXTRA 12 + #define SCALE(x, n) ((x) >> (n)) + #define SCALER(x, n) (((x) + ((1 << (n)) >> 1)) >> (n)) + #define RLE_RUN(a) ((a) >> 10) + #define RLE_VAL(a) (((int)(a) << (sizeof(int) * 8 - 10)) >> (sizeof(int) * 8 - 10)) + #define MULS(var, c) (SCALE((var) * (c), AAN_CONST_BITS)) + + #define AAN_CONST_SIZE 24 + #define AAN_CONST_SCALE (AAN_CONST_SIZE - AAN_CONST_BITS) + + #define MULR(a) ((1434 * (a))) + #define MULB(a) ((1807 * (a))) + #define MULG2(a, b) ((-351 * (a)-728 * (b))) + #define MULY(a) ((a) << 10) + + #define MAKERGB15(r, g, b, a) ((a | ((b) << 10) | ((g) << 5) | (r))) + #define SCALE8(c) SCALER(c, 20) + #define SCALE5(c) SCALER(c, 23) + + #define CLAMP5(c) (((c) < -16) ? 0 : (((c) > (31 - 16)) ? 31 : ((c) + 16))) + #define CLAMP8(c) (((c) < -128) ? 0 : (((c) > (255 - 128)) ? 255 : ((c) + 128))) + + #define CLAMP_SCALE8(a) (CLAMP8(SCALE8(a))) + #define CLAMP_SCALE5(a) (CLAMP5(SCALE5(a))) + + static inline void fillCol(int *blk, int val) + { + blk[0 * 8] = blk[1 * 8] = blk[2 * 8] = blk[3 * 8] = blk[4 * 8] = blk[5 * 8] = blk[6 * 8] = blk[7 * 8] = val; + } + + static inline void fillRow(int *blk, int val) + { + blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] = blk[7] = val; + } + + static void IDCT(int *block, int used_col) + { + #define FIX_1_082392200 4433 + #define FIX_1_414213562 5793 + #define FIX_1_847759065 7568 + #define FIX_2_613125930 10703 + + int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int z5, z10, z11, z12, z13; + int *ptr; + int i; + + if (used_col == -1) + { + int v = block[0]; + for (i = 0; i < 64; i++) + { + block[i] = v; + } + return; + } + + ptr = block; + for (i = 0; i < 8; i++, ptr++) + { + if ((used_col & (1 << i)) == 0) + { + if (ptr[8 * 0]) + { + fillCol(ptr, ptr[0]); + used_col |= (1 << i); + } + continue; + } + + z10 = ptr[8 * 0] + ptr[8 * 4]; + z11 = ptr[8 * 0] - ptr[8 * 4]; + z13 = ptr[8 * 2] + ptr[8 * 6]; + z12 = MULS(ptr[8 * 2] - ptr[8 * 6], FIX_1_414213562) - z13; + + tmp0 = z10 + z13; + tmp3 = z10 - z13; + tmp1 = z11 + z12; + tmp2 = z11 - z12; + + z13 = ptr[8 * 3] + ptr[8 * 5]; + z10 = ptr[8 * 3] - ptr[8 * 5]; + z11 = ptr[8 * 1] + ptr[8 * 7]; + z12 = ptr[8 * 1] - ptr[8 * 7]; + + tmp7 = z11 + z13; + + z5 = (z12 - z10) * (FIX_1_847759065); + tmp6 = SCALE(z10 * (FIX_2_613125930) + z5, AAN_CONST_BITS) - tmp7; + tmp5 = MULS(z11 - z13, FIX_1_414213562) - tmp6; + tmp4 = SCALE(z12 * (FIX_1_082392200)-z5, AAN_CONST_BITS) + tmp5; + + ptr[8 * 0] = (tmp0 + tmp7); + ptr[8 * 7] = (tmp0 - tmp7); + ptr[8 * 1] = (tmp1 + tmp6); + ptr[8 * 6] = (tmp1 - tmp6); + ptr[8 * 2] = (tmp2 + tmp5); + ptr[8 * 5] = (tmp2 - tmp5); + ptr[8 * 4] = (tmp3 + tmp4); + ptr[8 * 3] = (tmp3 - tmp4); + } + + ptr = block; + if (used_col == 1) + { + for (i = 0; i < 8; i++) + { + fillRow(block + 8 * i, block[8 * i]); + } + } else { + for (i = 0; i < 8; i++, ptr += 8) + { + z10 = ptr[0] + ptr[4]; + z11 = ptr[0] - ptr[4]; + z13 = ptr[2] + ptr[6]; + z12 = MULS(ptr[2] - ptr[6], FIX_1_414213562) - z13; + + tmp0 = z10 + z13; + tmp3 = z10 - z13; + tmp1 = z11 + z12; + tmp2 = z11 - z12; + + z13 = ptr[3] + ptr[5]; + z10 = ptr[3] - ptr[5]; + z11 = ptr[1] + ptr[7]; + z12 = ptr[1] - ptr[7]; + + tmp7 = z11 + z13; + z5 = (z12 - z10) * FIX_1_847759065; + tmp6 = SCALE(z10 * FIX_2_613125930 + z5, AAN_CONST_BITS) - tmp7; + tmp5 = MULS(z11 - z13, FIX_1_414213562) - tmp6; + tmp4 = SCALE(z12 * FIX_1_082392200 - z5, AAN_CONST_BITS) + tmp5; + + ptr[0] = tmp0 + tmp7; + + ptr[7] = tmp0 - tmp7; + ptr[1] = tmp1 + tmp6; + ptr[6] = tmp1 - tmp6; + ptr[2] = tmp2 + tmp5; + ptr[5] = tmp2 - tmp5; + ptr[4] = tmp3 + tmp4; + ptr[3] = tmp3 - tmp4; + } + } + } + + static inline void putQuadRGB24(uint8 *image, int *Yblk, int Cr, int Cb) + { + int Y, R, G, B; + + R = MULR(Cr); + G = MULG2(Cb, Cr); + B = MULB(Cb); + + Y = MULY(Yblk[0]); + image[0 * 3 + 0] = CLAMP_SCALE8(Y + R); + image[0 * 3 + 1] = CLAMP_SCALE8(Y + G); + image[0 * 3 + 2] = CLAMP_SCALE8(Y + B); + Y = MULY(Yblk[1]); + image[1 * 3 + 0] = CLAMP_SCALE8(Y + R); + image[1 * 3 + 1] = CLAMP_SCALE8(Y + G); + image[1 * 3 + 2] = CLAMP_SCALE8(Y + B); + Y = MULY(Yblk[8]); + image[16 * 3 + 0] = CLAMP_SCALE8(Y + R); + image[16 * 3 + 1] = CLAMP_SCALE8(Y + G); + image[16 * 3 + 2] = CLAMP_SCALE8(Y + B); + Y = MULY(Yblk[9]); + image[17 * 3 + 0] = CLAMP_SCALE8(Y + R); + image[17 * 3 + 1] = CLAMP_SCALE8(Y + G); + image[17 * 3 + 2] = CLAMP_SCALE8(Y + B); + } + + inline void YUV2RGB24(int32 *blk, uint8 *image) + { + int x, y; + int *Yblk = blk + 64 * 2; + int *Crblk = blk; + int *Cbblk = blk + 64; + + for (y = 0; y < 16; y += 2, Crblk += 4, Cbblk += 4, Yblk += 8, image += 8 * 3 * 3) + { + if (y == 8) Yblk += 64; + for (x = 0; x < 4; x++, image += 6, Crblk++, Cbblk++, Yblk += 2) + { + putQuadRGB24(image, Yblk, *Crblk, *Cbblk); + putQuadRGB24(image + 8 * 3, Yblk + 64, *(Crblk + 4), *(Cbblk + 4)); } + } } - virtual bool decodeVideo(Color32 *pixels) { + virtual bool decodeVideo(Color32 *pixels) + { curVideoChunk++; - while (curVideoChunk >= videoChunksCount) { - if (!nextChunk()) { + while (curVideoChunk >= videoChunksCount) + { + if (!nextChunk()) + { return false; } } @@ -1012,83 +1217,101 @@ struct Video { BitStream bs(chunk->data + 8, chunk->size - 8); // make bitstream without frame header - int16 block[6][64]; // Cr, Cb, YTL, YTR, YBL, YBR - for (int bX = 0; bX < width / 16; bX++) - for (int bY = 0; bY < height / 16; bY++) { - memset(block, 0, sizeof(block)); - - for (int i = 0; i < 6; i++) { - bool nonZero = false; - - int16 *channel = block[i]; - channel[0] = bs.readU(10); - if (channel[0]) { - if (channel[0] & 0x200) - channel[0] -= 0x400; - channel[0] = channel[0] * STR_QUANTIZATION[0]; // DC - nonZero = true; + int32 qscale = chunk->qscale; + + int32 blocks[64 * 6]; // Cr, Cb, YTL, YTR, YBL, YBR + for (int32 bX = 0; bX < width / 16; bX++) + { + for (int32 bY = 0; bY < height / 16; bY++) + { + memset(blocks, 0, sizeof(blocks)); + + for (int i = 0; i < 6; i++) + { + int32* block = blocks + i * 64; + + int16 dc = bs.readU(10); + if (dc & 0x200) { + dc -= 0x400; } - + + block[0] = SCALER(dc * STR_QTABLE[0], AAN_EXTRA - 3); + + int32 used_col = 0; + int16 skip, ac; - int index = 0; - while (readCode(bs, skip, ac)) { - index += 1 + skip; + int32 index = 0; + while (readCode(bs, skip, ac)) + { + index += skip + 1; ASSERT(index < 64); - int zIndex = STR_ZIG_ZAG[index]; - channel[zIndex] = (ac * STR_QUANTIZATION[zIndex] * chunk->qscale + 4) >> 3; - nonZero = true; - } + block[STR_ZSCAN[index]] = SCALER(ac * STR_QTABLE[index] * qscale, AAN_EXTRA); - if (nonZero) - IDCT(channel); - } - - Color32 *blockPixels = pixels + (width * bY * 16 + bX * 16); + used_col |= (STR_ZSCAN[index] > 7) ? 1 << (STR_ZSCAN[index] & 7) : 0; + } - for (uint32 i = 0; i < 8 * 8; i++) { - int x = (i % 8) * 2; - int y = (i / 8) * 2; - int j = (x & 7) + (y & 7) * 8; + if (index == 0) used_col = -1; - Color32 *c = blockPixels + (width * y + x); + IDCT(block, used_col); + } - int16 *b = block[(x < 8) ? ((y < 8) ? 2 : 4) : ((y < 8) ? 3 : 5)]; + Color24 pix[16 * 16]; + YUV2RGB24(blocks, (uint8*)pix); - Color32::YCbCr_T871_420(b[j] + 128, b[j + 1] + 128, b[j + 8] + 128, b[j + 8 + 1] + 128, block[1][i], block[0][i], 4, - c[0], c[1], c[width], c[width + 1]); + int32 i = 0; + Color32 *blockPixels = pixels + (width * bY * 16 + bX * 16); + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x++) + { + blockPixels[y * width + x] = pix[i++]; + } } } + } + + chunk->size = 0; return true; } - virtual int decode(Sound::Frame *frames, int count) { - if (!audioDecoder) return 0; - Sound::XA *xa = (Sound::XA*)audioDecoder; - - int i = 0; - while (i < count) { - if (xa->pos >= COUNT(xa->buffer)) { - curAudioChunk++; - while (curAudioChunk >= audioChunksCount) { - if (!nextChunk()) { - memset(frames, 0, count * sizeof(Sound::Frame)); - return count; - } - } + bool getNextAudioStream() + { + curAudioChunk++; + while (curAudioChunk >= audioChunksCount) + { + if (!nextChunk()) + { + curAudioChunk--; + return false; } + } - AudioChunk *chunk = audioChunks + (curAudioChunk % MAX_CHUNKS); - ASSERT(chunk->size > 0); - Stream *memStream = new Stream(NULL, chunk->data, AUDIO_SECTOR_SIZE); - audioDecoder->stream = memStream; + AudioChunk *chunk = audioChunks + (curAudioChunk % MAX_CHUNKS); + ASSERT(chunk->size > 0); + audioDecoder->processSector(chunk->data); + return true; + } - i += audioDecoder->decode(&frames[i], count - i); + static bool audioNextBlockCallback(void* userData) + { + return ((STR*)userData)->getNextAudioStream(); + } - delete memStream; + virtual int decode(Sound::Frame *frames, int count) + { + #ifdef NO_VIDEO + return 0; + #else + if (!audioDecoder) return 0; + + int ret = audioDecoder->decode(frames, count); + if (ret < count) { + memset(frames + ret, 0, (count - ret) * sizeof(Sound::Frame)); } return count; + #endif } }; @@ -1241,16 +1464,29 @@ struct Video { } }; + enum Format { + PC, + PSX, + SAT, + } format; + Sound::Sample *sample; Decoder *decoder; Texture *frameTex[2]; Color32 *frameData; float step, stepTimer, time; bool isPlaying; bool needUpdate; - Sound::Sample *sample; - Video(Stream *stream) : decoder(NULL), stepTimer(0.0f), time(0.0f), isPlaying(false) { + static void playAsync(Stream *stream, void *userData) { + if (stream) { + Video *video = (Video*)userData; + video->sample = Sound::play(stream, NULL, 1.0f, 1.0f, Sound::MUSIC); + Core::resetTime(); + } + } + + Video(Stream *stream, TR::LevelID id) : sample(NULL), decoder(NULL), stepTimer(0.0f), time(0.0f), isPlaying(false), needUpdate(false) { frameTex[0] = frameTex[1] = NULL; if (!stream) return; @@ -1261,21 +1497,31 @@ struct Video { float pitch = 1.0f; if (magic == FOURCC("FILM")) { + format = SAT; decoder = new Cinepak(stream); pitch = decoder->freq / 22050.0f; // 22254 / 22050 = 1.00925 - } else if (magic == FOURCC("ARMo")) + } else if (magic == FOURCC("ARMo")) { + format = PC; decoder = new Escape(stream); - else + } else { + format = PSX; decoder = new STR(stream); + } frameData = new Color32[decoder->width * decoder->height]; memset(frameData, 0, decoder->width * decoder->height * sizeof(Color32)); - for (int i = 0; i < 2; i++) - frameTex[i] = new Texture(decoder->width, decoder->height, FMT_RGBA, 0, frameData); + for (int i = 0; i < 2; i++) { + frameTex[i] = new Texture(decoder->width, decoder->height, 1, FMT_RGBA, OPT_DYNAMIC, frameData); + } - sample = Sound::play(decoder); - sample->pitch = pitch; + if (!TR::getVideoTrack(id, playAsync, this)) { + sample = Sound::play(decoder); + sample->pitch = pitch; + if (sample) { + sample->pitch = pitch; + } + } step = 1.0f / decoder->fps; stepTimer = step; @@ -1285,8 +1531,12 @@ struct Video { virtual ~Video() { OS_LOCK(Sound::lock); - sample->decoder = NULL; - sample->stop(); + if (sample) { + if (sample->decoder == decoder) { + sample->decoder = NULL; + } + sample->stop(); + } delete decoder; delete frameTex[0]; delete frameTex[1]; @@ -1311,7 +1561,7 @@ struct Video { #endif } - void render() { // just update GPU texture if it's necessary + void render() { // update GPU texture if (!needUpdate) return; frameTex[0]->update(frameData); swap(frameTex[0], frameTex[1]);