Start fixing MSVC builds.

Conflicts:
	rdp/n64video.c
This commit is contained in:
Tyler J. Stachecki 2016-06-26 14:25:42 -04:00
parent 8415caf9ad
commit 3288229a50
9 changed files with 43 additions and 17 deletions

View file

@ -360,7 +360,11 @@ set(VR4300_SOURCES
if (DEFINED WIN32)
include_directories(${PROJECT_SOURCE_DIR}/os/winapi)
set(EXTRA_OS_EXE WIN32)
set(EXTRA_OS_LIBS mingw32 opengl32 winmm ws2_32)
if (NOT MSVC)
set(EXTRA_OS_LIBS mingw32 opengl32 winmm ws2_32)
else ()
set(EXTRA_OS_LIBS opengl32 winmm ws2_32)
endif ()
list(APPEND OS_SOURCES
${OS_COMMON_SOURCES}
@ -406,6 +410,7 @@ endif (NOT MSVC)
add_executable(cen64
${EXTRA_OS_EXE}
${ASM_SOURCES}
${AI_SOURCES}
${ARCH_X86_64_SOURCES}
${BUS_SOURCES}

View file

@ -390,7 +390,7 @@ int write_dd_ipl_rom(void *opaque, uint32_t address, uint32_t word, uint32_t dqm
}
// Reads a word from the DD C2S/DS buffer.
int read_dd_controller(void *opaque __attribute__ ((unused)), uint32_t address, uint32_t *word) {
int read_dd_controller(void *unused(opaque), uint32_t address, uint32_t *word) {
// XXX: Hack to reduce memorymap entries.
if (address >= DD_MS_RAM_ADDRESS)
return read_dd_ms_ram(opaque, address, word);
@ -404,7 +404,7 @@ int read_dd_controller(void *opaque __attribute__ ((unused)), uint32_t address,
}
// Writes a word to the DD C2S/DS BUFFER.
int write_dd_controller(void *opaque __attribute__ ((unused)), uint32_t address, uint32_t word, uint32_t dqm) {
int write_dd_controller(void *unused(opaque), uint32_t address, uint32_t word, uint32_t dqm) {
// XXX: Hack to reduce memorymap entries.
if (address >= DD_MS_RAM_ADDRESS)
return write_dd_ms_ram(opaque, address, word, dqm);
@ -418,13 +418,13 @@ int write_dd_controller(void *opaque __attribute__ ((unused)), uint32_t address,
}
// Reads a word from the DD MS RAM.
int read_dd_ms_ram(void *opaque __attribute__ ((unused)), uint32_t address, uint32_t *word) {
int read_dd_ms_ram(void *unused(opaque), uint32_t address, uint32_t *word) {
debug_mmio_read(dd, "DD_MS_RAM", *word);
return 0;
}
// Writes a word to the DD MS RAM.
int write_dd_ms_ram(void *opaque __attribute__ ((unused)), uint32_t address, uint32_t word, uint32_t dqm) {
int write_dd_ms_ram(void *unused(opaque), uint32_t address, uint32_t word, uint32_t dqm) {
debug_mmio_write(dd, "DD_MS_RAM", word, dqm);
return 0;
}

View file

@ -10,7 +10,7 @@
#include "common.h"
#ifdef __WIN32__
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>

View file

@ -35,10 +35,14 @@
* implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
*/
#ifdef _WIN32
#include <windows.h>
#else
#include <string.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/time.h>
#endif
#include "sha1.h"

View file

@ -68,7 +68,7 @@ static int pi_dma_read(struct pi_controller *pi) {
// SRAM
if (pi->sram->ptr != NULL && addr + length <= 0x8000)
memcpy(pi->sram->ptr + addr, pi->bus->ri->ram + source, length);
memcpy((uint8_t *) (pi->sram->ptr) + addr, pi->bus->ri->ram + source, length);
// FlashRAM: Save the RDRAM destination address. Writing happens
// after the system sends the flash write command (handled in
@ -109,7 +109,7 @@ static int pi_dma_write(struct pi_controller *pi) {
uint32_t addr = source & 0x00FFFFF;
if (pi->sram->ptr != NULL && addr + length <= 0x8000)
memcpy(pi->bus->ri->ram + dest, pi->sram->ptr + addr, length);
memcpy(pi->bus->ri->ram + dest, (const uint8_t *) (pi->sram->ptr) + addr, length);
else if (pi->flashram.data != NULL) {
// SRAM

View file

@ -220,7 +220,7 @@ typedef struct
int32_t invalyscan[4];
} SPAN;
static SPAN span[1024];
cen64_align(static SPAN span[1024], 16);
uint8_t cvgbuf[1024];
@ -6983,7 +6983,6 @@ static void rdp_tex_rect(uint32_t w1, uint32_t w2)
edgewalker_for_prims(ewdata);
}
static void rdp_tex_rect_flip(uint32_t w1, uint32_t w2)

View file

@ -57,8 +57,13 @@ uint32_t rsp_read_cp0_reg(struct rsp *rsp, unsigned src) {
return *((volatile uint32_t *) &rsp->regs[RSP_CP0_REGISTER_SP_STATUS]);
case RSP_CP0_REGISTER_SP_RESERVED:
#ifdef _WIN32
return _InterlockedCompareExchange((volatile long *)
(&rsp->regs[RSP_CP0_REGISTER_SP_RESERVED]), 1, 0) == 0;
#else
return !__sync_bool_compare_and_swap(
&rsp->regs[RSP_CP0_REGISTER_SP_RESERVED], 0, 1);
#endif
case RSP_CP0_REGISTER_DMA_FULL:
case RSP_CP0_REGISTER_DMA_BUSY:
@ -158,9 +163,15 @@ void rsp_status_write(struct rsp *rsp, uint32_t rt) {
status &= ~SP_STATUS_SIG7;
else if (rt & SP_SET_SIG7)
status |= SP_STATUS_SIG7;
#ifdef _WIN32
} while (!(_InterlockedCompareExchange((volatile long *)
(&rsp->regs[RSP_CP0_REGISTER_SP_STATUS]),
status, prev_status) == prev_status));
#else
} while (!__sync_bool_compare_and_swap(
&rsp->regs[RSP_CP0_REGISTER_SP_STATUS],
prev_status, status));
#endif
}
// Writes a value to the control processor.
@ -193,7 +204,11 @@ void rsp_write_cp0_reg(struct rsp *rsp, unsigned dest, uint32_t rt) {
case RSP_CP0_REGISTER_SP_RESERVED:
if (rt == 0) {
*((volatile uint32_t *) &rsp->regs[RSP_CP0_REGISTER_SP_RESERVED]) = 0;
#ifdef _MSC_VER
_ReadWriteBarrier();
#else
__asm__ __volatile__("" ::: "memory");
#endif
}
break;

View file

@ -8,6 +8,9 @@
// 'LICENSE', which is part of this source code package.
//
#ifdef _WIN32
#include <wchar.h>
#endif
#include "pak.h"
#include "pak_transfer.h"
@ -18,12 +21,12 @@ int controller_pak_read(struct controller *controller,
uint8_t *recv_buf, uint8_t recv_bytes) {
uint16_t address = send_buf[1] << 8 | send_buf[2];
address &= ~0b11111; // lower 5 bits are address CRC
address &= ~0x1F; // lower 5 bits are address CRC
// printf("read from %04x\n", address);
if (controller->pak == PAK_MEM) {
if (address <= MEMPAK_SIZE - 0x20)
memcpy(recv_buf, controller->mempak_save.ptr + address, 0x20);
memcpy(recv_buf, (uint8_t *) (controller->mempak_save.ptr) + address, 0x20);
else
assert(0 && "invalid mempak address");
}
@ -48,7 +51,7 @@ int controller_pak_write(struct controller *controller,
uint8_t *recv_buf, uint8_t recv_bytes) {
uint16_t address = send_buf[1] << 8 | send_buf[2];
address &= ~0b11111; // lower 5 bits are a checksum
address &= ~0x1F; // lower 5 bits are a checksum
// printf("write to %04x\n", address);
if (address == 0x8000) {
@ -61,7 +64,7 @@ int controller_pak_write(struct controller *controller,
else if (controller->pak == PAK_MEM) {
if (address <= MEMPAK_SIZE - 0x20)
memcpy(controller->mempak_save.ptr + address, send_buf + 3, 0x20);
memcpy((uint8_t *) (controller->mempak_save.ptr) + address, send_buf + 3, 0x20);
else
assert(0 && "Attempt to write past end of mempak");
}

View file

@ -21,7 +21,7 @@ void transfer_pak_read(struct controller *controller,
uint8_t *recv_buf, uint8_t recv_bytes) {
uint16_t address = send_buf[1] << 8 | send_buf[2];
address &= ~0b11111; // lower 5 bits are address CRC
address &= ~0x1F; // lower 5 bits are address CRC
// printf("read from %04x\n", address);
// get enable/disable state
@ -34,7 +34,7 @@ void transfer_pak_read(struct controller *controller,
// cart inserted, return mode and mode changed
if (controller->tpak_rom.ptr != NULL) {
memset(recv_buf, controller->tpak_mode == 1 ? 0x89 : 0x80, 0x20);
recv_buf[0] |= controller->tpak_mode_changed ? 0b100 : 0;
recv_buf[0] |= controller->tpak_mode_changed ? 0x4 : 0;
}
// cart not inserted
@ -60,7 +60,7 @@ void transfer_pak_write(struct controller *controller,
uint8_t *recv_buf, uint8_t recv_bytes) {
uint16_t address = send_buf[1] << 8 | send_buf[2];
address &= ~0b11111; // lower 5 bits are address CRC
address &= ~0x1F; // lower 5 bits are address CRC
// printf("write to %04x\n", address);
// set bank