Fix compilation errors for MSVC

This commit is contained in:
InvisibleUp 2023-04-01 15:37:43 -07:00
parent 4a075815b3
commit 98a152bf7b
4 changed files with 56 additions and 7 deletions

View File

@ -78,7 +78,13 @@ unsigned int m68k_read_memory_16(unsigned int address)
}
// Return raw data
uint16_t result = __builtin_bswap16(*(uint16_t *)(r->usebase + address));
uint16_t result;
#ifdef _MSC_VER
result = _byteswap_ushort(*(uint16_t *)(r->usebase + address));
#else
// gcc-likes
result = __builtin_bswap16(*(uint16_t *)(r->usebase + address));
#endif
//fprintf(stderr, "read16 %X -> %X\n", address, result);
return result;
}
@ -104,7 +110,12 @@ unsigned int m68k_read_memory_32(unsigned int address)
}
// Return raw data
uint32_t result = __builtin_bswap32(*(uint32_t *)(r->usebase + address));
uint32_t result;
#ifdef _MSC_VER
result = _byteswap_ulong(*(uint32_t *)(r->usebase + address));
#else
result = __builtin_bswap32(*(uint32_t *)(r->usebase + address));
#endif
//fprintf(stderr, "read32 %X -> %X\n", address, result);
return result;
}
@ -168,7 +179,11 @@ void m68k_write_memory_8(unsigned int address, unsigned int value)
void m68k_write_memory_16(unsigned int address, unsigned int value)
{
ATTer *r = get_address_realblock1(true, address);
#ifdef _MSC_VER
value = _byteswap_ushort(value);
#else
value = __builtin_bswap16(value);
#endif
// check for bus error
//assert (r != NULL);
@ -192,7 +207,11 @@ void m68k_write_memory_16(unsigned int address, unsigned int value)
void m68k_write_memory_32(unsigned int address, unsigned int value)
{
ATTer *r = get_address_realblock1(true, address);
#ifdef _MSC_VER
value = _byteswap_ulong(value);
#else
value = __builtin_bswap32(value);
#endif
// check for bus error
//assert(r != NULL);

View File

@ -57,10 +57,16 @@ configure_file(
)
# Dependencies
lSDL2 = dependency('SDL2')
lSDL2 = dependency('SDL2', static: true)
# Windows resources
# todo: gate this off if not on Windows
windows = import('windows')
WIN_RSRC = windows.compile_resources(
'rsrc/WIN32/main.rc',
)
# Hardware libraries
# Some are temporarily disabled while I get CMake up and running
HW_SRC = {
'ADB': [
@ -174,8 +180,9 @@ EMU_INC = include_directories([
# Just gonna do an SDL2 Mac Plus for now
executable(
'microvmac',
sources: MAC_SRC['Plus'] + UI_SRC + EMU_SRC,
sources: MAC_SRC['Plus'] + UI_SRC + EMU_SRC + WIN_RSRC,
dependencies: [lSDL2],
include_directories: EMU_INC,
gui_app: true
)

View File

@ -6,8 +6,8 @@ ICO_DSK ICON DISCARDABLE "ICONDSKW.ico"
ICO_ROM ICON DISCARDABLE "ICONROMW.ico"
// Binary data
SONY_DRV RCDATA "SONYDRV.bin"
SONY_ICO RCDATA "SONYICO.bin"
SONY_DRV RCDATA "../SONYDRV.bin"
SONY_ICO RCDATA "../SONYICO.bin"
// Version information
VS_VERSION_INFO VERSIONINFO

View File

@ -6,6 +6,9 @@
#include <stdint.h>
#include <string.h>
#include "incbin/incbin.h"
#ifdef _MSC_VER
#include <Windows.h>
#endif
#include "EMCONFIG.h"
#include "GLOBGLUE.h"
@ -19,20 +22,40 @@
#include "HW/SCREEN/SCRNEMDV.h"
// Include binaries
#ifndef _MSC_VER
INCBIN(SonyDriver, "rsrc/SONYDRV.bin");
INCBIN(SonyIcon, "rsrc/SONYICO.bin");
#endif
void Sony_LoadDriver(uint8_t *pto, int *size)
{
#ifdef _MSC_VER
HRSRC hDrvInfo = FindResource(NULL, "SONY_DRV", RT_RCDATA);
HGLOBAL hDrv = LoadResource(NULL, hDrvInfo);
DWORD sDrv = SizeofResource(NULL, hDrvInfo);
void *pDrv = LockResource(hDrv);
memcpy(pto, pDrv, sDrv);
*size = sDrv;
#else
memcpy(pto, gSonyDriverData, gSonyDriverSize);
*size = gSonyDriverSize;
#endif
}
void Sony_LoadIcon(uint8_t *pto, int *icoSize)
{
disk_icon_addr = (pto - ROM) + kROM_Base;
#ifdef _MSC_VER
HRSRC hIcoInfo = FindResource(NULL, "SONY_ICO", RT_RCDATA);
HGLOBAL hIco = LoadResource(NULL, hIcoInfo);
DWORD sIco = SizeofResource(NULL, hIcoInfo);
void *pIco = LockResource(hIco);
memcpy(pto, pIco, sIco);
pto += sizeof(sIco);
#else
memcpy(pto, gSonyIconData, gSonyIconSize);
*icoSize = gSonyIconSize;
#endif
}
void Sony_TwiggyPatch(uint8_t *pto)