Browse Source

Added (blank) binary file reading utils

Thomas Buck 9 years ago
parent
commit
d8d2fce36b
8 changed files with 101 additions and 20 deletions
  1. 0
    3
      CMakeLists.txt
  2. 8
    8
      README.md
  3. 1
    6
      TODO.md
  4. 30
    0
      include/utils/binary.h
  5. 1
    1
      src/Menu.cpp
  6. 2
    2
      src/TombRaider.cpp
  7. 1
    0
      src/utils/CMakeLists.txt
  8. 58
    0
      src/utils/binary.cpp

+ 0
- 3
CMakeLists.txt View File

36
     set (WARNINGS "${WARNINGS} -Wno-padded -Wno-packed")
36
     set (WARNINGS "${WARNINGS} -Wno-padded -Wno-packed")
37
     set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
37
     set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
38
     set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
38
     set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
39
-
40
-    set (WARNINGS "${WARNINGS} -Wno-sign-conversion")
41
-
42
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
39
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
43
     set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")
40
     set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")
44
     set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")
41
     set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")

+ 8
- 8
README.md View File

1
 # OpenRaider
1
 # OpenRaider
2
 
2
 
3
+[![Build Status](https://travis-ci.org/xythobuz/OpenRaider.svg?branch=master)](https://travis-ci.org/xythobuz/OpenRaider)
4
+
3
 This is a fork of the [OpenRaider](http://openraider.sourceforge.net) Open Source implementation of the classic Tomb Raider Game Engine. The original project was abandoned in 2003.
5
 This is a fork of the [OpenRaider](http://openraider.sourceforge.net) Open Source implementation of the classic Tomb Raider Game Engine. The original project was abandoned in 2003.
4
 
6
 
5
 This fork aims to get OpenRaider in a more usable state, maybe one day even being able to play the old Tomb Raider games flawlessly...
7
 This fork aims to get OpenRaider in a more usable state, maybe one day even being able to play the old Tomb Raider games flawlessly...
8
 
10
 
9
 It seems as if OpenRaider will currently only work on Little-Endian platforms. This is not nice and will hopefully be fixed in the future!
11
 It seems as if OpenRaider will currently only work on Little-Endian platforms. This is not nice and will hopefully be fixed in the future!
10
 
12
 
11
-[![Build Status](https://travis-ci.org/xythobuz/OpenRaider.svg?branch=master)](https://travis-ci.org/xythobuz/OpenRaider)
12
-
13
 [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=xythobuz&url=https://github.com/xythobuz/OpenRaider&title=OpenRaider&language=&tags=github&category=software)
13
 [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=xythobuz&url=https://github.com/xythobuz/OpenRaider&title=OpenRaider&language=&tags=github&category=software)
14
 
14
 
15
 ## Configuration
15
 ## Configuration
30
 
30
 
31
 Basically, OpenRaider depends on the following:
31
 Basically, OpenRaider depends on the following:
32
 
32
 
33
+* C++11 compiler
34
+* cmake
33
 * OpenGL
35
 * OpenGL
36
+* zlib
34
 * SDL2
37
 * SDL2
35
 * SDL2-TTF (optional, needed if you want to use TTF fonts)
38
 * SDL2-TTF (optional, needed if you want to use TTF fonts)
36
-* OpenAL & ALUT
37
-* zlib
38
-* cmake as build system
39
+* OpenAL & ALUT (optional, needed for sound output)
39
 * libpng (optional)
40
 * libpng (optional)
40
-* C++11 compiler
41
 
41
 
42
 On Mac OS X 10.9 with [XCode](https://developer.apple.com/xcode/) and [MacPorts](http://www.macports.org) installed, the following should be enough to get all dependencies that are available as port:
42
 On Mac OS X 10.9 with [XCode](https://developer.apple.com/xcode/) and [MacPorts](http://www.macports.org) installed, the following should be enough to get all dependencies that are available as port:
43
 
43
 
57
 
57
 
58
 Linux Distributions will probably provide an ALUT library ready to install with their package manager, so you won't need to compile freealut.
58
 Linux Distributions will probably provide an ALUT library ready to install with their package manager, so you won't need to compile freealut.
59
 
59
 
60
-Sound support is optional now, however. If cmake can’t find OpenAL and ALUT, Audio will be deactivated. If you want to explicitly deactivate it, call cmake with `-DENABLE_AUDIO=NO`.
60
+Sound support is optional, however. If cmake can’t find OpenAL and ALUT, Audio will be deactivated. If you want to explicitly deactivate it, call cmake with `-DENABLE_AUDIO=NO`.
61
 
61
 
62
 ## Building
62
 ## Building
63
 
63
 
142
 
142
 
143
 ## License
143
 ## License
144
 
144
 
145
-OpenRaider is based on code, specs, and alogrithms from:
145
+OpenRaider is based on code, specs, and algorithms from:
146
 
146
 
147
 * GooseEgg/Freyja 3d Modelers by Mongoose
147
 * GooseEgg/Freyja 3d Modelers by Mongoose
148
 * TR Rosetta Stone spec sheet by Anonymous
148
 * TR Rosetta Stone spec sheet by Anonymous

+ 1
- 6
TODO.md View File

2
 
2
 
3
 ## General
3
 ## General
4
 
4
 
5
+* Move to newer OpenGL (GLES or 3.x or 4.x?)
5
 * Endian dependence ugly, shouldn't dereference to different types?
6
 * Endian dependence ugly, shouldn't dereference to different types?
6
     * TombRaider.h/cpp structs aren't aligned... unportable to some big endian & other archs?!
7
     * TombRaider.h/cpp structs aren't aligned... unportable to some big endian & other archs?!
7
     * Maybe replace loader with [VT](http://icculus.org/vt/), also used by OpenTomb.
8
     * Maybe replace loader with [VT](http://icculus.org/vt/), also used by OpenTomb.
8
-* Use more asserts
9
 * Don't use C-Style code, try to replace with C++ lib
9
 * Don't use C-Style code, try to replace with C++ lib
10
     * Use std::strings
10
     * Use std::strings
11
     * Rewrite Console and use operator << to write to the console?
11
     * Rewrite Console and use operator << to write to the console?
12
-* SDL_TTF 2.0.12+ [can do line breaks](http://stackoverflow.com/questions/17847818/how-to-do-line-breaks-and-line-wrapping-with-sdl-ttf/18418688#18418688), use it
13
 * Mesh has 2 different approaches of storing the same data (eg. mColors and mColorArray), but half of ‘em isn’t implemented. Unify this, probably even combining Mesh and StaticMesh...
12
 * Mesh has 2 different approaches of storing the same data (eg. mColors and mColorArray), but half of ‘em isn’t implemented. Unify this, probably even combining Mesh and StaticMesh...
14
 * Don’t use float everywhere just because (eg. float colors)
13
 * Don’t use float everywhere just because (eg. float colors)
15
 
14
 
16
-## Changes
17
-
18
-* Using std::vector with [] is not bound checked. Segfaults were caused because the upper bound of the argument was never checked and garbage was returned... Do consistent checks, or use .at() as it throws an exception
19
-
20
 ## Cmake
15
 ## Cmake
21
 
16
 
22
 * Support SSE with other compilers than Clang (src/CMakeLists.txt)
17
 * Support SSE with other compilers than Clang (src/CMakeLists.txt)

+ 30
- 0
include/utils/binary.h View File

1
+/*!
2
+ * \file include/utils/binary.h
3
+ * \brief Binary file reading utilities
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _UTILS_BINARY_H_
9
+#define _UTILS_BINARY_H_
10
+
11
+void binOpen(const char *file);
12
+void binClose();
13
+
14
+unsigned long binTell();
15
+void binSeek(unsigned long pos);
16
+
17
+int8_t binRead8();
18
+uint8_t binReadU8();
19
+
20
+int16_t binRead16();
21
+uint16_t binReadU16();
22
+
23
+int32_t binRead32();
24
+uint32_t binReadU32();
25
+
26
+int64_t binRead64();
27
+uint64_t binReadU64();
28
+
29
+#endif
30
+

+ 1
- 1
src/Menu.cpp View File

31
     mCursor = 0;
31
     mCursor = 0;
32
     mMin = 0;
32
     mMin = 0;
33
 
33
 
34
-    mainText.text = bufferString(VERSION);
34
+    mainText.text = bufferString("%s", VERSION);
35
     mainText.color[0] = BLUE[0];
35
     mainText.color[0] = BLUE[0];
36
     mainText.color[1] = BLUE[1];
36
     mainText.color[1] = BLUE[1];
37
     mainText.color[2] = BLUE[2];
37
     mainText.color[2] = BLUE[2];

+ 2
- 2
src/TombRaider.cpp View File

3334
                 {
3334
                 {
3335
                     k = triangleIndex - count;
3335
                     k = triangleIndex - count;
3336
 
3336
 
3337
-                    *texture = *flags = 0; // FIXME
3337
+                    *texture = *flags = 0; //! \fixme
3338
 
3338
 
3339
                     // Setup per vertex
3339
                     // Setup per vertex
3340
                     for (j = 0; j < 3; ++j)
3340
                     for (j = 0; j < 3; ++j)
3342
                         // Get vertex index {(0, a), (1, b), (2, c) }
3342
                         // Get vertex index {(0, a), (1, b), (2, c) }
3343
                         indices[j] = mRoomsTR5[roomIndex].faces[i].tris[k].vertices[j];
3343
                         indices[j] = mRoomsTR5[roomIndex].faces[i].tris[k].vertices[j];
3344
 
3344
 
3345
-                        // FIXME
3345
+                        //! \fixme
3346
                         //tIndex = mRoomsTR5[roomIndex].faces[i].vertices[j].texture & 0xff;
3346
                         //tIndex = mRoomsTR5[roomIndex].faces[i].vertices[j].texture & 0xff;
3347
                         //computeUV(objectTexturesTR5[tIndex].vertices + i,
3347
                         //computeUV(objectTexturesTR5[tIndex].vertices + i,
3348
                         //          texCoords+i*2, texCoords+i*2+1);
3348
                         //          texCoords+i*2, texCoords+i*2+1);

+ 1
- 0
src/utils/CMakeLists.txt View File

1
 # Source files
1
 # Source files
2
+set (UTIL_SRCS ${UTIL_SRCS} "binary.cpp")
2
 set (UTIL_SRCS ${UTIL_SRCS} "pcx.cpp")
3
 set (UTIL_SRCS ${UTIL_SRCS} "pcx.cpp")
3
 set (UTIL_SRCS ${UTIL_SRCS} "pixel.cpp")
4
 set (UTIL_SRCS ${UTIL_SRCS} "pixel.cpp")
4
 set (UTIL_SRCS ${UTIL_SRCS} "strings.cpp")
5
 set (UTIL_SRCS ${UTIL_SRCS} "strings.cpp")

+ 58
- 0
src/utils/binary.cpp View File

1
+/*!
2
+ * \file src/utils/binary.cpp
3
+ * \brief Binary file reading utilities
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "utils/binary.h"
10
+
11
+void binOpen(const char *file) {
12
+
13
+}
14
+
15
+void binClose() {
16
+
17
+}
18
+
19
+unsigned long binTell() {
20
+    return 0;
21
+}
22
+
23
+void binSeek(unsigned long pos) {
24
+
25
+}
26
+
27
+int8_t binRead8() {
28
+    return 0;
29
+}
30
+
31
+uint8_t binReadU8() {
32
+    return 0;
33
+}
34
+
35
+int16_t binRead16() {
36
+    return 0;
37
+}
38
+
39
+uint16_t binReadU16() {
40
+    return 0;
41
+}
42
+
43
+int32_t binRead32() {
44
+    return 0;
45
+}
46
+
47
+uint32_t binReadU32() {
48
+    return 0;
49
+}
50
+
51
+int64_t binRead64() {
52
+    return 0;
53
+}
54
+
55
+uint64_t binReadU64() {
56
+    return 0;
57
+}
58
+

Loading…
Cancel
Save