improve 64bit portability

for win64 mostly
This commit is contained in:
notaz 2018-01-06 21:29:59 +02:00
parent a0b95da112
commit 48c9e01be8
14 changed files with 42 additions and 26 deletions

View file

@ -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 \

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -11,7 +11,6 @@
#define PICO_INTERNAL_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pico_port.h"
#include "pico.h"

View file

@ -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

View file

@ -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;
}