mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
improve 64bit portability
for win64 mostly
This commit is contained in:
parent
a0b95da112
commit
48c9e01be8
14 changed files with 42 additions and 26 deletions
|
@ -11,6 +11,12 @@
|
|||
#ifndef CZ80_H
|
||||
#define CZ80_H
|
||||
|
||||
// uintptr_t
|
||||
#include <stdlib.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -44,7 +50,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef FPTR
|
||||
#define FPTR unsigned long
|
||||
#define FPTR uintptr_t
|
||||
#endif
|
||||
|
||||
/*************************************/
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#define WRITE_MEM8(A, D) { \
|
||||
unsigned short a = A; \
|
||||
unsigned char d = D; \
|
||||
unsigned long v = z80_write_map[a >> Z80_MEM_SHIFT]; \
|
||||
uptr v = z80_write_map[a >> Z80_MEM_SHIFT]; \
|
||||
if (map_flag_set(v)) \
|
||||
((z80_write_f *)(v << 1))(a, d); \
|
||||
else \
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
#ifndef __FAME_H__
|
||||
#define __FAME_H__
|
||||
|
||||
// uintptr_t
|
||||
#include <stdlib.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -127,7 +133,7 @@ typedef struct
|
|||
signed int cycles_needed;
|
||||
|
||||
unsigned short *PC;
|
||||
unsigned long BasePC;
|
||||
uintptr_t BasePC;
|
||||
unsigned int flag_C;
|
||||
unsigned int flag_V;
|
||||
unsigned int flag_NotZ;
|
||||
|
@ -140,7 +146,7 @@ typedef struct
|
|||
unsigned char not_polling;
|
||||
unsigned char pad[3];
|
||||
|
||||
unsigned long Fetch[M68K_FETCHBANK1];
|
||||
uintptr_t Fetch[M68K_FETCHBANK1];
|
||||
} M68K_CONTEXT;
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
#define s16 signed short
|
||||
#define u32 unsigned int
|
||||
#define s32 signed int
|
||||
#define uptr unsigned long
|
||||
#define uptr uintptr_t
|
||||
|
||||
/*
|
||||
typedef unsigned char u8;
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
/* Exception Vectors handled by emulation */
|
||||
#define EXCEPTION_BUS_ERROR 2 /* This one is not emulated! */
|
||||
#define EXCEPTION_ADDRESS_ERROR 3 /* This one is partially emulated (doesn't stack a proper frame yet) */
|
||||
#undef EXCEPTION_ILLEGAL_INSTRUCTION
|
||||
#define EXCEPTION_ILLEGAL_INSTRUCTION 4
|
||||
#define EXCEPTION_ZERO_DIVIDE 5
|
||||
#define EXCEPTION_CHK 6
|
||||
|
|
|
@ -58,7 +58,7 @@ static void convert_pal555(int invert_prio)
|
|||
unsigned short t; \
|
||||
int i; \
|
||||
for (i = 320; i > 0; i--, pd++, p32x++, pmd++) { \
|
||||
t = pal[*(unsigned char *)((long)p32x ^ 1)]; \
|
||||
t = pal[*(unsigned char *)((uintptr_t)p32x ^ 1)]; \
|
||||
if ((t & 0x20) || (*pmd & 0x3f) == mdbg) \
|
||||
*pd = t; \
|
||||
else \
|
||||
|
|
|
@ -1786,9 +1786,9 @@ void PicoMemSetup32x(void)
|
|||
cpu68k_map_set(m68k_write16_map, 0x880000, 0x880000 + rs - 1, PicoWrite16_cart, 1);
|
||||
#ifdef EMU_F68K
|
||||
// setup FAME fetchmap
|
||||
PicoCpuFM68k.Fetch[0] = (unsigned long)Pico32xMem->m68k_rom;
|
||||
PicoCpuFM68k.Fetch[0] = (uptr)Pico32xMem->m68k_rom;
|
||||
for (rs = 0x88; rs < 0x90; rs++)
|
||||
PicoCpuFM68k.Fetch[rs] = (unsigned long)Pico.rom - 0x880000;
|
||||
PicoCpuFM68k.Fetch[rs] = (uptr)Pico.rom - 0x880000;
|
||||
#endif
|
||||
|
||||
// 32X ROM (banked)
|
||||
|
|
|
@ -1168,29 +1168,29 @@ PICO_INTERNAL void PicoMemSetupCD(void)
|
|||
#ifdef __clang__
|
||||
volatile // prevent strange relocs from clang
|
||||
#endif
|
||||
unsigned long ptr_ram = (unsigned long)PicoMem.ram;
|
||||
unsigned long ptr_ram = (uptr)PicoMem.ram;
|
||||
int i;
|
||||
|
||||
// M68k
|
||||
// by default, point everything to fitst 64k of ROM (BIOS)
|
||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||
// now real ROM (BIOS)
|
||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
|
||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom;
|
||||
// .. and RAM
|
||||
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
||||
PicoCpuFM68k.Fetch[i] = ptr_ram - (i<<(24-FAMEC_FETCHBITS));
|
||||
// S68k
|
||||
// PRG RAM is default
|
||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||
PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->prg_ram - (i<<(24-FAMEC_FETCHBITS));
|
||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->prg_ram - (i<<(24-FAMEC_FETCHBITS));
|
||||
// real PRG RAM
|
||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0x80000; i++)
|
||||
PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->prg_ram;
|
||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->prg_ram;
|
||||
// WORD RAM 2M area
|
||||
for (i = M68K_FETCHBANK1*0x08/0x100; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < 0xc0000; i++)
|
||||
PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram2M - 0x80000;
|
||||
PicoCpuFS68k.Fetch[i] = (uptr)Pico_mcd->word_ram2M - 0x80000;
|
||||
// remap_word_ram() will setup word ram for both
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -832,10 +832,10 @@ PICO_INTERNAL void PicoMemSetup(void)
|
|||
int i;
|
||||
// by default, point everything to first 64k of ROM
|
||||
for (i = 0; i < M68K_FETCHBANK1 * 0xe0 / 0x100; i++)
|
||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||
// now real ROM
|
||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
|
||||
PicoCpuFM68k.Fetch[i] = (uptr)Pico.rom;
|
||||
// RAM already set
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// memory map related stuff
|
||||
|
||||
#include "pico_port.h"
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long uptr; // unsigned pointer-sized int
|
||||
typedef uintptr_t uptr; // unsigned pointer-sized int
|
||||
|
||||
#define M68K_MEM_SHIFT 16
|
||||
// minimum size we can map
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#define PICO_INTERNAL_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pico_port.h"
|
||||
#include "pico.h"
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#ifndef PICO_PORT_INCLUDED
|
||||
#define PICO_PORT_INCLUDED
|
||||
|
||||
// provide size_t, uintptr_t
|
||||
#include <stdlib.h>
|
||||
#if !(defined(_MSC_VER) && _MSC_VER < 1800)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
#define REGPARM(x) __attribute__((regparm(x)))
|
||||
#else
|
||||
|
|
|
@ -265,7 +265,7 @@ PICO_INTERNAL void PsndClear(void)
|
|||
memset32((int *) PicoIn.sndOut, 0, len); // assume PicoIn.sndOut to be aligned
|
||||
else {
|
||||
short *out = PicoIn.sndOut;
|
||||
if ((long)out & 2) { *out++ = 0; len--; }
|
||||
if ((uintptr_t)out & 2) { *out++ = 0; len--; }
|
||||
memset32((int *) out, 0, len/2);
|
||||
if (len & 1) out[len-1] = 0;
|
||||
}
|
||||
|
|
|
@ -79,11 +79,7 @@ static void *vout_buf;
|
|||
static int vout_width, vout_height, vout_offset;
|
||||
static float user_vout_width = 0.0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static short sndBuffer[2*44100/50];
|
||||
#else
|
||||
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
||||
#endif
|
||||
static short ALIGNED(4) sndBuffer[2*44100/50];
|
||||
|
||||
static void snd_write(int len);
|
||||
|
||||
|
@ -375,7 +371,7 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed)
|
|||
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
void *req, *ret;
|
||||
|
||||
req = (void *)addr;
|
||||
req = (void *)(uintptr_t)addr;
|
||||
ret = mmap(req, size, PROT_READ | PROT_WRITE, flags, -1, 0);
|
||||
if (ret == MAP_FAILED) {
|
||||
if (log_cb)
|
||||
|
@ -383,7 +379,7 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (addr != 0 && ret != (void *)addr) {
|
||||
if (addr != 0 && ret != (void *)(uintptr_t)addr) {
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_WARN, "warning: wanted to map @%08lx, got %p\n",
|
||||
addr, ret);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue