mirror of
https://github.com/simtactics/niotso.git
synced 2025-03-22 02:52:18 +00:00
* License header formatting change
* New IFF chunk formats supported: CST, FBMP, CATS * Rebranded libfar to simply far * Started preliminary work on the hitutils package
This commit is contained in:
parent
55659f43b5
commit
bc51bb4aad
96 changed files with 2321 additions and 424 deletions
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Audio/Audio.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Audio/Startup.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,7 +27,7 @@ IXAudio2MasteringVoice *MasterVoice = NULL;
|
||||||
|
|
||||||
int Initialize(){
|
int Initialize(){
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
|
||||||
result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE | COINIT_SPEED_OVER_MEMORY);
|
result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE | COINIT_SPEED_OVER_MEMORY);
|
||||||
if(result != S_OK){
|
if(result != S_OK){
|
||||||
MessageBox(Window::hWnd, "Failed to initialize Microsoft COM.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to initialize Microsoft COM.", NULL, MB_OK | MB_ICONERROR);
|
||||||
|
@ -39,7 +42,7 @@ int Initialize(){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_AUDIO_INIT_XAUDIO2;
|
return ERROR_AUDIO_INIT_XAUDIO2;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = pXAudio2->CreateMasteringVoice(&MasterVoice, 2, 44100, 0, 0, NULL);
|
result = pXAudio2->CreateMasteringVoice(&MasterVoice, 2, 44100, 0, 0, NULL);
|
||||||
if(result != S_OK){
|
if(result != S_OK){
|
||||||
MessageBox(Window::hWnd, "Failed to create the mastering voice for XAudio2.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to create the mastering voice for XAudio2.", NULL, MB_OK | MB_ICONERROR);
|
||||||
|
@ -59,7 +62,7 @@ PlayableSound_t * LoadSound(const Sound_t * Sound){
|
||||||
Sound->BitDepth, //wBitsPerSample
|
Sound->BitDepth, //wBitsPerSample
|
||||||
0 //cbSize
|
0 //cbSize
|
||||||
};
|
};
|
||||||
|
|
||||||
const XAUDIO2_BUFFER buffer = {
|
const XAUDIO2_BUFFER buffer = {
|
||||||
0, //Flags
|
0, //Flags
|
||||||
Sound->Duration * wfx.nBlockAlign, //AudioBytes
|
Sound->Duration * wfx.nBlockAlign, //AudioBytes
|
||||||
|
@ -71,13 +74,13 @@ PlayableSound_t * LoadSound(const Sound_t * Sound){
|
||||||
XAUDIO2_LOOP_INFINITE, //LoopCount
|
XAUDIO2_LOOP_INFINITE, //LoopCount
|
||||||
NULL, //pContext
|
NULL, //pContext
|
||||||
};
|
};
|
||||||
|
|
||||||
IXAudio2SourceVoice* pSourceVoice;
|
IXAudio2SourceVoice* pSourceVoice;
|
||||||
if(FAILED(pXAudio2->CreateSourceVoice(&pSourceVoice, &wfx)))
|
if(FAILED(pXAudio2->CreateSourceVoice(&pSourceVoice, &wfx)))
|
||||||
return NULL;
|
return NULL;
|
||||||
if(FAILED(pSourceVoice->SubmitSourceBuffer(&buffer)))
|
if(FAILED(pSourceVoice->SubmitSourceBuffer(&buffer)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
PlayableSound_t * PlayableSound = (PlayableSound_t*) malloc(sizeof(PlayableSound_t));
|
PlayableSound_t * PlayableSound = (PlayableSound_t*) malloc(sizeof(PlayableSound_t));
|
||||||
if(!PlayableSound)
|
if(!PlayableSound)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Client.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,7 +26,7 @@ Scene * CurrentScene;
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
//Disallow multiple instances of the game from running
|
//Disallow multiple instances of the game from running
|
||||||
CreateMutex(NULL, TRUE, "Global\\TSO_NIOTSO_MUTEX");
|
CreateMutex(NULL, TRUE, "Global\\TSO_NIOTSO_MUTEX");
|
||||||
if(GetLastError() == ERROR_ALREADY_EXISTS){
|
if(GetLastError() == ERROR_ALREADY_EXISTS){
|
||||||
|
@ -40,13 +43,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
Window::Height = 600;
|
Window::Height = 600;
|
||||||
Window::Fullscreen = false;
|
Window::Fullscreen = false;
|
||||||
System::hInst = hInstance;
|
System::hInst = hInstance;
|
||||||
|
|
||||||
result = Window::Initialize();
|
result = Window::Initialize();
|
||||||
if(result != 0){
|
if(result != 0){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_INIT | ERROR_INIT_WINDOW | result;
|
return ERROR_INIT | ERROR_INIT_WINDOW | result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = System::Initialize();
|
result = System::Initialize();
|
||||||
if(result != 0){
|
if(result != 0){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
@ -64,20 +67,20 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_INIT | ERROR_INIT_AUDIO | result;
|
return ERROR_INIT | ERROR_INIT_AUDIO | result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentScene = new LoginScreen();
|
CurrentScene = new LoginScreen();
|
||||||
if(CurrentScene == NULL || System::SceneFailed){
|
if(CurrentScene == NULL || System::SceneFailed){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_INIT | ERROR_INIT_LOGIC | ERROR_LOGIC_CREATE_SCENE;
|
return ERROR_INIT | ERROR_INIT_LOGIC | ERROR_LOGIC_CREATE_SCENE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(Window::hWnd, SW_SHOW);
|
ShowWindow(Window::hWnd, SW_SHOW);
|
||||||
SetForegroundWindow(Window::hWnd);
|
SetForegroundWindow(Window::hWnd);
|
||||||
SetFocus(Window::hWnd);
|
SetFocus(Window::hWnd);
|
||||||
|
|
||||||
LARGE_INTEGER PreviousTime;
|
LARGE_INTEGER PreviousTime;
|
||||||
QueryPerformanceCounter(&PreviousTime);
|
QueryPerformanceCounter(&PreviousTime);
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
LARGE_INTEGER CurrentTime;
|
LARGE_INTEGER CurrentTime;
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
QueryPerformanceCounter(&CurrentTime);
|
||||||
|
@ -86,9 +89,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
PreviousTime.QuadPart = CurrentTime.QuadPart;
|
PreviousTime.QuadPart = CurrentTime.QuadPart;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&System::UserInput, (const void*) &System::UserInput_v, sizeof(System::UserInput_t));
|
memcpy(&System::UserInput, (const void*) &System::UserInput_v, sizeof(System::UserInput_t));
|
||||||
|
|
||||||
int result = CurrentScene->RunFor(TimeDelta);
|
int result = CurrentScene->RunFor(TimeDelta);
|
||||||
if(result == System::SHUTDOWN)
|
if(result == System::SHUTDOWN)
|
||||||
break;
|
break;
|
||||||
|
@ -97,7 +100,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
CurrentScene->Render();
|
CurrentScene->Render();
|
||||||
SwapBuffers(Graphics::hDC);
|
SwapBuffers(Graphics::hDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviousTime.QuadPart = CurrentTime.QuadPart;
|
PreviousTime.QuadPart = CurrentTime.QuadPart;
|
||||||
QueryPerformanceCounter(&CurrentTime);
|
QueryPerformanceCounter(&CurrentTime);
|
||||||
float SleepDuration =
|
float SleepDuration =
|
||||||
|
@ -107,7 +110,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
|
|
||||||
ShowWindow(Window::hWnd, SW_HIDE);
|
ShowWindow(Window::hWnd, SW_HIDE);
|
||||||
delete CurrentScene;
|
delete CurrentScene;
|
||||||
|
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
EngineInterface.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,8 +25,9 @@
|
||||||
|
|
||||||
//Standard libraries
|
//Standard libraries
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#undef NULL
|
#undef NULL
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Graphics/Font.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,25 +28,25 @@ FT_Face FontFace;
|
||||||
static void FindStringSize(const wchar_t * String, unsigned * width, unsigned * height, int * xoffset, int * yoffset, int font){
|
static void FindStringSize(const wchar_t * String, unsigned * width, unsigned * height, int * xoffset, int * yoffset, int font){
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
int lowestx = 0, lowesty = 0, highestx = 0, highesty = 0;
|
int lowestx = 0, lowesty = 0, highestx = 0, highesty = 0;
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
||||||
if(error) continue;
|
if(error) continue;
|
||||||
|
|
||||||
int bottomx = x + FontFace->glyph->bitmap_left;
|
int bottomx = x + FontFace->glyph->bitmap_left;
|
||||||
int bottomy = y + FontFace->glyph->bitmap_top - FontFace->glyph->bitmap.rows;
|
int bottomy = y + FontFace->glyph->bitmap_top - FontFace->glyph->bitmap.rows;
|
||||||
if(bottomx < lowestx) lowestx = bottomx;
|
if(bottomx < lowestx) lowestx = bottomx;
|
||||||
if(bottomy < lowesty) lowesty = bottomy;
|
if(bottomy < lowesty) lowesty = bottomy;
|
||||||
|
|
||||||
int topx = x + FontFace->glyph->bitmap_left + FontFace->glyph->bitmap.width;
|
int topx = x + FontFace->glyph->bitmap_left + FontFace->glyph->bitmap.width;
|
||||||
int topy = y + FontFace->glyph->bitmap_top;
|
int topy = y + FontFace->glyph->bitmap_top;
|
||||||
if(topx > highestx) highestx = topx;
|
if(topx > highestx) highestx = topx;
|
||||||
if(topy > highesty) highesty = topy;
|
if(topy > highesty) highesty = topy;
|
||||||
|
|
||||||
x += FontFace->glyph->advance.x >> 6;
|
x += FontFace->glyph->advance.x >> 6;
|
||||||
y += FontFace->glyph->advance.y >> 6;
|
y += FontFace->glyph->advance.y >> 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
*width = highestx-lowestx, *height = highesty-lowesty;
|
*width = highestx-lowestx, *height = highesty-lowesty;
|
||||||
*xoffset = -lowestx, *yoffset = -lowesty;
|
*xoffset = -lowestx, *yoffset = -lowesty;
|
||||||
}
|
}
|
||||||
|
@ -53,14 +56,14 @@ void DrawText(Image_t * Image, const wchar_t * String, int x, int y, unsigned wi
|
||||||
//x, y, width, height form the bounding rectangle into which the text should be drawn.
|
//x, y, width, height form the bounding rectangle into which the text should be drawn.
|
||||||
//(x,y) defines the offset to the top-left of the rectangle from the top left of the background.
|
//(x,y) defines the offset to the top-left of the rectangle from the top left of the background.
|
||||||
//The destination image must be stored in bottom-up order.
|
//The destination image must be stored in bottom-up order.
|
||||||
|
|
||||||
if(x >= (signed)Image->Width || y >= (signed)Image->Height) return;
|
if(x >= (signed)Image->Width || y >= (signed)Image->Height) return;
|
||||||
|
|
||||||
//(stringx,stringy) will refer to the top-left of the string in bottom-up coordinates
|
//(stringx,stringy) will refer to the top-left of the string in bottom-up coordinates
|
||||||
int stringx, stringy;
|
int stringx, stringy;
|
||||||
unsigned StringWidth, StringHeight;
|
unsigned StringWidth, StringHeight;
|
||||||
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
||||||
|
|
||||||
//Horizontal alignment
|
//Horizontal alignment
|
||||||
if(Alignment < 2) stringx = x; //Left
|
if(Alignment < 2) stringx = x; //Left
|
||||||
else if(Alignment < 4) stringx = x+(width-StringWidth+1)/2; //Middle
|
else if(Alignment < 4) stringx = x+(width-StringWidth+1)/2; //Middle
|
||||||
|
@ -69,17 +72,17 @@ void DrawText(Image_t * Image, const wchar_t * String, int x, int y, unsigned wi
|
||||||
if(!(Alignment&1)) stringy = y; //Top
|
if(!(Alignment&1)) stringy = y; //Top
|
||||||
else stringy = y+(height-StringHeight+1)/2; //Middle
|
else stringy = y+(height-StringHeight+1)/2; //Middle
|
||||||
stringy = Image->Height-stringy-StringHeight;
|
stringy = Image->Height-stringy-StringHeight;
|
||||||
|
|
||||||
//Now that we've done the alignment, we can crop the bounding box within the limits of the background image
|
//Now that we've done the alignment, we can crop the bounding box within the limits of the background image
|
||||||
if(x < 0){ Image->Width += x; x = 0; }
|
if(x < 0){ Image->Width += x; x = 0; }
|
||||||
if(y < 0){ Image->Height += y; y = 0; }
|
if(y < 0){ Image->Height += y; y = 0; }
|
||||||
if(width > Image->Width) width = Image->Width;
|
if(width > Image->Width) width = Image->Width;
|
||||||
if(height > Image->Height) height = Image->Height;
|
if(height > Image->Height) height = Image->Height;
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
||||||
if(error) continue;
|
if(error) continue;
|
||||||
|
|
||||||
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
||||||
if(cWidth && cHeight){
|
if(cWidth && cHeight){
|
||||||
uint8_t * cRender; /* Convert to Bottom-up */
|
uint8_t * cRender; /* Convert to Bottom-up */
|
||||||
|
@ -108,7 +111,7 @@ void DrawText(Image_t * Image, const wchar_t * String, int x, int y, unsigned wi
|
||||||
}
|
}
|
||||||
stringx -= FontFace->glyph->bitmap_left;
|
stringx -= FontFace->glyph->bitmap_left;
|
||||||
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
||||||
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
||||||
}
|
}
|
||||||
stringx += FontFace->glyph->advance.x >> 6;
|
stringx += FontFace->glyph->advance.x >> 6;
|
||||||
|
@ -123,7 +126,7 @@ Image_t * StringImage(const wchar_t * String, int font, COLORREF Color){
|
||||||
unsigned StringWidth, StringHeight;
|
unsigned StringWidth, StringHeight;
|
||||||
int stringx, stringy;
|
int stringx, stringy;
|
||||||
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
FindStringSize(String, &StringWidth, &StringHeight, &stringx, &stringy, font);
|
||||||
|
|
||||||
Image->Data = (uint8_t*) malloc(4 * StringWidth * StringHeight);
|
Image->Data = (uint8_t*) malloc(4 * StringWidth * StringHeight);
|
||||||
if(Image->Data == NULL){
|
if(Image->Data == NULL){
|
||||||
free(Image);
|
free(Image);
|
||||||
|
@ -135,11 +138,11 @@ Image_t * StringImage(const wchar_t * String, int font, COLORREF Color){
|
||||||
Image->Data[i++] = GetRValue(Color);
|
Image->Data[i++] = GetRValue(Color);
|
||||||
Image->Data[i++] = 0;
|
Image->Data[i++] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
for(wchar_t letter=*String; letter!='\0'; letter=*(++String)){
|
||||||
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
int error = FT_Load_Char(FontFace, letter, FT_LOAD_RENDER);
|
||||||
if(error) continue;
|
if(error) continue;
|
||||||
|
|
||||||
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
int cWidth = FontFace->glyph->bitmap.width, cHeight = FontFace->glyph->bitmap.rows;
|
||||||
if(cWidth && cHeight){
|
if(cWidth && cHeight){
|
||||||
uint8_t * cRender; /* Convert to Bottom-up */
|
uint8_t * cRender; /* Convert to Bottom-up */
|
||||||
|
@ -160,13 +163,13 @@ Image_t * StringImage(const wchar_t * String, int font, COLORREF Color){
|
||||||
}
|
}
|
||||||
stringx -= FontFace->glyph->bitmap_left;
|
stringx -= FontFace->glyph->bitmap_left;
|
||||||
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
stringy -= FontFace->glyph->bitmap_top-cHeight;
|
||||||
|
|
||||||
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
if(FontFace->glyph->bitmap.pitch > 0) free(cRender);
|
||||||
}
|
}
|
||||||
stringx += FontFace->glyph->advance.x >> 6;
|
stringx += FontFace->glyph->advance.x >> 6;
|
||||||
stringy += FontFace->glyph->advance.y >> 6;
|
stringy += FontFace->glyph->advance.y >> 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image->Width = StringWidth;
|
Image->Width = StringWidth;
|
||||||
Image->Height = StringHeight;
|
Image->Height = StringHeight;
|
||||||
Image->Format = FIMG_BGRA32;
|
Image->Format = FIMG_BGRA32;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Graphics/Graphics.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,10 +27,10 @@ namespace Graphics {
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
extern HDC hDC;
|
extern HDC hDC;
|
||||||
extern HGLRC hRC;
|
extern HGLRC hRC;
|
||||||
|
|
||||||
int InitGL();
|
int InitGL();
|
||||||
void ResizeViewport(unsigned width, unsigned height);
|
void ResizeViewport(unsigned width, unsigned height);
|
||||||
|
|
||||||
enum TextAlignment {
|
enum TextAlignment {
|
||||||
ALIGN_LEFT_TOP,
|
ALIGN_LEFT_TOP,
|
||||||
ALIGN_LEFT_CENTER,
|
ALIGN_LEFT_CENTER,
|
||||||
|
@ -36,7 +39,7 @@ namespace Graphics {
|
||||||
ALIGN_RIGHT_TOP,
|
ALIGN_RIGHT_TOP,
|
||||||
ALIGN_RIGHT_CENTER
|
ALIGN_RIGHT_CENTER
|
||||||
};
|
};
|
||||||
|
|
||||||
//Font.cpp
|
//Font.cpp
|
||||||
extern FT_Library FreeTypeLibrary;
|
extern FT_Library FreeTypeLibrary;
|
||||||
extern FT_Face FontFace;
|
extern FT_Face FontFace;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Graphics/Startup.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,7 +32,7 @@ int Initialize(){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_GRAPHICS_OBTAIN_DC;
|
return ERROR_GRAPHICS_OBTAIN_DC;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PIXELFORMATDESCRIPTOR pfd = {
|
const PIXELFORMATDESCRIPTOR pfd = {
|
||||||
sizeof(PIXELFORMATDESCRIPTOR), 1, //Size and version
|
sizeof(PIXELFORMATDESCRIPTOR), 1, //Size and version
|
||||||
PFD_DRAW_TO_WINDOW | //dwFlags
|
PFD_DRAW_TO_WINDOW | //dwFlags
|
||||||
|
@ -46,7 +49,7 @@ int Initialize(){
|
||||||
0, //Reserved
|
0, //Reserved
|
||||||
0, 0, 0 //Masks
|
0, 0, 0 //Masks
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned PixelFormat = ChoosePixelFormat(hDC, &pfd);
|
unsigned PixelFormat = ChoosePixelFormat(hDC, &pfd);
|
||||||
if(!PixelFormat){
|
if(!PixelFormat){
|
||||||
MessageBox(Window::hWnd, "Failed to find a suitable pixel format for the device context.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to find a suitable pixel format for the device context.", NULL, MB_OK | MB_ICONERROR);
|
||||||
|
@ -59,31 +62,31 @@ int Initialize(){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_GRAPHICS_SET_PIXELFORMAT;
|
return ERROR_GRAPHICS_SET_PIXELFORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
hRC = wglCreateContext(hDC);
|
hRC = wglCreateContext(hDC);
|
||||||
if(!hRC){
|
if(!hRC){
|
||||||
MessageBox(Window::hWnd, "Failed to create an OpenGL rendering context.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to create an OpenGL rendering context.", NULL, MB_OK | MB_ICONERROR);
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_GRAPHICS_CREATE_GLRC;
|
return ERROR_GRAPHICS_CREATE_GLRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wglMakeCurrent(hDC, hRC)){
|
if(!wglMakeCurrent(hDC, hRC)){
|
||||||
MessageBox(Window::hWnd, "Failed to activate the OpenGL device context.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to activate the OpenGL device context.", NULL, MB_OK | MB_ICONERROR);
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_GRAPHICS_ACTIVATE_GLRC;
|
return ERROR_GRAPHICS_ACTIVATE_GLRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL (WINAPI *wglSwapIntervalEXT)(int) = (BOOL (WINAPI *)(int)) wglGetProcAddress("wglSwapIntervalEXT");
|
BOOL (WINAPI *wglSwapIntervalEXT)(int) = (BOOL (WINAPI *)(int)) wglGetProcAddress("wglSwapIntervalEXT");
|
||||||
if(wglSwapIntervalEXT) wglSwapIntervalEXT(1);
|
if(wglSwapIntervalEXT) wglSwapIntervalEXT(1);
|
||||||
int (WINAPI *wglGetSwapIntervalEXT)(void) = (int (WINAPI *)(void)) wglGetProcAddress("wglGetSwapIntervalEXT");
|
int (WINAPI *wglGetSwapIntervalEXT)(void) = (int (WINAPI *)(void)) wglGetProcAddress("wglGetSwapIntervalEXT");
|
||||||
if(wglGetSwapIntervalEXT) wglGetSwapIntervalEXT(); //Seems necessary on some cards
|
if(wglGetSwapIntervalEXT) wglGetSwapIntervalEXT(); //Seems necessary on some cards
|
||||||
|
|
||||||
int result = InitGL();
|
int result = InitGL();
|
||||||
if(result != 0){
|
if(result != 0){
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return ERROR_GRAPHICS_INIT_GLSCENE | result;
|
return ERROR_GRAPHICS_INIT_GLSCENE | result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeViewport(Window::Width, Window::Height);
|
ResizeViewport(Window::Width, Window::Height);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Graphics/Viewport.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Scene/LoginScreen/LoginScreen.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -43,9 +46,9 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
glGenTextures(TEX_COUNT, texture);
|
glGenTextures(TEX_COUNT, texture);
|
||||||
|
|
||||||
FT_Set_Char_Size(Graphics::FontFace, 0, 22*64, 0, 0);
|
FT_Set_Char_Size(Graphics::FontFace, 0, 22*64, 0, 0);
|
||||||
|
|
||||||
for(int i=TEX_EAGAMES; i<=TEX_SETUP; i++){
|
for(int i=TEX_EAGAMES; i<=TEX_SETUP; i++){
|
||||||
Image_t * Image = File::ReadImageFile(images[i]);
|
Image_t * Image = File::ReadImageFile(images[i]);
|
||||||
if(!Image){
|
if(!Image){
|
||||||
|
@ -74,12 +77,12 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
||||||
EXIT_SCENE();
|
EXIT_SCENE();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i == TEX_MAXIS){
|
if(i == TEX_MAXIS){
|
||||||
Graphics::DrawText(Image, L"Maxis\x2122 is an Electronic Arts\x2122 brand.", 0, 600-146, 800, 146,
|
Graphics::DrawText(Image, L"Maxis\x2122 is an Electronic Arts\x2122 brand.", 0, 600-146, 800, 146,
|
||||||
Graphics::ALIGN_CENTER_CENTER, 0, RGB(0xef, 0xe3, 0x8c));
|
Graphics::ALIGN_CENTER_CENTER, 0, RGB(0xef, 0xe3, 0x8c));
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[i]);
|
glBindTexture(GL_TEXTURE_2D, texture[i]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
@ -89,7 +92,7 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
free(Image->Data);
|
free(Image->Data);
|
||||||
free(Image);
|
free(Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
image[IMG_COPYRIGHT] = Graphics::StringImage(L"(c) 2002, 2003 Electronic Arts Inc. All rights reserved.",
|
image[IMG_COPYRIGHT] = Graphics::StringImage(L"(c) 2002, 2003 Electronic Arts Inc. All rights reserved.",
|
||||||
0, RGB(0xef, 0xe3, 0x8c));
|
0, RGB(0xef, 0xe3, 0x8c));
|
||||||
if(image[IMG_COPYRIGHT] == NULL){
|
if(image[IMG_COPYRIGHT] == NULL){
|
||||||
|
@ -118,7 +121,7 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
GL_UNSIGNED_BYTE, image[IMG_STATUS+i]->Data);
|
GL_UNSIGNED_BYTE, image[IMG_STATUS+i]->Data);
|
||||||
free(image[IMG_STATUS+i]->Data);
|
free(image[IMG_STATUS+i]->Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<SND_COUNT; i++){
|
for(int i=0; i<SND_COUNT; i++){
|
||||||
Sound_t * Sound = File::ReadSoundFile(sounds[i]);
|
Sound_t * Sound = File::ReadSoundFile(sounds[i]);
|
||||||
if(!Sound){
|
if(!Sound){
|
||||||
|
@ -147,7 +150,7 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, Buffer, NULL, MB_OK | MB_ICONERROR);
|
||||||
EXIT_SCENE();
|
EXIT_SCENE();
|
||||||
}
|
}
|
||||||
|
|
||||||
sound[i] = Audio::LoadSound(Sound);
|
sound[i] = Audio::LoadSound(Sound);
|
||||||
free(Sound);
|
free(Sound);
|
||||||
if(!sound){
|
if(!sound){
|
||||||
|
@ -157,11 +160,11 @@ LoginScreen::LoginScreen() : Scene(0){
|
||||||
Audio::PlaySound(sound[i]);
|
Audio::PlaySound(sound[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginScreen::~LoginScreen(){
|
LoginScreen::~LoginScreen(){
|
||||||
for(int i=0; i<IMG_COUNT; i++){ if(image[i]) free(image[i]); }
|
for(int i=0; i<IMG_COUNT; i++){ if(image[i]) free(image[i]); }
|
||||||
glDeleteTextures(TEX_COUNT, texture);
|
glDeleteTextures(TEX_COUNT, texture);
|
||||||
|
|
||||||
for(int i=0; i<SND_COUNT; i++){
|
for(int i=0; i<SND_COUNT; i++){
|
||||||
if(sound[i]){
|
if(sound[i]){
|
||||||
Audio::DeleteSound(sound[i]);
|
Audio::DeleteSound(sound[i]);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Scene/LoginScreen/LoginScreen.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -47,7 +50,7 @@ class LoginScreen : public Scene {
|
||||||
LoginScreen();
|
LoginScreen();
|
||||||
~LoginScreen();
|
~LoginScreen();
|
||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int Run(float TimeDelta);
|
int Run(float TimeDelta);
|
||||||
};
|
};
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Scene/Scene.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,7 +37,7 @@ class Scene {
|
||||||
if(TickPeriod == 0){
|
if(TickPeriod == 0){
|
||||||
return Run(TimeDelta);
|
return Run(TimeDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Redraw = false;
|
bool Redraw = false;
|
||||||
RealTimeDelta += TimeDelta;
|
RealTimeDelta += TimeDelta;
|
||||||
while(RealTimeDelta >= 0){
|
while(RealTimeDelta >= 0){
|
||||||
|
@ -46,7 +49,7 @@ class Scene {
|
||||||
}
|
}
|
||||||
return (Redraw) ? 1 : -1;
|
return (Redraw) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Render() = 0;
|
virtual void Render() = 0;
|
||||||
virtual ~Scene() {};
|
virtual ~Scene() {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
System/System.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,17 +27,17 @@ HANDLE Process;
|
||||||
HANDLE ProcessHeap;
|
HANDLE ProcessHeap;
|
||||||
LARGE_INTEGER ClockFreq;
|
LARGE_INTEGER ClockFreq;
|
||||||
volatile float FramePeriod;
|
volatile float FramePeriod;
|
||||||
UserInput_t UserInput = {0};
|
UserInput_t UserInput = UserInput_t();
|
||||||
volatile UserInput_t UserInput_v;
|
volatile UserInput_t UserInput_v;
|
||||||
bool SceneFailed = false;
|
bool SceneFailed = false;
|
||||||
|
|
||||||
int Initialize(){
|
int Initialize(){
|
||||||
QueryPerformanceFrequency(&ClockFreq);
|
QueryPerformanceFrequency(&ClockFreq);
|
||||||
|
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
||||||
System::FramePeriod = 1.0f/dm.dmDisplayFrequency;
|
System::FramePeriod = 1.0f/dm.dmDisplayFrequency;
|
||||||
|
|
||||||
if(FT_Init_FreeType(&Graphics::FreeTypeLibrary)){
|
if(FT_Init_FreeType(&Graphics::FreeTypeLibrary)){
|
||||||
MessageBox(Window::hWnd, "Failed to initialize FreeType.", NULL, MB_OK | MB_ICONERROR);
|
MessageBox(Window::hWnd, "Failed to initialize FreeType.", NULL, MB_OK | MB_ICONERROR);
|
||||||
Graphics::FreeTypeLibrary = NULL;
|
Graphics::FreeTypeLibrary = NULL;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
System/System.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,7 +27,7 @@ namespace System {
|
||||||
extern HANDLE ProcessHeap;
|
extern HANDLE ProcessHeap;
|
||||||
extern LARGE_INTEGER ClockFreq;
|
extern LARGE_INTEGER ClockFreq;
|
||||||
extern volatile float FramePeriod;
|
extern volatile float FramePeriod;
|
||||||
|
|
||||||
struct UserInput_t {
|
struct UserInput_t {
|
||||||
bool Keys[256];
|
bool Keys[256];
|
||||||
bool MouseDown;
|
bool MouseDown;
|
||||||
|
@ -34,7 +37,7 @@ namespace System {
|
||||||
extern volatile UserInput_t UserInput_v;
|
extern volatile UserInput_t UserInput_v;
|
||||||
|
|
||||||
extern bool SceneFailed;
|
extern bool SceneFailed;
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
enum {
|
enum {
|
||||||
SHUTDOWN = 0
|
SHUTDOWN = 0
|
||||||
|
|
|
@ -12,7 +12,7 @@ Development Phase: Planning
|
||||||
Technical Preview 1
|
Technical Preview 1
|
||||||
Schedule: (Not very subject to change)
|
Schedule: (Not very subject to change)
|
||||||
1. Implement cst and uis parsers [40%]
|
1. Implement cst and uis parsers [40%]
|
||||||
2. Replicate functionality up until the login dialog [0%]
|
2. Replicate functionality up until the login dialog [90%]
|
||||||
3. Implement the OpenGL-based windowing system
|
3. Implement the OpenGL-based windowing system
|
||||||
4. Replicate character selection and creation features and the city selection dialog
|
4. Replicate character selection and creation features and the city selection dialog
|
||||||
5. Implement the code needed to allow the game to read all necessary files from the TSOClient folder
|
5. Implement the code needed to allow the game to read all necessary files from the TSOClient folder
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Window/Window.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso - The New Implementation of The Sims Online
|
||||||
|
Window/Window.hpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
2
Libraries/FileHandler/AUTHORS
Normal file
2
Libraries/FileHandler/AUTHORS
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Fatbag <X-Fi6@phppoll.org>
|
||||||
|
Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
FileHandler - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
Audio.cpp - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -51,7 +53,7 @@ static uint8_t* (* const SoundFunction[])(Sound_t*, const uint8_t*, size_t) = {
|
||||||
Sound_t * ReadSoundFile(const char * Filename){
|
Sound_t * ReadSoundFile(const char * Filename){
|
||||||
uint8_t * InData = File::ReadFile(Filename);
|
uint8_t * InData = File::ReadFile(Filename);
|
||||||
if(InData == NULL) return NULL;
|
if(InData == NULL) return NULL;
|
||||||
|
|
||||||
if(File::FileSize < 4){
|
if(File::FileSize < 4){
|
||||||
free(InData);
|
free(InData);
|
||||||
File::Error = FERR_INVALIDDATA;
|
File::Error = FERR_INVALIDDATA;
|
||||||
|
@ -87,13 +89,13 @@ static uint8_t * ReadWAV(Sound_t * Sound, const uint8_t * InData, size_t FileSiz
|
||||||
if(!wav_read_header(&WAVHeader, InData, FileSize)){
|
if(!wav_read_header(&WAVHeader, InData, FileSize)){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * OutData = (uint8_t*) malloc(WAVHeader.DataSize);
|
uint8_t * OutData = (uint8_t*) malloc(WAVHeader.DataSize);
|
||||||
if(OutData == NULL){
|
if(OutData == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(OutData, InData+44, WAVHeader.DataSize);
|
memcpy(OutData, InData+44, WAVHeader.DataSize);
|
||||||
|
|
||||||
Sound->Channels = WAVHeader.nChannels;
|
Sound->Channels = WAVHeader.nChannels;
|
||||||
Sound->SamplingRate = WAVHeader.nSamplesPerSec;
|
Sound->SamplingRate = WAVHeader.nSamplesPerSec;
|
||||||
Sound->BitDepth = WAVHeader.wBitsPerSample;
|
Sound->BitDepth = WAVHeader.wBitsPerSample;
|
||||||
|
@ -108,7 +110,7 @@ static uint8_t * ReadXA(Sound_t * Sound, const uint8_t * InData, size_t FileSize
|
||||||
if(!xa_read_header(&XAHeader, InData, FileSize)){
|
if(!xa_read_header(&XAHeader, InData, FileSize)){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * OutData = (uint8_t*) malloc(XAHeader.dwOutSize);
|
uint8_t * OutData = (uint8_t*) malloc(XAHeader.dwOutSize);
|
||||||
if(OutData == NULL){
|
if(OutData == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -117,7 +119,7 @@ static uint8_t * ReadXA(Sound_t * Sound, const uint8_t * InData, size_t FileSize
|
||||||
free(OutData);
|
free(OutData);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound->Channels = XAHeader.nChannels;
|
Sound->Channels = XAHeader.nChannels;
|
||||||
Sound->SamplingRate = XAHeader.nSamplesPerSec;
|
Sound->SamplingRate = XAHeader.nSamplesPerSec;
|
||||||
Sound->BitDepth = XAHeader.wBitsPerSample;
|
Sound->BitDepth = XAHeader.wBitsPerSample;
|
||||||
|
@ -131,12 +133,12 @@ static uint8_t * ReadUTK(Sound_t * Sound, const uint8_t * InData, size_t FileSiz
|
||||||
if(!utk_read_header(&UTKHeader, InData, FileSize)){
|
if(!utk_read_header(&UTKHeader, InData, FileSize)){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * OutData = (uint8_t*) malloc(UTKHeader.dwOutSize);
|
uint8_t * OutData = (uint8_t*) malloc(UTKHeader.dwOutSize);
|
||||||
if(OutData == NULL){
|
if(OutData == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool generated = false;
|
static bool generated = false;
|
||||||
if(!generated){
|
if(!generated){
|
||||||
UTKGenerateTables();
|
UTKGenerateTables();
|
||||||
|
@ -147,7 +149,7 @@ static uint8_t * ReadUTK(Sound_t * Sound, const uint8_t * InData, size_t FileSiz
|
||||||
free(OutData);
|
free(OutData);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound->Channels = 1;
|
Sound->Channels = 1;
|
||||||
Sound->SamplingRate = UTKHeader.nSamplesPerSec;
|
Sound->SamplingRate = UTKHeader.nSamplesPerSec;
|
||||||
Sound->BitDepth = UTKHeader.wBitsPerSample;
|
Sound->BitDepth = UTKHeader.wBitsPerSample;
|
||||||
|
@ -161,7 +163,7 @@ static uint8_t * ReadMP3(Sound_t * Sound, const uint8_t * InData, size_t FileSiz
|
||||||
mpg123_exit();
|
mpg123_exit();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
long rate;
|
long rate;
|
||||||
int channels, encoding;
|
int channels, encoding;
|
||||||
unsigned samples;
|
unsigned samples;
|
||||||
|
@ -190,12 +192,12 @@ static uint8_t * ReadMP3(Sound_t * Sound, const uint8_t * InData, size_t FileSiz
|
||||||
mpg123_close(mh);
|
mpg123_close(mh);
|
||||||
mpg123_delete(mh);
|
mpg123_delete(mh);
|
||||||
mpg123_exit();
|
mpg123_exit();
|
||||||
|
|
||||||
if(decoded != OutSize){
|
if(decoded != OutSize){
|
||||||
free(OutData);
|
free(OutData);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound->Channels = channels;
|
Sound->Channels = channels;
|
||||||
Sound->SamplingRate = rate;
|
Sound->SamplingRate = rate;
|
||||||
Sound->BitDepth = 16;
|
Sound->BitDepth = 16;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
project(FileHandler)
|
project(FileHandler)
|
||||||
|
|
||||||
|
add_subdirectory(far)
|
||||||
add_subdirectory(iff)
|
add_subdirectory(iff)
|
||||||
add_subdirectory(libexpat)
|
add_subdirectory(libexpat)
|
||||||
add_subdirectory(libfar)
|
|
||||||
add_subdirectory(libjpeg-turbo)
|
add_subdirectory(libjpeg-turbo)
|
||||||
add_subdirectory(libmpg123)
|
add_subdirectory(libmpg123)
|
||||||
add_subdirectory(libpng)
|
add_subdirectory(libpng)
|
||||||
|
|
15
Libraries/FileHandler/COPYING
Normal file
15
Libraries/FileHandler/COPYING
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
Version 0.0.0
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
FileHandler - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
File.cpp - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
FileHandler - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
FileHandler.hpp - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
FileHandler - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
Image.cpp - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -42,7 +44,7 @@ static uint8_t * ReadTGACUR(Image_t * Image, const uint8_t * InData, size_t File
|
||||||
//In many cases we're going to see these bytes, exactly, at the beginning in both formats:
|
//In many cases we're going to see these bytes, exactly, at the beginning in both formats:
|
||||||
//00 00 02 00 01 00
|
//00 00 02 00 01 00
|
||||||
//So screw it. Try parsing the file first as a TGA, then as a CUR.
|
//So screw it. Try parsing the file first as a TGA, then as a CUR.
|
||||||
|
|
||||||
uint8_t * Result = ReadTGA(Image, InData, FileSize);
|
uint8_t * Result = ReadTGA(Image, InData, FileSize);
|
||||||
return Result ? Result : ReadCUR(Image, InData, FileSize);
|
return Result ? Result : ReadCUR(Image, InData, FileSize);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +65,7 @@ static uint8_t* (* const ImageFunction[])(Image_t*, const uint8_t*, size_t) = {
|
||||||
Image_t * ReadImageFile(const char * Filename){
|
Image_t * ReadImageFile(const char * Filename){
|
||||||
uint8_t * InData = File::ReadFile(Filename);
|
uint8_t * InData = File::ReadFile(Filename);
|
||||||
if(InData == NULL) return NULL;
|
if(InData == NULL) return NULL;
|
||||||
|
|
||||||
if(File::FileSize < 4){
|
if(File::FileSize < 4){
|
||||||
free(InData);
|
free(InData);
|
||||||
File::Error = FERR_INVALIDDATA;
|
File::Error = FERR_INVALIDDATA;
|
||||||
|
@ -99,7 +101,7 @@ static uint8_t * ReadBMP(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
||||||
if(!bmp_read_header(&BMPHeader, InData, FileSize)){
|
if(!bmp_read_header(&BMPHeader, InData, FileSize)){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * OutData = (uint8_t*) malloc(BMPHeader.DecompressedSize);
|
uint8_t * OutData = (uint8_t*) malloc(BMPHeader.DecompressedSize);
|
||||||
if(OutData == NULL){
|
if(OutData == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -108,7 +110,7 @@ static uint8_t * ReadBMP(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
||||||
free(OutData);
|
free(OutData);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image->Width = BMPHeader.biWidth;
|
Image->Width = BMPHeader.biWidth;
|
||||||
Image->Height = BMPHeader.biHeight;
|
Image->Height = BMPHeader.biHeight;
|
||||||
Image->Format = FIMG_BGR24;
|
Image->Format = FIMG_BGR24;
|
||||||
|
@ -179,7 +181,7 @@ static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t lengt
|
||||||
}
|
}
|
||||||
static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
||||||
pngdata_t pngdata;
|
pngdata_t pngdata;
|
||||||
|
|
||||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if(png_ptr == NULL) return 0;
|
if(png_ptr == NULL) return 0;
|
||||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
@ -191,7 +193,7 @@ static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pngdata.buffer = InData;
|
pngdata.buffer = InData;
|
||||||
pngdata.size = FileSize;
|
pngdata.size = FileSize;
|
||||||
png_set_read_fn(png_ptr, &pngdata, user_read_data);
|
png_set_read_fn(png_ptr, &pngdata, user_read_data);
|
||||||
|
@ -199,7 +201,7 @@ static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
||||||
png_read_png(png_ptr, info_ptr,
|
png_read_png(png_ptr, info_ptr,
|
||||||
PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_STRIP_ALPHA |
|
PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_STRIP_ALPHA |
|
||||||
PNG_TRANSFORM_PACKING | PNG_TRANSFORM_GRAY_TO_RGB | PNG_TRANSFORM_BGR, NULL);
|
PNG_TRANSFORM_PACKING | PNG_TRANSFORM_GRAY_TO_RGB | PNG_TRANSFORM_BGR, NULL);
|
||||||
|
|
||||||
//png_get_IHDR does not work in high-level mode.
|
//png_get_IHDR does not work in high-level mode.
|
||||||
unsigned width = png_get_image_width(png_ptr, info_ptr);
|
unsigned width = png_get_image_width(png_ptr, info_ptr);
|
||||||
unsigned height = png_get_image_height(png_ptr, info_ptr);
|
unsigned height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
@ -208,11 +210,11 @@ static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t **Scanlines = png_get_rows(png_ptr, info_ptr);
|
uint8_t **Scanlines = png_get_rows(png_ptr, info_ptr);
|
||||||
for(unsigned i=0; i<height; i++)
|
for(unsigned i=0; i<height; i++)
|
||||||
memcpy(OutData + i*width*3, Scanlines[height-i-1], width*3);
|
memcpy(OutData + i*width*3, Scanlines[height-i-1], width*3);
|
||||||
|
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
Image->Width = width;
|
Image->Width = width;
|
||||||
Image->Height = height;
|
Image->Height = height;
|
||||||
|
|
32
Libraries/FileHandler/README
Normal file
32
Libraries/FileHandler/README
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
***************************************************************************
|
||||||
|
* ** FileHandler - General-purpose file handling library for Niotso ** *
|
||||||
|
* ** Copyright (c) 2011-2012 Niotso Project <http://niotso.org/ ** *
|
||||||
|
* *
|
||||||
|
* Use and distribution of all files in the "include" and "lib" folders *
|
||||||
|
* are governed under the ISC License, included with this source code in *
|
||||||
|
* "COPYING". *
|
||||||
|
* *
|
||||||
|
* All other files included but not aforementioned are not copyrighted, *
|
||||||
|
* and are distributed into the public domain. *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
FileHandler is a generic C++ library written specifically for Niotso and used to read, and sometimes modify and write,
|
||||||
|
the various types of files used in The Sims Online.
|
||||||
|
|
||||||
|
FileHandler outsources most of its work to de-facto third-party libraries written in C89 (zlib, libpng, libjpeg-turbo,
|
||||||
|
libmpg123, ...), while other libraries, also written in C89, are provided inside FileHandler, without a flashy name (bmp, cst,
|
||||||
|
iff, far, ...).
|
||||||
|
|
||||||
|
FileHandler wraps around these libraries and provides a convenient C++ API to interact with these files to just the degree
|
||||||
|
needed by Niotso. The function of FileHandler is analogous to the gimex library used in The Sims Online.
|
||||||
|
|
||||||
|
Supported formats:
|
||||||
|
Image:
|
||||||
|
(*) bmp, png, jpg, cur, tga
|
||||||
|
Audio:
|
||||||
|
(*) wav, mp3, xa, utk
|
||||||
|
Archive:
|
||||||
|
(*) far, iff
|
||||||
|
Plain-text:
|
||||||
|
(*) ini, xml, cst, uis
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_bmp.c - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_bmp.c - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -49,7 +51,7 @@ int bmp_read_header(bmpheader_t * BMPHeader, const uint8_t * Buffer, size_t File
|
||||||
BMPHeader->biYPelsPerMeter = read_uint32(Buffer+42);
|
BMPHeader->biYPelsPerMeter = read_uint32(Buffer+42);
|
||||||
BMPHeader->biClrUsed = read_uint32(Buffer+46);
|
BMPHeader->biClrUsed = read_uint32(Buffer+46);
|
||||||
BMPHeader->biClrImportant = read_uint32(Buffer+50);
|
BMPHeader->biClrImportant = read_uint32(Buffer+50);
|
||||||
|
|
||||||
BMPHeader->CompressedSize = FileSize - BMPHeader->bfOffBits;
|
BMPHeader->CompressedSize = FileSize - BMPHeader->bfOffBits;
|
||||||
BMPHeader->DecompressedSize = BMPHeader->biWidth * BMPHeader->biHeight * 3;
|
BMPHeader->DecompressedSize = BMPHeader->biWidth * BMPHeader->biHeight * 3;
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ int bmp_read_header(bmpheader_t * BMPHeader, const uint8_t * Buffer, size_t File
|
||||||
(BMPHeader->biBitCount == 8 && BMPHeader->CompressedSize < BMPHeader->DecompressedSize/3 +
|
(BMPHeader->biBitCount == 8 && BMPHeader->CompressedSize < BMPHeader->DecompressedSize/3 +
|
||||||
BMPHeader->biHeight*(BMPHeader->biWidth%4) /* Account for padding in 8-bit BMPs */)))
|
BMPHeader->biHeight*(BMPHeader->biWidth%4) /* Account for padding in 8-bit BMPs */)))
|
||||||
) return 0;
|
) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ int bmp_read_data(bmpheader_t * BMPHeader, const uint8_t *__restrict InBuffer, u
|
||||||
memcpy(OutBuffer, InBuffer+BMPHeader->bfOffBits, BMPHeader->DecompressedSize);
|
memcpy(OutBuffer, InBuffer+BMPHeader->bfOffBits, BMPHeader->DecompressedSize);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BMPHeader->biBitCount == 8){
|
if(BMPHeader->biBitCount == 8){
|
||||||
const uint8_t *__restrict Palette = InBuffer + 54;
|
const uint8_t *__restrict Palette = InBuffer + 54;
|
||||||
InBuffer += BMPHeader->bfOffBits;
|
InBuffer += BMPHeader->bfOffBits;
|
||||||
|
@ -98,7 +100,7 @@ int bmp_read_data(bmpheader_t * BMPHeader, const uint8_t *__restrict InBuffer, u
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BMPHeader->biCompression == BI_RLE8){
|
if(BMPHeader->biCompression == BI_RLE8){
|
||||||
const uint8_t *__restrict const srcend = InBuffer+BMPHeader->CompressedSize;
|
const uint8_t *__restrict const srcend = InBuffer+BMPHeader->CompressedSize;
|
||||||
uint8_t *__restrict const destend = OutBuffer+BMPHeader->DecompressedSize;
|
uint8_t *__restrict const destend = OutBuffer+BMPHeader->DecompressedSize;
|
||||||
|
@ -107,12 +109,12 @@ int bmp_read_data(bmpheader_t * BMPHeader, const uint8_t *__restrict InBuffer, u
|
||||||
unsigned i;
|
unsigned i;
|
||||||
const unsigned command = *InBuffer++;
|
const unsigned command = *InBuffer++;
|
||||||
const unsigned value = *InBuffer++;
|
const unsigned value = *InBuffer++;
|
||||||
|
|
||||||
if(command == 0){
|
if(command == 0){
|
||||||
if(value == 0) continue; /* End of scanline reminder */
|
if(value == 0) continue; /* End of scanline reminder */
|
||||||
if(value == 1) return (InBuffer == srcend && OutBuffer == destend); /* End of bitmap reminder */
|
if(value == 1) return (InBuffer == srcend && OutBuffer == destend); /* End of bitmap reminder */
|
||||||
if(value == 2) return 0; /* Delta, used for ICO/CUR masks; wrong kind of bitmap */
|
if(value == 2) return 0; /* Delta, used for ICO/CUR masks; wrong kind of bitmap */
|
||||||
|
|
||||||
/* Absolute copy */
|
/* Absolute copy */
|
||||||
if(value > (unsigned)(srcend-InBuffer) || value*3 > (unsigned)(destend-OutBuffer)) break;
|
if(value > (unsigned)(srcend-InBuffer) || value*3 > (unsigned)(destend-OutBuffer)) break;
|
||||||
for(i=0; i<value; i++){
|
for(i=0; i<value; i++){
|
||||||
|
@ -133,9 +135,7 @@ int bmp_read_data(bmpheader_t * BMPHeader, const uint8_t *__restrict InBuffer, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_bmp.h - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_bmp.h - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -34,7 +36,7 @@ typedef struct
|
||||||
uint32_t biYPelsPerMeter;
|
uint32_t biYPelsPerMeter;
|
||||||
uint32_t biClrUsed;
|
uint32_t biClrUsed;
|
||||||
uint32_t biClrImportant;
|
uint32_t biClrImportant;
|
||||||
|
|
||||||
size_t CompressedSize;
|
size_t CompressedSize;
|
||||||
size_t DecompressedSize;
|
size_t DecompressedSize;
|
||||||
} bmpheader_t;
|
} bmpheader_t;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
cst.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
cst.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
cst.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
cst.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_cur.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
it under the terms of the GNU General Public License as published by
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
copyright notice and this permission notice appear in all copies.
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
GNU General Public License for more details.
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
You should have received a copy of the GNU General Public License
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
|
@ -1,16 +1,17 @@
|
||||||
/*
|
/*
|
||||||
Niotso - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_cur.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
it under the terms of the GNU General Public License as published by
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
copyright notice and this permission notice appear in all copies.
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
GNU General Public License for more details.
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
You should have received a copy of the GNU General Public License
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
22
Libraries/FileHandler/far/CMakeLists.txt
Normal file
22
Libraries/FileHandler/far/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
project(far)
|
||||||
|
|
||||||
|
set(FAR_SOURCES
|
||||||
|
libfar.c
|
||||||
|
refpack_dec.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(far_static STATIC ${FAR_SOURCES})
|
||||||
|
set_target_properties(far_static PROPERTIES
|
||||||
|
OUTPUT_NAME "far"
|
||||||
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
|
||||||
|
#### Shared library (uncomment to build)
|
||||||
|
#add_library(far_shared SHARED ${FAR_SOURCES})
|
||||||
|
#set_target_properties(far_shared PROPERTIES
|
||||||
|
# OUTPUT_NAME "far"
|
||||||
|
# PREFIX ""
|
||||||
|
# CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
|
||||||
|
add_executable(farextract farextract.c)
|
||||||
|
target_link_libraries(farextract far_static)
|
42
Libraries/FileHandler/far/Makefile
Normal file
42
Libraries/FileHandler/far/Makefile
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# macros --------------------------------------------------------------------
|
||||||
|
CC = gcc
|
||||||
|
LD = gcc
|
||||||
|
CFLAGS = -m32 -Wall -Wextra -Wabi -Os -march=i686 -fomit-frame-pointer -ffast-math -funsafe-loop-optimizations -fmerge-all-constants -g0 -fno-exceptions
|
||||||
|
LDFLAGS = -m32 -s -fwhole-program
|
||||||
|
|
||||||
|
AR = ar rcs
|
||||||
|
WINDRES = windres -F pe-i386
|
||||||
|
|
||||||
|
LIBRARY_OBJS = obj/libfar.o obj/qfsdecompress.o
|
||||||
|
RESOURCE_OBJ = obj/resource.o
|
||||||
|
FAREXTRACT_OBJ = obj/farextract.o
|
||||||
|
|
||||||
|
# These will rebuild the entire library upon edit.
|
||||||
|
DEPS = Makefile \
|
||||||
|
config.h \
|
||||||
|
include/libfar.h
|
||||||
|
|
||||||
|
# dependencies --------------------------------------------------------------
|
||||||
|
all: libfar.a libfar-10.dll farextract.exe
|
||||||
|
|
||||||
|
$(LIBRARY_OBJS): $(DEPS)
|
||||||
|
|
||||||
|
libfar.a: $(LIBRARY_OBJS)
|
||||||
|
$(AR) $@ $(LIBRARY_OBJS)
|
||||||
|
|
||||||
|
libfar-10.dll: $(LIBRARY_OBJS) $(RESOURCE_OBJ)
|
||||||
|
$(CC) $(LDFLAGS) -shared -o $@ $(LIBRARY_OBJS) $(RESOURCE_OBJ)
|
||||||
|
|
||||||
|
farextract.exe: libfar.a $(FAREXTRACT_OBJ)
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $(FAREXTRACT_OBJ) libfar.a
|
||||||
|
|
||||||
|
# make rules ----------------------------------------------------------------
|
||||||
|
obj/%.o: %.c
|
||||||
|
$(CC) -c -ansi -pedantic $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
obj/%.o: %.rc
|
||||||
|
$(WINDRES) -i $< -o $@
|
||||||
|
|
||||||
|
# maintenance ---------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
del /Q /S obj libfar.a libfar-10.dll farextract.exe
|
24
Libraries/FileHandler/far/config.h
Normal file
24
Libraries/FileHandler/far/config.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* config.h - libfar build configuration */
|
||||||
|
|
||||||
|
/* Define if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* compile-in support */
|
||||||
|
#define LIBFAR_ARCHIVEREAD
|
||||||
|
#define LIBFAR_ARCHIVEWRITE
|
||||||
|
#define LIBFAR_REFPACK_DECOMPRESS
|
||||||
|
#define LIBFAR_REFPACK_COMPRESS
|
||||||
|
#define LIBFAR_SUPPORT_FAR
|
||||||
|
#define LIBFAR_SUPPORT_DBPF
|
||||||
|
#define LIBFAR_SUPPORT_PERSIST
|
||||||
|
#define LIBFAR_DEBUGSUPPORT
|
||||||
|
#define LIBFAR_FILEIO
|
||||||
|
#define LIBFAR_EMBEDDEDFUNCTIONS
|
||||||
|
/* end of compile-in support */
|
||||||
|
|
||||||
|
/* preferences -- on non-numerical definitions, define to 1 for "yes", 0 for "no"; */
|
||||||
|
#define LIBFAR_DEFAULT_1A 0
|
||||||
|
#define LIBFAR_DEFAULT_DBPF_COMPRESSED 0
|
||||||
|
#define LIBFAR_DEFAULT_MAX_FILE_NAME_LENGTH 255
|
||||||
|
#define LIBFAR_DEFAULT_REFPACK_HNSV 0xFB
|
||||||
|
/* end of default preferences */
|
287
Libraries/FileHandler/far/farextract.c
Normal file
287
Libraries/FileHandler/far/farextract.c
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
farextract.c - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#else
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef signed long int32_t;
|
||||||
|
typedef unsigned long uint32_t;
|
||||||
|
typedef unsigned int uintptr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libfar.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
profile_ts1 = 1,
|
||||||
|
profile_tso,
|
||||||
|
profile_sc4,
|
||||||
|
profile_ts2,
|
||||||
|
profile_spore,
|
||||||
|
profile_ts3
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
int profile = 0, overwrite = 0;
|
||||||
|
char infile[256] = "", outdirectory[256] = "";
|
||||||
|
|
||||||
|
HANDLE ProcessHeap = GetProcessHeap();
|
||||||
|
HANDLE hFile;
|
||||||
|
DWORD ArchiveSize;
|
||||||
|
DWORD bytestransferred = 0;
|
||||||
|
uint8_t * ArchiveData;
|
||||||
|
int ArchiveType;
|
||||||
|
|
||||||
|
unsigned BeginningTime, EndingTime;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Check the arguments
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(argc == 1 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))){
|
||||||
|
printf("Usage: farextract [OPTIONS] [FILE] [OUTDIRECTORY]\n"
|
||||||
|
"Extract the contents of a FAR, DBPF, or Persist file.\n"
|
||||||
|
"With no FILE, or when FILE is -, read from standard input.\n"
|
||||||
|
"\n"
|
||||||
|
"Profile options:\n"
|
||||||
|
" -ts1, -tso, -sc4, Select presets suitable for The Sims 1,\n"
|
||||||
|
" -ts2, -spore, -ts3 The Sims Online, SimCity 4, Spore, or The Sims 3\n"
|
||||||
|
"\n");
|
||||||
|
printf("Miscellaneous options:\n"
|
||||||
|
" -f, --force Force overwriting of files without confirmation\n"
|
||||||
|
" -h, --help Show this help and exit\n"
|
||||||
|
"\n"
|
||||||
|
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||||
|
"farextract and libfar are maintained by the Niotso project.\n"
|
||||||
|
"Home page: <http://www.niotso.org/>");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=1; !infile[0] && i != argc-1; i++){
|
||||||
|
/* Match for options */
|
||||||
|
if(!profile){
|
||||||
|
if(!strcmp(argv[i], "-ts1")){ profile = profile_ts1; continue; }
|
||||||
|
if(!strcmp(argv[i], "-tso")){ profile = profile_tso; continue; }
|
||||||
|
if(!strcmp(argv[i], "-sc4")){ profile = profile_sc4; continue; }
|
||||||
|
if(!strcmp(argv[i], "-ts2")){ profile = profile_ts2; continue; }
|
||||||
|
if(!strcmp(argv[i], "-spore")){ profile = profile_spore; continue; }
|
||||||
|
if(!strcmp(argv[i], "-ts3")){ profile = profile_ts3; continue; }
|
||||||
|
}
|
||||||
|
if(!overwrite && (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--force"))){
|
||||||
|
overwrite = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* Not an option */
|
||||||
|
if(!strcmp(argv[i], "-")){
|
||||||
|
printf("%sReading from standard input is not yet implemented.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strcpy(infile, argv[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* We're left with the out directory */
|
||||||
|
if(!infile[0]){
|
||||||
|
printf("%sReading from standard input is not yet implemented.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strcpy(outdirectory, argv[i]);
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Handle profile settings
|
||||||
|
*/
|
||||||
|
if(!profile) profile = profile_tso;
|
||||||
|
libfar_set_option(LIBFAR_CONFIG_DEFAULT_TO_1A, (profile == profile_ts1));
|
||||||
|
libfar_set_option(LIBFAR_CONFIG_DBPF_COMPRESSED, (profile >= profile_sc4));
|
||||||
|
libfar_set_option(LIBFAR_CONFIG_REFPACK_HNSV, 0xFB);
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Attempt to open the file and read in the entire contents to memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
hFile = CreateFile(infile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
if(hFile == INVALID_HANDLE_VALUE){
|
||||||
|
if(GetLastError() == ERROR_FILE_NOT_FOUND){
|
||||||
|
printf("%sThe specified input file does not exist.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("%sThe input file could not be opened for reading.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ArchiveSize = GetFileSize(hFile, NULL);
|
||||||
|
if(ArchiveSize < LIBFAR_ARCHIVE_MINIMUM_SIZE){
|
||||||
|
printf("%sNot a valid archive.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ArchiveData = HeapAlloc(ProcessHeap, HEAP_NO_SERIALIZE, ArchiveSize);
|
||||||
|
if(ArchiveData == NULL){
|
||||||
|
printf("%sMemory for this archive could not be allocated.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!ReadFile(hFile, ArchiveData, ArchiveSize, &bytestransferred, NULL) || bytestransferred != ArchiveSize){
|
||||||
|
printf("%sThe input file could not be read.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Identify the type of archive
|
||||||
|
*/
|
||||||
|
|
||||||
|
ArchiveType = far_identify(ArchiveData, ArchiveSize);
|
||||||
|
if(ArchiveType == FAR_TYPE_INVALID){
|
||||||
|
printf("%sNot a valid archive.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ArchiveType != FAR_TYPE_PERSIST){
|
||||||
|
FAREntryNode * EntryNode;
|
||||||
|
unsigned file = 0, filescount;
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Load header information
|
||||||
|
*/
|
||||||
|
|
||||||
|
FARFile * FARFileInfo = far_create_archive(ArchiveType);
|
||||||
|
if(FARFileInfo == NULL){
|
||||||
|
printf("%sMemory for this archive could not be allocated.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!far_read_header(FARFileInfo, ArchiveData, ArchiveSize)){
|
||||||
|
printf("%sNot a valid archive.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
filescount = FARFileInfo->Files;
|
||||||
|
printf("This archive contains %u files.\n\nExtracting\n", filescount);
|
||||||
|
BeginningTime = GetTickCount();
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Load entry information
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(!far_enumerate_entries(FARFileInfo, ArchiveData+FARFileInfo->IndexOffset,
|
||||||
|
ArchiveSize-FARFileInfo->IndexOffset, ArchiveSize)){
|
||||||
|
printf("%sEntry data is corrupt.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Extract each entry
|
||||||
|
*/
|
||||||
|
for(EntryNode = FARFileInfo->FirstEntry; EntryNode; EntryNode = EntryNode->NextEntry){
|
||||||
|
char destination[256];
|
||||||
|
|
||||||
|
file++;
|
||||||
|
if(EntryNode->Entry.Filename)
|
||||||
|
sprintf(destination, "%s/%s", outdirectory, EntryNode->Entry.Filename);
|
||||||
|
else
|
||||||
|
sprintf(destination, "%s/%08x-%08x-%08x.dat", outdirectory,
|
||||||
|
EntryNode->Entry.TypeID, EntryNode->Entry.GroupID, EntryNode->Entry.FileID);
|
||||||
|
|
||||||
|
if(!far_read_entry_data(FARFileInfo, &(EntryNode->Entry), ArchiveData)){
|
||||||
|
printf(" (%u/%u) Skipped (%s): %s\n", file, filescount,
|
||||||
|
"entry data is corrupt", EntryNode->Entry.Filename);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* Decompression, if any, was successful */
|
||||||
|
|
||||||
|
hFile = CreateFile(destination, GENERIC_WRITE, 0, NULL, CREATE_NEW+overwrite,
|
||||||
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
if(hFile == INVALID_HANDLE_VALUE){
|
||||||
|
printf(" (%u/%u) Skipped (%s): %s\n", file, filescount,
|
||||||
|
(!overwrite && GetLastError() == ERROR_FILE_EXISTS) ? "file exists" : "could not open",
|
||||||
|
EntryNode->Entry.Filename);
|
||||||
|
if(EntryNode->Entry.DecompressedData != EntryNode->Entry.CompressedData)
|
||||||
|
libfar_free(EntryNode->Entry.DecompressedData);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(EntryNode->Entry.Filename)
|
||||||
|
printf(" (%u/%u) %s (%u bytes)\n", file, filescount,
|
||||||
|
EntryNode->Entry.Filename, EntryNode->Entry.DecompressedSize);
|
||||||
|
else
|
||||||
|
printf(" (%u/%u) %08x-%08x-%08x (%u bytes)\n", file, filescount,
|
||||||
|
EntryNode->Entry.TypeID, EntryNode->Entry.GroupID, EntryNode->Entry.FileID,
|
||||||
|
EntryNode->Entry.DecompressedSize);
|
||||||
|
|
||||||
|
WriteFile(hFile, EntryNode->Entry.DecompressedData,
|
||||||
|
EntryNode->Entry.DecompressedSize, &bytestransferred, NULL);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
if(EntryNode->Entry.DecompressedData != EntryNode->Entry.CompressedData)
|
||||||
|
libfar_free(EntryNode->Entry.DecompressedData);
|
||||||
|
}
|
||||||
|
printf("\nFinished extracting %u of %u files in %.2f seconds.", file, filescount,
|
||||||
|
((float) (GetTickCount() - BeginningTime))/1000);
|
||||||
|
}else{
|
||||||
|
/* Persist file */
|
||||||
|
PersistFile * PersistInfo;
|
||||||
|
char destination[256];
|
||||||
|
sprintf(destination, "%s/%s.out", outdirectory, infile);
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Load header information
|
||||||
|
*/
|
||||||
|
|
||||||
|
PersistInfo = far_create_persist();
|
||||||
|
if(PersistInfo == NULL){
|
||||||
|
printf("%sMemory for this archive could not be allocated.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!far_read_persist_header(PersistInfo, ArchiveData, ArchiveSize)){
|
||||||
|
printf("%sNot a valid archive.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Extract the data
|
||||||
|
*/
|
||||||
|
printf("Extracting\n");
|
||||||
|
BeginningTime = GetTickCount();
|
||||||
|
if(!far_read_persist_data(PersistInfo, ArchiveData+18)){
|
||||||
|
printf("%sNot a valid archive.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
EndingTime = GetTickCount();
|
||||||
|
|
||||||
|
hFile = CreateFile(destination, GENERIC_WRITE, 0, NULL, CREATE_NEW+overwrite,
|
||||||
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
if(hFile == INVALID_HANDLE_VALUE){
|
||||||
|
printf((!overwrite && GetLastError() == ERROR_FILE_EXISTS) ?
|
||||||
|
"%sFile exists." : "%sCould not open.", "farextract: error: ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
WriteFile(hFile, PersistInfo->DecompressedData,
|
||||||
|
PersistInfo->DecompressedSize, &bytestransferred, NULL);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
printf("Extracted %u bytes in %.2f seconds.\n", PersistInfo->DecompressedSize,
|
||||||
|
((float) (EndingTime - BeginningTime))/1000);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
469
Libraries/FileHandler/far/libfar.c
Normal file
469
Libraries/FileHandler/far/libfar.c
Normal file
|
@ -0,0 +1,469 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
libfar.c - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#else
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef signed long int32_t;
|
||||||
|
typedef unsigned long uint32_t;
|
||||||
|
typedef unsigned int uintptr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libfar.h"
|
||||||
|
|
||||||
|
#if defined(LIBFAR_SUPPORT_PERSIST)
|
||||||
|
#define LIBFAR_MINSIZE_ANY MINSIZE_PERSIST
|
||||||
|
#elif defined(LIBFAR_SUPPORT_FAR)
|
||||||
|
#define LIBFAR_MINSIZE_ANY MINSIZE_FAR
|
||||||
|
#else
|
||||||
|
#define LIBFAR_MINSIZE_ANY MINSIZE_DBPF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef read_int32
|
||||||
|
#define read_int32(x) (int)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||||
|
#define read_int24(x) (int)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)))
|
||||||
|
#define read_int16(x) (int)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||||
|
#define read_int8(x) (int)(((x)[0]<<(8*0)))
|
||||||
|
#define read_uint32(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
|
||||||
|
#define read_uint24(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)))
|
||||||
|
#define read_uint16(x) (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
|
||||||
|
#define read_uint8(x) (unsigned)(((x)[0]<<(8*0)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef max
|
||||||
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
#ifndef min
|
||||||
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* These options can be changed during runtime */
|
||||||
|
static int libfarOptions[] = {
|
||||||
|
LIBFAR_DEFAULT_1A,
|
||||||
|
LIBFAR_DEFAULT_DBPF_COMPRESSED,
|
||||||
|
LIBFAR_DEFAULT_MAX_FILE_NAME_LENGTH,
|
||||||
|
LIBFAR_DEFAULT_REFPACK_HNSV
|
||||||
|
};
|
||||||
|
|
||||||
|
void libfar_set_option(int Option, int Value){
|
||||||
|
libfarOptions[Option] = Value;
|
||||||
|
}
|
||||||
|
int libfar_get_option(int Option){
|
||||||
|
return libfarOptions[Option];
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_identify(const uint8_t * Buffer, unsigned FileSize)
|
||||||
|
{
|
||||||
|
if(!FileSize) FileSize = ~0;
|
||||||
|
else if(FileSize < LIBFAR_MINSIZE_ANY)
|
||||||
|
return FAR_TYPE_INVALID;
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_FAR
|
||||||
|
if(FileSize >= MINSIZE_FAR)
|
||||||
|
if(!memcmp(Buffer, Header_FAR, 8))
|
||||||
|
return FAR_TYPE_FAR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_DBPF
|
||||||
|
if(FileSize >= MINSIZE_DBPF)
|
||||||
|
if(!memcmp(Buffer, Header_DBPF, 4))
|
||||||
|
return FAR_TYPE_DBPF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_PERSIST
|
||||||
|
if(FileSize >= MINSIZE_PERSIST)
|
||||||
|
if(Buffer[0] == 0x01)
|
||||||
|
return FAR_TYPE_PERSIST;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return FAR_TYPE_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
FARFile * far_create_archive(int Type)
|
||||||
|
{
|
||||||
|
FARFile *ptr = malloc(sizeof(FARFile));
|
||||||
|
if(ptr == NULL) return NULL;
|
||||||
|
|
||||||
|
memset(ptr, 0, sizeof(FARFile));
|
||||||
|
ptr->Type = Type;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistFile * far_create_persist()
|
||||||
|
{
|
||||||
|
PersistFile *ptr = malloc(sizeof(PersistFile));
|
||||||
|
if(ptr == NULL) return NULL;
|
||||||
|
|
||||||
|
memset(ptr, 0, sizeof(PersistFile));
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
FAREntryNode * far_add_entry(FARFile * FARFileInfo, int Position)
|
||||||
|
{
|
||||||
|
FAREntryNode *ptr = malloc(sizeof(FAREntryNode)), *node;
|
||||||
|
if(ptr == NULL) return NULL;
|
||||||
|
memset(ptr, 0, sizeof(FAREntryNode));
|
||||||
|
if(FARFileInfo == NULL) return ptr;
|
||||||
|
|
||||||
|
if(Position >= 0){
|
||||||
|
node = FARFileInfo->FirstEntry;
|
||||||
|
|
||||||
|
if(node == NULL){
|
||||||
|
FARFileInfo->FirstEntry = ptr;
|
||||||
|
FARFileInfo->LastEntry = ptr;
|
||||||
|
}else{
|
||||||
|
/* Find the node we will take the place of */
|
||||||
|
while(Position-- && node->NextEntry != NULL)
|
||||||
|
node = node->NextEntry;
|
||||||
|
|
||||||
|
if(node->PrevEntry == NULL)
|
||||||
|
FARFileInfo->FirstEntry = ptr;
|
||||||
|
|
||||||
|
/* Shift this node and all nodes after it above us */
|
||||||
|
ptr->PrevEntry = node->PrevEntry;
|
||||||
|
ptr->NextEntry = node;
|
||||||
|
node->PrevEntry = ptr;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
node = FARFileInfo->LastEntry;
|
||||||
|
|
||||||
|
if(node == NULL){
|
||||||
|
FARFileInfo->FirstEntry = ptr;
|
||||||
|
FARFileInfo->LastEntry = ptr;
|
||||||
|
}else{
|
||||||
|
/* Find the node we will take the place of */
|
||||||
|
while(++Position && node->PrevEntry != NULL)
|
||||||
|
node = node->PrevEntry;
|
||||||
|
|
||||||
|
if(node->NextEntry == NULL)
|
||||||
|
FARFileInfo->LastEntry = ptr;
|
||||||
|
|
||||||
|
/* Shift this node and all nodes before it below us */
|
||||||
|
ptr->PrevEntry = node;
|
||||||
|
ptr->NextEntry = node->NextEntry;
|
||||||
|
node->NextEntry = ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FARFileInfo->Files++;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned FileSize)
|
||||||
|
{
|
||||||
|
if(!FileSize) FileSize = ~0;
|
||||||
|
else if(FileSize < LIBFAR_MINSIZE_ANY)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_FAR
|
||||||
|
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
||||||
|
FARFileInfo->MajorVersion = read_uint32(Buffer+8);
|
||||||
|
FARFileInfo->IndexOffset = read_uint32(Buffer+12);
|
||||||
|
|
||||||
|
if(FARFileInfo->MajorVersion != 1 && FARFileInfo->MajorVersion != 3)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(FARFileInfo->MajorVersion == 1)
|
||||||
|
FARFileInfo->Revision = !libfarOptions[LIBFAR_CONFIG_DEFAULT_TO_1A];
|
||||||
|
|
||||||
|
if(FARFileInfo->IndexOffset > FileSize-4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
FARFileInfo->Files = read_uint32(Buffer + FARFileInfo->IndexOffset);
|
||||||
|
|
||||||
|
if(FARFileInfo->Files > (FileSize-FARFileInfo->IndexOffset) / (
|
||||||
|
(FARFileInfo->MajorVersion == 1) ? (
|
||||||
|
(FARFileInfo->Revision == 0) ? MINSIZE_ENTRY_FAR_1A : MINSIZE_ENTRY_FAR_1B
|
||||||
|
) : MINSIZE_ENTRY_FAR_3)
|
||||||
|
) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_DBPF
|
||||||
|
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
||||||
|
int i;
|
||||||
|
|
||||||
|
FARFileInfo->MajorVersion = read_uint32(Buffer+4);
|
||||||
|
FARFileInfo->MinorVersion = read_uint32(Buffer+8);
|
||||||
|
FARFileInfo->DateCreated = read_uint32(Buffer+24);
|
||||||
|
FARFileInfo->DateModified = read_uint32(Buffer+28);
|
||||||
|
FARFileInfo->IndexMajorVersion = read_uint32(Buffer+32);
|
||||||
|
FARFileInfo->Files = read_uint32(Buffer+36);
|
||||||
|
FARFileInfo->IndexOffset = read_uint32(Buffer+40);
|
||||||
|
FARFileInfo->IndexSize = read_uint32(Buffer+44);
|
||||||
|
FARFileInfo->TrashCount = read_uint32(Buffer+48);
|
||||||
|
FARFileInfo->TrashOffset = read_uint32(Buffer+52);
|
||||||
|
FARFileInfo->TrashSize = read_uint32(Buffer+56);
|
||||||
|
FARFileInfo->IndexMinorVersion = read_uint32(Buffer+60);
|
||||||
|
|
||||||
|
if(FARFileInfo->MajorVersion != 1) return 0;
|
||||||
|
if(FARFileInfo->MinorVersion != 0) return 0;
|
||||||
|
if(FARFileInfo->IndexMajorVersion != 7) return 0;
|
||||||
|
if(FARFileInfo->IndexMinorVersion != 0) return 0;
|
||||||
|
|
||||||
|
for(i=12; i<24; i++)
|
||||||
|
if(Buffer[i] != 0x00) return 0;
|
||||||
|
|
||||||
|
if(FARFileInfo->Files){
|
||||||
|
if(FARFileInfo->Files > MAX_ENTRIES_DBPF) return 0;
|
||||||
|
if(FARFileInfo->IndexSize != FARFileInfo->Files*SIZEOF_ENTRY_DBPF) return 0;
|
||||||
|
if(FARFileInfo->IndexOffset > FileSize) return 0;
|
||||||
|
if(FARFileInfo->IndexSize > FileSize - FARFileInfo->IndexOffset) return 0;
|
||||||
|
}
|
||||||
|
if(FARFileInfo->TrashCount){
|
||||||
|
if(FARFileInfo->TrashCount > MAX_ENTRIES_DBPF) return 0;
|
||||||
|
if(FARFileInfo->TrashSize != FARFileInfo->TrashCount*SIZEOF_ENTRY_DBPF) return 0;
|
||||||
|
if(FARFileInfo->TrashOffset > FileSize) return 0;
|
||||||
|
if(FARFileInfo->TrashSize > FileSize - FARFileInfo->TrashOffset) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_read_entry(const FARFile * FARFileInfo, FAREntry * FAREntryInfo,
|
||||||
|
const uint8_t * Buffer, unsigned MaxEntrySize, unsigned ArchiveSize)
|
||||||
|
{
|
||||||
|
int MajorVersion = FARFileInfo->MajorVersion, Revision = FARFileInfo->Revision;
|
||||||
|
if(MaxEntrySize == 0) MaxEntrySize = ~0;
|
||||||
|
if(ArchiveSize == 0) ArchiveSize = ~0;
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_FAR
|
||||||
|
if(FARFileInfo->Type == FAR_TYPE_FAR){
|
||||||
|
unsigned MinEntrySize =
|
||||||
|
(MajorVersion == 1) ? (
|
||||||
|
(Revision == 0) ? MINSIZE_ENTRY_FAR_1A : MINSIZE_ENTRY_FAR_1B
|
||||||
|
) : MINSIZE_ENTRY_FAR_3;
|
||||||
|
|
||||||
|
if(MaxEntrySize < MinEntrySize)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(MajorVersion == 1){
|
||||||
|
FAREntryInfo->DecompressedSize = read_uint32(Buffer+0);
|
||||||
|
FAREntryInfo->CompressedSize = read_uint32(Buffer+4);
|
||||||
|
FAREntryInfo->DataOffset = read_uint32(Buffer+8);
|
||||||
|
if(Revision == 0)
|
||||||
|
FAREntryInfo->FilenameLength = read_uint32(Buffer+12);
|
||||||
|
else
|
||||||
|
FAREntryInfo->FilenameLength = read_uint16(Buffer+12);
|
||||||
|
}else if(MajorVersion == 3){
|
||||||
|
FAREntryInfo->DecompressedSize = read_uint32(Buffer+0);
|
||||||
|
FAREntryInfo->CompressedSize = read_uint24(Buffer+4);
|
||||||
|
FAREntryInfo->DataType = read_uint8(Buffer+7);
|
||||||
|
FAREntryInfo->DataOffset = read_uint32(Buffer+8);
|
||||||
|
FAREntryInfo->HasFilename = read_uint16(Buffer+12);
|
||||||
|
FAREntryInfo->FilenameLength = read_uint16(Buffer+14);
|
||||||
|
FAREntryInfo->TypeID = read_uint32(Buffer+16);
|
||||||
|
FAREntryInfo->FileID = read_uint32(Buffer+20);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAREntryInfo->FilenameLength > MaxEntrySize - MinEntrySize) return 0;
|
||||||
|
if(FAREntryInfo->FilenameLength > (unsigned)libfarOptions[LIBFAR_CONFIG_MAX_FILE_NAME_LENGTH]) return 0;
|
||||||
|
|
||||||
|
if(FAREntryInfo->CompressedSize > FAREntryInfo->DecompressedSize) return 0;
|
||||||
|
if(FAREntryInfo->DecompressedSize != 0){
|
||||||
|
if(FAREntryInfo->DataOffset > ArchiveSize) return 0;
|
||||||
|
if(FAREntryInfo->CompressedSize > ArchiveSize - FAREntryInfo->DataOffset) return 0;
|
||||||
|
}else if(MajorVersion == 3 && FAREntryInfo->DataType != 0) return 0;
|
||||||
|
|
||||||
|
FAREntryInfo->Filename = malloc(FAREntryInfo->FilenameLength + 1);
|
||||||
|
if(FAREntryInfo->Filename == NULL) return 0;
|
||||||
|
if(FAREntryInfo->FilenameLength != 0)
|
||||||
|
memcpy(FAREntryInfo->Filename, Buffer+MinEntrySize, FAREntryInfo->FilenameLength);
|
||||||
|
FAREntryInfo->Filename[FAREntryInfo->FilenameLength] = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIBFAR_SUPPORT_DBPF
|
||||||
|
if(FARFileInfo->Type == FAR_TYPE_DBPF){
|
||||||
|
if(MaxEntrySize < SIZEOF_ENTRY_DBPF) return 0;
|
||||||
|
|
||||||
|
FAREntryInfo->TypeID = read_uint32(Buffer+0);
|
||||||
|
FAREntryInfo->GroupID = read_uint32(Buffer+4);
|
||||||
|
FAREntryInfo->FileID = read_uint32(Buffer+8);
|
||||||
|
FAREntryInfo->DataOffset = read_uint32(Buffer+12);
|
||||||
|
FAREntryInfo->CompressedSize = read_uint32(Buffer+16);
|
||||||
|
FAREntryInfo->DecompressedSize = FAREntryInfo->CompressedSize;
|
||||||
|
|
||||||
|
if(FAREntryInfo->CompressedSize != 0){
|
||||||
|
if(FAREntryInfo->CompressedSize > ArchiveSize - FAREntryInfo->DataOffset) return 0;
|
||||||
|
if(FAREntryInfo->DataOffset > ArchiveSize) return 0;
|
||||||
|
if(FAREntryInfo->CompressedSize > ArchiveSize - FAREntryInfo->DataOffset) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_read_persist_header(PersistFile * PersistData, const uint8_t * Buffer, unsigned FileSize)
|
||||||
|
{
|
||||||
|
RefPackParameters * Parameters;
|
||||||
|
PersistData->BodyType = read_uint8(Buffer);
|
||||||
|
PersistData->DecompressedSize = read_uint32(Buffer+1);
|
||||||
|
PersistData->CompressedSize = read_uint32(Buffer+5);
|
||||||
|
PersistData->StreamBodySize = read_uint32(Buffer+9);
|
||||||
|
PersistData->Compressor = read_uint8(Buffer+13);
|
||||||
|
|
||||||
|
if(PersistData->BodyType != 1)
|
||||||
|
return 0;
|
||||||
|
if(PersistData->CompressedSize < FileSize-9)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(PersistData->CompressedSize != PersistData->StreamBodySize)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
PersistData->Parameters = malloc(sizeof(RefPackParameters));
|
||||||
|
if(PersistData->Parameters == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Parameters = (RefPackParameters *) PersistData->Parameters;
|
||||||
|
Parameters->hnsv = read_uint8(Buffer+14);
|
||||||
|
Parameters->DecompressedSize = (Buffer[15]<<16) | (Buffer[16]<<8) | Buffer[17]; /* Big endian */
|
||||||
|
|
||||||
|
if((PersistData->DecompressedSize&0x00FFFFFF) != Parameters->DecompressedSize){
|
||||||
|
free(PersistData->Parameters); return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_read_entry_data(const FARFile * FARFileInfo, FAREntry * FAREntryInfo, uint8_t * Buffer)
|
||||||
|
{
|
||||||
|
int Compressed = (FARFileInfo->Type == FAR_TYPE_FAR) ? (
|
||||||
|
(FARFileInfo->MajorVersion == 1) ? (
|
||||||
|
FAREntryInfo->DecompressedSize != FAREntryInfo->CompressedSize
|
||||||
|
) : FAREntryInfo->DataType == 0x80) : libfarOptions[LIBFAR_CONFIG_DBPF_COMPRESSED];
|
||||||
|
|
||||||
|
FAREntryInfo->CompressedData = Buffer+FAREntryInfo->DataOffset;
|
||||||
|
|
||||||
|
if(!Compressed)
|
||||||
|
FAREntryInfo->DecompressedData = FAREntryInfo->CompressedData;
|
||||||
|
else{
|
||||||
|
PersistFile * PersistInfo = &(FAREntryInfo->PersistData);
|
||||||
|
if(far_identify(FAREntryInfo->CompressedData, FAREntryInfo->CompressedSize) != FAR_TYPE_PERSIST)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!far_read_persist_header(PersistInfo, FAREntryInfo->CompressedData, FAREntryInfo->CompressedSize))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Verify that the Persist data agrees with the entry data */
|
||||||
|
if(PersistInfo->DecompressedSize != FAREntryInfo->DecompressedSize){
|
||||||
|
free(PersistInfo->Parameters); return 0;
|
||||||
|
}if(PersistInfo->CompressedSize != FAREntryInfo->CompressedSize - 9){
|
||||||
|
free(PersistInfo->Parameters); return 0;
|
||||||
|
}if(PersistInfo->Compressor != 0x10){
|
||||||
|
free(PersistInfo->Parameters); return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistInfo->DecompressedData = FAREntryInfo->DecompressedData;
|
||||||
|
|
||||||
|
if(!far_read_persist_data(PersistInfo, FAREntryInfo->CompressedData+18)){
|
||||||
|
free(PersistInfo->Parameters); return 0;
|
||||||
|
}
|
||||||
|
FAREntryInfo->DecompressedData = PersistInfo->DecompressedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_read_persist_data(PersistFile * PersistData, uint8_t * CompressedData)
|
||||||
|
{
|
||||||
|
if(CompressedData != NULL) PersistData->CompressedData = CompressedData;
|
||||||
|
|
||||||
|
PersistData->DecompressedData = malloc(PersistData->DecompressedSize);
|
||||||
|
if(PersistData->DecompressedData == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!RefPackDecompress(PersistData->CompressedData, PersistData->CompressedSize-9,
|
||||||
|
PersistData->DecompressedData, PersistData->DecompressedSize,
|
||||||
|
libfarOptions[LIBFAR_CONFIG_REFPACK_HNSV])){
|
||||||
|
free(PersistData->DecompressedData);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_enumerate_entries(FARFile * FARFileInfo, const uint8_t * Index, unsigned IndexSize, unsigned ArchiveSize)
|
||||||
|
{
|
||||||
|
unsigned Files = FARFileInfo->Files;
|
||||||
|
int ArchiveType = FARFileInfo->Type;
|
||||||
|
unsigned MinEntrySize = (ArchiveType == FAR_TYPE_FAR) ? (
|
||||||
|
(FARFileInfo->MajorVersion == 1) ? (
|
||||||
|
(FARFileInfo->Revision == 0) ? MINSIZE_ENTRY_FAR_1A : MINSIZE_ENTRY_FAR_1B
|
||||||
|
) : MINSIZE_ENTRY_FAR_3) : SIZEOF_ENTRY_DBPF;
|
||||||
|
unsigned EntriesAdded = 0;
|
||||||
|
FARFileInfo->Files = 0;
|
||||||
|
|
||||||
|
if(FARFileInfo->Type == FAR_TYPE_FAR)
|
||||||
|
Index += 4;
|
||||||
|
|
||||||
|
while(EntriesAdded < Files){
|
||||||
|
FAREntryNode * node = far_add_entry(FARFileInfo, -1);
|
||||||
|
if(node == NULL)
|
||||||
|
return 0;
|
||||||
|
if(!far_read_entry(FARFileInfo, &(node->Entry), Index, IndexSize, ArchiveSize)){
|
||||||
|
free(node);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntriesAdded++;
|
||||||
|
Index += MinEntrySize;
|
||||||
|
IndexSize -= MinEntrySize;
|
||||||
|
if(ArchiveType != FAR_TYPE_DBPF){
|
||||||
|
Index += node->Entry.FilenameLength;
|
||||||
|
IndexSize -= node->Entry.FilenameLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (EntriesAdded == FARFileInfo->Files);
|
||||||
|
}
|
||||||
|
|
||||||
|
int far_enumerate_entry_data(const FARFile * FARFileInfo, uint8_t * Buffer)
|
||||||
|
{
|
||||||
|
FAREntryNode * node = FARFileInfo->FirstEntry;
|
||||||
|
while(node){
|
||||||
|
if(!far_read_entry_data(FARFileInfo, &(node->Entry), Buffer))
|
||||||
|
return 0;
|
||||||
|
node = node->NextEntry;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void libfar_free(void * ptr)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
|
}
|
176
Libraries/FileHandler/far/libfar.h
Normal file
176
Libraries/FileHandler/far/libfar.h
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
libfar.h - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Constants
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* libfarOptions array members */
|
||||||
|
#define LIBFAR_CONFIG_DEFAULT_TO_1A 0
|
||||||
|
#define LIBFAR_CONFIG_DBPF_COMPRESSED 1
|
||||||
|
#define LIBFAR_CONFIG_MAX_FILE_NAME_LENGTH 2
|
||||||
|
#define LIBFAR_CONFIG_REFPACK_HNSV 3
|
||||||
|
|
||||||
|
/* Archive types */
|
||||||
|
#define FAR_TYPE_INVALID 0
|
||||||
|
#define FAR_TYPE_FAR 1
|
||||||
|
#define FAR_TYPE_DBPF 2
|
||||||
|
#define FAR_TYPE_PERSIST 3
|
||||||
|
|
||||||
|
/* Numerical constants */
|
||||||
|
#define LIBFAR_ARCHIVE_MINIMUM_SIZE 14
|
||||||
|
#define MINSIZE_FAR 20
|
||||||
|
#define MINSIZE_DBPF 64
|
||||||
|
#define MINSIZE_ENTRY_FAR_1A 16
|
||||||
|
#define MINSIZE_ENTRY_FAR_1B 14
|
||||||
|
#define MINSIZE_ENTRY_FAR_3 24
|
||||||
|
#define SIZEOF_ENTRY_DBPF 20
|
||||||
|
#define MAX_ENTRIES_FAR_1A 268435455
|
||||||
|
#define MAX_ENTRIES_FAR_1B 306783377
|
||||||
|
#define MAX_ENTRIES_FAR_3 178956970
|
||||||
|
#define MAX_ENTRIES_DBPF 214748364
|
||||||
|
#define MINSIZE_PERSIST 18
|
||||||
|
#define MAXSIZE_REFPACK_UNCOMPRESSED 16777215
|
||||||
|
#define MAXSIZE_REFPACK_COMPRESSED 16777215
|
||||||
|
|
||||||
|
/* Header bytes */
|
||||||
|
static const uint8_t Header_FAR[] = {'F','A','R','!','b','y','A','Z'};
|
||||||
|
static const uint8_t Header_DBPF[] = {'D','B','P','F'};
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Data structures
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct PersistFile_s
|
||||||
|
{
|
||||||
|
uint8_t BodyType;
|
||||||
|
uint32_t DecompressedSize;
|
||||||
|
uint32_t CompressedSize;
|
||||||
|
uint32_t StreamBodySize;
|
||||||
|
uint8_t Compressor;
|
||||||
|
uint8_t * Parameters;
|
||||||
|
uint8_t * CompressedData;
|
||||||
|
uint8_t * DecompressedData;
|
||||||
|
} PersistFile;
|
||||||
|
|
||||||
|
typedef struct RefPackParameters_s
|
||||||
|
{
|
||||||
|
uint8_t hnsv;
|
||||||
|
uint32_t DecompressedSize;
|
||||||
|
} RefPackParameters;
|
||||||
|
|
||||||
|
typedef struct FAREntry_s
|
||||||
|
{
|
||||||
|
uint32_t DecompressedSize;
|
||||||
|
uint32_t CompressedSize;
|
||||||
|
uint8_t DataType;
|
||||||
|
uint32_t DataOffset;
|
||||||
|
uint16_t HasFilename;
|
||||||
|
uint32_t FilenameLength;
|
||||||
|
uint32_t TypeID;
|
||||||
|
uint32_t GroupID;
|
||||||
|
uint32_t FileID;
|
||||||
|
char * Filename;
|
||||||
|
PersistFile PersistData;
|
||||||
|
uint8_t * CompressedData;
|
||||||
|
uint8_t * DecompressedData;
|
||||||
|
} FAREntry;
|
||||||
|
|
||||||
|
typedef struct FAREntryNode_s
|
||||||
|
{
|
||||||
|
FAREntry Entry;
|
||||||
|
struct FAREntryNode_s * PrevEntry;
|
||||||
|
struct FAREntryNode_s * NextEntry;
|
||||||
|
} FAREntryNode;
|
||||||
|
|
||||||
|
typedef struct FARFile_s
|
||||||
|
{
|
||||||
|
int32_t Type;
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
uint32_t MajorVersion;
|
||||||
|
uint32_t MinorVersion;
|
||||||
|
uint32_t Revision;
|
||||||
|
uint32_t IndexOffset;
|
||||||
|
/* DBPF */
|
||||||
|
uint32_t DateCreated;
|
||||||
|
uint32_t DateModified;
|
||||||
|
uint32_t IndexMajorVersion;
|
||||||
|
uint32_t IndexSize;
|
||||||
|
uint32_t TrashCount;
|
||||||
|
uint32_t TrashOffset;
|
||||||
|
uint32_t TrashSize;
|
||||||
|
uint32_t IndexMinorVersion;
|
||||||
|
|
||||||
|
/* Regular index */
|
||||||
|
uint32_t Files;
|
||||||
|
FAREntryNode * FirstEntry;
|
||||||
|
FAREntryNode * LastEntry;
|
||||||
|
struct { /* DIR index for DBPF */
|
||||||
|
FAREntryNode * FirstEntry;
|
||||||
|
FAREntryNode * LastEntry;
|
||||||
|
} Dir;
|
||||||
|
struct { /* Trash index for DBPF */
|
||||||
|
FAREntryNode * FirstEntry;
|
||||||
|
FAREntryNode * LastEntry;
|
||||||
|
} Trash;
|
||||||
|
} FARFile;
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Exported functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void libfar_set_option(int Option, int Value);
|
||||||
|
int libfar_get_option(int Option);
|
||||||
|
|
||||||
|
int far_identify(const uint8_t * Buffer, unsigned FileSize);
|
||||||
|
|
||||||
|
FARFile * far_create_archive(int Type);
|
||||||
|
PersistFile * far_create_persist();
|
||||||
|
|
||||||
|
FAREntryNode * far_add_entry(FARFile * FARFileInfo, int Position);
|
||||||
|
|
||||||
|
int far_read_header(FARFile * FARFileInfo, const uint8_t * Buffer, unsigned FileSize);
|
||||||
|
int far_read_entry(const FARFile * FARFileInfo, FAREntry * FAREntryInfo,
|
||||||
|
const uint8_t * Buffer, unsigned MaxEntrySize, unsigned ArchiveSize);
|
||||||
|
int far_read_persist_header(PersistFile * PersistData, const uint8_t * Buffer, unsigned FileSize);
|
||||||
|
int far_read_entry_data(const FARFile * FARFileInfo, FAREntry * FAREntryInfo, uint8_t * Buffer);
|
||||||
|
int far_read_persist_data(PersistFile * PersistData, uint8_t * CompressedData);
|
||||||
|
|
||||||
|
int far_enumerate_entries(FARFile * FARFileInfo, const uint8_t * Index, unsigned IndexSize, unsigned ArchiveSize);
|
||||||
|
int far_enumerate_entry_data(const FARFile * FARFileInfo, uint8_t * Buffer);
|
||||||
|
|
||||||
|
FAREntryNode * far_search_id();
|
||||||
|
FAREntryNode * far_search_name();
|
||||||
|
FAREntryNode * far_search_multi();
|
||||||
|
|
||||||
|
void far_delete_entry(FARFile * FARFileInfo, int Position);
|
||||||
|
void far_delete_archive(FARFile * FARFileInfo);
|
||||||
|
void far_delete_persist(FARFile * FARFileInfo);
|
||||||
|
void libfar_free(void * ptr);
|
||||||
|
|
||||||
|
int RefPackDecompress(const uint8_t * CompressedData, size_t CompressedSize,
|
||||||
|
uint8_t * DecompressedData, size_t DecompressedSize, unsigned HNSV);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
200
Libraries/FileHandler/far/libfar.svg
Normal file
200
Libraries/FileHandler/far/libfar.svg
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="191.67342"
|
||||||
|
height="69.682022"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.2 r9819"
|
||||||
|
sodipodi:docname="libfar.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="1"
|
||||||
|
inkscape:cx="209.27206"
|
||||||
|
inkscape:cy="113.29596"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1030"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="2"
|
||||||
|
fit-margin-left="2"
|
||||||
|
fit-margin-right="2"
|
||||||
|
fit-margin-bottom="2" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-98.729108,-354.59789)">
|
||||||
|
<g
|
||||||
|
style="font-size:80.0009613px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:ParkAvenue BT;-inkscape-font-specification:ParkAvenue BT"
|
||||||
|
id="text2989">
|
||||||
|
<path
|
||||||
|
d="m 100.72911,361.63701 6.56014,-4.1602 0,45.6817 -6.56014,0 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3052" />
|
||||||
|
<path
|
||||||
|
d="m 115.10672,368.99794 6.56014,0 0,34.16057 -6.56014,0 z m 3.28129,-3.52055 c -1.12144,4e-5 -2.01541,-0.4264 -2.68192,-1.27931 -0.66651,-0.85284 -0.99977,-1.89289 -0.99976,-3.12016 -10e-6,-1.27926 0.32023,-2.34576 0.9607,-3.1995 0.64047,-0.85364 1.54746,-1.28048 2.72098,-1.28053 1.01238,5e-5 1.87868,0.42689 2.59891,1.28053 0.72021,0.85374 1.08032,1.92024 1.08034,3.1995 -2e-5,1.22727 -0.37355,2.26732 -1.12062,3.12016 -0.74709,0.85291 -1.59997,1.27935 -2.55863,1.27931 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3054" />
|
||||||
|
<path
|
||||||
|
d="m 135.88578,391.31755 c 0.10741,0.53387 0.34749,1.13405 0.72022,1.80055 0.37272,0.66653 0.83903,1.27973 1.39895,1.83963 0.55989,0.55991 1.19995,1.04005 1.92019,1.44044 0.7202,0.4004 1.50757,0.6006 2.36208,0.6006 1.17188,0 2.22454,-0.27995 3.158,-0.83986 0.93342,-0.55989 1.72038,-1.30656 2.36087,-2.24001 0.64045,-0.93344 1.1206,-2.04022 1.44045,-3.32036 0.3198,-1.28011 0.47971,-2.64039 0.47974,-4.08086 -3e-5,-3.57261 -0.55993,-6.34567 -1.67971,-8.31919 -1.11983,-1.97347 -3.12017,-2.96021 -6.00105,-2.96024 -1.59997,3e-5 -2.91997,0.60021 -3.96001,1.80056 -1.04006,1.2004 -1.7733,2.68031 -2.19973,4.43975 z m -6.56014,-30.55945 6.56014,-2.8809 0,13.92107 c 0.69336,-0.90656 1.76026,-1.66666 3.20072,-2.2803 1.44043,-0.61358 2.96063,-0.92039 4.5606,-0.92042 3.89326,3e-5 6.91982,1.57353 9.0797,4.72051 2.15983,3.14704 3.23976,7.54691 3.23979,13.19962 -3e-5,2.40076 -0.29341,4.64118 -0.88014,6.72128 -0.58679,2.08011 -1.44007,3.89328 -2.55984,5.43951 -1.11984,1.54625 -2.46669,2.75964 -4.04058,3.64018 -1.57393,0.88055 -3.34723,1.32082 -5.31989,1.32082 -1.49417,0 -2.84103,-0.29338 -4.04057,-0.88014 -1.19958,-0.58675 -2.2795,-1.73382 -3.23979,-3.4412 l 0,3.84038 -6.56014,0 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3056" />
|
||||||
|
<path
|
||||||
|
d="m 169.59468,403.15851 -6.00105,0 0,-27.60043 -3.59868,0 0,-6.56014 3.59868,0 c -1e-5,-3.83952 0.74667,-6.82621 2.24002,-8.96007 1.49333,-2.13377 3.78706,-3.20067 6.88118,-3.20072 1.01237,5e-5 2.07846,0.0806 3.19828,0.2417 l 0,5.99861 c -1.27933,-0.21318 -2.34583,-0.30636 -3.1995,-0.27954 -0.8537,0.0269 -1.53364,0.25354 -2.03982,0.67994 -0.5062,0.42647 -0.86591,1.07996 -1.07911,1.96047 -0.21323,0.88058 -0.31984,2.06712 -0.31983,3.55961 l 6.71883,0 0,6.56014 -6.399,0 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3058" />
|
||||||
|
<path
|
||||||
|
d="m 199.10675,388.91761 c -2e-5,-0.42642 -0.17336,-0.83943 -0.52002,-1.23902 -0.34671,-0.39957 -0.78657,-0.74625 -1.3196,-1.04006 -0.53307,-0.29376 -1.09297,-0.52041 -1.67971,-0.67994 -0.58677,-0.15949 -1.14708,-0.23924 -1.68093,-0.23926 -4.53294,2e-5 -6.7994,1.89295 -6.79939,5.67878 -1e-5,1.59997 0.59977,2.89352 1.79933,3.88066 1.19955,0.98717 2.62616,1.48074 4.27984,1.48074 0.53385,0 1.13403,-0.0802 1.80056,-0.24049 0.66649,-0.16031 1.30656,-0.38696 1.92019,-0.67994 0.61359,-0.29296 1.13362,-0.65307 1.56008,-1.08033 0.42641,-0.42724 0.63963,-0.93384 0.63965,-1.51979 z m 0.0806,11.28188 c -0.53388,0.79916 -1.49418,1.54543 -2.8809,2.23879 -1.38675,0.69337 -3.06645,1.04006 -5.03912,1.04006 -1.49417,0 -2.89433,-0.26653 -4.20049,-0.79957 -1.30617,-0.53305 -2.45283,-1.3196 -3.43998,-2.35965 -0.98716,-1.04005 -1.76069,-2.29332 -2.32059,-3.75981 -0.5599,-1.46648 -0.83985,-3.13317 -0.83985,-5.00006 0,-3.84118 1.10678,-6.77497 3.32035,-8.80138 2.21356,-2.02637 5.10666,-3.03956 8.67931,-3.03958 1.28092,2e-5 2.48129,0.1465 3.60111,0.43945 1.11979,0.293 2.13298,0.94649 3.03959,1.96048 -2e-5,-1.44043 -0.14651,-2.60052 -0.43946,-3.48027 -0.29299,-0.87971 -0.70641,-1.55964 -1.24025,-2.03982 -0.53388,-0.48012 -1.21422,-0.81338 -2.04104,-0.99977 -0.82685,-0.18633 -1.74645,-0.27951 -2.75882,-0.27954 -1.22724,3e-5 -2.28072,0.19982 -3.16044,0.59937 -0.87974,0.39961 -1.66629,0.89319 -2.35964,1.48073 l -2.96147,-5.04156 c 1.06772,-1.17349 2.40155,-2.08007 4.00152,-2.71976 1.59994,-0.63962 3.38625,-0.95945 5.35895,-0.95949 3.68004,4e-5 6.64027,1.10682 8.88072,3.32036 2.2404,2.21359 3.36061,5.24016 3.36064,9.07969 l 0,22.08035 -6.56014,0 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3060" />
|
||||||
|
<path
|
||||||
|
d="m 226.83658,376.19774 c -1.06611,-0.58592 -1.86609,-0.87889 -2.39994,-0.87892 -1.70576,3e-5 -2.93217,0.65311 -3.67924,1.95925 -0.74709,1.30619 -1.12063,2.91957 -1.12062,4.84015 l 0,21.04029 -6.56014,0 0,-34.16057 6.56014,0 0,4.07964 c 0.37272,-1.3867 1.13241,-2.4532 2.27908,-3.1995 1.14665,-0.74623 2.4402,-1.11936 3.88066,-1.1194 1.28093,4e-5 2.37469,0.29301 3.28129,0.87892 z"
|
||||||
|
style="font-family:Blue Highway;-inkscape-font-specification:Blue Highway"
|
||||||
|
id="path3062" />
|
||||||
|
</g>
|
||||||
|
<rect
|
||||||
|
style="fill:#105785;fill-opacity:1;stroke:none"
|
||||||
|
id="rect2995"
|
||||||
|
width="20.804075"
|
||||||
|
height="20.804075"
|
||||||
|
x="240.98857"
|
||||||
|
y="356.87091" />
|
||||||
|
<rect
|
||||||
|
y="356.87091"
|
||||||
|
x="267.59845"
|
||||||
|
height="20.804075"
|
||||||
|
width="20.804075"
|
||||||
|
id="rect2997"
|
||||||
|
style="fill:#105785;fill-opacity:1;stroke:none" />
|
||||||
|
<rect
|
||||||
|
style="fill:#105785;fill-opacity:1;stroke:none"
|
||||||
|
id="rect2999"
|
||||||
|
width="20.804075"
|
||||||
|
height="20.804075"
|
||||||
|
x="267.59845"
|
||||||
|
y="382.02936" />
|
||||||
|
<rect
|
||||||
|
y="382.02936"
|
||||||
|
x="240.98863"
|
||||||
|
height="20.804075"
|
||||||
|
width="20.804075"
|
||||||
|
id="rect3001"
|
||||||
|
style="fill:#105785;fill-opacity:1;stroke:none" />
|
||||||
|
<g
|
||||||
|
style="font-size:80.0009613px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:ParkAvenue BT;-inkscape-font-specification:ParkAvenue BT"
|
||||||
|
id="text3831">
|
||||||
|
<path
|
||||||
|
d="m 106.6453,409.23288 -4.37505,0 0,3.87505 4.04692,0 0,1.1797 -4.04692,0 0,4.961 -1.31251,0 0,-11.20326 5.68756,0 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3011" />
|
||||||
|
<path
|
||||||
|
d="m 117.44231,419.24863 -1.45315,0 -1.18751,-3.14067 -4.75006,0 -1.1172,3.14067 -1.46095,0 4.29692,-11.20326 1.3594,0 z m -3.07035,-4.32037 -1.75784,-4.77349 c -0.0573,-0.15624 -0.11459,-0.40625 -0.17187,-0.75001 l -0.0312,0 c -0.0521,0.31772 -0.11199,0.56772 -0.17969,0.75001 l -1.74221,4.77349 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3013" />
|
||||||
|
<path
|
||||||
|
d="m 127.1143,419.24863 -1.56252,0 -1.87502,-3.14067 c -0.17189,-0.29166 -0.33856,-0.54036 -0.50001,-0.7461 -0.16147,-0.20573 -0.32683,-0.3737 -0.4961,-0.50391 -0.16928,-0.13021 -0.35157,-0.22526 -0.54688,-0.28516 -0.19532,-0.0599 -0.41538,-0.0898 -0.66017,-0.0899 l -1.07813,0 0,4.76569 -1.31252,0 0,-11.20326 3.34379,0 c 0.48958,1e-5 0.94141,0.0612 1.35549,0.18359 0.41406,0.12241 0.77344,0.30861 1.07813,0.5586 0.30469,0.25002 0.54297,0.56122 0.71486,0.93361 0.17186,0.37241 0.2578,0.80861 0.25781,1.30861 -10e-6,0.39064 -0.0586,0.74871 -0.17578,1.07423 -0.1172,0.32553 -0.28387,0.6159 -0.50001,0.8711 -0.21615,0.25522 -0.47657,0.47267 -0.78126,0.65236 -0.30469,0.17969 -0.64715,0.31902 -1.02735,0.41797 l 0,0.0312 c 0.18749,0.0833 0.35026,0.17839 0.48828,0.28516 0.13802,0.10678 0.26953,0.23308 0.39454,0.37891 0.12499,0.14584 0.24869,0.31121 0.3711,0.4961 0.12239,0.1849 0.25911,0.39975 0.41016,0.64454 z m -6.71883,-10.01575 0,4.06255 1.78127,0 c 0.32812,10e-6 0.63151,-0.0495 0.91016,-0.14844 0.27865,-0.099 0.51954,-0.24088 0.72267,-0.42578 0.20312,-0.1849 0.36198,-0.41146 0.47657,-0.6797 0.11458,-0.26823 0.17187,-0.56901 0.17188,-0.90235 -1e-5,-0.59896 -0.19402,-1.06641 -0.58204,-1.40237 -0.38803,-0.33593 -0.94924,-0.5039 -1.68362,-0.50391 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3015" />
|
||||||
|
<path
|
||||||
|
d="m 135.31752,416.06109 c -0.54167,0 -1.00783,-0.1901 -1.39845,-0.57032 -0.39063,-0.38021 -0.58595,-0.84115 -0.58595,-1.38283 0,-0.53646 0.19532,-1.00131 0.58595,-1.39455 0.39062,-0.39322 0.85678,-0.58984 1.39845,-0.58985 0.54167,1e-5 1.00261,0.19532 1.38283,0.58595 0.38021,0.39063 0.57031,0.85678 0.57032,1.39845 -1e-5,0.54168 -0.19011,1.00262 -0.57032,1.38283 -0.38022,0.38022 -0.84116,0.57032 -1.38283,0.57032 z"
|
||||||
|
style="letter-spacing:0.50000596px"
|
||||||
|
id="path3017" />
|
||||||
|
<path
|
||||||
|
d="m 145.39577,419.24863 0,-11.20326 3.09378,0 c 3.94796,1e-5 5.92194,1.82034 5.92195,5.461 -1e-5,1.72919 -0.5482,3.11853 -1.64455,4.16802 -1.09638,1.04949 -2.56384,1.57424 -4.4024,1.57424 z m 1.31251,-10.01575 0,8.82823 1.6719,0 c 1.46876,0 2.612,-0.39323 3.42972,-1.1797 0.81771,-0.78646 1.22657,-1.90106 1.22658,-3.34379 -1e-5,-2.86982 -1.52607,-4.30473 -4.57818,-4.30474 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3019" />
|
||||||
|
<path
|
||||||
|
d="m 156.61465,419.24863 0,-11.20326 3.18754,0 c 0.96875,1e-5 1.73699,0.23699 2.30471,0.71094 0.56771,0.47398 0.85157,1.09117 0.85157,1.85159 0,0.63543 -0.17188,1.18752 -0.51563,1.65627 -0.34376,0.46876 -0.81772,0.8021 -1.42189,1.00001 l 0,0.0312 c 0.75521,0.0885 1.35939,0.37371 1.81252,0.85548 0.45313,0.48178 0.67969,1.10809 0.6797,1.87893 -1e-5,0.95835 -0.34376,1.7344 -1.03126,2.32815 -0.68752,0.59376 -1.55472,0.89064 -2.6016,0.89064 z m 1.31251,-10.01575 0,3.61723 1.34377,0 c 0.71875,1e-5 1.28386,-0.17317 1.69533,-0.51953 0.41146,-0.34636 0.61719,-0.83464 0.6172,-1.46487 -1e-5,-1.08854 -0.71616,-1.63282 -2.14846,-1.63283 z m 0,4.79693 0,4.0313 1.78128,0 c 0.77083,0 1.3685,-0.18229 1.79299,-0.54688 0.42447,-0.36458 0.63672,-0.86459 0.63672,-1.50002 0,-1.32292 -0.90106,-1.98439 -2.70315,-1.9844 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3021" />
|
||||||
|
<path
|
||||||
|
d="m 167.11477,415.0142 0,4.23443 -1.31251,0 0,-11.20326 3.07816,0 c 1.19792,1e-5 2.12632,0.29168 2.78519,0.87501 0.65885,0.58335 0.98828,1.40627 0.98829,2.46878 -1e-5,1.06252 -0.3659,1.93232 -1.09767,2.6094 -0.73179,0.6771 -1.72008,1.01565 -2.96488,1.01564 z m 0,-5.78132 0,4.59381 1.37502,0 c 0.90625,0 1.59767,-0.20703 2.07424,-0.6211 0.47656,-0.41407 0.71485,-0.99871 0.71485,-1.75393 0,-1.47918 -0.87501,-2.21877 -2.62503,-2.21878 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3023" />
|
||||||
|
<path
|
||||||
|
d="m 180.45868,409.23288 -4.37505,0 0,3.87505 4.04692,0 0,1.1797 -4.04692,0 0,4.961 -1.31252,0 0,-11.20326 5.68757,0 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3025" />
|
||||||
|
<path
|
||||||
|
d="m 189.25566,416.06109 c -0.54167,0 -1.00782,-0.1901 -1.39845,-0.57032 -0.39063,-0.38021 -0.58595,-0.84115 -0.58595,-1.38283 0,-0.53646 0.19532,-1.00131 0.58595,-1.39455 0.39063,-0.39322 0.85678,-0.58984 1.39845,-0.58985 0.54167,1e-5 1.00261,0.19532 1.38283,0.58595 0.38021,0.39063 0.57031,0.85678 0.57032,1.39845 -1e-5,0.54168 -0.19011,1.00262 -0.57032,1.38283 -0.38022,0.38022 -0.84116,0.57032 -1.38283,0.57032 z"
|
||||||
|
style="letter-spacing:0.50000596px"
|
||||||
|
id="path3027" />
|
||||||
|
<path
|
||||||
|
d="m 200.64643,415.0142 0,4.23443 -1.31252,0 0,-11.20326 3.07816,0 c 1.19793,1e-5 2.12632,0.29168 2.78519,0.87501 0.65886,0.58335 0.98829,1.40627 0.98829,2.46878 0,1.06252 -0.36589,1.93232 -1.09766,2.6094 -0.73179,0.6771 -1.72008,1.01565 -2.96488,1.01564 z m 0,-5.78132 0,4.59381 1.37501,0 c 0.90626,0 1.59767,-0.20703 2.07425,-0.6211 0.47656,-0.41407 0.71484,-0.99871 0.71485,-1.75393 -1e-5,-1.47918 -0.87502,-2.21877 -2.62503,-2.21878 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3029" />
|
||||||
|
<path
|
||||||
|
d="m 214.56065,415.5689 -5.6485,0 c 0.0208,0.89063 0.26042,1.57814 0.71876,2.06252 0.45833,0.48438 1.08855,0.72657 1.89065,0.72657 0.90104,0 1.72918,-0.29688 2.4844,-0.89063 l 0,1.20313 c -0.70314,0.51043 -1.63284,0.76564 -2.7891,0.76564 -1.13022,0 -2.01825,-0.36329 -2.66409,-1.08986 -0.64584,-0.72657 -0.96876,-1.74871 -0.96876,-3.06644 0,-1.2448 0.35287,-2.25914 1.0586,-3.04301 0.70574,-0.78385 1.58205,-1.17578 2.62894,-1.17579 1.04688,10e-6 1.85679,0.33855 2.42972,1.01564 0.57292,0.67709 0.85938,1.61721 0.85938,2.82034 z m -1.31251,-1.08596 c -0.005,-0.73958 -0.1836,-1.31511 -0.53516,-1.72658 -0.35158,-0.41145 -0.83986,-0.61719 -1.46487,-0.61719 -0.60417,0 -1.1172,0.21615 -1.53908,0.64844 -0.42188,0.43231 -0.6823,0.99742 -0.78126,1.69533 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3031" />
|
||||||
|
<path
|
||||||
|
d="m 220.67791,412.54542 c -0.22396,-0.17187 -0.54688,-0.25781 -0.96876,-0.25781 -0.54688,0 -1.00392,0.25782 -1.37111,0.77344 -0.36719,0.51564 -0.55079,1.21877 -0.55079,2.1094 l 0,4.07818 -1.28126,0 0,-8.0001 1.28126,0 0,1.64846 0.0312,0 c 0.1823,-0.5625 0.46094,-1.00131 0.83595,-1.31642 0.375,-0.3151 0.79428,-0.47266 1.25783,-0.47267 0.33333,1e-5 0.58854,0.0365 0.76563,0.10938 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3033" />
|
||||||
|
<path
|
||||||
|
d="m 221.58417,418.95956 0,-1.37502 c 0.69792,0.51564 1.46616,0.77345 2.30471,0.77345 1.12501,0 1.68752,-0.375 1.68752,-1.12501 0,-0.21354 -0.0482,-0.39454 -0.14453,-0.54298 -0.0964,-0.14843 -0.22657,-0.27995 -0.39063,-0.39453 -0.16407,-0.11459 -0.35678,-0.21745 -0.57813,-0.3086 -0.22136,-0.0911 -0.45964,-0.1862 -0.71485,-0.28516 -0.35418,-0.14062 -0.66538,-0.28255 -0.93361,-0.42579 -0.26823,-0.14322 -0.49219,-0.30468 -0.67188,-0.48438 -0.17969,-0.17968 -0.31511,-0.38411 -0.40625,-0.61329 -0.0911,-0.22916 -0.13673,-0.49739 -0.13673,-0.80469 0,-0.375 0.0859,-0.70704 0.25782,-0.99611 0.17188,-0.28906 0.40105,-0.53125 0.68751,-0.72657 0.28646,-0.19531 0.61328,-0.34244 0.98048,-0.44141 0.36719,-0.099 0.7461,-0.14843 1.13673,-0.14844 0.69271,10e-6 1.31251,0.1198 1.8594,0.35938 l 0,1.29689 c -0.58856,-0.38542 -1.26565,-0.57813 -2.03128,-0.57813 -0.23959,0 -0.45573,0.0274 -0.64844,0.082 -0.19271,0.0547 -0.35808,0.13152 -0.4961,0.23047 -0.13803,0.099 -0.2448,0.21746 -0.32032,0.35547 -0.0755,0.13803 -0.11328,0.29038 -0.11328,0.45704 0,0.20834 0.0378,0.38282 0.11328,0.52344 0.0755,0.14064 0.1862,0.26564 0.33204,0.37501 0.14583,0.10938 0.32292,0.20834 0.53125,0.29688 0.20834,0.0885 0.44532,0.1849 0.71095,0.28906 0.35417,0.13543 0.67188,0.27475 0.95314,0.41798 0.28125,0.14323 0.52083,0.30469 0.71876,0.48438 0.19791,0.17969 0.35025,0.38672 0.45703,0.6211 0.10677,0.23438 0.16015,0.51303 0.16016,0.83595 -1e-5,0.39584 -0.0873,0.73959 -0.26172,1.03126 -0.17449,0.29167 -0.40756,0.53386 -0.69923,0.72657 -0.29167,0.19271 -0.62761,0.33594 -1.00782,0.42969 -0.38022,0.0937 -0.77866,0.14063 -1.19533,0.14063 -0.82293,0 -1.53648,-0.15886 -2.14065,-0.47657 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3035" />
|
||||||
|
<path
|
||||||
|
d="m 229.4202,409.21726 c -0.22917,10e-6 -0.42448,-0.0781 -0.58594,-0.23438 -0.16146,-0.15624 -0.24219,-0.35416 -0.24219,-0.59376 0,-0.23957 0.0807,-0.43879 0.24219,-0.59766 0.16146,-0.15885 0.35677,-0.23827 0.58594,-0.23829 0.23438,2e-5 0.4336,0.0794 0.59767,0.23829 0.16406,0.15887 0.24609,0.35809 0.24609,0.59766 0,0.22918 -0.082,0.4245 -0.24609,0.58595 -0.16407,0.16147 -0.36329,0.2422 -0.59767,0.24219 z m 0.62501,7.79697 c 0,0.73438 0.28386,1.10157 0.85157,1.10157 0.22917,0 0.4349,-0.0286 0.6172,-0.0859 l 0,1.15627 c -0.099,0.026 -0.23048,0.0508 -0.39454,0.0742 -0.16407,0.0234 -0.33724,0.0351 -0.51953,0.0351 -0.25522,0 -0.49481,-0.0417 -0.71876,-0.125 -0.22397,-0.0833 -0.41798,-0.21094 -0.58204,-0.38282 -0.16407,-0.17187 -0.29428,-0.38672 -0.39063,-0.64454 -0.0964,-0.25781 -0.14454,-0.55859 -0.14453,-0.90235 l 0,-5.99226 1.28126,0 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3037" />
|
||||||
|
<path
|
||||||
|
d="m 232.42805,418.95956 0,-1.37502 c 0.69792,0.51564 1.46616,0.77345 2.30471,0.77345 1.12501,0 1.68752,-0.375 1.68752,-1.12501 0,-0.21354 -0.0482,-0.39454 -0.14453,-0.54298 -0.0964,-0.14843 -0.22657,-0.27995 -0.39063,-0.39453 -0.16407,-0.11459 -0.35678,-0.21745 -0.57813,-0.3086 -0.22136,-0.0911 -0.45964,-0.1862 -0.71485,-0.28516 -0.35418,-0.14062 -0.66538,-0.28255 -0.93361,-0.42579 -0.26823,-0.14322 -0.49219,-0.30468 -0.67188,-0.48438 -0.17969,-0.17968 -0.31511,-0.38411 -0.40626,-0.61329 -0.0911,-0.22916 -0.13672,-0.49739 -0.13672,-0.80469 0,-0.375 0.0859,-0.70704 0.25782,-0.99611 0.17188,-0.28906 0.40104,-0.53125 0.68751,-0.72657 0.28646,-0.19531 0.61328,-0.34244 0.98048,-0.44141 0.36719,-0.099 0.7461,-0.14843 1.13673,-0.14844 0.69271,10e-6 1.31251,0.1198 1.8594,0.35938 l 0,1.29689 c -0.58856,-0.38542 -1.26565,-0.57813 -2.03128,-0.57813 -0.23959,0 -0.45573,0.0274 -0.64844,0.082 -0.19271,0.0547 -0.35808,0.13152 -0.4961,0.23047 -0.13803,0.099 -0.2448,0.21746 -0.32032,0.35547 -0.0755,0.13803 -0.11328,0.29038 -0.11328,0.45704 0,0.20834 0.0378,0.38282 0.11328,0.52344 0.0755,0.14064 0.1862,0.26564 0.33204,0.37501 0.14583,0.10938 0.32292,0.20834 0.53125,0.29688 0.20834,0.0885 0.44532,0.1849 0.71095,0.28906 0.35417,0.13543 0.67188,0.27475 0.95314,0.41798 0.28124,0.14323 0.52083,0.30469 0.71876,0.48438 0.19791,0.17969 0.35025,0.38672 0.45703,0.6211 0.10677,0.23438 0.16015,0.51303 0.16016,0.83595 -1e-5,0.39584 -0.0873,0.73959 -0.26172,1.03126 -0.17449,0.29167 -0.40756,0.53386 -0.69923,0.72657 -0.29167,0.19271 -0.62762,0.33594 -1.00782,0.42969 -0.38022,0.0937 -0.77866,0.14063 -1.19533,0.14063 -0.82293,0 -1.53648,-0.15886 -2.14065,-0.47657 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3039" />
|
||||||
|
<path
|
||||||
|
d="m 243.40474,419.1705 c -0.30209,0.16667 -0.70054,0.25 -1.19533,0.25 -1.40106,0 -2.10159,-0.78125 -2.10159,-2.34377 l 0,-4.73444 -1.37501,0 0,-1.09376 1.37501,0 0,-1.95315 1.28127,-0.41406 0,2.36721 2.01565,0 0,1.09376 -2.01565,0 0,4.50787 c 0,0.53647 0.0911,0.91928 0.27344,1.14845 0.18229,0.22917 0.48438,0.34376 0.90626,0.34376 0.32292,0 0.60157,-0.0885 0.83595,-0.26563 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3041" />
|
||||||
|
<path
|
||||||
|
d="m 251.97517,416.06109 c -0.54168,0 -1.00783,-0.1901 -1.39846,-0.57032 -0.39063,-0.38021 -0.58594,-0.84115 -0.58594,-1.38283 0,-0.53646 0.19531,-1.00131 0.58594,-1.39455 0.39063,-0.39322 0.85678,-0.58984 1.39846,-0.58985 0.54167,1e-5 1.00261,0.19532 1.38283,0.58595 0.3802,0.39063 0.57031,0.85678 0.57032,1.39845 -1e-5,0.54168 -0.19012,1.00262 -0.57032,1.38283 -0.38022,0.38022 -0.84116,0.57032 -1.38283,0.57032 z"
|
||||||
|
style="letter-spacing:0.50000596px"
|
||||||
|
id="path3043" />
|
||||||
|
<path
|
||||||
|
d="m 266.49096,419.43613 c -0.33334,0 -0.67189,-0.0326 -1.01564,-0.0977 -0.34375,-0.0651 -0.67709,-0.16406 -1.00001,-0.29688 -0.32292,-0.13281 -0.63152,-0.29688 -0.92579,-0.49219 -0.29428,-0.19531 -0.56121,-0.42318 -0.80079,-0.6836 -0.95314,-1.04168 -1.42971,-2.40367 -1.42971,-4.08599 0,-1.8073 0.48438,-3.24482 1.45315,-4.31255 0.97917,-1.07292 2.31773,-1.60938 4.01567,-1.60939 1.52084,1e-5 2.75523,0.52085 3.70317,1.56251 0.94792,1.04169 1.42188,2.40369 1.42189,4.08599 -10e-6,0.70835 -0.0794,1.37632 -0.23828,2.00393 -0.15887,0.62762 -0.39976,1.19403 -0.72267,1.69924 -0.32293,0.50522 -0.72918,0.93361 -1.21876,1.28517 -0.4896,0.35157 -1.06773,0.60287 -1.7344,0.75392 0.27083,0.29167 0.52474,0.54948 0.76173,0.77344 0.23697,0.22396 0.47395,0.41277 0.71095,0.56642 0.23697,0.15364 0.48306,0.26953 0.73829,0.34766 0.2552,0.0781 0.53645,0.11718 0.84376,0.11719 0.0833,-10e-6 0.17447,-0.004 0.27344,-0.0117 0.0989,-0.008 0.19921,-0.0208 0.30078,-0.0391 0.10155,-0.0182 0.19921,-0.0391 0.29297,-0.0625 0.0937,-0.0234 0.17968,-0.0508 0.25782,-0.082 l 0,1.26564 c -0.0833,0.026 -0.1771,0.0482 -0.28125,0.0664 -0.10418,0.0182 -0.20965,0.0339 -0.31641,0.0469 -0.10679,0.013 -0.21226,0.0234 -0.31641,0.0312 -0.10418,0.008 -0.20054,0.0117 -0.28907,0.0117 -0.50002,0 -0.94924,-0.0742 -1.34767,-0.22266 -0.39845,-0.14844 -0.77085,-0.35157 -1.1172,-0.60938 -0.34637,-0.25782 -0.68101,-0.5586 -1.00392,-0.90235 -0.32293,-0.34376 -0.66147,-0.71355 -1.01564,-1.10939 z m 0.17188,-10.39075 c -1.1771,10e-6 -2.13284,0.42449 -2.86722,1.27345 -0.73439,0.84898 -1.10158,1.96357 -1.10158,3.34379 0,1.37502 0.35677,2.48701 1.07033,3.33598 0.71875,0.83855 1.65366,1.25783 2.80472,1.25783 1.22917,0 2.19793,-0.40105 2.90628,-1.20314 0.70833,-0.80209 1.0625,-1.9245 1.06251,-3.36723 -10e-6,-1.48439 -0.34376,-2.62763 -1.03126,-3.42973 -0.68751,-0.80729 -1.63544,-1.21094 -2.84378,-1.21095 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3045" />
|
||||||
|
<path
|
||||||
|
d="m 279.80361,409.23288 -4.37505,0 0,3.87505 4.04692,0 0,1.1797 -4.04692,0 0,4.961 -1.31251,0 0,-11.20326 5.68756,0 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3047" />
|
||||||
|
<path
|
||||||
|
d="m 281.40519,418.7955 0,-1.5469 c 0.17709,0.15626 0.38933,0.29688 0.63673,0.42188 0.2474,0.12501 0.50782,0.23048 0.78126,0.31641 0.27344,0.0859 0.54818,0.15235 0.82423,0.19922 0.27604,0.0469 0.53125,0.0703 0.76563,0.0703 0.8073,0 1.41017,-0.14974 1.80862,-0.44923 0.39843,-0.29948 0.59765,-0.73047 0.59766,-1.29298 -1e-5,-0.30208 -0.0664,-0.56511 -0.19922,-0.78907 -0.13282,-0.22396 -0.31642,-0.42839 -0.55079,-0.61329 -0.23438,-0.1849 -0.51173,-0.36198 -0.83204,-0.53126 -0.32032,-0.16927 -0.66538,-0.34765 -1.03517,-0.53516 -0.39063,-0.19791 -0.75522,-0.39844 -1.09376,-0.60157 -0.33855,-0.20312 -0.63282,-0.42708 -0.88282,-0.67188 -0.25001,-0.24479 -0.44663,-0.52214 -0.58986,-0.83204 -0.14323,-0.3099 -0.21484,-0.67318 -0.21484,-1.08986 0,-0.51041 0.11198,-0.95443 0.33594,-1.33205 0.22396,-0.3776 0.51823,-0.6888 0.88282,-0.9336 0.36459,-0.24479 0.77996,-0.42708 1.24611,-0.54688 0.46615,-0.11979 0.94141,-0.17968 1.4258,-0.17969 1.10417,1e-5 1.90887,0.13282 2.41409,0.39844 l 0,1.47658 c -0.66147,-0.45833 -1.51044,-0.6875 -2.5469,-0.68751 -0.28647,10e-6 -0.57293,0.03 -0.85939,0.0898 -0.28646,0.0599 -0.54168,0.15757 -0.76563,0.29298 -0.22397,0.13543 -0.40626,0.30991 -0.54689,0.52344 -0.14062,0.21355 -0.21094,0.47397 -0.21094,0.78126 0,0.28647 0.0534,0.53387 0.16016,0.7422 0.10677,0.20834 0.26433,0.39845 0.47266,0.57032 0.20834,0.17188 0.46225,0.33855 0.76173,0.5 0.29948,0.16147 0.64454,0.33855 1.03517,0.53126 0.40104,0.19792 0.78125,0.40626 1.14064,0.62501 0.35937,0.21875 0.67448,0.46094 0.94532,0.72657 0.27083,0.26563 0.48568,0.5599 0.64454,0.88282 0.15885,0.32292 0.23828,0.69272 0.23829,1.10939 -1e-5,0.55209 -0.10809,1.01954 -0.32423,1.40236 -0.21615,0.38282 -0.50782,0.69402 -0.87501,0.9336 -0.36719,0.23959 -0.79038,0.41277 -1.26954,0.51954 -0.47918,0.10677 -0.98439,0.16016 -1.51565,0.16016 -0.17708,0 -0.39584,-0.0143 -0.65625,-0.043 -0.26043,-0.0287 -0.52605,-0.0703 -0.79689,-0.125 -0.27084,-0.0547 -0.52735,-0.1224 -0.76954,-0.20313 -0.24219,-0.0807 -0.4362,-0.17057 -0.58204,-0.26953 z"
|
||||||
|
style="font-size:16.00019073px;font-family:Gisha;-inkscape-font-specification:Gisha"
|
||||||
|
id="path3049" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 25 KiB |
167
Libraries/FileHandler/far/refpack_dec.c
Normal file
167
Libraries/FileHandler/far/refpack_dec.c
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
refpack_dec.c - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
|
||||||
|
#ifndef __restrict
|
||||||
|
#define __restrict
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int RefPackDecompress(const uint8_t *__restrict CompressedData, size_t CompressedSize,
|
||||||
|
uint8_t *__restrict DecompressedData, size_t DecompressedSize, unsigned HNSV){
|
||||||
|
unsigned datawritten = 0;
|
||||||
|
int stopflag = 0, StopFlagData;
|
||||||
|
|
||||||
|
if(HNSV == 0) HNSV = 0xFB; /* EA default */
|
||||||
|
if (HNSV >= 0xFF) StopFlagData = 0x1F;
|
||||||
|
else if(HNSV >= 0xFE) StopFlagData = 0x00;
|
||||||
|
else if(HNSV >= 0xFD) StopFlagData = 0x01;
|
||||||
|
else if(HNSV >= 0xFB) StopFlagData = 0x03;
|
||||||
|
else if(HNSV >= 0xF7) StopFlagData = 0x07;
|
||||||
|
else StopFlagData = 0x0F;
|
||||||
|
|
||||||
|
while(CompressedSize > 0 && !stopflag){
|
||||||
|
unsigned ProceedingDataLength, ReferencedDataLength, ReferencedDataOffset;
|
||||||
|
unsigned currentbyte = *(CompressedData++);
|
||||||
|
CompressedSize--;
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Fetch the opcode
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The first byte determines the size of the entire opcode. */
|
||||||
|
|
||||||
|
if(currentbyte <= 0x7F){ /* 2 bytes */
|
||||||
|
if(CompressedSize < 1) return 0;
|
||||||
|
CompressedSize -= 1;
|
||||||
|
|
||||||
|
/* First byte */
|
||||||
|
ProceedingDataLength = currentbyte & 0x03;
|
||||||
|
ReferencedDataLength = ((currentbyte & 0x1C) >> 2) + 3;
|
||||||
|
ReferencedDataOffset = (currentbyte & 0x60) << 3;
|
||||||
|
|
||||||
|
/* Second byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ReferencedDataOffset += currentbyte;
|
||||||
|
}else if(currentbyte <= 0xBF){ /* 3 bytes */
|
||||||
|
if(CompressedSize < 2) return 0;
|
||||||
|
CompressedSize -= 2;
|
||||||
|
|
||||||
|
/* First byte */
|
||||||
|
ReferencedDataLength = (currentbyte & 0x3F) + 4;
|
||||||
|
|
||||||
|
/* Second byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ProceedingDataLength = (currentbyte & 0xC0) >> 6;
|
||||||
|
ReferencedDataOffset = (currentbyte & 0x3F) << 8;
|
||||||
|
|
||||||
|
/* Third byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ReferencedDataOffset += currentbyte;
|
||||||
|
}else if(currentbyte <= 0xDF){ /* 4 bytes */
|
||||||
|
if(CompressedSize < 3) return 0;
|
||||||
|
CompressedSize -= 3;
|
||||||
|
|
||||||
|
/* First byte */
|
||||||
|
ProceedingDataLength = currentbyte & 0x03;
|
||||||
|
ReferencedDataLength = ((currentbyte & 0x0C) << 6) + 5;
|
||||||
|
ReferencedDataOffset = (currentbyte & 0x10) << 12;
|
||||||
|
|
||||||
|
/* Second byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ReferencedDataOffset += currentbyte << 8;
|
||||||
|
|
||||||
|
/* Third byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ReferencedDataOffset += currentbyte;
|
||||||
|
|
||||||
|
/* Fourth byte */
|
||||||
|
currentbyte = *(CompressedData++);
|
||||||
|
ReferencedDataLength += currentbyte;
|
||||||
|
}else{ /* 1 byte: Two different opcode types fall into this category */
|
||||||
|
if(currentbyte <= HNSV){
|
||||||
|
ProceedingDataLength = ((currentbyte & 0x1F) + 1) << 2;
|
||||||
|
}else{
|
||||||
|
ProceedingDataLength = currentbyte & StopFlagData;
|
||||||
|
stopflag++;
|
||||||
|
}
|
||||||
|
ReferencedDataLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Copy proceeding data
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(ProceedingDataLength != 0){
|
||||||
|
if(ProceedingDataLength > CompressedSize || ProceedingDataLength > DecompressedSize)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memcpy(DecompressedData, CompressedData, ProceedingDataLength);
|
||||||
|
DecompressedSize -= ProceedingDataLength;
|
||||||
|
CompressedSize -= ProceedingDataLength;
|
||||||
|
datawritten += ProceedingDataLength;
|
||||||
|
DecompressedData += ProceedingDataLength;
|
||||||
|
CompressedData += ProceedingDataLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
|
** Copy referenced data
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(ReferencedDataLength != 0){
|
||||||
|
/* It is possible that the offset specified does not provide for a large enough buffer to copy all at once from.
|
||||||
|
This event would be caused when the referenced data offset is set smaller than the referenced data length.
|
||||||
|
When this occurs, the decoder is to repeatedly copy/paste the referenced data until the length is satisfied.
|
||||||
|
We will do this in a way so that we call memcpy ceil(log2(N)) times instead of N times. */
|
||||||
|
|
||||||
|
ReferencedDataOffset++;
|
||||||
|
if(ReferencedDataLength > DecompressedSize || ReferencedDataOffset > datawritten)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
DecompressedSize -= ReferencedDataLength;
|
||||||
|
datawritten += ReferencedDataLength;
|
||||||
|
|
||||||
|
if(ReferencedDataOffset == 1){
|
||||||
|
memset(DecompressedData, *(DecompressedData-1), ReferencedDataLength);
|
||||||
|
DecompressedData += ReferencedDataLength;
|
||||||
|
}else{
|
||||||
|
unsigned copylength =
|
||||||
|
(ReferencedDataOffset < ReferencedDataLength) ? ReferencedDataOffset : ReferencedDataLength;
|
||||||
|
uint8_t *__restrict copysource = DecompressedData;
|
||||||
|
|
||||||
|
memcpy(DecompressedData, DecompressedData-ReferencedDataOffset, copylength);
|
||||||
|
DecompressedData += copylength;
|
||||||
|
ReferencedDataLength -= copylength;
|
||||||
|
|
||||||
|
while(ReferencedDataLength){
|
||||||
|
if(copylength > ReferencedDataLength)
|
||||||
|
copylength = ReferencedDataLength;
|
||||||
|
|
||||||
|
memcpy(DecompressedData, copysource, copylength);
|
||||||
|
DecompressedData += copylength;
|
||||||
|
ReferencedDataLength -= copylength;
|
||||||
|
|
||||||
|
if(!(copylength&0x80000000)) copylength <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!stopflag || CompressedSize || DecompressedSize) ? 0 : 1;
|
||||||
|
}
|
17
Libraries/FileHandler/hit/evt.c
Normal file
17
Libraries/FileHandler/hit/evt.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
evt.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
17
Libraries/FileHandler/hit/hit.c
Normal file
17
Libraries/FileHandler/hit/hit.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
hit.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
17
Libraries/FileHandler/hit/hot.c
Normal file
17
Libraries/FileHandler/hit/hot.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
hot.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
17
Libraries/FileHandler/hit/hsm.c
Normal file
17
Libraries/FileHandler/hit/hsm.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
hsm.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
|
@ -2,10 +2,12 @@ cmake_minimum_required(VERSION 2.6)
|
||||||
project(iff)
|
project(iff)
|
||||||
|
|
||||||
set(IFF_SOURCES
|
set(IFF_SOURCES
|
||||||
|
cats.c
|
||||||
iff.c
|
iff.c
|
||||||
bcon.c
|
bcon.c
|
||||||
rsmp.c
|
rsmp.c
|
||||||
str.c
|
str.c
|
||||||
|
string.c
|
||||||
trcn.c
|
trcn.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +19,7 @@ set_target_properties(iff_static PROPERTIES
|
||||||
|
|
||||||
#### Shared library (uncomment to build)
|
#### Shared library (uncomment to build)
|
||||||
#add_library(iff_shared SHARED ${IFF_SOURCES})
|
#add_library(iff_shared SHARED ${IFF_SOURCES})
|
||||||
#set_target_properties(libiff_shared PROPERTIES
|
#set_target_properties(iff_shared PROPERTIES
|
||||||
# OUTPUT_NAME "iff"
|
# OUTPUT_NAME "iff"
|
||||||
# PREFIX ""
|
# PREFIX ""
|
||||||
# CLEAN_DIRECT_OUTPUT 1)
|
# CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
bcon.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
bcon.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -33,14 +36,12 @@ int iff_parse_bcon(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
BCONData->Flags = read_uint8le(Buffer + 1);
|
BCONData->Flags = read_uint8le(Buffer + 1);
|
||||||
if(BCONData->ConstantCount == 0)
|
if(BCONData->ConstantCount == 0)
|
||||||
return 1;
|
return 1;
|
||||||
if(BCONData->ConstantCount * 2 /* bytes */ > Size - 2){
|
if(BCONData->ConstantCount * 2 /* bytes */ > Size - 2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
BCONData->Constants = malloc(BCONData->ConstantCount * sizeof(uint16_t));
|
BCONData->Constants = malloc(BCONData->ConstantCount * sizeof(uint16_t));
|
||||||
if(BCONData->Constants == NULL){
|
if(BCONData->Constants == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
Buffer += 2;
|
Buffer += 2;
|
||||||
for(i=0; i<BCONData->ConstantCount; i++, Buffer += 2)
|
for(i=0; i<BCONData->ConstantCount; i++, Buffer += 2)
|
||||||
|
|
18
Libraries/FileHandler/iff/bhav.c
Normal file
18
Libraries/FileHandler/iff/bhav.c
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
bhav.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
55
Libraries/FileHandler/iff/cats.c
Normal file
55
Libraries/FileHandler/iff/cats.c
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
cats.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "iff.h"
|
||||||
|
|
||||||
|
int iff_parse_cats(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
|
IFFStringPair * StringData;
|
||||||
|
unsigned Size = ChunkInfo->Size - 76;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
ChunkInfo->FormattedData = calloc(1, sizeof(IFFStringPair));
|
||||||
|
if(ChunkInfo->FormattedData == NULL)
|
||||||
|
return 0;
|
||||||
|
StringData = (IFFStringPair*) ChunkInfo->FormattedData;
|
||||||
|
|
||||||
|
for(s=0; s<2; s++){
|
||||||
|
unsigned length;
|
||||||
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
|
if(length == Size) return 0;
|
||||||
|
|
||||||
|
if(length != 0){
|
||||||
|
char ** string = (s==0) ? &StringData->Key : &StringData->Value;
|
||||||
|
*string = malloc(length+1);
|
||||||
|
if(*string == NULL) return 0;
|
||||||
|
strcpy(*string, (char*) Buffer);
|
||||||
|
|
||||||
|
Buffer += length;
|
||||||
|
Size -= length;
|
||||||
|
}
|
||||||
|
Buffer++; Size--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void iff_free_cats(void * FormattedData){
|
||||||
|
IFFStringPair * StringData = (IFFStringPair*) FormattedData;
|
||||||
|
free(StringData->Key);
|
||||||
|
free(StringData->Value);
|
||||||
|
}
|
0
Libraries/FileHandler/iff/glob.c
Normal file
0
Libraries/FileHandler/iff/glob.c
Normal file
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
iff.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
iff.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -26,24 +29,31 @@
|
||||||
|
|
||||||
int iff_parse_rsmp(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned IFFSize);
|
int iff_parse_rsmp(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned IFFSize);
|
||||||
int iff_free_rsmp(void * FormattedData);
|
int iff_free_rsmp(void * FormattedData);
|
||||||
|
|
||||||
/* The order of these chunks must remain the same throughout this block: */
|
|
||||||
iff_register(bcon);
|
iff_register(bcon);
|
||||||
iff_register(str);
|
iff_register(str);
|
||||||
|
iff_register(cats);
|
||||||
|
iff_register(c_string);
|
||||||
iff_register(trcn);
|
iff_register(trcn);
|
||||||
|
|
||||||
|
/* The ordering of these chunk types must match throughout this block: */
|
||||||
const char chunktypes[] =
|
const char chunktypes[] =
|
||||||
"STR#" "CTSS" "FAMs" "TTAs"
|
"STR#" "CTSS" "FAMs" "TTAs" "CST\0"
|
||||||
|
"CATS"
|
||||||
|
"FWAV"
|
||||||
"BCON"
|
"BCON"
|
||||||
"TRCN"
|
"TRCN"
|
||||||
;
|
;
|
||||||
int (* const iff_parse_function[])(IFFChunk*, const uint8_t*) = {
|
int (* const iff_parse_function[])(IFFChunk*, const uint8_t*) = {
|
||||||
iff_parse_str, iff_parse_str, iff_parse_str, iff_parse_str,
|
iff_parse_str, iff_parse_str, iff_parse_str, iff_parse_str, iff_parse_str,
|
||||||
|
iff_parse_cats,
|
||||||
|
iff_parse_c_string,
|
||||||
iff_parse_bcon,
|
iff_parse_bcon,
|
||||||
iff_parse_trcn
|
iff_parse_trcn
|
||||||
};
|
};
|
||||||
void (* const iff_free_function[])(void*) = {
|
void (* const iff_free_function[])(void*) = {
|
||||||
iff_free_str, iff_free_str, iff_free_str, iff_free_str,
|
iff_free_str, iff_free_str, iff_free_str, iff_free_str, iff_free_str,
|
||||||
|
iff_free_cats,
|
||||||
|
NULL,
|
||||||
iff_free_bcon,
|
iff_free_bcon,
|
||||||
iff_free_trcn
|
iff_free_trcn
|
||||||
};
|
};
|
||||||
|
@ -58,7 +68,7 @@ IFFFile * iff_create()
|
||||||
{
|
{
|
||||||
IFFFile *ptr = calloc(1, sizeof(IFFFile));
|
IFFFile *ptr = calloc(1, sizeof(IFFFile));
|
||||||
if(ptr == NULL) return NULL;
|
if(ptr == NULL) return NULL;
|
||||||
|
|
||||||
ptr->Chunks = malloc(sizeof(IFFChunk));
|
ptr->Chunks = malloc(sizeof(IFFChunk));
|
||||||
if(ptr->Chunks == NULL){
|
if(ptr->Chunks == NULL){
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
@ -94,13 +104,12 @@ IFFChunk * iff_add_chunk(IFFFile * IFFFileInfo)
|
||||||
if(IFFFileInfo->SizeAllocated > SIZE_MAX/2) return NULL;
|
if(IFFFileInfo->SizeAllocated > SIZE_MAX/2) return NULL;
|
||||||
ptr = realloc(IFFFileInfo->Chunks, IFFFileInfo->SizeAllocated<<1);
|
ptr = realloc(IFFFileInfo->Chunks, IFFFileInfo->SizeAllocated<<1);
|
||||||
if(ptr == NULL) return NULL;
|
if(ptr == NULL) return NULL;
|
||||||
|
|
||||||
IFFFileInfo->Chunks = ptr;
|
IFFFileInfo->Chunks = ptr;
|
||||||
IFFFileInfo->SizeAllocated<<=1;
|
IFFFileInfo->SizeAllocated<<=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFFFileInfo->ChunkCount++;
|
return &IFFFileInfo->Chunks[IFFFileInfo->ChunkCount++];
|
||||||
return IFFFileInfo->Chunks + IFFFileInfo->ChunkCount-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iff_read_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize)
|
int iff_read_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChunkSize)
|
||||||
|
@ -126,6 +135,7 @@ int iff_read_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer, unsigned MaxChu
|
||||||
return 0;
|
return 0;
|
||||||
memcpy(ChunkInfo->Data, Buffer+76, ChunkInfo->Size - 76);
|
memcpy(ChunkInfo->Data, Buffer+76, ChunkInfo->Size - 76);
|
||||||
}
|
}
|
||||||
|
ChunkInfo->FormattedData = NULL;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +160,7 @@ int iff_parse_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
for(i=0; chunktypes[i*4] != '\0'; i++){
|
for(i=0; chunktypes[i*4] != '\0'; i++){
|
||||||
if(!memcmp(ChunkInfo->Type, chunktypes+i*4, 4)){
|
if(!memcmp(ChunkInfo->Type, chunktypes+i*4, 4)){
|
||||||
if(iff_parse_function[i](ChunkInfo, Buffer)) return 1;
|
if(iff_parse_function[i](ChunkInfo, Buffer)) return 1;
|
||||||
iff_free_chunk(ChunkInfo->FormattedData);
|
iff_free_chunk(ChunkInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,13 +169,14 @@ int iff_parse_chunk(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
|
|
||||||
void iff_free_chunk(IFFChunk * ChunkInfo){
|
void iff_free_chunk(IFFChunk * ChunkInfo){
|
||||||
unsigned i;
|
unsigned i;
|
||||||
if(ChunkInfo == NULL || ChunkInfo->FormattedData) return;
|
if(ChunkInfo == NULL || ChunkInfo->FormattedData == NULL) return;
|
||||||
|
|
||||||
for(i=0; chunktypes[i*4] != '\0'; i++){
|
for(i=0; chunktypes[i*4] != '\0'; i++){
|
||||||
if(!memcmp(ChunkInfo->Type, chunktypes+i*4, 4)){
|
if(!memcmp(ChunkInfo->Type, chunktypes+i*4, 4)){
|
||||||
if(iff_free_function[i])
|
if(iff_free_function[i])
|
||||||
iff_free_function[i](ChunkInfo->FormattedData);
|
iff_free_function[i](ChunkInfo->FormattedData);
|
||||||
free(ChunkInfo->FormattedData);
|
free(ChunkInfo->FormattedData);
|
||||||
|
ChunkInfo->FormattedData = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
iff.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
iff.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -120,29 +123,29 @@ typedef struct IFF_STR_s
|
||||||
{
|
{
|
||||||
int16_t Format;
|
int16_t Format;
|
||||||
IFFLanguageSet LanguageSets[20];
|
IFFLanguageSet LanguageSets[20];
|
||||||
} IFF_STR;
|
} IFFString;
|
||||||
|
|
||||||
/* TRCN chunk */
|
/* TRCN chunk */
|
||||||
|
|
||||||
typedef struct IFFRangePair_s
|
typedef struct IFFRangeEntry_s
|
||||||
{
|
{
|
||||||
uint32_t IsUnused;
|
uint32_t IsUnused;
|
||||||
uint32_t Unknown;
|
uint32_t DefaultValue;
|
||||||
char * Key;
|
char * Name;
|
||||||
char * Value;
|
char * Comment;
|
||||||
uint8_t Enforced;
|
uint8_t Enforced;
|
||||||
uint16_t RangeMin;
|
uint16_t RangeMin;
|
||||||
uint16_t RangeMax;
|
uint16_t RangeMax;
|
||||||
} IFFRangePair;
|
} IFFRangeEntry;
|
||||||
|
|
||||||
typedef struct IFF_TRCN_s
|
typedef struct IFFRangeSet_s
|
||||||
{
|
{
|
||||||
uint32_t Reserved;
|
uint32_t Reserved;
|
||||||
uint32_t Version;
|
uint32_t Version;
|
||||||
char MagicNumber[5];
|
char MagicNumber[5];
|
||||||
uint32_t EntryCount;
|
uint32_t RangeCount;
|
||||||
IFFRangePair * Entries;
|
IFFRangeEntry * Ranges;
|
||||||
} IFF_TRCN;
|
} IFFRangeSet;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
iffexport.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
iffexport.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -133,7 +135,8 @@ int main(int argc, char *argv[]){
|
||||||
while((c = strchr(c, filter[i])) != NULL)
|
while((c = strchr(c, filter[i])) != NULL)
|
||||||
*c = '.';
|
*c = '.';
|
||||||
}
|
}
|
||||||
sprintf(destination, "%s/%s.%s", OutDirectory, name, (!memcmp(ChunkData->Type, "BMP_", 4)) ? "bmp" : "dat");
|
sprintf(destination, "%s/%s.%s", OutDirectory, name,
|
||||||
|
(!memcmp(ChunkData->Type, "BMP_", 4) || !memcmp(ChunkData->Type, "FBMP", 4)) ? "bmp" : "dat");
|
||||||
|
|
||||||
hFile = CreateFile(destination, GENERIC_WRITE, 0, NULL, CREATE_NEW+overwrite,
|
hFile = CreateFile(destination, GENERIC_WRITE, 0, NULL, CREATE_NEW+overwrite,
|
||||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
rsmp.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
rsmp.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
str.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
str.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -17,23 +20,23 @@
|
||||||
#include "iff.h"
|
#include "iff.h"
|
||||||
|
|
||||||
int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
IFF_STR * StringData;
|
IFFString * StringData;
|
||||||
unsigned Size = ChunkInfo->Size - 76;
|
unsigned Size = ChunkInfo->Size - 76;
|
||||||
|
|
||||||
if(Size < 2)
|
if(Size < 2)
|
||||||
return 0;
|
return 0;
|
||||||
ChunkInfo->FormattedData = calloc(1, sizeof(IFF_STR));
|
ChunkInfo->FormattedData = calloc(1, sizeof(IFFString));
|
||||||
if(ChunkInfo->FormattedData == NULL)
|
if(ChunkInfo->FormattedData == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
StringData = (IFF_STR*) ChunkInfo->FormattedData;
|
StringData = (IFFString*) ChunkInfo->FormattedData;
|
||||||
StringData->Format = read_int16le(Buffer);
|
StringData->Format = read_int16le(Buffer);
|
||||||
if((Size-=2) < 2) /* TSO allows this; as seen in the animations chunk in personglobals.iff */
|
if((Size-=2) < 2) /* TSO allows this; as seen in the animations chunk in personglobals.iff */
|
||||||
return 1;
|
return 1;
|
||||||
Buffer += 2;
|
Buffer += 2;
|
||||||
|
|
||||||
switch(StringData->Format){
|
switch(StringData->Format){
|
||||||
|
|
||||||
case 0: { /* 00 00 */
|
case 0: { /* 00 00 */
|
||||||
unsigned i;
|
unsigned i;
|
||||||
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
||||||
|
@ -69,23 +72,22 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
case -1: { /* FF FF */
|
case -1: { /* FF FF */
|
||||||
unsigned i;
|
unsigned i;
|
||||||
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
||||||
|
|
||||||
LanguageSet->PairCount = read_uint16le(Buffer);
|
LanguageSet->PairCount = read_uint16le(Buffer);
|
||||||
Buffer += 2; Size -= 2;
|
Buffer += 2; Size -= 2;
|
||||||
if(LanguageSet->PairCount == 0)
|
if(LanguageSet->PairCount == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
||||||
if(LanguageSet->Pairs == NULL)
|
if(LanguageSet->Pairs == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for(i=0; i<LanguageSet->PairCount; i++){
|
for(i=0; i<LanguageSet->PairCount; i++){
|
||||||
unsigned length;
|
unsigned length;
|
||||||
|
|
||||||
if(Size == 0) return 0;
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
for(length=0; Size-length && Buffer[length]; length++);
|
if(length == Size) return 0;
|
||||||
if(Buffer[length] != 0x00) return 0;
|
|
||||||
|
|
||||||
if(length != 0){
|
if(length != 0){
|
||||||
LanguageSet->Pairs[i].Key = malloc(length+1);
|
LanguageSet->Pairs[i].Key = malloc(length+1);
|
||||||
if(LanguageSet->Pairs[i].Key == NULL) return 0;
|
if(LanguageSet->Pairs[i].Key == NULL) return 0;
|
||||||
|
@ -101,25 +103,24 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
case -2: { /* FE FF */
|
case -2: { /* FE FF */
|
||||||
unsigned i;
|
unsigned i;
|
||||||
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[0];
|
||||||
|
|
||||||
LanguageSet->PairCount = read_uint16le(Buffer);
|
LanguageSet->PairCount = read_uint16le(Buffer);
|
||||||
Buffer += 2; Size -= 2;
|
Buffer += 2; Size -= 2;
|
||||||
if(LanguageSet->PairCount == 0)
|
if(LanguageSet->PairCount == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
||||||
if(LanguageSet->Pairs == NULL)
|
if(LanguageSet->Pairs == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for(i=0; i<LanguageSet->PairCount; i++){
|
for(i=0; i<LanguageSet->PairCount; i++){
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
for(s=0; s<2; s++){
|
for(s=0; s<2; s++){
|
||||||
unsigned length;
|
unsigned length;
|
||||||
if(Size == 0) return 0;
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
for(length=0; Size-length && Buffer[length]; length++);
|
if(length == Size) return 0;
|
||||||
if(Buffer[length] != 0x00) return 0;
|
|
||||||
|
|
||||||
if(length != 0){
|
if(length != 0){
|
||||||
char ** string = (s==0) ? &LanguageSet->Pairs[i].Key : &LanguageSet->Pairs[i].Value;
|
char ** string = (s==0) ? &LanguageSet->Pairs[i].Key : &LanguageSet->Pairs[i].Value;
|
||||||
*string = malloc(length+1);
|
*string = malloc(length+1);
|
||||||
|
@ -144,7 +145,7 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
|
|
||||||
if(TotalPairCount == 0)
|
if(TotalPairCount == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Scan through the chunk to count up the number of strings in each LanguageSet,
|
** Scan through the chunk to count up the number of strings in each LanguageSet,
|
||||||
** and then allocate exactly that much and fill in the data on the second pass
|
** and then allocate exactly that much and fill in the data on the second pass
|
||||||
|
@ -158,30 +159,29 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
if(lang >= 20) return 0;
|
if(lang >= 20) return 0;
|
||||||
LanguageSet[lang].PairCount++;
|
LanguageSet[lang].PairCount++;
|
||||||
Buffer++; Size--;
|
Buffer++; Size--;
|
||||||
|
|
||||||
for(s=0; s<2; s++){
|
for(s=0; s<2; s++){
|
||||||
/* Includes the string length check too */
|
/* Includes the string length check too */
|
||||||
unsigned length;
|
unsigned length;
|
||||||
if(Size == 0) return 0;
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
for(length=0; Size-length && Buffer[length]; length++);
|
if(length == Size) return 0;
|
||||||
if(Buffer[length] != 0x00) return 0;
|
|
||||||
Buffer += length+1;
|
Buffer += length+1;
|
||||||
Size -= length+1;
|
Size -= length+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<20; i++){
|
for(i=0; i<20; i++){
|
||||||
LanguageSet[i].Pairs = calloc(LanguageSet[i].PairCount, sizeof(IFFStringPair));
|
LanguageSet[i].Pairs = calloc(LanguageSet[i].PairCount, sizeof(IFFStringPair));
|
||||||
if(LanguageSet[i].Pairs == NULL) return 0;
|
if(LanguageSet[i].Pairs == NULL) return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2nd pass */
|
/* 2nd pass */
|
||||||
Buffer = Start;
|
Buffer = Start;
|
||||||
for(i=0; i<TotalPairCount; i++){
|
for(i=0; i<TotalPairCount; i++){
|
||||||
unsigned lang = read_uint8le(Buffer) - 1, s;
|
unsigned lang = read_uint8le(Buffer) - 1, s;
|
||||||
IFFStringPair * Pair = &LanguageSet[lang].Pairs[Index[lang]++];
|
IFFStringPair * Pair = &LanguageSet[lang].Pairs[Index[lang]++];
|
||||||
Buffer++;
|
Buffer++;
|
||||||
|
|
||||||
for(s=0; s<2; s++){
|
for(s=0; s<2; s++){
|
||||||
unsigned length = strlen((char*) Buffer);
|
unsigned length = strlen((char*) Buffer);
|
||||||
if(length != 0){
|
if(length != 0){
|
||||||
|
@ -202,11 +202,11 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
unsigned LanguageSetCount = read_uint8le(Buffer);
|
unsigned LanguageSetCount = read_uint8le(Buffer);
|
||||||
Buffer++; Size--;
|
Buffer++; Size--;
|
||||||
if(LanguageSetCount > 20) return 0;
|
if(LanguageSetCount > 20) return 0;
|
||||||
|
|
||||||
for(lang=0; lang<LanguageSetCount; lang++){
|
for(lang=0; lang<LanguageSetCount; lang++){
|
||||||
unsigned i;
|
unsigned i;
|
||||||
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[lang];
|
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[lang];
|
||||||
|
|
||||||
if(Size < 2) return 0;
|
if(Size < 2) return 0;
|
||||||
LanguageSet->PairCount = read_uint16le(Buffer);
|
LanguageSet->PairCount = read_uint16le(Buffer);
|
||||||
Buffer += 2; Size -= 2;
|
Buffer += 2; Size -= 2;
|
||||||
|
@ -216,12 +216,12 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
LanguageSet->Pairs = calloc(LanguageSet->PairCount, sizeof(IFFStringPair));
|
||||||
if(LanguageSet->Pairs == NULL)
|
if(LanguageSet->Pairs == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for(i=0; i<LanguageSet->PairCount; i++){
|
for(i=0; i<LanguageSet->PairCount; i++){
|
||||||
unsigned s;
|
unsigned s;
|
||||||
if(Size == 0) return 0;
|
if(Size == 0) return 0;
|
||||||
Buffer++; Size--; /* Skip over the "Language set index" */
|
Buffer++; Size--; /* Skip over the "Language set index" */
|
||||||
|
|
||||||
for(s=0; s<2; s++){
|
for(s=0; s<2; s++){
|
||||||
unsigned length;
|
unsigned length;
|
||||||
if(Size == 0) return 0;
|
if(Size == 0) return 0;
|
||||||
|
@ -248,7 +248,7 @@ int iff_parse_str(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} return 1;
|
} return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -261,9 +261,9 @@ void iff_free_str(void * FormattedData){
|
||||||
** - If the Pairs pointer is nonzero, there must be PairCount initialized pairs in Pairs
|
** - If the Pairs pointer is nonzero, there must be PairCount initialized pairs in Pairs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IFF_STR * StringData = (IFF_STR*) FormattedData;
|
IFFString * StringData = (IFFString*) FormattedData;
|
||||||
unsigned ls;
|
unsigned ls;
|
||||||
|
|
||||||
for(ls=0; ls<20; ls++){
|
for(ls=0; ls<20; ls++){
|
||||||
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[ls];
|
IFFLanguageSet * LanguageSet = &StringData->LanguageSets[ls];
|
||||||
unsigned p;
|
unsigned p;
|
||||||
|
|
38
Libraries/FileHandler/iff/string.c
Normal file
38
Libraries/FileHandler/iff/string.c
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
string.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "iff.h"
|
||||||
|
|
||||||
|
int iff_parse_c_string(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
|
char ** string = (char**) &ChunkInfo->FormattedData;
|
||||||
|
unsigned Size = ChunkInfo->Size - 76;
|
||||||
|
unsigned length;
|
||||||
|
|
||||||
|
if(Size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
|
if(length == Size) return 0;
|
||||||
|
|
||||||
|
if(length > 0){
|
||||||
|
*string = malloc(length+1);
|
||||||
|
if(*string == NULL) return 0;
|
||||||
|
strcpy(*string, (char*) Buffer);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
0
Libraries/FileHandler/iff/tprp.c
Normal file
0
Libraries/FileHandler/iff/tprp.c
Normal file
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
trcn.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
trcn.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -17,39 +20,105 @@
|
||||||
#include "iff.h"
|
#include "iff.h"
|
||||||
|
|
||||||
int iff_parse_trcn(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
int iff_parse_trcn(IFFChunk * ChunkInfo, const uint8_t * Buffer){
|
||||||
return 0; /*
|
IFFRangeSet *RangeSet;
|
||||||
IFF_TRCN * TRCNData;
|
|
||||||
unsigned Size = ChunkInfo->Size - 76;
|
unsigned Size = ChunkInfo->Size - 76;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if(Size < 16)
|
if(Size < 16)
|
||||||
return 0;
|
return 0;
|
||||||
ChunkInfo->FormattedData = malloc(sizeof(IFF_TRCN));
|
ChunkInfo->FormattedData = malloc(sizeof(IFFRangeSet));
|
||||||
if(ChunkInfo->FormattedData == NULL)
|
if(ChunkInfo->FormattedData == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TRCNData = (IFF_TRCN*) ChunkInfo->FormattedData;
|
RangeSet = (IFFRangeSet*) ChunkInfo->FormattedData;
|
||||||
TRCNData->Reserved = read_uint32le(Buffer+0);
|
RangeSet->Ranges = NULL;
|
||||||
TRCNData->Version = read_uint32le(Buffer+4);
|
RangeSet->Reserved = read_uint32le(Buffer);
|
||||||
memcpy(TRCNData->MagicNumber, Buffer+8, 4);
|
RangeSet->Version = read_uint32le(Buffer+4);
|
||||||
TRCNData->MagicNumber[4] = 0x00;
|
memcpy(RangeSet->MagicNumber, Buffer+8, 4);
|
||||||
TRCNData->EntryCount = read_uint32le(Buffer+12);
|
RangeSet->MagicNumber[4] = 0x00;
|
||||||
|
RangeSet->RangeCount = read_uint32le(Buffer+12);
|
||||||
if(TRCNData->Reserved != 0 || TRCNData->Version > 2 || strcmp(TRCNData->MagicNumber, "NCRT")){
|
if(RangeSet->Version > 2)
|
||||||
free(TRCNData);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
if(RangeSet->RangeCount == 0)
|
||||||
ChunkInfo->FormattedData = malloc(TRCNData->EntryCount * sizeof(IFFRangePair));
|
return 1;
|
||||||
if(ChunkInfo->FormattedData == NULL){
|
|
||||||
free(TRCNData);
|
RangeSet->Ranges = calloc(RangeSet->RangeCount, sizeof(IFFRangeEntry));
|
||||||
|
if(RangeSet->Ranges == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Buffer += 16; Size -= 16;
|
||||||
|
for(i=0; i<RangeSet->RangeCount; i++){
|
||||||
|
unsigned s;
|
||||||
|
IFFRangeEntry * Range = &RangeSet->Ranges[i];
|
||||||
|
if(Size < 10)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Range->IsUnused = read_uint32le(Buffer);
|
||||||
|
Range->DefaultValue = read_uint32le(Buffer+4);
|
||||||
|
Buffer += 8; Size -= 8;
|
||||||
|
|
||||||
|
for(s=0; s<2; s++){
|
||||||
|
char ** string = (s==0) ? &Range->Name : &Range->Comment;
|
||||||
|
unsigned length;
|
||||||
|
if(Size == 0) return 0;
|
||||||
|
|
||||||
|
if(RangeSet->Version < 2){
|
||||||
|
/* C string */
|
||||||
|
for(length=0; length != Size && Buffer[length]; length++);
|
||||||
|
if(length == Size) return 0;
|
||||||
|
|
||||||
|
if(length != 0){
|
||||||
|
*string = malloc(length+1);
|
||||||
|
if(*string == NULL) return 0;
|
||||||
|
strcpy(*string, (char*) Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer += length+1;
|
||||||
|
Size -= length+1;
|
||||||
|
|
||||||
|
/* Skip past the 0xA3 character;
|
||||||
|
** see global.iff chunk 546 for why you can't do modulo-2 to detect this */
|
||||||
|
if(Size && *Buffer == 0xA3){
|
||||||
|
Buffer++; Size--;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
/* Pascal string */
|
||||||
|
length = read_uint8le(Buffer);
|
||||||
|
Buffer++; Size--;
|
||||||
|
|
||||||
|
if(length != 0){
|
||||||
|
*string = malloc(length+1);
|
||||||
|
if(*string == NULL) return 0;
|
||||||
|
memcpy(*string, Buffer, length);
|
||||||
|
(*string)[length] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer += length;
|
||||||
|
Size -= length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RangeSet->Version != 0){
|
||||||
|
if(Size < 5) return 0;
|
||||||
|
Range->Enforced = read_uint8le(Buffer);
|
||||||
|
Range->RangeMin = read_uint16le(Buffer+1);
|
||||||
|
Range->RangeMax = read_uint16le(Buffer+3);
|
||||||
|
Buffer += 5; Size -= 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer += 16;
|
return 1;
|
||||||
for(i=0; i<TRCNData->EntryCount; i++){
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void iff_free_trcn(void * FormattedData){
|
void iff_free_trcn(void * FormattedData){
|
||||||
/*IFF_TRCN *TRCNData = (IFF_TRCN*) FormattedData;*/
|
IFFRangeSet *RangeSet = (IFFRangeSet*) FormattedData;
|
||||||
|
if(RangeSet->Ranges){
|
||||||
|
unsigned i;
|
||||||
|
for(i=0; i<RangeSet->RangeCount; i++){
|
||||||
|
IFFRangeEntry *Entry = &RangeSet->Ranges[i];
|
||||||
|
free(Entry->Name);
|
||||||
|
free(Entry->Comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(RangeSet->Ranges);
|
||||||
}
|
}
|
0
Libraries/FileHandler/iff/ttab.c
Normal file
0
Libraries/FileHandler/iff/ttab.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_ini.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_tga.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
Binary file not shown.
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
uis.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
uis.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
uis.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
uis.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -5,5 +5,5 @@ set(UTK_SOURCES
|
||||||
read_utk.c
|
read_utk.c
|
||||||
utkdecode.c
|
utkdecode.c
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(utkdecode ${UTK_SOURCES})
|
add_executable(utkdecode ${UTK_SOURCES})
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_utk.c - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_utk.c - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_utk.h - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_utk.h - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
utkdecode.c - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
utkdecode.c - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -108,7 +110,7 @@ int main(int argc, char *argv[]){
|
||||||
}
|
}
|
||||||
|
|
||||||
UTKGenerateTables();
|
UTKGenerateTables();
|
||||||
|
|
||||||
BeginningTime = GetTickCount();
|
BeginningTime = GetTickCount();
|
||||||
if(!utk_decode(UTKData+32, WaveData+44, UTKHeader.Frames)){
|
if(!utk_decode(UTKData+32, WaveData+44, UTKHeader.Frames)){
|
||||||
printf("%sMemory for this file could not be allocated.", "utkdecode: error: ");
|
printf("%sMemory for this file could not be allocated.", "utkdecode: error: ");
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_wav.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_wav.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -44,16 +46,16 @@ int wav_read_header(wavheader_t * WAVHeader, const uint8_t * Buffer, size_t File
|
||||||
WAVHeader->wBitsPerSample = read_uint16(Buffer+34);
|
WAVHeader->wBitsPerSample = read_uint16(Buffer+34);
|
||||||
WAVHeader->DataID = read_uint32(Buffer+36);
|
WAVHeader->DataID = read_uint32(Buffer+36);
|
||||||
WAVHeader->DataSize = read_uint32(Buffer+40);
|
WAVHeader->DataSize = read_uint32(Buffer+40);
|
||||||
|
|
||||||
if(WAVHeader->sID != 0x46464952 || WAVHeader->Size != FileSize-8 || WAVHeader->DataType != 0x45564157 ||
|
if(WAVHeader->sID != 0x46464952 || WAVHeader->Size != FileSize-8 || WAVHeader->DataType != 0x45564157 ||
|
||||||
WAVHeader->FmtID != 0x20746D66 || WAVHeader->FmtSize != 16 || WAVHeader->wFormatTag != WAVE_FORMAT_PCM ||
|
WAVHeader->FmtID != 0x20746D66 || WAVHeader->FmtSize != 16 || WAVHeader->wFormatTag != WAVE_FORMAT_PCM ||
|
||||||
WAVHeader->nChannels < 1 || WAVHeader->nChannels > 2 || WAVHeader->nSamplesPerSec == 0 ||
|
WAVHeader->nChannels < 1 || WAVHeader->nChannels > 2 || WAVHeader->nSamplesPerSec == 0 ||
|
||||||
(WAVHeader->nSamplesPerSec%8000 != 0 && WAVHeader->nSamplesPerSec%11025 != 0) || WAVHeader->nSamplesPerSec > 48000 ||
|
(WAVHeader->nSamplesPerSec%8000 != 0 && WAVHeader->nSamplesPerSec%11025 != 0) || WAVHeader->nSamplesPerSec > 48000 ||
|
||||||
WAVHeader->nAvgBytesPerSec != WAVHeader->nSamplesPerSec * WAVHeader->nBlockAlign ||
|
WAVHeader->nAvgBytesPerSec != WAVHeader->nSamplesPerSec * WAVHeader->nBlockAlign ||
|
||||||
WAVHeader->nBlockAlign != WAVHeader->nChannels * WAVHeader->wBitsPerSample >> 3 ||
|
WAVHeader->nBlockAlign != WAVHeader->nChannels * WAVHeader->wBitsPerSample >> 3 ||
|
||||||
(WAVHeader->wBitsPerSample != 8 && WAVHeader->wBitsPerSample != 16) || WAVHeader->DataID != 0x61746164 ||
|
(WAVHeader->wBitsPerSample != 8 && WAVHeader->wBitsPerSample != 16) || WAVHeader->DataID != 0x61746164 ||
|
||||||
WAVHeader->DataSize != FileSize - 44 || WAVHeader->DataSize % WAVHeader->nBlockAlign != 0
|
WAVHeader->DataSize != FileSize - 44 || WAVHeader->DataSize % WAVHeader->nBlockAlign != 0
|
||||||
) return 0;
|
) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_wav.h - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_wav.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_xa.c - Copyright (c) 2011 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_xa.c - Copyright (c) 2011 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -49,8 +51,8 @@ unsigned xa_compressed_size(unsigned Frames, unsigned Channels)
|
||||||
|
|
||||||
unsigned SingleChannelData = (((Frames+1)>>1) + (Frames+27)/28);
|
unsigned SingleChannelData = (((Frames+1)>>1) + (Frames+27)/28);
|
||||||
|
|
||||||
if(Frames > 0xFFFFFFFFu-27) return 0;
|
if(Frames > UINT_MAX-27) return 0;
|
||||||
if(0xFFFFFFFFu/SingleChannelData < Channels) return 0;
|
if(UINT_MAX/SingleChannelData < Channels) return 0;
|
||||||
|
|
||||||
return Channels*SingleChannelData;
|
return Channels*SingleChannelData;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +88,7 @@ int xa_read_header(xaheader_t * XAHeader, const uint8_t * Buffer, size_t FileSiz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__inline int16_t Clip16(int sample)
|
static __inline int16_t Clip16(int sample)
|
||||||
{
|
{
|
||||||
if(sample>=32767) return 32767;
|
if(sample>=32767) return 32767;
|
||||||
else if(sample<=-32768) return -32768;
|
else if(sample<=-32768) return -32768;
|
||||||
|
@ -99,7 +101,7 @@ typedef struct {
|
||||||
int c1, c2; /* predictor coefficients */
|
int c1, c2; /* predictor coefficients */
|
||||||
} channel_t;
|
} channel_t;
|
||||||
|
|
||||||
const int XATable[] =
|
static const int16_t XATable[] =
|
||||||
{
|
{
|
||||||
0, 240, 460, 392,
|
0, 240, 460, 392,
|
||||||
0, 0, -208, -220,
|
0, 0, -208, -220,
|
||||||
|
@ -110,11 +112,11 @@ const int XATable[] =
|
||||||
|
|
||||||
int xa_decode(const uint8_t *__restrict InBuffer, uint8_t *__restrict OutBuffer, unsigned Frames, unsigned Channels)
|
int xa_decode(const uint8_t *__restrict InBuffer, uint8_t *__restrict OutBuffer, unsigned Frames, unsigned Channels)
|
||||||
{
|
{
|
||||||
channel_t * Channel = malloc(Channels * sizeof(channel_t));
|
channel_t Channel[8];
|
||||||
if(!Channel) return 0;
|
memset(Channel, 0x00, sizeof(Channel));
|
||||||
memset(Channel, 0x00, Channels * sizeof(channel_t));
|
if(Frames == 0) return 1;
|
||||||
|
|
||||||
while(Frames){
|
while(1){
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for(i=0; i<Channels; i++){
|
for(i=0; i<Channels; i++){
|
||||||
|
@ -129,26 +131,23 @@ int xa_decode(const uint8_t *__restrict InBuffer, uint8_t *__restrict OutBuffer,
|
||||||
for(j=0; j<Channels; j++){
|
for(j=0; j<Channels; j++){
|
||||||
unsigned byte = *(InBuffer++);
|
unsigned byte = *(InBuffer++);
|
||||||
int n;
|
int n;
|
||||||
for(n=0; n<2; n++){
|
for(n=4; n>=0; n-=4){
|
||||||
int NewValue = (n == 0) ? HINIBBLE(byte) : LONIBBLE(byte);
|
int NewValue = byte >> n;
|
||||||
NewValue = (NewValue << 28) >> Channel[j].divisor;
|
NewValue = (NewValue << 28) >> Channel[j].divisor;
|
||||||
NewValue = (NewValue + Channel[j].CurSample*Channel[j].c1 + Channel[j].PrevSample*Channel[j].c2 + 128) >> 8;
|
NewValue = (NewValue + Channel[j].CurSample*Channel[j].c1 + Channel[j].PrevSample*Channel[j].c2 + 128) >> 8;
|
||||||
Channel[j].PrevSample = Channel[j].CurSample;
|
Channel[j].PrevSample = Channel[j].CurSample;
|
||||||
Channel[j].CurSample = Clip16(NewValue);
|
Channel[j].CurSample = Clip16(NewValue);
|
||||||
}
|
}
|
||||||
*(OutBuffer++) = (Channel[j].PrevSample&0x00FFu)>>(8*0);
|
*(OutBuffer++) = Channel[j].PrevSample>>(8*0);
|
||||||
*(OutBuffer++) = (Channel[j].PrevSample&0xFF00u)>>(8*1);
|
*(OutBuffer++) = Channel[j].PrevSample>>(8*1);
|
||||||
}
|
}
|
||||||
if(!--Frames) break;
|
if(!--Frames) return 1;
|
||||||
|
|
||||||
for(j=0; j<Channels; j++){
|
for(j=0; j<Channels; j++){
|
||||||
*(OutBuffer++) = (Channel[j].CurSample&0x00FFu)>>(8*0);
|
*(OutBuffer++) = Channel[j].CurSample>>(8*0);
|
||||||
*(OutBuffer++) = (Channel[j].CurSample&0xFF00u)>>(8*1);
|
*(OutBuffer++) = Channel[j].CurSample>>(8*1);
|
||||||
}
|
}
|
||||||
if(!--Frames) break;
|
if(!--Frames) return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(Channel);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
read_xa.h - Copyright (c) 2011 Fatbag <X-Fi6@phppoll.org>
|
FileHandler - General-purpose file handling library for Niotso
|
||||||
|
read_xa.h - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
libfar - Copyright (c) 2011-2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
Version 1.0.1
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
Renderer.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
anim.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
apr.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
bnd.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
col.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
libvitaboy.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
libvitaboy.hpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -21,7 +23,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
|
||||||
#include <FileHandler.hpp>
|
#include <FileHandler.hpp>
|
||||||
|
|
||||||
class VBFile_t {
|
class VBFile_t {
|
||||||
|
@ -84,7 +85,7 @@ class VBFile_t {
|
||||||
inline char* readstring(){
|
inline char* readstring(){
|
||||||
//Read a Pascal string with 1 length byte
|
//Read a Pascal string with 1 length byte
|
||||||
unsigned length = readint8();
|
unsigned length = readint8();
|
||||||
char *string = (char*) malloc((length+1) * sizeof(char));
|
char *string = (char*) malloc(length+1);
|
||||||
readbytes(string, length);
|
readbytes(string, length);
|
||||||
string[length] = '\0';
|
string[length] = '\0';
|
||||||
return string;
|
return string;
|
||||||
|
@ -93,7 +94,7 @@ class VBFile_t {
|
||||||
inline char* readstring2(){
|
inline char* readstring2(){
|
||||||
//Read a Pascal string with 2 length bytes
|
//Read a Pascal string with 2 length bytes
|
||||||
unsigned length = readint16();
|
unsigned length = readint16();
|
||||||
char *string = (char*) malloc((length+1) * sizeof(char));
|
char *string = (char*) malloc(length+1);
|
||||||
readbytes(string, length);
|
readbytes(string, length);
|
||||||
string[length] = '\0';
|
string[length] = '\0';
|
||||||
return string;
|
return string;
|
||||||
|
@ -288,7 +289,7 @@ struct Vertex_t {
|
||||||
Coord_t Coord;
|
Coord_t Coord;
|
||||||
TextureCoord_t TextureCoord;
|
TextureCoord_t TextureCoord;
|
||||||
NormalCoord_t NormalCoord;
|
NormalCoord_t NormalCoord;
|
||||||
|
|
||||||
unsigned BoneIndex;
|
unsigned BoneIndex;
|
||||||
BlendData_t BlendData;
|
BlendData_t BlendData;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
mesh.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -87,7 +89,7 @@ void ReadMesh(Mesh_t& Mesh){
|
||||||
Mesh.TransformedVertexData[i].BlendData.OtherVertex = BlendData[i-Mesh.RealVertexCount].OtherVertex;
|
Mesh.TransformedVertexData[i].BlendData.OtherVertex = BlendData[i-Mesh.RealVertexCount].OtherVertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(TextureVertexData);
|
free(TextureVertexData);
|
||||||
free(BlendData);
|
free(BlendData);
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
oft.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
po.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
skel.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
libvitaboy - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
libvitaboy - Open source OpenGL TSO character animation library
|
||||||
|
vbparse.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Niotso Server - Copyright (C) 2012 Fatbag <X-Fi6@phppoll.org>
|
Niotso Server - Niotso daemon based on PostgreSQL
|
||||||
|
Server.cpp
|
||||||
|
Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
|
@ -1,3 +1,3 @@
|
||||||
add_subdirectory(FARDive)
|
add_subdirectory(FARDive)
|
||||||
add_subdirectory(iff2html)
|
add_subdirectory(hitutils)
|
||||||
add_subdirectory(misc)
|
add_subdirectory(iff2html)
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
TSOSimulatorClient.cpp - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
TSOSimulatorClient - TSOSimulatorClientD.dll injector
|
||||||
|
iff2html.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
18
Tools/hitutils/CMakeLists.txt
Normal file
18
Tools/hitutils/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
project(hitutils)
|
||||||
|
|
||||||
|
set(HITDUMP_SOURCES
|
||||||
|
hitdump.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HITASM_SOURCES
|
||||||
|
hitasm.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HITLD_SOURCES
|
||||||
|
hitld.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(hitdump ${HITDUMP_SOURCES})
|
||||||
|
add_executable(hitasm ${HITASM_SOURCES})
|
||||||
|
add_executable(hitld ${HITLD_SOURCES})
|
32
Tools/hitutils/hitasm.cpp
Normal file
32
Tools/hitutils/hitasm.cpp
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
hitutils - The Sims HIT (dis)assembler and linker
|
||||||
|
hitasm.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Usage: hitasm [-f] [-o outfile.o] infile.txt\n"
|
||||||
|
"Compile a HIT source file to an intermediary object file\n"
|
||||||
|
"which can be linked using hitld.\n"
|
||||||
|
"\n"
|
||||||
|
"Use -f to force overwriting without confirmation.\n"
|
||||||
|
"\n"
|
||||||
|
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||||
|
"hitutils is maintained by the Niotso project.\n"
|
||||||
|
"Home page: <http://www.niotso.org/>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
35
Tools/hitutils/hitdump.cpp
Normal file
35
Tools/hitutils/hitdump.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
hitutils - The Sims HIT (dis)assembler and linker
|
||||||
|
hitdump.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Usage: hitdump [-f] [-o outfile.txt] [-hsm outfile.hsm]\n"
|
||||||
|
" [-hot outfile.hot] infile.hit\n"
|
||||||
|
"Disassemble a HIT binary.\n"
|
||||||
|
"\n"
|
||||||
|
"The HSM and HOT files associated with the HIT file are required\n"
|
||||||
|
"as inputs; their paths default to same base name as the input\n"
|
||||||
|
"file but can be changed with the above options.\n"
|
||||||
|
"Use -f to force overwriting without confirmation.\n"
|
||||||
|
"\n"
|
||||||
|
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||||
|
"hitutils is maintained by the Niotso project.\n"
|
||||||
|
"Home page: <http://www.niotso.org/>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
35
Tools/hitutils/hitld.cpp
Normal file
35
Tools/hitutils/hitld.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
hitutils - The Sims HIT (dis)assembler and linker
|
||||||
|
hitld.cpp - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Usage: hitld [-f] [-hsm infile.hsm] [-hot infile.hot]\n"
|
||||||
|
" outfile.hit INFILES\n"
|
||||||
|
"Link object files produced by hitasm into a HIT binary.\n"
|
||||||
|
"\n"
|
||||||
|
"The HSM and HOT files associated with the HIT file are required\n"
|
||||||
|
"for modification; their paths are normally defined by one of the\n"
|
||||||
|
"linked objects but can be forced using the above options.\n"
|
||||||
|
"Use -f to force overwriting without confirmation.\n"
|
||||||
|
"\n"
|
||||||
|
"Report bugs to <X-Fi6@phppoll.org>.\n"
|
||||||
|
"hitutils is maintained by the Niotso project.\n"
|
||||||
|
"Home page: <http://www.niotso.org/>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
/*
|
/*
|
||||||
iff2html.c - Copyright (c) 2012 Fatbag <X-Fi6@phppoll.org>
|
iff2html - iff web page description generator
|
||||||
|
iff2html.c - Copyright (c) 2012 Niotso Project <http://niotso.org/>
|
||||||
|
Author(s): Fatbag <X-Fi6@phppoll.org>
|
||||||
|
Ahmed El-Mahdawy <aa.mahdawy.10@gmail.com>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -140,7 +143,7 @@ int main(int argc, char *argv[]){
|
||||||
printf("%sChunk data is corrupt.", "iff2html: error: ");
|
printf("%sChunk data is corrupt.", "iff2html: error: ");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the MD5, and then we can free the IFF data because we're done with it */
|
/* Calculate the MD5, and then we can free the IFF data because we're done with it */
|
||||||
MD5Init(&md5c);
|
MD5Init(&md5c);
|
||||||
MD5Update(&md5c, IFFData, FileSize);
|
MD5Update(&md5c, IFFData, FileSize);
|
||||||
|
@ -269,7 +272,6 @@ int main(int argc, char *argv[]){
|
||||||
fprintf(hFile, "\n");
|
fprintf(hFile, "\n");
|
||||||
|
|
||||||
for(i=1, ChunkData = IFFFileInfo->Chunks; i <= IFFFileInfo->ChunkCount; i++, ChunkData++){
|
for(i=1, ChunkData = IFFFileInfo->Chunks; i <= IFFFileInfo->ChunkCount; i++, ChunkData++){
|
||||||
IFF_STR * StringData = (IFF_STR*) ChunkData->FormattedData;
|
|
||||||
fprintf(hFile, "<h2 id=\"chunk%u_%.4x\">%u [%s] (%.4X)%s%s <a href=\"#chunk%u_%.4x\">(Jump)</a></h2>\n",
|
fprintf(hFile, "<h2 id=\"chunk%u_%.4x\">%u [%s] (%.4X)%s%s <a href=\"#chunk%u_%.4x\">(Jump)</a></h2>\n",
|
||||||
i, ChunkData->ChunkID, i, ChunkData->Type, ChunkData->ChunkID,
|
i, ChunkData->ChunkID, i, ChunkData->Type, ChunkData->ChunkID,
|
||||||
(ChunkData->Label[0] != 0x00) ? " – " : "", ChunkData->Label,
|
(ChunkData->Label[0] != 0x00) ? " – " : "", ChunkData->Label,
|
||||||
|
@ -281,11 +283,13 @@ int main(int argc, char *argv[]){
|
||||||
}else if(!strcmp(ChunkData->Type, "STR#") ||
|
}else if(!strcmp(ChunkData->Type, "STR#") ||
|
||||||
!strcmp(ChunkData->Type, "CTSS") ||
|
!strcmp(ChunkData->Type, "CTSS") ||
|
||||||
!strcmp(ChunkData->Type, "FAMs") ||
|
!strcmp(ChunkData->Type, "FAMs") ||
|
||||||
!strcmp(ChunkData->Type, "TTAs") ){
|
!strcmp(ChunkData->Type, "TTAs") ||
|
||||||
|
!strcmp(ChunkData->Type, "CST") ){
|
||||||
/****
|
/****
|
||||||
** STR# parsing
|
** STR# parsing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
IFFString * StringData = ChunkData->FormattedData;
|
||||||
fprintf(hFile, "<table>\n");
|
fprintf(hFile, "<table>\n");
|
||||||
fprintf(hFile, "<tr><td>Format:</td><td>");
|
fprintf(hFile, "<tr><td>Format:</td><td>");
|
||||||
switch(StringData->Format){
|
switch(StringData->Format){
|
||||||
|
@ -346,23 +350,71 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
fprintf(hFile, "</table>\n");
|
fprintf(hFile, "</table>\n");
|
||||||
}
|
}
|
||||||
|
}else if(!strcmp(ChunkData->Type, "CATS")){
|
||||||
|
/****
|
||||||
|
** CATS parsing
|
||||||
|
*/
|
||||||
|
|
||||||
|
IFFStringPair * Pair = ChunkData->FormattedData;
|
||||||
|
|
||||||
|
fprintf(hFile, "<table class=\"center\">\n");
|
||||||
|
fprintf(hFile, "<tr><th>Key</th><th>Value</th></tr>\n");
|
||||||
|
fprintf(hFile, "<tr><td>%s</td><td>%s</td></tr>\n",
|
||||||
|
(Pair->Key) != NULL ? Pair->Key : "",
|
||||||
|
(Pair->Value) != NULL ? Pair->Value : "");
|
||||||
|
fprintf(hFile, "</table>\n");
|
||||||
|
}else if(!strcmp(ChunkData->Type, "FWAV")){
|
||||||
|
/****
|
||||||
|
** Regular string
|
||||||
|
*/
|
||||||
|
|
||||||
|
fprintf(hFile, "<table class=\"center\">\n");
|
||||||
|
fprintf(hFile, "<tr><th>String</th></tr>\n");
|
||||||
|
fprintf(hFile, "<tr><td>%s</td></tr>\n", ChunkData->FormattedData ? (char*) ChunkData->FormattedData : "");
|
||||||
|
fprintf(hFile, "</table>\n");
|
||||||
}else if(!strcmp(ChunkData->Type, "BCON")){
|
}else if(!strcmp(ChunkData->Type, "BCON")){
|
||||||
/****
|
/****
|
||||||
** BCON parsing
|
** BCON parsing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IFF_BCON * BCONData = (IFF_BCON*) ChunkData->FormattedData;
|
IFF_BCON * BCONData = ChunkData->FormattedData;
|
||||||
fprintf(hFile, "<table>\n");
|
fprintf(hFile, "<table>\n");
|
||||||
fprintf(hFile, "<tr><td>Flags:</td><td><tt>%02X</tt> (%d)</td></tr>\n", BCONData->Flags, BCONData->Flags);
|
fprintf(hFile, "<tr><td>Flags:</td><td><tt>%02X</tt> (%d)</td></tr>\n", BCONData->Flags, BCONData->Flags);
|
||||||
fprintf(hFile, "</table>\n");
|
fprintf(hFile, "</table>\n");
|
||||||
if(BCONData->ConstantCount > 0){
|
if(BCONData->ConstantCount > 0){
|
||||||
unsigned ConstantIndex;
|
unsigned i;
|
||||||
|
|
||||||
fprintf(hFile, "<br />\n");
|
fprintf(hFile, "<br />\n");
|
||||||
fprintf(hFile, "<table class=\"center\">\n");
|
fprintf(hFile, "<table class=\"center\">\n");
|
||||||
fprintf(hFile, "<tr><th colspan=\"2\">Constant Value</th></tr>\n");
|
fprintf(hFile, "<tr><th colspan=\"2\">Constant Value</th></tr>\n");
|
||||||
for(ConstantIndex=0; ConstantIndex<BCONData->ConstantCount; ConstantIndex++)
|
for(i=0; i<BCONData->ConstantCount; i++)
|
||||||
fprintf(hFile, "<tr><td>%u</td><td>%u</td></tr>\n", ConstantIndex+1, BCONData->Constants[ConstantIndex]);
|
fprintf(hFile, "<tr><td>%u</td><td>%u</td></tr>\n", i+1, BCONData->Constants[i]);
|
||||||
|
fprintf(hFile, "</table>\n");
|
||||||
|
}
|
||||||
|
}else if(!strcmp(ChunkData->Type, "TRCN")){
|
||||||
|
/****
|
||||||
|
** TRCN parsing
|
||||||
|
*/
|
||||||
|
|
||||||
|
IFFRangeSet * RangeSet = ChunkData->FormattedData;
|
||||||
|
fprintf(hFile, "<table>\n");
|
||||||
|
fprintf(hFile, "<tr><td>Version:</td><td>%u</td></tr>\n", RangeSet->Version);
|
||||||
|
fprintf(hFile, "</table>\n");
|
||||||
|
if(RangeSet->RangeCount > 0){
|
||||||
|
unsigned i;
|
||||||
|
IFFRangeEntry * Range;
|
||||||
|
|
||||||
|
fprintf(hFile, "<br />\n");
|
||||||
|
fprintf(hFile, "<table class=\"center\">\n");
|
||||||
|
fprintf(hFile, "<tr><th>Used yet</th><th>Default value</th><th>Name</th>"
|
||||||
|
"<th>Comment</th><th>Range is enforced</th><th>Minimum</th><th>Maximum</th></tr>\n");
|
||||||
|
for(i=0, Range=RangeSet->Ranges; i<RangeSet->RangeCount; i++, Range++)
|
||||||
|
fprintf(hFile, "<tr><td>%s</td><td>%u</td><td>%s</td><td>%s</td><td>%s</td><td>%u</td><td>%u</td></tr>\n",
|
||||||
|
Range->IsUnused ? "No" : "Yes", Range->DefaultValue,
|
||||||
|
Range->Name ? Range->Name : "",
|
||||||
|
Range->Comment ? Range->Comment : "",
|
||||||
|
Range->Enforced ? "Yes" : "No",
|
||||||
|
Range->RangeMin, Range->RangeMax);
|
||||||
fprintf(hFile, "</table>\n");
|
fprintf(hFile, "</table>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +429,7 @@ int main(int argc, char *argv[]){
|
||||||
fprintf(hFile, "</body>\n");
|
fprintf(hFile, "</body>\n");
|
||||||
fprintf(hFile, "</html>");
|
fprintf(hFile, "</html>");
|
||||||
fclose(hFile);
|
fclose(hFile);
|
||||||
|
|
||||||
printf("Wrote contents to '%s'.\n", OutFile);
|
printf("Wrote contents to '%s'.\n", OutFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -1,125 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<meta http-equiv="Content-Style-Type" content="text/css; charset=utf-8" />
|
|
||||||
<meta http-equiv="Content-Language" content="en" />
|
|
||||||
<meta name="description" content="behavior.iff (iff2html)" />
|
|
||||||
<meta name="generator" content="iff2html" />
|
|
||||||
<title>behavior.iff (iff2html)</title>
|
|
||||||
<style type="text/css" media="all">
|
|
||||||
html, body {
|
|
||||||
background: #fff;
|
|
||||||
color: #000;
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link, a:visited, a:hover, a:active { color: #00f; }
|
|
||||||
a:link, a:visited { text-decoration: none; }
|
|
||||||
a:hover, a:active { text-decoration: underline; }
|
|
||||||
|
|
||||||
#attributes {
|
|
||||||
border-left: 2px solid #888; padding-left: 4px; margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#toc {
|
|
||||||
display: table-cell;
|
|
||||||
margin-top: 1em;
|
|
||||||
background: #eee; border: 1px solid #bbb;
|
|
||||||
padding: .25em;
|
|
||||||
}
|
|
||||||
#toc div {
|
|
||||||
border-bottom: 1px solid #aaa;
|
|
||||||
}
|
|
||||||
#toc ul {
|
|
||||||
list-style-type: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
ul ul {
|
|
||||||
padding: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
border-bottom: 1px solid #888;
|
|
||||||
margin: 2em 0 0.25em 0;
|
|
||||||
}
|
|
||||||
h2 a {
|
|
||||||
font-size: 9pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
border: 1px #aaa solid;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
th, td {
|
|
||||||
border: 1px #aaa solid;
|
|
||||||
padding: 0.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
margin: auto auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#footer {
|
|
||||||
margin-top: 1.75em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>behavior.iff</h1>
|
|
||||||
<div id="attributes">
|
|
||||||
<div>9809b96803833f2891ddd31e474795a9 (md5), 42.4kB (43,446 bytes)</div>
|
|
||||||
<div>Dumped by iff2html.</div></div>
|
|
||||||
|
|
||||||
<div id="toc"><div><b>Contents</b> – x chunks</div>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#chunk1_00dd">1 [STR#] (00DD) – neighbor data labels</a></li>
|
|
||||||
<li><a href="#chunk2_00ea">2 [STR#] (00EA) – build mode types</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 id="chunk1_00dd">1 [STR#] (00DD) – neighbor data labels <a href="#chunk1_00dd">(Jump)</a></h2>
|
|
||||||
<div>
|
|
||||||
<table>
|
|
||||||
<tr><td>Format:</td><td><tt>FC FF</tt> (−4)</td></tr>
|
|
||||||
</table><br />
|
|
||||||
<table class="center">
|
|
||||||
<tr><th>Language</th><th colspan="3">String pairs</th></tr>
|
|
||||||
<tr><td rowspan="10">English (US)</td>
|
|
||||||
<td>1</td><td>person instance id</td><td>4</td></tr>
|
|
||||||
<tr><td>2</td><td>belongs in house</td><td>4</td></tr>
|
|
||||||
<tr><td>3</td><td>person age</td><td>4</td></tr>
|
|
||||||
<tr><td>4</td><td>relationship raw score</td><td>4</td></tr>
|
|
||||||
<tr><td>5</td><td>relationship score</td><td>4</td></tr>
|
|
||||||
<tr><td>6</td><td>friend count</td><td>4</td></tr>
|
|
||||||
<tr><td>7</td><td>house number</td><td>4</td></tr>
|
|
||||||
<tr><td>8</td><td>has telephone</td><td>4</td></tr>
|
|
||||||
<tr><td>9</td><td>has baby</td><td>4</td></tr>
|
|
||||||
<tr><td>10</td><td>family friend count</td><td>4</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 id="chunk2_00ea">2 [STR#] (00EA) – build mode types <a href="#chunk2_00ea">(Jump)</a></h2>
|
|
||||||
<div>
|
|
||||||
<table>
|
|
||||||
<tr><td>Format:</td><td><tt>FC FF</tt> (−4)</td></tr>
|
|
||||||
</table><br />
|
|
||||||
<table class="center">
|
|
||||||
<tr><th>Language</th><th colspan="3">String pairs</th></tr>
|
|
||||||
<tr><td rowspan="8">English (US)</td>
|
|
||||||
<td>1</td><td>none</td><td>4</td></tr>
|
|
||||||
<tr><td>2</td><td>door</td><td>4</td></tr>
|
|
||||||
<tr><td>3</td><td>window</td><td>4</td></tr>
|
|
||||||
<tr><td>4</td><td>stair</td><td>4</td></tr>
|
|
||||||
<tr><td>5</td><td>plant</td><td>4</td></tr>
|
|
||||||
<tr><td>6</td><td>fireplace</td><td>4</td></tr>
|
|
||||||
<tr><td>7</td><td>column</td><td>4</td></tr>
|
|
||||||
<tr><td>8</td><td>pool equipment</td><td>4</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="footer">This page was generated by the use of <a href="http://www.niotso.org/">iff2html</a>.
|
|
||||||
The content of this page may be subject to copyright by the author(s) of the original iff file.</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -107,7 +107,7 @@ void MD5Update(ctx, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||||
*/
|
*/
|
||||||
void MD5Final(digest, ctx)
|
void MD5Final(digest, ctx)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
the byteReverse function in md5.c must be invoked. However,
|
the byteReverse function in md5.c must be invoked. However,
|
||||||
byteReverse is coded in such a way that it is an identity
|
byteReverse is coded in such a way that it is an identity
|
||||||
function when run on a little-endian machine, so calling it
|
function when run on a little-endian machine, so calling it
|
||||||
on such a platform causes no harm apart from wasting time.
|
on such a platform causes no harm apart from wasting time.
|
||||||
If the platform is known to be little-endian, we speed
|
If the platform is known to be little-endian, we speed
|
||||||
things up by undefining HIGHFIRST, which defines
|
things up by undefining HIGHFIRST, which defines
|
||||||
byteReverse as a null macro. Doing things in this manner
|
byteReverse as a null macro. Doing things in this manner
|
||||||
|
|
0
Tools/tsoscan/tsoscan.txt
Normal file
0
Tools/tsoscan/tsoscan.txt
Normal file
|
@ -5,4 +5,7 @@ Add these files:
|
||||||
* Chair-Liv-Deco_large_front_z.png
|
* Chair-Liv-Deco_large_front_z.png
|
||||||
* tower_large_ne_a.png
|
* tower_large_ne_a.png
|
||||||
* tower_large_ne_p.png
|
* tower_large_ne_p.png
|
||||||
* tower_large_ne_z.png
|
* tower_large_ne_z.png
|
||||||
|
|
||||||
|
Then open index.html in a web browser which supports the HTML5 canvas,
|
||||||
|
and use the arrow keys.
|
Loading…
Add table
Reference in a new issue