mirror of
https://github.com/libretro/px68k-libretro.git
synced 2026-11-07 04:25:57 -10:00
libretro hack patch
This commit is contained in:
1 parent
74ddbb37b4
commit
510449e690
92 files changed
+73009
-117
No files matched your search
Executable
+103
@@ -0,0 +1,103 @@
|
||||
|
||||
DEBUG = 0
|
||||
|
||||
ifeq ($(platform),)
|
||||
platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
platform = osx
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
platform = win
|
||||
endif
|
||||
endif
|
||||
|
||||
TARGET_NAME := px68k
|
||||
|
||||
ifeq ($(platform), unix)
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
CFLAGS = -g -O2
|
||||
CXXFLAGS = -g -O2 -fno-merge-constants
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
FLAGS += -D__LINUX__
|
||||
# android arm
|
||||
else ifneq (,$(findstring android,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_android.so
|
||||
fpic = -fPIC
|
||||
SHARED := -lstdc++ -llog -lz -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
CFLAGS += -g -O2
|
||||
CC = arm-linux-androideabi-gcc
|
||||
CXX = arm-linux-androideabi-g++
|
||||
# cross Windows
|
||||
else ifeq ($(platform), wincross64)
|
||||
TARGET := $(TARGET_NAME)_libretro.dll
|
||||
AR = x86_64-w64-mingw32-ar
|
||||
CC = x86_64-w64-mingw32-gcc
|
||||
CXX = x86_64-w64-mingw32-g++
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
LDFLAGS += -static-libgcc -static-libstdc++
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
FLAGS +=
|
||||
EXTRA_LDF := -lwinmm -Wl,--export-all-symbols
|
||||
else
|
||||
TARGET := $(TARGET_NAME)_retro.dll
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
LDFLAGS += -static-libgcc -static-libstdc++
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
FLAGS +=
|
||||
EXTRA_LDF = -lwinmm -Wl,--export-all-symbols
|
||||
endif
|
||||
|
||||
CDEBUGFLAGS+= -DNO_MERCURY
|
||||
CDEBUGFLAGS+=-DPX68K_VERSION=0.15
|
||||
EXTRA_INCLUDES= -I./libretro -I./x68k -I./fmgen -I./win32api
|
||||
FLAGS += $(CDEBUGFLAGS)
|
||||
|
||||
CPUOBJS= x68k/d68k.o m68000/m68000.o
|
||||
C68KOBJS= m68000/c68k/c68k.o m68000/c68k/c68kexec.o
|
||||
|
||||
X68KOBJS= x68k/adpcm.o x68k/bg.o x68k/crtc.o x68k/dmac.o x68k/fdc.o x68k/fdd.o x68k/disk_d88.o x68k/disk_dim.o x68k/disk_xdf.o x68k/gvram.o x68k/ioc.o x68k/irqh.o x68k/mem_wrap.o x68k/mercury.o x68k/mfp.o x68k/palette.o x68k/midi.o x68k/pia.o x68k/rtc.o x68k/sasi.o x68k/scc.o x68k/scsi.o x68k/sram.o x68k/sysport.o x68k/tvram.o
|
||||
FMGENOBJS= fmgen/fmgen.o fmgen/fmg_wrap.o fmgen/file.o fmgen/fmtimer.o fmgen/opm.o fmgen/opna.o fmgen/psg.o
|
||||
X11OBJS= libretro/joystick.o libretro/juliet.o libretro/keyboard.o libretro/mouse.o libretro/prop.o libretro/status.o libretro/timer.o libretro/dswin.o libretro/windraw.o libretro/winui.o libretro/about.o libretro/common.o
|
||||
X11CXXOBJS= libretro/winx68k.o
|
||||
WIN32APIOBJS= win32api/dosio.o win32api/fake.o win32api/peace.o
|
||||
|
||||
OBJECTS := $(X68KOBJS) $(X11OBJS) $(WIN32APIOBJS) $(CPUOBJS) $(C68KOBJS) $(FMGENOBJS) $(X11CXXOBJS) libretro.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
ifeq ($(DEBUG), 0)
|
||||
FLAGS += -O3 -ffast-math -fomit-frame-pointer
|
||||
else
|
||||
FLAGS += -O0 -g
|
||||
endif
|
||||
|
||||
LDFLAGS += $(fpic) $(SHARED) $(EXTRA_LDF)
|
||||
FLAGS += -I. -I.. $(EXTRA_INCLUDES)
|
||||
|
||||
WARNINGS :=
|
||||
|
||||
FLAGS += -D__LIBRETRO__ $(ENDIANNESS_DEFINES) $(WARNINGS) $(fpic)
|
||||
|
||||
CXXFLAGS += $(FLAGS) -fpermissive
|
||||
CFLAGS += $(FLAGS) -std=gnu99
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CXXFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.PHONY: clean
|
||||
Executable
+482
@@ -0,0 +1,482 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libretro.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
char slash = '\\';
|
||||
#else
|
||||
char slash = '/';
|
||||
#endif
|
||||
|
||||
#define LOGI printf
|
||||
#define RENDER16B 1
|
||||
|
||||
char RPATH[512];
|
||||
char RETRO_DIR[512];
|
||||
const char *retro_save_directory;
|
||||
const char *retro_system_directory;
|
||||
const char *retro_content_directory;
|
||||
char retro_system_conf[512];
|
||||
|
||||
char Core_Key_Sate[512];
|
||||
char Core_old_Key_Sate[512];
|
||||
|
||||
bool opt_analog;
|
||||
|
||||
int retrow=800;
|
||||
int retroh=600;
|
||||
int CHANGEAV=0;
|
||||
|
||||
int pauseg=0;
|
||||
|
||||
signed short soundbuf[1024*2];
|
||||
|
||||
uint16_t *videoBuffer;
|
||||
|
||||
static retro_video_refresh_t video_cb;
|
||||
static retro_environment_t environ_cb;
|
||||
|
||||
static retro_input_poll_t input_poll_cb;
|
||||
|
||||
retro_input_state_t input_state_cb;
|
||||
retro_audio_sample_t audio_cb;
|
||||
retro_audio_sample_batch_t audio_batch_cb;
|
||||
|
||||
void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
|
||||
void retro_set_audio_sample(retro_audio_sample_t cb) { audio_cb =cb; }
|
||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; }
|
||||
void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; }
|
||||
void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
|
||||
|
||||
#define LOGI printf
|
||||
|
||||
//Args for experimental_cmdline
|
||||
static char ARGUV[64][1024];
|
||||
static unsigned char ARGUC=0;
|
||||
|
||||
// Args for Core
|
||||
static char XARGV[64][1024];
|
||||
static const char* xargv_cmd[64];
|
||||
int PARAMCOUNT=0;
|
||||
|
||||
extern int cmain(int argc, char *argv[]);
|
||||
|
||||
void parse_cmdline( const char *argv );
|
||||
|
||||
void Add_Option(const char* option)
|
||||
{
|
||||
static int first=0;
|
||||
|
||||
if(first==0)
|
||||
{
|
||||
PARAMCOUNT=0;
|
||||
first++;
|
||||
}
|
||||
|
||||
sprintf(XARGV[PARAMCOUNT++],"%s\0",option);
|
||||
}
|
||||
|
||||
int pre_main(const char *argv)
|
||||
{
|
||||
int i;
|
||||
int Only1Arg;
|
||||
|
||||
parse_cmdline(argv);
|
||||
|
||||
Only1Arg = (strcmp(ARGUV[0],"px68k") == 0) ? 0 : 1;
|
||||
|
||||
for (i = 0; i<64; i++)
|
||||
xargv_cmd[i] = NULL;
|
||||
|
||||
|
||||
if(Only1Arg)
|
||||
{
|
||||
int cfgload=0;
|
||||
|
||||
Add_Option("px68k");
|
||||
|
||||
if (strlen(RPATH) >= strlen("hdf")){
|
||||
if(!strcasecmp(&RPATH[strlen(RPATH)-strlen("hdf")], "hdf")){
|
||||
Add_Option("-h");
|
||||
cfgload=1;
|
||||
}
|
||||
}
|
||||
|
||||
if(cfgload==0) {
|
||||
//Add_Option("-verbose");
|
||||
//Add_Option(retro_system_tos);
|
||||
//Add_Option("-8");
|
||||
}
|
||||
|
||||
Add_Option(RPATH);
|
||||
}
|
||||
else
|
||||
{ // Pass all cmdline args
|
||||
for(i = 0; i < ARGUC; i++)
|
||||
Add_Option(ARGUV[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < PARAMCOUNT; i++)
|
||||
{
|
||||
xargv_cmd[i] = (char*)(XARGV[i]);
|
||||
LOGI("%2d %s\n",i,XARGV[i]);
|
||||
}
|
||||
|
||||
pmain(PARAMCOUNT,( char **)xargv_cmd);
|
||||
|
||||
xargv_cmd[PARAMCOUNT - 2] = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void parse_cmdline(const char *argv)
|
||||
{
|
||||
char *p,*p2,*start_of_word;
|
||||
int c,c2;
|
||||
static char buffer[512*4];
|
||||
enum states { DULL, IN_WORD, IN_STRING } state = DULL;
|
||||
|
||||
strcpy(buffer,argv);
|
||||
strcat(buffer," \0");
|
||||
|
||||
for (p = buffer; *p != '\0'; p++)
|
||||
{
|
||||
c = (unsigned char) *p; /* convert to unsigned char for is* functions */
|
||||
switch (state)
|
||||
{
|
||||
case DULL: /* not in a word, not in a double quoted string */
|
||||
if (isspace(c)) /* still not in a word, so ignore this char */
|
||||
continue;
|
||||
/* not a space -- if it's a double quote we go to IN_STRING, else to IN_WORD */
|
||||
if (c == '"')
|
||||
{
|
||||
state = IN_STRING;
|
||||
start_of_word = p + 1; /* word starts at *next* char, not this one */
|
||||
continue;
|
||||
}
|
||||
state = IN_WORD;
|
||||
start_of_word = p; /* word starts here */
|
||||
continue;
|
||||
case IN_STRING:
|
||||
/* we're in a double quoted string, so keep going until we hit a close " */
|
||||
if (c == '"')
|
||||
{
|
||||
/* word goes from start_of_word to p-1 */
|
||||
//... do something with the word ...
|
||||
for (c2 = 0,p2 = start_of_word; p2 < p; p2++, c2++)
|
||||
ARGUV[ARGUC][c2] = (unsigned char) *p2;
|
||||
ARGUC++;
|
||||
|
||||
state = DULL; /* back to "not in word, not in string" state */
|
||||
}
|
||||
continue; /* either still IN_STRING or we handled the end above */
|
||||
case IN_WORD:
|
||||
/* we're in a word, so keep going until we get to a space */
|
||||
if (isspace(c))
|
||||
{
|
||||
/* word goes from start_of_word to p-1 */
|
||||
//... do something with the word ...
|
||||
for (c2 = 0,p2 = start_of_word; p2 <p; p2++,c2++)
|
||||
ARGUV[ARGUC][c2] = (unsigned char) *p2;
|
||||
ARGUC++;
|
||||
|
||||
state = DULL; /* back to "not in word, not in string" state */
|
||||
}
|
||||
continue; /* either still IN_WORD or we handled the end above */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void texture_init(){
|
||||
memset(videoBuffer, 0, sizeof(videoBuffer));
|
||||
}
|
||||
|
||||
void retro_set_environment(retro_environment_t cb)
|
||||
{
|
||||
// bool no_rom = true;
|
||||
|
||||
environ_cb = cb;
|
||||
|
||||
// cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_rom);
|
||||
|
||||
struct retro_variable variables[] = {
|
||||
{
|
||||
"px68k_analog","Use Analog; OFF|ON",
|
||||
},
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||
|
||||
}
|
||||
|
||||
static void update_variables(void)
|
||||
{
|
||||
struct retro_variable var = {0};
|
||||
|
||||
|
||||
var.key = "px68k_analog";
|
||||
var.value = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
fprintf(stderr, "value: %s\n", var.value);
|
||||
if (strcmp(var.value, "OFF") == 0)
|
||||
opt_analog = false;
|
||||
if (strcmp(var.value, "ON") == 0)
|
||||
opt_analog = true;
|
||||
|
||||
fprintf(stderr, "[libretro-test]: Analog: %s.\n",opt_analog?"ON":"OFF");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void update_input()
|
||||
{
|
||||
input_poll_cb();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void keyboard_cb(bool down, unsigned keycode, uint32_t character, uint16_t mod)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************
|
||||
* libretro implementation
|
||||
************************************/
|
||||
|
||||
//static struct retro_system_av_info g_av_info;
|
||||
|
||||
void retro_get_system_info(struct retro_system_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->library_name = "px68k";
|
||||
info->library_version = "0.15+";
|
||||
info->need_fullpath = true;
|
||||
info->valid_extensions = "dim|zip|img|d88|88d|hdm|dup|2hd|xdf|hdf";
|
||||
}
|
||||
|
||||
|
||||
void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
//FIXME handle vice PAL/NTSC
|
||||
struct retro_game_geometry geom = { retrow, retroh,800, 600 ,4.0 / 3.0 };
|
||||
struct retro_system_timing timing = { 60.0, 44100.0 };
|
||||
|
||||
info->geometry = geom;
|
||||
info->timing = timing;
|
||||
}
|
||||
|
||||
void update_geometry()
|
||||
{
|
||||
struct retro_system_av_info system_av_info;
|
||||
system_av_info.geometry.base_width = retrow;
|
||||
system_av_info.geometry.base_height = retroh;
|
||||
system_av_info.geometry.aspect_ratio = (float)4/3;// retro_aspect;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &system_av_info);
|
||||
}
|
||||
|
||||
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
(void)port;
|
||||
(void)device;
|
||||
}
|
||||
|
||||
size_t retro_serialize_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool retro_serialize(void *data, size_t size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retro_unserialize(const void *data, size_t size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void retro_cheat_reset(void)
|
||||
{}
|
||||
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||
{
|
||||
(void)index;
|
||||
(void)enabled;
|
||||
(void)code;
|
||||
}
|
||||
|
||||
bool retro_load_game(const struct retro_game_info *info)
|
||||
{
|
||||
|
||||
const char *full_path;
|
||||
|
||||
full_path = info->path;
|
||||
|
||||
strcpy(RPATH,full_path);
|
||||
|
||||
printf("LOAD EMU\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
|
||||
{
|
||||
(void)game_type;
|
||||
(void)info;
|
||||
(void)num_info;
|
||||
return false;
|
||||
}
|
||||
|
||||
void retro_unload_game(void)
|
||||
{
|
||||
pauseg=0;
|
||||
}
|
||||
|
||||
unsigned retro_get_region(void)
|
||||
{
|
||||
return RETRO_REGION_NTSC;
|
||||
}
|
||||
|
||||
unsigned retro_api_version(void)
|
||||
{
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
void *retro_get_memory_data(unsigned id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t retro_get_memory_size(unsigned id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void retro_init(void)
|
||||
{
|
||||
const char *system_dir = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir) && system_dir)
|
||||
{
|
||||
// if defined, use the system directory
|
||||
retro_system_directory=system_dir;
|
||||
}
|
||||
|
||||
const char *content_dir = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY, &content_dir) && content_dir)
|
||||
{
|
||||
// if defined, use the system directory
|
||||
retro_content_directory=content_dir;
|
||||
}
|
||||
|
||||
const char *save_dir = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &save_dir) && save_dir)
|
||||
{
|
||||
// If save directory is defined use it, otherwise use system directory
|
||||
retro_save_directory = *save_dir ? save_dir : retro_system_directory;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make retro_save_directory the same in case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY is not implemented by the frontend
|
||||
retro_save_directory=retro_system_directory;
|
||||
}
|
||||
|
||||
if(retro_system_directory==NULL)sprintf(RETRO_DIR, "%s\0",".");
|
||||
else sprintf(RETRO_DIR, "%s\0", retro_system_directory);
|
||||
|
||||
sprintf(retro_system_conf, "%s%ckeropi\0",RETRO_DIR,slash);
|
||||
|
||||
LOGI("Retro SYSTEM_DIRECTORY %s\n",retro_system_directory);
|
||||
LOGI("Retro SAVE_DIRECTORY %s\n",retro_save_directory);
|
||||
LOGI("Retro CONTENT_DIRECTORY %s\n",retro_content_directory);
|
||||
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
{
|
||||
fprintf(stderr, "RGB565 is not supported.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
struct retro_input_descriptor inputDescriptors[] = {
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3" }
|
||||
};
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, &inputDescriptors);
|
||||
|
||||
/*
|
||||
struct retro_keyboard_callback cbk = { keyboard_cb };
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cbk);
|
||||
*/
|
||||
update_variables();
|
||||
|
||||
memset(Core_Key_Sate,0,512);
|
||||
memset(Core_old_Key_Sate ,0, sizeof(Core_old_Key_Sate));
|
||||
}
|
||||
|
||||
void retro_deinit(void)
|
||||
{
|
||||
end_loop_retro();
|
||||
printf("Retro DeInit\n");
|
||||
}
|
||||
|
||||
void retro_reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int firstcall=1;
|
||||
|
||||
void retro_run(void)
|
||||
{
|
||||
|
||||
if(firstcall){
|
||||
pre_main(RPATH);
|
||||
firstcall=0;
|
||||
printf("INIT done\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CHANGEAV == 1){
|
||||
update_geometry();
|
||||
printf("w:%d h:%d a:%f\n",retrow,retroh,(float)(4/3));
|
||||
CHANGEAV=0;
|
||||
}
|
||||
|
||||
|
||||
update_input();
|
||||
|
||||
if(pauseg!=-1){
|
||||
|
||||
}
|
||||
|
||||
exec_app_retro();
|
||||
|
||||
raudio_callback(NULL, NULL,735*4);
|
||||
|
||||
video_cb(videoBuffer, retrow, retroh, /*retrow*/ 800 << 1/*2*/);
|
||||
|
||||
}
|
||||
|
||||
+1926
File diff suppressed because it is too large.
Load diff
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,24 @@
|
||||
#ifndef CDASPI_H_
|
||||
#define CDASPI_H_
|
||||
|
||||
int CDASPI_Open(void);
|
||||
void CDASPI_Close(void);
|
||||
int CDASPI_Wait(void);
|
||||
int CDASPI_ReadTOC(void* buf);
|
||||
int CDASPI_Read(long block, BYTE* buf);
|
||||
int CDASPI_ExecCmd(BYTE *cdb, int cdb_size, BYTE *out_buff, int out_size);
|
||||
int CDASPI_IsOpen(void);
|
||||
|
||||
void CDASPI_EnumCD(void);
|
||||
|
||||
void CDASPI_Init(void);
|
||||
void CDASPI_Cleanup(void);
|
||||
|
||||
extern BYTE CDASPI_CDName[8][4];
|
||||
extern int CDASPI_CDNum;
|
||||
|
||||
extern HINSTANCE ASPIDLL;
|
||||
DWORD (*pSendASPI32Command)(LPSRB);
|
||||
DWORD (*pGetASPI32SupportInfo)(VOID);
|
||||
|
||||
#endif // CDASPI_H_
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef CDCTRL_H_
|
||||
#define CDCTRL_H_
|
||||
|
||||
int CDCTRL_Open(void);
|
||||
void CDCTRL_Close(void);
|
||||
int CDCTRL_Wait(void);
|
||||
int CDCTRL_ReadTOC(void* buf);
|
||||
int CDCTRL_Read(long block, BYTE* buf);
|
||||
int CDCTRL_IsOpen(void);
|
||||
|
||||
#endif // CDCTRL_H_
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef _winx68k_cdrom
|
||||
#define _winx68k_cdrom
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned char reserved;
|
||||
unsigned char adr;
|
||||
unsigned char trackno;
|
||||
unsigned char reserved1;
|
||||
unsigned char addr[4];
|
||||
} TOCENTRY;
|
||||
|
||||
typedef struct {
|
||||
unsigned char size[2];
|
||||
unsigned char first;
|
||||
unsigned char last;
|
||||
TOCENTRY track[100];
|
||||
} TOC;
|
||||
|
||||
void CDROM_Init(void);
|
||||
void CDROM_Cleanup(void);
|
||||
BYTE FASTCALL CDROM_Read(DWORD adr);
|
||||
void FASTCALL CDROM_Write(DWORD adr, BYTE data);
|
||||
|
||||
extern BYTE CDROM_ASPIChecked;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef keropi_cmdline_h
|
||||
#define keropi_cmdline_h
|
||||
|
||||
extern char macrofile[MAX_PATH];
|
||||
|
||||
void CheckCmdLine(LPSTR s);
|
||||
void SetCmdLineFD(void);
|
||||
|
||||
#endif //keropi_cmdline_h
|
||||
@@ -0,0 +1,46 @@
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// COMMON - 標準ヘッダ群(COMMON.H)とエラーダイアログ表示とか
|
||||
// ---------------------------------------------------------------------------------------
|
||||
//#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
//#include "sstp.h"
|
||||
|
||||
//extern HWND hWndMain;
|
||||
extern const char PrgTitle[];
|
||||
|
||||
// P6L: PX68K_LOG
|
||||
// ~ ~ ~
|
||||
#define P6L_LEN 256
|
||||
char p6l_buf[P6L_LEN];
|
||||
|
||||
void Error(const char* s)
|
||||
{
|
||||
printf("%s Error: %s\n", PrgTitle, s);
|
||||
|
||||
// SSTP_SendMes(SSTPMES_ERROR);
|
||||
|
||||
// MessageBox(hWndMain, s, title, MB_ICONERROR | MB_OK);
|
||||
}
|
||||
|
||||
// log for debug
|
||||
void p6logd(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(p6l_buf, P6L_LEN, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
#if defined(ANDROID)
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "Tag", p6l_buf);
|
||||
#elif defined(PSP)
|
||||
printf("%s", p6l_buf);
|
||||
#else
|
||||
printf("%s", p6l_buf);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef winx68k_common_h
|
||||
#define winx68k_common_h
|
||||
|
||||
#include "windows.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define SUCCESS 0
|
||||
#define FAILURE 1
|
||||
|
||||
#define FASTCALL
|
||||
#define STDCALL
|
||||
#define LABEL
|
||||
#define __stdcall
|
||||
|
||||
#ifdef PSP
|
||||
#ifdef MAX_PATH
|
||||
#undef MAX_PATH
|
||||
#endif
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
typedef unsigned char UINT8;
|
||||
typedef unsigned short UINT16;
|
||||
typedef unsigned int UINT32;
|
||||
typedef signed char INT8;
|
||||
typedef signed short INT16;
|
||||
typedef signed int INT32;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
BYTE l;
|
||||
BYTE h;
|
||||
} b;
|
||||
WORD w;
|
||||
} PAIR;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void Error(const char* s);
|
||||
void p6logd(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //winx68k_common_h
|
||||
Executable
+268
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2003 NONAKA Kimihiro
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "common.h"
|
||||
#include "dswin.h"
|
||||
#include "prop.h"
|
||||
#include "adpcm.h"
|
||||
#include "mercury.h"
|
||||
#include "fmg_wrap.h"
|
||||
|
||||
#include "libretro.h"
|
||||
extern retro_audio_sample_batch_t audio_batch_cb;
|
||||
extern signed short soundbuf[1024*2];
|
||||
|
||||
short playing = FALSE;
|
||||
|
||||
#define PCMBUF_SIZE 2*2*48000
|
||||
BYTE pcmbuffer[PCMBUF_SIZE];
|
||||
BYTE *pcmbufp = pcmbuffer;
|
||||
BYTE *pbsp = pcmbuffer;
|
||||
BYTE *pbrp = pcmbuffer, *pbwp = pcmbuffer;
|
||||
BYTE *pbep = &pcmbuffer[PCMBUF_SIZE];
|
||||
DWORD ratebase = 22050;
|
||||
long DSound_PreCounter = 0;
|
||||
BYTE rsndbuf[PCMBUF_SIZE];
|
||||
|
||||
int audio_fd = 1;
|
||||
|
||||
void raudio_callback(void *userdata, unsigned char *stream, int len);
|
||||
|
||||
#ifndef NOSOUND
|
||||
|
||||
|
||||
int
|
||||
DSound_Init(unsigned long rate, unsigned long buflen)
|
||||
{
|
||||
DWORD samples;
|
||||
|
||||
if (playing) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (rate == 0) {
|
||||
audio_fd = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ratebase = rate;
|
||||
|
||||
samples = 2048;
|
||||
|
||||
playing = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
DSound_Play(void)
|
||||
{
|
||||
// if (audio_fd >= 0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DSound_Stop(void)
|
||||
{
|
||||
// if (audio_fd >= 0);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
DSound_Cleanup(void)
|
||||
{
|
||||
playing = FALSE;
|
||||
if (audio_fd >= 0) {
|
||||
|
||||
audio_fd = -1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void sound_send(int length)
|
||||
{
|
||||
int rate;
|
||||
|
||||
rate = 0;
|
||||
|
||||
ADPCM_Update((short *)pbwp, length, rate, pbsp, pbep);
|
||||
OPM_Update((short *)pbwp, length, rate, pbsp, pbep);
|
||||
#ifndef NO_MERCURY
|
||||
//Mcry_Update((short *)pcmbufp, length);
|
||||
#endif
|
||||
|
||||
pbwp += length * sizeof(WORD) * 2;
|
||||
if (pbwp >= pbep) {
|
||||
pbwp = pbsp + (pbwp - pbep);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FASTCALL DSound_Send0(long clock)
|
||||
{
|
||||
int length = 0;
|
||||
int rate;
|
||||
|
||||
if (audio_fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
DSound_PreCounter += (ratebase * clock);
|
||||
while (DSound_PreCounter >= 10000000L) {
|
||||
length++;
|
||||
DSound_PreCounter -= 10000000L;
|
||||
}
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
sound_send(length);
|
||||
}
|
||||
|
||||
static void FASTCALL DSound_Send(int length)
|
||||
{
|
||||
int rate;
|
||||
|
||||
if (audio_fd < 0) {
|
||||
return;
|
||||
}
|
||||
sound_send(length);
|
||||
}
|
||||
|
||||
void
|
||||
raudio_callback(void *userdata, unsigned char *stream, int len)
|
||||
{
|
||||
int lena, lenb, datalen, rate;
|
||||
BYTE *buf;
|
||||
static DWORD bef;
|
||||
DWORD now;
|
||||
|
||||
now = timeGetTime();
|
||||
|
||||
//p6logd("tdiff %4d : len %d ", now - bef, len);
|
||||
|
||||
//printf("tdiff %4d : len %d \n", now - bef, len);
|
||||
cb_start:
|
||||
if (pbrp <= pbwp) {
|
||||
// pcmbuffer
|
||||
// +---------+-------------+----------+
|
||||
// | |/////////////| |
|
||||
// +---------+-------------+----------+
|
||||
// A A<--datalen-->A A
|
||||
// | | | |
|
||||
// pbsp pbrp pbwp pbep
|
||||
|
||||
datalen = pbwp - pbrp;
|
||||
if (datalen < len) {
|
||||
// needs more data
|
||||
|
||||
DSound_Send((len - datalen) / 4);
|
||||
|
||||
}
|
||||
#if 0
|
||||
datalen = pbwp - pbrp;
|
||||
if (datalen < len) {
|
||||
printf("xxxxx not enough sound data xxxxx\n");
|
||||
}
|
||||
#endif
|
||||
if (pbrp > pbwp) {
|
||||
// chage to TYPEC or TYPED
|
||||
goto cb_start;
|
||||
}
|
||||
|
||||
buf = pbrp;
|
||||
pbrp += len;
|
||||
//printf("TYPEA: ");
|
||||
|
||||
} else {
|
||||
// pcmbuffer
|
||||
// +---------+-------------+----------+
|
||||
// |/////////| |//////////|
|
||||
// +------+--+-------------+----------+
|
||||
// <-lenb-> A <---lena--->
|
||||
// A | A A
|
||||
// | | | |
|
||||
// pbsp pbwp pbrp pbep
|
||||
|
||||
lena = pbep - pbrp;
|
||||
if (lena >= len) {
|
||||
buf = pbrp;
|
||||
pbrp += len;
|
||||
//printf("TYPEC: ");
|
||||
} else {
|
||||
lenb = len - lena;
|
||||
if (pbwp - pbsp < lenb) {
|
||||
|
||||
DSound_Send((lenb - (pbwp - pbsp)) / 4);
|
||||
|
||||
}
|
||||
#if 0
|
||||
if (pbwp - pbsp < lenb) {
|
||||
printf("xxxxx not enough sound data xxxxx\n");
|
||||
}
|
||||
#endif
|
||||
memcpy(rsndbuf, pbrp, lena);
|
||||
memcpy(&rsndbuf[lena], pbsp, lenb);
|
||||
buf = rsndbuf;
|
||||
pbrp = pbsp + lenb;
|
||||
//printf("TYPED: ");
|
||||
}
|
||||
}
|
||||
|
||||
//printf("%d %d \n",len,lena+lenb);
|
||||
// _MixAudio(stream, buf, len, _MIX_MAXVOLUME);
|
||||
signed short int *ptr=(signed short int *)buf;
|
||||
memcpy(&soundbuf[0],buf,735*4);
|
||||
audio_batch_cb(soundbuf,735);
|
||||
bef = now;
|
||||
}
|
||||
|
||||
#else /* NOSOUND */
|
||||
int
|
||||
DSound_Init(unsigned long rate, unsigned long buflen)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
DSound_Play(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DSound_Stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
DSound_Cleanup(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void FASTCALL
|
||||
DSound_Send0(long clock)
|
||||
{
|
||||
}
|
||||
#endif /* !NOSOUND */
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef dswin_h__
|
||||
#define dswin_h__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int DSound_Init(unsigned long rate, unsigned long length);
|
||||
int DSound_Cleanup(void);
|
||||
|
||||
void DSound_Play(void);
|
||||
void DSound_Stop(void);
|
||||
void FASTCALL DSound_Send0(long clock);
|
||||
|
||||
void DS_SetVolumeOPM(long vol);
|
||||
void DS_SetVolumeADPCM(long vol);
|
||||
void DS_SetVolumeMercury(long vol);
|
||||
|
||||
#endif /* dswin_h__ */
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef winx68k_fileio_h
|
||||
#define winx68k_fileio_h
|
||||
|
||||
#include "common.h"
|
||||
#include "dosio.h"
|
||||
|
||||
#define FILEH HANDLE
|
||||
|
||||
#define FSEEK_SET 0
|
||||
#define FSEEK_CUR 1
|
||||
#define FSEEK_END 2
|
||||
|
||||
LPSTR getFileName(LPSTR filename);
|
||||
//#define getFileName GetFileName
|
||||
|
||||
FILEH File_Open(BYTE *filename);
|
||||
FILEH File_Create(BYTE *filename);
|
||||
DWORD File_Seek(FILEH handle, long pointer, short mode);
|
||||
DWORD File_Read(FILEH handle, void *data, DWORD length);
|
||||
DWORD File_Write(FILEH handle, void *data, DWORD length);
|
||||
short File_Close(FILEH handle);
|
||||
short File_Attr(BYTE *filename);
|
||||
#define File_Open file_open
|
||||
#define File_Create file_create
|
||||
#define File_Seek file_seek
|
||||
#define File_Read file_lread
|
||||
#define File_Write file_lwrite
|
||||
#define File_Close file_close
|
||||
#define File_Attr file_attr
|
||||
|
||||
void File_SetCurDir(BYTE *exename);
|
||||
FILEH File_OpenCurDir(BYTE *filename);
|
||||
FILEH File_CreateCurDir(BYTE *filename);
|
||||
short File_AttrCurDir(BYTE *filename);
|
||||
#define File_SetCurDir file_setcd
|
||||
#define File_OpenCurDir file_open_c
|
||||
#define File_CreateCurDir file_create_c
|
||||
#define File_AttrCurDir file_attr_c
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
// JOYSTICK.C - joystick support for WinX68k
|
||||
|
||||
#include "common.h"
|
||||
#include "prop.h"
|
||||
#include "joystick.h"
|
||||
#include "winui.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#include "libretro.h"
|
||||
extern retro_input_state_t input_state_cb;
|
||||
|
||||
#ifndef MAX_BUTTON
|
||||
#define MAX_BUTTON 32
|
||||
#endif
|
||||
|
||||
char joyname[2][MAX_PATH];
|
||||
char joybtnname[2][MAX_BUTTON][MAX_PATH];
|
||||
BYTE joybtnnum[2] = {0, 0};
|
||||
|
||||
BYTE joy[2];
|
||||
BYTE JoyKeyState;
|
||||
BYTE JoyKeyState0;
|
||||
BYTE JoyKeyState1;
|
||||
BYTE JoyState0[2];
|
||||
BYTE JoyState1[2];
|
||||
|
||||
// This stores whether the buttons were down. This avoids key repeats.
|
||||
BYTE JoyDownState0;
|
||||
BYTE MouseDownState0;
|
||||
|
||||
// This stores whether the buttons were up. This avoids key repeats.
|
||||
BYTE JoyUpState0;
|
||||
BYTE MouseUpState0;
|
||||
|
||||
BYTE JoyPortData[2];
|
||||
|
||||
int *r_joy;
|
||||
|
||||
void Joystick_Init(void)
|
||||
{
|
||||
joy[0] = 1; // active only one
|
||||
joy[1] = 0;
|
||||
JoyKeyState = 0;
|
||||
JoyKeyState0 = 0;
|
||||
JoyKeyState1 = 0;
|
||||
JoyState0[0] = 0xff;
|
||||
JoyState0[1] = 0xff;
|
||||
JoyState1[0] = 0xff;
|
||||
JoyState1[1] = 0xff;
|
||||
JoyPortData[0] = 0;
|
||||
JoyPortData[1] = 0;
|
||||
}
|
||||
|
||||
void Joystick_Cleanup(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BYTE FASTCALL Joystick_Read(BYTE num)
|
||||
{
|
||||
BYTE joynum = num;
|
||||
BYTE ret0 = 0xff, ret1 = 0xff, ret;
|
||||
|
||||
if (Config.JoySwap) joynum ^= 1;
|
||||
if (joy[num]) {
|
||||
ret0 = JoyState0[num];
|
||||
ret1 = JoyState1[num];
|
||||
}
|
||||
|
||||
if (Config.JoyKey)
|
||||
{
|
||||
if ((Config.JoyKeyJoy2)&&(num==1))
|
||||
ret0 ^= JoyKeyState;
|
||||
else if ((!Config.JoyKeyJoy2)&&(num==0))
|
||||
ret0 ^= JoyKeyState;
|
||||
}
|
||||
|
||||
ret = ((~JoyPortData[num])&ret0)|(JoyPortData[num]&ret1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void FASTCALL Joystick_Write(BYTE num, BYTE data)
|
||||
{
|
||||
if ( (num==0)||(num==1) ) JoyPortData[num] = data;
|
||||
}
|
||||
|
||||
void FASTCALL Joystick_Update(int is_menu, int key)
|
||||
{
|
||||
BYTE ret0 = 0xff, ret1 = 0xff;
|
||||
BYTE mret0 = 0xff, mret1 = 0xff;
|
||||
int num = 0; //xxx only joy1
|
||||
static BYTE pre_ret0 = 0xff, pre_mret0 = 0xff;
|
||||
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))ret0 ^= JOY_RIGHT;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))ret0 ^= JOY_LEFT;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) )ret0 ^= JOY_UP;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))ret0 ^= JOY_DOWN;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) )ret0 ^= JOY_TRG1;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) )ret0 ^= JOY_TRG2;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT))ret0 ^= JOY_TRG3;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START) )ret0 ^= JOY_TRG4;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X) )ret0 ^= JOY_TRG5;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y) )ret0 ^= JOY_TRG6;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L))ret0 ^= JOY_TRG7;
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R) )ret0 ^= JOY_TRG8;
|
||||
|
||||
JoyDownState0 = ~(ret0 ^ pre_ret0) | ret0;
|
||||
JoyUpState0 = (ret0 ^ pre_ret0) & ret0;
|
||||
pre_ret0 = ret0;
|
||||
|
||||
MouseDownState0 = ~(mret0 ^ pre_mret0) | mret0;
|
||||
MouseUpState0 = (mret0 ^ pre_mret0) & mret0;
|
||||
pre_mret0 = mret0;
|
||||
|
||||
// disable Joystick when software keyboard is active
|
||||
if (!is_menu && !Keyboard_IsSwKeyboard()) {
|
||||
JoyState0[num] = ret0;
|
||||
JoyState1[num] = ret1;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE get_joy_downstate(void)
|
||||
{
|
||||
return JoyDownState0;
|
||||
}
|
||||
void reset_joy_downstate(void)
|
||||
{
|
||||
JoyDownState0 = 0xff;
|
||||
}
|
||||
BYTE get_joy_upstate(void)
|
||||
{
|
||||
return JoyUpState0;
|
||||
}
|
||||
void reset_joy_upstate(void)
|
||||
{
|
||||
JoyUpState0 = 0x00;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef winx68k_joy_h
|
||||
#define winx68k_joy_h
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define JOY_UP 0x01
|
||||
#define JOY_DOWN 0x02
|
||||
#define JOY_LEFT 0x04
|
||||
#define JOY_RIGHT 0x08
|
||||
#define JOY_TRG2 0x20
|
||||
#define JOY_TRG1 0x40
|
||||
|
||||
#define JOY_TRG5 0x01
|
||||
#define JOY_TRG4 0x02
|
||||
#define JOY_TRG3 0x04
|
||||
#define JOY_TRG7 0x08
|
||||
#define JOY_TRG8 0x20
|
||||
#define JOY_TRG6 0x40
|
||||
|
||||
#ifndef PSP
|
||||
#define JOYAXISPLAY 2048
|
||||
#endif
|
||||
|
||||
#define need_Vpad() (is_menu || Keyboard_IsSwKeyboard() || (!Config.JoyOrMouse && !r_joy))
|
||||
|
||||
void Joystick_Init(void);
|
||||
void Joystick_Cleanup(void);
|
||||
BYTE FASTCALL Joystick_Read(BYTE num);
|
||||
void FASTCALL Joystick_Write(BYTE num, BYTE data);
|
||||
|
||||
typedef signed int R_Keycode;
|
||||
void FASTCALL Joystick_Update(int is_menu, R_Keycode key);
|
||||
|
||||
|
||||
BYTE get_joy_downstate(void);
|
||||
void reset_joy_downstate(void);
|
||||
BYTE get_joy_upstate(void);
|
||||
void reset_joy_upstate(void);
|
||||
|
||||
|
||||
extern BYTE JoyKeyState;
|
||||
|
||||
extern int *r_joy;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
/* $Id: juliet.c,v 1.2 2003/12/05 18:07:16 nonaka Exp $ */
|
||||
|
||||
#include "common.h"
|
||||
#include "juliet.h"
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Juliet ダミー
|
||||
*/
|
||||
|
||||
BOOL
|
||||
juliet_load(void)
|
||||
{
|
||||
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
juliet_unload(void)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL
|
||||
juliet_prepare(void)
|
||||
{
|
||||
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---- YM2151部
|
||||
// リセットと同時に、OPMチップの有無も確認
|
||||
void
|
||||
juliet_YM2151Reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
juliet_YM2151IsEnable(void)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
juliet_YM2151IsBusy(void)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
juliet_YM2151W(BYTE reg, BYTE data)
|
||||
{
|
||||
}
|
||||
|
||||
// ---- YMF288部
|
||||
|
||||
void
|
||||
juliet_YMF288Reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
juliet_YM288IsEnable(void)
|
||||
{
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
juliet_YM288IsBusy(void)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
juliet_YMF288A(BYTE addr, BYTE data)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
juliet_YMF288B(BYTE addr, BYTE data)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
juliet_YMF288W(BYTE addr, BYTE data)
|
||||
{
|
||||
}
|
||||
|
||||
BYTE
|
||||
juliet_YMF288R(BYTE addr)
|
||||
{
|
||||
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
#define juliet_load()
|
||||
#define juliet_unload()
|
||||
|
||||
#define juliet_prepare()
|
||||
|
||||
#define juliet_YM2151Reset()
|
||||
#define juliet_YM2151IsEnable() FALSE
|
||||
|
||||
#define juliet_YM2151W(r,d)
|
||||
|
||||
#else
|
||||
|
||||
BOOL juliet_load(void);
|
||||
void juliet_unload(void);
|
||||
|
||||
BOOL juliet_prepare(void);
|
||||
|
||||
void juliet_YM2151Reset(void);
|
||||
int juliet_YM2151IsEnable(void);
|
||||
int juliet_YM2151IsBusy(void);
|
||||
void juliet_YM2151W(BYTE reg, BYTE data);
|
||||
|
||||
void juliet_YMF288Reset(void);
|
||||
int juliet_YMF288Enable(void);
|
||||
int juliet_YMF288IsBusy(void);
|
||||
void juliet_YMF288A(BYTE addr, BYTE data);
|
||||
void juliet_YMF288B(BYTE addr, BYTE data);
|
||||
void juliet_YMF288W(BYTE addr, BYTE data);
|
||||
BYTE juliet_YMF288R(BYTE addr);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,641 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2008 NONAKA Kimihiro
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "joystick.h"
|
||||
#include "prop.h"
|
||||
#include "keyboard.h"
|
||||
#include "mfp.h"
|
||||
#include "windraw.h"
|
||||
|
||||
#include "libretro.h"
|
||||
|
||||
BYTE KeyBufWP;
|
||||
BYTE KeyBufRP;
|
||||
BYTE KeyBuf[KeyBufSize];
|
||||
BYTE KeyEnable = 1;
|
||||
BYTE KeyIntFlag = 0;
|
||||
|
||||
struct keyboard_key kbd_key[] = {
|
||||
#include "keytbl.inc"
|
||||
};
|
||||
|
||||
extern BYTE traceflag;
|
||||
|
||||
void
|
||||
Keyboard_Init(void)
|
||||
{
|
||||
|
||||
KeyBufWP = 0;
|
||||
KeyBufRP = 0;
|
||||
ZeroMemory(KeyBuf, KeyBufSize);
|
||||
KeyEnable = 1;
|
||||
KeyIntFlag = 0;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// てーぶる類
|
||||
// ----------------------------------
|
||||
|
||||
#define NC 0
|
||||
#define KEYTABLE_MAX 512
|
||||
|
||||
|
||||
BYTE KeyTable[KEYTABLE_MAX] = {
|
||||
// , , , , , , , ; 0x00
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// BS, TAB, , , , RET, , ; 0x08
|
||||
0x0f,0x10, NC, NC, NC,0x1d, NC, NC,
|
||||
// , , , , , , , ; 0x10
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , ESC, , , , ; 0x18
|
||||
NC, NC, NC,0x01, NC, NC, NC, NC,
|
||||
// SPC, ! , " , # , $ , % , & , ' ; 0x20
|
||||
0x35,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
// ( , ) , * , + , , , - , . , / ; 0x28
|
||||
0x09,0x0a,0x28,0x27,0x31,0x0c,0x32,0x33,
|
||||
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ; 0x30
|
||||
0x0b,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
// 8 , 9 , ; , : , < , = , > , ? ; 0x38
|
||||
0x09,0x0a,0x28,0x27,0x31,0x0c,0x32,0x33,
|
||||
// @ , A , B , C , D , E , F , G ; 0x40
|
||||
0x1b,0x1e,0x2e,0x2c,0x20,0x13,0x21,0x22,
|
||||
// H , I , J , K , L , M , N , O ; 0x48
|
||||
0x23,0x18,0x24,0x25,0x26,0x30,0x2f,0x10,
|
||||
// P , Q , R , S , T , U , V , W ; 0x50
|
||||
0x1a,0x11,0x14,0x1f,0x15,0x17,0x2d,0x12,
|
||||
// X , Y , Z , [ , \ , ] , ^ , _ ; 0x58
|
||||
0x2b,0x16,0x2a,0x1c,0x0e,0x29,0x0d,0x34,
|
||||
// ` , a , b , c , d , e , f , g ; 0x60
|
||||
0x1b,0x1e,0x2e,0x2c,0x20,0x13,0x21,0x22,
|
||||
// h , i , j , k , l , m , n , o ; 0x68
|
||||
0x23,0x18,0x24,0x25,0x26,0x30,0x2f,0x19,
|
||||
// p , q , r , s , t , u , v , w ; 0x70
|
||||
0x1a,0x11,0x14,0x1f,0x15,0x17,0x2d,0x12,
|
||||
// x , y , z , { , | , } , ~ , ; 0x78
|
||||
0x2b,0x16,0x2a,0x1c,0x0e,0x29,0x0d, NC,
|
||||
// , , , , , , , ; 0x80
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x88
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x90
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x98
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xa0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xa8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xb0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xb8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xc0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xc8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xe0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xe8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
|
||||
// ;0x100
|
||||
|
||||
// , , , , , , , ; 0x00
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// BS, TAB, LF, CLR, , RET, , ; 0x08
|
||||
0x0f,0x10,0x1d, NC, NC,0x1d, NC, NC,
|
||||
// , ↑, ↓, →, ←,SYSQ, , ; 0x10
|
||||
NC,0x3c,0x3e,0x3d,0x3b, NC, NC, NC,
|
||||
// , , , ESC, , , , ; 0x18
|
||||
NC, NC,0x63,0x01, NC, NC, NC, NC,
|
||||
// ,KANJ,MUHE,HENM,HENK,RONM,HIRA,KATA ; 0x20
|
||||
NC, NC,0x56, NC, NC, NC, NC, NC,
|
||||
// HIKA,ZENK,HANK,ZNHN, ,KANA, , ; 0x28
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// SFTL, , , , , , , ; 0x30
|
||||
0x70, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , ,ZKOU,MKOU, ; 0x38
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x40
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x48
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// HOME, ←, ↑, →, ↓,RLDN,RLUP, END ; 0x50
|
||||
0x36,0x3b,0x3c,0x3d,0x3e,0x39,0x38,0x3a,
|
||||
// , , , , , , , ; 0x58
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,PRNT, INS, , , , , ; 0x60
|
||||
NC, NC,0x5e, NC, NC, NC, NC, NC,
|
||||
// , , ,BREA, , , , ; 0x68
|
||||
NC, NC, NC,0x61, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x70
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x78
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// <SPC, , , , , , , ; 0x80
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,<TAB, , , ,<ENT, , ; 0x88
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , ,<HOM,<←>,<↑> ; 0x90
|
||||
NC, NC, NC, NC, NC,0x36,0x3b,0x3c,
|
||||
// <→>,<↓>,<RDN,<RUP,<END, ,<INS,<DEL ; 0x98
|
||||
0x3d,0x3e,0x39,0x38,0x3a, NC,0x5e,0x37,
|
||||
// , , , , , , , ; 0xa0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , <*>, <+>, <,>, <->, <.>, </> ; 0xa8
|
||||
NC, NC,0x41,0x46, NC,0x42,0x51,0x40,
|
||||
// <0>, <1>, <2>, <3>, <4>, <5>, <6>, <7> ; 0xb0
|
||||
0x4f,0x4b,0x4c,0x4d,0x47,0x48,0x49,0x43,
|
||||
// <8>, <9>, , , , , f.1, f.2 ; 0xb8
|
||||
0x44,0x45, NC, NC, NC, NC,0x63,0x64,
|
||||
// f.3, f.4, f.5, f.6, f.7, f.8, f.9,f.10 ; 0xc0
|
||||
0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,
|
||||
// f.11,f.12,f.13,f.14,f.15, , , ; 0xc8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,SFTL,SFTR,CTLL,CTLR,CAPS, ,METL ; 0xe0
|
||||
NC,0x70,0x70,0x71,0x71,0x5d, NC,0x55,
|
||||
// METR,ALTL,ALTR, , , , , ; 0xe8
|
||||
0x55,0x55,0x55, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , DEL ; 0xf8
|
||||
NC, NC, NC, NC, NC, NC, NC,0x37
|
||||
};
|
||||
|
||||
BYTE KeyTableMaster[KEYTABLE_MAX] = {
|
||||
// , , , , , , , ; 0x00
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x08
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x10
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x18
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// SPC, ! , " , # , $ , % , & , ' ; 0x20
|
||||
0x35,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
// ( , ) , * , + , , , - , . , / ; 0x28
|
||||
0x09,0x0a,0x28,0x27,0x31,0x0c,0x32,0x33,
|
||||
// 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ; 0x30
|
||||
0x0b,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
||||
// 8 , 9 , ; , : , < , = , > , ? ; 0x38
|
||||
0x09,0x0a,0x28,0x27,0x31,0x0c,0x32,0x33,
|
||||
// @ , A , B , C , D , E , F , G ; 0x40
|
||||
0x1b,0x1e,0x2e,0x2c,0x20,0x13,0x21,0x22,
|
||||
// H , I , J , K , L , M , N , O ; 0x48
|
||||
0x23,0x18,0x24,0x25,0x26,0x30,0x2f,0x10,
|
||||
// P , Q , R , S , T , U , V , W ; 0x50
|
||||
0x1a,0x11,0x14,0x1f,0x15,0x17,0x2d,0x12,
|
||||
// X , Y , Z , [ , \ , ] , ^ , _ ; 0x58
|
||||
0x2b,0x16,0x2a,0x1c,0x0e,0x29,0x0d,0x34,
|
||||
// ` , a , b , c , d , e , f , g ; 0x60
|
||||
0x1b,0x1e,0x2e,0x2c,0x20,0x13,0x21,0x22,
|
||||
// h , i , j , k , l , m , n , o ; 0x68
|
||||
0x23,0x18,0x24,0x25,0x26,0x30,0x2f,0x19,
|
||||
// p , q , r , s , t , u , v , w ; 0x70
|
||||
0x1a,0x11,0x14,0x1f,0x15,0x17,0x2d,0x12,
|
||||
// x , y , z , { , | , } , ~ , ; 0x78
|
||||
0x2b,0x16,0x2a,0x1c,0x0e,0x29,0x0d, NC,
|
||||
// , , , , , , , ; 0x80
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x88
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x90
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x98
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xa0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xa8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xb0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xb8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xc0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xc8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xe0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xe8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
|
||||
// ;0x100
|
||||
|
||||
// , , , , , , , ; 0x00
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// BS, TAB, LF, CLR, , RET, , ; 0x08
|
||||
0x0f,0x10,0x1d, NC, NC,0x1d, NC, NC,
|
||||
// , , ,PAUS,SCRL,SYSQ, , ; 0x10
|
||||
NC, NC, NC,0x61, NC, NC, NC, NC,
|
||||
// , , , ESC, , , , ; 0x18
|
||||
NC, NC,0x63,0x01, NC, NC, NC, NC,
|
||||
// ,KANJ,MUHE,HENM,HENK,RONM,HIRA,KATA ; 0x20
|
||||
NC, NC,0x56, NC, NC, NC, NC, NC,
|
||||
// HIKA,ZENK,HANK,ZNHN, ,KANA, , ; 0x28
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ALNU, , , , , , , ; 0x30
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , ,ZKOU,MKOU, ; 0x38
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x40
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x48
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// HOME, ←, ↑, →, ↓,RLDN,RLUP, END ; 0x50
|
||||
0x36, NC, NC, NC, NC,0x39,0x38,0x3a,
|
||||
// , , , , , , , ; 0x58
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,PRNT, INS, , , , , ; 0x60
|
||||
NC, NC,0x5e, NC, NC, NC, NC, NC,
|
||||
// , , ,BREA, , , , ; 0x68
|
||||
NC, NC, NC,0x61, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x70
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0x78
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// <SPC, , , , , , , ; 0x80
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,<TAB, , , ,<ENT, , ; 0x88
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , ,<HOM,<←>,<↑> ; 0x90
|
||||
NC, NC, NC, NC, NC,0x36, NC, NC,
|
||||
// <→>,<↓>,<RDN,<RUP,<END, ,<INS,<DEL ; 0x98
|
||||
NC, NC,0x39,0x38,0x3a, NC,0x5e,0x37,
|
||||
// , , , , , , , ; 0xa0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , <*>, <+>, <,>, <->, <.>, </> ; 0xa8
|
||||
NC, NC,0x41,0x46, NC,0x42, NC,0x40,
|
||||
// <0>, <1>, <2>, <3>, <4>, <5>, <6>, <7> ; 0xb0
|
||||
0x4f,0x4b,0x4c,0x4d,0x47,0x48,0x49,0x43,
|
||||
// <8>, <9>, , , , , f.1, f.2 ; 0xb8
|
||||
0x44,0x45, NC, NC, NC, NC,0x63,0x64,
|
||||
// f.3, f.4, f.5, f.6, f.7, f.8, f.9,f.10 ; 0xc0
|
||||
0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,
|
||||
// f.11,f.12,f.13,f.14,f.15, , , ; 0xc8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xd8
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// ,SFTL,SFTR,CTLL,CTLR,CAPS, ,METL ; 0xe0
|
||||
NC,0x70,0x70,0x71,0x71,0x5d, NC,0x55,
|
||||
// METR,ALTL,ALTR, , , , , ; 0xe8
|
||||
0x55,0x55,0x55, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , ; 0xf0
|
||||
NC, NC, NC, NC, NC, NC, NC, NC,
|
||||
// , , , , , , , DEL ; 0xf8
|
||||
NC, NC, NC, NC, NC, NC, NC,0x37
|
||||
};
|
||||
|
||||
// P6K: PX68K_KEYBOARD
|
||||
// ~ ~ ~
|
||||
#define P6K_UP 1
|
||||
#define P6K_DOWN 2
|
||||
|
||||
void send_keycode(BYTE code, int flag)
|
||||
{
|
||||
BYTE newwp;
|
||||
|
||||
if (code != NC) {
|
||||
newwp = ((KeyBufWP + 1) & (KeyBufSize - 1));
|
||||
if (newwp != KeyBufRP) {
|
||||
KeyBuf[KeyBufWP] = code | ((flag == P6K_UP)? 0x80 : 0);
|
||||
p6logd("KeyBuf: %x\n", KeyBuf[KeyBufWP]);
|
||||
KeyBufWP = newwp;
|
||||
p6logd("KeyBufWP: %d\n", KeyBufWP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static BYTE get_x68k_keycode(DWORD wp)
|
||||
{
|
||||
if (wp < KEYTABLE_MAX) {
|
||||
return KeyTable[wp];
|
||||
}
|
||||
|
||||
switch (wp) {
|
||||
case RETROK_UP:
|
||||
return 0x3c;
|
||||
case RETROK_DOWN:
|
||||
return 0x3e;
|
||||
case RETROK_LEFT:
|
||||
return 0x3b;
|
||||
case RETROK_RIGHT:
|
||||
return 0x3d;
|
||||
|
||||
#define RETROK_KP_0 RETROK_KP0
|
||||
#define RETROK_KP_1 RETROK_KP1
|
||||
#define RETROK_KP_2 RETROK_KP2
|
||||
#define RETROK_KP_3 RETROK_KP3
|
||||
#define RETROK_KP_4 RETROK_KP4
|
||||
#define RETROK_KP_5 RETROK_KP5
|
||||
#define RETROK_KP_6 RETROK_KP6
|
||||
#define RETROK_KP_7 RETROK_KP7
|
||||
#define RETROK_KP_8 RETROK_KP8
|
||||
#define RETROK_KP_9 RETROK_KP9
|
||||
#define RETROK_NUMLOCKCLEAR RETROK_NUMLOCK
|
||||
|
||||
case RETROK_KP_0:
|
||||
return 0x4f;
|
||||
case RETROK_KP_1:
|
||||
return 0x4b;
|
||||
case RETROK_KP_2:
|
||||
return 0x4c;
|
||||
case RETROK_KP_3:
|
||||
return 0x4d;
|
||||
case RETROK_KP_4:
|
||||
return 0x47;
|
||||
case RETROK_KP_5:
|
||||
return 0x48;
|
||||
case RETROK_KP_6:
|
||||
return 0x49;
|
||||
case RETROK_KP_7:
|
||||
return 0x43;
|
||||
case RETROK_KP_8:
|
||||
return 0x44;
|
||||
case RETROK_KP_9:
|
||||
return 0x45;
|
||||
case RETROK_NUMLOCKCLEAR:
|
||||
return 0x3f;
|
||||
|
||||
case RETROK_F1:
|
||||
return 0x63;
|
||||
case RETROK_F2:
|
||||
return 0x64;
|
||||
case RETROK_F3:
|
||||
return 0x65;
|
||||
case RETROK_F4:
|
||||
return 0x66;
|
||||
case RETROK_F5:
|
||||
return 0x67;
|
||||
case RETROK_F6:
|
||||
return 0x68;
|
||||
case RETROK_F7:
|
||||
return 0x69;
|
||||
case RETROK_F8:
|
||||
return 0x6a;
|
||||
case RETROK_F9:
|
||||
return 0x6b;
|
||||
case RETROK_F10:
|
||||
return 0x6c;
|
||||
case RETROK_LSHIFT:
|
||||
case RETROK_RSHIFT:
|
||||
return 0x70;
|
||||
case RETROK_LCTRL:
|
||||
case RETROK_RCTRL:
|
||||
return 0x71;
|
||||
case RETROK_KP_DIVIDE:
|
||||
return 0x40;
|
||||
case RETROK_KP_MULTIPLY:
|
||||
return 0x41;
|
||||
case RETROK_KP_MINUS:
|
||||
return 0x42;
|
||||
case RETROK_KP_PLUS:
|
||||
return 0x46;
|
||||
case RETROK_KP_ENTER:
|
||||
return 0x4e;
|
||||
case RETROK_INSERT:
|
||||
return 0x5e;
|
||||
case RETROK_HOME:
|
||||
return 0x36;
|
||||
case RETROK_END:
|
||||
return 0x3a;
|
||||
case RETROK_PAGEUP:
|
||||
return 0x38;
|
||||
case RETROK_PAGEDOWN:
|
||||
return 0x39;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// WM_KEYDOWN~
|
||||
// ----------------------------------
|
||||
void
|
||||
Keyboard_KeyDown(DWORD wp)
|
||||
{
|
||||
|
||||
BYTE code;
|
||||
BYTE newwp;
|
||||
#if 0
|
||||
if (wp & ~0xff) {
|
||||
if (wp == GDK_VoidSymbol)
|
||||
code = NC;
|
||||
else if ((wp & 0xff00) == 0xff00)
|
||||
code = KeyTable[(wp & 0xff) | 0x100];
|
||||
else
|
||||
code = NC;
|
||||
} else
|
||||
code = KeyTable[wp & 0xff];
|
||||
#endif
|
||||
code = get_x68k_keycode(wp);
|
||||
if (code < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Keyboard_KeyDown: ");
|
||||
printf("wp=0x%x, code=0x%x\n", wp, code);
|
||||
printf("RETROK_UP: 0x%x", RETROK_UP);
|
||||
|
||||
#if 0
|
||||
if (code != NC) {
|
||||
newwp = ((KeyBufWP + 1) & (KeyBufSize - 1));
|
||||
if (newwp != KeyBufRP) {
|
||||
KeyBuf[KeyBufWP] = code;
|
||||
KeyBufWP = newwp;
|
||||
printf("KeyBufWP: %d\n", KeyBufWP);
|
||||
}
|
||||
}
|
||||
#else
|
||||
send_keycode(code, P6K_DOWN);
|
||||
#endif
|
||||
|
||||
printf("JoyKeyState: 0x%x\n", JoyKeyState);
|
||||
|
||||
switch (wp) {
|
||||
case RETROK_UP:
|
||||
puts("key up");
|
||||
if (!(JoyKeyState&JOY_DOWN))
|
||||
JoyKeyState |= JOY_UP;
|
||||
break;
|
||||
|
||||
case RETROK_DOWN:
|
||||
if (!(JoyKeyState&JOY_UP))
|
||||
JoyKeyState |= JOY_DOWN;
|
||||
break;
|
||||
|
||||
case RETROK_LEFT:
|
||||
if (!(JoyKeyState&JOY_RIGHT))
|
||||
JoyKeyState |= JOY_LEFT;
|
||||
break;
|
||||
|
||||
case RETROK_RIGHT:
|
||||
if (!(JoyKeyState&JOY_LEFT))
|
||||
JoyKeyState |= JOY_RIGHT;
|
||||
break;
|
||||
|
||||
case RETROK_z:
|
||||
puts("key z");
|
||||
if (Config.JoyKeyReverse)
|
||||
JoyKeyState |= JOY_TRG2;
|
||||
else
|
||||
JoyKeyState |= JOY_TRG1;
|
||||
break;
|
||||
|
||||
case RETROK_x:
|
||||
puts("key x");
|
||||
if (Config.JoyKeyReverse)
|
||||
JoyKeyState |= JOY_TRG1;
|
||||
else
|
||||
JoyKeyState |= JOY_TRG2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// WM_KEYUP
|
||||
// ----------------------------------
|
||||
void
|
||||
Keyboard_KeyUp(DWORD wp)
|
||||
{
|
||||
BYTE code;
|
||||
BYTE newwp;
|
||||
#if 0
|
||||
if (wp & ~0xff) {
|
||||
if (wp == GDK_VoidSymbol)
|
||||
code = NC;
|
||||
else if ((wp & 0xff00) == 0xff00)
|
||||
code = KeyTable[(wp & 0xff) | 0x100];
|
||||
else
|
||||
code = NC;
|
||||
} else
|
||||
code = KeyTable[wp & 0xff];
|
||||
#endif
|
||||
code = get_x68k_keycode(wp);
|
||||
if (code < 0) {
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
if (code != NC) {
|
||||
newwp = ((KeyBufWP + 1) & (KeyBufSize - 1));
|
||||
if (newwp != KeyBufRP) {
|
||||
KeyBuf[KeyBufWP] = code | 0x80;
|
||||
KeyBufWP = newwp;
|
||||
}
|
||||
}
|
||||
#else
|
||||
send_keycode(code, P6K_UP);
|
||||
#endif
|
||||
|
||||
printf("JoyKeyState: 0x%x\n", JoyKeyState);
|
||||
|
||||
switch(wp) {
|
||||
case RETROK_UP:
|
||||
JoyKeyState &= ~JOY_UP;
|
||||
break;
|
||||
|
||||
case RETROK_DOWN:
|
||||
JoyKeyState &= ~JOY_DOWN;
|
||||
break;
|
||||
|
||||
case RETROK_LEFT:
|
||||
JoyKeyState &= ~JOY_LEFT;
|
||||
break;
|
||||
|
||||
case RETROK_RIGHT:
|
||||
JoyKeyState &= ~JOY_RIGHT;
|
||||
break;
|
||||
|
||||
case RETROK_z:
|
||||
if (Config.JoyKeyReverse)
|
||||
JoyKeyState &= ~JOY_TRG2;
|
||||
else
|
||||
JoyKeyState &= ~JOY_TRG1;
|
||||
break;
|
||||
|
||||
case RETROK_x:
|
||||
if (Config.JoyKeyReverse)
|
||||
JoyKeyState &= ~JOY_TRG1;
|
||||
else
|
||||
JoyKeyState &= ~JOY_TRG2;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// Key Check
|
||||
// 1フレーム中に4回(2400bps/10bit/60fpsとすれば、だが)呼ばれて、MFPにデータを送る
|
||||
// ----------------------------------
|
||||
|
||||
void
|
||||
Keyboard_Int(void)
|
||||
{
|
||||
if (KeyBufRP != KeyBufWP) {
|
||||
printf("KeyBufRP:%d, KeyBufWP:%d\n", KeyBufRP, KeyBufWP);
|
||||
if (!KeyIntFlag) {
|
||||
LastKey = KeyBuf[KeyBufRP];
|
||||
KeyBufRP = ((KeyBufRP+1)&(KeyBufSize-1));
|
||||
KeyIntFlag = 1;
|
||||
MFP_Int(3);
|
||||
}
|
||||
} else if (!KeyIntFlag) {
|
||||
LastKey = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/********** ソフトウェアキーボード **********/
|
||||
|
||||
|
||||
int Keyboard_IsSwKeyboard(void)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _winx68k_keyboard
|
||||
#define _winx68k_keyboard
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define KeyBufSize 128
|
||||
|
||||
extern BYTE KeyBuf[KeyBufSize];
|
||||
extern BYTE KeyBufWP;
|
||||
extern BYTE KeyBufRP;
|
||||
extern BYTE KeyTable[512];
|
||||
extern BYTE KeyTableMaster[512];
|
||||
extern BYTE KeyEnable;
|
||||
extern BYTE KeyIntFlag;
|
||||
|
||||
struct keyboard_key {
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
char *s;
|
||||
unsigned char c;
|
||||
};
|
||||
|
||||
extern struct keyboard_key kbd_key[];
|
||||
extern int kbd_kx, kbd_ky;
|
||||
extern int kbd_x, kbd_y, kbd_w, kbd_h;
|
||||
|
||||
void Keyboard_Init(void);
|
||||
void Keyboard_KeyDown(DWORD vkcode);
|
||||
void Keyboard_KeyUp(DWORD vkcode);
|
||||
void Keyboard_Int(void);
|
||||
void send_keycode(BYTE code, int flag);
|
||||
int Keyboard_get_key_ptr(int x, int y);
|
||||
void Keyboard_skbd(void);
|
||||
int Keyboard_IsSwKeyboard(void);
|
||||
void Keyboard_ToggleSkbd(void);
|
||||
|
||||
#endif //_winx68k_keyboard
|
||||
@@ -0,0 +1,68 @@
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// KEYCONF.C - KeyConfig ÆþÎÏÂÔ¤Á¥À¥¤¥¢¥í¥°
|
||||
// ---------------------------------------------------------------------------------------
|
||||
#include "common.h"
|
||||
#include "resource.h"
|
||||
#include "keyconf.h"
|
||||
#include "winx68k.h"
|
||||
|
||||
HWND hWndKeyConf = NULL;
|
||||
WORD KeyConf_CodeW = 0;
|
||||
DWORD KeyConf_CodeL = 0;
|
||||
char KeyConfMessage[255];
|
||||
int KeyConfFlag = 0;
|
||||
|
||||
|
||||
LRESULT CALLBACK KeyConfProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// if (!KeyConfFlag) SetFocus(hWndKeyConf);
|
||||
KeyConfFlag = 1;
|
||||
KeyConf_CodeW = 0;
|
||||
KeyConf_CodeL = 0;
|
||||
// SetDlgItemText(hdlg, IDC_KEYCONF_DLG, KeyConfMessage);
|
||||
//ShowWindow(hdlg, SW_HIDE);
|
||||
return 0;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (IDCANCEL == LOWORD(wp))
|
||||
{
|
||||
EndDialog(hdlg, TRUE);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_SYSCOMMAND:
|
||||
return TRUE;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
SetFocus(hWndKeyConf);
|
||||
break;
|
||||
|
||||
// case WM_CLOSE:
|
||||
// EndDialog(hdlg, FALSE);
|
||||
// return TRUE;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
if (wp==VK_F12)
|
||||
{
|
||||
EndDialog(hdlg, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
// Error("Key Pressed.");
|
||||
KeyConf_CodeW = wp;
|
||||
KeyConf_CodeL = lp;
|
||||
EndDialog(hdlg, TRUE);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
// SetFocus(hWndKeyConf);
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef _x68_keyconf
|
||||
#define _x68_keyconf
|
||||
|
||||
extern HWND hWndKeyConf;
|
||||
extern WORD KeyConf_CodeW;
|
||||
extern DWORD KeyConf_CodeL;
|
||||
extern char KeyConfMessage[255];
|
||||
LRESULT CALLBACK KeyConfProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||
|
||||
#endif // _x68_keyconf
|
||||
@@ -0,0 +1,115 @@
|
||||
{ 2, 2, 32, 32, "BRK", 0x61},
|
||||
{ 40, 2, 32, 32, "CPY", 0x62},
|
||||
{ 86, 16, 40, 18, "F 1", 0x63},
|
||||
{128, 16, 40, 18, "F 2", 0x64},
|
||||
{170, 16, 40, 18, "F 3", 0x65},
|
||||
{212, 16, 40, 18, "F 4", 0x66},
|
||||
{254, 16, 40, 18, "F 5", 0x67},
|
||||
{302, 16, 40, 18, "F 6", 0x68},
|
||||
{344, 16, 40, 18, "F 7", 0x69},
|
||||
{386, 16, 40, 18, "F 8", 0x6a},
|
||||
{428, 16, 40, 18, "F 9", 0x6b},
|
||||
{470, 16, 40, 18, "F10", 0x6c},
|
||||
{520, 2, 32, 32, "KAN", 0x5a},
|
||||
{554, 2, 32, 32, "ROM", 0x5b},
|
||||
{588, 2, 32, 32, "COD", 0x5c},
|
||||
{630, 2, 32, 32, "CAP", 0x5d},
|
||||
{664, 2, 32, 32, "KIG", 0x52},
|
||||
{698, 2, 32, 32, "TOR", 0x53},
|
||||
{732, 2, 32, 32, "HLP", 0x54},
|
||||
{ 2, 48, 32, 32, "ESC", 0x1},
|
||||
{ 36, 48, 32, 32, "1", 0x2},
|
||||
{ 70, 48, 32, 32, "2", 0x3},
|
||||
{104, 48, 32, 32, "3", 0x4},
|
||||
{138, 48, 32, 32, "4", 0x5},
|
||||
{172, 48, 32, 32, "5", 0x6},
|
||||
{206, 48, 32, 32, "6", 0x7},
|
||||
{240, 48, 32, 32, "7", 0x8},
|
||||
{274, 48, 32, 32, "8", 0x9},
|
||||
{308, 48, 32, 32, "9", 0xa},
|
||||
{342, 48, 32, 32, "0", 0xb},
|
||||
{376, 48, 32, 32, "-", 0xc},
|
||||
{410, 48, 32, 32, "^", 0xd},
|
||||
{444, 48, 32, 32, "\\", 0xe},
|
||||
{478, 48, 32, 32, "BS", 0xf},
|
||||
{520, 48, 32, 32, "HOM", 0x36},
|
||||
{554, 48, 32, 32, "INS", 0x5e},
|
||||
{588, 48, 32, 32, "DEL", 0x37},
|
||||
{630, 48, 32, 32, "CLR", 0x3f},
|
||||
{664, 48, 32, 32, "/", 0x40},
|
||||
{698, 48, 32, 32, "*", 0x41},
|
||||
{732, 48, 32, 32, "-", 0x42},
|
||||
{ 2, 82, 44, 32, "TAB", 0x10},
|
||||
{ 48, 82, 32, 32, "Q", 0x11},
|
||||
{ 82, 82, 32, 32, "W", 0x12},
|
||||
{116, 82, 32, 32, "E", 0x13},
|
||||
{150, 82, 32, 32, "R", 0x14},
|
||||
{184, 82, 32, 32, "T", 0x15},
|
||||
{218, 82, 32, 32, "Y", 0x16},
|
||||
{252, 82, 32, 32, "U", 0x17},
|
||||
{286, 82, 32, 32, "I", 0x18},
|
||||
{320, 82, 32, 32, "O", 0x19},
|
||||
{354, 82, 32, 32, "P", 0x1a},
|
||||
{388, 82, 32, 32, "@", 0x1b},
|
||||
{422, 82, 32, 32, "[", 0x1c},
|
||||
{456, 82, 32, 32, "", 0x0},
|
||||
{468, 82, 42, 66, "RET", 0x1d},
|
||||
{520, 82, 32, 32, "RUP", 0x38},
|
||||
{554, 82, 32, 32, "RDN", 0x39},
|
||||
{588, 82, 32, 32, "UND", 0x3a},
|
||||
{630, 82, 32, 32, "7", 0x43},
|
||||
{664, 82, 32, 32, "8", 0x44},
|
||||
{698, 82, 32, 32, "9", 0x45},
|
||||
{732, 82, 32, 32, "+", 0x46},
|
||||
{ 2, 116, 56, 32, "CTRL", 0x71},
|
||||
{ 60, 116, 32, 32, "A", 0x1e},
|
||||
{ 94, 116, 32, 32, "S", 0x1f},
|
||||
{128, 116, 32, 32, "D", 0x20},
|
||||
{162, 116, 32, 32, "F", 0x21},
|
||||
{196, 116, 32, 32, "G", 0x22},
|
||||
{230, 116, 32, 32, "H", 0x23},
|
||||
{264, 116, 32, 32, "J", 0x24},
|
||||
{298, 116, 32, 32, "K", 0x25},
|
||||
{332, 116, 32, 32, "L", 0x26},
|
||||
{366, 116, 32, 32, ";", 0x27},
|
||||
{400, 116, 32, 32, ":", 0x28},
|
||||
{434, 116, 32, 32, "]", 0x29},
|
||||
{554, 116, 32, 32, "up", 0x3c},
|
||||
{630, 116, 32, 32, "4", 0x47},
|
||||
{664, 116, 32, 32, "5", 0x48},
|
||||
{698, 116, 32, 32, "6", 0x49},
|
||||
{732, 116, 32, 32, "=", 0x4a},
|
||||
{ 2, 150, 68, 32, "SHIFT", 0x70},
|
||||
{ 72, 150, 32, 32, "Z", 0x2a},
|
||||
{106, 150, 32, 32, "X", 0x2b},
|
||||
{140, 150, 32, 32, "C", 0x2c},
|
||||
{174, 150, 32, 32, "V", 0x2d},
|
||||
{208, 150, 32, 32, "B", 0x2e},
|
||||
{242, 150, 32, 32, "N", 0x2f},
|
||||
{276, 150, 32, 32, "M", 0x30},
|
||||
{310, 150, 32, 32, ",", 0x31},
|
||||
{344, 150, 32, 32, ".", 0x32},
|
||||
{378, 150, 32, 32, "/", 0x33},
|
||||
{412, 150, 32, 32, " ", 0x34},
|
||||
{446, 150, 64, 32, "SHIFT", 0x70},
|
||||
{520, 132, 32, 32, "left", 0x3b},
|
||||
{554, 150, 32, 32, "down", 0x3e},
|
||||
{588, 132, 32, 32, "rigt", 0x3d},
|
||||
{630, 150, 32, 32, "1", 0x4b},
|
||||
{664, 150, 32, 32, "2", 0x4c},
|
||||
{698, 150, 32, 32, "3", 0x4d},
|
||||
{732, 150, 32, 66, "ENT", 0x4e},
|
||||
{ 60, 184, 32, 32, "HIR", 0x5f},
|
||||
{ 94, 184, 38, 32, "XF1", 0x55},
|
||||
{134, 184, 38, 32, "XF2", 0x56},
|
||||
{174, 184, 128, 32, "", 0x35},
|
||||
{304, 184, 38, 32, "XF3", 0x57},
|
||||
{344, 184, 42, 32, "XF4", 0x58},
|
||||
{388, 184, 42, 32, "XF5", 0x59},
|
||||
{432, 184, 32, 32, "ZEN", 0x60},
|
||||
{520, 184, 48, 32, "OPT1", 0x72},
|
||||
{572, 184, 48, 32, "OPT2", 0x73},
|
||||
{630, 184, 32, 32, "0", 0x4f},
|
||||
{664, 184, 32, 32, ",", 0x50},
|
||||
{698, 184, 32, 32, ".", 0x51},
|
||||
{-1, -1, -1, -1, NULL}
|
||||
@@ -0,0 +1,32 @@
|
||||
char twaku_str[] = "┏━━━━━━━━━━━━━━━━━━━━━━━━━┓";
|
||||
char twaku2_str[] = "┃ ┃";
|
||||
char twaku3_str[] = "┗━━━━━━━━━━━━━━━━━━━━━━━━━┛";
|
||||
|
||||
char title_str[] = "SWITCH for PX68K Version ";
|
||||
|
||||
char pc98_title1_str[] = "SWITCHコマンド Ver. ";
|
||||
char pc98_title2_str[] = "──────────────── Copyright (C) hissorii 2013";
|
||||
char pc98_title3_str[] = " (現在の設定値)";
|
||||
|
||||
|
||||
char waku_val_str[][10] = {"キーワード", "現在値"};
|
||||
|
||||
char waku_str[] = "┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓";
|
||||
char waku2_str[] = "┃ ┃ ┃";
|
||||
char waku3_str[] = "┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━┛";
|
||||
|
||||
char swaku_str[] = "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓";
|
||||
char swaku2_str[] = "┃ ┃";
|
||||
char swaku3_str[] = "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
|
||||
|
||||
char item_cap[][60] = {"システムを[リセット/NMIリセット/終了]します", "[仮想パッド/仮想マウス]を選択します", "フロッピー0の[入れ替え/イジェクト]をします", "フロッピー1の[入れ替え/イジェクト]をします", "ハードディスク0の[入れ替え/イジェクト]をします", "ハードディスク1の[入れ替え/イジェクト]をします", "フレームスキップを設定します", "サウンドの出力周波数を設定します(次回起動時に有効)", "仮想パッド、仮想ボタンの大きさを調整します", "仮想ボタンの位置を交換します", "物理Padの設定をします", "No Wait Modeを設定します", "JoyKeyを設定します"};
|
||||
|
||||
#if defined (PSP)
|
||||
#define CAP_BTN_STR "[○]ボタン"
|
||||
#elif defined (ANDROID)
|
||||
#define CAP_BTN_STR "[TRG1]ボタン"
|
||||
#else
|
||||
#define CAP_BTN_STR "[リターン]キー"
|
||||
#endif
|
||||
|
||||
char item_cap2[][50] = {"↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択し、"CAP_BTN_STR"で実行してください", "↑↓で選択してください", "↑↓で選択してください。", "↑↓で選択してください", "↑↓で選択してください", "↑↓で選択後、物理パッドの設定をしてください", "↑↓で選択してください", "↑↓で選択してください"};
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
x11/keytbl.inc を生成するツールプログラム
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// 0xff: 終端, 0xfe, 増加繰り返し, 0x0: ダミーキー(リターンキーの装飾用)
|
||||
unsigned char code_tbl[] = {
|
||||
0xfe, 0x61, 12, 0xfe, 0x5a, 4, 0xfe, 0x52, 3,
|
||||
0xfe, 0x01, 15, 0x36, 0x5e, 0x37, 0x3f, 0xfe, 0x40, 3,
|
||||
0xfe, 0x10, 13, 0x0, 0x1d, 0xfe, 0x38, 3, 0xfe, 0x43, 4,
|
||||
0x71, 0xfe, 0x1e, 12, 0x3c, 0xfe, 0x47, 4,
|
||||
0x70, 0xfe, 0x2a, 11, 0x70, 0x3b, 0x3e, 0x3d, 0xfe, 0x4b, 4,
|
||||
0x5f, 0x55, 0x56, 0x35, 0xfe, 0x57, 3, 0x60, 0x72, 0x73, 0xfe, 0x4f, 3
|
||||
};
|
||||
|
||||
int ct_ptr = 0;
|
||||
unsigned char get_code(void)
|
||||
{
|
||||
static int cnt = 0;
|
||||
static unsigned char cc;
|
||||
unsigned char c;
|
||||
|
||||
if (cnt > 0) {
|
||||
cnt--;
|
||||
return cc++;
|
||||
}
|
||||
|
||||
c = code_tbl[ct_ptr++];
|
||||
|
||||
if (c == 0xfe) {
|
||||
cc = code_tbl[ct_ptr++];
|
||||
cnt = code_tbl[ct_ptr++];
|
||||
return get_code();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void prt_tbl(int x, int y, int w, int h, char *s)
|
||||
{
|
||||
printf("{%3d, %3d, %3d, %3d, \"%s\", 0x%x},\n",
|
||||
x, y, w, h, s, get_code());
|
||||
}
|
||||
void prt_tblc(int x, int y, int w, int h, char c)
|
||||
{
|
||||
printf("{%3d, %3d, %3d, %3d, \"%c\", 0x%x},\n",
|
||||
x, y, w, h, c, get_code());
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
int x, y, w, h, i;
|
||||
char s[256];
|
||||
char str[][10] = {"KAN", "ROM", "COD", "CAP", "KIG", "TOR", "HLP", //0
|
||||
"HOM", "INS", "DEL", "CLR", "/", "*", "-", // 7
|
||||
"RUP", "RDN", "UND", "7", "8", "9", "+", // 14
|
||||
"4", "5", "6", "=", // 21
|
||||
"1", "2", "3", // 25
|
||||
"0", ",", ".", // 28
|
||||
};
|
||||
|
||||
char c[] = "1234567890-^QWERTYUIOP@[ASDFGHJKL;:]ZXCVBNM,./ ";
|
||||
|
||||
char *p[10];
|
||||
|
||||
// 1列目
|
||||
|
||||
w = 32;
|
||||
h = 32;
|
||||
strcpy(s, "BRK");
|
||||
prt_tbl(2, 2, w, h, s);
|
||||
|
||||
strcpy(s, "CPY");
|
||||
prt_tbl(40, 2, w, h, s);
|
||||
|
||||
// function keys
|
||||
y = 16;
|
||||
w = 40;
|
||||
h = 18;
|
||||
for (i = 0; i < 5; i++) {
|
||||
sprintf(s, "F%2d", i + 1);
|
||||
prt_tbl(86 + (w + 2) * i, y, w, h, s);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
sprintf(s, "F%2d", i + 6);
|
||||
prt_tbl(302 + (w + 2) * i, y, w, h, s);
|
||||
}
|
||||
|
||||
y = 2;
|
||||
w = 32;
|
||||
h = 32;
|
||||
for (i = 0; i < 3; i++) {
|
||||
prt_tbl(520 + (w + 2) * i, y, w, h, str[i]);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 3]);
|
||||
}
|
||||
|
||||
// 2列目
|
||||
|
||||
y = 48;
|
||||
|
||||
prt_tbl(2, y, w, h, "ESC");
|
||||
for (i = 0; i < 12; i++) {
|
||||
prt_tblc(36 + (w + 2) * i, y, w, h, c[i]);
|
||||
}
|
||||
prt_tbl(444, y, w, h, "\\\\");
|
||||
prt_tbl(478, y, w, h, "BS");
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
prt_tbl(520 + (w + 2) * i, y, w, h, str[i + 7]);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 10]);
|
||||
}
|
||||
|
||||
// 3列目
|
||||
|
||||
y = 82;
|
||||
|
||||
prt_tbl(2, y, 44, 32, "TAB");
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
prt_tblc(48 + (w + 2) * i, y, w, h, c[i + 12]);
|
||||
}
|
||||
prt_tbl(456, y, w, h, "");
|
||||
prt_tbl(468, y, 42, 66, "RET");
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
prt_tbl(520 + (w + 2) * i, y, w, h, str[i + 14]);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 17]);
|
||||
}
|
||||
|
||||
|
||||
// 4列目
|
||||
|
||||
y = 116;
|
||||
|
||||
prt_tbl(2, y, 56, 32, "CTRL");
|
||||
|
||||
for (i = 0; i < 12; i++) {
|
||||
prt_tblc(60 + (w + 2) * i, y, w, h, c[i + 24]);
|
||||
}
|
||||
|
||||
prt_tbl(554, y, 32, 32, "up");
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 21]);
|
||||
}
|
||||
|
||||
// 5列目
|
||||
|
||||
y = 150;
|
||||
|
||||
prt_tbl(2, y, 68, 32, "SHIFT");
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
prt_tblc(72 + (w + 2) * i, y, w, h, c[i + 36]);
|
||||
}
|
||||
|
||||
prt_tbl(446, y, 64, 32, "SHIFT");
|
||||
|
||||
prt_tbl(520, 132, 32, 32, "left"); // left cursor
|
||||
prt_tbl(554, y, 32, 32, "down"); // down cursor
|
||||
prt_tbl(588, 132, 32, 32, "rigt"); // right cursor
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 25]);
|
||||
}
|
||||
|
||||
prt_tbl(732, y, 32, 66, "ENT");
|
||||
|
||||
// 6列目
|
||||
|
||||
y = 184;
|
||||
|
||||
prt_tbl(60, y, 32, 32, "HIR");
|
||||
prt_tbl(94, y, 38, 32, "XF1");
|
||||
prt_tbl(134, y, 38, 32, "XF2");
|
||||
prt_tbl(174, y, 128, 32, "");
|
||||
prt_tbl(304, y, 38, 32, "XF3");
|
||||
prt_tbl(344, y, 42, 32, "XF4");
|
||||
prt_tbl(388, y, 42, 32, "XF5");
|
||||
prt_tbl(432, y, 32, 32, "ZEN");
|
||||
|
||||
prt_tbl(520, y, 48, 32, "OPT1");
|
||||
prt_tbl(572, y, 48, 32, "OPT2");
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
prt_tbl(630 + (w + 2) * i, y, w, h, str[i + 28]);
|
||||
}
|
||||
|
||||
// 終端
|
||||
printf("{-1, -1, -1, -1, NULL}\n");
|
||||
}
|
||||
+1102
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
|
||||
// X68KのCGROMを作る
|
||||
// buf: 作る領域 (0xc0000バイト分のバッファ)
|
||||
// x68030: X68030フォントを作るか? (現在無効)
|
||||
// primaryface: 書体1 (主に16ドット用)
|
||||
// secondaryface: 書体2 (主に24ドット用)
|
||||
//
|
||||
// 戻り値: FALSE: 失敗, TRUE: 成功
|
||||
|
||||
|
||||
int make_cgromdat(BYTE *buf, int x68030, LPSTR primaryface, LPSTR secondaryface);
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2008 NONAKA Kimihiro
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "winx68k.h"
|
||||
#include "prop.h"
|
||||
#include "scc.h"
|
||||
#include "crtc.h"
|
||||
#include "mouse.h"
|
||||
|
||||
float MouseDX = 0;
|
||||
float MouseDY = 0;
|
||||
BYTE MouseStat = 0;
|
||||
BYTE MouseSW = 0;
|
||||
|
||||
POINT CursorPos;
|
||||
int mousex = 0, mousey = 0;
|
||||
|
||||
#if 0
|
||||
static GdkPixmap *cursor_pixmap;
|
||||
static GdkCursor *cursor;
|
||||
|
||||
static void getmaincenter(GtkWidget *w, POINT *p);
|
||||
void gdk_window_set_pointer(GdkWindow *window, gint x, gint y);
|
||||
#endif
|
||||
|
||||
void Mouse_Init(void)
|
||||
{
|
||||
if (Config.JoyOrMouse) {
|
||||
Mouse_StartCapture(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// Mouse Event Occured
|
||||
// ----------------------------------
|
||||
void Mouse_Event(int param, float dx, float dy)
|
||||
{
|
||||
//printf("ME(): %f %f\n", dx, dy);
|
||||
|
||||
if (MouseSW) {
|
||||
switch (param) {
|
||||
case 0: // mouse move
|
||||
MouseDX += dx;
|
||||
MouseDY += dy;
|
||||
break;
|
||||
case 1: // left button
|
||||
if (dx != 0)
|
||||
MouseStat |= 1;
|
||||
else
|
||||
MouseStat &= 0xfe;
|
||||
break;
|
||||
case 2: // right button
|
||||
if (dx != 0)
|
||||
MouseStat |= 2;
|
||||
else
|
||||
MouseStat &= 0xfd;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// Mouse Data send to SCC
|
||||
// ----------------------------------
|
||||
void Mouse_SetData(void)
|
||||
{
|
||||
POINT pt;
|
||||
int x, y;
|
||||
|
||||
if (MouseSW) {
|
||||
|
||||
x = (int)MouseDX;
|
||||
y = (int)MouseDY;
|
||||
|
||||
MouseDX = MouseDY = 0;
|
||||
|
||||
MouseSt = MouseStat;
|
||||
|
||||
if (x > 127) {
|
||||
MouseSt |= 0x10;
|
||||
MouseX = 127;
|
||||
} else if (x < -128) {
|
||||
MouseSt |= 0x20;
|
||||
MouseX = -128;
|
||||
} else {
|
||||
MouseX = (signed char)x;
|
||||
}
|
||||
|
||||
if (y > 127) {
|
||||
MouseSt |= 0x40;
|
||||
MouseY = 127;
|
||||
} else if (y < -128) {
|
||||
MouseSt |= 0x80;
|
||||
MouseY = -128;
|
||||
} else {
|
||||
MouseY = (signed char)y;
|
||||
}
|
||||
|
||||
} else {
|
||||
MouseSt = 0;
|
||||
MouseX = 0;
|
||||
MouseY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// Start Capture
|
||||
// ----------------------------------
|
||||
void Mouse_StartCapture(int flag)
|
||||
{
|
||||
if (flag && !MouseSW) {
|
||||
MouseSW = 1;
|
||||
} else if (!flag && MouseSW) {
|
||||
MouseSW = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Mouse_ChangePos(void)
|
||||
{
|
||||
#if 0
|
||||
if (MouseSW) {
|
||||
POINT pt;
|
||||
|
||||
getmaincenter(window, &pt);
|
||||
gdk_window_set_pointer(window->window, pt.x, pt.y);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
getmaincenter(GtkWidget *w, POINT *p)
|
||||
{
|
||||
|
||||
p->x = w->allocation.x + w->allocation.width / 2;
|
||||
p->y = w->allocation.y + w->allocation.height / 2;
|
||||
}
|
||||
|
||||
#if GTK_MAJOR_VERSION == 1
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
void
|
||||
gdk_window_set_pointer(GdkWindow *window, gint x, gint y)
|
||||
{
|
||||
GdkWindowPrivate *private;
|
||||
|
||||
if (!window)
|
||||
window = (GdkWindow *)&gdk_root_parent;
|
||||
|
||||
private = (GdkWindowPrivate *)window;
|
||||
if (private->destroyed)
|
||||
return;
|
||||
|
||||
XWarpPointer(private->xdisplay, None, private->xwindow,
|
||||
0, 0, 0, 0, x, y);
|
||||
}
|
||||
#else /* GTK_MAJOR_VERSION != 1 */
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
void
|
||||
gdk_window_set_pointer(GdkWindow *window, gint x, gint y)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
|
||||
if (window == NULL) {
|
||||
screen = gdk_screen_get_default();
|
||||
window = gdk_screen_get_root_window(screen);
|
||||
}
|
||||
if (GDK_WINDOW_DESTROYED(window))
|
||||
return;
|
||||
|
||||
XWarpPointer(GDK_WINDOW_XDISPLAY(window), None, GDK_WINDOW_XID(window),
|
||||
0, 0, 0, 0, x, y);
|
||||
}
|
||||
#endif /* GTK_MAJOR_VERSION == 1 */
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _winx68k_mouse
|
||||
#define _winx68k_mouse
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern int MousePosX;
|
||||
extern int MousePosY;
|
||||
extern BYTE MouseStat;
|
||||
extern BYTE MouseSW;
|
||||
|
||||
void Mouse_Init(void);
|
||||
void Mouse_Event(int wparam, float dx, float dy);
|
||||
void Mouse_SetData(void);
|
||||
void Mouse_StartCapture(int flag);
|
||||
void Mouse_ChangePos(void);
|
||||
|
||||
#endif //_winx68k_mouse
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
|
||||
; Copyright (C) 1999 URURI
|
||||
|
||||
; nasm用マクロ
|
||||
; 1999/08/21 作成
|
||||
; 1999/10/10 幾つか追加
|
||||
; 1999/10/27 aout対応
|
||||
; 1999/11/07 pushf, popf のNASMのバグ対応
|
||||
; 1999/12/02 for BCC ( Thanks to Miquel )
|
||||
|
||||
; for Windows Visual C++ -> define WIN32
|
||||
; Borland or cygwin -> WIN32 and COFF
|
||||
; for FreeBSD 2.x -> AOUT
|
||||
; for TownsOS -> __tos__
|
||||
; otherwise -> none
|
||||
|
||||
;名前の付け方
|
||||
|
||||
BITS 32
|
||||
|
||||
%ifdef WIN32
|
||||
%define _NAMING
|
||||
%define segment_code segment .text align=16 class=CODE use32
|
||||
%define segment_data segment .data align=16 class=DATA use32
|
||||
%ifdef __BORLANDC__
|
||||
%define segment_bss segment .data align=16 class=DATA use32
|
||||
%else
|
||||
%define segment_bss segment .bss align=16 class=DATA use32
|
||||
%endif
|
||||
%elifdef AOUT
|
||||
%define _NAMING
|
||||
%define segment_code segment .text
|
||||
%define segment_data segment .data
|
||||
%define segment_bss segment .bss
|
||||
%else
|
||||
%define segment_code segment .text align=16 class=CODE use32
|
||||
%define segment_data segment .data align=16 class=DATA use32
|
||||
%define segment_bss segment .bss align=16 class=DATA use32
|
||||
%endif
|
||||
|
||||
%ifdef __tos__
|
||||
group CGROUP text
|
||||
group DGROUP data
|
||||
%endif
|
||||
|
||||
;単精度浮動小数点形式
|
||||
|
||||
%idefine float dword
|
||||
%idefine fsize 4
|
||||
%idefine fsizen(a) (fsize*(a))
|
||||
|
||||
;ワード形式
|
||||
|
||||
%idefine wsize 2
|
||||
%idefine wsizen(a) (wsize*(a))
|
||||
%idefine dwsize 4
|
||||
%idefine dwsizen(a) (dwsize*(a))
|
||||
|
||||
;REG
|
||||
|
||||
%define r0 eax
|
||||
%define r1 ebx
|
||||
%define r2 ecx
|
||||
%define r3 edx
|
||||
%define r4 esi
|
||||
%define r5 edi
|
||||
%define r6 ebp
|
||||
%define r7 esp
|
||||
|
||||
;MMX,3DNow!,SSE
|
||||
|
||||
%define pmov movq
|
||||
%define pmovd movd
|
||||
|
||||
%define pupldq punpckldq
|
||||
%define puphdq punpckhdq
|
||||
%define puplwd punpcklwd
|
||||
%define puphwd punpckhwd
|
||||
|
||||
%define xm0 xmm0
|
||||
%define xm1 xmm1
|
||||
%define xm2 xmm2
|
||||
%define xm3 xmm3
|
||||
%define xm4 xmm4
|
||||
%define xm5 xmm5
|
||||
%define xm6 xmm6
|
||||
%define xm7 xmm7
|
||||
|
||||
;シャッフル用の4進マクロ
|
||||
|
||||
%define R4(a,b,c,d) (a*64+b*16+c*4+d)
|
||||
|
||||
;Cライクな簡易マクロ
|
||||
|
||||
%imacro globaldef 1
|
||||
%ifdef _NAMING
|
||||
%define %1 _%1
|
||||
%endif
|
||||
global %1
|
||||
%endmacro
|
||||
|
||||
%imacro externdef 1
|
||||
%ifdef _NAMING
|
||||
%define %1 _%1
|
||||
%endif
|
||||
extern %1
|
||||
%endmacro
|
||||
|
||||
%imacro proc 1
|
||||
%push proc
|
||||
%ifdef _NAMING
|
||||
global _%1
|
||||
%else
|
||||
global %1
|
||||
%endif
|
||||
|
||||
align 32
|
||||
%1:
|
||||
_%1:
|
||||
|
||||
%assign %$STACK 0
|
||||
%assign %$STACKN 0
|
||||
%assign %$ARG 4
|
||||
%endmacro
|
||||
|
||||
%imacro endproc 0
|
||||
%ifnctx proc
|
||||
%error expected 'proc' before 'endproc'.
|
||||
%else
|
||||
%if %$STACK > 0
|
||||
add esp, %$STACK
|
||||
%endif
|
||||
|
||||
%if %$STACK <> (-%$STACKN)
|
||||
%error STACKLEVEL mismatch check 'local', 'alloc', 'pushd', 'popd'
|
||||
%endif
|
||||
|
||||
ret
|
||||
%pop
|
||||
%endif
|
||||
%endmacro
|
||||
|
||||
%idefine sp(a) esp+%$STACK+a
|
||||
|
||||
%imacro arg 1
|
||||
%00 equ %$ARG
|
||||
%assign %$ARG %$ARG+%1
|
||||
%endmacro
|
||||
|
||||
%imacro local 1
|
||||
%assign %$STACKN %$STACKN-%1
|
||||
%00 equ %$STACKN
|
||||
%endmacro
|
||||
|
||||
%imacro alloc 0
|
||||
sub esp, (-%$STACKN)-%$STACK
|
||||
%assign %$STACK (-%$STACKN)
|
||||
%endmacro
|
||||
|
||||
%imacro pushd 1-*
|
||||
%rep %0
|
||||
push %1
|
||||
%assign %$STACK %$STACK+4
|
||||
%rotate 1
|
||||
%endrep
|
||||
%endmacro
|
||||
|
||||
%imacro popd 1-*
|
||||
%rep %0
|
||||
%rotate -1
|
||||
pop %1
|
||||
%assign %$STACK %$STACK-4
|
||||
%endrep
|
||||
%endmacro
|
||||
|
||||
; bug of NASM-0.98
|
||||
%define pushf db 0x66, 0x9C
|
||||
%define popf db 0x66, 0x9D
|
||||
+1374
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,66 @@
|
||||
#ifndef _winx68k_config
|
||||
#define _winx68k_config
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD SampleRate;
|
||||
DWORD BufferSize;
|
||||
int WinPosX;
|
||||
int WinPosY;
|
||||
int OPM_VOL;
|
||||
int PCM_VOL;
|
||||
int MCR_VOL;
|
||||
int JOY_BTN[2][8];
|
||||
int MouseSpeed;
|
||||
int WindowFDDStat;
|
||||
int FullScrFDDStat;
|
||||
int DSAlert;
|
||||
int MIDI_SW;
|
||||
int MIDI_Type;
|
||||
int MIDI_Reset;
|
||||
int JoyKey;
|
||||
int JoyKeyReverse;
|
||||
int JoyKeyJoy2;
|
||||
int SRAMWarning;
|
||||
char HDImage[16][MAX_PATH];
|
||||
int ToneMap;
|
||||
char ToneMapFile[MAX_PATH];
|
||||
int XVIMode;
|
||||
int JoySwap;
|
||||
int LongFileName;
|
||||
int WinDrvFD;
|
||||
int WinStrech;
|
||||
int DSMixing;
|
||||
int CDROM_ASPI;
|
||||
int CDROM_ASPI_Drive;
|
||||
int CDROM_IOCTRL_Drive;
|
||||
int CDROM_SCSIID;
|
||||
int CDROM_Enable;
|
||||
int SSTP_Enable;
|
||||
int SSTP_Port;
|
||||
int Sound_LPF;
|
||||
int SoundROMEO;
|
||||
int MIDIDelay;
|
||||
int MIDIAutoDelay;
|
||||
char FDDImage[2][MAX_PATH];
|
||||
int VkeyScale;
|
||||
int VbtnSwap;
|
||||
int JoyOrMouse;
|
||||
int HwJoyAxis[2];
|
||||
int HwJoyHat;
|
||||
int HwJoyBtn[8];
|
||||
int NoWaitMode;
|
||||
BYTE FrameRate;
|
||||
} Win68Conf;
|
||||
|
||||
extern Win68Conf Config;
|
||||
|
||||
void LoadConfig(void);
|
||||
void SaveConfig(void);
|
||||
void PropPage_Init(void);
|
||||
|
||||
int set_modulepath(char *path, size_t len);
|
||||
|
||||
#endif //_winx68k_config
|
||||
@@ -0,0 +1,344 @@
|
||||
/* $Id: status.c,v 1.3 2008/11/08 01:42:42 nonaka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 NONAKA Kimihiro
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* FDD状態表示用ステータスバー *
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "common.h"
|
||||
#include "windraw.h"
|
||||
#include "winx68k.h"
|
||||
#include "prop.h"
|
||||
#include "status.h"
|
||||
#include "fileio.h"
|
||||
#include "fdd.h"
|
||||
|
||||
#if 0
|
||||
#include "../icons/fd_inserted.xpm"
|
||||
#include "../icons/fd_inuse.xpm"
|
||||
#include "../icons/fd_normal.xpm"
|
||||
#include "../icons/fd_protected.xpm"
|
||||
#include "../icons/hd_inserted.xpm"
|
||||
#include "../icons/hd_inuse.xpm"
|
||||
#include "../icons/hd_normal.xpm"
|
||||
#include "../icons/nulldev.xpm"
|
||||
|
||||
static char **pixmaps[] = {
|
||||
fd_normal,
|
||||
fd_inuse,
|
||||
fd_inserted,
|
||||
fd_protected,
|
||||
hd_normal,
|
||||
hd_inuse,
|
||||
hd_inserted,
|
||||
nulldev,
|
||||
};
|
||||
#endif
|
||||
|
||||
//static GtkWidget *statbar;
|
||||
//static GtkWidget *devstat[2 /* FDD */ + 1 /* SASI */];
|
||||
//static GtkWidget *devlabel[2 /* FDD */ + 1 /* SASI */];
|
||||
//static GdkPixmap *devstat_pixmap[2 /* FDD */ + 1 /* SASI */];
|
||||
//static GdkPixmap *dev_pixmap[NELEMENTS(pixmaps)];
|
||||
|
||||
typedef struct {
|
||||
int insert;
|
||||
int access;
|
||||
int blink;
|
||||
int timer;
|
||||
char file[MAX_PATH];
|
||||
} FDDLED;
|
||||
|
||||
static FDDLED FddLed[2];
|
||||
//static int HddLed = 0, HddLedTmp = 0;
|
||||
|
||||
#if 0
|
||||
/* ----- GTK signal handler */
|
||||
static gint
|
||||
expose(GtkWidget *w, GdkEventExpose *ev, gpointer d)
|
||||
{
|
||||
|
||||
if (ev->type == GDK_EXPOSE) {
|
||||
if (ev->count == 0) {
|
||||
gdk_draw_pixmap(w->window,
|
||||
w->style->fg_gc[GTK_WIDGET_STATE(w)],
|
||||
devstat_pixmap[(int)d], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
/* ----- */
|
||||
#endif
|
||||
|
||||
void
|
||||
StatBar_Redraw(void)
|
||||
{
|
||||
|
||||
if (Config.FullScrFDDStat) {
|
||||
StatBar_FDD(0, 0, FddLed[0].access);
|
||||
StatBar_FDD(0, 1, FddLed[0].insert);
|
||||
StatBar_FDD(1, 0, FddLed[1].access);
|
||||
StatBar_FDD(1, 1, FddLed[1].insert);
|
||||
StatBar_FDName(0, FddLed[0].file);
|
||||
StatBar_FDName(1, FddLed[1].file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_Show(int sw)
|
||||
{
|
||||
#if 1
|
||||
(void)sw;
|
||||
#else
|
||||
if (sw) {
|
||||
if (statbar == 0) {
|
||||
GdkVisual *visual;
|
||||
GdkColormap *colormap;
|
||||
GdkBitmap *mask;
|
||||
int pos = 0;
|
||||
int i;
|
||||
|
||||
statbar = gtk_table_new(1, 18, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(main_vbox), statbar,
|
||||
FALSE, TRUE, 0);
|
||||
|
||||
colormap = gtk_widget_get_colormap(window);
|
||||
for (i = 0; i < NELEMENTS(dev_pixmap); ++i) {
|
||||
dev_pixmap[i] =
|
||||
gdk_pixmap_colormap_create_from_xpm_d(NULL,
|
||||
colormap, &mask, NULL, pixmaps[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NELEMENTS(devstat); ++i) {
|
||||
GtkWidget *w;
|
||||
int idx = 0;
|
||||
|
||||
if (i == NELEMENTS(devstat) - 1) {
|
||||
w = gtk_vseparator_new();
|
||||
gtk_table_attach(GTK_TABLE(statbar), w,
|
||||
pos, pos + 1, 0, 1, 0, 0, 0, 0);
|
||||
pos++;
|
||||
gtk_widget_show(w);
|
||||
idx += 4;
|
||||
}
|
||||
|
||||
w = devstat[i] = gtk_drawing_area_new();
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(w),
|
||||
16, 16);
|
||||
gtk_table_attach(GTK_TABLE(statbar), w,
|
||||
pos, pos + 1, 0, 1, 0, 0, 0, 0);
|
||||
pos++;
|
||||
gtk_signal_connect(GTK_OBJECT(w),"expose_event",
|
||||
GTK_SIGNAL_FUNC(expose), (gpointer)i);
|
||||
gtk_widget_show(w);
|
||||
|
||||
devlabel[i] = gtk_label_new(
|
||||
(i == NELEMENTS(devstat) - 1) ?
|
||||
"HDD"
|
||||
:
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ");
|
||||
gtk_table_attach_defaults(GTK_TABLE(statbar),
|
||||
devlabel[i], pos, pos + 3, 0, 1);
|
||||
pos += 3;
|
||||
gtk_widget_show(devlabel[i]);
|
||||
|
||||
visual = gtk_widget_get_visual(w);
|
||||
devstat_pixmap[i] = gdk_pixmap_new(w->window,
|
||||
16, 16, visual->depth);
|
||||
gdk_draw_pixmap(devstat_pixmap[i],
|
||||
w->style->fg_gc[GTK_WIDGET_STATE(w)],
|
||||
dev_pixmap[idx], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
|
||||
}
|
||||
gtk_widget_show(statbar);
|
||||
} else {
|
||||
if (statbar)
|
||||
gtk_widget_hide(statbar);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_UpdateTimer(void)
|
||||
{
|
||||
#if 0
|
||||
FddLed[0].timer ^= 1;
|
||||
FddLed[1].timer ^= 1;
|
||||
|
||||
if (FddLed[0].blink && (!FddLed[0].file[0]) && statbar) {
|
||||
gdk_draw_pixmap(devstat_pixmap[0],
|
||||
devstat[0]->style->fg_gc[GTK_WIDGET_STATE(devstat[0])],
|
||||
dev_pixmap[FddLed[0].timer], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
if (FddLed[1].blink && (!FddLed[1].file[0]) && statbar) {
|
||||
gdk_draw_pixmap(devstat_pixmap[1],
|
||||
devstat[1]->style->fg_gc[GTK_WIDGET_STATE(devstat[1])],
|
||||
dev_pixmap[FddLed[1].timer], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
if (HddLed != HddLedTmp) {
|
||||
HddLed = HddLedTmp;
|
||||
if (statbar) {
|
||||
gdk_draw_pixmap(devstat_pixmap[2],
|
||||
devstat[2]->style->fg_gc[
|
||||
GTK_WIDGET_STATE(devstat[2])],
|
||||
dev_pixmap[HddLed ? 5 : 4], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
}
|
||||
StatBar_Redraw();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_HDD(int hd)
|
||||
{
|
||||
#if 1
|
||||
(void)hd;
|
||||
#else
|
||||
HddLedTmp = hd;
|
||||
if ((HddLed != hd) && (hd)) {
|
||||
gdk_draw_pixmap(devstat_pixmap[2],
|
||||
devstat[2]->style->fg_gc[GTK_WIDGET_STATE(devstat[2])],
|
||||
dev_pixmap[HddLed ? 5 : 4], 0, 0, 0, 0, 16, 16);
|
||||
HddLed = hd;
|
||||
}
|
||||
StatBar_Redraw();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_SetFDD(int drv, char* file)
|
||||
{
|
||||
#if 1
|
||||
(void)drv;
|
||||
(void)file;
|
||||
#else
|
||||
char name[81];
|
||||
char *f;
|
||||
int i;
|
||||
|
||||
if ((drv < 0)||(drv > 1))
|
||||
return;
|
||||
|
||||
f = (char *)getFileName(file);
|
||||
strcpy(FddLed[drv].file, f);
|
||||
g_snprintf(name, sizeof(name), "%s", f);
|
||||
|
||||
if (f[0]) {
|
||||
FddLed[drv].access = 1;
|
||||
FddLed[drv].insert = 1;
|
||||
} else {
|
||||
FddLed[drv].access = 0;
|
||||
FddLed[drv].insert = 0;
|
||||
}
|
||||
|
||||
if (statbar) {
|
||||
int len = strlen(name);
|
||||
int c = ((FddLed[drv].blink) && (!FddLed[drv].file[0])) ? FddLed[drv].timer : FddLed[drv].access;
|
||||
gdk_draw_pixmap(devstat_pixmap[drv],
|
||||
devstat[drv]->style->fg_gc[
|
||||
GTK_WIDGET_STATE(devstat[drv])],
|
||||
dev_pixmap[c], 0, 0, 0, 0, 16, 16);
|
||||
|
||||
memset(name + len, ' ', sizeof(name) - len);
|
||||
name[80] = '\0';
|
||||
gtk_label_set_text(devlabel[drv], name);
|
||||
}
|
||||
StatBar_Redraw();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_ParamFDD(int drv, int access, int insert, int blink)
|
||||
{
|
||||
#if 1
|
||||
(void)drv;
|
||||
(void)access;
|
||||
(void)insert;
|
||||
(void)blink;
|
||||
#else
|
||||
int update;
|
||||
|
||||
if ((drv < 0) || (drv > 1))
|
||||
return;
|
||||
|
||||
update = 0;
|
||||
if (FddLed[drv].access != access) {
|
||||
FddLed[drv].access = access;
|
||||
update = 1;
|
||||
}
|
||||
if (FddLed[drv].insert != insert) {
|
||||
FddLed[drv].insert = insert;
|
||||
update = 1;
|
||||
}
|
||||
if (FddLed[drv].blink != blink) {
|
||||
FddLed[drv].blink = blink;
|
||||
update = 1;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
if (statbar) {
|
||||
int c = ((FddLed[drv].blink) && (!FddLed[drv].file[0])) ? FddLed[drv].timer : FddLed[drv].access;
|
||||
gdk_draw_pixmap(devstat_pixmap[drv],
|
||||
devstat[drv]->style->fg_gc[
|
||||
GTK_WIDGET_STATE(devstat[drv])],
|
||||
dev_pixmap[c], 0, 0, 0, 0, 16, 16);
|
||||
}
|
||||
StatBar_Redraw();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_FDName(int drv, char* name)
|
||||
{
|
||||
/* Full screen 専用 */
|
||||
(void)drv;
|
||||
(void)name;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StatBar_FDD(int drv, int led, int col)
|
||||
{
|
||||
/* Full screen 専用 */
|
||||
(void)drv;
|
||||
(void)led;
|
||||
(void)col;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef winx68k_statusbar_h
|
||||
#define winx68k_statusbar_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
#define StatBar_Show(s)
|
||||
#define StatBar_UpdateTimer()
|
||||
#define StatBar_SetFDD(d,f)
|
||||
#define StatBar_ParamFDD(d,a,i,b)
|
||||
#define StatBar_HDD(s)
|
||||
|
||||
#else
|
||||
|
||||
void StatBar_Redraw(void);
|
||||
void StatBar_Show(int sw);
|
||||
void StatBar_Draw(DRAWITEMSTRUCT* dis);
|
||||
void StatBar_FDName(int drv, char* name);
|
||||
void StatBar_FDD(int drv, int led, int col);
|
||||
void StatBar_UpdateTimer(void);
|
||||
void StatBar_SetFDD(int drv, char* file);
|
||||
void StatBar_ParamFDD(int drv, int access, int insert, int blink);
|
||||
void StatBar_HDD(int sw);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif //winx68k_statusbar_h
|
||||
@@ -0,0 +1,36 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// 55.6fps¥¡¼¥×ÍѤ¿¤¤¤Þ¡¼
|
||||
// -----------------------------------------------------------------------
|
||||
#include "common.h"
|
||||
#include "crtc.h"
|
||||
#include "mfp.h"
|
||||
|
||||
DWORD timercnt = 0;
|
||||
DWORD tick = 0;
|
||||
|
||||
void Timer_Init(void)
|
||||
{
|
||||
tick = timeGetTime();
|
||||
}
|
||||
|
||||
void Timer_Reset(void)
|
||||
{
|
||||
tick = timeGetTime();
|
||||
}
|
||||
|
||||
WORD Timer_GetCount(void)
|
||||
{
|
||||
DWORD ticknow = timeGetTime();
|
||||
DWORD dif = ticknow-tick;
|
||||
DWORD TIMEBASE = ((CRTC_Regs[0x29]&0x10)?VSYNC_HIGH:VSYNC_NORM);
|
||||
|
||||
timercnt += dif*10000;
|
||||
tick = ticknow;
|
||||
if ( timercnt>=TIMEBASE ) {
|
||||
// timercnt = 0;
|
||||
timercnt -= TIMEBASE;
|
||||
if ( timercnt>=(TIMEBASE*2) ) timercnt = 0;
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef winx1_timer_h
|
||||
#define winx1_timer_h
|
||||
|
||||
void Timer_Init(void);
|
||||
void Timer_Reset(void);
|
||||
WORD Timer_GetCount(void);
|
||||
void Timer_SetCount(WORD);
|
||||
|
||||
#endif //winx1_timer_h
|
||||
@@ -0,0 +1,15 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// WinX68k - SHARP X680x0 Emulator
|
||||
// Copyright (C) Kenjo 2000
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _version_h
|
||||
#define _version_h
|
||||
|
||||
#define APP_VER_MAJOR 0
|
||||
#define APP_VER_MINOR 65
|
||||
#define APP_VER_STRING "0.65"
|
||||
|
||||
#define SOURCE_VERSION "20081108"
|
||||
|
||||
#endif //_version_h
|
||||
+1459
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
#ifndef _winx68k_windraw_h
|
||||
#define _winx68k_windraw_h
|
||||
|
||||
extern BYTE Draw_DrawFlag;
|
||||
extern int winx, winy;
|
||||
extern int winh, winw;
|
||||
extern int FullScreenFlag;
|
||||
extern BYTE Draw_ClrMenu;
|
||||
extern WORD FrameCount;
|
||||
extern WORD WinDraw_Pal16B, WinDraw_Pal16R, WinDraw_Pal16G;
|
||||
|
||||
extern BYTE Draw_BitMask[800];
|
||||
extern BYTE Draw_TextBitMask[800];
|
||||
|
||||
extern int WindowX;
|
||||
extern int WindowY;
|
||||
extern int kbd_x, kbd_y, kbd_w, kbd_h;
|
||||
|
||||
void WinDraw_InitWindowSize(WORD width, WORD height);
|
||||
void WinDraw_ChangeMode(int flag);
|
||||
int WinDraw_Init(void);
|
||||
void WinDraw_Cleanup(void);
|
||||
void WinDraw_Redraw(void);
|
||||
void FASTCALL WinDraw_Draw(void);
|
||||
void WinDraw_ShowMenu(int flag);
|
||||
void WinDraw_DrawLine(void);
|
||||
void WinDraw_HideSplash(void);
|
||||
void WinDraw_ChangeSize(void);
|
||||
|
||||
void WinDraw_StartupScreen(void);
|
||||
void WinDraw_CleanupScreen(void);
|
||||
|
||||
int WinDraw_MenuInit(void);
|
||||
void WinDraw_DrawMenu(int menu_state, int mkey_pos, int mkey_y, int *mval_y);
|
||||
|
||||
extern struct menu_flist mfl;
|
||||
|
||||
void WinDraw_DrawMenufile(struct menu_flist *mfl);
|
||||
void WinDraw_ClearMenuBuffer(void);
|
||||
void WinDraw_reverse_key(int x, int y);
|
||||
|
||||
#endif //winx68k_windraw_h
|
||||
|
||||
|
||||
@@ -0,0 +1,788 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2008 NONAKA Kimihiro
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* WINUI.C - UI *
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "about.h"
|
||||
#include "keyboard.h"
|
||||
#include "windraw.h"
|
||||
#include "dswin.h"
|
||||
#include "fileio.h"
|
||||
#include "prop.h"
|
||||
#include "status.h"
|
||||
#include "joystick.h"
|
||||
#include "mouse.h"
|
||||
#include "winx68k.h"
|
||||
#include "version.h"
|
||||
#include "juliet.h"
|
||||
#include "fdd.h"
|
||||
#include "irqh.h"
|
||||
#include "../m68000/m68000.h"
|
||||
#include "crtc.h"
|
||||
#include "mfp.h"
|
||||
#include "fdc.h"
|
||||
#include "disk_d88.h"
|
||||
#include "dmac.h"
|
||||
#include "ioc.h"
|
||||
#include "rtc.h"
|
||||
#include "sasi.h"
|
||||
#include "bg.h"
|
||||
#include "palette.h"
|
||||
#include "crtc.h"
|
||||
#include "pia.h"
|
||||
#include "scc.h"
|
||||
#include "midi.h"
|
||||
#include "adpcm.h"
|
||||
#include "mercury.h"
|
||||
#include "tvram.h"
|
||||
#include "winui.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "fmg_wrap.h"
|
||||
|
||||
extern BYTE fdctrace;
|
||||
extern BYTE traceflag;
|
||||
extern WORD FrameCount;
|
||||
extern DWORD TimerICount;
|
||||
extern unsigned int hTimerID;
|
||||
DWORD timertick=0;
|
||||
extern int FullScreenFlag;
|
||||
int UI_MouseFlag = 0;
|
||||
int UI_MouseX = -1, UI_MouseY = -1;
|
||||
extern short timertrace;
|
||||
|
||||
BYTE MenuClearFlag = 0;
|
||||
|
||||
BYTE Debug_Text=1, Debug_Grp=1, Debug_Sp=1;
|
||||
|
||||
char filepath[MAX_PATH] = ".";
|
||||
int fddblink = 0;
|
||||
int fddblinkcount = 0;
|
||||
int hddtrace = 0;
|
||||
extern int dmatrace;
|
||||
|
||||
DWORD LastClock[4] = {0, 0, 0, 0};
|
||||
|
||||
char cur_dir_str[MAX_PATH];
|
||||
int cur_dir_slen;
|
||||
|
||||
struct menu_flist mfl;
|
||||
|
||||
/***** menu items *****/
|
||||
|
||||
#define MENU_NUM 13
|
||||
#define MENU_WINDOW 7
|
||||
|
||||
int mval_y[] = {0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 1};
|
||||
|
||||
enum menu_id {M_SYS, M_JOM, M_FD0, M_FD1, M_HD0, M_HD1, M_FS, M_SR, M_VKS, M_VBS, M_HJS, M_NW, M_JK};
|
||||
|
||||
// Max # of characters is 15.
|
||||
char menu_item_key[][15] = {"SYSTEM", "Joy/Mouse", "FDD0", "FDD1", "HDD0", "HDD1", "Frame Skip", "Sound Rate", "VKey Size", "VBtn Swap", "HwJoy Setting", "No Wait Mode", "JoyKey", "uhyo", ""};
|
||||
|
||||
// Max # of characters is 30.
|
||||
// Max # of items including terminater `""' in each line is 15.
|
||||
char menu_items[][15][30] = {
|
||||
{"RESET", "NMI RESET", "QUIT", ""},
|
||||
{"Joystick", "Mouse", ""},
|
||||
{"dummy", "EJECT", ""},
|
||||
{"dummy", "EJECT", ""},
|
||||
{"dummy", "EJECT", ""},
|
||||
{"dummy", "EJECT", ""},
|
||||
{"Auto Frame Skip", "Full Frame", "1/2 Frame", "1/3 Frame", "1/4 Frame", "1/5 Frame", "1/6 Frame", "1/8 Frame", "1/16 Frame", "1/32 Frame", "1/60 Frame", ""},
|
||||
{"No Sound", "11025Hz", "22050Hz", "44100Hz", "48000Hz", ""},
|
||||
{"Ultra Huge", "Super Huge", "Huge", "Large", "Medium", "Small", ""},
|
||||
{"TRIG1 TRIG2", "TRIG2 TRIG1", ""},
|
||||
{"Axis0: xx", "Axis1: xx", "Hat: xx", "Button0: xx", "Button1: xx", ""},
|
||||
{"Off", "On", ""},
|
||||
{"Off", "On", ""}
|
||||
};
|
||||
|
||||
static void menu_system(int v);
|
||||
static void menu_joy_or_mouse(int v);
|
||||
static void menu_create_flist(int v);
|
||||
static void menu_frame_skip(int v);
|
||||
static void menu_sound_rate(int v);
|
||||
static void menu_vkey_size(int v);
|
||||
static void menu_vbtn_swap(int v);
|
||||
static void menu_hwjoy_setting(int v);
|
||||
static void menu_nowait(int v);
|
||||
static void menu_joykey(int v);
|
||||
|
||||
struct _menu_func {
|
||||
void (*func)(int v);
|
||||
int imm;
|
||||
};
|
||||
|
||||
struct _menu_func menu_func[] = {
|
||||
{menu_system, 0},
|
||||
{menu_joy_or_mouse, 1},
|
||||
{menu_create_flist, 0},
|
||||
{menu_create_flist, 0},
|
||||
{menu_create_flist, 0},
|
||||
{menu_create_flist, 0},
|
||||
{menu_frame_skip, 1},
|
||||
{menu_sound_rate, 1},
|
||||
{menu_vkey_size, 1},
|
||||
{menu_vbtn_swap, 1},
|
||||
{menu_hwjoy_setting, 0},
|
||||
{menu_nowait, 1},
|
||||
{menu_joykey, 1}
|
||||
};
|
||||
|
||||
int WinUI_get_drv_num(int key)
|
||||
{
|
||||
char *s = menu_item_key[key];
|
||||
|
||||
if (!strncmp("FDD", s, 3)) {
|
||||
return strcmp("FDD0", s)?
|
||||
(strcmp("FDD1", s)? -1 : 1) : 0;
|
||||
} else {
|
||||
return strcmp("HDD0", s)?
|
||||
(strcmp("HDD1", s)? -1: 3) : 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_hwjoy_print(int v)
|
||||
{
|
||||
if (v <= 1) {
|
||||
sprintf(menu_items[M_HJS][v], "Axis%d(%s): %d",
|
||||
v,
|
||||
(v == 0)? "Left/Right" : "Up/Down",
|
||||
Config.HwJoyAxis[v]);
|
||||
} else if (v == 2) {
|
||||
sprintf(menu_items[M_HJS][v], "Hat: %d", Config.HwJoyHat);
|
||||
} else {
|
||||
sprintf(menu_items[M_HJS][v], "Button%d: %d",
|
||||
v - 3,
|
||||
Config.HwJoyBtn[v - 3]);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* init
|
||||
******************************************************************************/
|
||||
void
|
||||
WinUI_Init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
mval_y[M_JOM] = Config.JoyOrMouse;
|
||||
if (Config.FrameRate == 7) {
|
||||
mval_y[M_FS] = 0;
|
||||
} else if (Config.FrameRate == 8) {
|
||||
mval_y[M_FS] = 7;
|
||||
} else if (Config.FrameRate == 16) {
|
||||
mval_y[M_FS] = 8;
|
||||
} else if (Config.FrameRate == 32) {
|
||||
mval_y[M_FS] = 9;
|
||||
} else if (Config.FrameRate == 60) {
|
||||
mval_y[M_FS] = 10;
|
||||
} else {
|
||||
mval_y[M_FS] = Config.FrameRate;
|
||||
}
|
||||
|
||||
if (Config.SampleRate == 0) {
|
||||
mval_y[M_SR] = 0;
|
||||
} else if (Config.SampleRate == 11025) {
|
||||
mval_y[M_SR] = 1;
|
||||
} else if (Config.SampleRate == 22050) {
|
||||
mval_y[M_SR] = 2;
|
||||
} else if (Config.SampleRate == 44100) {
|
||||
mval_y[M_SR] = 3;
|
||||
} else if (Config.SampleRate == 48000) {
|
||||
mval_y[M_SR] = 4;
|
||||
} else {
|
||||
mval_y[M_SR] = 1;
|
||||
}
|
||||
|
||||
mval_y[M_VKS] = Config.VkeyScale;
|
||||
mval_y[M_VBS] = Config.VbtnSwap;
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
menu_hwjoy_print(i);
|
||||
}
|
||||
|
||||
mval_y[M_NW] = Config.NoWaitMode;
|
||||
mval_y[M_JK] = Config.JoyKey;
|
||||
|
||||
#if defined(ANDROID)
|
||||
#define CUR_DIR_STR winx68k_dir
|
||||
#elif TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR == 0
|
||||
#define CUR_DIR_STR "/var/mobile/px68k/"
|
||||
#else
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
#ifdef _WIN32
|
||||
#define CUR_DIR_STR "c:\\"
|
||||
#else
|
||||
#define CUR_DIR_STR "/"
|
||||
#endif
|
||||
#else
|
||||
#define CUR_DIR_STR "./"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
strcpy(cur_dir_str, CUR_DIR_STR);
|
||||
#ifdef ANDROID
|
||||
strcat(cur_dir_str, "/");
|
||||
#endif
|
||||
cur_dir_slen = strlen(cur_dir_str);
|
||||
p6logd("cur_dir_str %s %d\n", cur_dir_str, cur_dir_slen);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
strcpy(mfl.dir[i], cur_dir_str);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* item function
|
||||
*/
|
||||
static void
|
||||
reset(gpointer data, guint action, GtkWidget *w)
|
||||
{
|
||||
WinX68k_Reset();
|
||||
if (Config.MIDI_SW && Config.MIDI_Reset)
|
||||
MIDI_Reset();
|
||||
}
|
||||
|
||||
static void
|
||||
stretch(gpointer data, guint action, GtkWidget *w)
|
||||
{
|
||||
UNUSED(data);
|
||||
UNUSED(w);
|
||||
|
||||
if (Config.WinStrech != (int)action)
|
||||
Config.WinStrech = action;
|
||||
}
|
||||
|
||||
static void
|
||||
xvimode(gpointer data, guint action, GtkWidget *w)
|
||||
{
|
||||
UNUSED(data);
|
||||
UNUSED(w);
|
||||
|
||||
if (Config.XVIMode != (int)action)
|
||||
Config.XVIMode = action;
|
||||
}
|
||||
|
||||
static void
|
||||
videoreg_save(gpointer data, guint action, GtkWidget *w)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
UNUSED(data);
|
||||
UNUSED(action);
|
||||
UNUSED(w);
|
||||
|
||||
DSound_Stop();
|
||||
g_snprintf(buf, sizeof(buf),
|
||||
"VCReg 0:$%02X%02X 1:$%02x%02X 2:$%02X%02X "
|
||||
"CRTC00/02/05/06=%02X/%02X/%02X/%02X%02X "
|
||||
"BGHT/HD/VD=%02X/%02X/%02X $%02X/$%02X",
|
||||
VCReg0[0], VCReg0[1], VCReg1[0], VCReg1[1], VCReg2[0], VCReg2[1],
|
||||
CRTC_Regs[0x01], CRTC_Regs[0x05], CRTC_Regs[0x0b], CRTC_Regs[0x0c],
|
||||
CRTC_Regs[0x0d],
|
||||
BG_Regs[0x0b], BG_Regs[0x0d], BG_Regs[0x0f],
|
||||
CRTC_Regs[0x29], BG_Regs[0x11]);
|
||||
Error(buf);
|
||||
DSound_Play();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
float VKey_scale[] = {3.0, 2.5, 2.0, 1.5, 1.25, 1.0};
|
||||
|
||||
float WinUI_get_vkscale(void)
|
||||
{
|
||||
int n = Config.VkeyScale;
|
||||
|
||||
// failsafe against invalid values
|
||||
if (n < 0 || n >= sizeof(VKey_scale)/sizeof(float)) {
|
||||
return 1.0;
|
||||
}
|
||||
return VKey_scale[n];
|
||||
}
|
||||
|
||||
int menu_state = ms_key;
|
||||
int mkey_y = 0;
|
||||
int mkey_pos = 0;
|
||||
|
||||
static void menu_system(int v)
|
||||
{
|
||||
switch (v) {
|
||||
case 0 :
|
||||
WinX68k_Reset();
|
||||
break;
|
||||
case 1:
|
||||
IRQH_Int(7, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_joy_or_mouse(int v)
|
||||
{
|
||||
Config.JoyOrMouse = v;
|
||||
Mouse_StartCapture(v == 1);
|
||||
}
|
||||
|
||||
|
||||
static void upper(char *s)
|
||||
{
|
||||
while (*s != '\0') {
|
||||
if (*s >= 'a' && *s <= 'z') {
|
||||
*s = 'A' + *s - 'a';
|
||||
}
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_create_flist(int v)
|
||||
{
|
||||
int drv;
|
||||
//file extension of FD image
|
||||
char support[] = "D8888DHDMDUP2HDDIMXDFIMG";
|
||||
|
||||
drv = WinUI_get_drv_num(mkey_y);
|
||||
p6logd("*** drv:%d ***** %s \n", drv, mfl.dir[drv]);
|
||||
if (drv < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set current directory when FDD is ejected
|
||||
if (v == 1) {
|
||||
if (drv < 2) {
|
||||
FDD_EjectFD(drv);
|
||||
Config.FDDImage[drv][0] = '\0';
|
||||
} else {
|
||||
Config.HDImage[drv - 2][0] = '\0';
|
||||
}
|
||||
strcpy(mfl.dir[drv], cur_dir_str);
|
||||
return;
|
||||
}
|
||||
|
||||
if (drv >= 2) {
|
||||
strcpy(support, "HDF");
|
||||
}
|
||||
|
||||
// This routine gets file lists.
|
||||
DIR *dp;
|
||||
struct dirent *dent;
|
||||
struct stat buf;
|
||||
int i, len;
|
||||
char *n, ext[4], *p;
|
||||
char ent_name[MAX_PATH];
|
||||
|
||||
dp = opendir(mfl.dir[drv]);
|
||||
|
||||
// xxx check if dp is null...
|
||||
|
||||
// xxx You can get only MFL_MAX files.
|
||||
for (i = 0 ; i < MFL_MAX; i++) {
|
||||
dent = readdir(dp);
|
||||
if (dent == NULL) {
|
||||
break;
|
||||
}
|
||||
n = dent->d_name;
|
||||
strcpy(ent_name, mfl.dir[drv]);
|
||||
strcat(ent_name, n);
|
||||
stat(ent_name, &buf);
|
||||
|
||||
if (!S_ISDIR(buf.st_mode)) {
|
||||
// Check extension if this is file.
|
||||
len = strlen(n);
|
||||
if (len < 4 || *(n + len - 4) != '.') {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
strcpy(ext, n + len - 3);
|
||||
upper(ext);
|
||||
p = strstr(support, ext);
|
||||
if (p == NULL || (p - support) % 3 != 0) {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(n, ".")) {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// You can't go up over current directory.
|
||||
if (!strcmp(n, "..") &&
|
||||
!strcmp(mfl.dir[drv], cur_dir_str)) {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(mfl.name[i], n);
|
||||
// set 1 if this is directory
|
||||
mfl.type[i] = S_ISDIR(buf.st_mode)? 1 : 0;
|
||||
printf("%s 0x%x\n", n, buf.st_mode);
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
|
||||
strcpy(mfl.name[i], "");
|
||||
mfl.num = i;
|
||||
mfl.ptr = 0;
|
||||
}
|
||||
|
||||
static void menu_frame_skip(int v)
|
||||
{
|
||||
if (v == 0) {
|
||||
Config.FrameRate = 7;
|
||||
} else if (v == 7) {
|
||||
Config.FrameRate = 8;
|
||||
} else if (v == 8) {
|
||||
Config.FrameRate = 16;
|
||||
} else if (v == 9) {
|
||||
Config.FrameRate = 32;
|
||||
} else if (v == 10) {
|
||||
Config.FrameRate = 60;
|
||||
} else {
|
||||
Config.FrameRate = v;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_sound_rate(int v)
|
||||
{
|
||||
if (v == 0) {
|
||||
Config.SampleRate = 0;
|
||||
} else if (v == 1) {
|
||||
Config.SampleRate = 11025;
|
||||
} else if (v == 2) {
|
||||
Config.SampleRate = 22050;
|
||||
} else if (v == 3) {
|
||||
Config.SampleRate = 44100;
|
||||
} else if (v == 4) {
|
||||
Config.SampleRate = 48000;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_vkey_size(int v)
|
||||
{
|
||||
Config.VkeyScale = v;
|
||||
}
|
||||
|
||||
static void menu_vbtn_swap(int v)
|
||||
{
|
||||
Config.VbtnSwap = v;
|
||||
}
|
||||
|
||||
static void menu_hwjoy_setting(int v)
|
||||
{
|
||||
menu_state = ms_hwjoy_set;
|
||||
}
|
||||
|
||||
static void menu_nowait(int v)
|
||||
{
|
||||
Config.NoWaitMode = v;
|
||||
}
|
||||
|
||||
static void menu_joykey(int v)
|
||||
{
|
||||
Config.JoyKey = v;
|
||||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
extern char slash;
|
||||
#endif
|
||||
// ex. ./hoge/.. -> ./
|
||||
// ( ./ ---down hoge dir--> ./hoge ---up hoge dir--> ./hoge/.. )
|
||||
static void shortcut_dir(int drv)
|
||||
{
|
||||
int i, len, found = 0;
|
||||
char *p;
|
||||
|
||||
// len is larger than 2
|
||||
len = strlen(mfl.dir[drv]);
|
||||
p = mfl.dir[drv] + len - 2;
|
||||
for (i = len - 2; i >= 0; i--) {
|
||||
if (*p == slash/*'/'*/) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
p--;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (found && strcmp(p, "\\..\\")) {
|
||||
#else
|
||||
if (found && strcmp(p, "/../")) {
|
||||
#endif
|
||||
*(p + 1) = '\0';
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
strcat(mfl.dir[drv], "..\\");
|
||||
#else
|
||||
strcat(mfl.dir[drv], "../");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int WinUI_Menu(int first)
|
||||
{
|
||||
int i, n;
|
||||
int cursor0;
|
||||
BYTE joy;
|
||||
int menu_redraw = 0;
|
||||
int pad_changed = 0;
|
||||
int mfile_redraw = 0;
|
||||
|
||||
if (first) {
|
||||
menu_state = ms_key;
|
||||
mkey_y = 0;
|
||||
mkey_pos = 0;
|
||||
menu_redraw = 1;
|
||||
first = 0;
|
||||
// The screen is not rewritten without any key actions,
|
||||
// so draw screen first.
|
||||
WinDraw_ClearMenuBuffer();
|
||||
WinDraw_DrawMenu(menu_state, mkey_pos, mkey_y, mval_y);
|
||||
}
|
||||
|
||||
cursor0 = mkey_y;
|
||||
joy = get_joy_downstate();
|
||||
reset_joy_downstate();
|
||||
|
||||
|
||||
if (!(joy & JOY_UP)) {
|
||||
switch (menu_state) {
|
||||
case ms_key:
|
||||
if (mkey_y > 0) {
|
||||
mkey_y--;
|
||||
}
|
||||
if (mkey_pos > mkey_y) {
|
||||
mkey_pos--;
|
||||
}
|
||||
break;
|
||||
case ms_value:
|
||||
if (mval_y[mkey_y] > 0) {
|
||||
mval_y[mkey_y]--;
|
||||
|
||||
// do something immediately
|
||||
if (menu_func[mkey_y].imm) {
|
||||
menu_func[mkey_y].func(mval_y[mkey_y]);
|
||||
}
|
||||
|
||||
menu_redraw = 1;
|
||||
}
|
||||
break;
|
||||
case ms_file:
|
||||
if (mfl.y == 0) {
|
||||
if (mfl.ptr > 0) {
|
||||
mfl.ptr--;
|
||||
}
|
||||
} else {
|
||||
mfl.y--;
|
||||
}
|
||||
mfile_redraw = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(joy & JOY_DOWN)) {
|
||||
switch (menu_state) {
|
||||
case ms_key:
|
||||
if (mkey_y < MENU_NUM - 1) {
|
||||
mkey_y++;
|
||||
}
|
||||
if (mkey_y > mkey_pos + MENU_WINDOW - 1) {
|
||||
mkey_pos++;
|
||||
}
|
||||
break;
|
||||
case ms_value:
|
||||
if (menu_items[mkey_y][mval_y[mkey_y] + 1][0] != '\0') {
|
||||
mval_y[mkey_y]++;
|
||||
|
||||
if (menu_func[mkey_y].imm) {
|
||||
menu_func[mkey_y].func(mval_y[mkey_y]);
|
||||
}
|
||||
|
||||
menu_redraw = 1;
|
||||
}
|
||||
break;
|
||||
case ms_file:
|
||||
if (mfl.y == 13) {
|
||||
if (mfl.ptr + 14 < mfl.num
|
||||
&& mfl.ptr < MFL_MAX - 13) {
|
||||
mfl.ptr++;
|
||||
}
|
||||
} else if (mfl.y + 1 < mfl.num) {
|
||||
mfl.y++;
|
||||
printf("mfl.y %d\n", mfl.y);
|
||||
}
|
||||
mfile_redraw = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(joy & JOY_TRG1)) {
|
||||
int drv, y;
|
||||
switch (menu_state) {
|
||||
case ms_key:
|
||||
menu_state = ms_value;
|
||||
menu_redraw = 1;
|
||||
break;
|
||||
case ms_value:
|
||||
menu_func[mkey_y].func(mval_y[mkey_y]);
|
||||
|
||||
if (menu_state == ms_hwjoy_set) {
|
||||
menu_redraw = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// get back key_mode if value is set.
|
||||
// go file_mode if value is filename.
|
||||
menu_state = ms_key;
|
||||
menu_redraw = 1;
|
||||
|
||||
drv = WinUI_get_drv_num(mkey_y);
|
||||
printf("**** drv:%d *****\n", drv);
|
||||
if (drv >= 0) {
|
||||
if (mval_y[mkey_y] == 0) {
|
||||
// go file_mode
|
||||
printf("hoge:%d", mval_y[mkey_y]);
|
||||
menu_state = ms_file;
|
||||
menu_redraw = 0; //reset
|
||||
mfile_redraw = 1;
|
||||
} else { // mval_y[mkey_y] == 1
|
||||
// FDD_EjectFD() is done, so set 0.
|
||||
mval_y[mkey_y] = 0;
|
||||
}
|
||||
} else if (!strcmp("SYSTEM", menu_item_key[mkey_y])) {
|
||||
if (mval_y[mkey_y] == 2) {
|
||||
return WUM_EMU_QUIT;
|
||||
}
|
||||
return WUM_MENU_END;
|
||||
}
|
||||
break;
|
||||
case ms_file:
|
||||
drv = WinUI_get_drv_num(mkey_y);
|
||||
printf("***** drv:%d *****\n", drv);
|
||||
if (drv < 0) {
|
||||
break;
|
||||
}
|
||||
y = mfl.ptr + mfl.y;
|
||||
p6logd("file slect %s\n", mfl.name[y]);
|
||||
if (mfl.type[y]) {
|
||||
// directory operation
|
||||
if (!strcmp(mfl.name[y], "..")) {
|
||||
shortcut_dir(drv);
|
||||
} else {
|
||||
strcat(mfl.dir[drv], mfl.name[y]);
|
||||
#ifdef _WIN32
|
||||
strcat(mfl.dir[drv], "\\");
|
||||
#else
|
||||
strcat(mfl.dir[drv], "/");
|
||||
#endif
|
||||
}
|
||||
menu_func[mkey_y].func(0);
|
||||
mfile_redraw = 1;
|
||||
} else {
|
||||
// file operation
|
||||
if (strlen(mfl.name[y]) != 0) {
|
||||
char tmpstr[MAX_PATH];
|
||||
strcpy(tmpstr, mfl.dir[drv]);
|
||||
strcat(tmpstr, mfl.name[y]);
|
||||
if (drv < 2) {
|
||||
FDD_SetFD(drv, tmpstr, 0);
|
||||
strcpy(Config.FDDImage[drv], tmpstr);
|
||||
} else {
|
||||
strcpy(Config.HDImage[drv - 2], tmpstr);
|
||||
}
|
||||
}
|
||||
menu_state = ms_key;
|
||||
menu_redraw = 1;
|
||||
}
|
||||
mfl.y = 0;
|
||||
mfl.ptr = 0;
|
||||
break;
|
||||
case ms_hwjoy_set:
|
||||
// Go back keymode
|
||||
// if TRG1 of v-pad or hw keyboard was pushed.
|
||||
if (!pad_changed) {
|
||||
menu_state = ms_key;
|
||||
menu_redraw = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(joy & JOY_TRG2)) {
|
||||
switch (menu_state) {
|
||||
case ms_file:
|
||||
menu_state = ms_value;
|
||||
// reset position of file cursor
|
||||
mfl.y = 0;
|
||||
mfl.ptr = 0;
|
||||
menu_redraw = 1;
|
||||
break;
|
||||
case ms_value:
|
||||
menu_state = ms_key;
|
||||
menu_redraw = 1;
|
||||
break;
|
||||
case ms_hwjoy_set:
|
||||
// Go back keymode
|
||||
// if TRG2 of v-pad or hw keyboard was pushed.
|
||||
if (!pad_changed) {
|
||||
menu_state = ms_key;
|
||||
menu_redraw = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pad_changed) {
|
||||
menu_redraw = 1;
|
||||
}
|
||||
|
||||
if (cursor0 != mkey_y) {
|
||||
menu_redraw = 1;
|
||||
}
|
||||
|
||||
if (mfile_redraw) {
|
||||
WinDraw_DrawMenufile(&mfl);
|
||||
mfile_redraw = 0;
|
||||
}
|
||||
|
||||
if (menu_redraw) {
|
||||
WinDraw_ClearMenuBuffer();
|
||||
WinDraw_DrawMenu(menu_state, mkey_pos, mkey_y, mval_y);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _winx68k_winui_h
|
||||
#define _winx68k_winui_h
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern BYTE Debug_Text, Debug_Grp, Debug_Sp;
|
||||
extern DWORD LastClock[4];
|
||||
|
||||
extern char cur_dir_str[];
|
||||
extern int cur_dir_slen;
|
||||
|
||||
void WinUI_Init(void);
|
||||
int WinUI_Menu(int first);
|
||||
float WinUI_get_vkscale(void);
|
||||
void send_key(void);
|
||||
|
||||
#define WUM_MENU_END 1
|
||||
#define WUM_EMU_QUIT 2
|
||||
|
||||
enum MenuState {ms_key, ms_value, ms_file, ms_hwjoy_set};
|
||||
|
||||
#define MFL_MAX 1000
|
||||
|
||||
struct menu_flist {
|
||||
char name[MFL_MAX][MAX_PATH];
|
||||
char type[MFL_MAX];
|
||||
char dir[4][MAX_PATH];
|
||||
int ptr;
|
||||
int num;
|
||||
int y;
|
||||
};
|
||||
|
||||
extern char menu_item_key[][15];
|
||||
extern char menu_items[][15][30];
|
||||
|
||||
int WinUI_get_drv_num(int key);
|
||||
|
||||
#ifndef _winx68k_gtkui_h
|
||||
#define _winx68k_gtkui_h
|
||||
#endif //winx68k_gtkui_h
|
||||
#endif //winx68k_winui_h
|
||||
@@ -0,0 +1,797 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "fileio.h"
|
||||
#include "timer.h"
|
||||
#include "keyboard.h"
|
||||
#include "prop.h"
|
||||
#include "status.h"
|
||||
#include "joystick.h"
|
||||
#include "mkcgrom.h"
|
||||
#include "winx68k.h"
|
||||
#include "windraw.h"
|
||||
#include "winui.h"
|
||||
#include "../x68k/m68000.h" // xxx €³€ì€Ï€€€º€ì€€€é€Ê€¯€Ê€ë€Ï€º
|
||||
#include "../m68000/m68000.h"
|
||||
#include "../x68k/memory.h"
|
||||
#include "mfp.h"
|
||||
#include "opm.h"
|
||||
#include "bg.h"
|
||||
#include "adpcm.h"
|
||||
#include "mercury.h"
|
||||
#include "crtc.h"
|
||||
#include "mfp.h"
|
||||
#include "fdc.h"
|
||||
#include "fdd.h"
|
||||
#include "dmac.h"
|
||||
#include "irqh.h"
|
||||
#include "ioc.h"
|
||||
#include "rtc.h"
|
||||
#include "sasi.h"
|
||||
#include "scsi.h"
|
||||
#include "sysport.h"
|
||||
#include "bg.h"
|
||||
#include "palette.h"
|
||||
#include "crtc.h"
|
||||
#include "pia.h"
|
||||
#include "scc.h"
|
||||
#include "midi.h"
|
||||
#include "sram.h"
|
||||
#include "gvram.h"
|
||||
#include "tvram.h"
|
||||
#include "mouse.h"
|
||||
|
||||
#include "dswin.h"
|
||||
#include "fmg_wrap.h"
|
||||
|
||||
#ifdef RFMDRV
|
||||
int rfd_sock;
|
||||
#endif
|
||||
|
||||
//#define WIN68DEBUG
|
||||
|
||||
#ifdef WIN68DEBUG
|
||||
#include "d68k.h"
|
||||
#endif
|
||||
|
||||
//#include "../icons/keropi_mono.xbm"
|
||||
|
||||
#define APPNAME "Keropi"
|
||||
|
||||
extern WORD BG_CHREND;
|
||||
extern WORD BG_BGTOP;
|
||||
extern WORD BG_BGEND;
|
||||
extern BYTE BG_CHRSIZE;
|
||||
|
||||
const BYTE PrgName[] = "Keropi";
|
||||
const BYTE PrgTitle[] = APPNAME;
|
||||
|
||||
char winx68k_dir[MAX_PATH];
|
||||
char winx68k_ini[MAX_PATH];
|
||||
|
||||
WORD VLINE_TOTAL = 567;
|
||||
DWORD VLINE = 0;
|
||||
DWORD vline = 0;
|
||||
|
||||
extern int SplashFlag;
|
||||
|
||||
BYTE DispFrame = 0;
|
||||
DWORD SoundSampleRate;
|
||||
|
||||
unsigned int hTimerID = 0;
|
||||
DWORD TimerICount = 0;
|
||||
extern DWORD timertick;
|
||||
BYTE traceflag = 0;
|
||||
|
||||
BYTE ForceDebugMode = 0;
|
||||
DWORD skippedframes = 0;
|
||||
|
||||
static int ClkUsed = 0;
|
||||
static int FrameSkipCount = 0;
|
||||
static int FrameSkipQueue = 0;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
WinX68k_SCSICheck(void)
|
||||
{
|
||||
static const BYTE SCSIIMG[] = {
|
||||
0x00, 0xfc, 0x00, 0x14, // $fc0000 SCSIµ¯Æ°ÍрΥš¥ó¥È¥ê¥¢¥É¥ì¥¹
|
||||
0x00, 0xfc, 0x00, 0x16, // $fc0004 IOCS¥Ù¥¯¥¿ÀßÄê€Î¥š¥ó¥È¥ê¥¢¥É¥ì¥¹(ɬ€º"Human"€Î8¥Ð¥€¥ÈÁ°)
|
||||
0x00, 0x00, 0x00, 0x00, // $fc0008 ?
|
||||
0x48, 0x75, 0x6d, 0x61, // $fc000c ¢
|
||||
0x6e, 0x36, 0x38, 0x6b, // $fc0010 ID "Human68k" (ɬ€ºµ¯Æ°¥š¥ó¥È¥ê¥Ý¥€¥ó¥È€ÎÄŸÁ°)
|
||||
0x4e, 0x75, // $fc0014 "rts" (µ¯Æ°¥š¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x23, 0xfc, 0x00, 0xfc, 0x00, 0x2a, // $fc0016 ¢ (IOCS¥Ù¥¯¥¿ÀßÄ꥚¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x00, 0x00, 0x07, 0xd4, // $fc001c "move.l #$fc002a, $7d4.l"
|
||||
0x74, 0xff, // $fc0020 "moveq #-1, d2"
|
||||
0x4e, 0x75, // $fc0022 "rts"
|
||||
// 0x53, 0x43, 0x53, 0x49, 0x49, 0x4e, // $fc0024 ID "SCSIIN"
|
||||
// Æâ¢SCSI€òON€Ë€¹€ë€È¡¢SASI€ÏŒ«Æ°Åª€ËOFF€Ë€Ê€Ã€Á€ã€Š€é€·€€¡Ä
|
||||
// €è€Ã€Æ¡¢ID€Ï¥Þ¥Ã¥Á€·€Ê€€€è€Š€Ë€·€Æ€ª€¯¡Ä
|
||||
0x44, 0x55, 0x4d, 0x4d, 0x59, 0x20, // $fc0024 ID "DUMMY "
|
||||
0x70, 0xff, // $fc002a "moveq #-1, d0" (SCSI IOCS¥³¡Œ¥ë¥š¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x4e, 0x75, // $fc002c "rts"
|
||||
};
|
||||
|
||||
#if 0
|
||||
DWORD *p;
|
||||
#endif
|
||||
WORD *p1, *p2;
|
||||
int scsi;
|
||||
int i;
|
||||
|
||||
scsi = 0;
|
||||
for (i = 0x30600; i < 0x30c00; i += 2) {
|
||||
#if 0 // 4€ÎÇÜ¿ô€Ç€Ï€Ê€€¶ö¿ô¥¢¥É¥ì¥¹€«€é€Î4¥Ð¥€¥ÈĹ¥¢¥¯¥»¥¹€ÏMIPS€Ë€Ï̵Íý
|
||||
p = (DWORD *)(&IPL[i]);
|
||||
if (*p == 0x0000fc00)
|
||||
scsi = 1;
|
||||
#else
|
||||
p1 = (WORD *)(&IPL[i]);
|
||||
p2 = p1 + 1;
|
||||
// xxx: works only for little endian guys
|
||||
if (*p1 == 0xfc00 && *p2 == 0x0000) {
|
||||
scsi = 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// SCSI¥â¥Ç¥ë€Î€È€
|
||||
if (scsi) {
|
||||
ZeroMemory(IPL, 0x2000); // ËÜÂ΀Ï8kb
|
||||
memset(&IPL[0x2000], 0xff, 0x1e000); // »Ä€ê€Ï0xff
|
||||
memcpy(IPL, SCSIIMG, sizeof(SCSIIMG)); // ¥€¥ó¥Á¥SCSI BIOS
|
||||
// Memory_SetSCSIMode();
|
||||
} else {
|
||||
// SASI¥â¥Ç¥ë€ÏIPL€¬€œ€Î€Þ€Þž«€š€ë
|
||||
memcpy(IPL, &IPL[0x20000], 0x20000);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
WinX68k_LoadROMs(void)
|
||||
{
|
||||
static const char *BIOSFILE[] = {
|
||||
"iplrom.dat", "iplrom30.dat", "iplromco.dat", "iplromxv.dat"
|
||||
};
|
||||
static const char FONTFILE[] = "cgrom.dat";
|
||||
static const char FONTFILETMP[] = "cgrom.tmp";
|
||||
FILEH fp;
|
||||
int i;
|
||||
BYTE tmp;
|
||||
|
||||
for (fp = 0, i = 0; fp == 0 && i < NELEMENTS(BIOSFILE); ++i) {
|
||||
fp = File_OpenCurDir((char *)BIOSFILE[i]);
|
||||
printf("fp:%d (%s)\n",fp,(char *)BIOSFILE[i]);
|
||||
}
|
||||
|
||||
if (fp == 0) {
|
||||
Error("BIOS ROM ¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
File_Read(fp, &IPL[0x20000], 0x20000);
|
||||
File_Close(fp);
|
||||
|
||||
WinX68k_SCSICheck(); // SCSI IPL€Ê€é¡¢$fc0000¡Á€ËSCSI BIOS€òÃÖ€¯
|
||||
|
||||
for (i = 0; i < 0x40000; i += 2) {
|
||||
tmp = IPL[i];
|
||||
IPL[i] = IPL[i + 1];
|
||||
IPL[i + 1] = tmp;
|
||||
}
|
||||
|
||||
fp = File_OpenCurDir((char *)FONTFILE);
|
||||
if (fp == 0) {
|
||||
// cgrom.tmp€¬€¢€ë¡©
|
||||
fp = File_OpenCurDir((char *)FONTFILETMP);
|
||||
if (fp == 0) {
|
||||
#if 1
|
||||
// ¥Õ¥©¥ó¥ÈÀžÀ® XXX
|
||||
printf("¥Õ¥©¥ó¥ÈROM¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó\n");
|
||||
return FALSE;
|
||||
#else
|
||||
MessageBox(hWndMain,
|
||||
"¥Õ¥©¥ó¥ÈROM¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó.\nWindows¥Õ¥©¥ó¥È€«€é¿·µ¬€ËºîÀ®€·€Þ€¹.",
|
||||
"€±€í€Ô¡Œ€Î¥á¥Ã¥»¡Œ¥ž", MB_ICONWARNING | MB_OK);
|
||||
SSTP_SendMes(SSTPMES_MAKEFONT);
|
||||
make_cgromdat(FONT, FALSE, "£Í£Ó ¥Ž¥·¥Ã¥¯", "£Í£Ó ÌÀÄ«");
|
||||
//WinX68k_MakeFont();
|
||||
//DialogBox(hInst, MAKEINTRESOURCE(IDD_PROGBAR),
|
||||
// hWndMain, (DLGPROC)MakeFontProc);
|
||||
fp = File_CreateCurDir(FONTFILETMP);
|
||||
if (fp)
|
||||
{
|
||||
File_Write(fp, FONT, 0xc0000);
|
||||
File_Close(fp);
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
File_Read(fp, FONT, 0xc0000);
|
||||
File_Close(fp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
WinX68k_Reset(void)
|
||||
{
|
||||
OPM_Reset();
|
||||
|
||||
C68k_Reset(&C68K);
|
||||
/*
|
||||
C68k_Set_Reg(&C68K, C68K_A7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]);
|
||||
C68k_Set_Reg(&C68K, C68K_PC, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]);
|
||||
*/
|
||||
C68k_Set_AReg(&C68K, 7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]);
|
||||
C68k_Set_PC(&C68K, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]);
|
||||
Memory_Init();
|
||||
CRTC_Init();
|
||||
DMA_Init();
|
||||
MFP_Init();
|
||||
FDC_Init();
|
||||
FDD_Reset();
|
||||
SASI_Init();
|
||||
SCSI_Init();
|
||||
IOC_Init();
|
||||
SCC_Init();
|
||||
PIA_Init();
|
||||
RTC_Init();
|
||||
TVRAM_Init();
|
||||
GVRAM_Init();
|
||||
BG_Init();
|
||||
Pal_Init();
|
||||
IRQH_Init();
|
||||
MIDI_Init();
|
||||
//WinDrv_Init();
|
||||
|
||||
// C68K.ICount = 0;
|
||||
m68000_ICountBk = 0;
|
||||
ICount = 0;
|
||||
|
||||
DSound_Stop();
|
||||
SRAM_VirusCheck();
|
||||
//CDROM_Init();
|
||||
DSound_Play();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
WinX68k_Init(void)
|
||||
{
|
||||
|
||||
#define MEM_SIZE 0xc00000
|
||||
|
||||
IPL = (BYTE*)malloc(0x40000);
|
||||
MEM = (BYTE*)malloc(MEM_SIZE);
|
||||
FONT = (BYTE*)malloc(0xc0000);
|
||||
|
||||
if (MEM)
|
||||
ZeroMemory(MEM, MEM_SIZE);
|
||||
|
||||
if (MEM && FONT && IPL) {
|
||||
m68000_init();
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
WinX68k_Cleanup(void)
|
||||
{
|
||||
|
||||
if (IPL) {
|
||||
free(IPL);
|
||||
IPL = 0;
|
||||
}
|
||||
if (MEM) {
|
||||
free(MEM);
|
||||
MEM = 0;
|
||||
}
|
||||
if (FONT) {
|
||||
free(FONT);
|
||||
FONT = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define CLOCK_SLICE 200
|
||||
// -----------------------------------------------------------------------------------
|
||||
// ¥³¥¢€Î€á€€€ó€ë¡Œ€×
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WinX68k_Exec(void)
|
||||
{
|
||||
//char *test = NULL;
|
||||
int clk_total, clkdiv, usedclk, hsync, clk_next, clk_count, clk_line=0;
|
||||
int KeyIntCnt = 0, MouseIntCnt = 0;
|
||||
DWORD t_start = timeGetTime(), t_end;
|
||||
|
||||
if ( Config.FrameRate != 7 ) {
|
||||
DispFrame = (DispFrame+1)%Config.FrameRate;
|
||||
} else { // Auto Frame Skip
|
||||
if ( FrameSkipQueue ) {
|
||||
if ( FrameSkipCount>15 ) {
|
||||
FrameSkipCount = 0;
|
||||
FrameSkipQueue++;
|
||||
DispFrame = 0;
|
||||
} else {
|
||||
FrameSkipCount++;
|
||||
FrameSkipQueue--;
|
||||
DispFrame = 1;
|
||||
}
|
||||
} else {
|
||||
FrameSkipCount = 0;
|
||||
DispFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
vline = 0;
|
||||
clk_count = -ICount;
|
||||
clk_total = (CRTC_Regs[0x29] & 0x10) ? VSYNC_HIGH : VSYNC_NORM;
|
||||
if (Config.XVIMode == 1) {
|
||||
clk_total = (clk_total*16)/10;
|
||||
clkdiv = 16;
|
||||
} else if (Config.XVIMode == 2) {
|
||||
clk_total = (clk_total*24)/10;
|
||||
clkdiv = 24;
|
||||
} else {
|
||||
clkdiv = 10;
|
||||
}
|
||||
ICount += clk_total;
|
||||
clk_next = (clk_total/VLINE_TOTAL);
|
||||
hsync = 1;
|
||||
|
||||
do {
|
||||
int m, n = (ICount>CLOCK_SLICE)?CLOCK_SLICE:ICount;
|
||||
// C68K.ICount = m68000_ICountBk = 0; // ³ä€ê¹þ€ßȯÀžÁ°€ËÍ¿€š€Æ€ª€«€Ê€€€È¥À¥á¡ÊCARAT¡Ë
|
||||
|
||||
if ( hsync ) {
|
||||
hsync = 0;
|
||||
clk_line = 0;
|
||||
MFP_Int(0);
|
||||
if ( (vline>=CRTC_VSTART)&&(vline<CRTC_VEND) )
|
||||
VLINE = ((vline-CRTC_VSTART)*CRTC_VStep)/2;
|
||||
else
|
||||
VLINE = (DWORD)-1;
|
||||
if ( (!(MFP[MFP_AER]&0x40))&&(vline==CRTC_IntLine) )
|
||||
MFP_Int(1);
|
||||
if ( MFP[MFP_AER]&0x10 ) {
|
||||
if ( vline==CRTC_VSTART )
|
||||
MFP_Int(9);
|
||||
} else {
|
||||
if ( CRTC_VEND>=VLINE_TOTAL ) {
|
||||
if ( (long)vline==(CRTC_VEND-VLINE_TOTAL) ) MFP_Int(9); // ¥š¥¥µ¥€¥Æ¥£¥ó¥°¥¢¥ï¡Œ€È€«¡ÊTOTAL<VEND¡Ë
|
||||
} else {
|
||||
if ( (long)vline==(VLINE_TOTAL-1) ) MFP_Int(9); // ¥¯¥ì¥€¥ž¡Œ¥¯¥é¥€¥Þ¡Œ€Ï¥³¥ì€Ç€Ê€€€È¥À¥á¡©
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN68DEBUG
|
||||
if (traceflag/*&&fdctrace*/)
|
||||
{
|
||||
FILE *fp;
|
||||
static DWORD oldpc;
|
||||
int i;
|
||||
char buf[200];
|
||||
fp=fopen("_trace68.txt", "a");
|
||||
for (i=0; i<HSYNC_CLK; i++)
|
||||
{
|
||||
m68k_disassemble(buf, C68k_Get_Reg(&C68K, C68K_PC));
|
||||
// if (MEM[0xa84c0]) /**test=1; */tracing=1000;
|
||||
// if (regs.pc==0x9d2a) tracing=5000;
|
||||
// if ((regs.pc>=0x2000)&&((regs.pc<=0x8e0e0))) tracing=50000;
|
||||
// if (regs.pc<0x10000) tracing=1;
|
||||
// if ( (regs.pc&1) )
|
||||
// fp=fopen("_trace68.txt", "a");
|
||||
// if ( (regs.pc==0x7176) /*&& (Memory_ReadW(oldpc)==0xff1a)*/ ) tracing=100;
|
||||
// if ( (/*((regs.pc>=0x27000) && (regs.pc<=0x29000))||*/((regs.pc>=0x27000) && (regs.pc<=0x29000))) && (oldpc!=regs.pc))
|
||||
if (/*fdctrace&&*/(oldpc != C68k_Get_Reg(&C68K, C68K_PC)))
|
||||
{
|
||||
// //tracing--;
|
||||
fprintf(fp, "D0:%08X D1:%08X D2:%08X D3:%08X D4:%08X D5:%08X D6:%08X D7:%08X CR:%04X\n", C68K.D[0], C68K.D[1], C68K.D[2], C68K.D[3], C68K.D[4], C68K.D[5], C68K.D[6], C68K.D[7], 0/* xxx €È€ê€¢€š€º0 C68K.ccr */);
|
||||
fprintf(fp, "A0:%08X A1:%08X A2:%08X A3:%08X A4:%08X A5:%08X A6:%08X A7:%08X SR:%04X\n", C68K.A[0], C68K.A[1], C68K.A[2], C68K.A[3], C68K.A[4], C68K.A[5], C68K.A[6], C68K.A[7], C68k_Get_Reg(&C68K, C68K_SR) >> 8/* regs.sr_high*/);
|
||||
fprintf(fp, "<%04X> (%08X ->) %08X : %s\n", Memory_ReadW(C68k_Get_Reg(&C68K, C68K_PC)), oldpc, C68k_Get_Reg(&C68K, C68K_PC), buf);
|
||||
}
|
||||
oldpc = C68k_Get_Reg(&C68K, C68K_PC);
|
||||
// C68K.ICount = 1;
|
||||
// C68k_Exec(&C68K, C68K.ICount);
|
||||
C68k_Exec(&C68K, 1);
|
||||
}
|
||||
fclose(fp);
|
||||
usedclk = clk_line = HSYNC_CLK;
|
||||
clk_count = clk_next;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// C68K.ICount = n;
|
||||
// C68k_Exec(&C68K, C68K.ICount);
|
||||
C68k_Exec(&C68K, n);
|
||||
m = (n-m68000_ICountBk); // 経過クロック数
|
||||
// m = (n-C68K.ICount-m68000_ICountBk); // ·Ð²á¥¯¥í¥Ã¥¯¿ô
|
||||
ClkUsed += m*10;
|
||||
usedclk = ClkUsed/clkdiv;
|
||||
clk_line += usedclk;
|
||||
ClkUsed -= usedclk*clkdiv;
|
||||
ICount -= m;
|
||||
clk_count += m;
|
||||
// C68K.ICount = m68000_ICountBk = 0;
|
||||
}
|
||||
|
||||
MFP_Timer(usedclk);
|
||||
RTC_Timer(usedclk);
|
||||
DMA_Exec(0);
|
||||
DMA_Exec(1);
|
||||
DMA_Exec(2);
|
||||
|
||||
if ( clk_count>=clk_next ) {
|
||||
//OPM_RomeoOut(Config.BufferSize*5);
|
||||
//MIDI_DelayOut((Config.MIDIAutoDelay)?(Config.BufferSize*5):Config.MIDIDelay);
|
||||
MFP_TimerA();
|
||||
if ( (MFP[MFP_AER]&0x40)&&(vline==CRTC_IntLine) )
|
||||
MFP_Int(1);
|
||||
if ( (!DispFrame)&&(vline>=CRTC_VSTART)&&(vline<CRTC_VEND) ) {
|
||||
if ( CRTC_VStep==1 ) { // HighReso 256dot¡Ê2ÅÙÆÉ€ß¡Ë
|
||||
if ( vline%2 )
|
||||
WinDraw_DrawLine();
|
||||
} else if ( CRTC_VStep==4 ) { // LowReso 512dot
|
||||
WinDraw_DrawLine(); // 1ÁöººÀþ€Ç2²óÉÁ€¯¡Ê¥€¥ó¥¿¡Œ¥ì¡Œ¥¹¡Ë
|
||||
VLINE++;
|
||||
WinDraw_DrawLine();
|
||||
} else { // High 512dot / Low 256dot
|
||||
WinDraw_DrawLine();
|
||||
}
|
||||
}
|
||||
|
||||
ADPCM_PreUpdate(clk_line);
|
||||
OPM_Timer(clk_line);
|
||||
MIDI_Timer(clk_line);
|
||||
#ifndef NO_MERCURY
|
||||
Mcry_PreUpdate(clk_line);
|
||||
#endif
|
||||
|
||||
KeyIntCnt++;
|
||||
if ( KeyIntCnt>(VLINE_TOTAL/4) ) {
|
||||
KeyIntCnt = 0;
|
||||
Keyboard_Int();
|
||||
}
|
||||
MouseIntCnt++;
|
||||
if ( MouseIntCnt>(VLINE_TOTAL/8) ) {
|
||||
MouseIntCnt = 0;
|
||||
SCC_IntCheck();
|
||||
}
|
||||
DSound_Send0(clk_line);
|
||||
|
||||
vline++;
|
||||
clk_next = (clk_total*(vline+1))/VLINE_TOTAL;
|
||||
hsync = 1;
|
||||
}
|
||||
} while ( vline<VLINE_TOTAL );
|
||||
|
||||
if ( CRTC_Mode&2 ) { // FastClr¥Ó¥Ã¥È€ÎÄŽÀ°¡ÊPITAPAT¡Ë
|
||||
if ( CRTC_FastClr ) { // FastClr=1 ³î€Ä CRTC_Mode&2 €Ê€é œªÎ»
|
||||
CRTC_FastClr--;
|
||||
if ( !CRTC_FastClr )
|
||||
CRTC_Mode &= 0xfd;
|
||||
} else { // FastClr³«»Ï
|
||||
if ( CRTC_Regs[0x29]&0x10 )
|
||||
CRTC_FastClr = 1;
|
||||
else
|
||||
CRTC_FastClr = 2;
|
||||
TVRAM_SetAllDirty();
|
||||
GVRAM_FastClear();
|
||||
}
|
||||
}
|
||||
|
||||
Joystick_Update(FALSE, -1);
|
||||
|
||||
FDD_SetFDInt();
|
||||
if ( !DispFrame )
|
||||
WinDraw_Draw();
|
||||
TimerICount += clk_total;
|
||||
|
||||
t_end = timeGetTime();
|
||||
if ( (int)(t_end-t_start)>((CRTC_Regs[0x29]&0x10)?14:16) ) {
|
||||
FrameSkipQueue += ((t_end-t_start)/((CRTC_Regs[0x29]&0x10)?14:16))+1;
|
||||
if ( FrameSkipQueue>100 )
|
||||
FrameSkipQueue = 100;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "libretro.h"
|
||||
|
||||
extern retro_input_state_t input_state_cb;
|
||||
extern char Core_Key_Sate[512];
|
||||
extern char Core_old_Key_Sate[512];
|
||||
|
||||
int mb1=0,mb2=0;
|
||||
extern int retrow,retroh,CHANGEAV;
|
||||
static int oldrw=0,oldrh=0;
|
||||
int end_loop=0;
|
||||
|
||||
enum {menu_out, menu_enter, menu_in};
|
||||
int menu_mode = menu_out;
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
extern "C" int pmain(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int raudio = -1;
|
||||
|
||||
p6logd("PX68K Ver.%s\n", PX68KVERSTR);
|
||||
|
||||
#ifdef RFMDRV
|
||||
struct sockaddr_in dest;
|
||||
|
||||
memset(&dest, 0, sizeof(dest));
|
||||
dest.sin_port = htons(2151);
|
||||
dest.sin_family = AF_INET;
|
||||
dest.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
|
||||
rfd_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
connect (rfd_sock, (struct sockaddr *)&dest, sizeof(dest));
|
||||
#endif
|
||||
|
||||
if (set_modulepath(winx68k_dir, sizeof(winx68k_dir)))
|
||||
return 1;
|
||||
|
||||
dosio_init();
|
||||
file_setcd(winx68k_dir);
|
||||
puts(winx68k_dir);
|
||||
|
||||
LoadConfig();
|
||||
|
||||
if (!WinDraw_MenuInit()) {
|
||||
WinX68k_Cleanup();
|
||||
WinDraw_Cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
SplashFlag = 20;
|
||||
SoundSampleRate = Config.SampleRate;
|
||||
|
||||
StatBar_Show(Config.WindowFDDStat);
|
||||
WinDraw_ChangeSize();
|
||||
WinDraw_ChangeMode(FALSE);
|
||||
|
||||
WinUI_Init();
|
||||
WinDraw_StartupScreen();
|
||||
|
||||
if (!WinX68k_Init()) {
|
||||
WinX68k_Cleanup();
|
||||
WinDraw_Cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!WinX68k_LoadROMs()) {
|
||||
WinX68k_Cleanup();
|
||||
WinDraw_Cleanup();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
Keyboard_Init(); //WinDraw_Init()Á°€Ë°Üư
|
||||
|
||||
if (!WinDraw_Init()) {
|
||||
WinDraw_Cleanup();
|
||||
Error("Error: Can't init screen.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( SoundSampleRate ) {
|
||||
ADPCM_Init(SoundSampleRate);
|
||||
OPM_Init(4000000/*3579545*/, SoundSampleRate);
|
||||
#ifndef NO_MERCURY
|
||||
Mcry_Init(SoundSampleRate, winx68k_dir);
|
||||
#endif
|
||||
} else {
|
||||
ADPCM_Init(100);
|
||||
OPM_Init(4000000/*3579545*/, 100);
|
||||
#ifndef NO_MERCURY
|
||||
Mcry_Init(100, winx68k_dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
FDD_Init();
|
||||
SysPort_Init();
|
||||
Mouse_Init();
|
||||
Joystick_Init();
|
||||
SRAM_Init();
|
||||
WinX68k_Reset();
|
||||
Timer_Init();
|
||||
|
||||
MIDI_Init();
|
||||
MIDI_SetMimpiMap(Config.ToneMapFile); // ²»¿§ÀßÄê¥Õ¥¡¥€¥ë»ÈÍÑÈ¿±Ç
|
||||
MIDI_EnableMimpiDef(Config.ToneMap);
|
||||
|
||||
if (/*raudio == 0 &&*/ !DSound_Init(Config.SampleRate, Config.BufferSize)) {
|
||||
|
||||
if (Config.DSAlert)
|
||||
fprintf(stderr, "Can't init sound.\n");
|
||||
}
|
||||
|
||||
ADPCM_SetVolume((BYTE)Config.PCM_VOL);
|
||||
OPM_SetVolume((BYTE)Config.OPM_VOL);
|
||||
#ifndef NO_MERCURY
|
||||
Mcry_SetVolume((BYTE)Config.MCR_VOL);
|
||||
#endif
|
||||
DSound_Play();
|
||||
|
||||
// command line €«€é»ØÄꀷ€¿Ÿì¹ç
|
||||
if(argc==3 && argv[1][0]=='-' && argv[1][1]=='h')
|
||||
strcpy(Config.HDImage[0], argv[2]);
|
||||
else {
|
||||
switch (argc) {
|
||||
case 3:
|
||||
strcpy(Config.FDDImage[1], argv[2]);
|
||||
case 2:
|
||||
strcpy(Config.FDDImage[0], argv[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FDD_SetFD(0, Config.FDDImage[0], 0);
|
||||
FDD_SetFD(1, Config.FDDImage[1], 0);
|
||||
|
||||
}
|
||||
|
||||
extern "C" void exec_app_retro(){
|
||||
|
||||
int menu_key_down;
|
||||
//while (1) {
|
||||
// OPM_RomeoOut(Config.BufferSize * 5);
|
||||
if (menu_mode == menu_out
|
||||
&& (Config.NoWaitMode || Timer_GetCount())) {
|
||||
WinX68k_Exec();
|
||||
|
||||
if (SplashFlag) {
|
||||
SplashFlag--;
|
||||
if (SplashFlag == 0)
|
||||
WinDraw_HideSplash();
|
||||
}
|
||||
}
|
||||
|
||||
menu_key_down = -1;
|
||||
//end_loop=1;
|
||||
|
||||
static int mbL = 0, mbR = 0;
|
||||
|
||||
int mouse_x = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
int mouse_y = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||
|
||||
Mouse_Event(0, mouse_x, mouse_y);
|
||||
|
||||
int mouse_l = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
||||
int mouse_r = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
||||
|
||||
if(mbL==0 && mouse_l){
|
||||
mbL=1;
|
||||
Mouse_Event(1,1.0,0);
|
||||
}
|
||||
else if(mbL==1 && !mouse_l)
|
||||
{
|
||||
mbL=0;
|
||||
Mouse_Event(1,0,0);
|
||||
}
|
||||
if(mbR==0 && mouse_r){
|
||||
mbR=1;
|
||||
Mouse_Event(2,1.0,0);
|
||||
}
|
||||
else if(mbR==1 && !mouse_r)
|
||||
{
|
||||
mbR=0;
|
||||
Mouse_Event(2,0,0);
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
for(i=0;i<320;i++)
|
||||
Core_Key_Sate[i]=input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,i) ? 0x80: 0;
|
||||
|
||||
if(memcmp( Core_Key_Sate,Core_old_Key_Sate , sizeof(Core_Key_Sate) ) )
|
||||
for(i=0;i<320;i++)
|
||||
if(Core_Key_Sate[i] && Core_Key_Sate[i]!=Core_old_Key_Sate[i] )
|
||||
{
|
||||
if(i==RETROK_F12)
|
||||
{
|
||||
if (menu_mode == menu_out) {
|
||||
oldrw=retrow;oldrh=retroh;
|
||||
retroh=600;retrow=800;
|
||||
CHANGEAV=1;
|
||||
menu_mode = menu_enter;
|
||||
DSound_Stop();
|
||||
} else {
|
||||
CHANGEAV=1;
|
||||
retrow=oldrw;retroh=oldrh;
|
||||
DSound_Play();
|
||||
menu_mode = menu_out;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef WIN68DEBUG
|
||||
if (i == RETROK_F10) {
|
||||
traceflag ^= 1;
|
||||
printf("trace %s\n", (traceflag)?"on":"off");
|
||||
}
|
||||
#endif
|
||||
if (menu_mode != menu_out) {
|
||||
menu_key_down = i;
|
||||
} else {
|
||||
Keyboard_KeyDown(i);
|
||||
}
|
||||
//printf("press: %d \n",i);
|
||||
|
||||
}
|
||||
else if ( !Core_Key_Sate[i] && Core_Key_Sate[i]!=Core_old_Key_Sate[i] )
|
||||
{
|
||||
//printf("release: %d \n",i);
|
||||
Keyboard_KeyUp(i);
|
||||
|
||||
}
|
||||
|
||||
memcpy(Core_old_Key_Sate,Core_Key_Sate , sizeof(Core_Key_Sate) );
|
||||
|
||||
|
||||
if (menu_mode != menu_out) {
|
||||
int ret;
|
||||
|
||||
Joystick_Update(TRUE, menu_key_down);
|
||||
|
||||
ret = WinUI_Menu(menu_mode == menu_enter);
|
||||
menu_mode = menu_in;
|
||||
if (ret == WUM_MENU_END) {
|
||||
DSound_Play();
|
||||
menu_mode = menu_out;
|
||||
} else if (ret == WUM_EMU_QUIT) {
|
||||
end_loop=1;
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
extern "C" void end_loop_retro(){
|
||||
//end_loop:
|
||||
Memory_WriteB(0xe8e00d, 0x31); // SRAMœñ€¹þ€ßµö²Ä
|
||||
Memory_WriteD(0xed0040, Memory_ReadD(0xed0040)+1); // ÀÑ»»²ÔƯ»þŽÖ(min.)
|
||||
Memory_WriteD(0xed0044, Memory_ReadD(0xed0044)+1); // ÀÑ»»µ¯Æ°²ó¿ô
|
||||
|
||||
OPM_Cleanup();
|
||||
#ifndef NO_MERCURY
|
||||
Mcry_Cleanup();
|
||||
#endif
|
||||
|
||||
Joystick_Cleanup();
|
||||
SRAM_Cleanup();
|
||||
FDD_Cleanup();
|
||||
//CDROM_Cleanup();
|
||||
MIDI_Cleanup();
|
||||
DSound_Cleanup();
|
||||
WinX68k_Cleanup();
|
||||
WinDraw_Cleanup();
|
||||
WinDraw_CleanupScreen();
|
||||
|
||||
SaveConfig();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef winx68k_wincore_h
|
||||
#define winx68k_wincore_h
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef RFMDRV
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
extern int rfd_sock;
|
||||
#endif
|
||||
|
||||
#define vline HOGEvline // workaround for redefinition of 'vline'
|
||||
|
||||
#define SCREEN_WIDTH 768
|
||||
#define SCREEN_HEIGHT 512
|
||||
|
||||
#define FULLSCREEN_WIDTH 800
|
||||
#define FULLSCREEN_HEIGHT 600
|
||||
#define FULLSCREEN_POSX ((FULLSCREEN_WIDTH - SCREEN_WIDTH) / 2)
|
||||
#define FULLSCREEN_POSY ((FULLSCREEN_HEIGHT - SCREEN_HEIGHT) / 2)
|
||||
|
||||
#define TOSTR(s) #s
|
||||
#define _TOSTR(s) TOSTR(s)
|
||||
#define PX68KVERSTR _TOSTR(PX68K_VERSION)
|
||||
|
||||
extern BYTE* FONT;
|
||||
|
||||
extern WORD VLINE_TOTAL;
|
||||
extern DWORD VLINE;
|
||||
extern DWORD vline;
|
||||
|
||||
extern char winx68k_dir[MAX_PATH];
|
||||
extern char winx68k_ini[MAX_PATH];
|
||||
extern int BIOS030Flag;
|
||||
extern BYTE FrameChanged;
|
||||
|
||||
extern const BYTE PrgTitle[];
|
||||
|
||||
#if defined(ANDROID) || TARGET_OS_IPHONE
|
||||
extern int realdisp_w, realdisp_h;
|
||||
#endif
|
||||
|
||||
int WinX68k_Reset(void);
|
||||
|
||||
#ifndef winx68k_gtkwarpper_h
|
||||
#define winx68k_gtkwarpper_h
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if 0
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
extern GtkWidget *window;
|
||||
extern GtkWidget *main_vbox;
|
||||
extern GtkWidget *menubar;
|
||||
extern GtkWidget *drawarea;
|
||||
extern GdkPixmap *splash_pixmap;
|
||||
#endif
|
||||
|
||||
BOOL is_installed_idle_process(void);
|
||||
void install_idle_process(void);
|
||||
void uninstall_idle_process(void);
|
||||
|
||||
#define NELEMENTS(array) ((int)(sizeof(array) / sizeof(array[0])))
|
||||
|
||||
#endif //winx68k_gtkwarpper_h
|
||||
|
||||
#endif //winx68k_wincore_h
|
||||
@@ -0,0 +1,315 @@
|
||||
/* Copyright 2003-2004 Stephane Dallongeville
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*! \file c68k.c
|
||||
\brief C68K init, interrupt and memory access functions.
|
||||
*/
|
||||
|
||||
/*********************************************************************************
|
||||
*
|
||||
* C68K (68000 CPU emulator) version 0.80
|
||||
* Compiled with Dev-C++
|
||||
* Copyright 2003-2004 Stephane Dallongeville
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "c68k.h"
|
||||
|
||||
// shared global variable
|
||||
//////////////////////////
|
||||
|
||||
c68k_struc C68K;
|
||||
|
||||
// include macro file
|
||||
//////////////////////
|
||||
|
||||
#include "c68kmac.inc"
|
||||
|
||||
// prototype
|
||||
/////////////
|
||||
|
||||
u32 FASTCALL C68k_Read_Dummy(const u32 adr);
|
||||
void FASTCALL C68k_Write_Dummy(const u32 adr, u32 data);
|
||||
|
||||
u32 C68k_Read_Byte(c68k_struc *cpu, u32 adr);
|
||||
u32 C68k_Read_Word(c68k_struc *cpu, u32 adr);
|
||||
u32 C68k_Read_Long(c68k_struc *cpu, u32 adr);
|
||||
void C68k_Write_Byte(c68k_struc *cpu, u32 adr, u32 data);
|
||||
void C68k_Write_Word(c68k_struc *cpu, u32 adr, u32 data);
|
||||
void C68k_Write_Long(c68k_struc *cpu, u32 adr, u32 data);
|
||||
|
||||
s32 FASTCALL C68k_Interrupt_Ack_Dummy(s32 level);
|
||||
void FASTCALL C68k_Reset_Dummy(void);
|
||||
|
||||
// core main functions
|
||||
///////////////////////
|
||||
|
||||
void C68k_Init(c68k_struc *cpu, C68K_INT_CALLBACK *int_cb)
|
||||
{
|
||||
memset(cpu, 0, sizeof(c68k_struc));
|
||||
|
||||
C68k_Set_ReadB(cpu, C68k_Read_Dummy);
|
||||
C68k_Set_ReadW(cpu, C68k_Read_Dummy);
|
||||
|
||||
C68k_Set_WriteB(cpu, C68k_Write_Dummy);
|
||||
C68k_Set_WriteW(cpu, C68k_Write_Dummy);
|
||||
|
||||
if (int_cb) cpu->Interrupt_CallBack = int_cb;
|
||||
else cpu->Interrupt_CallBack = C68k_Interrupt_Ack_Dummy;
|
||||
cpu->Reset_CallBack = C68k_Reset_Dummy;
|
||||
|
||||
// used to init JumpTable
|
||||
cpu->Status |= C68K_DISABLE;
|
||||
C68k_Exec(cpu, 0);
|
||||
|
||||
cpu->Status &= ~C68K_DISABLE;
|
||||
}
|
||||
|
||||
s32 FASTCALL C68k_Reset(c68k_struc *cpu)
|
||||
{
|
||||
memset(cpu, 0, ((u8 *)&(cpu->dirty1)) - ((u8 *)&(cpu->D[0])));
|
||||
|
||||
cpu->flag_notZ = 1;
|
||||
cpu->flag_I = 7;
|
||||
cpu->flag_S = C68K_SR_S;
|
||||
|
||||
cpu->A[7] = C68k_Read_Long(cpu, 0);
|
||||
C68k_Set_PC(cpu, C68k_Read_Long(cpu, 4));
|
||||
|
||||
return cpu->Status;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
void FASTCALL C68k_Set_IRQ(c68k_struc *cpu, s32 level)
|
||||
{
|
||||
cpu->IRQLine = level;
|
||||
if (cpu->Status & C68K_RUNNING)
|
||||
{
|
||||
cpu->CycleSup = cpu->CycleIO;
|
||||
cpu->CycleIO = 0;
|
||||
}
|
||||
cpu->Status &= ~(C68K_HALTED | C68K_WAITING);
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
s32 FASTCALL C68k_Get_CycleToDo(c68k_struc *cpu)
|
||||
{
|
||||
if (!(cpu->Status & C68K_RUNNING)) return -1;
|
||||
|
||||
return cpu->CycleToDo;
|
||||
}
|
||||
|
||||
s32 FASTCALL C68k_Get_CycleRemaining(c68k_struc *cpu)
|
||||
{
|
||||
if (!(cpu->Status & C68K_RUNNING)) return -1;
|
||||
|
||||
return (cpu->CycleIO + cpu->CycleSup);
|
||||
}
|
||||
|
||||
s32 FASTCALL C68k_Get_CycleDone(c68k_struc *cpu)
|
||||
{
|
||||
if (!(cpu->Status & C68K_RUNNING)) return -1;
|
||||
|
||||
return (cpu->CycleToDo - (cpu->CycleIO + cpu->CycleSup));
|
||||
}
|
||||
|
||||
void FASTCALL C68k_Release_Cycle(c68k_struc *cpu)
|
||||
{
|
||||
if (cpu->Status & C68K_RUNNING) cpu->CycleIO = cpu->CycleSup = 0;
|
||||
}
|
||||
|
||||
void FASTCALL C68k_Add_Cycle(c68k_struc *cpu, s32 cycle)
|
||||
{
|
||||
if (cpu->Status & C68K_RUNNING) cpu->CycleIO -= cycle;
|
||||
}
|
||||
|
||||
// Read / Write dummy functions
|
||||
////////////////////////////////
|
||||
|
||||
u32 FASTCALL C68k_Read_Dummy(__attribute ((unused)) const u32 adr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FASTCALL C68k_Write_Dummy(__attribute ((unused)) const u32 adr, __attribute ((unused)) u32 data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
s32 FASTCALL C68k_Interrupt_Ack_Dummy(s32 level)
|
||||
{
|
||||
// return vector
|
||||
return (C68K_INTERRUPT_AUTOVECTOR_EX + level);
|
||||
}
|
||||
|
||||
void FASTCALL C68k_Reset_Dummy(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Read / Write core functions
|
||||
///////////////////////////////
|
||||
|
||||
u32 C68k_Read_Byte(c68k_struc *cpu, u32 adr)
|
||||
{
|
||||
return cpu->Read_Byte(adr);
|
||||
}
|
||||
|
||||
u32 C68k_Read_Word(c68k_struc *cpu, u32 adr)
|
||||
{
|
||||
return cpu->Read_Word(adr);
|
||||
}
|
||||
|
||||
u32 C68k_Read_Long(c68k_struc *cpu, u32 adr)
|
||||
{
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
return (cpu->Read_Word(adr) << 16) | (cpu->Read_Word(adr + 2) & 0xFFFF);
|
||||
#else
|
||||
return (cpu->Read_Word(adr) << 16) | (cpu->Read_Word(adr + 2) & 0xFFFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
void C68k_Write_Byte(c68k_struc *cpu, u32 adr, u32 data)
|
||||
{
|
||||
cpu->Write_Byte(adr, data);
|
||||
}
|
||||
|
||||
void C68k_Write_Word(c68k_struc *cpu, u32 adr, u32 data)
|
||||
{
|
||||
cpu->Write_Word(adr, data);
|
||||
}
|
||||
|
||||
void C68k_Write_Long(c68k_struc *cpu, u32 adr, u32 data)
|
||||
{
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
cpu->Write_Word(adr, data >> 16);
|
||||
cpu->Write_Word(adr + 2, data & 0xFFFF);
|
||||
#else
|
||||
cpu->Write_Word(adr, data >> 16);
|
||||
cpu->Write_Word(adr + 2, data & 0xFFFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// setting core functions
|
||||
//////////////////////////
|
||||
|
||||
void C68k_Set_Fetch(c68k_struc *cpu, u32 low_adr, u32 high_adr, pointer fetch_adr)
|
||||
{
|
||||
u32 i, j;
|
||||
|
||||
i = (low_adr >> C68K_FETCH_SFT) & C68K_FETCH_MASK;
|
||||
j = (high_adr >> C68K_FETCH_SFT) & C68K_FETCH_MASK;
|
||||
fetch_adr -= i << C68K_FETCH_SFT;
|
||||
while (i <= j) cpu->Fetch[i++] = fetch_adr;
|
||||
}
|
||||
|
||||
void C68k_Set_ReadB(c68k_struc *cpu, C68K_READ *Func)
|
||||
{
|
||||
cpu->Read_Byte = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_ReadW(c68k_struc *cpu, C68K_READ *Func)
|
||||
{
|
||||
cpu->Read_Word = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_WriteB(c68k_struc *cpu, C68K_WRITE *Func)
|
||||
{
|
||||
cpu->Write_Byte = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_WriteW(c68k_struc *cpu, C68K_WRITE *Func)
|
||||
{
|
||||
cpu->Write_Word = Func;
|
||||
}
|
||||
|
||||
// externals main functions
|
||||
////////////////////////////
|
||||
|
||||
u32 C68k_Get_DReg(c68k_struc *cpu, u32 num)
|
||||
{
|
||||
return cpu->D[num];
|
||||
}
|
||||
|
||||
u32 C68k_Get_AReg(c68k_struc *cpu, u32 num)
|
||||
{
|
||||
return cpu->A[num];
|
||||
}
|
||||
|
||||
u32 C68k_Get_PC(c68k_struc *cpu)
|
||||
{
|
||||
return (cpu->PC - cpu->BasePC);
|
||||
}
|
||||
|
||||
u32 C68k_Get_SR(c68k_struc *cpu)
|
||||
{
|
||||
c68k_struc *CPU = cpu;
|
||||
return GET_SR;
|
||||
}
|
||||
|
||||
u32 C68k_Get_USP(c68k_struc *cpu)
|
||||
{
|
||||
if (cpu->flag_S) return cpu->USP;
|
||||
else return cpu->A[7];
|
||||
}
|
||||
|
||||
u32 C68k_Get_MSP(c68k_struc *cpu)
|
||||
{
|
||||
if (cpu->flag_S) return cpu->A[7];
|
||||
else return cpu->USP;
|
||||
}
|
||||
|
||||
void C68k_Set_DReg(c68k_struc *cpu, u32 num, u32 val)
|
||||
{
|
||||
cpu->D[num] = val;
|
||||
}
|
||||
|
||||
void C68k_Set_AReg(c68k_struc *cpu, u32 num, u32 val)
|
||||
{
|
||||
cpu->A[num] = val;
|
||||
}
|
||||
|
||||
void C68k_Set_PC(c68k_struc *cpu, u32 val)
|
||||
{
|
||||
cpu->BasePC = cpu->Fetch[(val >> C68K_FETCH_SFT) & C68K_FETCH_MASK];
|
||||
cpu->PC = val + cpu->BasePC;
|
||||
}
|
||||
|
||||
void C68k_Set_SR(c68k_struc *cpu, u32 val)
|
||||
{
|
||||
c68k_struc *CPU = cpu;
|
||||
SET_SR(val);
|
||||
}
|
||||
|
||||
void C68k_Set_USP(c68k_struc *cpu, u32 val)
|
||||
{
|
||||
if (cpu->flag_S) cpu->USP = val;
|
||||
else cpu->A[7] = val;
|
||||
}
|
||||
|
||||
void C68k_Set_MSP(c68k_struc *cpu, u32 val)
|
||||
{
|
||||
if (cpu->flag_S) cpu->A[7] = val;
|
||||
else cpu->USP = val;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/* Copyright 2003-2004 Stephane Dallongeville
|
||||
Copyright 2004 Theo Berkau
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*********************************************************************************
|
||||
* C68K.H :
|
||||
*
|
||||
* C68K include file
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef _C68K_H_
|
||||
#define _C68K_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "core.h"
|
||||
#include "common.h"
|
||||
|
||||
// setting
|
||||
///////////
|
||||
|
||||
//#define NEOCD_HLE
|
||||
|
||||
//#define C68K_GEN
|
||||
#define C68K_BYTE_SWAP_OPT
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define C68K_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
#define BYTE_OFF 3
|
||||
#define WORD_OFF 1
|
||||
#else
|
||||
#define BYTE_OFF 0
|
||||
#define WORD_OFF 0
|
||||
#endif
|
||||
|
||||
//#define C68K_NO_JUMP_TABLE
|
||||
//#define C68K_DEBUG
|
||||
#define C68K_TAS_CAN_SET_MEMORY
|
||||
//#define C68K_CONST_JUMP_TABLE
|
||||
//#define C68K_AUTOVECTOR_CALLBACK
|
||||
|
||||
// 68K core types definitions
|
||||
//////////////////////////////
|
||||
|
||||
#define C68K_FETCH_BITS 8 // [4-12] default = 8
|
||||
#define C68K_ADR_BITS 24
|
||||
|
||||
#define C68K_FETCH_SFT (C68K_ADR_BITS - C68K_FETCH_BITS)
|
||||
#define C68K_FETCH_BANK (1 << C68K_FETCH_BITS)
|
||||
#define C68K_FETCH_MASK (C68K_FETCH_BANK - 1)
|
||||
|
||||
#define C68K_SR_C_SFT 8
|
||||
#define C68K_SR_V_SFT 7
|
||||
#define C68K_SR_Z_SFT 0
|
||||
#define C68K_SR_N_SFT 7
|
||||
#define C68K_SR_X_SFT 8
|
||||
|
||||
#define C68K_SR_S_SFT 13
|
||||
|
||||
#define C68K_SR_C (1 << C68K_SR_C_SFT)
|
||||
#define C68K_SR_V (1 << C68K_SR_V_SFT)
|
||||
#define C68K_SR_Z 0
|
||||
#define C68K_SR_N (1 << C68K_SR_N_SFT)
|
||||
#define C68K_SR_X (1 << C68K_SR_X_SFT)
|
||||
|
||||
#define C68K_SR_S (1 << C68K_SR_S_SFT)
|
||||
|
||||
#define C68K_CCR_MASK 0x1F
|
||||
#define C68K_SR_MASK (0x2700 | C68K_CCR_MASK)
|
||||
|
||||
// exception defines taken from musashi core
|
||||
#define C68K_RESET_EX 1
|
||||
#define C68K_BUS_ERROR_EX 2
|
||||
#define C68K_ADDRESS_ERROR_EX 3
|
||||
#define C68K_ILLEGAL_INSTRUCTION_EX 4
|
||||
#define C68K_ZERO_DIVIDE_EX 5
|
||||
#define C68K_CHK_EX 6
|
||||
#define C68K_TRAPV_EX 7
|
||||
#define C68K_PRIVILEGE_VIOLATION_EX 8
|
||||
#define C68K_TRACE_EX 9
|
||||
#define C68K_1010_EX 10
|
||||
#define C68K_1111_EX 11
|
||||
#define C68K_FORMAT_ERROR_EX 14
|
||||
#define C68K_UNINITIALIZED_INTERRUPT_EX 15
|
||||
#define C68K_SPURIOUS_INTERRUPT_EX 24
|
||||
#define C68K_INTERRUPT_AUTOVECTOR_EX 24
|
||||
#define C68K_TRAP_BASE_EX 32
|
||||
|
||||
#define C68K_INT_ACK_AUTOVECTOR -1
|
||||
|
||||
#define C68K_RUNNING 0x01
|
||||
#define C68K_HALTED 0x02
|
||||
#define C68K_WAITING 0x04
|
||||
#define C68K_DISABLE 0x10
|
||||
#define C68K_FAULTED 0x40
|
||||
|
||||
typedef u32 FASTCALL C68K_READ(const u32 adr);
|
||||
typedef void FASTCALL C68K_WRITE(const u32 adr, u32 data);
|
||||
|
||||
typedef s32 FASTCALL C68K_INT_CALLBACK(s32 level);
|
||||
typedef void FASTCALL C68K_RESET_CALLBACK(void);
|
||||
|
||||
typedef struct {
|
||||
u32 D[8]; // 32 bytes aligned
|
||||
u32 A[8]; // 16 bytes aligned
|
||||
|
||||
u32 flag_C; // 32 bytes aligned
|
||||
u32 flag_V;
|
||||
u32 flag_notZ;
|
||||
u32 flag_N;
|
||||
|
||||
u32 flag_X; // 16 bytes aligned
|
||||
u32 flag_I;
|
||||
u32 flag_S;
|
||||
|
||||
u32 USP;
|
||||
|
||||
pointer PC; // 32 bytes aligned
|
||||
pointer BasePC;
|
||||
u32 Status;
|
||||
s32 IRQLine;
|
||||
|
||||
s32 CycleToDo; // 16 bytes aligned
|
||||
s32 CycleIO;
|
||||
s32 CycleSup;
|
||||
u32 dirty1;
|
||||
|
||||
C68K_READ *Read_Byte; // 32 bytes aligned
|
||||
C68K_READ *Read_Word;
|
||||
|
||||
C68K_WRITE *Write_Byte;
|
||||
C68K_WRITE *Write_Word;
|
||||
|
||||
C68K_INT_CALLBACK *Interrupt_CallBack; // 16 bytes aligned
|
||||
C68K_RESET_CALLBACK *Reset_CallBack;
|
||||
|
||||
pointer Fetch[C68K_FETCH_BANK]; // 32 bytes aligned
|
||||
} c68k_struc;
|
||||
|
||||
|
||||
// 68K core var declaration
|
||||
////////////////////////////
|
||||
|
||||
extern c68k_struc C68K;
|
||||
|
||||
|
||||
// 68K core function declaration
|
||||
/////////////////////////////////
|
||||
|
||||
void C68k_Init(c68k_struc *cpu, C68K_INT_CALLBACK *int_cb);
|
||||
|
||||
s32 FASTCALL C68k_Reset(c68k_struc *cpu);
|
||||
|
||||
// if < 0 --> error (cpu state returned)
|
||||
// if >= 0 --> number of extras cycles done
|
||||
s32 FASTCALL C68k_Exec(c68k_struc *cpu, s32 cycle);
|
||||
|
||||
void FASTCALL C68k_Set_IRQ(c68k_struc *cpu, s32 level);
|
||||
|
||||
s32 FASTCALL C68k_Get_CycleToDo(c68k_struc *cpu);
|
||||
s32 FASTCALL C68k_Get_CycleRemaining(c68k_struc *cpu);
|
||||
s32 FASTCALL C68k_Get_CycleDone(c68k_struc *cpu);
|
||||
void FASTCALL C68k_Release_Cycle(c68k_struc *cpu);
|
||||
void FASTCALL C68k_Add_Cycle(c68k_struc *cpu, s32 cycle);
|
||||
|
||||
void C68k_Set_Fetch(c68k_struc *cpu, u32 low_adr, u32 high_adr, pointer fetch_adr);
|
||||
|
||||
void C68k_Set_ReadB(c68k_struc *cpu, C68K_READ *Func);
|
||||
void C68k_Set_ReadW(c68k_struc *cpu, C68K_READ *Func);
|
||||
void C68k_Set_WriteB(c68k_struc *cpu, C68K_WRITE *Func);
|
||||
void C68k_Set_WriteW(c68k_struc *cpu, C68K_WRITE *Func);
|
||||
|
||||
u32 C68k_Get_DReg(c68k_struc *cpu, u32 num);
|
||||
u32 C68k_Get_AReg(c68k_struc *cpu, u32 num);
|
||||
u32 C68k_Get_PC(c68k_struc *cpu);
|
||||
u32 C68k_Get_SR(c68k_struc *cpu);
|
||||
u32 C68k_Get_USP(c68k_struc *cpu);
|
||||
u32 C68k_Get_MSP(c68k_struc *cpu);
|
||||
|
||||
void C68k_Set_DReg(c68k_struc *cpu, u32 num, u32 val);
|
||||
void C68k_Set_AReg(c68k_struc *cpu, u32 num, u32 val);
|
||||
void C68k_Set_PC(c68k_struc *cpu, u32 val);
|
||||
void C68k_Set_SR(c68k_struc *cpu, u32 val);
|
||||
void C68k_Set_USP(c68k_struc *cpu, u32 val);
|
||||
void C68k_Set_MSP(c68k_struc *cpu, u32 val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _C68K_H_
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,390 @@
|
||||
|
||||
// BCC
|
||||
OP_0x6201:
|
||||
{
|
||||
if (CPU->flag_notZ && (!(CPU->flag_C & 0x100)))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6301:
|
||||
{
|
||||
if ((!CPU->flag_notZ) || (CPU->flag_C & 0x100))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6401:
|
||||
{
|
||||
if (!(CPU->flag_C & 0x100))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6501:
|
||||
{
|
||||
if (CPU->flag_C & 0x100)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6601:
|
||||
{
|
||||
if (CPU->flag_notZ)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6701:
|
||||
{
|
||||
if (!CPU->flag_notZ)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6801:
|
||||
{
|
||||
if (!(CPU->flag_V & 0x80))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6901:
|
||||
{
|
||||
if (CPU->flag_V & 0x80)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6A01:
|
||||
{
|
||||
if (!(CPU->flag_N & 0x80))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6B01:
|
||||
{
|
||||
if (CPU->flag_N & 0x80)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6C01:
|
||||
{
|
||||
if (!((CPU->flag_N ^ CPU->flag_V) & 0x80))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6D01:
|
||||
{
|
||||
if ((CPU->flag_N ^ CPU->flag_V) & 0x80)
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6E01:
|
||||
{
|
||||
if (CPU->flag_notZ && (!((CPU->flag_N ^ CPU->flag_V) & 0x80)))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC
|
||||
OP_0x6F01:
|
||||
{
|
||||
if ((!CPU->flag_notZ) || ((CPU->flag_N ^ CPU->flag_V) & 0x80))
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
CCnt -= 2;
|
||||
}
|
||||
}
|
||||
RET(8)
|
||||
|
||||
// BCC16
|
||||
OP_0x6200:
|
||||
{
|
||||
if (CPU->flag_notZ && (!(CPU->flag_C & 0x100)))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6300:
|
||||
{
|
||||
if ((!CPU->flag_notZ) || (CPU->flag_C & 0x100))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6400:
|
||||
{
|
||||
if (!(CPU->flag_C & 0x100))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6500:
|
||||
{
|
||||
if (CPU->flag_C & 0x100)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6600:
|
||||
{
|
||||
if (CPU->flag_notZ)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6700:
|
||||
{
|
||||
if (!CPU->flag_notZ)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6800:
|
||||
{
|
||||
if (!(CPU->flag_V & 0x80))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6900:
|
||||
{
|
||||
if (CPU->flag_V & 0x80)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6A00:
|
||||
{
|
||||
if (!(CPU->flag_N & 0x80))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6B00:
|
||||
{
|
||||
if (CPU->flag_N & 0x80)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6C00:
|
||||
{
|
||||
if (!((CPU->flag_N ^ CPU->flag_V) & 0x80))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6D00:
|
||||
{
|
||||
if ((CPU->flag_N ^ CPU->flag_V) & 0x80)
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6E00:
|
||||
{
|
||||
if (CPU->flag_notZ && (!((CPU->flag_N ^ CPU->flag_V) & 0x80)))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BCC16
|
||||
OP_0x6F00:
|
||||
{
|
||||
if ((!CPU->flag_notZ) || ((CPU->flag_N ^ CPU->flag_V) & 0x80))
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
RET(10)
|
||||
}
|
||||
PC += 2;
|
||||
}
|
||||
RET(12)
|
||||
|
||||
// BRA
|
||||
OP_0x6001:
|
||||
{
|
||||
PC += (s32)(s8)Opcode;
|
||||
}
|
||||
RET(10)
|
||||
|
||||
// BRA16
|
||||
OP_0x6000:
|
||||
{
|
||||
PC += (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
SET_PC(PC);
|
||||
}
|
||||
RET(10)
|
||||
|
||||
// BSR
|
||||
OP_0x6101:
|
||||
{
|
||||
PRE_IO
|
||||
PUSH_32_F(PC - CPU->BasePC)
|
||||
PC += (s32)(s8)Opcode;
|
||||
POST_IO
|
||||
}
|
||||
RET(18)
|
||||
|
||||
// BSR16
|
||||
OP_0x6100:
|
||||
{
|
||||
u32 res;
|
||||
res = (s32)(s16)FETCH_WORD;
|
||||
PC -= CPU->BasePC;
|
||||
PRE_IO
|
||||
PUSH_32_F(PC + 2)
|
||||
PC += (s32) res;
|
||||
SET_PC(PC);
|
||||
POST_IO
|
||||
}
|
||||
RET(18)
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
// MOVEQ
|
||||
OP_0x7000:
|
||||
{
|
||||
u32 res;
|
||||
res = (s32)(s8)Opcode;
|
||||
CPU->flag_C = CPU->flag_V = 0;
|
||||
CPU->flag_N = CPU->flag_notZ = res;
|
||||
*((u32*)(&CPU->D[(Opcode >> 9) & 7])) = res;
|
||||
}
|
||||
RET(4)
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,23 @@
|
||||
|
||||
// 1010
|
||||
OP_0xA000:
|
||||
{
|
||||
u32 res;
|
||||
PC -= 2;
|
||||
if (!CPU->flag_S)
|
||||
{
|
||||
res = CPU->USP;
|
||||
CPU->USP = CPU->A[7];
|
||||
CPU->A[7] = res;
|
||||
}
|
||||
res = C68K_1010_EX;
|
||||
CCnt -= c68k_exception_cycle_table[res];
|
||||
PRE_IO
|
||||
PUSH_32_F(PC - CPU->BasePC)
|
||||
PUSH_16_F(GET_SR)
|
||||
CPU->flag_S = C68K_SR_S;
|
||||
READ_LONG_F(res * 4, PC)
|
||||
SET_PC(PC)
|
||||
POST_IO
|
||||
}
|
||||
RET(4)
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,23 @@
|
||||
|
||||
// 1111
|
||||
OP_0xF000:
|
||||
{
|
||||
u32 res;
|
||||
PC -= 2;
|
||||
if (!CPU->flag_S)
|
||||
{
|
||||
res = CPU->USP;
|
||||
CPU->USP = CPU->A[7];
|
||||
CPU->A[7] = res;
|
||||
}
|
||||
res = C68K_1111_EX;
|
||||
CCnt -= c68k_exception_cycle_table[res];
|
||||
PRE_IO
|
||||
PUSH_32_F(PC - CPU->BasePC)
|
||||
PUSH_16_F(GET_SR)
|
||||
CPU->flag_S = C68K_SR_S;
|
||||
READ_LONG_F(res * 4, PC)
|
||||
SET_PC(PC)
|
||||
POST_IO
|
||||
}
|
||||
RET(4)
|
||||
@@ -0,0 +1,339 @@
|
||||
/* Copyright 2003-2004 Stephane Dallongeville
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*! \file c68kexec.c
|
||||
\brief C68K emulation execution and instruction functions.
|
||||
*/
|
||||
|
||||
#include "core.h"
|
||||
#include "c68k.h"
|
||||
|
||||
// #define TRACE_WITH_Q68 // Define to use Q68 tracing code to trace insns
|
||||
// (requires Q68 built in, of course)
|
||||
|
||||
#ifdef NEOCD_HLE
|
||||
void cdrom_load_files(void);
|
||||
void neogeo_cdda_control(void);
|
||||
void neogeo_prio_switch(void);
|
||||
void neogeo_upload(void);
|
||||
#endif
|
||||
|
||||
// exception cycle table (taken from musashi core)
|
||||
static const s32 c68k_exception_cycle_table[256] =
|
||||
{
|
||||
4, // 0: Reset - Initial Stack Pointer
|
||||
4, // 1: Reset - Initial Program Counter
|
||||
50, // 2: Bus Error
|
||||
50, // 3: Address Error
|
||||
34, // 4: Illegal Instruction
|
||||
38, // 5: Divide by Zero
|
||||
40, // 6: CHK
|
||||
34, // 7: TRAPV
|
||||
34, // 8: Privilege Violation
|
||||
34, // 9: Trace
|
||||
4, // 10:
|
||||
4, // 11:
|
||||
4, // 12: RESERVED
|
||||
4, // 13: Coprocessor Protocol Violation
|
||||
4, // 14: Format Error
|
||||
44, // 15: Uninitialized Interrupt
|
||||
4, // 16: RESERVED
|
||||
4, // 17: RESERVED
|
||||
4, // 18: RESERVED
|
||||
4, // 19: RESERVED
|
||||
4, // 20: RESERVED
|
||||
4, // 21: RESERVED
|
||||
4, // 22: RESERVED
|
||||
4, // 23: RESERVED
|
||||
44, // 24: Spurious Interrupt
|
||||
44, // 25: Level 1 Interrupt Autovector
|
||||
44, // 26: Level 2 Interrupt Autovector
|
||||
44, // 27: Level 3 Interrupt Autovector
|
||||
44, // 28: Level 4 Interrupt Autovector
|
||||
44, // 29: Level 5 Interrupt Autovector
|
||||
44, // 30: Level 6 Interrupt Autovector
|
||||
44, // 31: Level 7 Interrupt Autovector
|
||||
34, // 32: TRAP #0
|
||||
34, // 33: TRAP #1
|
||||
34, // 34: TRAP #2
|
||||
34, // 35: TRAP #3
|
||||
34, // 36: TRAP #4
|
||||
34, // 37: TRAP #5
|
||||
34, // 38: TRAP #6
|
||||
34, // 39: TRAP #7
|
||||
34, // 40: TRAP #8
|
||||
34, // 41: TRAP #9
|
||||
34, // 42: TRAP #10
|
||||
34, // 43: TRAP #11
|
||||
34, // 44: TRAP #12
|
||||
34, // 45: TRAP #13
|
||||
34, // 46: TRAP #14
|
||||
34, // 47: TRAP #15
|
||||
4, // 48: FP Branch or Set on Unknown Condition
|
||||
4, // 49: FP Inexact Result
|
||||
4, // 50: FP Divide by Zero
|
||||
4, // 51: FP Underflow
|
||||
4, // 52: FP Operand Error
|
||||
4, // 53: FP Overflow
|
||||
4, // 54: FP Signaling NAN
|
||||
4, // 55: FP Unimplemented Data Type
|
||||
4, // 56: MMU Configuration Error
|
||||
4, // 57: MMU Illegal Operation Error
|
||||
4, // 58: MMU Access Level Violation Error
|
||||
4, // 59: RESERVED
|
||||
4, // 60: RESERVED
|
||||
4, // 61: RESERVED
|
||||
4, // 62: RESERVED
|
||||
4, // 63: RESERVED
|
||||
// 64-255: User Defined
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
|
||||
};
|
||||
|
||||
// global variable
|
||||
///////////////////
|
||||
|
||||
#ifndef C68K_GEN
|
||||
|
||||
#ifndef C68K_NO_JUMP_TABLE
|
||||
#ifndef C68K_CONST_JUMP_TABLE
|
||||
static void *JumpTable[0x10000];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static u32 C68k_Initialised = 0;
|
||||
|
||||
#endif // C68K_GEN
|
||||
|
||||
#ifdef NEOCD_HLE
|
||||
extern int img_display;
|
||||
#endif
|
||||
|
||||
// include macro file
|
||||
//////////////////////
|
||||
|
||||
#include "c68kmac.inc"
|
||||
|
||||
#ifndef C68K_GEN
|
||||
# ifdef TRACE_WITH_Q68
|
||||
#include "../q68/q68.h"
|
||||
static c68k_struc *TRACE_CPU;
|
||||
static uint32_t readw(uint32_t address) {
|
||||
return TRACE_CPU->Read_Word(address);
|
||||
}
|
||||
/* Make our own version of the structure to avoid the overhead of dozens of
|
||||
* function calls every instruction */
|
||||
static struct {
|
||||
u32 D[8], A[8], PC, SR, USP, SSP, dummy[7];
|
||||
void *readb, *readw, *writeb, *writew;
|
||||
} state = {.readw = readw};
|
||||
void TRACE(int PC,c68k_struc *CPU,int Opcode,int CCnt) {
|
||||
static FILE *f;
|
||||
if (!f) f = fopen("c68k.log", "w");
|
||||
TRACE_CPU = CPU;
|
||||
memcpy(state.D, CPU->D, 16*4);
|
||||
state.PC = PC - 2 - CPU->BasePC;
|
||||
state.SR = GET_SR;
|
||||
if (f) q68_trace((Q68State *)&state, f,
|
||||
CPU->CycleToDo - CCnt, CPU->CycleToDo);
|
||||
}
|
||||
# endif // TRACE_WITH_Q68
|
||||
#endif // !C68K_GEN
|
||||
|
||||
// main exec function
|
||||
//////////////////////
|
||||
|
||||
s32 FASTCALL C68k_Exec(c68k_struc *cpu, s32 cycle)
|
||||
{
|
||||
#ifndef C68K_GEN
|
||||
#if 0
|
||||
register c68k_struc *CPU asm ("ebx");
|
||||
register pointer PC asm ("esi");
|
||||
register s32 CCnt asm ("edi");
|
||||
// register u32 Opcode asm ("edi");
|
||||
// c68k_struc *CPU;
|
||||
// u32 PC;
|
||||
// s32 CCnt;
|
||||
u32 Opcode;
|
||||
#else
|
||||
// register c68k_struc *CPU asm ("r10");
|
||||
// register u32 PC asm ("r11");
|
||||
// register s32 CCnt asm ("r12");
|
||||
// register u32 Opcode asm ("r13");
|
||||
c68k_struc *CPU;
|
||||
pointer PC;
|
||||
s32 CCnt;
|
||||
u32 Opcode;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef C68K_GEN
|
||||
|
||||
#ifndef C68K_NO_JUMP_TABLE
|
||||
#ifdef C68K_CONST_JUMP_TABLE
|
||||
#include "c68k_ini.inc"
|
||||
#endif
|
||||
#else
|
||||
C68k_Initialised = 1;
|
||||
#endif
|
||||
|
||||
CPU = cpu;
|
||||
PC = CPU->PC;
|
||||
|
||||
if (CPU->Status & (C68K_RUNNING | C68K_DISABLE | C68K_FAULTED))
|
||||
{
|
||||
#ifndef C68K_NO_JUMP_TABLE
|
||||
#ifndef C68K_CONST_JUMP_TABLE
|
||||
if (!C68k_Initialised) goto C68k_Init;
|
||||
#endif
|
||||
#endif
|
||||
return (CPU->Status | 0x80000000);
|
||||
}
|
||||
|
||||
if (cycle <= 0) return -cycle;
|
||||
|
||||
CPU->CycleToDo = CCnt = cycle;
|
||||
|
||||
#ifndef C68K_DEBUG
|
||||
CHECK_INT
|
||||
#else
|
||||
{
|
||||
s32 line, vect;
|
||||
|
||||
line = CPU->IRQLine;
|
||||
|
||||
if ((line == 7) || (line > CPU->flag_I))
|
||||
{
|
||||
PRE_IO
|
||||
|
||||
/* get vector */
|
||||
CPU->IRQLine = 0;
|
||||
vect = CPU->Interrupt_CallBack(line);
|
||||
if (vect == C68K_INT_ACK_AUTOVECTOR)
|
||||
vect = C68K_INTERRUPT_AUTOVECTOR_EX + (line & 7);
|
||||
|
||||
/* adjust CCnt */
|
||||
CCnt -= c68k_exception_cycle_table[vect];
|
||||
|
||||
/* swap A7 and USP */
|
||||
if (!CPU->flag_S)
|
||||
{
|
||||
u32 tmpSP;
|
||||
|
||||
tmpSP = CPU->USP;
|
||||
CPU->USP = CPU->A[7];
|
||||
CPU->A[7] = tmpSP;
|
||||
}
|
||||
|
||||
/* push PC and SR */
|
||||
PUSH_32_F(PC - CPU->BasePC)
|
||||
PUSH_16_F(GET_SR)
|
||||
|
||||
/* adjust SR */
|
||||
CPU->flag_S = C68K_SR_S;
|
||||
CPU->flag_I = line;
|
||||
|
||||
/* fetch new PC */
|
||||
READ_LONG_F(vect * 4, PC)
|
||||
SET_PC(PC)
|
||||
|
||||
POST_IO
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (CPU->Status & (C68K_HALTED | C68K_WAITING)) return CPU->CycleToDo;
|
||||
|
||||
CPU->CycleSup = 0;
|
||||
CPU->Status |= C68K_RUNNING;
|
||||
|
||||
#ifndef C68K_DEBUG
|
||||
NEXT
|
||||
#else
|
||||
#ifdef C68K_NO_JUMP_TABLE
|
||||
NEXT
|
||||
#else
|
||||
Opcode = FETCH_WORD;
|
||||
PC += 2;
|
||||
goto *JumpTable[Opcode];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef C68K_NO_JUMP_TABLE
|
||||
SwitchTable:
|
||||
switch(Opcode)
|
||||
{
|
||||
#endif
|
||||
#include "c68k_op0.inc"
|
||||
#include "c68k_op1.inc"
|
||||
#include "c68k_op2.inc"
|
||||
#include "c68k_op3.inc"
|
||||
#include "c68k_op4.inc"
|
||||
#include "c68k_op5.inc"
|
||||
#include "c68k_op6.inc"
|
||||
#include "c68k_op7.inc"
|
||||
#include "c68k_op8.inc"
|
||||
#include "c68k_op9.inc"
|
||||
#include "c68k_opA.inc"
|
||||
#include "c68k_opB.inc"
|
||||
#include "c68k_opC.inc"
|
||||
#include "c68k_opD.inc"
|
||||
#include "c68k_opE.inc"
|
||||
#include "c68k_opF.inc"
|
||||
#ifdef C68K_NO_JUMP_TABLE
|
||||
}
|
||||
#endif
|
||||
|
||||
C68k_Exec_End:
|
||||
CHECK_INT
|
||||
if ((CCnt += CPU->CycleSup) > 0)
|
||||
{
|
||||
CPU->CycleSup = 0;
|
||||
NEXT;
|
||||
}
|
||||
|
||||
C68k_Exec_Really_End:
|
||||
CPU->Status &= ~C68K_RUNNING;
|
||||
CPU->PC = PC;
|
||||
|
||||
return (CPU->CycleToDo - CCnt);
|
||||
|
||||
#ifndef C68K_CONST_JUMP_TABLE
|
||||
#ifndef C68K_NO_JUMP_TABLE
|
||||
C68k_Init:
|
||||
{
|
||||
u32 i, j;
|
||||
|
||||
#include "c68k_ini.inc"
|
||||
|
||||
C68k_Initialised = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
/* Copyright 2003-2004 Stephane Dallongeville
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// internals core macros
|
||||
/////////////////////////
|
||||
|
||||
#define LSL(A, C) ((A) << (C))
|
||||
#define LSR(A, C) ((A) >> (C))
|
||||
|
||||
#define LSR_32(A, C) ((C) < 32 ? (A) >> (C) : 0)
|
||||
#define LSL_32(A, C) ((C) < 32 ? (A) << (C) : 0)
|
||||
|
||||
#define ROL_8(A, C) (LSL(A, C) | LSR(A, 8-(C)))
|
||||
#define ROL_9(A, C) (LSL(A, C) | LSR(A, 9-(C)))
|
||||
#define ROL_16(A, C) (LSL(A, C) | LSR(A, 16-(C)))
|
||||
#define ROL_17(A, C) (LSL(A, C) | LSR(A, 17-(C)))
|
||||
#define ROL_32(A, C) (LSL_32(A, C) | LSR_32(A, 32-(C)))
|
||||
#define ROL_33(A, C) (LSL_32(A, C) | LSR_32(A, 33-(C)))
|
||||
|
||||
#define ROR_8(A, C) (LSR(A, C) | LSL(A, 8-(C)))
|
||||
#define ROR_9(A, C) (LSR(A, C) | LSL(A, 9-(C)))
|
||||
#define ROR_16(A, C) (LSR(A, C) | LSL(A, 16-(C)))
|
||||
#define ROR_17(A, C) (LSR(A, C) | LSL(A, 17-(C)))
|
||||
#define ROR_32(A, C) (LSR_32(A, C) | LSL_32(A, 32-(C)))
|
||||
#define ROR_33(A, C) (LSR_32(A, C) | LSL_32(A, 33-(C)))
|
||||
|
||||
|
||||
#ifdef TRACE_WITH_Q68
|
||||
extern void TRACE(int,c68k_struc*,int,int);
|
||||
#else
|
||||
# define TRACE(a,b,c,d) /*nothing*/
|
||||
#endif
|
||||
#ifndef C68K_NO_JUMP_TABLE
|
||||
#define NEXT \
|
||||
PRE_IO \
|
||||
Opcode = FETCH_WORD; \
|
||||
PC += 2; \
|
||||
TRACE(PC, CPU, Opcode, CCnt); \
|
||||
goto *JumpTable[Opcode];
|
||||
#else
|
||||
#define NEXT \
|
||||
PRE_IO \
|
||||
Opcode = FETCH_WORD; \
|
||||
PC += 2; \
|
||||
TRACE(PC, CPU, Opcode, CCnt); \
|
||||
goto SwitchTable;
|
||||
#endif
|
||||
|
||||
#define RET(A) \
|
||||
CCnt -= (A); \
|
||||
if (CCnt <= 0) goto C68k_Exec_End; \
|
||||
NEXT
|
||||
|
||||
#define SET_PC(A) \
|
||||
CPU->BasePC = CPU->Fetch[((A) >> C68K_FETCH_SFT) & C68K_FETCH_MASK]; \
|
||||
CPU->BasePC -= (A) & 0xFF000000; \
|
||||
PC = (A) + CPU->BasePC;
|
||||
|
||||
#define PRE_IO \
|
||||
CPU->CycleIO = CCnt;
|
||||
|
||||
#define POST_IO \
|
||||
CCnt = CPU->CycleIO;
|
||||
|
||||
#define READ_BYTE_F(A, D) \
|
||||
D = CPU->Read_Byte(A) & 0xFF;
|
||||
|
||||
#define READ_WORD_F(A, D) \
|
||||
D = CPU->Read_Word(A) & 0xFFFF;
|
||||
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
#define READ_LONG_F(A, D) \
|
||||
D = CPU->Read_Word((A)) << 16; \
|
||||
D |= CPU->Read_Word((A) + 2) & 0xFFFF;
|
||||
|
||||
#define READ_LONG_DEC_F(A, D) \
|
||||
D = CPU->Read_Word((A) + 2) & 0xFFFF; \
|
||||
D |= CPU->Read_Word((A)) << 16;
|
||||
#else
|
||||
#define READ_LONG_F(A, D) \
|
||||
D = CPU->Read_Word((A)) << 16; \
|
||||
D |= CPU->Read_Word((A) + 2) & 0xFFFF;
|
||||
|
||||
#define READ_LONG_DEC_F(A, D) \
|
||||
D = CPU->Read_Word((A) + 2) & 0xFFFF; \
|
||||
D |= CPU->Read_Word((A)) << 16;
|
||||
#endif
|
||||
|
||||
#define READSX_BYTE_F(A, D) \
|
||||
D = (s32)(s8)CPU->Read_Byte(A);
|
||||
|
||||
#define READSX_WORD_F(A, D) \
|
||||
D = (s32)(s16)CPU->Read_Word(A);
|
||||
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
#define READSX_LONG_F(A, D) \
|
||||
D = CPU->Read_Word((A)) << 16; \
|
||||
D |= CPU->Read_Word((A) + 2) & 0xFFFF;
|
||||
|
||||
#define READSX_LONG_DEC_F(A, D) \
|
||||
D = CPU->Read_Word((A) + 2) & 0xFFFF; \
|
||||
D |= CPU->Read_Word((A)) << 16;
|
||||
#else
|
||||
#define READSX_LONG_F(A, D) \
|
||||
D = CPU->Read_Word((A)) << 16; \
|
||||
D |= CPU->Read_Word((A) + 2) & 0xFFFF;
|
||||
|
||||
#define READSX_LONG_DEC_F(A, D) \
|
||||
D = CPU->Read_Word((A) + 2) & 0xFFFF; \
|
||||
D |= CPU->Read_Word((A)) << 16;
|
||||
#endif
|
||||
|
||||
#define WRITE_BYTE_F(A, D) \
|
||||
CPU->Write_Byte(A, D);
|
||||
|
||||
#define WRITE_WORD_F(A, D) \
|
||||
CPU->Write_Word(A, D);
|
||||
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
#define WRITE_LONG_F(A, D) \
|
||||
CPU->Write_Word((A), (D) >> 16); \
|
||||
CPU->Write_Word((A) + 2, (D) & 0xFFFF);
|
||||
|
||||
#define WRITE_LONG_DEC_F(A, D) \
|
||||
CPU->Write_Word((A) + 2, (D) & 0xFFFF); \
|
||||
CPU->Write_Word((A), (D) >> 16);
|
||||
#else
|
||||
#define WRITE_LONG_F(A, D) \
|
||||
CPU->Write_Word((A), (D) >> 16); \
|
||||
CPU->Write_Word((A) + 2, (D) & 0xFFFF);
|
||||
|
||||
#define WRITE_LONG_DEC_F(A, D) \
|
||||
CPU->Write_Word((A) + 2, (D) & 0xFFFF); \
|
||||
CPU->Write_Word((A), (D) >> 16);
|
||||
#endif
|
||||
|
||||
#define PUSH_16_F(D) \
|
||||
CPU->Write_Word(CPU->A[7] -= 2, D); \
|
||||
|
||||
#define POP_16_F(D) \
|
||||
D = (u16)CPU->Read_Word(CPU->A[7]); \
|
||||
CPU->A[7] += 2;
|
||||
|
||||
#ifdef C68K_BIG_ENDIAN
|
||||
#define PUSH_32_F(D) \
|
||||
CPU->A[7] -= 4; \
|
||||
CPU->Write_Word(CPU->A[7] + 2, (D) & 0xFFFF); \
|
||||
CPU->Write_Word(CPU->A[7], (D) >> 16);
|
||||
|
||||
#define POP_32_F(D) \
|
||||
D = CPU->Read_Word(CPU->A[7]) << 16; \
|
||||
D |= CPU->Read_Word(CPU->A[7] + 2) & 0xFFFF; \
|
||||
CPU->A[7] += 4;
|
||||
#else
|
||||
#define PUSH_32_F(D) \
|
||||
CPU->A[7] -= 4; \
|
||||
CPU->Write_Word(CPU->A[7] + 2, (D) & 0xFFFF); \
|
||||
CPU->Write_Word(CPU->A[7], (D) >> 16);
|
||||
|
||||
#define POP_32_F(D) \
|
||||
D = CPU->Read_Word(CPU->A[7]) << 16; \
|
||||
D |= CPU->Read_Word(CPU->A[7] + 2) & 0xFFFF; \
|
||||
CPU->A[7] += 4;
|
||||
#endif
|
||||
|
||||
#define FETCH_BYTE \
|
||||
((*(u16*)PC) & 0xFF)
|
||||
|
||||
#define FETCH_WORD \
|
||||
(*(u16*)PC)
|
||||
|
||||
|
||||
#define FETCH_LONG \
|
||||
(*(u32*)PC)
|
||||
|
||||
#define DECODE_EXT_WORD \
|
||||
{ \
|
||||
u32 ext; \
|
||||
\
|
||||
ext = (*(u16*)PC); \
|
||||
PC += 2; \
|
||||
\
|
||||
adr += (s32)((s8)(ext)); \
|
||||
if (ext & 0x0800) adr += (s32) CPU->D[ext >> 12]; \
|
||||
else adr += (s32)((s16)(CPU->D[ext >> 12])); \
|
||||
}
|
||||
|
||||
#ifndef C68K_BIG_ENDIAN
|
||||
#ifdef C68K_BYTE_SWAP_OPT
|
||||
#undef FETCH_LONG
|
||||
#define FETCH_LONG \
|
||||
((((u32)(*(u16*)PC)) << 16) | ((u32)(*(u16*)(PC + 2))))
|
||||
// ((((u32)(*(u8*)(PC + 2))) | (((u32)(*(u8*)(PC + 3))) << 8) | (((u32)(*(u8*)PC)) << 16) | (((u32)(*(u8*)(PC + 1))) << 24)))
|
||||
#else
|
||||
#undef FETCH_BYTE
|
||||
#define FETCH_BYTE \
|
||||
(*(u16*)PC) >> 8)
|
||||
|
||||
#undef FETCH_WORD
|
||||
#define FETCH_WORD \
|
||||
((((u16)(*(u8*)PC)) << 8) | ((u16)(*(u8*)(PC + 1))))
|
||||
// ((((u16)(*(u8*)(PC + 1))) | (((u16)(*(u8*)PC)) << 8)))
|
||||
|
||||
#undef FETCH_LONG
|
||||
#define FETCH_LONG \
|
||||
((((u32)(*(u8*)PC)) << 24) | (((u32)(*(u8*)(PC + 1))) << 16) | (((u32)(*(u8*)(PC + 2))) << 8) | ((u32)(*(u8*)(PC + 3))))
|
||||
// ((((u32)(*(u8*)(PC + 3))) | (((u32)(*(u8*)(PC + 2))) << 8) | (((u32)(*(u8*)(PC + 1))) << 16) | (((u32)(*(u8*)PC)) << 24)))
|
||||
|
||||
#undef DECODE_EXT_WORD
|
||||
#define DECODE_EXT_WORD \
|
||||
{ \
|
||||
u32 ext; \
|
||||
\
|
||||
ext = (*(u16*)PC); \
|
||||
PC += 2; \
|
||||
\
|
||||
adr += (s32)((s8)(ext >> 8)); \
|
||||
if (ext & 0x0008) adr += (s32) CPU->D[(ext >> 4) & 0x000F]; \
|
||||
else adr += (s32)((s16)(CPU->D[(ext >> 4) & 0x000F])); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GET_CCR \
|
||||
(((CPU->flag_C >> (C68K_SR_C_SFT - 0)) & 1) | \
|
||||
((CPU->flag_V >> (C68K_SR_V_SFT - 1)) & 2) | \
|
||||
(((!CPU->flag_notZ) & 1) << 2) | \
|
||||
((CPU->flag_N >> (C68K_SR_N_SFT - 3)) & 8) | \
|
||||
((CPU->flag_X >> (C68K_SR_X_SFT - 4)) & 0x10))
|
||||
|
||||
#define GET_SR \
|
||||
((CPU->flag_S << 0) | \
|
||||
(CPU->flag_I << 8) | \
|
||||
GET_CCR)
|
||||
|
||||
#define SET_CCR(A) \
|
||||
CPU->flag_C = (A) << (C68K_SR_C_SFT - 0); \
|
||||
CPU->flag_V = (A) << (C68K_SR_V_SFT - 1); \
|
||||
CPU->flag_notZ = ~(A) & 4; \
|
||||
CPU->flag_N = (A) << (C68K_SR_N_SFT - 3); \
|
||||
CPU->flag_X = (A) << (C68K_SR_X_SFT - 4);
|
||||
|
||||
#define SET_SR(A) \
|
||||
SET_CCR(A) \
|
||||
CPU->flag_I = ((A) >> 8) & 7; \
|
||||
CPU->flag_S = (A) & C68K_SR_S;
|
||||
|
||||
#define CHECK_INT \
|
||||
{ \
|
||||
s32 line, vect; \
|
||||
\
|
||||
line = CPU->IRQLine; \
|
||||
\
|
||||
if ((line == 7) || (line > CPU->flag_I)) \
|
||||
{ \
|
||||
/* get vector */ \
|
||||
CPU->IRQLine = 0; \
|
||||
vect = CPU->Interrupt_CallBack(line); \
|
||||
if (vect == C68K_INT_ACK_AUTOVECTOR) \
|
||||
vect = C68K_INTERRUPT_AUTOVECTOR_EX + (line & 7); \
|
||||
\
|
||||
/* adjust CCnt */ \
|
||||
CCnt -= c68k_exception_cycle_table[vect]; \
|
||||
\
|
||||
/* swap A7 and USP */ \
|
||||
if (!CPU->flag_S) \
|
||||
{ \
|
||||
u32 tmpSP; \
|
||||
\
|
||||
tmpSP = CPU->USP; \
|
||||
CPU->USP = CPU->A[7]; \
|
||||
CPU->A[7] = tmpSP; \
|
||||
} \
|
||||
\
|
||||
PRE_IO \
|
||||
\
|
||||
/* push PC and SR */ \
|
||||
PUSH_32_F(PC - CPU->BasePC) \
|
||||
PUSH_16_F(GET_SR) \
|
||||
\
|
||||
/* adjust SR */ \
|
||||
CPU->flag_S = C68K_SR_S; \
|
||||
CPU->flag_I = line; \
|
||||
\
|
||||
/* fetch new PC */ \
|
||||
READ_LONG_F(vect * 4, PC) \
|
||||
SET_PC(PC) \
|
||||
\
|
||||
POST_IO \
|
||||
} \
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
/* Copyright 2005 Guillaume Duhamel
|
||||
Copyright 2005-2006 Theo Berkau
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CORE_H
|
||||
#define CORE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef ALIGNED
|
||||
#ifdef _MSC_VER
|
||||
#define ALIGNED(x) __declspec(align(x))
|
||||
#else
|
||||
#define ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STDCALL
|
||||
#ifdef _MSC_VER
|
||||
#define STDCALL __stdcall
|
||||
#else
|
||||
#define STDCALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FASTCALL
|
||||
#ifdef __MINGW32__
|
||||
#define FASTCALL __attribute__((fastcall))
|
||||
#elif defined (__i386__)
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#else
|
||||
#define FASTCALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* When building multiple arches on OS X you must use the compiler-
|
||||
provided endian flags instead of the one provided by autoconf */
|
||||
#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)
|
||||
#undef WORDS_BIGENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#define WORDS_BIGENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INLINE
|
||||
#ifdef _MSC_VER
|
||||
#define INLINE _inline
|
||||
#else
|
||||
#define INLINE inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
/* Wii have both stdint.h and "yabause" definitions of fixed
|
||||
size types */
|
||||
#include <gccore.h>
|
||||
typedef unsigned long pointer;
|
||||
|
||||
#else /* ! GEKKO */
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
|
||||
#include <stdint.h>
|
||||
typedef uint8_t u8;
|
||||
typedef int8_t s8;
|
||||
typedef uint16_t u16;
|
||||
typedef int16_t s16;
|
||||
typedef uint32_t u32;
|
||||
typedef int32_t s32;
|
||||
typedef uint64_t u64;
|
||||
typedef int64_t s64;
|
||||
typedef uintptr_t pointer;
|
||||
|
||||
#else // !HAVE_STDINT_H
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
|
||||
#if defined(__LP64__)
|
||||
// Generic 64-bit
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long u64;
|
||||
typedef unsigned long pointer;
|
||||
|
||||
typedef signed int s32;
|
||||
typedef signed long s64;
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned __int64 u64;
|
||||
typedef unsigned long long u64;
|
||||
#ifdef _WIN64
|
||||
typedef __int64 pointer;
|
||||
#else
|
||||
typedef unsigned long pointer;
|
||||
#endif
|
||||
|
||||
typedef signed long s32;
|
||||
typedef __int64 s64;
|
||||
typedef signed long long s64;
|
||||
|
||||
#else
|
||||
// 32-bit Linux GCC/MINGW/etc.
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
typedef unsigned long pointer;
|
||||
|
||||
typedef signed long s32;
|
||||
typedef signed long long s64;
|
||||
#endif
|
||||
|
||||
#endif // !HAVE_STDINT_H
|
||||
|
||||
#endif // !GEKKO
|
||||
|
||||
#if 0
|
||||
typedef struct {
|
||||
unsigned int size;
|
||||
unsigned int done;
|
||||
} IOCheck_struct;
|
||||
|
||||
static INLINE void ywrite(IOCheck_struct * check, void * ptr, size_t size, size_t nmemb, FILE * stream) {
|
||||
check->done += (unsigned int)fwrite(ptr, size, nmemb, stream);
|
||||
check->size += (unsigned int)nmemb;
|
||||
}
|
||||
|
||||
static INLINE void yread(IOCheck_struct * check, void * ptr, size_t size, size_t nmemb, FILE * stream) {
|
||||
check->done += (unsigned int)fread(ptr, size, nmemb, stream);
|
||||
check->size += (unsigned int)nmemb;
|
||||
}
|
||||
|
||||
static INLINE int StateWriteHeader(FILE *fp, const char *name, int version) {
|
||||
IOCheck_struct check;
|
||||
fprintf(fp, "%s", name);
|
||||
check.done = 0;
|
||||
check.size = 0;
|
||||
ywrite(&check, (void *)&version, sizeof(version), 1, fp);
|
||||
ywrite(&check, (void *)&version, sizeof(version), 1, fp); // place holder for size
|
||||
return (check.done == check.size) ? ftell(fp) : -1;
|
||||
}
|
||||
|
||||
static INLINE int StateFinishHeader(FILE *fp, int offset) {
|
||||
IOCheck_struct check;
|
||||
int size = 0;
|
||||
size = ftell(fp) - offset;
|
||||
fseek(fp, offset - 4, SEEK_SET);
|
||||
check.done = 0;
|
||||
check.size = 0;
|
||||
ywrite(&check, (void *)&size, sizeof(size), 1, fp); // write true size
|
||||
fseek(fp, 0, SEEK_END);
|
||||
return (check.done == check.size) ? (size + 12) : -1;
|
||||
}
|
||||
|
||||
static INLINE int StateCheckRetrieveHeader(FILE *fp, const char *name, int *version, int *size) {
|
||||
char id[4];
|
||||
size_t ret;
|
||||
|
||||
if ((ret = fread((void *)id, 1, 4, fp)) != 4)
|
||||
return -1;
|
||||
|
||||
if (strncmp(name, id, 4) != 0)
|
||||
return -2;
|
||||
|
||||
if ((ret = fread((void *)version, 4, 1, fp)) != 1)
|
||||
return -1;
|
||||
|
||||
if (fread((void *)size, 4, 1, fp) != 1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Terrible, but I'm not sure how to do the equivalent in inline
|
||||
#ifdef HAVE_C99_VARIADIC_MACROS
|
||||
#define AddString(s, ...) \
|
||||
{ \
|
||||
sprintf(s, __VA_ARGS__); \
|
||||
s += strlen(s); \
|
||||
}
|
||||
#else
|
||||
#define AddString(s, r...) \
|
||||
{ \
|
||||
sprintf(s, ## r); \
|
||||
s += strlen(s); \
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef HAVE_LIBMINI18N
|
||||
#include "mini18n.h"
|
||||
#else
|
||||
#ifndef _
|
||||
#define _(a) (a)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Minimum/maximum values */
|
||||
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* BSWAP16(x) swaps two bytes in a 16-bit value (AABB -> BBAA) or adjacent
|
||||
* bytes in a 32-bit value (AABBCCDD -> BBAADDCC).
|
||||
*
|
||||
* BSWAP32(x) reverses four bytes in a 32-bit value (AABBCCDD -> DDCCBBAA).
|
||||
*
|
||||
* WSWAP32(x) swaps two 16-bit words in a 32-bit value (AABBCCDD -> CCDDAABB).
|
||||
*
|
||||
* Any of these can be left undefined if there is no platform-specific
|
||||
* optimization for them; the defaults below will then be used instead.
|
||||
*/
|
||||
|
||||
#ifdef PSP
|
||||
# define BSWAP16(x) ((typeof(x)) __builtin_allegrex_wsbh((x)))
|
||||
# define BSWAP16L(x) BSWAP16(x)
|
||||
# define BSWAP32(x) ((typeof(x)) __builtin_allegrex_wsbw((x)))
|
||||
# define WSWAP32(x) ((typeof(x)) __builtin_allegrex_rotr((x), 16))
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef HAVE_BUILTIN_BSWAP16
|
||||
# define BSWAP16(x) ((__builtin_bswap16((x) >> 16) << 16) | __builtin_bswap16((x)))
|
||||
# define BSWAP16L(x) (__builtin_bswap16((x)))
|
||||
#endif
|
||||
# define BSWAP32(x) (__builtin_bswap32((x)))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define BSWAP16(x) ((_byteswap_ushort((x) >> 16) << 16) | _byteswap_ushort((x)))
|
||||
# define BSWAP16L(x) (_byteswap_ushort((x)))
|
||||
# define BSWAP32(x) (_byteswap_ulong((x)))
|
||||
# define WSWAP32(x) (_lrotr((x), 16))
|
||||
#endif
|
||||
|
||||
/* Defaults: */
|
||||
|
||||
#ifndef BSWAP16
|
||||
# define BSWAP16(x) (((u32)(x)>>8 & 0x00FF00FF) | ((u32)(x) & 0x00FF00FF) << 8)
|
||||
#endif
|
||||
#ifndef BSWAP16L
|
||||
# define BSWAP16L(x) (((u16)(x)>>8 & 0xFF) | ((u16)(x) & 0xFF) << 8)
|
||||
#endif
|
||||
#ifndef BSWAP32
|
||||
# define BSWAP32(x) ((u32)(x)>>24 | ((u32)(x)>>8 & 0xFF00) | ((u32)(x) & 0xFF00)<<8 | (u32)(x)<<24)
|
||||
#endif
|
||||
#ifndef WSWAP32
|
||||
# define WSWAP32(x) ((u32)(x)>>16 | (u32)(x)<<16)
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED __attribute ((unused))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define USED_IF_DEBUG
|
||||
#else
|
||||
#define USED_IF_DEBUG __attribute ((unused))
|
||||
#endif
|
||||
|
||||
#ifdef SMPC_DEBUG
|
||||
#define USED_IF_SMPC_DEBUG
|
||||
#else
|
||||
#define USED_IF_SMPC_DEBUG __attribute ((unused))
|
||||
#endif
|
||||
|
||||
/* LIKELY(x) indicates that x is likely to be true (nonzero);
|
||||
* UNLIKELY(x) indicates that x is likely to be false (zero).
|
||||
* Use like: "if (UNLIKELY(a < b)) {...}" */
|
||||
#define LIKELY(x) (__builtin_expect(!!(x), 1))
|
||||
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
|
||||
|
||||
#else
|
||||
|
||||
#define UNUSED
|
||||
#define USED_IF_DEBUG
|
||||
#define USED_IF_SMPC_DEBUG
|
||||
#define LIKELY(x) (x)
|
||||
#define UNLIKELY(x) (x)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_16BPP
|
||||
typedef u16 pixel_t;
|
||||
#else
|
||||
typedef u32 pixel_t;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,68 @@
|
||||
/* Copyright 2003-2004 Stephane Dallongeville
|
||||
Copyright 2004 Theo Berkau
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yabause is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*********************************************************************************
|
||||
* GEN68K.H :
|
||||
*
|
||||
* C68K generator include file
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef _GEN68K_H_
|
||||
#define _GEN68K_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// setting
|
||||
///////////
|
||||
|
||||
// structure definition
|
||||
////////////////////////
|
||||
|
||||
typedef struct {
|
||||
u32 name;
|
||||
u32 mask;
|
||||
u32 match;
|
||||
} c68k_ea_info_struc;
|
||||
|
||||
typedef struct __c68k_op_info_struc {
|
||||
s8 op_name[8 + 1];
|
||||
u16 op_base;
|
||||
u16 op_mask;
|
||||
s8 size_type;
|
||||
s8 size_sft;
|
||||
s8 eam_sft;
|
||||
s8 reg_sft;
|
||||
s8 eam2_sft;
|
||||
s8 reg2_sft;
|
||||
s8 ea_supported[12 + 1];
|
||||
s8 ea2_supported[12 + 1];
|
||||
void (*genfunc)(void);
|
||||
} c68k_op_info_struc;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _GEN68K_H_
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+83
-21
@@ -7,9 +7,12 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "m68000.h"
|
||||
#include "c68k.h"
|
||||
#include "c68k/c68k.h"
|
||||
#include "../x68k/memory.h"
|
||||
|
||||
int m68000_ICountBk;
|
||||
int ICount;
|
||||
|
||||
/******************************************************************************
|
||||
CPS2暗号化ROM用
|
||||
******************************************************************************/
|
||||
@@ -65,21 +68,29 @@ static UINT16 m68000_read_pcrelative_16(UINT32 offset)
|
||||
/*--------------------------------------------------------
|
||||
CPU初期化
|
||||
--------------------------------------------------------*/
|
||||
s32 my_irqh_callback(s32 level);
|
||||
|
||||
void m68000_init(void)
|
||||
{
|
||||
C68k_Init(&C68K);
|
||||
C68k_Set_ReadB(&C68K, Memory_ReadB);
|
||||
C68k_Set_ReadW(&C68K, Memory_ReadW);
|
||||
C68k_Set_WriteB(&C68K, Memory_WriteB);
|
||||
C68k_Set_WriteW(&C68K, Memory_WriteW);
|
||||
C68k_Set_Fetch(&C68K, 0x000000, 0xbfffff, (UINT32)MEM);
|
||||
C68k_Set_Fetch(&C68K, 0xc00000, 0xc7ffff, (UINT32)GVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xe00000, 0xe7ffff, (UINT32)TVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xea0000, 0xea1fff, (UINT32)SCSIIPL);
|
||||
C68k_Set_Fetch(&C68K, 0xed0000, 0xed3fff, (UINT32)SRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xf00000, 0xfbffff, (UINT32)FONT);
|
||||
C68k_Set_Fetch(&C68K, 0xfc0000, 0xffffff, (UINT32)IPL);
|
||||
C68k_Init(&C68K, my_irqh_callback);
|
||||
#if 0
|
||||
C68k_Set_ReadB(&C68K, Memory_ReadB);
|
||||
C68k_Set_ReadW(&C68K, Memory_ReadW);
|
||||
C68k_Set_WriteB(&C68K, Memory_WriteB);
|
||||
C68k_Set_WriteW(&C68K, Memory_WriteW);
|
||||
#else
|
||||
C68k_Set_ReadB(&C68K, Memory_ReadB);
|
||||
C68k_Set_ReadW(&C68K, Memory_ReadW);
|
||||
C68k_Set_WriteB(&C68K, Memory_WriteB);
|
||||
C68k_Set_WriteW(&C68K, Memory_WriteW);
|
||||
#endif
|
||||
C68k_Set_Fetch(&C68K, 0x000000, 0xbfffff, (pointer)MEM);
|
||||
C68k_Set_Fetch(&C68K, 0xc00000, 0xc7ffff, (pointer)GVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xe00000, 0xe7ffff, (pointer)TVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xea0000, 0xea1fff, (pointer)SCSIIPL);
|
||||
C68k_Set_Fetch(&C68K, 0xed0000, 0xed3fff, (pointer)SRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xf00000, 0xfbffff, (pointer)FONT);
|
||||
C68k_Set_Fetch(&C68K, 0xfc0000, 0xffffff, (pointer)IPL);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,15 +134,17 @@ void m68000_execute2(UINT32 start, UINT32 break_point)
|
||||
UINT32 pc, old_pc, opcode;
|
||||
c68k_struc C68K_temp;
|
||||
|
||||
old_pc = C68k_Get_Reg(&C68K, M68K_PC);
|
||||
old_pc = C68k_Get_PC(&C68K);
|
||||
|
||||
memcpy(&C68K_temp, &C68K, sizeof(c68k_struc));
|
||||
|
||||
C68k_Set_Reg(&C68K_temp, C68K_PC, start);
|
||||
// C68k_Set_Reg(&C68K_temp, C68K_PC, start);
|
||||
C68k_Set_PC(&C68K_temp, start);
|
||||
C68K_temp.A[5] = 0x108000;
|
||||
C68K_temp.A[7] -= 4 * 8 * 2;
|
||||
|
||||
while ((pc = C68k_Get_Reg(&C68K_temp, M68K_PC)) != break_point)
|
||||
// while ((pc = C68k_Get_Reg(&C68K_temp, M68K_PC)) != break_point)
|
||||
while ((pc = C68k_Get_PC(&C68K_temp)) != break_point)
|
||||
{
|
||||
opcode = Memory_ReadW(pc);
|
||||
if (opcode == 0x4e75)
|
||||
@@ -159,7 +172,8 @@ void m68000_execute2(UINT32 start, UINT32 break_point)
|
||||
C68k_Exec(&C68K_temp, 1);
|
||||
}
|
||||
|
||||
C68k_Set_Reg(&C68K, C68K_PC, old_pc);
|
||||
// C68k_Set_Reg(&C68K, C68K_PC, old_pc);
|
||||
C68k_Set_PC(&C68K, old_pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -170,10 +184,11 @@ void m68000_execute2(UINT32 start, UINT32 break_point)
|
||||
|
||||
void m68000_set_irq_line(int irqline, int state)
|
||||
{
|
||||
if (irqline == IRQ_LINE_NMI)
|
||||
irqline = 7;
|
||||
// if (irqline == IRQ_LINE_NMI)
|
||||
// irqline = 7;
|
||||
|
||||
C68k_Set_IRQ(&C68K, irqline, state);
|
||||
// C68k_Set_IRQ(&C68K, irqline, state);
|
||||
C68k_Set_IRQ(&C68K, irqline);
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +198,7 @@ void m68000_set_irq_line(int irqline, int state)
|
||||
|
||||
void m68000_set_irq_callback(int (*callback)(int line))
|
||||
{
|
||||
C68k_Set_IRQ_Callback(&C68K, callback);
|
||||
// C68k_Set_IRQ_Callback(&C68K, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +210,7 @@ UINT32 m68000_get_reg(int regnum)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
#if 0
|
||||
case M68K_PC: return C68k_Get_Reg(&C68K, C68K_PC);
|
||||
case M68K_USP: return C68k_Get_Reg(&C68K, C68K_USP);
|
||||
case M68K_MSP: return C68k_Get_Reg(&C68K, C68K_MSP);
|
||||
@@ -215,6 +231,29 @@ UINT32 m68000_get_reg(int regnum)
|
||||
case M68K_A5: return C68k_Get_Reg(&C68K, C68K_A5);
|
||||
case M68K_A6: return C68k_Get_Reg(&C68K, C68K_A6);
|
||||
case M68K_A7: return C68k_Get_Reg(&C68K, C68K_A7);
|
||||
#else
|
||||
case M68K_PC: return C68k_Get_PC(&C68K);
|
||||
case M68K_USP: return C68k_Get_USP(&C68K);
|
||||
case M68K_MSP: return C68k_Get_MSP(&C68K);
|
||||
case M68K_SR: return C68k_Get_SR(&C68K);
|
||||
case M68K_D0: return C68k_Get_DReg(&C68K, 0);
|
||||
case M68K_D1: return C68k_Get_DReg(&C68K, 1);
|
||||
case M68K_D2: return C68k_Get_DReg(&C68K, 2);
|
||||
case M68K_D3: return C68k_Get_DReg(&C68K, 3);
|
||||
case M68K_D4: return C68k_Get_DReg(&C68K, 4);
|
||||
case M68K_D5: return C68k_Get_DReg(&C68K, 5);
|
||||
case M68K_D6: return C68k_Get_DReg(&C68K, 6);
|
||||
case M68K_D7: return C68k_Get_DReg(&C68K, 7);
|
||||
case M68K_A0: return C68k_Get_AReg(&C68K, 0);
|
||||
case M68K_A1: return C68k_Get_AReg(&C68K, 1);
|
||||
case M68K_A2: return C68k_Get_AReg(&C68K, 2);
|
||||
case M68K_A3: return C68k_Get_AReg(&C68K, 3);
|
||||
case M68K_A4: return C68k_Get_AReg(&C68K, 4);
|
||||
case M68K_A5: return C68k_Get_AReg(&C68K, 5);
|
||||
case M68K_A6: return C68k_Get_AReg(&C68K, 6);
|
||||
case M68K_A7: return C68k_Get_AReg(&C68K, 7);
|
||||
#endif
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
@@ -228,6 +267,7 @@ void m68000_set_reg(int regnum, UINT32 val)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
#if 0
|
||||
case M68K_PC: C68k_Set_Reg(&C68K, C68K_PC, val); break;
|
||||
case M68K_USP: C68k_Set_Reg(&C68K, C68K_USP, val); break;
|
||||
case M68K_MSP: C68k_Set_Reg(&C68K, C68K_MSP, val); break;
|
||||
@@ -248,6 +288,28 @@ void m68000_set_reg(int regnum, UINT32 val)
|
||||
case M68K_A5: C68k_Set_Reg(&C68K, C68K_A5, val); break;
|
||||
case M68K_A6: C68k_Set_Reg(&C68K, C68K_A6, val); break;
|
||||
case M68K_A7: C68k_Set_Reg(&C68K, C68K_A7, val); break;
|
||||
#else
|
||||
case M68K_PC: C68k_Set_PC(&C68K, val); break;
|
||||
case M68K_USP: C68k_Set_USP(&C68K, val); break;
|
||||
case M68K_MSP: C68k_Set_MSP(&C68K, val); break;
|
||||
case M68K_SR: C68k_Set_SR(&C68K, val); break;
|
||||
case M68K_D0: C68k_Set_DReg(&C68K, 0, val); break;
|
||||
case M68K_D1: C68k_Set_DReg(&C68K, 1, val); break;
|
||||
case M68K_D2: C68k_Set_DReg(&C68K, 2, val); break;
|
||||
case M68K_D3: C68k_Set_DReg(&C68K, 3, val); break;
|
||||
case M68K_D4: C68k_Set_DReg(&C68K, 4, val); break;
|
||||
case M68K_D5: C68k_Set_DReg(&C68K, 5, val); break;
|
||||
case M68K_D6: C68k_Set_DReg(&C68K, 6, val); break;
|
||||
case M68K_D7: C68k_Set_DReg(&C68K, 7, val); break;
|
||||
case M68K_A0: C68k_Set_AReg(&C68K, 0, val); break;
|
||||
case M68K_A1: C68k_Set_AReg(&C68K, 1, val); break;
|
||||
case M68K_A2: C68k_Set_AReg(&C68K, 2, val); break;
|
||||
case M68K_A3: C68k_Set_AReg(&C68K, 3, val); break;
|
||||
case M68K_A4: C68k_Set_AReg(&C68K, 4, val); break;
|
||||
case M68K_A5: C68k_Set_AReg(&C68K, 5, val); break;
|
||||
case M68K_A6: C68k_Set_AReg(&C68K, 6, val); break;
|
||||
case M68K_A7: C68k_Set_AReg(&C68K, 7, val); break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#ifndef M68000_H
|
||||
#define M68000_H
|
||||
|
||||
#include "c68k.h"
|
||||
#include "c68k/c68k.h"
|
||||
|
||||
// MAME互換のレジスタ番号 (一部未対応)
|
||||
enum
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* C68K (68000 CPU emulator) version 0.80
|
||||
* Compiled with Dev-C++
|
||||
* Copyright 2003-2004 Stephane Dallongeville
|
||||
*
|
||||
* (Modified by NJ)
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "c68k.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
マクロ
|
||||
******************************************************************************/
|
||||
|
||||
#include "c68kmacro.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
グローバル構造体
|
||||
******************************************************************************/
|
||||
|
||||
c68k_struc C68K;
|
||||
int m68000_ICountBk;
|
||||
int ICount;
|
||||
|
||||
/******************************************************************************
|
||||
ローカル変数
|
||||
******************************************************************************/
|
||||
|
||||
static void *JumpTable[0x10000];
|
||||
static UINT8 c68k_bad_address[1 << C68K_FETCH_SFT];
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
ローカル関数
|
||||
******************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------
|
||||
割り込みコールバック
|
||||
--------------------------------------------------------*/
|
||||
|
||||
static INT32 C68k_InterruptCallback(INT32 line)
|
||||
{
|
||||
return C68K_INTERRUPT_AUTOVECTOR_EX + line;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
リセットコールバック
|
||||
--------------------------------------------------------*/
|
||||
|
||||
static void C68k_ResetCallback(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
C68Kインタフェース関数
|
||||
******************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU初期化
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Init(c68k_struc *CPU)
|
||||
{
|
||||
int i;
|
||||
|
||||
memset(CPU, 0, sizeof(c68k_struc));
|
||||
|
||||
CPU->Interrupt_CallBack = C68k_InterruptCallback;
|
||||
CPU->Reset_CallBack = C68k_ResetCallback;
|
||||
|
||||
memset(c68k_bad_address, 0xff, sizeof(c68k_bad_address));
|
||||
|
||||
for (i = 0; i < C68K_FETCH_BANK; i++)
|
||||
CPU->Fetch[i] = (UINT32)c68k_bad_address;
|
||||
|
||||
C68k_Exec(NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPUリセット
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Reset(c68k_struc *CPU)
|
||||
{
|
||||
UINT32 PC;
|
||||
|
||||
memset(CPU, 0, (UINT32)&CPU->BasePC - (UINT32)CPU);
|
||||
|
||||
CPU->flag_I = 7;
|
||||
CPU->flag_S = C68K_SR_S;
|
||||
|
||||
// SP, PCの初期化はWinX68k_Reset()側で実行する
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU実行
|
||||
--------------------------------------------------------*/
|
||||
|
||||
extern DWORD BusErrHandling;
|
||||
extern DWORD BusErrAdr;
|
||||
|
||||
INT32 C68k_Exec(c68k_struc *CPU, INT32 cycles)
|
||||
{
|
||||
if (CPU)
|
||||
{
|
||||
UINT32 PC;
|
||||
UINT32 Opcode;
|
||||
UINT32 adr;
|
||||
UINT32 res;
|
||||
UINT32 src;
|
||||
UINT32 dst;
|
||||
|
||||
PC = CPU->PC;
|
||||
CPU->ICount = cycles;
|
||||
|
||||
C68k_Check_Interrupt:
|
||||
CHECK_INT
|
||||
if (!CPU->HaltState)
|
||||
{
|
||||
|
||||
C68k_Exec_Next:
|
||||
if (CPU->ICount > 0)
|
||||
{
|
||||
|
||||
if (BusErrHandling) {
|
||||
printf("BusError occured\n");
|
||||
SWAP_SP();
|
||||
PUSH_32_F(GET_PC() - 2);
|
||||
PUSH_16_F(GET_SR());
|
||||
CPU->A[7] -= 2;
|
||||
PUSH_32_F(BusErrAdr);
|
||||
CPU->A[7] -= 2;
|
||||
CPU->flag_S = C68K_SR_S;
|
||||
PC = READ_MEM_32((C68K_BUS_ERROR_EX) << 2);
|
||||
SET_PC(PC);
|
||||
BusErrHandling = 0;
|
||||
}
|
||||
|
||||
|
||||
Opcode = READ_IMM_16();
|
||||
PC += 2;
|
||||
goto *JumpTable[Opcode];
|
||||
|
||||
#include "c68k_op.c"
|
||||
}
|
||||
}
|
||||
|
||||
CPU->PC = PC;
|
||||
|
||||
return cycles - CPU->ICount;
|
||||
}
|
||||
else
|
||||
{
|
||||
#include "c68k_ini.c"
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
割り込み処理
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Set_IRQ(c68k_struc *CPU, INT32 line, INT32 state)
|
||||
{
|
||||
CPU->IRQState = state;
|
||||
if (state == CLEAR_LINE)
|
||||
{
|
||||
CPU->IRQLine = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CPU->IRQLine = line;
|
||||
CPU->HaltState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
レジスタ取得
|
||||
--------------------------------------------------------*/
|
||||
|
||||
UINT32 C68k_Get_Reg(c68k_struc *CPU, INT32 regnum)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
case C68K_PC: return (CPU->PC - CPU->BasePC);
|
||||
case C68K_USP: return (CPU->flag_S ? CPU->USP : CPU->A[7]);
|
||||
case C68K_MSP: return (CPU->flag_S ? CPU->A[7] : CPU->USP);
|
||||
case C68K_SR: return GET_SR();
|
||||
case C68K_D0: return CPU->D[0];
|
||||
case C68K_D1: return CPU->D[1];
|
||||
case C68K_D2: return CPU->D[2];
|
||||
case C68K_D3: return CPU->D[3];
|
||||
case C68K_D4: return CPU->D[4];
|
||||
case C68K_D5: return CPU->D[5];
|
||||
case C68K_D6: return CPU->D[6];
|
||||
case C68K_D7: return CPU->D[7];
|
||||
case C68K_A0: return CPU->A[0];
|
||||
case C68K_A1: return CPU->A[1];
|
||||
case C68K_A2: return CPU->A[2];
|
||||
case C68K_A3: return CPU->A[3];
|
||||
case C68K_A4: return CPU->A[4];
|
||||
case C68K_A5: return CPU->A[5];
|
||||
case C68K_A6: return CPU->A[6];
|
||||
case C68K_A7: return CPU->A[7];
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
レジスタ設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Set_Reg(c68k_struc *CPU, INT32 regnum, UINT32 val)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
case C68K_PC:
|
||||
CPU->BasePC = CPU->Fetch[(val >> C68K_FETCH_SFT) & C68K_FETCH_MASK];
|
||||
CPU->BasePC -= val & 0xff000000;
|
||||
CPU->PC = val + CPU->BasePC;
|
||||
break;
|
||||
|
||||
case C68K_USP:
|
||||
if (CPU->flag_S) CPU->USP = val;
|
||||
else CPU->A[7] = val;
|
||||
break;
|
||||
|
||||
case C68K_MSP:
|
||||
if (CPU->flag_S) CPU->A[7] = val;
|
||||
else CPU->USP = val;
|
||||
break;
|
||||
|
||||
case C68K_SR: SET_SR(val); break;
|
||||
case C68K_D0: CPU->D[0] = val; break;
|
||||
case C68K_D1: CPU->D[1] = val; break;
|
||||
case C68K_D2: CPU->D[2] = val; break;
|
||||
case C68K_D3: CPU->D[3] = val; break;
|
||||
case C68K_D4: CPU->D[4] = val; break;
|
||||
case C68K_D5: CPU->D[5] = val; break;
|
||||
case C68K_D6: CPU->D[6] = val; break;
|
||||
case C68K_D7: CPU->D[7] = val; break;
|
||||
case C68K_A0: CPU->A[0] = val; break;
|
||||
case C68K_A1: CPU->A[1] = val; break;
|
||||
case C68K_A2: CPU->A[2] = val; break;
|
||||
case C68K_A3: CPU->A[3] = val; break;
|
||||
case C68K_A4: CPU->A[4] = val; break;
|
||||
case C68K_A5: CPU->A[5] = val; break;
|
||||
case C68K_A6: CPU->A[6] = val; break;
|
||||
case C68K_A7: CPU->A[7] = val; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
フェッチアドレス設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Set_Fetch(c68k_struc *CPU, UINT32 low_adr, UINT32 high_adr, UINT32 fetch_adr)
|
||||
{
|
||||
UINT32 i, j;
|
||||
|
||||
i = (low_adr >> C68K_FETCH_SFT) & C68K_FETCH_MASK;
|
||||
j = (high_adr >> C68K_FETCH_SFT) & C68K_FETCH_MASK;
|
||||
fetch_adr -= i << C68K_FETCH_SFT;
|
||||
while (i <= j) CPU->Fetch[i++] = fetch_adr;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
メモリリード/ライト関数設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Set_ReadB(c68k_struc *CPU, UINT8 (*Func)(UINT32 address))
|
||||
{
|
||||
CPU->Read_Byte = Func;
|
||||
CPU->Read_Byte_PC_Relative = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_ReadW(c68k_struc *CPU, UINT16 (*Func)(UINT32 address))
|
||||
{
|
||||
CPU->Read_Word = Func;
|
||||
CPU->Read_Word_PC_Relative = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_ReadB_PC_Relative(c68k_struc *CPU, UINT8 (*Func)(UINT32 address))
|
||||
{
|
||||
CPU->Read_Byte_PC_Relative = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_ReadW_PC_Relative(c68k_struc *CPU, UINT16 (*Func)(UINT32 address))
|
||||
{
|
||||
CPU->Read_Word_PC_Relative = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_WriteB(c68k_struc *CPU, void (*Func)(UINT32 address, UINT8 data))
|
||||
{
|
||||
CPU->Write_Byte = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_WriteW(c68k_struc *CPU, void (*Func)(UINT32 address, UINT16 data))
|
||||
{
|
||||
CPU->Write_Word = Func;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
コールバック関数設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void C68k_Set_IRQ_Callback(c68k_struc *CPU, INT32 (*Func)(INT32 irqline))
|
||||
{
|
||||
CPU->Interrupt_CallBack = Func;
|
||||
}
|
||||
|
||||
void C68k_Set_Reset_Callback(c68k_struc *CPU, void (*Func)(void))
|
||||
{
|
||||
CPU->Reset_CallBack = Func;
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* C68K (68000 CPU emulator) version 0.80
|
||||
* Compiled with Dev-C++
|
||||
* Copyright 2003-2004 Stephane Dallongeville
|
||||
*
|
||||
* (Modified by NJ)
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef C68K_H
|
||||
#define C68K_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
// setting
|
||||
///////////
|
||||
|
||||
//#define C68K_BIG_ENDIAN
|
||||
|
||||
#define C68K_FETCH_BITS 8 // [4-12] default = 8
|
||||
|
||||
// 68K core types definitions
|
||||
//////////////////////////////
|
||||
|
||||
#define C68K_ADR_BITS 24
|
||||
|
||||
#define C68K_FETCH_SFT (C68K_ADR_BITS - C68K_FETCH_BITS)
|
||||
#define C68K_FETCH_BANK (1 << C68K_FETCH_BITS)
|
||||
#define C68K_FETCH_MASK (C68K_FETCH_BANK - 1)
|
||||
|
||||
#define C68K_SR_C_SFT 8
|
||||
#define C68K_SR_V_SFT 7
|
||||
#define C68K_SR_Z_SFT 0
|
||||
#define C68K_SR_N_SFT 7
|
||||
#define C68K_SR_X_SFT 8
|
||||
|
||||
#define C68K_SR_S_SFT 13
|
||||
|
||||
#define C68K_SR_C (1 << C68K_SR_C_SFT)
|
||||
#define C68K_SR_V (1 << C68K_SR_V_SFT)
|
||||
#define C68K_SR_Z 0
|
||||
#define C68K_SR_N (1 << C68K_SR_N_SFT)
|
||||
#define C68K_SR_X (1 << C68K_SR_X_SFT)
|
||||
|
||||
#define C68K_SR_S (1 << C68K_SR_S_SFT)
|
||||
|
||||
#define C68K_CCR_MASK 0x1F
|
||||
#define C68K_SR_MASK (0x2700 | C68K_CCR_MASK)
|
||||
|
||||
// exception defines taken from musashi core
|
||||
#define C68K_RESET_EX 1
|
||||
#define C68K_BUS_ERROR_EX 2
|
||||
#define C68K_ADDRESS_ERROR_EX 3
|
||||
#define C68K_ILLEGAL_INSTRUCTION_EX 4
|
||||
#define C68K_ZERO_DIVIDE_EX 5
|
||||
#define C68K_CHK_EX 6
|
||||
#define C68K_TRAPV_EX 7
|
||||
#define C68K_PRIVILEGE_VIOLATION_EX 8
|
||||
#define C68K_TRACE_EX 9
|
||||
#define C68K_1010_EX 10
|
||||
#define C68K_1111_EX 11
|
||||
#define C68K_FORMAT_ERROR_EX 14
|
||||
#define C68K_UNINITIALIZED_INTERRUPT_EX 15
|
||||
#define C68K_SPURIOUS_INTERRUPT_EX 24
|
||||
#define C68K_INTERRUPT_AUTOVECTOR_EX 24
|
||||
#define C68K_TRAP_BASE_EX 32
|
||||
|
||||
#define C68K_INT_ACK_AUTOVECTOR -1
|
||||
|
||||
#ifndef IRQ_LINE_STATE
|
||||
#define IRQ_LINE_STATE
|
||||
#define CLEAR_LINE 0 /* clear (a fired, held or pulsed) line */
|
||||
#define ASSERT_LINE 1 /* assert an interrupt immediately */
|
||||
#define HOLD_LINE 2 /* hold interrupt line until acknowledged */
|
||||
#define PULSE_LINE 3 /* pulse interrupt line for one instruction */
|
||||
#define IRQ_LINE_NMI 127 /* IRQ line for NMIs */
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
C68K_PC = 1,
|
||||
C68K_USP,
|
||||
C68K_MSP,
|
||||
C68K_SR,
|
||||
C68K_D0,
|
||||
C68K_D1,
|
||||
C68K_D2,
|
||||
C68K_D3,
|
||||
C68K_D4,
|
||||
C68K_D5,
|
||||
C68K_D6,
|
||||
C68K_D7,
|
||||
C68K_A0,
|
||||
C68K_A1,
|
||||
C68K_A2,
|
||||
C68K_A3,
|
||||
C68K_A4,
|
||||
C68K_A5,
|
||||
C68K_A6,
|
||||
C68K_A7
|
||||
};
|
||||
|
||||
typedef struct c68k_t
|
||||
{
|
||||
UINT32 D[8];
|
||||
UINT32 A[8];
|
||||
|
||||
UINT32 flag_C;
|
||||
UINT32 flag_V;
|
||||
UINT32 flag_Z;
|
||||
UINT32 flag_N;
|
||||
|
||||
UINT32 flag_X;
|
||||
UINT32 flag_I;
|
||||
UINT32 flag_S;
|
||||
|
||||
UINT32 USP;
|
||||
UINT32 PC;
|
||||
|
||||
UINT32 HaltState;
|
||||
INT32 IRQLine;
|
||||
INT32 IRQState;
|
||||
INT32 ICount;
|
||||
|
||||
UINT32 BasePC;
|
||||
UINT32 Fetch[C68K_FETCH_BANK];
|
||||
|
||||
UINT8 (*Read_Byte)(UINT32 address);
|
||||
UINT16 (*Read_Word)(UINT32 address);
|
||||
UINT8 (*Read_Byte_PC_Relative)(UINT32 address);
|
||||
UINT16 (*Read_Word_PC_Relative)(UINT32 address);
|
||||
void (*Write_Byte)(UINT32 address, UINT8 data);
|
||||
void (*Write_Word)(UINT32 address, UINT16 data);
|
||||
|
||||
INT32 (*Interrupt_CallBack)(INT32 irqline);
|
||||
void (*Reset_CallBack)(void);
|
||||
|
||||
} c68k_struc;
|
||||
|
||||
|
||||
// 68K core var declaration
|
||||
////////////////////////////
|
||||
|
||||
extern c68k_struc C68K;
|
||||
extern int m68000_ICountBk;
|
||||
|
||||
// 68K core function declaration
|
||||
/////////////////////////////////
|
||||
|
||||
void C68k_Init(c68k_struc *cpu);
|
||||
|
||||
void C68k_Reset(c68k_struc *cpu);
|
||||
|
||||
INT32 C68k_Exec(c68k_struc *cpu, INT32 cycle);
|
||||
|
||||
void C68k_Set_IRQ(c68k_struc *cpu, INT32 line, INT32 state);
|
||||
|
||||
UINT32 C68k_Get_Reg(c68k_struc *cpu, INT32 regnum);
|
||||
void C68k_Set_Reg(c68k_struc *cpu, INT32 regnum, UINT32 val);
|
||||
|
||||
void C68k_Set_Fetch(c68k_struc *cpu, UINT32 low_adr, UINT32 high_adr, UINT32 fetch_adr);
|
||||
|
||||
void C68k_Set_ReadB(c68k_struc *cpu, UINT8 (*Func)(UINT32 address));
|
||||
void C68k_Set_ReadW(c68k_struc *cpu, UINT16 (*Func)(UINT32 address));
|
||||
|
||||
void C68k_Set_ReadB_PC_Relative(c68k_struc *cpu, UINT8 (*Func)(UINT32 address));
|
||||
void C68k_Set_ReadW_PC_Relative(c68k_struc *cpu, UINT16 (*Func)(UINT32 address));
|
||||
|
||||
void C68k_Set_WriteB(c68k_struc *cpu, void (*Func)(UINT32 address, UINT8 data));
|
||||
void C68k_Set_WriteW(c68k_struc *cpu, void (*Func)(UINT32 address, UINT16 data));
|
||||
|
||||
void C68k_Set_IRQ_Callback(c68k_struc *cpu, INT32 (*Func)(INT32 irqline));
|
||||
void C68k_Set_Reset_Callback(c68k_struc *cpu, void (*Func)(void));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* C68K_H */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,312 @@
|
||||
/******************************************************************************
|
||||
|
||||
m68000.c
|
||||
|
||||
M68000 CPUインタフェース関数
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "m68000.h"
|
||||
#include "c68k.h"
|
||||
#include "../x68k/memory.h"
|
||||
|
||||
/******************************************************************************
|
||||
CPS2暗号化ROM用
|
||||
******************************************************************************/
|
||||
|
||||
#if (EMU_SYSTEM == CPS2)
|
||||
static UINT32 m68k_encrypt_start;
|
||||
static UINT32 m68k_encrypt_end;
|
||||
static UINT8 *m68k_decrypted_rom;
|
||||
|
||||
/*--------------------------------------------------------
|
||||
暗号化ROM範囲設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_set_encrypted_range(UINT32 start, UINT32 end, void *decrypted_rom)
|
||||
{
|
||||
m68k_encrypt_start = start;
|
||||
m68k_encrypt_end = end;
|
||||
m68k_decrypted_rom = (UINT8 *)decrypted_rom;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
PC依存メモリリード (byte)
|
||||
--------------------------------------------------------*/
|
||||
|
||||
static UINT8 m68000_read_pcrelative_8(UINT32 offset)
|
||||
{
|
||||
if (offset >= m68k_encrypt_start && offset <= m68k_encrypt_end)
|
||||
return m68k_decrypted_rom[offset ^ 1];
|
||||
else
|
||||
return Memory_ReadB(offset);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
PC依存メモリリード (word)
|
||||
--------------------------------------------------------*/
|
||||
|
||||
static UINT16 m68000_read_pcrelative_16(UINT32 offset)
|
||||
{
|
||||
if (offset >= m68k_encrypt_start && offset <= m68k_encrypt_end)
|
||||
return *(UINT16 *)&m68k_decrypted_rom[offset];
|
||||
else
|
||||
return Memory_ReadW(offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
M68000インタフェース関数
|
||||
******************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU初期化
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_init(void)
|
||||
{
|
||||
C68k_Init(&C68K);
|
||||
C68k_Set_ReadB(&C68K, Memory_ReadB);
|
||||
C68k_Set_ReadW(&C68K, Memory_ReadW);
|
||||
C68k_Set_WriteB(&C68K, Memory_WriteB);
|
||||
C68k_Set_WriteW(&C68K, Memory_WriteW);
|
||||
C68k_Set_Fetch(&C68K, 0x000000, 0xbfffff, (UINT32)MEM);
|
||||
C68k_Set_Fetch(&C68K, 0xc00000, 0xc7ffff, (UINT32)GVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xe00000, 0xe7ffff, (UINT32)TVRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xea0000, 0xea1fff, (UINT32)SCSIIPL);
|
||||
C68k_Set_Fetch(&C68K, 0xed0000, 0xed3fff, (UINT32)SRAM);
|
||||
C68k_Set_Fetch(&C68K, 0xf00000, 0xfbffff, (UINT32)FONT);
|
||||
C68k_Set_Fetch(&C68K, 0xfc0000, 0xffffff, (UINT32)IPL);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPUリセット
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_reset(void)
|
||||
{
|
||||
C68k_Reset(&C68K);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU停止
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU実行
|
||||
--------------------------------------------------------*/
|
||||
|
||||
int m68000_execute(int cycles)
|
||||
{
|
||||
return C68k_Exec(&C68K, cycles);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
CPU実行 (NEOGEO CDZ専用: ロード画面用)
|
||||
--------------------------------------------------------*/
|
||||
|
||||
#if (EMU_SYSTEM == NCDZ)
|
||||
void m68000_execute2(UINT32 start, UINT32 break_point)
|
||||
{
|
||||
int nest_counter = 0;
|
||||
UINT32 pc, old_pc, opcode;
|
||||
c68k_struc C68K_temp;
|
||||
|
||||
old_pc = C68k_Get_Reg(&C68K, M68K_PC);
|
||||
|
||||
memcpy(&C68K_temp, &C68K, sizeof(c68k_struc));
|
||||
|
||||
C68k_Set_Reg(&C68K_temp, C68K_PC, start);
|
||||
C68K_temp.A[5] = 0x108000;
|
||||
C68K_temp.A[7] -= 4 * 8 * 2;
|
||||
|
||||
while ((pc = C68k_Get_Reg(&C68K_temp, M68K_PC)) != break_point)
|
||||
{
|
||||
opcode = Memory_ReadW(pc);
|
||||
if (opcode == 0x4e75)
|
||||
{
|
||||
// rts
|
||||
nest_counter--;
|
||||
if (nest_counter < 0) break;
|
||||
}
|
||||
else if (opcode == 0x6100)
|
||||
{
|
||||
// bsr 16
|
||||
nest_counter++;
|
||||
}
|
||||
else if ((opcode & 0xff00) == 0x6100)
|
||||
{
|
||||
// bsr 8
|
||||
nest_counter++;
|
||||
}
|
||||
else if ((opcode & 0xffc0) == 0x4e80)
|
||||
{
|
||||
// jsr
|
||||
nest_counter++;
|
||||
}
|
||||
|
||||
C68k_Exec(&C68K_temp, 1);
|
||||
}
|
||||
|
||||
C68k_Set_Reg(&C68K, C68K_PC, old_pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
割り込み処理
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_set_irq_line(int irqline, int state)
|
||||
{
|
||||
if (irqline == IRQ_LINE_NMI)
|
||||
irqline = 7;
|
||||
|
||||
C68k_Set_IRQ(&C68K, irqline, state);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
割り込みコールバック関数設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_set_irq_callback(int (*callback)(int line))
|
||||
{
|
||||
C68k_Set_IRQ_Callback(&C68K, callback);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
レジスタ取得
|
||||
--------------------------------------------------------*/
|
||||
|
||||
UINT32 m68000_get_reg(int regnum)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
case M68K_PC: return C68k_Get_Reg(&C68K, C68K_PC);
|
||||
case M68K_USP: return C68k_Get_Reg(&C68K, C68K_USP);
|
||||
case M68K_MSP: return C68k_Get_Reg(&C68K, C68K_MSP);
|
||||
case M68K_SR: return C68k_Get_Reg(&C68K, C68K_SR);
|
||||
case M68K_D0: return C68k_Get_Reg(&C68K, C68K_D0);
|
||||
case M68K_D1: return C68k_Get_Reg(&C68K, C68K_D1);
|
||||
case M68K_D2: return C68k_Get_Reg(&C68K, C68K_D2);
|
||||
case M68K_D3: return C68k_Get_Reg(&C68K, C68K_D3);
|
||||
case M68K_D4: return C68k_Get_Reg(&C68K, C68K_D4);
|
||||
case M68K_D5: return C68k_Get_Reg(&C68K, C68K_D5);
|
||||
case M68K_D6: return C68k_Get_Reg(&C68K, C68K_D6);
|
||||
case M68K_D7: return C68k_Get_Reg(&C68K, C68K_D7);
|
||||
case M68K_A0: return C68k_Get_Reg(&C68K, C68K_A0);
|
||||
case M68K_A1: return C68k_Get_Reg(&C68K, C68K_A1);
|
||||
case M68K_A2: return C68k_Get_Reg(&C68K, C68K_A2);
|
||||
case M68K_A3: return C68k_Get_Reg(&C68K, C68K_A3);
|
||||
case M68K_A4: return C68k_Get_Reg(&C68K, C68K_A4);
|
||||
case M68K_A5: return C68k_Get_Reg(&C68K, C68K_A5);
|
||||
case M68K_A6: return C68k_Get_Reg(&C68K, C68K_A6);
|
||||
case M68K_A7: return C68k_Get_Reg(&C68K, C68K_A7);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------
|
||||
レジスタ設定
|
||||
--------------------------------------------------------*/
|
||||
|
||||
void m68000_set_reg(int regnum, UINT32 val)
|
||||
{
|
||||
switch (regnum)
|
||||
{
|
||||
case M68K_PC: C68k_Set_Reg(&C68K, C68K_PC, val); break;
|
||||
case M68K_USP: C68k_Set_Reg(&C68K, C68K_USP, val); break;
|
||||
case M68K_MSP: C68k_Set_Reg(&C68K, C68K_MSP, val); break;
|
||||
case M68K_SR: C68k_Set_Reg(&C68K, C68K_SR, val); break;
|
||||
case M68K_D0: C68k_Set_Reg(&C68K, C68K_D0, val); break;
|
||||
case M68K_D1: C68k_Set_Reg(&C68K, C68K_D1, val); break;
|
||||
case M68K_D2: C68k_Set_Reg(&C68K, C68K_D2, val); break;
|
||||
case M68K_D3: C68k_Set_Reg(&C68K, C68K_D3, val); break;
|
||||
case M68K_D4: C68k_Set_Reg(&C68K, C68K_D4, val); break;
|
||||
case M68K_D5: C68k_Set_Reg(&C68K, C68K_D5, val); break;
|
||||
case M68K_D6: C68k_Set_Reg(&C68K, C68K_D6, val); break;
|
||||
case M68K_D7: C68k_Set_Reg(&C68K, C68K_D7, val); break;
|
||||
case M68K_A0: C68k_Set_Reg(&C68K, C68K_A0, val); break;
|
||||
case M68K_A1: C68k_Set_Reg(&C68K, C68K_A1, val); break;
|
||||
case M68K_A2: C68k_Set_Reg(&C68K, C68K_A2, val); break;
|
||||
case M68K_A3: C68k_Set_Reg(&C68K, C68K_A3, val); break;
|
||||
case M68K_A4: C68k_Set_Reg(&C68K, C68K_A4, val); break;
|
||||
case M68K_A5: C68k_Set_Reg(&C68K, C68K_A5, val); break;
|
||||
case M68K_A6: C68k_Set_Reg(&C68K, C68K_A6, val); break;
|
||||
case M68K_A7: C68k_Set_Reg(&C68K, C68K_A7, val); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------
|
||||
セーブ/ロード ステート
|
||||
------------------------------------------------------*/
|
||||
|
||||
#ifdef SAVE_STATE
|
||||
|
||||
STATE_SAVE( m68000 )
|
||||
{
|
||||
int i;
|
||||
UINT32 pc = C68k_Get_Reg(&C68K, C68K_PC);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
state_save_long(&C68K.D[i], 1);
|
||||
for (i = 0; i < 8; i++)
|
||||
state_save_long(&C68K.A[i], 1);
|
||||
|
||||
state_save_long(&C68K.flag_C, 1);
|
||||
state_save_long(&C68K.flag_V, 1);
|
||||
state_save_long(&C68K.flag_Z, 1);
|
||||
state_save_long(&C68K.flag_N, 1);
|
||||
state_save_long(&C68K.flag_X, 1);
|
||||
state_save_long(&C68K.flag_I, 1);
|
||||
state_save_long(&C68K.flag_S, 1);
|
||||
state_save_long(&C68K.USP, 1);
|
||||
state_save_long(&pc, 1);
|
||||
state_save_long(&C68K.HaltState, 1);
|
||||
state_save_long(&C68K.IRQLine, 1);
|
||||
state_save_long(&C68K.IRQState, 1);
|
||||
}
|
||||
|
||||
STATE_LOAD( m68000 )
|
||||
{
|
||||
int i;
|
||||
UINT32 pc;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
state_load_long(&C68K.D[i], 1);
|
||||
for (i = 0; i < 8; i++)
|
||||
state_load_long(&C68K.A[i], 1);
|
||||
|
||||
state_load_long(&C68K.flag_C, 1);
|
||||
state_load_long(&C68K.flag_V, 1);
|
||||
state_load_long(&C68K.flag_Z, 1);
|
||||
state_load_long(&C68K.flag_N, 1);
|
||||
state_load_long(&C68K.flag_X, 1);
|
||||
state_load_long(&C68K.flag_I, 1);
|
||||
state_load_long(&C68K.flag_S, 1);
|
||||
state_load_long(&C68K.USP, 1);
|
||||
state_load_long(&pc, 1);
|
||||
state_load_long(&C68K.HaltState, 1);
|
||||
state_load_long(&C68K.IRQLine, 1);
|
||||
state_load_long(&C68K.IRQState, 1);
|
||||
|
||||
C68k_Set_Reg(&C68K, C68K_PC, pc);
|
||||
}
|
||||
|
||||
#endif /* SAVE_STATE */
|
||||
@@ -0,0 +1,45 @@
|
||||
/******************************************************************************
|
||||
|
||||
m68000.c
|
||||
|
||||
M68000 CPUインタフェース関数
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef M68000_H
|
||||
#define M68000_H
|
||||
|
||||
#include "c68k.h"
|
||||
|
||||
// MAME互換のレジスタ番号 (一部未対応)
|
||||
enum
|
||||
{
|
||||
/* NOTE: M68K_SP fetches the current SP, be it USP, ISP, or MSP */
|
||||
M68K_PC=1, M68K_SP, M68K_ISP, M68K_USP, M68K_MSP, M68K_SR, M68K_VBR,
|
||||
M68K_SFC, M68K_DFC, M68K_CACR, M68K_CAAR, M68K_PREF_ADDR, M68K_PREF_DATA,
|
||||
M68K_D0, M68K_D1, M68K_D2, M68K_D3, M68K_D4, M68K_D5, M68K_D6, M68K_D7,
|
||||
M68K_A0, M68K_A1, M68K_A2, M68K_A3, M68K_A4, M68K_A5, M68K_A6, M68K_A7
|
||||
};
|
||||
|
||||
void m68000_init(void);
|
||||
void m68000_reset(void);
|
||||
void m68000_exit(void);
|
||||
int m68000_execute(int cycles);
|
||||
#if (EMU_SYSTEM == NCDZ)
|
||||
void m68000_execute2(UINT32 start_pc, UINT32 break_point);
|
||||
#endif
|
||||
void m68000_set_irq_line(int irqline, int state);
|
||||
void m68000_set_irq_callback(int (*callback)(int irqline));
|
||||
UINT32 m68000_get_reg(int regnum);
|
||||
void m68000_set_reg(int regnum, UINT32 val);
|
||||
|
||||
#if (EMU_SYSTEM == CPS2)
|
||||
void m68000_set_encrypted_range(UINT32 start, UINT32 end, void *decrypted_rom);
|
||||
#endif
|
||||
|
||||
#ifdef SAVE_STATE
|
||||
STATE_SAVE( m68000 );
|
||||
STATE_LOAD( m68000 );
|
||||
#endif
|
||||
|
||||
#endif /* M68000_H */
|
||||
+13
-9
@@ -35,6 +35,10 @@
|
||||
|
||||
#include "dosio.h"
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
extern char slash;
|
||||
#endif
|
||||
|
||||
static char curpath[MAX_PATH+32] = "";
|
||||
static LPSTR curfilep = curpath;
|
||||
|
||||
@@ -260,7 +264,7 @@ getFileName(LPSTR filename)
|
||||
LPSTR p, q;
|
||||
|
||||
for (p = q = filename; *p != '\0'; p++)
|
||||
if (*p == '/')
|
||||
if (*p == slash/*'/'*/)
|
||||
q = p + 1;
|
||||
return q;
|
||||
}
|
||||
@@ -271,7 +275,7 @@ cutFileName(LPSTR filename)
|
||||
LPSTR p, q;
|
||||
|
||||
for (p = filename, q = NULL; *p != '\0'; p++)
|
||||
if (*p == '/')
|
||||
if (*p == slash/*'/'*/)
|
||||
q = p + 1;
|
||||
if (q != NULL)
|
||||
*q = '\0';
|
||||
@@ -375,7 +379,7 @@ cutyen(LPSTR str)
|
||||
{
|
||||
int pos = strlen(str) - 1;
|
||||
|
||||
if ((pos > 0) && (str[pos] == '/'))
|
||||
if ((pos > 0) && (str[pos] == slash/*'/'*/))
|
||||
str[pos] = '\0';
|
||||
}
|
||||
|
||||
@@ -385,12 +389,12 @@ plusyen(LPSTR str, int len)
|
||||
int pos = strlen(str);
|
||||
|
||||
if (pos) {
|
||||
if (str[pos-1] == '/')
|
||||
if (str[pos-1] == slash/*'/'*/)
|
||||
return;
|
||||
}
|
||||
if ((pos + 2) >= len)
|
||||
return;
|
||||
str[pos++] = '/';
|
||||
str[pos++] = slash/*'/'*/;
|
||||
str[pos] = '\0';
|
||||
}
|
||||
|
||||
@@ -404,7 +408,7 @@ fname_mix(LPSTR str, LPSTR mix, int size)
|
||||
char check;
|
||||
|
||||
cutFileName(str);
|
||||
if (mix[0] == '/')
|
||||
if (mix[0] == slash/*'/'*/)
|
||||
str[0] = '\0';
|
||||
|
||||
len = strlen(str);
|
||||
@@ -417,12 +421,12 @@ fname_mix(LPSTR str, LPSTR mix, int size)
|
||||
|
||||
if (c == check) {
|
||||
/* current dir */
|
||||
if (mix[0] == '/') {
|
||||
if (mix[0] == slash/*'/'*/) {
|
||||
mix++;
|
||||
continue;
|
||||
}
|
||||
/* parent dir */
|
||||
if (mix[0] == '.' && mix[1] == '/') {
|
||||
if (mix[0] == '.' && mix[1] == slash/*'/'*/) {
|
||||
mix += 2;
|
||||
cutyen(str);
|
||||
cutFileName(str);
|
||||
@@ -431,7 +435,7 @@ fname_mix(LPSTR str, LPSTR mix, int size)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c == '/')
|
||||
if (c == slash/*'/'*/)
|
||||
check = '.';
|
||||
else
|
||||
check = 0;
|
||||
|
||||
@@ -157,6 +157,9 @@ void fname_mix(LPSTR str, LPSTR mix, int size);
|
||||
#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
|
||||
#define DD_YEAR_SHIFT 9
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef unsigned int u_int;
|
||||
#endif
|
||||
void unix2dostime(time_t t, unsigned short *ddp, unsigned short *dtp, unsigned char *dhp);
|
||||
void dos2unixtime(u_int dd, u_int dt, u_int dh, time_t *tp);
|
||||
|
||||
|
||||
+2
-2
@@ -60,14 +60,14 @@ PostQuitMessage(int m)
|
||||
|
||||
exit(m);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
DWORD WINAPI
|
||||
GetLastError(VOID)
|
||||
{
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
BOOL WINAPI
|
||||
SetEndOfFile(HANDLE hFile)
|
||||
{
|
||||
|
||||
+8
-5
@@ -69,7 +69,10 @@ enum {
|
||||
HTYPE_CONSOLE,
|
||||
HTYPE_KEY,
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef unsigned int u_int;
|
||||
#define bzero(s,d) memset(s,1,d)
|
||||
#endif
|
||||
struct internal_handle {
|
||||
void *p;
|
||||
u_int flags;
|
||||
@@ -107,7 +110,7 @@ struct internal_file {
|
||||
#define DPRF(arg)
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
DWORD WINAPI
|
||||
GetTickCount(void)
|
||||
{
|
||||
@@ -116,7 +119,7 @@ GetTickCount(void)
|
||||
gettimeofday(&tv, 0);
|
||||
return tv.tv_usec / 1000 + tv.tv_sec * 1000;
|
||||
}
|
||||
|
||||
#endif
|
||||
BOOL WINAPI
|
||||
ReadFile(HANDLE h, PVOID buf, DWORD len, PDWORD lp, LPOVERLAPPED lpov)
|
||||
{
|
||||
@@ -213,7 +216,7 @@ SetFilePointer(HANDLE h, LONG pos, PLONG newposh, DWORD whence)
|
||||
newpos = lseek(fd, pos, whence);
|
||||
return newpos;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
BOOL WINAPI
|
||||
CloseHandle(HANDLE h)
|
||||
{
|
||||
@@ -233,7 +236,7 @@ CloseHandle(HANDLE h)
|
||||
LocalFree(h);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
DWORD WINAPI
|
||||
GetFileAttributes(LPCSTR path)
|
||||
{
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ void Mouse_Init(void)
|
||||
// ----------------------------------
|
||||
void Mouse_Event(int param, float dx, float dy)
|
||||
{
|
||||
printf("ME(): %f %f\n", dx, dy);
|
||||
//printf("ME(): %f %f\n", dx, dy);
|
||||
|
||||
if (MouseSW) {
|
||||
switch (param) {
|
||||
|
||||
+16
-1
@@ -131,6 +131,12 @@ static BYTE solveBOOL(char *str) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
extern char retro_system_conf[512];
|
||||
extern char slash;
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
set_modulepath(char *path, size_t len)
|
||||
{
|
||||
@@ -191,14 +197,23 @@ set_dir:
|
||||
sprintf(winx68k_ini, "/var/mobile/px68k/config");
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
puts("Libretro...");
|
||||
sprintf(path,retro_system_conf);
|
||||
sprintf(winx68k_ini, "%s%cconfig",retro_system_conf,slash);
|
||||
return 0;
|
||||
#endif
|
||||
homepath = getenv("HOME");
|
||||
if (homepath == 0)
|
||||
homepath = ".";
|
||||
|
||||
snprintf(path, len, "%s/%s", homepath, ".keropi");
|
||||
if (stat(path, &sb) < 0) {
|
||||
#ifdef _WIN32
|
||||
if (mkdir(path) < 0) {
|
||||
#else
|
||||
if (mkdir(path, 0700) < 0) {
|
||||
#endif
|
||||
perror(path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+38
-11
@@ -47,7 +47,10 @@
|
||||
#include "tvram.h"
|
||||
#include "joystick.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
extern uint16_t *videoBuffer;
|
||||
extern SDL_Surface *mysdl_surface;
|
||||
#endif
|
||||
#if 0
|
||||
#include "../icons/keropi.xpm"
|
||||
#endif
|
||||
@@ -64,11 +67,11 @@ WORD *ScrBuf = 0;
|
||||
WORD *menu_buffer;
|
||||
WORD *kbd_buffer;
|
||||
#endif
|
||||
|
||||
#ifndef __LIBRETRO__
|
||||
#ifdef USE_SDLGFX
|
||||
SDL_Surface *sdl_rgbsurface;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
int Draw_Opaque;
|
||||
int FullScreenFlag = 0;
|
||||
extern BYTE Draw_RedrawAllFlag;
|
||||
@@ -401,7 +404,7 @@ int WinDraw_Init(void)
|
||||
|
||||
draw_kbd_to_tex();
|
||||
#else
|
||||
|
||||
#ifndef __LIBRETRO__
|
||||
#ifdef USE_SDLGFX
|
||||
sdl_rgbsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 800, 600, 16, WinDraw_Pal16R, WinDraw_Pal16G, WinDraw_Pal16B, 0);
|
||||
|
||||
@@ -412,6 +415,8 @@ int WinDraw_Init(void)
|
||||
ScrBuf = sdl_rgbsurface->pixels;
|
||||
|
||||
printf("drawbuf: 0x%x, ScrBuf: 0x%x\n", sdl_surface->pixels, ScrBuf);
|
||||
printf("drawbuf: 0x%x, ScrBuf: 0x%x\n", mysdl_surface->pixels);
|
||||
#endif
|
||||
#else
|
||||
ScrBuf = malloc(800 * 600 * 2);
|
||||
#endif
|
||||
@@ -476,7 +481,7 @@ void draw_all_buttons(GLfloat *tex, GLfloat *ver, GLfloat scale, int is_menu)
|
||||
}
|
||||
}
|
||||
#endif // USE_OGLES11
|
||||
|
||||
extern int retrow,retroh,CHANGEAV;
|
||||
void FASTCALL
|
||||
WinDraw_Draw(void)
|
||||
{
|
||||
@@ -486,12 +491,17 @@ WinDraw_Draw(void)
|
||||
if (oldtextx != TextDotX) {
|
||||
oldtextx = TextDotX;
|
||||
p6logd("TextDotX: %d\n", TextDotX);
|
||||
CHANGEAV=1;
|
||||
}
|
||||
if (oldtexty != TextDotY) {
|
||||
oldtexty = TextDotY;
|
||||
p6logd("TextDotY: %d\n", TextDotY);
|
||||
CHANGEAV=1;
|
||||
}
|
||||
|
||||
if(CHANGEAV==1){
|
||||
retrow=TextDotX;
|
||||
retroh=TextDotY;
|
||||
}
|
||||
#if defined(USE_OGLES11)
|
||||
GLfloat texture_coordinates[8];
|
||||
GLfloat vertices[8];
|
||||
@@ -651,13 +661,16 @@ WinDraw_Draw(void)
|
||||
sceGuSwapBuffers();
|
||||
|
||||
#else // OpenGL ES 未使用
|
||||
|
||||
#ifndef __LIBRETRO__
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
sdl_surface = SDL_GetWindowSurface(sdl_window);
|
||||
#else
|
||||
sdl_surface = SDL_GetVideoSurface();
|
||||
#endif
|
||||
|
||||
#else
|
||||
sdl_surface = mysdl_surface;
|
||||
#endif
|
||||
#ifndef __LIBRETRO__
|
||||
#ifdef USE_SDLGFX
|
||||
SDL_Surface *roto_surface = NULL;
|
||||
int ret;
|
||||
@@ -667,10 +680,11 @@ WinDraw_Draw(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextDotX <= 512) {
|
||||
if(0){//if (TextDotX <= 512) {
|
||||
roto_surface = rotozoomSurfaceXY(sdl_rgbsurface, 0.0, 512.0*1.33333/TextDotX, 512.0/TextDotY, 0);
|
||||
}
|
||||
if (roto_surface) {
|
||||
|
||||
if(0){//if (roto_surface) {
|
||||
ret = SDL_BlitSurface(roto_surface, NULL, sdl_surface, NULL);
|
||||
SDL_FreeSurface(roto_surface);
|
||||
} else {
|
||||
@@ -679,6 +693,7 @@ WinDraw_Draw(void)
|
||||
if (ret < 0) {
|
||||
printf("SDL_BlitSurface() failed %d\n", ret);
|
||||
}
|
||||
//#endif
|
||||
#else
|
||||
int x, y, Bpp;
|
||||
// WORD c, *p, *p2, dummy, *dst16;
|
||||
@@ -735,11 +750,15 @@ WinDraw_Draw(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_UpdateWindowSurface(sdl_window);
|
||||
#else
|
||||
#ifdef __LIBRETRO__
|
||||
videoBuffer=(unsigned short int *)ScrBuf;//sdl_surface->pixels;
|
||||
#else
|
||||
SDL_UpdateRect(sdl_surface, 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT);
|
||||
#endif //libretro
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1935,9 +1954,13 @@ void WinDraw_DrawMenu(int menu_state, int mkey_pos, int mkey_y, int *mval_y)
|
||||
sdl_surface = SDL_GetWindowSurface(sdl_window);
|
||||
SDL_BlitSurface(menu_surface, NULL, sdl_surface, NULL);
|
||||
SDL_UpdateWindowSurface(sdl_window);
|
||||
#else
|
||||
#ifdef __LIBRETRO__
|
||||
videoBuffer=(unsigned short int *)menu_surface->pixels;//sdl_surface->pixels;
|
||||
#else
|
||||
SDL_UpdateRect(menu_surface, 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1991,9 +2014,13 @@ void WinDraw_DrawMenufile(struct menu_flist *mfl)
|
||||
sdl_surface = SDL_GetWindowSurface(sdl_window);
|
||||
SDL_BlitSurface(menu_surface, NULL, sdl_surface, NULL);
|
||||
SDL_UpdateWindowSurface(sdl_window);
|
||||
#else
|
||||
#ifdef __LIBRETRO__
|
||||
videoBuffer=(unsigned short int *)menu_surface->pixels;//sdl_surface->pixels;
|
||||
#else
|
||||
SDL_UpdateRect(menu_surface, 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
+27
-3
@@ -88,7 +88,7 @@ extern short timertrace;
|
||||
char filepath[MAX_PATH] = ".";
|
||||
int fddblink = 0;
|
||||
int fddblinkcount = 0;
|
||||
int hddtrace = 0;
|
||||
int hddtrace = 1;//0;
|
||||
extern int dmatrace;
|
||||
|
||||
DWORD LastClock[4] = {0, 0, 0, 0};
|
||||
@@ -241,7 +241,17 @@ WinUI_Init(void)
|
||||
#elif TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR == 0
|
||||
#define CUR_DIR_STR "/var/mobile/px68k/"
|
||||
#else
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
#ifdef _WIN32
|
||||
#define CUR_DIR_STR "c:\\"
|
||||
#else
|
||||
#define CUR_DIR_STR "/"
|
||||
#endif
|
||||
#else
|
||||
#define CUR_DIR_STR "./"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
strcpy(cur_dir_str, CUR_DIR_STR);
|
||||
@@ -511,6 +521,9 @@ static void menu_joykey(int v)
|
||||
Config.JoyKey = v;
|
||||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
extern char slash;
|
||||
#endif
|
||||
// ex. ./hoge/.. -> ./
|
||||
// ( ./ ---down hoge dir--> ./hoge ---up hoge dir--> ./hoge/.. )
|
||||
static void shortcut_dir(int drv)
|
||||
@@ -522,17 +535,24 @@ static void shortcut_dir(int drv)
|
||||
len = strlen(mfl.dir[drv]);
|
||||
p = mfl.dir[drv] + len - 2;
|
||||
for (i = len - 2; i >= 0; i--) {
|
||||
if (*p == '/') {
|
||||
if (*p == slash/*'/'*/) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
p--;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (found && strcmp(p, "\\..\\")) {
|
||||
#else
|
||||
if (found && strcmp(p, "/../")) {
|
||||
#endif
|
||||
*(p + 1) = '\0';
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
strcat(mfl.dir[drv], "..\\");
|
||||
#else
|
||||
strcat(mfl.dir[drv], "../");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,7 +744,11 @@ int WinUI_Menu(int first)
|
||||
shortcut_dir(drv);
|
||||
} else {
|
||||
strcat(mfl.dir[drv], mfl.name[y]);
|
||||
#ifdef _WIN32
|
||||
strcat(mfl.dir[drv], "\\");
|
||||
#else
|
||||
strcat(mfl.dir[drv], "/");
|
||||
#endif
|
||||
}
|
||||
menu_func[mkey_y].func(0);
|
||||
mfile_redraw = 1;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+61
-54
@@ -17,7 +17,7 @@ extern "C" {
|
||||
#include "winx68k.h"
|
||||
#include "windraw.h"
|
||||
#include "winui.h"
|
||||
#include "../x68k/m68000.h" // xxx これはいずれいらなくなるはず
|
||||
#include "../x68k/m68000.h" // xxx €³€ì€Ï€€€º€ì€€€é€Ê€¯€Ê€ë€Ï€º
|
||||
#include "../m68000/m68000.h"
|
||||
#include "../x68k/memory.h"
|
||||
#include "mfp.h"
|
||||
@@ -113,21 +113,21 @@ void
|
||||
WinX68k_SCSICheck(void)
|
||||
{
|
||||
static const BYTE SCSIIMG[] = {
|
||||
0x00, 0xfc, 0x00, 0x14, // $fc0000 SCSI起動用のエントリアドレス
|
||||
0x00, 0xfc, 0x00, 0x16, // $fc0004 IOCSベクタ設定のエントリアドレス(必ず"Human"の8バイト前)
|
||||
0x00, 0xfc, 0x00, 0x14, // $fc0000 SCSIµ¯Æ°ÍрΥš¥ó¥È¥ê¥¢¥É¥ì¥¹
|
||||
0x00, 0xfc, 0x00, 0x16, // $fc0004 IOCS¥Ù¥¯¥¿ÀßÄê€Î¥š¥ó¥È¥ê¥¢¥É¥ì¥¹(ɬ€º"Human"€Î8¥Ð¥€¥ÈÁ°)
|
||||
0x00, 0x00, 0x00, 0x00, // $fc0008 ?
|
||||
0x48, 0x75, 0x6d, 0x61, // $fc000c ↓
|
||||
0x6e, 0x36, 0x38, 0x6b, // $fc0010 ID "Human68k" (必ず起動エントリポイントの直前)
|
||||
0x4e, 0x75, // $fc0014 "rts" (起動エントリポイント)
|
||||
0x23, 0xfc, 0x00, 0xfc, 0x00, 0x2a, // $fc0016 ↓ (IOCSベクタ設定エントリポイント)
|
||||
0x48, 0x75, 0x6d, 0x61, // $fc000c ¢
|
||||
0x6e, 0x36, 0x38, 0x6b, // $fc0010 ID "Human68k" (ɬ€ºµ¯Æ°¥š¥ó¥È¥ê¥Ý¥€¥ó¥È€ÎÄŸÁ°)
|
||||
0x4e, 0x75, // $fc0014 "rts" (µ¯Æ°¥š¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x23, 0xfc, 0x00, 0xfc, 0x00, 0x2a, // $fc0016 ¢ (IOCS¥Ù¥¯¥¿ÀßÄ꥚¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x00, 0x00, 0x07, 0xd4, // $fc001c "move.l #$fc002a, $7d4.l"
|
||||
0x74, 0xff, // $fc0020 "moveq #-1, d2"
|
||||
0x4e, 0x75, // $fc0022 "rts"
|
||||
// 0x53, 0x43, 0x53, 0x49, 0x49, 0x4e, // $fc0024 ID "SCSIIN"
|
||||
// 内蔵SCSIをONにすると、SASIは自動的にOFFになっちゃうらしい…
|
||||
// よって、IDはマッチしないようにしておく…
|
||||
// Æâ¢SCSI€òON€Ë€¹€ë€È¡¢SASI€ÏŒ«Æ°Åª€ËOFF€Ë€Ê€Ã€Á€ã€Š€é€·€€¡Ä
|
||||
// €è€Ã€Æ¡¢ID€Ï¥Þ¥Ã¥Á€·€Ê€€€è€Š€Ë€·€Æ€ª€¯¡Ä
|
||||
0x44, 0x55, 0x4d, 0x4d, 0x59, 0x20, // $fc0024 ID "DUMMY "
|
||||
0x70, 0xff, // $fc002a "moveq #-1, d0" (SCSI IOCSコールエントリポイント)
|
||||
0x70, 0xff, // $fc002a "moveq #-1, d0" (SCSI IOCS¥³¡Œ¥ë¥š¥ó¥È¥ê¥Ý¥€¥ó¥È)
|
||||
0x4e, 0x75, // $fc002c "rts"
|
||||
};
|
||||
|
||||
@@ -140,7 +140,7 @@ WinX68k_SCSICheck(void)
|
||||
|
||||
scsi = 0;
|
||||
for (i = 0x30600; i < 0x30c00; i += 2) {
|
||||
#if 0 // 4の倍数ではない偶数アドレスからの4バイト長アクセスはMIPSには無理
|
||||
#if 0 // 4€ÎÇÜ¿ô€Ç€Ï€Ê€€¶ö¿ô¥¢¥É¥ì¥¹€«€é€Î4¥Ð¥€¥ÈĹ¥¢¥¯¥»¥¹€ÏMIPS€Ë€Ï̵Íý
|
||||
p = (DWORD *)(&IPL[i]);
|
||||
if (*p == 0x0000fc00)
|
||||
scsi = 1;
|
||||
@@ -155,14 +155,14 @@ WinX68k_SCSICheck(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
// SCSIモデルのとき
|
||||
// SCSI¥â¥Ç¥ë€Î€È€
|
||||
if (scsi) {
|
||||
ZeroMemory(IPL, 0x2000); // 本体は8kb
|
||||
memset(&IPL[0x2000], 0xff, 0x1e000); // 残りは0xff
|
||||
memcpy(IPL, SCSIIMG, sizeof(SCSIIMG)); // インチキSCSI BIOS
|
||||
ZeroMemory(IPL, 0x2000); // ËÜÂ΀Ï8kb
|
||||
memset(&IPL[0x2000], 0xff, 0x1e000); // »Ä€ê€Ï0xff
|
||||
memcpy(IPL, SCSIIMG, sizeof(SCSIIMG)); // ¥€¥ó¥Á¥SCSI BIOS
|
||||
// Memory_SetSCSIMode();
|
||||
} else {
|
||||
// SASIモデルはIPLがそのまま見える
|
||||
// SASI¥â¥Ç¥ë€ÏIPL€¬€œ€Î€Þ€Þž«€š€ë
|
||||
memcpy(IPL, &IPL[0x20000], 0x20000);
|
||||
}
|
||||
}
|
||||
@@ -184,14 +184,14 @@ WinX68k_LoadROMs(void)
|
||||
}
|
||||
|
||||
if (fp == 0) {
|
||||
Error("BIOS ROM イメージが見つかりません.");
|
||||
Error("BIOS ROM ¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
File_Read(fp, &IPL[0x20000], 0x20000);
|
||||
File_Close(fp);
|
||||
|
||||
WinX68k_SCSICheck(); // SCSI IPLなら、$fc0000~にSCSI BIOSを置く
|
||||
WinX68k_SCSICheck(); // SCSI IPL€Ê€é¡¢$fc0000¡Á€ËSCSI BIOS€òÃÖ€¯
|
||||
|
||||
for (i = 0; i < 0x40000; i += 2) {
|
||||
tmp = IPL[i];
|
||||
@@ -201,19 +201,19 @@ WinX68k_LoadROMs(void)
|
||||
|
||||
fp = File_OpenCurDir((char *)FONTFILE);
|
||||
if (fp == 0) {
|
||||
// cgrom.tmpがある?
|
||||
// cgrom.tmp€¬€¢€ë¡©
|
||||
fp = File_OpenCurDir((char *)FONTFILETMP);
|
||||
if (fp == 0) {
|
||||
#if 1
|
||||
// フォント生成 XXX
|
||||
printf("フォントROMイメージが見つかりません\n");
|
||||
// ¥Õ¥©¥ó¥ÈÀžÀ® XXX
|
||||
printf("¥Õ¥©¥ó¥ÈROM¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó\n");
|
||||
return FALSE;
|
||||
#else
|
||||
MessageBox(hWndMain,
|
||||
"フォントROMイメージが見つかりません.\nWindowsフォントから新規に作成します.",
|
||||
"けろぴーのメッセージ", MB_ICONWARNING | MB_OK);
|
||||
"¥Õ¥©¥ó¥ÈROM¥€¥á¡Œ¥ž€¬ž«€Ä€«€ê€Þ€»€ó.\nWindows¥Õ¥©¥ó¥È€«€é¿·µ¬€ËºîÀ®€·€Þ€¹.",
|
||||
"€±€í€Ô¡Œ€Î¥á¥Ã¥»¡Œ¥ž", MB_ICONWARNING | MB_OK);
|
||||
SSTP_SendMes(SSTPMES_MAKEFONT);
|
||||
make_cgromdat(FONT, FALSE, "MS ゴシック", "MS 明朝");
|
||||
make_cgromdat(FONT, FALSE, "£Í£Ó ¥Ž¥·¥Ã¥¯", "£Í£Ó ÌÀÄ«");
|
||||
//WinX68k_MakeFont();
|
||||
//DialogBox(hInst, MAKEINTRESOURCE(IDD_PROGBAR),
|
||||
// hWndMain, (DLGPROC)MakeFontProc);
|
||||
@@ -240,9 +240,12 @@ WinX68k_Reset(void)
|
||||
OPM_Reset();
|
||||
|
||||
C68k_Reset(&C68K);
|
||||
/*
|
||||
C68k_Set_Reg(&C68K, C68K_A7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]);
|
||||
C68k_Set_Reg(&C68K, C68K_PC, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]);
|
||||
|
||||
*/
|
||||
C68k_Set_AReg(&C68K, 7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]);
|
||||
C68k_Set_PC(&C68K, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]);
|
||||
Memory_Init();
|
||||
CRTC_Init();
|
||||
DMA_Init();
|
||||
@@ -263,7 +266,7 @@ WinX68k_Reset(void)
|
||||
MIDI_Init();
|
||||
//WinDrv_Init();
|
||||
|
||||
C68K.ICount = 0;
|
||||
//C68K.ICount = 0;
|
||||
m68000_ICountBk = 0;
|
||||
ICount = 0;
|
||||
|
||||
@@ -318,7 +321,7 @@ WinX68k_Cleanup(void)
|
||||
|
||||
#define CLOCK_SLICE 200
|
||||
// -----------------------------------------------------------------------------------
|
||||
// コアのめいんるーぷ
|
||||
// ¥³¥¢€Î€á€€€ó€ë¡Œ€×
|
||||
// -----------------------------------------------------------------------------------
|
||||
void WinX68k_Exec(void)
|
||||
{
|
||||
@@ -364,7 +367,7 @@ void WinX68k_Exec(void)
|
||||
|
||||
do {
|
||||
int m, n = (ICount>CLOCK_SLICE)?CLOCK_SLICE:ICount;
|
||||
C68K.ICount = m68000_ICountBk = 0; // 割り込み発生前に与えておかないとダメ(CARAT)
|
||||
// C68K.ICount = m68000_ICountBk = 0; // ³ä€ê¹þ€ßȯÀžÁ°€ËÍ¿€š€Æ€ª€«€Ê€€€È¥À¥á¡ÊCARAT¡Ë
|
||||
|
||||
if ( hsync ) {
|
||||
hsync = 0;
|
||||
@@ -381,9 +384,9 @@ void WinX68k_Exec(void)
|
||||
MFP_Int(9);
|
||||
} else {
|
||||
if ( CRTC_VEND>=VLINE_TOTAL ) {
|
||||
if ( (long)vline==(CRTC_VEND-VLINE_TOTAL) ) MFP_Int(9); // エキサイティングアワーとか(TOTAL<VEND)
|
||||
if ( (long)vline==(CRTC_VEND-VLINE_TOTAL) ) MFP_Int(9); // ¥š¥¥µ¥€¥Æ¥£¥ó¥°¥¢¥ï¡Œ€È€«¡ÊTOTAL<VEND¡Ë
|
||||
} else {
|
||||
if ( (long)vline==(VLINE_TOTAL-1) ) MFP_Int(9); // クレイジークライマーはコレでないとダメ?
|
||||
if ( (long)vline==(VLINE_TOTAL-1) ) MFP_Int(9); // ¥¯¥ì¥€¥ž¡Œ¥¯¥é¥€¥Þ¡Œ€Ï¥³¥ì€Ç€Ê€€€È¥À¥á¡©
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,13 +413,15 @@ void WinX68k_Exec(void)
|
||||
if (/*fdctrace&&*/(oldpc != C68k_Get_Reg(&C68K, C68K_PC)))
|
||||
{
|
||||
// //tracing--;
|
||||
fprintf(fp, "D0:%08X D1:%08X D2:%08X D3:%08X D4:%08X D5:%08X D6:%08X D7:%08X CR:%04X\n", C68K.D[0], C68K.D[1], C68K.D[2], C68K.D[3], C68K.D[4], C68K.D[5], C68K.D[6], C68K.D[7], 0/* xxx とりあえず0 C68K.ccr */);
|
||||
fprintf(fp, "D0:%08X D1:%08X D2:%08X D3:%08X D4:%08X D5:%08X D6:%08X D7:%08X CR:%04X\n", C68K.D[0], C68K.D[1], C68K.D[2], C68K.D[3], C68K.D[4], C68K.D[5], C68K.D[6], C68K.D[7], 0/* xxx €È€ê€¢€š€º0 C68K.ccr */);
|
||||
fprintf(fp, "A0:%08X A1:%08X A2:%08X A3:%08X A4:%08X A5:%08X A6:%08X A7:%08X SR:%04X\n", C68K.A[0], C68K.A[1], C68K.A[2], C68K.A[3], C68K.A[4], C68K.A[5], C68K.A[6], C68K.A[7], C68k_Get_Reg(&C68K, C68K_SR) >> 8/* regs.sr_high*/);
|
||||
fprintf(fp, "<%04X> (%08X ->) %08X : %s\n", Memory_ReadW(C68k_Get_Reg(&C68K, C68K_PC)), oldpc, C68k_Get_Reg(&C68K, C68K_PC), buf);
|
||||
}
|
||||
oldpc = C68k_Get_Reg(&C68K, C68K_PC);
|
||||
C68K.ICount = 1;
|
||||
C68k_Exec(&C68K, C68K.ICount);
|
||||
// C68K.ICount = 1;
|
||||
// C68k_Exec(&C68K, C68K.ICount);
|
||||
// C68k_Exec(&C68K, 0);
|
||||
C68k_Exec(&C68K, 1);
|
||||
}
|
||||
fclose(fp);
|
||||
usedclk = clk_line = HSYNC_CLK;
|
||||
@@ -425,16 +430,18 @@ void WinX68k_Exec(void)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
C68K.ICount = n;
|
||||
C68k_Exec(&C68K, C68K.ICount);
|
||||
m = (n-C68K.ICount-m68000_ICountBk); // 経過クロック数
|
||||
// C68K.ICount = n;
|
||||
// C68k_Exec(&C68K, C68K.ICount);
|
||||
C68k_Exec(&C68K, n);
|
||||
// m = (n-C68K.ICount-m68000_ICountBk); // ·Ð²á¥¯¥í¥Ã¥¯¿ô
|
||||
m = (n-m68000_ICountBk); // 経過クロック数
|
||||
ClkUsed += m*10;
|
||||
usedclk = ClkUsed/clkdiv;
|
||||
clk_line += usedclk;
|
||||
ClkUsed -= usedclk*clkdiv;
|
||||
ICount -= m;
|
||||
clk_count += m;
|
||||
C68K.ICount = m68000_ICountBk = 0;
|
||||
// C68K.ICount = m68000_ICountBk = 0;
|
||||
}
|
||||
|
||||
MFP_Timer(usedclk);
|
||||
@@ -450,11 +457,11 @@ void WinX68k_Exec(void)
|
||||
if ( (MFP[MFP_AER]&0x40)&&(vline==CRTC_IntLine) )
|
||||
MFP_Int(1);
|
||||
if ( (!DispFrame)&&(vline>=CRTC_VSTART)&&(vline<CRTC_VEND) ) {
|
||||
if ( CRTC_VStep==1 ) { // HighReso 256dot(2度読み)
|
||||
if ( CRTC_VStep==1 ) { // HighReso 256dot¡Ê2ÅÙÆÉ€ß¡Ë
|
||||
if ( vline%2 )
|
||||
WinDraw_DrawLine();
|
||||
} else if ( CRTC_VStep==4 ) { // LowReso 512dot
|
||||
WinDraw_DrawLine(); // 1走査線で2回描く(インターレース)
|
||||
WinDraw_DrawLine(); // 1ÁöººÀþ€Ç2²óÉÁ€¯¡Ê¥€¥ó¥¿¡Œ¥ì¡Œ¥¹¡Ë
|
||||
VLINE++;
|
||||
WinDraw_DrawLine();
|
||||
} else { // High 512dot / Low 256dot
|
||||
@@ -487,12 +494,12 @@ void WinX68k_Exec(void)
|
||||
}
|
||||
} while ( vline<VLINE_TOTAL );
|
||||
|
||||
if ( CRTC_Mode&2 ) { // FastClrビットの調整(PITAPAT)
|
||||
if ( CRTC_FastClr ) { // FastClr=1 且つ CRTC_Mode&2 なら 終了
|
||||
if ( CRTC_Mode&2 ) { // FastClr¥Ó¥Ã¥È€ÎÄŽÀ°¡ÊPITAPAT¡Ë
|
||||
if ( CRTC_FastClr ) { // FastClr=1 ³î€Ä CRTC_Mode&2 €Ê€é œªÎ»
|
||||
CRTC_FastClr--;
|
||||
if ( !CRTC_FastClr )
|
||||
CRTC_Mode &= 0xfd;
|
||||
} else { // FastClr開始
|
||||
} else { // FastClr³«»Ï
|
||||
if ( CRTC_Regs[0x29]&0x10 )
|
||||
CRTC_FastClr = 1;
|
||||
else
|
||||
@@ -645,7 +652,7 @@ int main(int argc, char *argv[])
|
||||
SDL_DisplayMode sdl_dispmode;
|
||||
SDL_GetCurrentDisplayMode(0, &sdl_dispmode);
|
||||
p6logd("width: %d height: %d", sdl_dispmode.w, sdl_dispmode.h);
|
||||
// ナビゲーションバーを除くアプリが触れる画面
|
||||
// ¥Ê¥Ó¥²¡Œ¥·¥ç¥ó¥Ð¡Œ€òœü€¯¥¢¥×¥ê€¬¿š€ì€ë²èÌÌ
|
||||
realdisp_w = sdl_dispmode.w, realdisp_h = sdl_dispmode.h;
|
||||
|
||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 1 );
|
||||
@@ -656,7 +663,7 @@ int main(int argc, char *argv[])
|
||||
#if TARGET_OS_IPHONE
|
||||
sdl_window = SDL_CreateWindow(APPNAME" SDL", 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS);
|
||||
#else
|
||||
// for Android: window sizeの指定は関係なくフルスクリーンになるみたい
|
||||
// for Android: window size€Î»ØÄê€ÏŽØ·ž€Ê€¯¥Õ¥ë¥¹¥¯¥ê¡Œ¥ó€Ë€Ê€ë€ß€¿€€
|
||||
sdl_window = SDL_CreateWindow(APPNAME" SDL", 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN);
|
||||
#endif
|
||||
#else
|
||||
@@ -676,10 +683,10 @@ int main(int argc, char *argv[])
|
||||
glEnable(GL_BLEND);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glViewport(0, 0, 800, 600); //ここを増やさないとOpenGLの画面はせまい
|
||||
//glViewport(0, 0, 800, 600); //€³€³€òÁý€ä€µ€Ê€€€ÈOpenGL€Î²èÌ̀π»€Þ€€
|
||||
glViewport(0, 0, sdl_dispmode.w, sdl_dispmode.h);
|
||||
// スマホやタブの実画面に関係なくOpenGLの描画領域を800x600とする。
|
||||
// 800x600にした意味は特にない。
|
||||
// ¥¹¥Þ¥Û€ä¥¿¥Ö€ÎŒÂ²èÌ̀ˎطž€Ê€¯OpenGL€ÎÉÁ²èÎΰè€ò800x600€È€¹€ë¡£
|
||||
// 800x600€Ë€·€¿°ÕÌ£€ÏÆÃ€Ë€Ê€€¡£
|
||||
glOrthof(0, 800, 600, 0, -1, 1);
|
||||
// glOrthof(0, 1024, 0, 1024, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -714,7 +721,7 @@ int main(int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
|
||||
Keyboard_Init(); //WinDraw_Init()前に移動
|
||||
Keyboard_Init(); //WinDraw_Init()Á°€Ë°Üư
|
||||
|
||||
if (!WinDraw_Init()) {
|
||||
WinDraw_Cleanup();
|
||||
@@ -745,7 +752,7 @@ int main(int argc, char *argv[])
|
||||
Timer_Init();
|
||||
|
||||
MIDI_Init();
|
||||
MIDI_SetMimpiMap(Config.ToneMapFile); // 音色設定ファイル使用反映
|
||||
MIDI_SetMimpiMap(Config.ToneMapFile); // ²»¿§ÀßÄê¥Õ¥¡¥€¥ë»ÈÍÑÈ¿±Ç
|
||||
MIDI_EnableMimpiDef(Config.ToneMap);
|
||||
|
||||
if (sdlaudio == 0 && !DSound_Init(Config.SampleRate, Config.BufferSize)) {
|
||||
@@ -760,7 +767,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
DSound_Play();
|
||||
|
||||
// command line から指定した場合
|
||||
// command line €«€é»ØÄꀷ€¿Ÿì¹ç
|
||||
switch (argc) {
|
||||
case 3:
|
||||
strcpy(Config.FDDImage[1], argv[2]);
|
||||
@@ -914,7 +921,7 @@ int main(int argc, char *argv[])
|
||||
if (menu_mode == menu_out
|
||||
&& Joystick_get_downstate_psp(PSP_CTRL_SELECT)) {
|
||||
Keyboard_ToggleSkbd();
|
||||
// 2度読み除け
|
||||
// 2ÅÙÆÉ€ßœü€±
|
||||
Joystick_reset_downstate_psp(PSP_CTRL_SELECT);
|
||||
}
|
||||
|
||||
@@ -1002,9 +1009,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
}
|
||||
end_loop:
|
||||
Memory_WriteB(0xe8e00d, 0x31); // SRAM書き込み許可
|
||||
Memory_WriteD(0xed0040, Memory_ReadD(0xed0040)+1); // 積算稼働時間(min.)
|
||||
Memory_WriteD(0xed0044, Memory_ReadD(0xed0044)+1); // 積算起動回数
|
||||
Memory_WriteB(0xe8e00d, 0x31); // SRAMœñ€¹þ€ßµö²Ä
|
||||
Memory_WriteD(0xed0040, Memory_ReadD(0xed0040)+1); // ÀÑ»»²ÔƯ»þŽÖ(min.)
|
||||
Memory_WriteD(0xed0044, Memory_ReadD(0xed0044)+1); // ÀÑ»»µ¯Æ°²ó¿ô
|
||||
|
||||
OPM_Cleanup();
|
||||
#ifndef NO_MERCURY
|
||||
|
||||
+78
-4
@@ -34,15 +34,16 @@ DWORD FASTCALL IRQH_DefaultVector(BYTE irq)
|
||||
// -----------------------------------------------------------------------
|
||||
void IRQH_IRQCallBack(BYTE irq)
|
||||
{
|
||||
#if 0
|
||||
int i;
|
||||
IRQH_IRQ[irq] = 0;
|
||||
C68k_Set_IRQ(&C68K, 0, 0);
|
||||
C68k_Set_IRQ(&C68K, 0);
|
||||
for (i=7; i>0; i--)
|
||||
{
|
||||
if (IRQH_IRQ[i])
|
||||
{
|
||||
C68k_Set_IRQ_Callback(&C68K, IRQH_CallBack[i]);
|
||||
C68k_Set_IRQ(&C68K, i, HOLD_LINE); // xxx
|
||||
C68k_Set_IRQ(&C68K, i); // xxx
|
||||
if ( C68K.ICount) { // 多重割り込み時(CARAT)
|
||||
m68000_ICountBk += C68K.ICount; // 強制的に割り込みチェックをさせる
|
||||
C68K.ICount = 0; // 苦肉の策 ^^;
|
||||
@@ -50,15 +51,28 @@ void IRQH_IRQCallBack(BYTE irq)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
IRQH_IRQ[irq&7] = 0;
|
||||
int i;
|
||||
C68k_Set_IRQ(&C68K, 0);
|
||||
for (i=7; i>0; i--)
|
||||
{
|
||||
if (IRQH_IRQ[i])
|
||||
{
|
||||
C68k_Set_IRQ(&C68K, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// 割り込み発生
|
||||
// -----------------------------------------------------------------------
|
||||
void IRQH_Int(BYTE irq, void* handler)
|
||||
{
|
||||
int i;
|
||||
#if 0
|
||||
int i;
|
||||
IRQH_IRQ[irq] = 1;
|
||||
if (handler==NULL)
|
||||
IRQH_CallBack[irq] = &IRQH_DefaultVector;
|
||||
@@ -77,4 +91,64 @@ void IRQH_Int(BYTE irq, void* handler)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
int i;
|
||||
IRQH_IRQ[irq&7] = 1;
|
||||
if (handler==NULL)
|
||||
IRQH_CallBack[irq&7] = &IRQH_DefaultVector;
|
||||
else
|
||||
IRQH_CallBack[irq&7] = handler;
|
||||
for (i=7; i>0; i--)
|
||||
{
|
||||
if (IRQH_IRQ[i])
|
||||
{
|
||||
C68k_Set_IRQ(&C68K, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
int i;
|
||||
IRQH_IRQ[irq&7] = 1;
|
||||
if (handler==NULL)
|
||||
IRQH_CallBack[irq&7] = &IRQH_DefaultVector;
|
||||
else
|
||||
IRQH_CallBack[irq&7] = handler;
|
||||
C68k_Set_IRQ(&C68K, irq&7);
|
||||
#endif
|
||||
}
|
||||
|
||||
s32 my_irqh_callback(s32 level)
|
||||
{
|
||||
#if 0
|
||||
int i;
|
||||
int vect = -1;
|
||||
for (i=7; i>0; i--)
|
||||
{
|
||||
if (IRQH_IRQ[i])
|
||||
{
|
||||
IRQH_IRQ[level&7] = 0;
|
||||
C68K_INT_CALLBACK *func = IRQH_CallBack[i];
|
||||
vect = (func)(level&7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int i;
|
||||
C68K_INT_CALLBACK *func = IRQH_CallBack[level&7];
|
||||
int vect = (func)(level&7);
|
||||
//printf("irq vect = %x line = %d\n", vect, level);
|
||||
|
||||
for (i=7; i>0; i--)
|
||||
{
|
||||
if (IRQH_IRQ[i])
|
||||
{
|
||||
C68k_Set_IRQ(&C68K, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (s32)vect;
|
||||
}
|
||||
+8
-3
@@ -362,6 +362,7 @@ cpu_readmem24(DWORD addr)
|
||||
|
||||
v = rm_main(addr);
|
||||
if (BusErrFlag & 1) {
|
||||
printf("func = %s addr = %x flag = %d\n", __func__, addr, BusErrFlag);
|
||||
Memory_ErrTrace();
|
||||
BusError(addr, 0);
|
||||
}
|
||||
@@ -383,6 +384,7 @@ cpu_readmem24_word(DWORD addr)
|
||||
v = rm_main(addr++) << 8;
|
||||
v |= rm_main(addr);
|
||||
if (BusErrFlag & 1) {
|
||||
printf("func = %s addr = %x flag = %d\n", __func__, addr, BusErrFlag);
|
||||
Memory_ErrTrace();
|
||||
BusError(addr, 0);
|
||||
}
|
||||
@@ -398,6 +400,7 @@ cpu_readmem24_dword(DWORD addr)
|
||||
|
||||
if (addr & 1) {
|
||||
BusErrFlag = 3;
|
||||
printf("func = %s addr = %x\n", __func__, addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -477,6 +480,7 @@ rm_e82(DWORD addr)
|
||||
static BYTE FASTCALL
|
||||
rm_buserr(DWORD addr)
|
||||
{
|
||||
printf("func = %s addr = %x flag = %d\n", __func__, addr, BusErrFlag);
|
||||
|
||||
BusErrFlag = 1;
|
||||
BusErrAdr = addr;
|
||||
@@ -490,7 +494,8 @@ rm_buserr(DWORD addr)
|
||||
void Memory_Init(void)
|
||||
{
|
||||
|
||||
cpu_setOPbase24((DWORD)C68k_Get_Reg(&C68K, C68K_PC));
|
||||
// cpu_setOPbase24((DWORD)C68k_Get_Reg(&C68K, C68K_PC));
|
||||
cpu_setOPbase24((DWORD)C68k_Get_PC(&C68K));
|
||||
}
|
||||
|
||||
void FASTCALL
|
||||
@@ -582,7 +587,7 @@ AdrError(DWORD adr, DWORD unknown)
|
||||
|
||||
(void)adr;
|
||||
(void)unknown;
|
||||
printf("AdrError: %d\n", adr);
|
||||
printf("AdrError: %x\n", adr);
|
||||
// assert(0);
|
||||
}
|
||||
|
||||
@@ -593,7 +598,7 @@ BusError(DWORD adr, DWORD unknown)
|
||||
(void)adr;
|
||||
(void)unknown;
|
||||
|
||||
printf("BusError: %d\n", adr);
|
||||
printf("BusError: %x\n", adr);
|
||||
BusErrHandling = 1;
|
||||
//assert(0);
|
||||
}
|
||||
@@ -256,6 +256,7 @@ fclose(fp);
|
||||
else if ( adr>=0xecc100 )
|
||||
{ // Bus Error?
|
||||
BusErrFlag = 1;
|
||||
printf("func = %s addr = %x flag = %d\n", __func__, adr, BusErrFlag);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
+4
-2
@@ -222,7 +222,8 @@ BYTE FASTCALL SASI_Read(DWORD adr)
|
||||
if (hddtrace&&((SASI_Phase!=3)||(adr!=0xe96001))) {
|
||||
FILE *fp;
|
||||
fp=fopen("_trace68.txt", "a");
|
||||
fprintf(fp, "Read - Adr:%08X Ret:%02X Phase:%d BufPtr:%d (Time:%08X) @ $%08X\n", adr, ret, SASI_Phase, SASI_BufPtr, timeGetTime(), C68k_Get_Reg(&C68K, C68K_PC));
|
||||
//fprintf(fp, "Read - Adr:%08X Ret:%02X Phase:%d BufPtr:%d (Time:%08X) @ $%08X\n", adr, ret, SASI_Phase, SASI_BufPtr, timeGetTime(), C68k_Get_Reg(&C68K, C68K_PC));
|
||||
fprintf(fp, "Read - Adr:%08X Ret:%02X Phase:%d BufPtr:%d (Time:%08X) @ $%08X\n", adr, ret, SASI_Phase, SASI_BufPtr, timeGetTime(), C68k_Get_PC(&C68K));
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@@ -357,7 +358,8 @@ void FASTCALL SASI_Write(DWORD adr, BYTE data)
|
||||
if (hddtrace&&((SASI_Phase!=3)||(adr!=0xe96001))) {
|
||||
FILE *fp;
|
||||
fp=fopen("_trace68.txt", "a");
|
||||
fprintf(fp, "Write - Adr:%08X Data:%02X Phase:%d (Time:%08X) @ $%08X\n", adr, data, SASI_Phase, timeGetTime(), C68k_Get_Reg(&C68K, C68K_PC));
|
||||
//fprintf(fp, "Write - Adr:%08X Data:%02X Phase:%d (Time:%08X) @ $%08X\n", adr, data, SASI_Phase, timeGetTime(), C68k_Get_Reg(&C68K, C68K_PC));
|
||||
fprintf(fp, "Write - Adr:%08X Data:%02X Phase:%d (Time:%08X) @ $%08X\n", adr, data, SASI_Phase, timeGetTime(), C68k_Get_PC(&C68K));
|
||||
fclose(fp);
|
||||
}
|
||||
if ( (adr==0xe96007)&&(SASI_Phase==0) )
|
||||
|
||||
Reference in new issue
Block a user