mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
updated Musashi to MAME 0.117
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@188 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
60305cdd4d
commit
c6a4c89286
13 changed files with 331 additions and 38681 deletions
|
@ -3,10 +3,10 @@
|
|||
/* ======================================================================== */
|
||||
/*
|
||||
* MUSASHI
|
||||
* Version 3.3
|
||||
* Version 3.31
|
||||
*
|
||||
* A portable Motorola M680x0 processor emulation engine.
|
||||
* Copyright 1998-2001 Karl Stenerud. All rights reserved.
|
||||
* Copyright 1998-2007 Karl Stenerud. All rights reserved.
|
||||
*
|
||||
* This code may be freely used for non-commercial purposes as long as this
|
||||
* copyright notice remains unaltered in the source code and any binary files
|
||||
|
@ -52,7 +52,7 @@
|
|||
*/
|
||||
|
||||
|
||||
const char* g_version = "3.3";
|
||||
static const char* g_version = "3.31";
|
||||
|
||||
/* ======================================================================== */
|
||||
/* =============================== INCLUDES =============================== */
|
||||
|
@ -88,9 +88,6 @@ const char* g_version = "3.3";
|
|||
#define FILENAME_INPUT "m68k_in.c"
|
||||
#define FILENAME_PROTOTYPE "m68kops.h"
|
||||
#define FILENAME_TABLE "m68kops.c"
|
||||
#define FILENAME_OPS_AC "m68kopac.c"
|
||||
#define FILENAME_OPS_DM "m68kopdm.c"
|
||||
#define FILENAME_OPS_NZ "m68kopnz.c"
|
||||
|
||||
|
||||
/* Identifier sequences recognized by this program */
|
||||
|
@ -240,7 +237,7 @@ void set_opcode_struct(opcode_struct* src, opcode_struct* dst, int ea_mode);
|
|||
void generate_opcode_handler(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* opinfo, int ea_mode);
|
||||
void generate_opcode_ea_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op);
|
||||
void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct* replace, opcode_struct* op_in, int offset);
|
||||
void process_opcode_handlers(void);
|
||||
void process_opcode_handlers(FILE* filep);
|
||||
void populate_table(void);
|
||||
void read_insert(char* insert);
|
||||
|
||||
|
@ -257,9 +254,6 @@ char g_input_filename[M68K_MAX_PATH] = FILENAME_INPUT;
|
|||
FILE* g_input_file = NULL;
|
||||
FILE* g_prototype_file = NULL;
|
||||
FILE* g_table_file = NULL;
|
||||
FILE* g_ops_ac_file = NULL;
|
||||
FILE* g_ops_dm_file = NULL;
|
||||
FILE* g_ops_nz_file = NULL;
|
||||
|
||||
int g_num_functions = 0; /* Number of functions processed */
|
||||
int g_num_primitives = 0; /* Number of function primitives read */
|
||||
|
@ -481,9 +475,6 @@ void error_exit(const char* fmt, ...)
|
|||
|
||||
if(g_prototype_file) fclose(g_prototype_file);
|
||||
if(g_table_file) fclose(g_table_file);
|
||||
if(g_ops_ac_file) fclose(g_ops_ac_file);
|
||||
if(g_ops_dm_file) fclose(g_ops_dm_file);
|
||||
if(g_ops_nz_file) fclose(g_ops_nz_file);
|
||||
if(g_input_file) fclose(g_input_file);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -500,9 +491,6 @@ void perror_exit(const char* fmt, ...)
|
|||
|
||||
if(g_prototype_file) fclose(g_prototype_file);
|
||||
if(g_table_file) fclose(g_table_file);
|
||||
if(g_ops_ac_file) fclose(g_ops_ac_file);
|
||||
if(g_ops_dm_file) fclose(g_ops_dm_file);
|
||||
if(g_ops_nz_file) fclose(g_ops_nz_file);
|
||||
if(g_input_file) fclose(g_input_file);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -1001,10 +989,9 @@ void generate_opcode_cc_variants(FILE* filep, body_struct* body, replace_struct*
|
|||
}
|
||||
|
||||
/* Process the opcode handlers section of the input file */
|
||||
void process_opcode_handlers(void)
|
||||
void process_opcode_handlers(FILE* filep)
|
||||
{
|
||||
FILE* input_file = g_input_file;
|
||||
FILE* output_file;
|
||||
char func_name[MAX_LINE_LENGTH+1];
|
||||
char oper_name[MAX_LINE_LENGTH+1];
|
||||
int oper_size;
|
||||
|
@ -1014,9 +1001,6 @@ void process_opcode_handlers(void)
|
|||
replace_struct* replace = malloc(sizeof(replace_struct));
|
||||
body_struct* body = malloc(sizeof(body_struct));
|
||||
|
||||
|
||||
output_file = g_ops_ac_file;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
/* Find the first line of the function */
|
||||
|
@ -1059,23 +1043,17 @@ void process_opcode_handlers(void)
|
|||
if(opinfo == NULL)
|
||||
error_exit("Unable to find matching table entry for %s", func_name);
|
||||
|
||||
/* Change output files if we pass 'c' or 'n' */
|
||||
if(output_file == g_ops_ac_file && oper_name[0] > 'c')
|
||||
output_file = g_ops_dm_file;
|
||||
else if(output_file == g_ops_dm_file && oper_name[0] > 'm')
|
||||
output_file = g_ops_nz_file;
|
||||
|
||||
replace->length = 0;
|
||||
|
||||
/* Generate opcode variants */
|
||||
if(strcmp(opinfo->name, "bcc") == 0 || strcmp(opinfo->name, "scc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 1);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 1);
|
||||
else if(strcmp(opinfo->name, "dbcc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 2);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 2);
|
||||
else if(strcmp(opinfo->name, "trapcc") == 0)
|
||||
generate_opcode_cc_variants(output_file, body, replace, opinfo, 4);
|
||||
generate_opcode_cc_variants(filep, body, replace, opinfo, 4);
|
||||
else
|
||||
generate_opcode_ea_variants(output_file, body, replace, opinfo);
|
||||
generate_opcode_ea_variants(filep, body, replace, opinfo);
|
||||
}
|
||||
|
||||
free(replace);
|
||||
|
@ -1248,7 +1226,9 @@ int main(int argc, char **argv)
|
|||
/* Inserts */
|
||||
char temp_insert[MAX_INSERT_LENGTH+1];
|
||||
char prototype_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
char table_header_insert[MAX_INSERT_LENGTH+1];
|
||||
char table_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
char ophandler_header_insert[MAX_INSERT_LENGTH+1];
|
||||
char ophandler_footer_insert[MAX_INSERT_LENGTH+1];
|
||||
/* Flags if we've processed certain parts already */
|
||||
int prototype_header_read = 0;
|
||||
|
@ -1260,8 +1240,8 @@ int main(int argc, char **argv)
|
|||
int table_body_read = 0;
|
||||
int ophandler_body_read = 0;
|
||||
|
||||
printf("\n\t\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020 emulator\n", g_version);
|
||||
printf("\t\tCopyright 1998-2000 Karl Stenerud (karl@mame.net)\n\n");
|
||||
printf("\n\tMusashi v%s 68000, 68008, 68010, 68EC020, 68020, 68040 emulator\n", g_version);
|
||||
printf("\tCopyright 1998-2007 Karl Stenerud (karl@mame.net)\n\n");
|
||||
|
||||
/* Check if output path and source for the input file are given */
|
||||
if(argc > 1)
|
||||
|
@ -1293,18 +1273,6 @@ int main(int argc, char **argv)
|
|||
if((g_table_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create table file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);
|
||||
if((g_ops_ac_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops ac file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);
|
||||
if((g_ops_dm_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops dm file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);
|
||||
if((g_ops_nz_file = fopen(filename, "w")) == NULL)
|
||||
perror_exit("Unable to create ops nz file (%s)\n", filename);
|
||||
|
||||
if((g_input_file=fopen(g_input_filename, "r")) == NULL)
|
||||
perror_exit("can't open %s for input", g_input_filename);
|
||||
|
||||
|
@ -1320,18 +1288,6 @@ int main(int argc, char **argv)
|
|||
if((g_table_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create table file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_AC);
|
||||
if((g_ops_ac_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops ac file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_DM);
|
||||
if((g_ops_dm_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops dm file (%s)\n", filename);
|
||||
|
||||
sprintf(filename, "%s%s", output_path, FILENAME_OPS_NZ);
|
||||
if((g_ops_nz_file = fopen(filename, "wt")) == NULL)
|
||||
perror_exit("Unable to create ops nz file (%s)\n", filename);
|
||||
|
||||
if((g_input_file=fopen(g_input_filename, "rt")) == NULL)
|
||||
perror_exit("can't open %s for input", g_input_filename);
|
||||
|
||||
|
@ -1360,18 +1316,14 @@ int main(int argc, char **argv)
|
|||
{
|
||||
if(table_header_read)
|
||||
error_exit("Duplicate table header");
|
||||
read_insert(temp_insert);
|
||||
fprintf(g_table_file, "%s", temp_insert);
|
||||
read_insert(table_header_insert);
|
||||
table_header_read = 1;
|
||||
}
|
||||
else if(strcmp(section_id, ID_OPHANDLER_HEADER) == 0)
|
||||
{
|
||||
if(ophandler_header_read)
|
||||
error_exit("Duplicate opcode handler header");
|
||||
read_insert(temp_insert);
|
||||
fprintf(g_ops_ac_file, "%s\n\n", temp_insert);
|
||||
fprintf(g_ops_dm_file, "%s\n\n", temp_insert);
|
||||
fprintf(g_ops_nz_file, "%s\n\n", temp_insert);
|
||||
read_insert(ophandler_header_insert);
|
||||
ophandler_header_read = 1;
|
||||
}
|
||||
else if(strcmp(section_id, ID_PROTOTYPE_FOOTER) == 0)
|
||||
|
@ -1424,7 +1376,9 @@ int main(int argc, char **argv)
|
|||
if(ophandler_body_read)
|
||||
error_exit("Duplicate opcode handler section");
|
||||
|
||||
process_opcode_handlers();
|
||||
fprintf(g_table_file, "%s\n\n", ophandler_header_insert);
|
||||
process_opcode_handlers(g_table_file);
|
||||
fprintf(g_table_file, "%s\n\n", ophandler_footer_insert);
|
||||
|
||||
ophandler_body_read = 1;
|
||||
}
|
||||
|
@ -1448,13 +1402,11 @@ int main(int argc, char **argv)
|
|||
if(!ophandler_body_read)
|
||||
error_exit("Missing opcode handler body");
|
||||
|
||||
fprintf(g_table_file, "%s\n\n", table_header_insert);
|
||||
print_opcode_output_table(g_table_file);
|
||||
fprintf(g_table_file, "%s\n\n", table_footer_insert);
|
||||
|
||||
fprintf(g_prototype_file, "%s\n\n", prototype_footer_insert);
|
||||
fprintf(g_table_file, "%s\n\n", table_footer_insert);
|
||||
fprintf(g_ops_ac_file, "%s\n\n", ophandler_footer_insert);
|
||||
fprintf(g_ops_dm_file, "%s\n\n", ophandler_footer_insert);
|
||||
fprintf(g_ops_nz_file, "%s\n\n", ophandler_footer_insert);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1467,9 +1419,6 @@ int main(int argc, char **argv)
|
|||
/* Close all files and exit */
|
||||
fclose(g_prototype_file);
|
||||
fclose(g_table_file);
|
||||
fclose(g_ops_ac_file);
|
||||
fclose(g_ops_dm_file);
|
||||
fclose(g_ops_nz_file);
|
||||
fclose(g_input_file);
|
||||
|
||||
printf("Generated %d opcode handlers from %d primitives\n", g_num_functions, g_num_primitives);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue