Fixed MSVC compilation

This commit is contained in:
KiritoDv
2023-08-25 19:35:10 -06:00
parent cfc0dce639
commit fbaf50aadd
16 changed files with 1383 additions and 45 deletions
+4
View File
@@ -92,6 +92,10 @@
#define eu_stubbed_printf_3(msg, a, b, c)
#endif
#ifdef _WIN32
typedef size_t ssize_t;
#endif
struct NotePool;
struct AudioListItem {
+1 -1
View File
@@ -605,7 +605,7 @@ void setup_game_memory(void) {
UNUSED u8 filler[8];
// Setup general Segment 0
set_segment_base_addr(0, (void *) 0x80000000);
set_segment_base_addr(0, (void *) (uintptr_t) 0x80000000);
// Create Mesg Queues
osCreateMesgQueue(&gGfxVblankQueue, gGfxMesgBuf, ARRAY_COUNT(gGfxMesgBuf));
osCreateMesgQueue(&gGameVblankQueue, gGameMesgBuf, ARRAY_COUNT(gGameMesgBuf));
+1 -1
View File
@@ -50,7 +50,7 @@ extern u16 sRenderingFramebuffer;
extern u32 gGlobalTimer;
void setup_game_memory(void);
void thread5_game_loop(UNUSED void *arg);
void thread5_game_loop();
void clear_framebuffer(s32 color);
void clear_viewport(Vp *viewport, s32 color);
void make_viewport_clip_rect(Vp *viewport);
+2 -2
View File
@@ -235,12 +235,12 @@ Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, UNUSED f3
gDPSetRenderMode(cakeHead++, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2);
gSPTexture(cakeHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
void* data = ResourceGetDataByName(gCakeImage);
uintptr_t data = (uintptr_t) ResourceGetDataByName(gCakeImage);
s32 size = 80 * 20 * 2;
for (int i = 0; i < 4 * 12; i++) {
if (!gCakeSlices[i]) {
gCakeSlices[i] = malloc(size);
memcpy(gCakeSlices[i], data + i * 3200, size);
memcpy(gCakeSlices[i], (const void *) (data + i * 3200), size);
}
gDPLoadTextureBlock(cakeHead++, gCakeSlices[i], G_IM_FMT_RGBA, G_IM_SIZ_16b, 80, 20, 0, G_TX_CLAMP, G_TX_CLAMP, 7, 6, G_TX_NOLOD, G_TX_NOLOD);
gSPVertex(cakeHead++, cake_end_vertex_positions[i], 4, 0);
-5
View File
@@ -1804,13 +1804,8 @@ void render_dialog_entries(void) {
// Horizontal scissoring isn't really required and can potentially mess up widescreen enhancements.
0,
ensure_nonnegative(DIAG_VAL2 - dialog->width),
#ifdef VERSION_EU
SCREEN_WIDTH,
ensure_nonnegative((240 - dialog->width) + (dialog->linesPerBox * 80 / DIAG_VAL4 / gDialogBoxScale))
#else
SCREEN_WIDTH,
ensure_nonnegative((240 - dialog->width) + (dialog->linesPerBox * 80 / DIAG_VAL4))
#endif
);
#ifdef VERSION_JP
+5 -1
View File
@@ -2,8 +2,12 @@
#define MEMORY_H
#include <libultra/types.h>
#include <strings.h>
#include "types.h"
#ifdef _WIN32
#include <string.h>
#else
#include <strings.h>
#endif
#define MEMORY_POOL_LEFT 0
#define MEMORY_POOL_RIGHT 1
-6
View File
@@ -437,12 +437,6 @@ ALIGNED8 static Texture gd_texture_sparkle_3[] = "__OTR__textures/intro_raw/spar
ALIGNED8 static Texture gd_texture_sparkle_4[] = "__OTR__textures/intro_raw/sparkle_4";
//! No reference to this texture. Two DL's uses the same previous texture
// instead of using this texture.
UNUSED ALIGNED8 static Texture gd_texture_sparkle_5[] = {
#include "textures/intro_raw/sparkle_5.rgba16.inc.c"
};
static Vtx_t gd_vertex_sparkle[] = {
{{ -32, 0, 0}, 0, { 0, 1984}, { 0x00, 0x00, 0x7F, 0x00}},
{{ 32, 0, 0}, 0, { 1984, 1984}, { 0x00, 0x00, 0x7F, 0x00}},
+2 -1
View File
@@ -44,6 +44,7 @@ int main(){
audio_init();
sound_init();
thread5_game_loop(nullptr);
thread5_game_loop();
GameEngine::Instance->ProcessFrame(push_frame);
return 0;
}
+1 -22
View File
@@ -14,19 +14,6 @@ else()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
set(n64graphics_SOURCES n64graphics.c utils.c)
add_executable(n64graphics ${n64graphics_SOURCES})
target_compile_definitions(n64graphics PUBLIC N64GRAPHICS_STANDALONE)
if(UNIX)
target_link_libraries(n64graphics PUBLIC m)
endif()
set(n64graphics_ci_SOURCES n64graphics_ci_dir/n64graphics_ci.c n64graphics_ci_dir/exoquant/exoquant.c n64graphics_ci_dir/utils.c)
add_executable(n64graphics_ci ${n64graphics_ci_SOURCES})
if(UNIX)
target_link_libraries(n64graphics_ci PUBLIC m)
endif()
set(mio0_SOURCES libmio0.c)
add_executable(mio0 ${mio0_SOURCES})
target_compile_definitions(mio0 PUBLIC MIO0_STANDALONE)
@@ -55,7 +42,7 @@ add_library(audiofile STATIC ${AUDIOFILE_FILES})
set_target_properties(audiofile PROPERTIES CXX_STANDARD 11)
#tabledesign: $(LIBAUDIOFILE)
set(tabledesign_SOURCES sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c)
set(tabledesign_SOURCES sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/getopt.c sdk-tools/tabledesign/tabledesign.c)
#tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
#tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/audiofile)
@@ -77,17 +64,9 @@ target_include_directories(vadpcm_enc PRIVATE ${GETOPT_INCLUDE_DIR})
set(extract_data_for_mio_SOURCES extract_data_for_mio.c)
add_executable(extract_data_for_mio ${extract_data_for_mio_SOURCES})
set(skyconv_SOURCES skyconv.c n64graphics.c utils.c)
add_executable(skyconv ${skyconv_SOURCES})
if(UNIX)
target_link_libraries(skyconv PUBLIC m)
endif()
# tools required for extract_assets.py
add_custom_target(Tools
DEPENDS
aifc_decode
mio0
n64graphics
skyconv
)
+12
View File
@@ -2,7 +2,9 @@
* Bruteforcing decoder for converting ADPCM-encoded AIFC into AIFF, in a way
* that roundtrips with vadpcm_enc.
*/
#ifndef WIN32
#include <unistd.h>
#endif
#include <assert.h>
#include <math.h>
#include <string.h>
@@ -19,14 +21,24 @@ typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
#ifdef _MSC_VER
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
#endif
#define bswap16(x) __builtin_bswap16(x)
#define bswap32(x) __builtin_bswap32(x)
#define BSWAP16(x) x = __builtin_bswap16(x)
#define BSWAP32(x) x = __builtin_bswap32(x)
#define BSWAP16_MANY(x, n) for (s32 _i = 0; _i < n; _i++) BSWAP16((x)[_i])
#ifndef WIN32
#define NORETURN __attribute__((noreturn))
#define UNUSED __attribute__((unused))
#else
#define NORETURN
#define UNUSED
#endif
typedef struct {
u32 ckID;
+10 -3
View File
@@ -14,11 +14,18 @@ typedef int s32;
typedef unsigned char u8;
typedef unsigned int u32;
#define BSWAP16(x) x = __builtin_bswap16(x)
#define BSWAP32(x) x = __builtin_bswap32(x)
#ifdef _MSC_VER
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
#define NORETURN
#define UNUSED
#else
#define NORETURN __attribute__((noreturn))
#define UNUSED __attribute__((unused))
#endif
#define BSWAP16(x) x = __builtin_bswap16(x)
#define BSWAP32(x) x = __builtin_bswap32(x)
typedef struct
{
+20 -2
View File
@@ -2217,6 +2217,16 @@ private:
#include <sys/types.h>
#ifdef _WIN32
#include <stdint.h>
typedef size_t ssize_t;
#endif
#ifdef _MSC_VER
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
#endif
typedef struct _AFvirtualfile AFvirtualfile;
class File : public Shared<File>
@@ -2241,8 +2251,8 @@ public:
virtual ~File();
virtual int close() = 0;
virtual ssize_t read(void *data, size_t nbytes) = 0;
virtual ssize_t write(const void *data, size_t nbytes) = 0;
virtual long long int read(void *data, size_t nbytes) = 0;
virtual long long int write(const void *data, size_t nbytes) = 0;
virtual off_t length() = 0;
virtual off_t seek(off_t offset, SeekOrigin origin) = 0;
virtual off_t tell() = 0;
@@ -8199,7 +8209,11 @@ Buffer::~Buffer()
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef _WIN32
#include "unistd.h"
#else
#include <unistd.h>
#endif
#include <stdio.h>
class FilePOSIX : public File
@@ -14324,7 +14338,11 @@ int _af_ulaw2linear (unsigned char u_val)
#include <assert.h>
#include <string.h>
#ifdef _WIN32
#include "unistd.h"
#else
#include <unistd.h>
#endif
#include <audiofile.h>
+57
View File
@@ -0,0 +1,57 @@
#ifdef _WIN32
#ifndef _UNISTD_H
#define _UNISTD_H 1
/* This is intended as a drop-in replacement for unistd.h on Windows.
* Please add functionality as needed.
* https://stackoverflow.com/a/826027/1202830
*/
#include <stdlib.h>
#include <io.h>
//#include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */
#include <process.h> /* for getpid() and the exec..() family */
#include <direct.h> /* for _getcwd() and _chdir() */
#define srandom srand
#define random rand
/* Values for the second argument to access.
These may be OR'd together. */
#define R_OK 4 /* Test for read permission. */
#define W_OK 2 /* Test for write permission. */
//#define X_OK 1 /* execute permission - unsupported in windows*/
#define F_OK 0 /* Test for existence. */
#define access _access
#define dup2 _dup2
#define execve _execve
#define ftruncate _chsize
#define unlink _unlink
#define fileno _fileno
#define getcwd _getcwd
#define chdir _chdir
#define isatty _isatty
#define lseek _lseek
/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */
#ifdef _WIN64
#define ssize_t __int64
#else
#define ssize_t long
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/* should be in some equivalent to <sys/types.h> */
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif /* unistd.h */
#endif
+3 -1
View File
@@ -522,7 +522,8 @@ def write_aiff(entry, filename):
write_aifc(entry, temp)
temp.flush()
temp.close()
aifc_decode = os.path.join(os.path.dirname(__file__), "aifc_decode")
aifc_decode = os.path.join("./cmake-msvc-dbg/tools/Debug", "aifc_decode.exe")
print(aifc_decode)
subprocess.run([aifc_decode, temp.name, filename], check=True)
finally:
temp.close()
@@ -683,6 +684,7 @@ def main():
if dir not in created_dirs:
os.makedirs(dir, exist_ok=True)
created_dirs.add(dir)
os.makedirs(dir, exist_ok=True)
write_aiff(entry, filename)
return
+5
View File
@@ -14,6 +14,11 @@ typedef unsigned long long u64;
typedef float f32;
typedef double f64;
#ifdef _MSC_VER
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
#endif
#ifdef __sgi
# define BSWAP16(x)
# define BSWAP32(x)
File diff suppressed because it is too large Load Diff