famec: fix 64bit portability issues

This commit is contained in:
notaz 2013-06-29 03:39:20 +03:00
parent 720bfc5d9f
commit be26eb239b
7 changed files with 206 additions and 204 deletions

View file

@ -37,12 +37,7 @@ asm_misc = 1
asm_cdpico = 1
asm_cdmemory = 1
else # if not arm
ifneq "$(ARCH)" "x86_64"
# no 64bit support
use_fame ?= 1
else
use_musashi ?= 1
endif
use_cz80 ?= 1
use_sh2mame ?= 1
endif

View file

@ -122,7 +122,7 @@ typedef struct
unsigned short execinfo;
// PD extension
int io_cycle_counter; // cycles left
unsigned int Fetch[M68K_FETCHBANK1];
unsigned long Fetch[M68K_FETCHBANK1];
} M68K_CONTEXT;
extern M68K_CONTEXT *g_m68kcontext;

View file

@ -11,6 +11,10 @@
#include <stdlib.h>
#include <string.h>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include "fame.h"
@ -70,12 +74,17 @@
#undef s32
#endif
#ifdef uptr
#undef uptr
#endif
#define u8 unsigned char
#define s8 signed char
#define u16 unsigned short
#define s16 signed short
#define u32 unsigned int
#define s32 signed int
#define uptr unsigned long
/*
typedef unsigned char u8;
@ -287,7 +296,7 @@ typedef signed int s32;
#define M68K_PPL (m68kcontext.sr >> 8) & 7
#define GET_PC \
((u32)PC - BasePC)
(u32)((uptr)PC - BasePC)
#ifdef FAMEC_CHECK_BRANCHES
@ -522,7 +531,7 @@ M68K_CONTEXT *g_m68kcontext;
static u32 Opcode;
static s32 cycles_needed;
static u16 *PC;
static u32 BasePC;
static uptr BasePC;
static u32 flag_C;
static u32 flag_V;
static u32 flag_NotZ;
@ -697,7 +706,7 @@ int fm68k_reset(void)
u32 fm68k_get_pc(M68K_CONTEXT *context)
{
#ifdef FAMEC_NO_GOTOS
return (context->execinfo & M68K_RUNNING)?(u32)PC-BasePC:context->pc;
return (context->execinfo & M68K_RUNNING)?(uptr)PC-BasePC:context->pc;
#else
return context->pc; // approximate PC in this mode
#endif
@ -776,8 +785,6 @@ static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(s32 vect, s32 addr, u16
}
static void setup_jumptable(void);
#ifdef FAMEC_NO_GOTOS
#define OPCODE(N_OP) static void OP_##N_OP(void)
@ -795,7 +802,7 @@ int fm68k_emulate(s32 cycles, int dualcore, int idle_mode)
u32 Opcode;
s32 cycles_needed;
u16 *PC;
u32 BasePC;
uptr BasePC;
u32 flag_C;
u32 flag_V;
u32 flag_NotZ;

File diff suppressed because it is too large Load diff

View file

@ -917,7 +917,7 @@ static void bank_switch(int b)
#ifdef EMU_F68K
// setup FAME fetchmap
for (rs = 0x90; rs < 0xa0; rs++)
PicoCpuFM68k.Fetch[rs] = (u32)Pico.rom + bank - 0x900000;
PicoCpuFM68k.Fetch[rs] = (unsigned long)Pico.rom + bank - 0x900000;
#endif
}
@ -1461,9 +1461,9 @@ void PicoMemSetup32x(void)
cpu68k_map_set(m68k_read16_map, 0x880000, 0x880000 + rs - 1, Pico.rom, 0);
#ifdef EMU_F68K
// setup FAME fetchmap
PicoCpuFM68k.Fetch[0] = (u32)Pico32xMem->m68k_rom;
PicoCpuFM68k.Fetch[0] = (unsigned long)Pico32xMem->m68k_rom;
for (rs = 0x88; rs < 0x90; rs++)
PicoCpuFM68k.Fetch[rs] = (u32)Pico.rom - 0x880000;
PicoCpuFM68k.Fetch[rs] = (unsigned long)Pico.rom - 0x880000;
#endif
// 32X ROM (banked)

View file

@ -966,14 +966,14 @@ static void remap_word_ram(int r3)
if (!(r3 & 4))
{
for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x240000; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram2M - 0x200000;
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram2M - 0x200000;
}
else
{
for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x220000; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram1M[r3 & 1] - 0x200000;
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram1M[r3 & 1] - 0x200000;
for (i = M68K_FETCHBANK1*0x0c/0x100; (i<<(24-FAMEC_FETCHBITS)) < 0x0e0000; i++)
PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->word_ram1M[(r3&1)^1] - 0x0c0000;
PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram1M[(r3&1)^1] - 0x0c0000;
}
#endif
}
@ -1073,23 +1073,23 @@ PICO_INTERNAL void PicoMemSetupCD(void)
// M68k
// by default, point everything to fitst 64k of ROM (BIOS)
for (i = 0; i < M68K_FETCHBANK1; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
PicoCpuFM68k.Fetch[i] = (unsigned long)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 int)Pico.rom;
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
// .. and RAM
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
// S68k
// PRG RAM is default
for (i = 0; i < M68K_FETCHBANK1; i++)
PicoCpuFS68k.Fetch[i] = (unsigned int)Pico_mcd->prg_ram - (i<<(24-FAMEC_FETCHBITS));
PicoCpuFS68k.Fetch[i] = (unsigned long)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 int)Pico_mcd->prg_ram;
PicoCpuFS68k.Fetch[i] = (unsigned long)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 int)Pico_mcd->word_ram2M - 0x80000;
PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram2M - 0x80000;
// remap_word_ram() will setup word ram for both
}
#endif

View file

@ -726,13 +726,13 @@ PICO_INTERNAL void PicoMemSetup(void)
int i;
// by default, point everything to first 64k of ROM
for (i = 0; i < M68K_FETCHBANK1; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
PicoCpuFM68k.Fetch[i] = (unsigned long)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 int)Pico.rom;
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
// .. and RAM
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
PicoCpuFM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
}
#endif
#ifdef EMU_M68K