diff --git a/Client/Audio/Makefile b/Client/Audio/Makefile deleted file mode 100644 index e69de29..0000000 diff --git a/Client/Bootstrap/Makefile b/Client/Bootstrap/Makefile deleted file mode 100644 index e69de29..0000000 diff --git a/Client/Graphics/Makefile b/Client/Graphics/Makefile deleted file mode 100644 index e69de29..0000000 diff --git a/Client/Makefile b/Client/Makefile deleted file mode 100644 index 27a0bc3..0000000 --- a/Client/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifdef niotso_buildsys - niotso_exes += TSO$(EXE) -endif \ No newline at end of file diff --git a/Libraries/libvitaboy/anim.cpp b/Libraries/libvitaboy/anim.cpp new file mode 100644 index 0000000..53bd58d --- /dev/null +++ b/Libraries/libvitaboy/anim.cpp @@ -0,0 +1,146 @@ +#include "libvitaboy.hpp" + +static unsigned motionnumber = 0; + +void ReadAnimation(Animation_t& Animation){ + printf("===== Animation =====\n"); + Animation.Version = VBFile.readint32(); + printf("Version: %u\n", Animation.Version); + Animation.Name = VBFile.readstring2(); + printf("Name: %s\n", Animation.Name); + Animation.Duration = VBFile.readfloat(); + printf("Duration: %g\n", Animation.Duration/1000); + Animation.Distance = VBFile.readfloat(); + printf("Distance: %g\n", Animation.Distance); + Animation.IsMoving = VBFile.readint8(); + printf("IsMoving: %u\n", Animation.IsMoving); + + Animation.TranslationsCount = VBFile.readint32(); + printf("TranslationsCount: %u\n", Animation.TranslationsCount); + Animation.TranslationsOffset = VBFile.getpos(); + VBFile.seekto(Animation.TranslationsOffset + 12*Animation.TranslationsCount); + + Animation.RotationsCount = VBFile.readint32(); + printf("RotationsCount: %u\n", Animation.RotationsCount); + Animation.RotationsOffset = VBFile.getpos(); + VBFile.seekto(Animation.RotationsOffset + 16*Animation.RotationsCount); + + Animation.MotionsCount = VBFile.readint32(); + printf("MotionsCount: %u\n", Animation.MotionsCount); + Animation.Motions = (Motion_t*) malloc(Animation.MotionsCount * sizeof(Motion_t)); + for(unsigned i=0; i +#include +#include +#include +#include + +class VBFile_t { + private: + const uint8_t *Buffer, *Position; + unsigned Size; + + public: + inline void set(const void *_Buffer, unsigned _Size){ + Buffer = (const uint8_t*) _Buffer; + Position = (const uint8_t*) _Buffer; + Size = _Size; + } + + inline unsigned getpos(){ + return Position-Buffer; + } + + inline void seekto(unsigned offset){ + Position = Buffer+offset; + } + + inline uint32_t readint32(){ + uint32_t value = (uint32_t)((Position[0]<<(8*3)) | (Position[1]<<(8*2)) | (Position[2]<<(8*1)) | (Position[3]<<(8*0))); + Position += 4; + return value; + } + + inline uint32_t readint16(){ + uint16_t value = (uint16_t)((Position[0]<<(8*1)) | (Position[1]<<(8*0))); + Position += 2; + return value; + } + + inline uint32_t readint8(){ + uint8_t value = (uint8_t)((Position[0]<<(8*0))); + Position += 1; + return value; + } + + inline float readfloat(){ + //Obviously a platform-dependent implementation + float value; + memcpy(&value, Position, 4); + Position += 4; + return value; + } + + inline void readbytes(void* Destination, unsigned length){ + memcpy(Destination, Position, length); + Position += length; + } + + inline char* readstring(){ + //Read a Pascal string with 1 length byte + unsigned length = readint8(); + char *string = (char*) malloc((length+1) * sizeof(char)); + readbytes(string, length); + string[length] = '\0'; + return string; + } + + inline char* readstring2(){ + //Read a Pascal string with 2 length bytes + unsigned length = readint16(); + char *string = (char*) malloc((length+1) * sizeof(char)); + readbytes(string, length); + string[length] = '\0'; + return string; + } +}; + +extern VBFile_t VBFile; + +struct Translation_t { + float x, y, z; +}; + +struct Rotation_t { + float w, x, y, z; +}; + +struct Prop_t { + uint32_t Property; + char * Key; + char * Value; +}; + +struct PropsList_t { + uint32_t PropsCount; + Prop_t * Props; +}; + +struct TimeProp_t { + uint32_t ID; + PropsList_t PropsList; +}; + +struct TimePropsList_t { + uint32_t TimePropsCount; + TimeProp_t * TimeProps; +}; + +struct Motion_t { + uint32_t Unknown; + char * BoneName; + uint32_t FrameCount; + float Duration; + uint8_t HasTranslation; + uint8_t HasRotation; + uint32_t TranslationsOffset; + uint32_t RotationsOffset; + Translation_t * Translations; + Rotation_t * Rotations; + + uint8_t HasPropsLists; + uint32_t PropsListsCount; + PropsList_t * PropsLists; + + uint8_t HasTimePropsLists; + uint32_t TimePropsListsCount; + TimePropsList_t * TimePropsLists; +}; + +struct Animation_t { + uint32_t Version; + char * Name; + float Duration; + float Distance; + uint8_t IsMoving; + uint32_t TranslationsCount; + uint32_t RotationsCount; + uint32_t MotionsCount; + + unsigned TranslationsOffset; + unsigned RotationsOffset; + + Motion_t * Motions; +}; + +void ReadAnimation(Animation_t& Animation); +void ReadMotion(Animation_t& Animation, Motion_t& Motion); +void ReadPropsList(PropsList_t& PropsList); +void ReadPropsLists(Motion_t& Motion); +void ReadTimePropsList(TimePropsList_t& TimePropsList); +void ReadTimePropsLists(Motion_t& Motion); \ No newline at end of file diff --git a/Libraries/libvitaboy/resource.rc b/Libraries/libvitaboy/resource.rc new file mode 100644 index 0000000..7a3c2a2 --- /dev/null +++ b/Libraries/libvitaboy/resource.rc @@ -0,0 +1,27 @@ +#include "config.h" + +1 VERSIONINFO +FILEVERSION VERSION_A,VERSION_B,VERSION_C,REVISION +PRODUCTVERSION VERSION_A,VERSION_B,VERSION_C,REVISION +FILEOS 0x00040000L /* VOS_NT - 32-bit Windows */ +FILETYPE 2 /* DLL */ +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "Niotso project" + VALUE "FileDescription", "Free, open source C++ OpenGL TSO character rendering and animation library" + VALUE "FileVersion", VERSION_STR + VALUE "InternalName", PACKAGE + VALUE "LegalCopyright", "Copyright © 2012" + VALUE "OriginalFilename", PACKAGE".dll" + VALUE "ProductName", PACKAGE + VALUE "ProductVersion", VERSION_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END diff --git a/Libraries/libvitaboy/vbparse.cpp b/Libraries/libvitaboy/vbparse.cpp new file mode 100644 index 0000000..cb42645 --- /dev/null +++ b/Libraries/libvitaboy/vbparse.cpp @@ -0,0 +1,125 @@ +/* + vbparse.cpp - Copyright (c) 2012 Fatbag + + 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 +#include "libvitaboy.hpp" + +enum VBFileType { + VBFILE_ANIM, + VBFILE_APR, + VBFILE_BND, + VBFILE_COL, + VBFILE_HAG, + VBFILE_MESH, + VBFILE_OFT, + VBFILE_PO, + VBFILE_SKEL +}; + +int main(int argc, char *argv[]){ + int type; + char * InFile; + + if(argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){ + printf("Usage: vbparse [-t type] infile\n" + "Parse a TSO VitaBoy file.\n" + "\n" + "Supported types:\n" + " (*) ANIM - Animation\n" + " (*) APR - Appearance\n" + " (*) BND - Binding\n" + " (*) COL - Collection\n" + " (*) HAG - Hand group\n" + " (*) MESH - Mesh\n" + " (*) OFT - Outfit\n" + " (*) PO - Purchasable object\n" + " (*) SKEL - Skeleton\n" + "\n" + "Report bugs to .\n" + "vbparse is maintained by the Niotso project.\n" + "Home page: "); + return 0; + } + + if(argc >= 4 && !strcmp(argv[1], "-t")){ + if(!stricmp(argv[2], "anim")) type = 0; + else if(!stricmp(argv[2], "apr")) type = 1; + else if(!stricmp(argv[2], "bnd")) type = 2; + else if(!stricmp(argv[2], "col")) type = 3; + else if(!stricmp(argv[2], "hag")) type = 4; + else if(!stricmp(argv[2], "mesh")) type = 5; + else if(!stricmp(argv[2], "oft")) type = 6; + else if(!stricmp(argv[2], "po")) type = 7; + else if(!stricmp(argv[2], "skel")) type = 8; + else{ + printf("%sUnrecognized type '%s'", "vbparse: Error: ", argv[2]); + return -1; + } + InFile = argv[3]; + }else{ + char * pos = strrchr(argv[1], '.') + 1; + if(!stricmp(pos, "anim")) type = 0; + else if(!stricmp(pos, "apr")) type = 1; + else if(!stricmp(pos, "bnd")) type = 2; + else if(!stricmp(pos, "col")) type = 3; + else if(!stricmp(pos, "hag")) type = 4; + else if(!stricmp(pos, "mesh")) type = 5; + else if(!stricmp(pos, "oft")) type = 6; + else if(!stricmp(pos, "po")) type = 7; + else if(!stricmp(pos, "skel")) type = 8; + else{ + printf("%sUnrecognized type", "vbparse: Error: "); + return -1; + } + InFile = argv[1]; + } + + HANDLE ProcessHeap = GetProcessHeap(); + HANDLE hFile; + unsigned FileSize; + uint8_t *InData; + DWORD bytestransferred; + + 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.", "vbparse: Error: "); + return -1; + } + printf("%sThe input file could not be opened for reading.", "vbparse: Error: "); + return -1; + } + FileSize = GetFileSize(hFile, NULL); + InData = (uint8_t*) HeapAlloc(ProcessHeap, HEAP_NO_SERIALIZE, FileSize); + if(InData == NULL){ + printf("%sMemory for this file could not be allocated.", "vbparse: Error: "); + return -1; + } + if(!ReadFile(hFile, InData, FileSize, &bytestransferred, NULL) || bytestransferred != FileSize){ + printf("%sThe input file could not be read.", "vbparse: Error: "); + return -1; + } + CloseHandle(hFile); + + VBFile.set(InData, FileSize); + + if(type == VBFILE_ANIM){ + Animation_t Animation; + ReadAnimation(Animation); + } + + return 0; +} \ No newline at end of file diff --git a/Server/Makefile b/Server/Makefile deleted file mode 100644 index e69de29..0000000 diff --git a/Tools/FARDive/Makefile b/Tools/FARDive/Makefile deleted file mode 100644 index cd2c3ee..0000000 --- a/Tools/FARDive/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# macros -------------------------------------------------------------------- -CC = gcc -LD = gcc -CFLAGS = -m32 -Os -march=i686 -fomit-frame-pointer -ffast-math -funsafe-loop-optimizations -fmerge-all-constants -g0 -fno-exceptions -LDFLAGS = -m32 -s -fwhole-program - -WINDRES = windres -F pe-i386 - -LIBS = -mwindows -lole32 -luxtheme -L. -lpng15 - -OBJS = obj/windows/common.o \ - obj/windows/Startup.o \ - obj/windows/Interaction.o \ - obj/windows/MainWindow.o \ - obj/windows/ReadPNGIcon.o \ - obj/windows/Dialog/AddToArchive.o \ - obj/windows/Dialog/NewArchive.o \ - obj/windows/resource.o - -# These will rebuild the entire program upon edit. -DEPS = Makefile \ - FARDive.hpp \ - version.hpp \ - windows/GUI.hpp \ - windows/resource.hpp \ - windows/Windows.hpp - -# dependencies -------------------------------------------------------------- -all: ./FARDive.exe -./FARDive.exe: $(OBJS) - $(LD) $(LDFLAGS) -L. -o $@ $(OBJS) $(LIBS) - -$(OBJS): $(DEPS) - -# make rules ---------------------------------------------------------------- -./obj/%.o: %.cpp - $(CC) -c $(CFLAGS) -o $@ $< - -./obj/%.o: %.rc - $(WINDRES) -i $< -o $@ - -# maintenance --------------------------------------------------------------- -clean: - del /Q /S FARDive.exe obj \ No newline at end of file